@@ -566,7 +566,7 @@ |
||
566 | 566 | * |
567 | 567 | * @param int $id |
568 | 568 | * @param EEM_Soft_Delete_Base $model |
569 | - * @return boolean |
|
569 | + * @return integer |
|
570 | 570 | * @throws EE_Error |
571 | 571 | * @throws InvalidArgumentException |
572 | 572 | * @throws InvalidDataTypeException |
@@ -14,1299 +14,1299 @@ |
||
14 | 14 | class Extend_Registration_Form_Admin_Page extends Registration_Form_Admin_Page |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
19 | - */ |
|
20 | - public function __construct($routing = true) |
|
21 | - { |
|
22 | - define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS); |
|
23 | - define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS); |
|
24 | - define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
25 | - define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS); |
|
26 | - define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
27 | - parent::__construct($routing); |
|
28 | - } |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * @return void |
|
33 | - */ |
|
34 | - protected function _extend_page_config() |
|
35 | - { |
|
36 | - $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
|
37 | - $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) |
|
38 | - ? $this->_req_data['QST_ID'] : 0; |
|
39 | - $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) |
|
40 | - ? $this->_req_data['QSG_ID'] : 0; |
|
41 | - |
|
42 | - $new_page_routes = array( |
|
43 | - 'question_groups' => array( |
|
44 | - 'func' => '_question_groups_overview_list_table', |
|
45 | - 'capability' => 'ee_read_question_groups', |
|
46 | - ), |
|
47 | - 'add_question' => array( |
|
48 | - 'func' => '_edit_question', |
|
49 | - 'capability' => 'ee_edit_questions', |
|
50 | - ), |
|
51 | - 'insert_question' => array( |
|
52 | - 'func' => '_insert_or_update_question', |
|
53 | - 'args' => array('new_question' => true), |
|
54 | - 'capability' => 'ee_edit_questions', |
|
55 | - 'noheader' => true, |
|
56 | - ), |
|
57 | - 'duplicate_question' => array( |
|
58 | - 'func' => '_duplicate_question', |
|
59 | - 'capability' => 'ee_edit_questions', |
|
60 | - 'noheader' => true, |
|
61 | - ), |
|
62 | - 'trash_question' => array( |
|
63 | - 'func' => '_trash_question', |
|
64 | - 'capability' => 'ee_delete_question', |
|
65 | - 'obj_id' => $qst_id, |
|
66 | - 'noheader' => true, |
|
67 | - ), |
|
68 | - |
|
69 | - 'restore_question' => array( |
|
70 | - 'func' => '_trash_or_restore_questions', |
|
71 | - 'capability' => 'ee_delete_question', |
|
72 | - 'obj_id' => $qst_id, |
|
73 | - 'args' => array('trash' => false), |
|
74 | - 'noheader' => true, |
|
75 | - ), |
|
76 | - |
|
77 | - 'delete_question' => array( |
|
78 | - 'func' => '_delete_question', |
|
79 | - 'capability' => 'ee_delete_question', |
|
80 | - 'obj_id' => $qst_id, |
|
81 | - 'noheader' => true, |
|
82 | - ), |
|
83 | - |
|
84 | - 'trash_questions' => array( |
|
85 | - 'func' => '_trash_or_restore_questions', |
|
86 | - 'capability' => 'ee_delete_questions', |
|
87 | - 'args' => array('trash' => true), |
|
88 | - 'noheader' => true, |
|
89 | - ), |
|
90 | - |
|
91 | - 'restore_questions' => array( |
|
92 | - 'func' => '_trash_or_restore_questions', |
|
93 | - 'capability' => 'ee_delete_questions', |
|
94 | - 'args' => array('trash' => false), |
|
95 | - 'noheader' => true, |
|
96 | - ), |
|
97 | - |
|
98 | - 'delete_questions' => array( |
|
99 | - 'func' => '_delete_questions', |
|
100 | - 'args' => array(), |
|
101 | - 'capability' => 'ee_delete_questions', |
|
102 | - 'noheader' => true, |
|
103 | - ), |
|
104 | - |
|
105 | - 'add_question_group' => array( |
|
106 | - 'func' => '_edit_question_group', |
|
107 | - 'capability' => 'ee_edit_question_groups', |
|
108 | - ), |
|
109 | - |
|
110 | - 'edit_question_group' => array( |
|
111 | - 'func' => '_edit_question_group', |
|
112 | - 'capability' => 'ee_edit_question_group', |
|
113 | - 'obj_id' => $qsg_id, |
|
114 | - 'args' => array('edit'), |
|
115 | - ), |
|
116 | - |
|
117 | - 'delete_question_groups' => array( |
|
118 | - 'func' => '_delete_question_groups', |
|
119 | - 'capability' => 'ee_delete_question_groups', |
|
120 | - 'noheader' => true, |
|
121 | - ), |
|
122 | - |
|
123 | - 'delete_question_group' => array( |
|
124 | - 'func' => '_delete_question_groups', |
|
125 | - 'capability' => 'ee_delete_question_group', |
|
126 | - 'obj_id' => $qsg_id, |
|
127 | - 'noheader' => true, |
|
128 | - ), |
|
129 | - |
|
130 | - 'trash_question_group' => array( |
|
131 | - 'func' => '_trash_or_restore_question_groups', |
|
132 | - 'args' => array('trash' => true), |
|
133 | - 'capability' => 'ee_delete_question_group', |
|
134 | - 'obj_id' => $qsg_id, |
|
135 | - 'noheader' => true, |
|
136 | - ), |
|
137 | - |
|
138 | - 'restore_question_group' => array( |
|
139 | - 'func' => '_trash_or_restore_question_groups', |
|
140 | - 'args' => array('trash' => false), |
|
141 | - 'capability' => 'ee_delete_question_group', |
|
142 | - 'obj_id' => $qsg_id, |
|
143 | - 'noheader' => true, |
|
144 | - ), |
|
145 | - |
|
146 | - 'insert_question_group' => array( |
|
147 | - 'func' => '_insert_or_update_question_group', |
|
148 | - 'args' => array('new_question_group' => true), |
|
149 | - 'capability' => 'ee_edit_question_groups', |
|
150 | - 'noheader' => true, |
|
151 | - ), |
|
152 | - |
|
153 | - 'update_question_group' => array( |
|
154 | - 'func' => '_insert_or_update_question_group', |
|
155 | - 'args' => array('new_question_group' => false), |
|
156 | - 'capability' => 'ee_edit_question_group', |
|
157 | - 'obj_id' => $qsg_id, |
|
158 | - 'noheader' => true, |
|
159 | - ), |
|
160 | - |
|
161 | - 'trash_question_groups' => array( |
|
162 | - 'func' => '_trash_or_restore_question_groups', |
|
163 | - 'args' => array('trash' => true), |
|
164 | - 'capability' => 'ee_delete_question_groups', |
|
165 | - 'noheader' => array('trash' => false), |
|
166 | - ), |
|
167 | - |
|
168 | - 'restore_question_groups' => array( |
|
169 | - 'func' => '_trash_or_restore_question_groups', |
|
170 | - 'args' => array('trash' => false), |
|
171 | - 'capability' => 'ee_delete_question_groups', |
|
172 | - 'noheader' => true, |
|
173 | - ), |
|
174 | - |
|
175 | - |
|
176 | - 'espresso_update_question_group_order' => array( |
|
177 | - 'func' => 'update_question_group_order', |
|
178 | - 'capability' => 'ee_edit_question_groups', |
|
179 | - 'noheader' => true, |
|
180 | - ), |
|
181 | - |
|
182 | - 'view_reg_form_settings' => array( |
|
183 | - 'func' => '_reg_form_settings', |
|
184 | - 'capability' => 'manage_options', |
|
185 | - ), |
|
186 | - |
|
187 | - 'update_reg_form_settings' => array( |
|
188 | - 'func' => '_update_reg_form_settings', |
|
189 | - 'capability' => 'manage_options', |
|
190 | - 'noheader' => true, |
|
191 | - ), |
|
192 | - ); |
|
193 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
194 | - |
|
195 | - $new_page_config = array( |
|
196 | - |
|
197 | - 'question_groups' => array( |
|
198 | - 'nav' => array( |
|
199 | - 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
200 | - 'order' => 20, |
|
201 | - ), |
|
202 | - 'list_table' => 'Registration_Form_Question_Groups_Admin_List_Table', |
|
203 | - 'help_tabs' => array( |
|
204 | - 'registration_form_question_groups_help_tab' => array( |
|
205 | - 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
206 | - 'filename' => 'registration_form_question_groups', |
|
207 | - ), |
|
208 | - 'registration_form_question_groups_table_column_headings_help_tab' => array( |
|
209 | - 'title' => esc_html__('Question Groups Table Column Headings', 'event_espresso'), |
|
210 | - 'filename' => 'registration_form_question_groups_table_column_headings', |
|
211 | - ), |
|
212 | - 'registration_form_question_groups_views_bulk_actions_search_help_tab' => array( |
|
213 | - 'title' => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'), |
|
214 | - 'filename' => 'registration_form_question_groups_views_bulk_actions_search', |
|
215 | - ), |
|
216 | - ), |
|
217 | - 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
218 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
219 | - 'require_nonce' => false, |
|
220 | - 'qtips' => array( |
|
221 | - 'EE_Registration_Form_Tips', |
|
222 | - ), |
|
223 | - ), |
|
224 | - |
|
225 | - 'add_question' => array( |
|
226 | - 'nav' => array( |
|
227 | - 'label' => esc_html__('Add Question', 'event_espresso'), |
|
228 | - 'order' => 5, |
|
229 | - 'persistent' => false, |
|
230 | - ), |
|
231 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
232 | - 'help_tabs' => array( |
|
233 | - 'registration_form_add_question_help_tab' => array( |
|
234 | - 'title' => esc_html__('Add Question', 'event_espresso'), |
|
235 | - 'filename' => 'registration_form_add_question', |
|
236 | - ), |
|
237 | - ), |
|
238 | - 'help_tour' => array('Registration_Form_Add_Question_Help_Tour'), |
|
239 | - 'require_nonce' => false, |
|
240 | - ), |
|
241 | - |
|
242 | - 'add_question_group' => array( |
|
243 | - 'nav' => array( |
|
244 | - 'label' => esc_html__('Add Question Group', 'event_espresso'), |
|
245 | - 'order' => 5, |
|
246 | - 'persistent' => false, |
|
247 | - ), |
|
248 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
249 | - 'help_tabs' => array( |
|
250 | - 'registration_form_add_question_group_help_tab' => array( |
|
251 | - 'title' => esc_html__('Add Question Group', 'event_espresso'), |
|
252 | - 'filename' => 'registration_form_add_question_group', |
|
253 | - ), |
|
254 | - ), |
|
255 | - 'help_tour' => array('Registration_Form_Add_Question_Group_Help_Tour'), |
|
256 | - 'require_nonce' => false, |
|
257 | - ), |
|
258 | - |
|
259 | - 'edit_question_group' => array( |
|
260 | - 'nav' => array( |
|
261 | - 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
|
262 | - 'order' => 5, |
|
263 | - 'persistent' => false, |
|
264 | - 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg( |
|
265 | - array('question_group_id' => $this->_req_data['question_group_id']), |
|
266 | - $this->_current_page_view_url |
|
267 | - ) : $this->_admin_base_url, |
|
268 | - ), |
|
269 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
270 | - 'help_tabs' => array( |
|
271 | - 'registration_form_edit_question_group_help_tab' => array( |
|
272 | - 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
|
273 | - 'filename' => 'registration_form_edit_question_group', |
|
274 | - ), |
|
275 | - ), |
|
276 | - 'help_tour' => array('Registration_Form_Edit_Question_Group_Help_Tour'), |
|
277 | - 'require_nonce' => false, |
|
278 | - ), |
|
279 | - |
|
280 | - 'view_reg_form_settings' => array( |
|
281 | - 'nav' => array( |
|
282 | - 'label' => esc_html__('Reg Form Settings', 'event_espresso'), |
|
283 | - 'order' => 40, |
|
284 | - ), |
|
285 | - 'labels' => array( |
|
286 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
287 | - ), |
|
288 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
289 | - 'help_tabs' => array( |
|
290 | - 'registration_form_reg_form_settings_help_tab' => array( |
|
291 | - 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
|
292 | - 'filename' => 'registration_form_reg_form_settings', |
|
293 | - ), |
|
294 | - ), |
|
295 | - 'help_tour' => array('Registration_Form_Settings_Help_Tour'), |
|
296 | - 'require_nonce' => false, |
|
297 | - ), |
|
298 | - |
|
299 | - ); |
|
300 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
301 | - |
|
302 | - // change the list table we're going to use so it's the NEW list table! |
|
303 | - $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
|
304 | - |
|
305 | - |
|
306 | - // additional labels |
|
307 | - $new_labels = array( |
|
308 | - 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
|
309 | - 'delete_question' => esc_html__('Delete Question', 'event_espresso'), |
|
310 | - 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
|
311 | - 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
|
312 | - 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
|
313 | - ); |
|
314 | - $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
315 | - } |
|
316 | - |
|
317 | - |
|
318 | - /** |
|
319 | - * @return void |
|
320 | - */ |
|
321 | - protected function _ajax_hooks() |
|
322 | - { |
|
323 | - add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order')); |
|
324 | - } |
|
325 | - |
|
326 | - |
|
327 | - /** |
|
328 | - * @return void |
|
329 | - */ |
|
330 | - public function load_scripts_styles_question_groups() |
|
331 | - { |
|
332 | - wp_enqueue_script('espresso_ajax_table_sorting'); |
|
333 | - } |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * @return void |
|
338 | - */ |
|
339 | - public function load_scripts_styles_add_question_group() |
|
340 | - { |
|
341 | - $this->load_scripts_styles_forms(); |
|
342 | - $this->load_sortable_question_script(); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * @return void |
|
348 | - */ |
|
349 | - public function load_scripts_styles_edit_question_group() |
|
350 | - { |
|
351 | - $this->load_scripts_styles_forms(); |
|
352 | - $this->load_sortable_question_script(); |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * registers and enqueues script for questions |
|
358 | - * |
|
359 | - * @return void |
|
360 | - */ |
|
361 | - public function load_sortable_question_script() |
|
362 | - { |
|
363 | - wp_register_script( |
|
364 | - 'ee-question-sortable', |
|
365 | - REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
366 | - array('jquery-ui-sortable'), |
|
367 | - EVENT_ESPRESSO_VERSION, |
|
368 | - true |
|
369 | - ); |
|
370 | - wp_enqueue_script('ee-question-sortable'); |
|
371 | - } |
|
372 | - |
|
373 | - |
|
374 | - /** |
|
375 | - * @return void |
|
376 | - */ |
|
377 | - protected function _set_list_table_views_default() |
|
378 | - { |
|
379 | - $this->_views = array( |
|
380 | - 'all' => array( |
|
381 | - 'slug' => 'all', |
|
382 | - 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
383 | - 'count' => 0, |
|
384 | - 'bulk_action' => array( |
|
385 | - 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
|
386 | - ), |
|
387 | - ), |
|
388 | - ); |
|
389 | - |
|
390 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
391 | - 'ee_delete_questions', |
|
392 | - 'espresso_registration_form_trash_questions' |
|
393 | - ) |
|
394 | - ) { |
|
395 | - $this->_views['trash'] = array( |
|
396 | - 'slug' => 'trash', |
|
397 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
398 | - 'count' => 0, |
|
399 | - 'bulk_action' => array( |
|
400 | - 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
|
401 | - 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
|
402 | - ), |
|
403 | - ); |
|
404 | - } |
|
405 | - } |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * @return void |
|
410 | - */ |
|
411 | - protected function _set_list_table_views_question_groups() |
|
412 | - { |
|
413 | - $this->_views = array( |
|
414 | - 'all' => array( |
|
415 | - 'slug' => 'all', |
|
416 | - 'label' => esc_html__('All', 'event_espresso'), |
|
417 | - 'count' => 0, |
|
418 | - 'bulk_action' => array( |
|
419 | - 'trash_question_groups' => esc_html__('Trash', 'event_espresso'), |
|
420 | - ), |
|
421 | - ), |
|
422 | - ); |
|
423 | - |
|
424 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
425 | - 'ee_delete_question_groups', |
|
426 | - 'espresso_registration_form_trash_question_groups' |
|
427 | - ) |
|
428 | - ) { |
|
429 | - $this->_views['trash'] = array( |
|
430 | - 'slug' => 'trash', |
|
431 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
432 | - 'count' => 0, |
|
433 | - 'bulk_action' => array( |
|
434 | - 'delete_question_groups' => esc_html__('Delete Permanently', 'event_espresso'), |
|
435 | - 'restore_question_groups' => esc_html__('Restore', 'event_espresso'), |
|
436 | - ), |
|
437 | - ); |
|
438 | - } |
|
439 | - } |
|
440 | - |
|
441 | - |
|
442 | - /** |
|
443 | - * @return void |
|
444 | - * @throws EE_Error |
|
445 | - * @throws InvalidArgumentException |
|
446 | - * @throws InvalidDataTypeException |
|
447 | - * @throws InvalidInterfaceException |
|
448 | - */ |
|
449 | - protected function _questions_overview_list_table() |
|
450 | - { |
|
451 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
452 | - 'add_question', |
|
453 | - 'add_question', |
|
454 | - array(), |
|
455 | - 'add-new-h2' |
|
456 | - ); |
|
457 | - parent::_questions_overview_list_table(); |
|
458 | - } |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * @return void |
|
463 | - * @throws DomainException |
|
464 | - * @throws EE_Error |
|
465 | - * @throws InvalidArgumentException |
|
466 | - * @throws InvalidDataTypeException |
|
467 | - * @throws InvalidInterfaceException |
|
468 | - */ |
|
469 | - protected function _question_groups_overview_list_table() |
|
470 | - { |
|
471 | - $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
|
472 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
473 | - 'add_question_group', |
|
474 | - 'add_question_group', |
|
475 | - array(), |
|
476 | - 'add-new-h2' |
|
477 | - ); |
|
478 | - $this->display_admin_list_table_page_with_sidebar(); |
|
479 | - } |
|
480 | - |
|
481 | - |
|
482 | - /** |
|
483 | - * @return void |
|
484 | - * @throws EE_Error |
|
485 | - * @throws InvalidArgumentException |
|
486 | - * @throws InvalidDataTypeException |
|
487 | - * @throws InvalidInterfaceException |
|
488 | - */ |
|
489 | - protected function _delete_question() |
|
490 | - { |
|
491 | - $success = $this->_delete_items($this->_question_model); |
|
492 | - $this->_redirect_after_action( |
|
493 | - $success, |
|
494 | - $this->_question_model->item_name($success), |
|
495 | - 'deleted', |
|
496 | - array('action' => 'default', 'status' => 'all') |
|
497 | - ); |
|
498 | - } |
|
499 | - |
|
500 | - |
|
501 | - /** |
|
502 | - * @return void |
|
503 | - * @throws EE_Error |
|
504 | - * @throws InvalidArgumentException |
|
505 | - * @throws InvalidDataTypeException |
|
506 | - * @throws InvalidInterfaceException |
|
507 | - */ |
|
508 | - protected function _delete_questions() |
|
509 | - { |
|
510 | - $success = $this->_delete_items($this->_question_model); |
|
511 | - $this->_redirect_after_action( |
|
512 | - $success, |
|
513 | - $this->_question_model->item_name($success), |
|
514 | - 'deleted permanently', |
|
515 | - array('action' => 'default', 'status' => 'trash') |
|
516 | - ); |
|
517 | - } |
|
518 | - |
|
519 | - |
|
520 | - /** |
|
521 | - * Performs the deletion of a single or multiple questions or question groups. |
|
522 | - * |
|
523 | - * @param EEM_Soft_Delete_Base $model |
|
524 | - * @return int number of items deleted permanently |
|
525 | - * @throws EE_Error |
|
526 | - * @throws InvalidArgumentException |
|
527 | - * @throws InvalidDataTypeException |
|
528 | - * @throws InvalidInterfaceException |
|
529 | - */ |
|
530 | - private function _delete_items(EEM_Soft_Delete_Base $model) |
|
531 | - { |
|
532 | - $success = 0; |
|
533 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
534 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
535 | - // if array has more than one element than success message should be plural |
|
536 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
537 | - // cycle thru bulk action checkboxes |
|
538 | - while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
539 | - if (! $this->_delete_item($ID, $model)) { |
|
540 | - $success = 0; |
|
541 | - } |
|
542 | - } |
|
543 | - } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
544 | - $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
545 | - } elseif (! empty($this->_req_data['QST_ID'])) { |
|
546 | - $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
547 | - } else { |
|
548 | - EE_Error::add_error( |
|
549 | - sprintf( |
|
550 | - esc_html__( |
|
551 | - "No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", |
|
552 | - "event_espresso" |
|
553 | - ) |
|
554 | - ), |
|
555 | - __FILE__, |
|
556 | - __FUNCTION__, |
|
557 | - __LINE__ |
|
558 | - ); |
|
559 | - } |
|
560 | - return $success; |
|
561 | - } |
|
562 | - |
|
563 | - |
|
564 | - /** |
|
565 | - * Deletes the specified question (and its associated question options) or question group |
|
566 | - * |
|
567 | - * @param int $id |
|
568 | - * @param EEM_Soft_Delete_Base $model |
|
569 | - * @return boolean |
|
570 | - * @throws EE_Error |
|
571 | - * @throws InvalidArgumentException |
|
572 | - * @throws InvalidDataTypeException |
|
573 | - * @throws InvalidInterfaceException |
|
574 | - */ |
|
575 | - protected function _delete_item($id, $model) |
|
576 | - { |
|
577 | - if ($model instanceof EEM_Question) { |
|
578 | - EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id)))); |
|
579 | - } |
|
580 | - return $model->delete_permanently_by_ID(absint($id)); |
|
581 | - } |
|
582 | - |
|
583 | - |
|
584 | - /****************************** QUESTION GROUPS ******************************/ |
|
585 | - |
|
586 | - |
|
587 | - /** |
|
588 | - * @param string $type |
|
589 | - * @return void |
|
590 | - * @throws DomainException |
|
591 | - * @throws EE_Error |
|
592 | - * @throws InvalidArgumentException |
|
593 | - * @throws InvalidDataTypeException |
|
594 | - * @throws InvalidInterfaceException |
|
595 | - */ |
|
596 | - protected function _edit_question_group($type = 'add') |
|
597 | - { |
|
598 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
599 | - $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) |
|
600 | - ? absint($this->_req_data['QSG_ID']) |
|
601 | - : false; |
|
602 | - |
|
603 | - switch ($this->_req_action) { |
|
604 | - case 'add_question_group': |
|
605 | - $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
606 | - break; |
|
607 | - case 'edit_question_group': |
|
608 | - $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
609 | - break; |
|
610 | - default: |
|
611 | - $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
612 | - } |
|
613 | - // add ID to title if editing |
|
614 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
615 | - if ($ID) { |
|
616 | - /** @var EE_Question_Group $questionGroup */ |
|
617 | - $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
618 | - $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
619 | - $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
|
620 | - } else { |
|
621 | - /** @var EE_Question_Group $questionGroup */ |
|
622 | - $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
|
623 | - $questionGroup->set_order_to_latest(); |
|
624 | - $this->_set_add_edit_form_tags('insert_question_group'); |
|
625 | - } |
|
626 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
627 | - $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
628 | - $this->_template_args['QSG_ID'] = $ID ? $ID : true; |
|
629 | - $this->_template_args['question_group'] = $questionGroup; |
|
630 | - |
|
631 | - $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
|
632 | - $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL); |
|
633 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
634 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
635 | - $this->_template_args, |
|
636 | - true |
|
637 | - ); |
|
638 | - |
|
639 | - // the details template wrapper |
|
640 | - $this->display_admin_page_with_sidebar(); |
|
641 | - } |
|
642 | - |
|
643 | - |
|
644 | - /** |
|
645 | - * @return void |
|
646 | - * @throws EE_Error |
|
647 | - * @throws InvalidArgumentException |
|
648 | - * @throws InvalidDataTypeException |
|
649 | - * @throws InvalidInterfaceException |
|
650 | - */ |
|
651 | - protected function _delete_question_groups() |
|
652 | - { |
|
653 | - $success = $this->_delete_items($this->_question_group_model); |
|
654 | - $this->_redirect_after_action( |
|
655 | - $success, |
|
656 | - $this->_question_group_model->item_name($success), |
|
657 | - 'deleted permanently', |
|
658 | - array('action' => 'question_groups', 'status' => 'trash') |
|
659 | - ); |
|
660 | - } |
|
661 | - |
|
662 | - |
|
663 | - /** |
|
664 | - * @param bool $new_question_group |
|
665 | - * @throws EE_Error |
|
666 | - * @throws InvalidArgumentException |
|
667 | - * @throws InvalidDataTypeException |
|
668 | - * @throws InvalidInterfaceException |
|
669 | - */ |
|
670 | - protected function _insert_or_update_question_group($new_question_group = true) |
|
671 | - { |
|
672 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
673 | - $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
674 | - if ($new_question_group) { |
|
675 | - $QSG_ID = $this->_question_group_model->insert($set_column_values); |
|
676 | - $success = $QSG_ID ? 1 : 0; |
|
677 | - } else { |
|
678 | - $QSG_ID = absint($this->_req_data['QSG_ID']); |
|
679 | - unset($set_column_values['QSG_ID']); |
|
680 | - $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID))); |
|
681 | - } |
|
682 | - $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( |
|
683 | - EEM_Attendee::system_question_phone |
|
684 | - ); |
|
685 | - // update the existing related questions |
|
686 | - // BUT FIRST... delete the phone question from the Question_Group_Question |
|
687 | - // if it is being added to this question group (therefore removed from the existing group) |
|
688 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) { |
|
689 | - // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
|
690 | - EEM_Question_Group_Question::instance()->delete( |
|
691 | - array( |
|
692 | - array( |
|
693 | - 'QST_ID' => $phone_question_id, |
|
694 | - 'QSG_ID' => array('!=', $QSG_ID), |
|
695 | - ), |
|
696 | - ) |
|
697 | - ); |
|
698 | - } |
|
699 | - /** @type EE_Question_Group $question_group */ |
|
700 | - $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
701 | - $questions = $question_group->questions(); |
|
702 | - // make sure system phone question is added to list of questions for this group |
|
703 | - if (! isset($questions[ $phone_question_id ])) { |
|
704 | - $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
705 | - } |
|
706 | - |
|
707 | - foreach ($questions as $question_ID => $question) { |
|
708 | - // first we always check for order. |
|
709 | - if (! empty($this->_req_data['question_orders'][ $question_ID ])) { |
|
710 | - // update question order |
|
711 | - $question_group->update_question_order( |
|
712 | - $question_ID, |
|
713 | - $this->_req_data['question_orders'][ $question_ID ] |
|
714 | - ); |
|
715 | - } |
|
716 | - |
|
717 | - // then we always check if adding or removing. |
|
718 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) { |
|
719 | - $question_group->add_question($question_ID); |
|
720 | - } else { |
|
721 | - // not found, remove it (but only if not a system question for the personal group |
|
722 | - // with the exception of lname system question - we allow removal of it) |
|
723 | - if (in_array( |
|
724 | - $question->system_ID(), |
|
725 | - EEM_Question::instance()->required_system_questions_in_system_question_group( |
|
726 | - $question_group->system_group() |
|
727 | - ) |
|
728 | - )) { |
|
729 | - continue; |
|
730 | - } else { |
|
731 | - $question_group->remove_question($question_ID); |
|
732 | - } |
|
733 | - } |
|
734 | - } |
|
735 | - // save new related questions |
|
736 | - if (isset($this->_req_data['questions'])) { |
|
737 | - foreach ($this->_req_data['questions'] as $QST_ID) { |
|
738 | - $question_group->add_question($QST_ID); |
|
739 | - if (isset($this->_req_data['question_orders'][ $QST_ID ])) { |
|
740 | - $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]); |
|
741 | - } |
|
742 | - } |
|
743 | - } |
|
744 | - |
|
745 | - if ($success !== false) { |
|
746 | - $msg = $new_question_group |
|
747 | - ? sprintf( |
|
748 | - esc_html__('The %s has been created', 'event_espresso'), |
|
749 | - $this->_question_group_model->item_name() |
|
750 | - ) |
|
751 | - : sprintf( |
|
752 | - esc_html__( |
|
753 | - 'The %s has been updated', |
|
754 | - 'event_espresso' |
|
755 | - ), |
|
756 | - $this->_question_group_model->item_name() |
|
757 | - ); |
|
758 | - EE_Error::add_success($msg); |
|
759 | - } |
|
760 | - $this->_redirect_after_action( |
|
761 | - false, |
|
762 | - '', |
|
763 | - '', |
|
764 | - array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
765 | - true |
|
766 | - ); |
|
767 | - } |
|
768 | - |
|
769 | - |
|
770 | - /** |
|
771 | - * duplicates a question and all its question options and redirects to the new question. |
|
772 | - * |
|
773 | - * @return void |
|
774 | - * @throws EE_Error |
|
775 | - * @throws InvalidArgumentException |
|
776 | - * @throws ReflectionException |
|
777 | - * @throws InvalidDataTypeException |
|
778 | - * @throws InvalidInterfaceException |
|
779 | - */ |
|
780 | - public function _duplicate_question() |
|
781 | - { |
|
782 | - $question_ID = (int) $this->_req_data['QST_ID']; |
|
783 | - $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
784 | - if ($question instanceof EE_Question) { |
|
785 | - $new_question = $question->duplicate(); |
|
786 | - if ($new_question instanceof EE_Question) { |
|
787 | - $this->_redirect_after_action( |
|
788 | - true, |
|
789 | - esc_html__('Question', 'event_espresso'), |
|
790 | - esc_html__('Duplicated', 'event_espresso'), |
|
791 | - array('action' => 'edit_question', 'QST_ID' => $new_question->ID()), |
|
792 | - true |
|
793 | - ); |
|
794 | - } else { |
|
795 | - global $wpdb; |
|
796 | - EE_Error::add_error( |
|
797 | - sprintf( |
|
798 | - esc_html__( |
|
799 | - 'Could not duplicate question with ID %1$d because: %2$s', |
|
800 | - 'event_espresso' |
|
801 | - ), |
|
802 | - $question_ID, |
|
803 | - $wpdb->last_error |
|
804 | - ), |
|
805 | - __FILE__, |
|
806 | - __FUNCTION__, |
|
807 | - __LINE__ |
|
808 | - ); |
|
809 | - $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
810 | - } |
|
811 | - } else { |
|
812 | - EE_Error::add_error( |
|
813 | - sprintf( |
|
814 | - esc_html__( |
|
815 | - 'Could not duplicate question with ID %d because it didn\'t exist!', |
|
816 | - 'event_espresso' |
|
817 | - ), |
|
818 | - $question_ID |
|
819 | - ), |
|
820 | - __FILE__, |
|
821 | - __FUNCTION__, |
|
822 | - __LINE__ |
|
823 | - ); |
|
824 | - $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
825 | - } |
|
826 | - } |
|
827 | - |
|
828 | - |
|
829 | - /** |
|
830 | - * @param bool $trash |
|
831 | - * @throws EE_Error |
|
832 | - */ |
|
833 | - protected function _trash_or_restore_question_groups($trash = true) |
|
834 | - { |
|
835 | - $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
836 | - } |
|
837 | - |
|
838 | - |
|
839 | - /** |
|
840 | - *_trash_question |
|
841 | - * |
|
842 | - * @return void |
|
843 | - * @throws EE_Error |
|
844 | - */ |
|
845 | - protected function _trash_question() |
|
846 | - { |
|
847 | - $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
848 | - $query_args = array('action' => 'default', 'status' => 'all'); |
|
849 | - $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
|
850 | - } |
|
851 | - |
|
852 | - |
|
853 | - /** |
|
854 | - * @param bool $trash |
|
855 | - * @throws EE_Error |
|
856 | - */ |
|
857 | - protected function _trash_or_restore_questions($trash = true) |
|
858 | - { |
|
859 | - $this->_trash_or_restore_items($this->_question_model, $trash); |
|
860 | - } |
|
861 | - |
|
862 | - |
|
863 | - /** |
|
864 | - * Internally used to delete or restore items, using the request data. Meant to be |
|
865 | - * flexible between question or question groups |
|
866 | - * |
|
867 | - * @param EEM_Soft_Delete_Base $model |
|
868 | - * @param boolean $trash whether to trash or restore |
|
869 | - * @throws EE_Error |
|
870 | - */ |
|
871 | - private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true) |
|
872 | - { |
|
873 | - |
|
874 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
875 | - |
|
876 | - $success = 1; |
|
877 | - // Checkboxes |
|
878 | - // echo "trash $trash"; |
|
879 | - // var_dump($this->_req_data['checkbox']);die; |
|
880 | - if (isset($this->_req_data['checkbox'])) { |
|
881 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
882 | - // if array has more than one element than success message should be plural |
|
883 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
884 | - // cycle thru bulk action checkboxes |
|
885 | - while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
886 | - if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
887 | - $success = 0; |
|
888 | - } |
|
889 | - } |
|
890 | - } else { |
|
891 | - // grab single id and delete |
|
892 | - $ID = absint($this->_req_data['checkbox']); |
|
893 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
894 | - $success = 0; |
|
895 | - } |
|
896 | - } |
|
897 | - } else { |
|
898 | - // delete via trash link |
|
899 | - // grab single id and delete |
|
900 | - $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
901 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
902 | - $success = 0; |
|
903 | - } |
|
904 | - } |
|
905 | - |
|
906 | - |
|
907 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) ); |
|
908 | - // echo "action :$action"; |
|
909 | - // $action = 'questions' ? 'default' : $action; |
|
910 | - if ($trash) { |
|
911 | - $action_desc = 'trashed'; |
|
912 | - $status = 'trash'; |
|
913 | - } else { |
|
914 | - $action_desc = 'restored'; |
|
915 | - $status = 'all'; |
|
916 | - } |
|
917 | - $this->_redirect_after_action( |
|
918 | - $success, |
|
919 | - $model->item_name($success), |
|
920 | - $action_desc, |
|
921 | - array('action' => $action, 'status' => $status) |
|
922 | - ); |
|
923 | - } |
|
924 | - |
|
925 | - |
|
926 | - /** |
|
927 | - * @param $per_page |
|
928 | - * @param int $current_page |
|
929 | - * @param bool|false $count |
|
930 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
931 | - * @throws EE_Error |
|
932 | - * @throws InvalidArgumentException |
|
933 | - * @throws InvalidDataTypeException |
|
934 | - * @throws InvalidInterfaceException |
|
935 | - */ |
|
936 | - public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
937 | - { |
|
938 | - $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
939 | - |
|
940 | - if ($count) { |
|
941 | - // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
942 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
943 | - $results = $this->_question_model->count_deleted($where); |
|
944 | - } else { |
|
945 | - // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
946 | - $results = $this->_question_model->get_all_deleted($query_params); |
|
947 | - } |
|
948 | - return $results; |
|
949 | - } |
|
950 | - |
|
951 | - |
|
952 | - /** |
|
953 | - * @param $per_page |
|
954 | - * @param int $current_page |
|
955 | - * @param bool|false $count |
|
956 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
957 | - * @throws EE_Error |
|
958 | - * @throws InvalidArgumentException |
|
959 | - * @throws InvalidDataTypeException |
|
960 | - * @throws InvalidInterfaceException |
|
961 | - */ |
|
962 | - public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
963 | - { |
|
964 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
965 | - $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
966 | - if ($count) { |
|
967 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
968 | - $results = $questionGroupModel->count($where); |
|
969 | - } else { |
|
970 | - $results = $questionGroupModel->get_all($query_params); |
|
971 | - } |
|
972 | - return $results; |
|
973 | - } |
|
974 | - |
|
975 | - |
|
976 | - /** |
|
977 | - * @param $per_page |
|
978 | - * @param int $current_page |
|
979 | - * @param bool $count |
|
980 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
981 | - * @throws EE_Error |
|
982 | - * @throws InvalidArgumentException |
|
983 | - * @throws InvalidDataTypeException |
|
984 | - * @throws InvalidInterfaceException |
|
985 | - */ |
|
986 | - public function get_trashed_question_groups($per_page, $current_page = 1, $count = false) |
|
987 | - { |
|
988 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
989 | - $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
990 | - if ($count) { |
|
991 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
992 | - $query_params['limit'] = null; |
|
993 | - $results = $questionGroupModel->count_deleted($where); |
|
994 | - } else { |
|
995 | - $results = $questionGroupModel->get_all_deleted($query_params); |
|
996 | - } |
|
997 | - return $results; |
|
998 | - } |
|
999 | - |
|
1000 | - |
|
1001 | - /** |
|
1002 | - * method for performing updates to question order |
|
1003 | - * |
|
1004 | - * @return void results array |
|
1005 | - * @throws EE_Error |
|
1006 | - * @throws InvalidArgumentException |
|
1007 | - * @throws InvalidDataTypeException |
|
1008 | - * @throws InvalidInterfaceException |
|
1009 | - */ |
|
1010 | - public function update_question_group_order() |
|
1011 | - { |
|
1012 | - |
|
1013 | - $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
1014 | - |
|
1015 | - // grab our row IDs |
|
1016 | - $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
1017 | - ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
1018 | - : array(); |
|
1019 | - |
|
1020 | - $perpage = ! empty($this->_req_data['perpage']) |
|
1021 | - ? (int) $this->_req_data['perpage'] |
|
1022 | - : null; |
|
1023 | - $curpage = ! empty($this->_req_data['curpage']) |
|
1024 | - ? (int) $this->_req_data['curpage'] |
|
1025 | - : null; |
|
1026 | - |
|
1027 | - if (! empty($row_ids)) { |
|
1028 | - // figure out where we start the row_id count at for the current page. |
|
1029 | - $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
1030 | - |
|
1031 | - $row_count = count($row_ids); |
|
1032 | - for ($i = 0; $i < $row_count; $i++) { |
|
1033 | - // Update the questions when re-ordering |
|
1034 | - $updated = EEM_Question_Group::instance()->update( |
|
1035 | - array('QSG_order' => $qsgcount), |
|
1036 | - array(array('QSG_ID' => $row_ids[ $i ])) |
|
1037 | - ); |
|
1038 | - if ($updated === false) { |
|
1039 | - $success = false; |
|
1040 | - } |
|
1041 | - $qsgcount++; |
|
1042 | - } |
|
1043 | - } else { |
|
1044 | - $success = false; |
|
1045 | - } |
|
1046 | - |
|
1047 | - $errors = ! $success |
|
1048 | - ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
1049 | - : false; |
|
1050 | - |
|
1051 | - echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors)); |
|
1052 | - die(); |
|
1053 | - } |
|
1054 | - |
|
1055 | - |
|
1056 | - |
|
1057 | - /*************************************** REGISTRATION SETTINGS ***************************************/ |
|
1058 | - |
|
1059 | - |
|
1060 | - /** |
|
1061 | - * @throws DomainException |
|
1062 | - * @throws EE_Error |
|
1063 | - * @throws InvalidArgumentException |
|
1064 | - * @throws InvalidDataTypeException |
|
1065 | - * @throws InvalidInterfaceException |
|
1066 | - */ |
|
1067 | - protected function _reg_form_settings() |
|
1068 | - { |
|
1069 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
1070 | - add_action( |
|
1071 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1072 | - array($this, 'email_validation_settings_form'), |
|
1073 | - 2 |
|
1074 | - ); |
|
1075 | - $this->_template_args = (array) apply_filters( |
|
1076 | - 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
|
1077 | - $this->_template_args |
|
1078 | - ); |
|
1079 | - $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
1080 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1081 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1082 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
1083 | - $this->_template_args, |
|
1084 | - true |
|
1085 | - ); |
|
1086 | - $this->display_admin_page_with_sidebar(); |
|
1087 | - } |
|
1088 | - |
|
1089 | - |
|
1090 | - /** |
|
1091 | - * @return void |
|
1092 | - * @throws EE_Error |
|
1093 | - * @throws InvalidArgumentException |
|
1094 | - * @throws ReflectionException |
|
1095 | - * @throws InvalidDataTypeException |
|
1096 | - * @throws InvalidInterfaceException |
|
1097 | - */ |
|
1098 | - protected function _update_reg_form_settings() |
|
1099 | - { |
|
1100 | - EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form( |
|
1101 | - EE_Registry::instance()->CFG->registration |
|
1102 | - ); |
|
1103 | - EE_Registry::instance()->CFG->registration = apply_filters( |
|
1104 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
1105 | - EE_Registry::instance()->CFG->registration |
|
1106 | - ); |
|
1107 | - $success = $this->_update_espresso_configuration( |
|
1108 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
1109 | - EE_Registry::instance()->CFG, |
|
1110 | - __FILE__, |
|
1111 | - __FUNCTION__, |
|
1112 | - __LINE__ |
|
1113 | - ); |
|
1114 | - $this->_redirect_after_action( |
|
1115 | - $success, |
|
1116 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
1117 | - 'updated', |
|
1118 | - array('action' => 'view_reg_form_settings') |
|
1119 | - ); |
|
1120 | - } |
|
1121 | - |
|
1122 | - |
|
1123 | - /** |
|
1124 | - * @return void |
|
1125 | - * @throws EE_Error |
|
1126 | - * @throws InvalidArgumentException |
|
1127 | - * @throws InvalidDataTypeException |
|
1128 | - * @throws InvalidInterfaceException |
|
1129 | - */ |
|
1130 | - public function email_validation_settings_form() |
|
1131 | - { |
|
1132 | - echo $this->_email_validation_settings_form()->get_html(); |
|
1133 | - } |
|
1134 | - |
|
1135 | - |
|
1136 | - /** |
|
1137 | - * _email_validation_settings_form |
|
1138 | - * |
|
1139 | - * @access protected |
|
1140 | - * @return EE_Form_Section_Proper |
|
1141 | - * @throws \EE_Error |
|
1142 | - */ |
|
1143 | - protected function _email_validation_settings_form() |
|
1144 | - { |
|
1145 | - return new EE_Form_Section_Proper( |
|
1146 | - array( |
|
1147 | - 'name' => 'email_validation_settings', |
|
1148 | - 'html_id' => 'email_validation_settings', |
|
1149 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1150 | - 'subsections' => apply_filters( |
|
1151 | - 'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections', |
|
1152 | - array( |
|
1153 | - 'email_validation_hdr' => new EE_Form_Section_HTML( |
|
1154 | - EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
1155 | - ), |
|
1156 | - 'email_validation_level' => new EE_Select_Input( |
|
1157 | - array( |
|
1158 | - 'basic' => esc_html__('Basic', 'event_espresso'), |
|
1159 | - 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
1160 | - 'i18n' => esc_html__('International', 'event_espresso'), |
|
1161 | - 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
1162 | - ), |
|
1163 | - array( |
|
1164 | - 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
1165 | - . EEH_Template::get_help_tab_link('email_validation_info'), |
|
1166 | - 'html_help_text' => esc_html__( |
|
1167 | - 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', |
|
1168 | - 'event_espresso' |
|
1169 | - ), |
|
1170 | - 'default' => isset( |
|
1171 | - EE_Registry::instance()->CFG->registration->email_validation_level |
|
1172 | - ) |
|
1173 | - ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
1174 | - : 'wp_default', |
|
1175 | - 'required' => false, |
|
1176 | - ) |
|
1177 | - ), |
|
1178 | - ) |
|
1179 | - ), |
|
1180 | - ) |
|
1181 | - ); |
|
1182 | - } |
|
1183 | - |
|
1184 | - |
|
1185 | - /** |
|
1186 | - * @param EE_Registration_Config $EE_Registration_Config |
|
1187 | - * @return EE_Registration_Config |
|
1188 | - * @throws EE_Error |
|
1189 | - * @throws InvalidArgumentException |
|
1190 | - * @throws ReflectionException |
|
1191 | - * @throws InvalidDataTypeException |
|
1192 | - * @throws InvalidInterfaceException |
|
1193 | - */ |
|
1194 | - public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1195 | - { |
|
1196 | - $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
1197 | - try { |
|
1198 | - $email_validation_settings_form = $this->_email_validation_settings_form(); |
|
1199 | - // if not displaying a form, then check for form submission |
|
1200 | - if ($email_validation_settings_form->was_submitted()) { |
|
1201 | - // capture form data |
|
1202 | - $email_validation_settings_form->receive_form_submission(); |
|
1203 | - // validate form data |
|
1204 | - if ($email_validation_settings_form->is_valid()) { |
|
1205 | - // grab validated data from form |
|
1206 | - $valid_data = $email_validation_settings_form->valid_data(); |
|
1207 | - if (isset($valid_data['email_validation_level'])) { |
|
1208 | - $email_validation_level = $valid_data['email_validation_level']; |
|
1209 | - // now if they want to use international email addresses |
|
1210 | - if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
1211 | - // in case we need to reset their email validation level, |
|
1212 | - // make sure that the previous value wasn't already set to one of the i18n options. |
|
1213 | - if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') { |
|
1214 | - // if so, then reset it back to "basic" since that is the only other option that, |
|
1215 | - // despite offering poor validation, supports i18n email addresses |
|
1216 | - $prev_email_validation_level = 'basic'; |
|
1217 | - } |
|
1218 | - // confirm our i18n email validation will work on the server |
|
1219 | - if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1220 | - // or reset email validation level to previous value |
|
1221 | - $email_validation_level = $prev_email_validation_level; |
|
1222 | - } |
|
1223 | - } |
|
1224 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1225 | - } else { |
|
1226 | - EE_Error::add_error( |
|
1227 | - esc_html__( |
|
1228 | - 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
|
1229 | - 'event_espresso' |
|
1230 | - ), |
|
1231 | - __FILE__, |
|
1232 | - __FUNCTION__, |
|
1233 | - __LINE__ |
|
1234 | - ); |
|
1235 | - } |
|
1236 | - } else { |
|
1237 | - if ($email_validation_settings_form->submission_error_message() !== '') { |
|
1238 | - EE_Error::add_error( |
|
1239 | - $email_validation_settings_form->submission_error_message(), |
|
1240 | - __FILE__, |
|
1241 | - __FUNCTION__, |
|
1242 | - __LINE__ |
|
1243 | - ); |
|
1244 | - } |
|
1245 | - } |
|
1246 | - } |
|
1247 | - } catch (EE_Error $e) { |
|
1248 | - $e->get_error(); |
|
1249 | - } |
|
1250 | - return $EE_Registration_Config; |
|
1251 | - } |
|
1252 | - |
|
1253 | - |
|
1254 | - /** |
|
1255 | - * confirms that the server's PHP version has the PCRE module enabled, |
|
1256 | - * and that the PCRE version works with our i18n email validation |
|
1257 | - * |
|
1258 | - * @param EE_Registration_Config $EE_Registration_Config |
|
1259 | - * @param string $email_validation_level |
|
1260 | - * @return bool |
|
1261 | - */ |
|
1262 | - private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1263 | - { |
|
1264 | - // first check that PCRE is enabled |
|
1265 | - if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1266 | - EE_Error::add_error( |
|
1267 | - sprintf( |
|
1268 | - esc_html__( |
|
1269 | - 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
1270 | - 'event_espresso' |
|
1271 | - ), |
|
1272 | - '<br />' |
|
1273 | - ), |
|
1274 | - __FILE__, |
|
1275 | - __FUNCTION__, |
|
1276 | - __LINE__ |
|
1277 | - ); |
|
1278 | - return false; |
|
1279 | - } else { |
|
1280 | - // PCRE support is enabled, but let's still |
|
1281 | - // perform a test to see if the server will support it. |
|
1282 | - // but first, save the updated validation level to the config, |
|
1283 | - // so that the validation strategy picks it up. |
|
1284 | - // this will get bumped back down if it doesn't work |
|
1285 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1286 | - try { |
|
1287 | - $email_validator = new EE_Email_Validation_Strategy(); |
|
1288 | - $i18n_email_address = apply_filters( |
|
1289 | - 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1290 | - 'jägerjü[email protected]' |
|
1291 | - ); |
|
1292 | - $email_validator->validate($i18n_email_address); |
|
1293 | - } catch (Exception $e) { |
|
1294 | - EE_Error::add_error( |
|
1295 | - sprintf( |
|
1296 | - esc_html__( |
|
1297 | - 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
1298 | - 'event_espresso' |
|
1299 | - ), |
|
1300 | - '<br />', |
|
1301 | - '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>' |
|
1302 | - ), |
|
1303 | - __FILE__, |
|
1304 | - __FUNCTION__, |
|
1305 | - __LINE__ |
|
1306 | - ); |
|
1307 | - return false; |
|
1308 | - } |
|
1309 | - } |
|
1310 | - return true; |
|
1311 | - } |
|
17 | + /** |
|
18 | + * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
19 | + */ |
|
20 | + public function __construct($routing = true) |
|
21 | + { |
|
22 | + define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS); |
|
23 | + define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS); |
|
24 | + define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
25 | + define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS); |
|
26 | + define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
27 | + parent::__construct($routing); |
|
28 | + } |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * @return void |
|
33 | + */ |
|
34 | + protected function _extend_page_config() |
|
35 | + { |
|
36 | + $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
|
37 | + $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) |
|
38 | + ? $this->_req_data['QST_ID'] : 0; |
|
39 | + $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) |
|
40 | + ? $this->_req_data['QSG_ID'] : 0; |
|
41 | + |
|
42 | + $new_page_routes = array( |
|
43 | + 'question_groups' => array( |
|
44 | + 'func' => '_question_groups_overview_list_table', |
|
45 | + 'capability' => 'ee_read_question_groups', |
|
46 | + ), |
|
47 | + 'add_question' => array( |
|
48 | + 'func' => '_edit_question', |
|
49 | + 'capability' => 'ee_edit_questions', |
|
50 | + ), |
|
51 | + 'insert_question' => array( |
|
52 | + 'func' => '_insert_or_update_question', |
|
53 | + 'args' => array('new_question' => true), |
|
54 | + 'capability' => 'ee_edit_questions', |
|
55 | + 'noheader' => true, |
|
56 | + ), |
|
57 | + 'duplicate_question' => array( |
|
58 | + 'func' => '_duplicate_question', |
|
59 | + 'capability' => 'ee_edit_questions', |
|
60 | + 'noheader' => true, |
|
61 | + ), |
|
62 | + 'trash_question' => array( |
|
63 | + 'func' => '_trash_question', |
|
64 | + 'capability' => 'ee_delete_question', |
|
65 | + 'obj_id' => $qst_id, |
|
66 | + 'noheader' => true, |
|
67 | + ), |
|
68 | + |
|
69 | + 'restore_question' => array( |
|
70 | + 'func' => '_trash_or_restore_questions', |
|
71 | + 'capability' => 'ee_delete_question', |
|
72 | + 'obj_id' => $qst_id, |
|
73 | + 'args' => array('trash' => false), |
|
74 | + 'noheader' => true, |
|
75 | + ), |
|
76 | + |
|
77 | + 'delete_question' => array( |
|
78 | + 'func' => '_delete_question', |
|
79 | + 'capability' => 'ee_delete_question', |
|
80 | + 'obj_id' => $qst_id, |
|
81 | + 'noheader' => true, |
|
82 | + ), |
|
83 | + |
|
84 | + 'trash_questions' => array( |
|
85 | + 'func' => '_trash_or_restore_questions', |
|
86 | + 'capability' => 'ee_delete_questions', |
|
87 | + 'args' => array('trash' => true), |
|
88 | + 'noheader' => true, |
|
89 | + ), |
|
90 | + |
|
91 | + 'restore_questions' => array( |
|
92 | + 'func' => '_trash_or_restore_questions', |
|
93 | + 'capability' => 'ee_delete_questions', |
|
94 | + 'args' => array('trash' => false), |
|
95 | + 'noheader' => true, |
|
96 | + ), |
|
97 | + |
|
98 | + 'delete_questions' => array( |
|
99 | + 'func' => '_delete_questions', |
|
100 | + 'args' => array(), |
|
101 | + 'capability' => 'ee_delete_questions', |
|
102 | + 'noheader' => true, |
|
103 | + ), |
|
104 | + |
|
105 | + 'add_question_group' => array( |
|
106 | + 'func' => '_edit_question_group', |
|
107 | + 'capability' => 'ee_edit_question_groups', |
|
108 | + ), |
|
109 | + |
|
110 | + 'edit_question_group' => array( |
|
111 | + 'func' => '_edit_question_group', |
|
112 | + 'capability' => 'ee_edit_question_group', |
|
113 | + 'obj_id' => $qsg_id, |
|
114 | + 'args' => array('edit'), |
|
115 | + ), |
|
116 | + |
|
117 | + 'delete_question_groups' => array( |
|
118 | + 'func' => '_delete_question_groups', |
|
119 | + 'capability' => 'ee_delete_question_groups', |
|
120 | + 'noheader' => true, |
|
121 | + ), |
|
122 | + |
|
123 | + 'delete_question_group' => array( |
|
124 | + 'func' => '_delete_question_groups', |
|
125 | + 'capability' => 'ee_delete_question_group', |
|
126 | + 'obj_id' => $qsg_id, |
|
127 | + 'noheader' => true, |
|
128 | + ), |
|
129 | + |
|
130 | + 'trash_question_group' => array( |
|
131 | + 'func' => '_trash_or_restore_question_groups', |
|
132 | + 'args' => array('trash' => true), |
|
133 | + 'capability' => 'ee_delete_question_group', |
|
134 | + 'obj_id' => $qsg_id, |
|
135 | + 'noheader' => true, |
|
136 | + ), |
|
137 | + |
|
138 | + 'restore_question_group' => array( |
|
139 | + 'func' => '_trash_or_restore_question_groups', |
|
140 | + 'args' => array('trash' => false), |
|
141 | + 'capability' => 'ee_delete_question_group', |
|
142 | + 'obj_id' => $qsg_id, |
|
143 | + 'noheader' => true, |
|
144 | + ), |
|
145 | + |
|
146 | + 'insert_question_group' => array( |
|
147 | + 'func' => '_insert_or_update_question_group', |
|
148 | + 'args' => array('new_question_group' => true), |
|
149 | + 'capability' => 'ee_edit_question_groups', |
|
150 | + 'noheader' => true, |
|
151 | + ), |
|
152 | + |
|
153 | + 'update_question_group' => array( |
|
154 | + 'func' => '_insert_or_update_question_group', |
|
155 | + 'args' => array('new_question_group' => false), |
|
156 | + 'capability' => 'ee_edit_question_group', |
|
157 | + 'obj_id' => $qsg_id, |
|
158 | + 'noheader' => true, |
|
159 | + ), |
|
160 | + |
|
161 | + 'trash_question_groups' => array( |
|
162 | + 'func' => '_trash_or_restore_question_groups', |
|
163 | + 'args' => array('trash' => true), |
|
164 | + 'capability' => 'ee_delete_question_groups', |
|
165 | + 'noheader' => array('trash' => false), |
|
166 | + ), |
|
167 | + |
|
168 | + 'restore_question_groups' => array( |
|
169 | + 'func' => '_trash_or_restore_question_groups', |
|
170 | + 'args' => array('trash' => false), |
|
171 | + 'capability' => 'ee_delete_question_groups', |
|
172 | + 'noheader' => true, |
|
173 | + ), |
|
174 | + |
|
175 | + |
|
176 | + 'espresso_update_question_group_order' => array( |
|
177 | + 'func' => 'update_question_group_order', |
|
178 | + 'capability' => 'ee_edit_question_groups', |
|
179 | + 'noheader' => true, |
|
180 | + ), |
|
181 | + |
|
182 | + 'view_reg_form_settings' => array( |
|
183 | + 'func' => '_reg_form_settings', |
|
184 | + 'capability' => 'manage_options', |
|
185 | + ), |
|
186 | + |
|
187 | + 'update_reg_form_settings' => array( |
|
188 | + 'func' => '_update_reg_form_settings', |
|
189 | + 'capability' => 'manage_options', |
|
190 | + 'noheader' => true, |
|
191 | + ), |
|
192 | + ); |
|
193 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
194 | + |
|
195 | + $new_page_config = array( |
|
196 | + |
|
197 | + 'question_groups' => array( |
|
198 | + 'nav' => array( |
|
199 | + 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
200 | + 'order' => 20, |
|
201 | + ), |
|
202 | + 'list_table' => 'Registration_Form_Question_Groups_Admin_List_Table', |
|
203 | + 'help_tabs' => array( |
|
204 | + 'registration_form_question_groups_help_tab' => array( |
|
205 | + 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
206 | + 'filename' => 'registration_form_question_groups', |
|
207 | + ), |
|
208 | + 'registration_form_question_groups_table_column_headings_help_tab' => array( |
|
209 | + 'title' => esc_html__('Question Groups Table Column Headings', 'event_espresso'), |
|
210 | + 'filename' => 'registration_form_question_groups_table_column_headings', |
|
211 | + ), |
|
212 | + 'registration_form_question_groups_views_bulk_actions_search_help_tab' => array( |
|
213 | + 'title' => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'), |
|
214 | + 'filename' => 'registration_form_question_groups_views_bulk_actions_search', |
|
215 | + ), |
|
216 | + ), |
|
217 | + 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
218 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
219 | + 'require_nonce' => false, |
|
220 | + 'qtips' => array( |
|
221 | + 'EE_Registration_Form_Tips', |
|
222 | + ), |
|
223 | + ), |
|
224 | + |
|
225 | + 'add_question' => array( |
|
226 | + 'nav' => array( |
|
227 | + 'label' => esc_html__('Add Question', 'event_espresso'), |
|
228 | + 'order' => 5, |
|
229 | + 'persistent' => false, |
|
230 | + ), |
|
231 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
232 | + 'help_tabs' => array( |
|
233 | + 'registration_form_add_question_help_tab' => array( |
|
234 | + 'title' => esc_html__('Add Question', 'event_espresso'), |
|
235 | + 'filename' => 'registration_form_add_question', |
|
236 | + ), |
|
237 | + ), |
|
238 | + 'help_tour' => array('Registration_Form_Add_Question_Help_Tour'), |
|
239 | + 'require_nonce' => false, |
|
240 | + ), |
|
241 | + |
|
242 | + 'add_question_group' => array( |
|
243 | + 'nav' => array( |
|
244 | + 'label' => esc_html__('Add Question Group', 'event_espresso'), |
|
245 | + 'order' => 5, |
|
246 | + 'persistent' => false, |
|
247 | + ), |
|
248 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
249 | + 'help_tabs' => array( |
|
250 | + 'registration_form_add_question_group_help_tab' => array( |
|
251 | + 'title' => esc_html__('Add Question Group', 'event_espresso'), |
|
252 | + 'filename' => 'registration_form_add_question_group', |
|
253 | + ), |
|
254 | + ), |
|
255 | + 'help_tour' => array('Registration_Form_Add_Question_Group_Help_Tour'), |
|
256 | + 'require_nonce' => false, |
|
257 | + ), |
|
258 | + |
|
259 | + 'edit_question_group' => array( |
|
260 | + 'nav' => array( |
|
261 | + 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
|
262 | + 'order' => 5, |
|
263 | + 'persistent' => false, |
|
264 | + 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg( |
|
265 | + array('question_group_id' => $this->_req_data['question_group_id']), |
|
266 | + $this->_current_page_view_url |
|
267 | + ) : $this->_admin_base_url, |
|
268 | + ), |
|
269 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
270 | + 'help_tabs' => array( |
|
271 | + 'registration_form_edit_question_group_help_tab' => array( |
|
272 | + 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
|
273 | + 'filename' => 'registration_form_edit_question_group', |
|
274 | + ), |
|
275 | + ), |
|
276 | + 'help_tour' => array('Registration_Form_Edit_Question_Group_Help_Tour'), |
|
277 | + 'require_nonce' => false, |
|
278 | + ), |
|
279 | + |
|
280 | + 'view_reg_form_settings' => array( |
|
281 | + 'nav' => array( |
|
282 | + 'label' => esc_html__('Reg Form Settings', 'event_espresso'), |
|
283 | + 'order' => 40, |
|
284 | + ), |
|
285 | + 'labels' => array( |
|
286 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
287 | + ), |
|
288 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
289 | + 'help_tabs' => array( |
|
290 | + 'registration_form_reg_form_settings_help_tab' => array( |
|
291 | + 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
|
292 | + 'filename' => 'registration_form_reg_form_settings', |
|
293 | + ), |
|
294 | + ), |
|
295 | + 'help_tour' => array('Registration_Form_Settings_Help_Tour'), |
|
296 | + 'require_nonce' => false, |
|
297 | + ), |
|
298 | + |
|
299 | + ); |
|
300 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
301 | + |
|
302 | + // change the list table we're going to use so it's the NEW list table! |
|
303 | + $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
|
304 | + |
|
305 | + |
|
306 | + // additional labels |
|
307 | + $new_labels = array( |
|
308 | + 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
|
309 | + 'delete_question' => esc_html__('Delete Question', 'event_espresso'), |
|
310 | + 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
|
311 | + 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
|
312 | + 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
|
313 | + ); |
|
314 | + $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
315 | + } |
|
316 | + |
|
317 | + |
|
318 | + /** |
|
319 | + * @return void |
|
320 | + */ |
|
321 | + protected function _ajax_hooks() |
|
322 | + { |
|
323 | + add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order')); |
|
324 | + } |
|
325 | + |
|
326 | + |
|
327 | + /** |
|
328 | + * @return void |
|
329 | + */ |
|
330 | + public function load_scripts_styles_question_groups() |
|
331 | + { |
|
332 | + wp_enqueue_script('espresso_ajax_table_sorting'); |
|
333 | + } |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * @return void |
|
338 | + */ |
|
339 | + public function load_scripts_styles_add_question_group() |
|
340 | + { |
|
341 | + $this->load_scripts_styles_forms(); |
|
342 | + $this->load_sortable_question_script(); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * @return void |
|
348 | + */ |
|
349 | + public function load_scripts_styles_edit_question_group() |
|
350 | + { |
|
351 | + $this->load_scripts_styles_forms(); |
|
352 | + $this->load_sortable_question_script(); |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * registers and enqueues script for questions |
|
358 | + * |
|
359 | + * @return void |
|
360 | + */ |
|
361 | + public function load_sortable_question_script() |
|
362 | + { |
|
363 | + wp_register_script( |
|
364 | + 'ee-question-sortable', |
|
365 | + REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
366 | + array('jquery-ui-sortable'), |
|
367 | + EVENT_ESPRESSO_VERSION, |
|
368 | + true |
|
369 | + ); |
|
370 | + wp_enqueue_script('ee-question-sortable'); |
|
371 | + } |
|
372 | + |
|
373 | + |
|
374 | + /** |
|
375 | + * @return void |
|
376 | + */ |
|
377 | + protected function _set_list_table_views_default() |
|
378 | + { |
|
379 | + $this->_views = array( |
|
380 | + 'all' => array( |
|
381 | + 'slug' => 'all', |
|
382 | + 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
383 | + 'count' => 0, |
|
384 | + 'bulk_action' => array( |
|
385 | + 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
|
386 | + ), |
|
387 | + ), |
|
388 | + ); |
|
389 | + |
|
390 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
391 | + 'ee_delete_questions', |
|
392 | + 'espresso_registration_form_trash_questions' |
|
393 | + ) |
|
394 | + ) { |
|
395 | + $this->_views['trash'] = array( |
|
396 | + 'slug' => 'trash', |
|
397 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
398 | + 'count' => 0, |
|
399 | + 'bulk_action' => array( |
|
400 | + 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
|
401 | + 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
|
402 | + ), |
|
403 | + ); |
|
404 | + } |
|
405 | + } |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * @return void |
|
410 | + */ |
|
411 | + protected function _set_list_table_views_question_groups() |
|
412 | + { |
|
413 | + $this->_views = array( |
|
414 | + 'all' => array( |
|
415 | + 'slug' => 'all', |
|
416 | + 'label' => esc_html__('All', 'event_espresso'), |
|
417 | + 'count' => 0, |
|
418 | + 'bulk_action' => array( |
|
419 | + 'trash_question_groups' => esc_html__('Trash', 'event_espresso'), |
|
420 | + ), |
|
421 | + ), |
|
422 | + ); |
|
423 | + |
|
424 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
425 | + 'ee_delete_question_groups', |
|
426 | + 'espresso_registration_form_trash_question_groups' |
|
427 | + ) |
|
428 | + ) { |
|
429 | + $this->_views['trash'] = array( |
|
430 | + 'slug' => 'trash', |
|
431 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
432 | + 'count' => 0, |
|
433 | + 'bulk_action' => array( |
|
434 | + 'delete_question_groups' => esc_html__('Delete Permanently', 'event_espresso'), |
|
435 | + 'restore_question_groups' => esc_html__('Restore', 'event_espresso'), |
|
436 | + ), |
|
437 | + ); |
|
438 | + } |
|
439 | + } |
|
440 | + |
|
441 | + |
|
442 | + /** |
|
443 | + * @return void |
|
444 | + * @throws EE_Error |
|
445 | + * @throws InvalidArgumentException |
|
446 | + * @throws InvalidDataTypeException |
|
447 | + * @throws InvalidInterfaceException |
|
448 | + */ |
|
449 | + protected function _questions_overview_list_table() |
|
450 | + { |
|
451 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
452 | + 'add_question', |
|
453 | + 'add_question', |
|
454 | + array(), |
|
455 | + 'add-new-h2' |
|
456 | + ); |
|
457 | + parent::_questions_overview_list_table(); |
|
458 | + } |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * @return void |
|
463 | + * @throws DomainException |
|
464 | + * @throws EE_Error |
|
465 | + * @throws InvalidArgumentException |
|
466 | + * @throws InvalidDataTypeException |
|
467 | + * @throws InvalidInterfaceException |
|
468 | + */ |
|
469 | + protected function _question_groups_overview_list_table() |
|
470 | + { |
|
471 | + $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
|
472 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
473 | + 'add_question_group', |
|
474 | + 'add_question_group', |
|
475 | + array(), |
|
476 | + 'add-new-h2' |
|
477 | + ); |
|
478 | + $this->display_admin_list_table_page_with_sidebar(); |
|
479 | + } |
|
480 | + |
|
481 | + |
|
482 | + /** |
|
483 | + * @return void |
|
484 | + * @throws EE_Error |
|
485 | + * @throws InvalidArgumentException |
|
486 | + * @throws InvalidDataTypeException |
|
487 | + * @throws InvalidInterfaceException |
|
488 | + */ |
|
489 | + protected function _delete_question() |
|
490 | + { |
|
491 | + $success = $this->_delete_items($this->_question_model); |
|
492 | + $this->_redirect_after_action( |
|
493 | + $success, |
|
494 | + $this->_question_model->item_name($success), |
|
495 | + 'deleted', |
|
496 | + array('action' => 'default', 'status' => 'all') |
|
497 | + ); |
|
498 | + } |
|
499 | + |
|
500 | + |
|
501 | + /** |
|
502 | + * @return void |
|
503 | + * @throws EE_Error |
|
504 | + * @throws InvalidArgumentException |
|
505 | + * @throws InvalidDataTypeException |
|
506 | + * @throws InvalidInterfaceException |
|
507 | + */ |
|
508 | + protected function _delete_questions() |
|
509 | + { |
|
510 | + $success = $this->_delete_items($this->_question_model); |
|
511 | + $this->_redirect_after_action( |
|
512 | + $success, |
|
513 | + $this->_question_model->item_name($success), |
|
514 | + 'deleted permanently', |
|
515 | + array('action' => 'default', 'status' => 'trash') |
|
516 | + ); |
|
517 | + } |
|
518 | + |
|
519 | + |
|
520 | + /** |
|
521 | + * Performs the deletion of a single or multiple questions or question groups. |
|
522 | + * |
|
523 | + * @param EEM_Soft_Delete_Base $model |
|
524 | + * @return int number of items deleted permanently |
|
525 | + * @throws EE_Error |
|
526 | + * @throws InvalidArgumentException |
|
527 | + * @throws InvalidDataTypeException |
|
528 | + * @throws InvalidInterfaceException |
|
529 | + */ |
|
530 | + private function _delete_items(EEM_Soft_Delete_Base $model) |
|
531 | + { |
|
532 | + $success = 0; |
|
533 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
534 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
535 | + // if array has more than one element than success message should be plural |
|
536 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
537 | + // cycle thru bulk action checkboxes |
|
538 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
539 | + if (! $this->_delete_item($ID, $model)) { |
|
540 | + $success = 0; |
|
541 | + } |
|
542 | + } |
|
543 | + } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
544 | + $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
545 | + } elseif (! empty($this->_req_data['QST_ID'])) { |
|
546 | + $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
547 | + } else { |
|
548 | + EE_Error::add_error( |
|
549 | + sprintf( |
|
550 | + esc_html__( |
|
551 | + "No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", |
|
552 | + "event_espresso" |
|
553 | + ) |
|
554 | + ), |
|
555 | + __FILE__, |
|
556 | + __FUNCTION__, |
|
557 | + __LINE__ |
|
558 | + ); |
|
559 | + } |
|
560 | + return $success; |
|
561 | + } |
|
562 | + |
|
563 | + |
|
564 | + /** |
|
565 | + * Deletes the specified question (and its associated question options) or question group |
|
566 | + * |
|
567 | + * @param int $id |
|
568 | + * @param EEM_Soft_Delete_Base $model |
|
569 | + * @return boolean |
|
570 | + * @throws EE_Error |
|
571 | + * @throws InvalidArgumentException |
|
572 | + * @throws InvalidDataTypeException |
|
573 | + * @throws InvalidInterfaceException |
|
574 | + */ |
|
575 | + protected function _delete_item($id, $model) |
|
576 | + { |
|
577 | + if ($model instanceof EEM_Question) { |
|
578 | + EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id)))); |
|
579 | + } |
|
580 | + return $model->delete_permanently_by_ID(absint($id)); |
|
581 | + } |
|
582 | + |
|
583 | + |
|
584 | + /****************************** QUESTION GROUPS ******************************/ |
|
585 | + |
|
586 | + |
|
587 | + /** |
|
588 | + * @param string $type |
|
589 | + * @return void |
|
590 | + * @throws DomainException |
|
591 | + * @throws EE_Error |
|
592 | + * @throws InvalidArgumentException |
|
593 | + * @throws InvalidDataTypeException |
|
594 | + * @throws InvalidInterfaceException |
|
595 | + */ |
|
596 | + protected function _edit_question_group($type = 'add') |
|
597 | + { |
|
598 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
599 | + $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) |
|
600 | + ? absint($this->_req_data['QSG_ID']) |
|
601 | + : false; |
|
602 | + |
|
603 | + switch ($this->_req_action) { |
|
604 | + case 'add_question_group': |
|
605 | + $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
606 | + break; |
|
607 | + case 'edit_question_group': |
|
608 | + $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
609 | + break; |
|
610 | + default: |
|
611 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
612 | + } |
|
613 | + // add ID to title if editing |
|
614 | + $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
615 | + if ($ID) { |
|
616 | + /** @var EE_Question_Group $questionGroup */ |
|
617 | + $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
618 | + $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
619 | + $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
|
620 | + } else { |
|
621 | + /** @var EE_Question_Group $questionGroup */ |
|
622 | + $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
|
623 | + $questionGroup->set_order_to_latest(); |
|
624 | + $this->_set_add_edit_form_tags('insert_question_group'); |
|
625 | + } |
|
626 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
627 | + $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
628 | + $this->_template_args['QSG_ID'] = $ID ? $ID : true; |
|
629 | + $this->_template_args['question_group'] = $questionGroup; |
|
630 | + |
|
631 | + $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
|
632 | + $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL); |
|
633 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
634 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
635 | + $this->_template_args, |
|
636 | + true |
|
637 | + ); |
|
638 | + |
|
639 | + // the details template wrapper |
|
640 | + $this->display_admin_page_with_sidebar(); |
|
641 | + } |
|
642 | + |
|
643 | + |
|
644 | + /** |
|
645 | + * @return void |
|
646 | + * @throws EE_Error |
|
647 | + * @throws InvalidArgumentException |
|
648 | + * @throws InvalidDataTypeException |
|
649 | + * @throws InvalidInterfaceException |
|
650 | + */ |
|
651 | + protected function _delete_question_groups() |
|
652 | + { |
|
653 | + $success = $this->_delete_items($this->_question_group_model); |
|
654 | + $this->_redirect_after_action( |
|
655 | + $success, |
|
656 | + $this->_question_group_model->item_name($success), |
|
657 | + 'deleted permanently', |
|
658 | + array('action' => 'question_groups', 'status' => 'trash') |
|
659 | + ); |
|
660 | + } |
|
661 | + |
|
662 | + |
|
663 | + /** |
|
664 | + * @param bool $new_question_group |
|
665 | + * @throws EE_Error |
|
666 | + * @throws InvalidArgumentException |
|
667 | + * @throws InvalidDataTypeException |
|
668 | + * @throws InvalidInterfaceException |
|
669 | + */ |
|
670 | + protected function _insert_or_update_question_group($new_question_group = true) |
|
671 | + { |
|
672 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
673 | + $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
674 | + if ($new_question_group) { |
|
675 | + $QSG_ID = $this->_question_group_model->insert($set_column_values); |
|
676 | + $success = $QSG_ID ? 1 : 0; |
|
677 | + } else { |
|
678 | + $QSG_ID = absint($this->_req_data['QSG_ID']); |
|
679 | + unset($set_column_values['QSG_ID']); |
|
680 | + $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID))); |
|
681 | + } |
|
682 | + $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( |
|
683 | + EEM_Attendee::system_question_phone |
|
684 | + ); |
|
685 | + // update the existing related questions |
|
686 | + // BUT FIRST... delete the phone question from the Question_Group_Question |
|
687 | + // if it is being added to this question group (therefore removed from the existing group) |
|
688 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) { |
|
689 | + // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
|
690 | + EEM_Question_Group_Question::instance()->delete( |
|
691 | + array( |
|
692 | + array( |
|
693 | + 'QST_ID' => $phone_question_id, |
|
694 | + 'QSG_ID' => array('!=', $QSG_ID), |
|
695 | + ), |
|
696 | + ) |
|
697 | + ); |
|
698 | + } |
|
699 | + /** @type EE_Question_Group $question_group */ |
|
700 | + $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
701 | + $questions = $question_group->questions(); |
|
702 | + // make sure system phone question is added to list of questions for this group |
|
703 | + if (! isset($questions[ $phone_question_id ])) { |
|
704 | + $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
705 | + } |
|
706 | + |
|
707 | + foreach ($questions as $question_ID => $question) { |
|
708 | + // first we always check for order. |
|
709 | + if (! empty($this->_req_data['question_orders'][ $question_ID ])) { |
|
710 | + // update question order |
|
711 | + $question_group->update_question_order( |
|
712 | + $question_ID, |
|
713 | + $this->_req_data['question_orders'][ $question_ID ] |
|
714 | + ); |
|
715 | + } |
|
716 | + |
|
717 | + // then we always check if adding or removing. |
|
718 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) { |
|
719 | + $question_group->add_question($question_ID); |
|
720 | + } else { |
|
721 | + // not found, remove it (but only if not a system question for the personal group |
|
722 | + // with the exception of lname system question - we allow removal of it) |
|
723 | + if (in_array( |
|
724 | + $question->system_ID(), |
|
725 | + EEM_Question::instance()->required_system_questions_in_system_question_group( |
|
726 | + $question_group->system_group() |
|
727 | + ) |
|
728 | + )) { |
|
729 | + continue; |
|
730 | + } else { |
|
731 | + $question_group->remove_question($question_ID); |
|
732 | + } |
|
733 | + } |
|
734 | + } |
|
735 | + // save new related questions |
|
736 | + if (isset($this->_req_data['questions'])) { |
|
737 | + foreach ($this->_req_data['questions'] as $QST_ID) { |
|
738 | + $question_group->add_question($QST_ID); |
|
739 | + if (isset($this->_req_data['question_orders'][ $QST_ID ])) { |
|
740 | + $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]); |
|
741 | + } |
|
742 | + } |
|
743 | + } |
|
744 | + |
|
745 | + if ($success !== false) { |
|
746 | + $msg = $new_question_group |
|
747 | + ? sprintf( |
|
748 | + esc_html__('The %s has been created', 'event_espresso'), |
|
749 | + $this->_question_group_model->item_name() |
|
750 | + ) |
|
751 | + : sprintf( |
|
752 | + esc_html__( |
|
753 | + 'The %s has been updated', |
|
754 | + 'event_espresso' |
|
755 | + ), |
|
756 | + $this->_question_group_model->item_name() |
|
757 | + ); |
|
758 | + EE_Error::add_success($msg); |
|
759 | + } |
|
760 | + $this->_redirect_after_action( |
|
761 | + false, |
|
762 | + '', |
|
763 | + '', |
|
764 | + array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
765 | + true |
|
766 | + ); |
|
767 | + } |
|
768 | + |
|
769 | + |
|
770 | + /** |
|
771 | + * duplicates a question and all its question options and redirects to the new question. |
|
772 | + * |
|
773 | + * @return void |
|
774 | + * @throws EE_Error |
|
775 | + * @throws InvalidArgumentException |
|
776 | + * @throws ReflectionException |
|
777 | + * @throws InvalidDataTypeException |
|
778 | + * @throws InvalidInterfaceException |
|
779 | + */ |
|
780 | + public function _duplicate_question() |
|
781 | + { |
|
782 | + $question_ID = (int) $this->_req_data['QST_ID']; |
|
783 | + $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
784 | + if ($question instanceof EE_Question) { |
|
785 | + $new_question = $question->duplicate(); |
|
786 | + if ($new_question instanceof EE_Question) { |
|
787 | + $this->_redirect_after_action( |
|
788 | + true, |
|
789 | + esc_html__('Question', 'event_espresso'), |
|
790 | + esc_html__('Duplicated', 'event_espresso'), |
|
791 | + array('action' => 'edit_question', 'QST_ID' => $new_question->ID()), |
|
792 | + true |
|
793 | + ); |
|
794 | + } else { |
|
795 | + global $wpdb; |
|
796 | + EE_Error::add_error( |
|
797 | + sprintf( |
|
798 | + esc_html__( |
|
799 | + 'Could not duplicate question with ID %1$d because: %2$s', |
|
800 | + 'event_espresso' |
|
801 | + ), |
|
802 | + $question_ID, |
|
803 | + $wpdb->last_error |
|
804 | + ), |
|
805 | + __FILE__, |
|
806 | + __FUNCTION__, |
|
807 | + __LINE__ |
|
808 | + ); |
|
809 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
810 | + } |
|
811 | + } else { |
|
812 | + EE_Error::add_error( |
|
813 | + sprintf( |
|
814 | + esc_html__( |
|
815 | + 'Could not duplicate question with ID %d because it didn\'t exist!', |
|
816 | + 'event_espresso' |
|
817 | + ), |
|
818 | + $question_ID |
|
819 | + ), |
|
820 | + __FILE__, |
|
821 | + __FUNCTION__, |
|
822 | + __LINE__ |
|
823 | + ); |
|
824 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
825 | + } |
|
826 | + } |
|
827 | + |
|
828 | + |
|
829 | + /** |
|
830 | + * @param bool $trash |
|
831 | + * @throws EE_Error |
|
832 | + */ |
|
833 | + protected function _trash_or_restore_question_groups($trash = true) |
|
834 | + { |
|
835 | + $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
836 | + } |
|
837 | + |
|
838 | + |
|
839 | + /** |
|
840 | + *_trash_question |
|
841 | + * |
|
842 | + * @return void |
|
843 | + * @throws EE_Error |
|
844 | + */ |
|
845 | + protected function _trash_question() |
|
846 | + { |
|
847 | + $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
848 | + $query_args = array('action' => 'default', 'status' => 'all'); |
|
849 | + $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
|
850 | + } |
|
851 | + |
|
852 | + |
|
853 | + /** |
|
854 | + * @param bool $trash |
|
855 | + * @throws EE_Error |
|
856 | + */ |
|
857 | + protected function _trash_or_restore_questions($trash = true) |
|
858 | + { |
|
859 | + $this->_trash_or_restore_items($this->_question_model, $trash); |
|
860 | + } |
|
861 | + |
|
862 | + |
|
863 | + /** |
|
864 | + * Internally used to delete or restore items, using the request data. Meant to be |
|
865 | + * flexible between question or question groups |
|
866 | + * |
|
867 | + * @param EEM_Soft_Delete_Base $model |
|
868 | + * @param boolean $trash whether to trash or restore |
|
869 | + * @throws EE_Error |
|
870 | + */ |
|
871 | + private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true) |
|
872 | + { |
|
873 | + |
|
874 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
875 | + |
|
876 | + $success = 1; |
|
877 | + // Checkboxes |
|
878 | + // echo "trash $trash"; |
|
879 | + // var_dump($this->_req_data['checkbox']);die; |
|
880 | + if (isset($this->_req_data['checkbox'])) { |
|
881 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
882 | + // if array has more than one element than success message should be plural |
|
883 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
884 | + // cycle thru bulk action checkboxes |
|
885 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
886 | + if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
887 | + $success = 0; |
|
888 | + } |
|
889 | + } |
|
890 | + } else { |
|
891 | + // grab single id and delete |
|
892 | + $ID = absint($this->_req_data['checkbox']); |
|
893 | + if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
894 | + $success = 0; |
|
895 | + } |
|
896 | + } |
|
897 | + } else { |
|
898 | + // delete via trash link |
|
899 | + // grab single id and delete |
|
900 | + $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
901 | + if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
902 | + $success = 0; |
|
903 | + } |
|
904 | + } |
|
905 | + |
|
906 | + |
|
907 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) ); |
|
908 | + // echo "action :$action"; |
|
909 | + // $action = 'questions' ? 'default' : $action; |
|
910 | + if ($trash) { |
|
911 | + $action_desc = 'trashed'; |
|
912 | + $status = 'trash'; |
|
913 | + } else { |
|
914 | + $action_desc = 'restored'; |
|
915 | + $status = 'all'; |
|
916 | + } |
|
917 | + $this->_redirect_after_action( |
|
918 | + $success, |
|
919 | + $model->item_name($success), |
|
920 | + $action_desc, |
|
921 | + array('action' => $action, 'status' => $status) |
|
922 | + ); |
|
923 | + } |
|
924 | + |
|
925 | + |
|
926 | + /** |
|
927 | + * @param $per_page |
|
928 | + * @param int $current_page |
|
929 | + * @param bool|false $count |
|
930 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
931 | + * @throws EE_Error |
|
932 | + * @throws InvalidArgumentException |
|
933 | + * @throws InvalidDataTypeException |
|
934 | + * @throws InvalidInterfaceException |
|
935 | + */ |
|
936 | + public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
937 | + { |
|
938 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
939 | + |
|
940 | + if ($count) { |
|
941 | + // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
942 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
943 | + $results = $this->_question_model->count_deleted($where); |
|
944 | + } else { |
|
945 | + // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
946 | + $results = $this->_question_model->get_all_deleted($query_params); |
|
947 | + } |
|
948 | + return $results; |
|
949 | + } |
|
950 | + |
|
951 | + |
|
952 | + /** |
|
953 | + * @param $per_page |
|
954 | + * @param int $current_page |
|
955 | + * @param bool|false $count |
|
956 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
957 | + * @throws EE_Error |
|
958 | + * @throws InvalidArgumentException |
|
959 | + * @throws InvalidDataTypeException |
|
960 | + * @throws InvalidInterfaceException |
|
961 | + */ |
|
962 | + public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
963 | + { |
|
964 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
965 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
966 | + if ($count) { |
|
967 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
968 | + $results = $questionGroupModel->count($where); |
|
969 | + } else { |
|
970 | + $results = $questionGroupModel->get_all($query_params); |
|
971 | + } |
|
972 | + return $results; |
|
973 | + } |
|
974 | + |
|
975 | + |
|
976 | + /** |
|
977 | + * @param $per_page |
|
978 | + * @param int $current_page |
|
979 | + * @param bool $count |
|
980 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
981 | + * @throws EE_Error |
|
982 | + * @throws InvalidArgumentException |
|
983 | + * @throws InvalidDataTypeException |
|
984 | + * @throws InvalidInterfaceException |
|
985 | + */ |
|
986 | + public function get_trashed_question_groups($per_page, $current_page = 1, $count = false) |
|
987 | + { |
|
988 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
989 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
990 | + if ($count) { |
|
991 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
992 | + $query_params['limit'] = null; |
|
993 | + $results = $questionGroupModel->count_deleted($where); |
|
994 | + } else { |
|
995 | + $results = $questionGroupModel->get_all_deleted($query_params); |
|
996 | + } |
|
997 | + return $results; |
|
998 | + } |
|
999 | + |
|
1000 | + |
|
1001 | + /** |
|
1002 | + * method for performing updates to question order |
|
1003 | + * |
|
1004 | + * @return void results array |
|
1005 | + * @throws EE_Error |
|
1006 | + * @throws InvalidArgumentException |
|
1007 | + * @throws InvalidDataTypeException |
|
1008 | + * @throws InvalidInterfaceException |
|
1009 | + */ |
|
1010 | + public function update_question_group_order() |
|
1011 | + { |
|
1012 | + |
|
1013 | + $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
1014 | + |
|
1015 | + // grab our row IDs |
|
1016 | + $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
1017 | + ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
1018 | + : array(); |
|
1019 | + |
|
1020 | + $perpage = ! empty($this->_req_data['perpage']) |
|
1021 | + ? (int) $this->_req_data['perpage'] |
|
1022 | + : null; |
|
1023 | + $curpage = ! empty($this->_req_data['curpage']) |
|
1024 | + ? (int) $this->_req_data['curpage'] |
|
1025 | + : null; |
|
1026 | + |
|
1027 | + if (! empty($row_ids)) { |
|
1028 | + // figure out where we start the row_id count at for the current page. |
|
1029 | + $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
1030 | + |
|
1031 | + $row_count = count($row_ids); |
|
1032 | + for ($i = 0; $i < $row_count; $i++) { |
|
1033 | + // Update the questions when re-ordering |
|
1034 | + $updated = EEM_Question_Group::instance()->update( |
|
1035 | + array('QSG_order' => $qsgcount), |
|
1036 | + array(array('QSG_ID' => $row_ids[ $i ])) |
|
1037 | + ); |
|
1038 | + if ($updated === false) { |
|
1039 | + $success = false; |
|
1040 | + } |
|
1041 | + $qsgcount++; |
|
1042 | + } |
|
1043 | + } else { |
|
1044 | + $success = false; |
|
1045 | + } |
|
1046 | + |
|
1047 | + $errors = ! $success |
|
1048 | + ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
1049 | + : false; |
|
1050 | + |
|
1051 | + echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors)); |
|
1052 | + die(); |
|
1053 | + } |
|
1054 | + |
|
1055 | + |
|
1056 | + |
|
1057 | + /*************************************** REGISTRATION SETTINGS ***************************************/ |
|
1058 | + |
|
1059 | + |
|
1060 | + /** |
|
1061 | + * @throws DomainException |
|
1062 | + * @throws EE_Error |
|
1063 | + * @throws InvalidArgumentException |
|
1064 | + * @throws InvalidDataTypeException |
|
1065 | + * @throws InvalidInterfaceException |
|
1066 | + */ |
|
1067 | + protected function _reg_form_settings() |
|
1068 | + { |
|
1069 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
1070 | + add_action( |
|
1071 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1072 | + array($this, 'email_validation_settings_form'), |
|
1073 | + 2 |
|
1074 | + ); |
|
1075 | + $this->_template_args = (array) apply_filters( |
|
1076 | + 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
|
1077 | + $this->_template_args |
|
1078 | + ); |
|
1079 | + $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
1080 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1081 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1082 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
1083 | + $this->_template_args, |
|
1084 | + true |
|
1085 | + ); |
|
1086 | + $this->display_admin_page_with_sidebar(); |
|
1087 | + } |
|
1088 | + |
|
1089 | + |
|
1090 | + /** |
|
1091 | + * @return void |
|
1092 | + * @throws EE_Error |
|
1093 | + * @throws InvalidArgumentException |
|
1094 | + * @throws ReflectionException |
|
1095 | + * @throws InvalidDataTypeException |
|
1096 | + * @throws InvalidInterfaceException |
|
1097 | + */ |
|
1098 | + protected function _update_reg_form_settings() |
|
1099 | + { |
|
1100 | + EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form( |
|
1101 | + EE_Registry::instance()->CFG->registration |
|
1102 | + ); |
|
1103 | + EE_Registry::instance()->CFG->registration = apply_filters( |
|
1104 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
1105 | + EE_Registry::instance()->CFG->registration |
|
1106 | + ); |
|
1107 | + $success = $this->_update_espresso_configuration( |
|
1108 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
1109 | + EE_Registry::instance()->CFG, |
|
1110 | + __FILE__, |
|
1111 | + __FUNCTION__, |
|
1112 | + __LINE__ |
|
1113 | + ); |
|
1114 | + $this->_redirect_after_action( |
|
1115 | + $success, |
|
1116 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
1117 | + 'updated', |
|
1118 | + array('action' => 'view_reg_form_settings') |
|
1119 | + ); |
|
1120 | + } |
|
1121 | + |
|
1122 | + |
|
1123 | + /** |
|
1124 | + * @return void |
|
1125 | + * @throws EE_Error |
|
1126 | + * @throws InvalidArgumentException |
|
1127 | + * @throws InvalidDataTypeException |
|
1128 | + * @throws InvalidInterfaceException |
|
1129 | + */ |
|
1130 | + public function email_validation_settings_form() |
|
1131 | + { |
|
1132 | + echo $this->_email_validation_settings_form()->get_html(); |
|
1133 | + } |
|
1134 | + |
|
1135 | + |
|
1136 | + /** |
|
1137 | + * _email_validation_settings_form |
|
1138 | + * |
|
1139 | + * @access protected |
|
1140 | + * @return EE_Form_Section_Proper |
|
1141 | + * @throws \EE_Error |
|
1142 | + */ |
|
1143 | + protected function _email_validation_settings_form() |
|
1144 | + { |
|
1145 | + return new EE_Form_Section_Proper( |
|
1146 | + array( |
|
1147 | + 'name' => 'email_validation_settings', |
|
1148 | + 'html_id' => 'email_validation_settings', |
|
1149 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1150 | + 'subsections' => apply_filters( |
|
1151 | + 'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections', |
|
1152 | + array( |
|
1153 | + 'email_validation_hdr' => new EE_Form_Section_HTML( |
|
1154 | + EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
1155 | + ), |
|
1156 | + 'email_validation_level' => new EE_Select_Input( |
|
1157 | + array( |
|
1158 | + 'basic' => esc_html__('Basic', 'event_espresso'), |
|
1159 | + 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
1160 | + 'i18n' => esc_html__('International', 'event_espresso'), |
|
1161 | + 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
1162 | + ), |
|
1163 | + array( |
|
1164 | + 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
1165 | + . EEH_Template::get_help_tab_link('email_validation_info'), |
|
1166 | + 'html_help_text' => esc_html__( |
|
1167 | + 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', |
|
1168 | + 'event_espresso' |
|
1169 | + ), |
|
1170 | + 'default' => isset( |
|
1171 | + EE_Registry::instance()->CFG->registration->email_validation_level |
|
1172 | + ) |
|
1173 | + ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
1174 | + : 'wp_default', |
|
1175 | + 'required' => false, |
|
1176 | + ) |
|
1177 | + ), |
|
1178 | + ) |
|
1179 | + ), |
|
1180 | + ) |
|
1181 | + ); |
|
1182 | + } |
|
1183 | + |
|
1184 | + |
|
1185 | + /** |
|
1186 | + * @param EE_Registration_Config $EE_Registration_Config |
|
1187 | + * @return EE_Registration_Config |
|
1188 | + * @throws EE_Error |
|
1189 | + * @throws InvalidArgumentException |
|
1190 | + * @throws ReflectionException |
|
1191 | + * @throws InvalidDataTypeException |
|
1192 | + * @throws InvalidInterfaceException |
|
1193 | + */ |
|
1194 | + public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1195 | + { |
|
1196 | + $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
1197 | + try { |
|
1198 | + $email_validation_settings_form = $this->_email_validation_settings_form(); |
|
1199 | + // if not displaying a form, then check for form submission |
|
1200 | + if ($email_validation_settings_form->was_submitted()) { |
|
1201 | + // capture form data |
|
1202 | + $email_validation_settings_form->receive_form_submission(); |
|
1203 | + // validate form data |
|
1204 | + if ($email_validation_settings_form->is_valid()) { |
|
1205 | + // grab validated data from form |
|
1206 | + $valid_data = $email_validation_settings_form->valid_data(); |
|
1207 | + if (isset($valid_data['email_validation_level'])) { |
|
1208 | + $email_validation_level = $valid_data['email_validation_level']; |
|
1209 | + // now if they want to use international email addresses |
|
1210 | + if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
1211 | + // in case we need to reset their email validation level, |
|
1212 | + // make sure that the previous value wasn't already set to one of the i18n options. |
|
1213 | + if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') { |
|
1214 | + // if so, then reset it back to "basic" since that is the only other option that, |
|
1215 | + // despite offering poor validation, supports i18n email addresses |
|
1216 | + $prev_email_validation_level = 'basic'; |
|
1217 | + } |
|
1218 | + // confirm our i18n email validation will work on the server |
|
1219 | + if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1220 | + // or reset email validation level to previous value |
|
1221 | + $email_validation_level = $prev_email_validation_level; |
|
1222 | + } |
|
1223 | + } |
|
1224 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1225 | + } else { |
|
1226 | + EE_Error::add_error( |
|
1227 | + esc_html__( |
|
1228 | + 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
|
1229 | + 'event_espresso' |
|
1230 | + ), |
|
1231 | + __FILE__, |
|
1232 | + __FUNCTION__, |
|
1233 | + __LINE__ |
|
1234 | + ); |
|
1235 | + } |
|
1236 | + } else { |
|
1237 | + if ($email_validation_settings_form->submission_error_message() !== '') { |
|
1238 | + EE_Error::add_error( |
|
1239 | + $email_validation_settings_form->submission_error_message(), |
|
1240 | + __FILE__, |
|
1241 | + __FUNCTION__, |
|
1242 | + __LINE__ |
|
1243 | + ); |
|
1244 | + } |
|
1245 | + } |
|
1246 | + } |
|
1247 | + } catch (EE_Error $e) { |
|
1248 | + $e->get_error(); |
|
1249 | + } |
|
1250 | + return $EE_Registration_Config; |
|
1251 | + } |
|
1252 | + |
|
1253 | + |
|
1254 | + /** |
|
1255 | + * confirms that the server's PHP version has the PCRE module enabled, |
|
1256 | + * and that the PCRE version works with our i18n email validation |
|
1257 | + * |
|
1258 | + * @param EE_Registration_Config $EE_Registration_Config |
|
1259 | + * @param string $email_validation_level |
|
1260 | + * @return bool |
|
1261 | + */ |
|
1262 | + private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1263 | + { |
|
1264 | + // first check that PCRE is enabled |
|
1265 | + if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1266 | + EE_Error::add_error( |
|
1267 | + sprintf( |
|
1268 | + esc_html__( |
|
1269 | + 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
1270 | + 'event_espresso' |
|
1271 | + ), |
|
1272 | + '<br />' |
|
1273 | + ), |
|
1274 | + __FILE__, |
|
1275 | + __FUNCTION__, |
|
1276 | + __LINE__ |
|
1277 | + ); |
|
1278 | + return false; |
|
1279 | + } else { |
|
1280 | + // PCRE support is enabled, but let's still |
|
1281 | + // perform a test to see if the server will support it. |
|
1282 | + // but first, save the updated validation level to the config, |
|
1283 | + // so that the validation strategy picks it up. |
|
1284 | + // this will get bumped back down if it doesn't work |
|
1285 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1286 | + try { |
|
1287 | + $email_validator = new EE_Email_Validation_Strategy(); |
|
1288 | + $i18n_email_address = apply_filters( |
|
1289 | + 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1290 | + 'jägerjü[email protected]' |
|
1291 | + ); |
|
1292 | + $email_validator->validate($i18n_email_address); |
|
1293 | + } catch (Exception $e) { |
|
1294 | + EE_Error::add_error( |
|
1295 | + sprintf( |
|
1296 | + esc_html__( |
|
1297 | + 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
1298 | + 'event_espresso' |
|
1299 | + ), |
|
1300 | + '<br />', |
|
1301 | + '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>' |
|
1302 | + ), |
|
1303 | + __FILE__, |
|
1304 | + __FUNCTION__, |
|
1305 | + __LINE__ |
|
1306 | + ); |
|
1307 | + return false; |
|
1308 | + } |
|
1309 | + } |
|
1310 | + return true; |
|
1311 | + } |
|
1312 | 1312 | } |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | */ |
20 | 20 | public function __construct($routing = true) |
21 | 21 | { |
22 | - define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS); |
|
23 | - define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS); |
|
24 | - define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
25 | - define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS); |
|
26 | - define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
22 | + define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND.'registration_form'.DS); |
|
23 | + define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets'.DS); |
|
24 | + define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/'); |
|
25 | + define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN.'templates'.DS); |
|
26 | + define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/templates/'); |
|
27 | 27 | parent::__construct($routing); |
28 | 28 | } |
29 | 29 | |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | { |
363 | 363 | wp_register_script( |
364 | 364 | 'ee-question-sortable', |
365 | - REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
365 | + REGISTRATION_FORM_CAF_ASSETS_URL.'ee_question_order.js', |
|
366 | 366 | array('jquery-ui-sortable'), |
367 | 367 | EVENT_ESPRESSO_VERSION, |
368 | 368 | true |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | */ |
449 | 449 | protected function _questions_overview_list_table() |
450 | 450 | { |
451 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
451 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
452 | 452 | 'add_question', |
453 | 453 | 'add_question', |
454 | 454 | array(), |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | protected function _question_groups_overview_list_table() |
470 | 470 | { |
471 | 471 | $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
472 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
472 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
473 | 473 | 'add_question_group', |
474 | 474 | 'add_question_group', |
475 | 475 | array(), |
@@ -531,18 +531,18 @@ discard block |
||
531 | 531 | { |
532 | 532 | $success = 0; |
533 | 533 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
534 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
534 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
535 | 535 | // if array has more than one element than success message should be plural |
536 | 536 | $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
537 | 537 | // cycle thru bulk action checkboxes |
538 | 538 | while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
539 | - if (! $this->_delete_item($ID, $model)) { |
|
539 | + if ( ! $this->_delete_item($ID, $model)) { |
|
540 | 540 | $success = 0; |
541 | 541 | } |
542 | 542 | } |
543 | - } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
543 | + } elseif ( ! empty($this->_req_data['QSG_ID'])) { |
|
544 | 544 | $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
545 | - } elseif (! empty($this->_req_data['QST_ID'])) { |
|
545 | + } elseif ( ! empty($this->_req_data['QST_ID'])) { |
|
546 | 546 | $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
547 | 547 | } else { |
548 | 548 | EE_Error::add_error( |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
612 | 612 | } |
613 | 613 | // add ID to title if editing |
614 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
614 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
615 | 615 | if ($ID) { |
616 | 616 | /** @var EE_Question_Group $questionGroup */ |
617 | 617 | $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
632 | 632 | $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL); |
633 | 633 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
634 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
634 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH.'question_groups_main_meta_box.template.php', |
|
635 | 635 | $this->_template_args, |
636 | 636 | true |
637 | 637 | ); |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | // update the existing related questions |
686 | 686 | // BUT FIRST... delete the phone question from the Question_Group_Question |
687 | 687 | // if it is being added to this question group (therefore removed from the existing group) |
688 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) { |
|
688 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) { |
|
689 | 689 | // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
690 | 690 | EEM_Question_Group_Question::instance()->delete( |
691 | 691 | array( |
@@ -700,22 +700,22 @@ discard block |
||
700 | 700 | $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
701 | 701 | $questions = $question_group->questions(); |
702 | 702 | // make sure system phone question is added to list of questions for this group |
703 | - if (! isset($questions[ $phone_question_id ])) { |
|
704 | - $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
703 | + if ( ! isset($questions[$phone_question_id])) { |
|
704 | + $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | foreach ($questions as $question_ID => $question) { |
708 | 708 | // first we always check for order. |
709 | - if (! empty($this->_req_data['question_orders'][ $question_ID ])) { |
|
709 | + if ( ! empty($this->_req_data['question_orders'][$question_ID])) { |
|
710 | 710 | // update question order |
711 | 711 | $question_group->update_question_order( |
712 | 712 | $question_ID, |
713 | - $this->_req_data['question_orders'][ $question_ID ] |
|
713 | + $this->_req_data['question_orders'][$question_ID] |
|
714 | 714 | ); |
715 | 715 | } |
716 | 716 | |
717 | 717 | // then we always check if adding or removing. |
718 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) { |
|
718 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) { |
|
719 | 719 | $question_group->add_question($question_ID); |
720 | 720 | } else { |
721 | 721 | // not found, remove it (but only if not a system question for the personal group |
@@ -736,8 +736,8 @@ discard block |
||
736 | 736 | if (isset($this->_req_data['questions'])) { |
737 | 737 | foreach ($this->_req_data['questions'] as $QST_ID) { |
738 | 738 | $question_group->add_question($QST_ID); |
739 | - if (isset($this->_req_data['question_orders'][ $QST_ID ])) { |
|
740 | - $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]); |
|
739 | + if (isset($this->_req_data['question_orders'][$QST_ID])) { |
|
740 | + $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]); |
|
741 | 741 | } |
742 | 742 | } |
743 | 743 | } |
@@ -878,33 +878,33 @@ discard block |
||
878 | 878 | // echo "trash $trash"; |
879 | 879 | // var_dump($this->_req_data['checkbox']);die; |
880 | 880 | if (isset($this->_req_data['checkbox'])) { |
881 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
881 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
882 | 882 | // if array has more than one element than success message should be plural |
883 | 883 | $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
884 | 884 | // cycle thru bulk action checkboxes |
885 | 885 | while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
886 | - if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
886 | + if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
887 | 887 | $success = 0; |
888 | 888 | } |
889 | 889 | } |
890 | 890 | } else { |
891 | 891 | // grab single id and delete |
892 | 892 | $ID = absint($this->_req_data['checkbox']); |
893 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
893 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
894 | 894 | $success = 0; |
895 | 895 | } |
896 | 896 | } |
897 | 897 | } else { |
898 | 898 | // delete via trash link |
899 | 899 | // grab single id and delete |
900 | - $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
901 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
900 | + $ID = absint($this->_req_data[$model->primary_key_name()]); |
|
901 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
902 | 902 | $success = 0; |
903 | 903 | } |
904 | 904 | } |
905 | 905 | |
906 | 906 | |
907 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) ); |
|
907 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups'; // strtolower( $model->item_name(2) ); |
|
908 | 908 | // echo "action :$action"; |
909 | 909 | // $action = 'questions' ? 'default' : $action; |
910 | 910 | if ($trash) { |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | ? (int) $this->_req_data['curpage'] |
1025 | 1025 | : null; |
1026 | 1026 | |
1027 | - if (! empty($row_ids)) { |
|
1027 | + if ( ! empty($row_ids)) { |
|
1028 | 1028 | // figure out where we start the row_id count at for the current page. |
1029 | 1029 | $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
1030 | 1030 | |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | // Update the questions when re-ordering |
1034 | 1034 | $updated = EEM_Question_Group::instance()->update( |
1035 | 1035 | array('QSG_order' => $qsgcount), |
1036 | - array(array('QSG_ID' => $row_ids[ $i ])) |
|
1036 | + array(array('QSG_ID' => $row_ids[$i])) |
|
1037 | 1037 | ); |
1038 | 1038 | if ($updated === false) { |
1039 | 1039 | $success = false; |
@@ -1079,7 +1079,7 @@ discard block |
||
1079 | 1079 | $this->_set_add_edit_form_tags('update_reg_form_settings'); |
1080 | 1080 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
1081 | 1081 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
1082 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
1082 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php', |
|
1083 | 1083 | $this->_template_args, |
1084 | 1084 | true |
1085 | 1085 | ); |
@@ -1216,7 +1216,7 @@ discard block |
||
1216 | 1216 | $prev_email_validation_level = 'basic'; |
1217 | 1217 | } |
1218 | 1218 | // confirm our i18n email validation will work on the server |
1219 | - if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1219 | + if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1220 | 1220 | // or reset email validation level to previous value |
1221 | 1221 | $email_validation_level = $prev_email_validation_level; |
1222 | 1222 | } |
@@ -1262,7 +1262,7 @@ discard block |
||
1262 | 1262 | private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
1263 | 1263 | { |
1264 | 1264 | // first check that PCRE is enabled |
1265 | - if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1265 | + if ( ! defined('PREG_BAD_UTF8_ERROR')) { |
|
1266 | 1266 | EE_Error::add_error( |
1267 | 1267 | sprintf( |
1268 | 1268 | esc_html__( |
@@ -622,7 +622,7 @@ |
||
622 | 622 | /** |
623 | 623 | * @param EE_Registration $registration |
624 | 624 | * @param EE_Question $question |
625 | - * @param $answer |
|
625 | + * @param EE_Answer $answer |
|
626 | 626 | * @return EE_Form_Input_Base |
627 | 627 | * @throws EE_Error |
628 | 628 | * @throws InvalidArgumentException |
@@ -17,1382 +17,1382 @@ |
||
17 | 17 | class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @type bool $_print_copy_info |
|
22 | - */ |
|
23 | - private $_print_copy_info = false; |
|
20 | + /** |
|
21 | + * @type bool $_print_copy_info |
|
22 | + */ |
|
23 | + private $_print_copy_info = false; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @type array $_attendee_data |
|
27 | - */ |
|
28 | - private $_attendee_data = array(); |
|
25 | + /** |
|
26 | + * @type array $_attendee_data |
|
27 | + */ |
|
28 | + private $_attendee_data = array(); |
|
29 | 29 | |
30 | - /** |
|
31 | - * @type array $_required_questions |
|
32 | - */ |
|
33 | - private $_required_questions = array(); |
|
30 | + /** |
|
31 | + * @type array $_required_questions |
|
32 | + */ |
|
33 | + private $_required_questions = array(); |
|
34 | 34 | |
35 | - /** |
|
36 | - * @type array $_registration_answers |
|
37 | - */ |
|
38 | - private $_registration_answers = array(); |
|
35 | + /** |
|
36 | + * @type array $_registration_answers |
|
37 | + */ |
|
38 | + private $_registration_answers = array(); |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * class constructor |
|
43 | - * |
|
44 | - * @access public |
|
45 | - * @param EE_Checkout $checkout |
|
46 | - */ |
|
47 | - public function __construct(EE_Checkout $checkout) |
|
48 | - { |
|
49 | - $this->_slug = 'attendee_information'; |
|
50 | - $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
|
51 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php'; |
|
52 | - $this->checkout = $checkout; |
|
53 | - $this->_reset_success_message(); |
|
54 | - $this->set_instructions( |
|
55 | - esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
56 | - ); |
|
57 | - } |
|
41 | + /** |
|
42 | + * class constructor |
|
43 | + * |
|
44 | + * @access public |
|
45 | + * @param EE_Checkout $checkout |
|
46 | + */ |
|
47 | + public function __construct(EE_Checkout $checkout) |
|
48 | + { |
|
49 | + $this->_slug = 'attendee_information'; |
|
50 | + $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
|
51 | + $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php'; |
|
52 | + $this->checkout = $checkout; |
|
53 | + $this->_reset_success_message(); |
|
54 | + $this->set_instructions( |
|
55 | + esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
56 | + ); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - public function translate_js_strings() |
|
61 | - { |
|
62 | - EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
63 | - ' is a required question.', |
|
64 | - 'event_espresso' |
|
65 | - ); |
|
66 | - EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
67 | - ' is a required question. Please enter a value for at least one of the options.', |
|
68 | - 'event_espresso' |
|
69 | - ); |
|
70 | - EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__( |
|
71 | - 'Please answer all required questions correctly before proceeding.', |
|
72 | - 'event_espresso' |
|
73 | - ); |
|
74 | - EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
75 | - esc_html_x( |
|
76 | - 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
|
77 | - 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
|
78 | - 'event_espresso' |
|
79 | - ), |
|
80 | - '<br/>' |
|
81 | - ); |
|
82 | - EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
83 | - 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
|
84 | - 'event_espresso' |
|
85 | - ); |
|
86 | - EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
87 | - 'You must enter a valid email address.', |
|
88 | - 'event_espresso' |
|
89 | - ); |
|
90 | - EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__( |
|
91 | - 'You must enter a valid email address and answer all other required questions before you can proceed.', |
|
92 | - 'event_espresso' |
|
93 | - ); |
|
94 | - } |
|
60 | + public function translate_js_strings() |
|
61 | + { |
|
62 | + EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
63 | + ' is a required question.', |
|
64 | + 'event_espresso' |
|
65 | + ); |
|
66 | + EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
67 | + ' is a required question. Please enter a value for at least one of the options.', |
|
68 | + 'event_espresso' |
|
69 | + ); |
|
70 | + EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__( |
|
71 | + 'Please answer all required questions correctly before proceeding.', |
|
72 | + 'event_espresso' |
|
73 | + ); |
|
74 | + EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
75 | + esc_html_x( |
|
76 | + 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
|
77 | + 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
|
78 | + 'event_espresso' |
|
79 | + ), |
|
80 | + '<br/>' |
|
81 | + ); |
|
82 | + EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
83 | + 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
|
84 | + 'event_espresso' |
|
85 | + ); |
|
86 | + EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
87 | + 'You must enter a valid email address.', |
|
88 | + 'event_espresso' |
|
89 | + ); |
|
90 | + EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__( |
|
91 | + 'You must enter a valid email address and answer all other required questions before you can proceed.', |
|
92 | + 'event_espresso' |
|
93 | + ); |
|
94 | + } |
|
95 | 95 | |
96 | 96 | |
97 | - public function enqueue_styles_and_scripts() |
|
98 | - { |
|
99 | - } |
|
97 | + public function enqueue_styles_and_scripts() |
|
98 | + { |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | - /** |
|
103 | - * @return boolean |
|
104 | - */ |
|
105 | - public function initialize_reg_step() |
|
106 | - { |
|
107 | - return true; |
|
108 | - } |
|
102 | + /** |
|
103 | + * @return boolean |
|
104 | + */ |
|
105 | + public function initialize_reg_step() |
|
106 | + { |
|
107 | + return true; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | |
111 | - /** |
|
112 | - * @return EE_Form_Section_Proper |
|
113 | - * @throws DomainException |
|
114 | - * @throws EE_Error |
|
115 | - * @throws InvalidArgumentException |
|
116 | - * @throws ReflectionException |
|
117 | - * @throws EntityNotFoundException |
|
118 | - * @throws InvalidDataTypeException |
|
119 | - * @throws InvalidInterfaceException |
|
120 | - */ |
|
121 | - public function generate_reg_form() |
|
122 | - { |
|
123 | - $this->_print_copy_info = false; |
|
124 | - $primary_registrant = null; |
|
125 | - // autoload Line_Item_Display classes |
|
126 | - EEH_Autoloader::register_line_item_display_autoloaders(); |
|
127 | - $Line_Item_Display = new EE_Line_Item_Display(); |
|
128 | - // calculate taxes |
|
129 | - $Line_Item_Display->display_line_item( |
|
130 | - $this->checkout->cart->get_grand_total(), |
|
131 | - array('set_tax_rate' => true) |
|
132 | - ); |
|
133 | - /** @var $subsections EE_Form_Section_Proper[] */ |
|
134 | - $subsections = array( |
|
135 | - 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), |
|
136 | - ); |
|
137 | - $template_args = array( |
|
138 | - 'revisit' => $this->checkout->revisit, |
|
139 | - 'registrations' => array(), |
|
140 | - 'ticket_count' => array(), |
|
141 | - ); |
|
142 | - // grab the saved registrations from the transaction |
|
143 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
144 | - if ($registrations) { |
|
145 | - foreach ($registrations as $registration) { |
|
146 | - // can this registration be processed during this visit ? |
|
147 | - if ($registration instanceof EE_Registration |
|
148 | - && $this->checkout->visit_allows_processing_of_this_registration($registration) |
|
149 | - ) { |
|
150 | - $subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form($registration); |
|
151 | - if (! $this->checkout->admin_request) { |
|
152 | - $template_args['registrations'][ $registration->reg_url_link() ] = $registration; |
|
153 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
154 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
155 | - ) |
|
156 | - ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
157 | - : 1; |
|
158 | - $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
159 | - $this->checkout->cart->get_grand_total(), |
|
160 | - 'Ticket', |
|
161 | - array($registration->ticket()->ID()) |
|
162 | - ); |
|
163 | - $ticket_line_item = is_array($ticket_line_item) |
|
164 | - ? reset($ticket_line_item) |
|
165 | - : $ticket_line_item; |
|
166 | - $template_args['ticket_line_item'][ $registration->ticket()->ID() ] = |
|
167 | - $Line_Item_Display->display_line_item($ticket_line_item); |
|
168 | - } |
|
169 | - if ($registration->is_primary_registrant()) { |
|
170 | - $primary_registrant = $registration->reg_url_link(); |
|
171 | - } |
|
172 | - } |
|
173 | - } |
|
174 | - // print_copy_info ? |
|
175 | - if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) { |
|
176 | - // TODO: add admin option for toggling copy attendee info, |
|
177 | - // then use that value to change $this->_print_copy_info |
|
178 | - $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info |
|
179 | - ? $this->_copy_attendee_info_form() |
|
180 | - : $this->_auto_copy_attendee_info(); |
|
181 | - // generate hidden input |
|
182 | - if (isset($subsections[ $primary_registrant ]) |
|
183 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
184 | - ) { |
|
185 | - $subsections[ $primary_registrant ]->add_subsections( |
|
186 | - $copy_options, |
|
187 | - 'primary_registrant', |
|
188 | - false |
|
189 | - ); |
|
190 | - } |
|
191 | - } |
|
192 | - } |
|
193 | - return new EE_Form_Section_Proper( |
|
194 | - array( |
|
195 | - 'name' => $this->reg_form_name(), |
|
196 | - 'html_id' => $this->reg_form_name(), |
|
197 | - 'subsections' => $subsections, |
|
198 | - 'layout_strategy' => $this->checkout->admin_request |
|
199 | - ? |
|
200 | - new EE_Div_Per_Section_Layout() |
|
201 | - : |
|
202 | - new EE_Template_Layout( |
|
203 | - array( |
|
204 | - 'layout_template_file' => $this->_template, // layout_template |
|
205 | - 'template_args' => $template_args, |
|
206 | - ) |
|
207 | - ), |
|
208 | - ) |
|
209 | - ); |
|
210 | - } |
|
111 | + /** |
|
112 | + * @return EE_Form_Section_Proper |
|
113 | + * @throws DomainException |
|
114 | + * @throws EE_Error |
|
115 | + * @throws InvalidArgumentException |
|
116 | + * @throws ReflectionException |
|
117 | + * @throws EntityNotFoundException |
|
118 | + * @throws InvalidDataTypeException |
|
119 | + * @throws InvalidInterfaceException |
|
120 | + */ |
|
121 | + public function generate_reg_form() |
|
122 | + { |
|
123 | + $this->_print_copy_info = false; |
|
124 | + $primary_registrant = null; |
|
125 | + // autoload Line_Item_Display classes |
|
126 | + EEH_Autoloader::register_line_item_display_autoloaders(); |
|
127 | + $Line_Item_Display = new EE_Line_Item_Display(); |
|
128 | + // calculate taxes |
|
129 | + $Line_Item_Display->display_line_item( |
|
130 | + $this->checkout->cart->get_grand_total(), |
|
131 | + array('set_tax_rate' => true) |
|
132 | + ); |
|
133 | + /** @var $subsections EE_Form_Section_Proper[] */ |
|
134 | + $subsections = array( |
|
135 | + 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), |
|
136 | + ); |
|
137 | + $template_args = array( |
|
138 | + 'revisit' => $this->checkout->revisit, |
|
139 | + 'registrations' => array(), |
|
140 | + 'ticket_count' => array(), |
|
141 | + ); |
|
142 | + // grab the saved registrations from the transaction |
|
143 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
144 | + if ($registrations) { |
|
145 | + foreach ($registrations as $registration) { |
|
146 | + // can this registration be processed during this visit ? |
|
147 | + if ($registration instanceof EE_Registration |
|
148 | + && $this->checkout->visit_allows_processing_of_this_registration($registration) |
|
149 | + ) { |
|
150 | + $subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form($registration); |
|
151 | + if (! $this->checkout->admin_request) { |
|
152 | + $template_args['registrations'][ $registration->reg_url_link() ] = $registration; |
|
153 | + $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
154 | + $template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
155 | + ) |
|
156 | + ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
157 | + : 1; |
|
158 | + $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
159 | + $this->checkout->cart->get_grand_total(), |
|
160 | + 'Ticket', |
|
161 | + array($registration->ticket()->ID()) |
|
162 | + ); |
|
163 | + $ticket_line_item = is_array($ticket_line_item) |
|
164 | + ? reset($ticket_line_item) |
|
165 | + : $ticket_line_item; |
|
166 | + $template_args['ticket_line_item'][ $registration->ticket()->ID() ] = |
|
167 | + $Line_Item_Display->display_line_item($ticket_line_item); |
|
168 | + } |
|
169 | + if ($registration->is_primary_registrant()) { |
|
170 | + $primary_registrant = $registration->reg_url_link(); |
|
171 | + } |
|
172 | + } |
|
173 | + } |
|
174 | + // print_copy_info ? |
|
175 | + if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) { |
|
176 | + // TODO: add admin option for toggling copy attendee info, |
|
177 | + // then use that value to change $this->_print_copy_info |
|
178 | + $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info |
|
179 | + ? $this->_copy_attendee_info_form() |
|
180 | + : $this->_auto_copy_attendee_info(); |
|
181 | + // generate hidden input |
|
182 | + if (isset($subsections[ $primary_registrant ]) |
|
183 | + && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
184 | + ) { |
|
185 | + $subsections[ $primary_registrant ]->add_subsections( |
|
186 | + $copy_options, |
|
187 | + 'primary_registrant', |
|
188 | + false |
|
189 | + ); |
|
190 | + } |
|
191 | + } |
|
192 | + } |
|
193 | + return new EE_Form_Section_Proper( |
|
194 | + array( |
|
195 | + 'name' => $this->reg_form_name(), |
|
196 | + 'html_id' => $this->reg_form_name(), |
|
197 | + 'subsections' => $subsections, |
|
198 | + 'layout_strategy' => $this->checkout->admin_request |
|
199 | + ? |
|
200 | + new EE_Div_Per_Section_Layout() |
|
201 | + : |
|
202 | + new EE_Template_Layout( |
|
203 | + array( |
|
204 | + 'layout_template_file' => $this->_template, // layout_template |
|
205 | + 'template_args' => $template_args, |
|
206 | + ) |
|
207 | + ), |
|
208 | + ) |
|
209 | + ); |
|
210 | + } |
|
211 | 211 | |
212 | 212 | |
213 | - /** |
|
214 | - * @param EE_Registration $registration |
|
215 | - * @return EE_Form_Section_Base |
|
216 | - * @throws EE_Error |
|
217 | - * @throws InvalidArgumentException |
|
218 | - * @throws EntityNotFoundException |
|
219 | - * @throws InvalidDataTypeException |
|
220 | - * @throws InvalidInterfaceException |
|
221 | - * @throws ReflectionException |
|
222 | - */ |
|
223 | - private function _registrations_reg_form(EE_Registration $registration) |
|
224 | - { |
|
225 | - static $attendee_nmbr = 1; |
|
226 | - $form_args = array(); |
|
227 | - // verify that registration has valid event |
|
228 | - if ($registration->event() instanceof EE_Event) { |
|
229 | - $question_groups = $registration->event()->question_groups( |
|
230 | - apply_filters( |
|
231 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters', |
|
232 | - array( |
|
233 | - array( |
|
234 | - 'Event.EVT_ID' => $registration->event()->ID(), |
|
235 | - 'Event_Question_Group.EQG_primary' => $registration->count() === 1, |
|
236 | - ), |
|
237 | - 'order_by' => array('QSG_order' => 'ASC'), |
|
238 | - ), |
|
239 | - $registration, |
|
240 | - $this |
|
241 | - ) |
|
242 | - ); |
|
243 | - if ($question_groups) { |
|
244 | - // array of params to pass to parent constructor |
|
245 | - $form_args = array( |
|
246 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
247 | - 'html_class' => 'ee-reg-form-attendee-dv', |
|
248 | - 'html_style' => $this->checkout->admin_request |
|
249 | - ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
250 | - : '', |
|
251 | - 'subsections' => array(), |
|
252 | - 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
253 | - array( |
|
254 | - 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
255 | - 'legend_text' => sprintf( |
|
256 | - esc_html_x( |
|
257 | - 'Attendee %d', |
|
258 | - 'Attendee 123', |
|
259 | - 'event_espresso' |
|
260 | - ), |
|
261 | - $attendee_nmbr |
|
262 | - ), |
|
263 | - ) |
|
264 | - ), |
|
265 | - ); |
|
266 | - foreach ($question_groups as $question_group) { |
|
267 | - if ($question_group instanceof EE_Question_Group) { |
|
268 | - $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
|
269 | - $registration, |
|
270 | - $question_group |
|
271 | - ); |
|
272 | - } |
|
273 | - } |
|
274 | - // add hidden input |
|
275 | - $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( |
|
276 | - $registration |
|
277 | - ); |
|
278 | - // if we have question groups for additional attendees, then display the copy options |
|
279 | - $this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info; |
|
280 | - if ($registration->is_primary_registrant()) { |
|
281 | - // generate hidden input |
|
282 | - $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( |
|
283 | - $registration |
|
284 | - ); |
|
285 | - } |
|
286 | - } |
|
287 | - } |
|
288 | - $attendee_nmbr++; |
|
289 | - return ! empty($form_args) |
|
290 | - ? new EE_Form_Section_Proper($form_args) |
|
291 | - : new EE_Form_Section_HTML(); |
|
292 | - } |
|
213 | + /** |
|
214 | + * @param EE_Registration $registration |
|
215 | + * @return EE_Form_Section_Base |
|
216 | + * @throws EE_Error |
|
217 | + * @throws InvalidArgumentException |
|
218 | + * @throws EntityNotFoundException |
|
219 | + * @throws InvalidDataTypeException |
|
220 | + * @throws InvalidInterfaceException |
|
221 | + * @throws ReflectionException |
|
222 | + */ |
|
223 | + private function _registrations_reg_form(EE_Registration $registration) |
|
224 | + { |
|
225 | + static $attendee_nmbr = 1; |
|
226 | + $form_args = array(); |
|
227 | + // verify that registration has valid event |
|
228 | + if ($registration->event() instanceof EE_Event) { |
|
229 | + $question_groups = $registration->event()->question_groups( |
|
230 | + apply_filters( |
|
231 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters', |
|
232 | + array( |
|
233 | + array( |
|
234 | + 'Event.EVT_ID' => $registration->event()->ID(), |
|
235 | + 'Event_Question_Group.EQG_primary' => $registration->count() === 1, |
|
236 | + ), |
|
237 | + 'order_by' => array('QSG_order' => 'ASC'), |
|
238 | + ), |
|
239 | + $registration, |
|
240 | + $this |
|
241 | + ) |
|
242 | + ); |
|
243 | + if ($question_groups) { |
|
244 | + // array of params to pass to parent constructor |
|
245 | + $form_args = array( |
|
246 | + 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
247 | + 'html_class' => 'ee-reg-form-attendee-dv', |
|
248 | + 'html_style' => $this->checkout->admin_request |
|
249 | + ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
250 | + : '', |
|
251 | + 'subsections' => array(), |
|
252 | + 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
253 | + array( |
|
254 | + 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
255 | + 'legend_text' => sprintf( |
|
256 | + esc_html_x( |
|
257 | + 'Attendee %d', |
|
258 | + 'Attendee 123', |
|
259 | + 'event_espresso' |
|
260 | + ), |
|
261 | + $attendee_nmbr |
|
262 | + ), |
|
263 | + ) |
|
264 | + ), |
|
265 | + ); |
|
266 | + foreach ($question_groups as $question_group) { |
|
267 | + if ($question_group instanceof EE_Question_Group) { |
|
268 | + $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
|
269 | + $registration, |
|
270 | + $question_group |
|
271 | + ); |
|
272 | + } |
|
273 | + } |
|
274 | + // add hidden input |
|
275 | + $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( |
|
276 | + $registration |
|
277 | + ); |
|
278 | + // if we have question groups for additional attendees, then display the copy options |
|
279 | + $this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info; |
|
280 | + if ($registration->is_primary_registrant()) { |
|
281 | + // generate hidden input |
|
282 | + $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( |
|
283 | + $registration |
|
284 | + ); |
|
285 | + } |
|
286 | + } |
|
287 | + } |
|
288 | + $attendee_nmbr++; |
|
289 | + return ! empty($form_args) |
|
290 | + ? new EE_Form_Section_Proper($form_args) |
|
291 | + : new EE_Form_Section_HTML(); |
|
292 | + } |
|
293 | 293 | |
294 | 294 | |
295 | - /** |
|
296 | - * @param EE_Registration $registration |
|
297 | - * @param bool $additional_attendee_reg_info |
|
298 | - * @return EE_Form_Input_Base |
|
299 | - * @throws EE_Error |
|
300 | - */ |
|
301 | - private function _additional_attendee_reg_info_input( |
|
302 | - EE_Registration $registration, |
|
303 | - $additional_attendee_reg_info = true |
|
304 | - ) { |
|
305 | - // generate hidden input |
|
306 | - return new EE_Hidden_Input( |
|
307 | - array( |
|
308 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
309 | - 'default' => $additional_attendee_reg_info, |
|
310 | - ) |
|
311 | - ); |
|
312 | - } |
|
295 | + /** |
|
296 | + * @param EE_Registration $registration |
|
297 | + * @param bool $additional_attendee_reg_info |
|
298 | + * @return EE_Form_Input_Base |
|
299 | + * @throws EE_Error |
|
300 | + */ |
|
301 | + private function _additional_attendee_reg_info_input( |
|
302 | + EE_Registration $registration, |
|
303 | + $additional_attendee_reg_info = true |
|
304 | + ) { |
|
305 | + // generate hidden input |
|
306 | + return new EE_Hidden_Input( |
|
307 | + array( |
|
308 | + 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
309 | + 'default' => $additional_attendee_reg_info, |
|
310 | + ) |
|
311 | + ); |
|
312 | + } |
|
313 | 313 | |
314 | 314 | |
315 | - /** |
|
316 | - * @param EE_Registration $registration |
|
317 | - * @param EE_Question_Group $question_group |
|
318 | - * @return EE_Form_Section_Proper |
|
319 | - * @throws EE_Error |
|
320 | - * @throws InvalidArgumentException |
|
321 | - * @throws InvalidDataTypeException |
|
322 | - * @throws InvalidInterfaceException |
|
323 | - * @throws ReflectionException |
|
324 | - */ |
|
325 | - private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) |
|
326 | - { |
|
327 | - // array of params to pass to parent constructor |
|
328 | - $form_args = array( |
|
329 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(), |
|
330 | - 'html_class' => $this->checkout->admin_request |
|
331 | - ? 'form-table ee-reg-form-qstn-grp-dv' |
|
332 | - : 'ee-reg-form-qstn-grp-dv', |
|
333 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' |
|
334 | - . $registration->ID() . '-lbl', |
|
335 | - 'subsections' => array( |
|
336 | - 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group), |
|
337 | - ), |
|
338 | - 'layout_strategy' => $this->checkout->admin_request |
|
339 | - ? new EE_Admin_Two_Column_Layout() |
|
340 | - : new EE_Div_Per_Section_Layout(), |
|
341 | - ); |
|
342 | - // where params |
|
343 | - $query_params = array('QST_deleted' => 0); |
|
344 | - // don't load admin only questions on the frontend |
|
345 | - if (! $this->checkout->admin_request) { |
|
346 | - $query_params['QST_admin_only'] = array('!=', true); |
|
347 | - } |
|
348 | - $questions = $question_group->get_many_related( |
|
349 | - 'Question', |
|
350 | - apply_filters( |
|
351 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params', |
|
352 | - array( |
|
353 | - $query_params, |
|
354 | - 'order_by' => array( |
|
355 | - 'Question_Group_Question.QGQ_order' => 'ASC', |
|
356 | - ), |
|
357 | - ), |
|
358 | - $question_group, |
|
359 | - $registration, |
|
360 | - $this |
|
361 | - ) |
|
362 | - ); |
|
363 | - // filter for additional content before questions |
|
364 | - $form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML( |
|
365 | - apply_filters( |
|
366 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
367 | - '', |
|
368 | - $registration, |
|
369 | - $question_group, |
|
370 | - $this |
|
371 | - ) |
|
372 | - ); |
|
373 | - // loop thru questions |
|
374 | - foreach ($questions as $question) { |
|
375 | - if ($question instanceof EE_Question) { |
|
376 | - $identifier = $question->is_system_question() |
|
377 | - ? $question->system_ID() |
|
378 | - : $question->ID(); |
|
379 | - $form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question); |
|
380 | - } |
|
381 | - } |
|
382 | - $form_args['subsections'] = apply_filters( |
|
383 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', |
|
384 | - $form_args['subsections'], |
|
385 | - $registration, |
|
386 | - $question_group, |
|
387 | - $this |
|
388 | - ); |
|
389 | - // filter for additional content after questions |
|
390 | - $form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML( |
|
391 | - apply_filters( |
|
392 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
393 | - '', |
|
394 | - $registration, |
|
395 | - $question_group, |
|
396 | - $this |
|
397 | - ) |
|
398 | - ); |
|
399 | - // d($form_args); |
|
400 | - $question_group_reg_form = new EE_Form_Section_Proper($form_args); |
|
401 | - return apply_filters( |
|
402 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
403 | - $question_group_reg_form, |
|
404 | - $registration, |
|
405 | - $question_group, |
|
406 | - $this |
|
407 | - ); |
|
408 | - } |
|
315 | + /** |
|
316 | + * @param EE_Registration $registration |
|
317 | + * @param EE_Question_Group $question_group |
|
318 | + * @return EE_Form_Section_Proper |
|
319 | + * @throws EE_Error |
|
320 | + * @throws InvalidArgumentException |
|
321 | + * @throws InvalidDataTypeException |
|
322 | + * @throws InvalidInterfaceException |
|
323 | + * @throws ReflectionException |
|
324 | + */ |
|
325 | + private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) |
|
326 | + { |
|
327 | + // array of params to pass to parent constructor |
|
328 | + $form_args = array( |
|
329 | + 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(), |
|
330 | + 'html_class' => $this->checkout->admin_request |
|
331 | + ? 'form-table ee-reg-form-qstn-grp-dv' |
|
332 | + : 'ee-reg-form-qstn-grp-dv', |
|
333 | + 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' |
|
334 | + . $registration->ID() . '-lbl', |
|
335 | + 'subsections' => array( |
|
336 | + 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group), |
|
337 | + ), |
|
338 | + 'layout_strategy' => $this->checkout->admin_request |
|
339 | + ? new EE_Admin_Two_Column_Layout() |
|
340 | + : new EE_Div_Per_Section_Layout(), |
|
341 | + ); |
|
342 | + // where params |
|
343 | + $query_params = array('QST_deleted' => 0); |
|
344 | + // don't load admin only questions on the frontend |
|
345 | + if (! $this->checkout->admin_request) { |
|
346 | + $query_params['QST_admin_only'] = array('!=', true); |
|
347 | + } |
|
348 | + $questions = $question_group->get_many_related( |
|
349 | + 'Question', |
|
350 | + apply_filters( |
|
351 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params', |
|
352 | + array( |
|
353 | + $query_params, |
|
354 | + 'order_by' => array( |
|
355 | + 'Question_Group_Question.QGQ_order' => 'ASC', |
|
356 | + ), |
|
357 | + ), |
|
358 | + $question_group, |
|
359 | + $registration, |
|
360 | + $this |
|
361 | + ) |
|
362 | + ); |
|
363 | + // filter for additional content before questions |
|
364 | + $form_args['subsections']['reg_form_questions_before'] = new EE_Form_Section_HTML( |
|
365 | + apply_filters( |
|
366 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
367 | + '', |
|
368 | + $registration, |
|
369 | + $question_group, |
|
370 | + $this |
|
371 | + ) |
|
372 | + ); |
|
373 | + // loop thru questions |
|
374 | + foreach ($questions as $question) { |
|
375 | + if ($question instanceof EE_Question) { |
|
376 | + $identifier = $question->is_system_question() |
|
377 | + ? $question->system_ID() |
|
378 | + : $question->ID(); |
|
379 | + $form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question); |
|
380 | + } |
|
381 | + } |
|
382 | + $form_args['subsections'] = apply_filters( |
|
383 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', |
|
384 | + $form_args['subsections'], |
|
385 | + $registration, |
|
386 | + $question_group, |
|
387 | + $this |
|
388 | + ); |
|
389 | + // filter for additional content after questions |
|
390 | + $form_args['subsections']['reg_form_questions_after'] = new EE_Form_Section_HTML( |
|
391 | + apply_filters( |
|
392 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
393 | + '', |
|
394 | + $registration, |
|
395 | + $question_group, |
|
396 | + $this |
|
397 | + ) |
|
398 | + ); |
|
399 | + // d($form_args); |
|
400 | + $question_group_reg_form = new EE_Form_Section_Proper($form_args); |
|
401 | + return apply_filters( |
|
402 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
403 | + $question_group_reg_form, |
|
404 | + $registration, |
|
405 | + $question_group, |
|
406 | + $this |
|
407 | + ); |
|
408 | + } |
|
409 | 409 | |
410 | 410 | |
411 | - /** |
|
412 | - * @param EE_Question_Group $question_group |
|
413 | - * @return EE_Form_Section_HTML |
|
414 | - */ |
|
415 | - private function _question_group_header(EE_Question_Group $question_group) |
|
416 | - { |
|
417 | - $html = ''; |
|
418 | - // group_name |
|
419 | - if ($question_group->show_group_name() && $question_group->name() !== '') { |
|
420 | - if ($this->checkout->admin_request) { |
|
421 | - $html .= EEH_HTML::br(); |
|
422 | - $html .= EEH_HTML::h3( |
|
423 | - $question_group->name(), |
|
424 | - '', |
|
425 | - 'ee-reg-form-qstn-grp-title title', |
|
426 | - 'font-size: 1.3em; padding-left:0;' |
|
427 | - ); |
|
428 | - } else { |
|
429 | - $html .= EEH_HTML::h4( |
|
430 | - $question_group->name(), |
|
431 | - '', |
|
432 | - 'ee-reg-form-qstn-grp-title section-title' |
|
433 | - ); |
|
434 | - } |
|
435 | - } |
|
436 | - // group_desc |
|
437 | - if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
438 | - $html .= EEH_HTML::p( |
|
439 | - $question_group->desc(), |
|
440 | - '', |
|
441 | - $this->checkout->admin_request |
|
442 | - ? 'ee-reg-form-qstn-grp-desc-pg' |
|
443 | - : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text' |
|
444 | - ); |
|
445 | - } |
|
446 | - return new EE_Form_Section_HTML($html); |
|
447 | - } |
|
411 | + /** |
|
412 | + * @param EE_Question_Group $question_group |
|
413 | + * @return EE_Form_Section_HTML |
|
414 | + */ |
|
415 | + private function _question_group_header(EE_Question_Group $question_group) |
|
416 | + { |
|
417 | + $html = ''; |
|
418 | + // group_name |
|
419 | + if ($question_group->show_group_name() && $question_group->name() !== '') { |
|
420 | + if ($this->checkout->admin_request) { |
|
421 | + $html .= EEH_HTML::br(); |
|
422 | + $html .= EEH_HTML::h3( |
|
423 | + $question_group->name(), |
|
424 | + '', |
|
425 | + 'ee-reg-form-qstn-grp-title title', |
|
426 | + 'font-size: 1.3em; padding-left:0;' |
|
427 | + ); |
|
428 | + } else { |
|
429 | + $html .= EEH_HTML::h4( |
|
430 | + $question_group->name(), |
|
431 | + '', |
|
432 | + 'ee-reg-form-qstn-grp-title section-title' |
|
433 | + ); |
|
434 | + } |
|
435 | + } |
|
436 | + // group_desc |
|
437 | + if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
438 | + $html .= EEH_HTML::p( |
|
439 | + $question_group->desc(), |
|
440 | + '', |
|
441 | + $this->checkout->admin_request |
|
442 | + ? 'ee-reg-form-qstn-grp-desc-pg' |
|
443 | + : 'ee-reg-form-qstn-grp-desc-pg small-text lt-grey-text' |
|
444 | + ); |
|
445 | + } |
|
446 | + return new EE_Form_Section_HTML($html); |
|
447 | + } |
|
448 | 448 | |
449 | 449 | |
450 | - /** |
|
451 | - * @return EE_Form_Section_Proper |
|
452 | - * @throws EE_Error |
|
453 | - * @throws InvalidArgumentException |
|
454 | - * @throws ReflectionException |
|
455 | - * @throws InvalidDataTypeException |
|
456 | - * @throws InvalidInterfaceException |
|
457 | - */ |
|
458 | - private function _copy_attendee_info_form() |
|
459 | - { |
|
460 | - // array of params to pass to parent constructor |
|
461 | - return new EE_Form_Section_Proper( |
|
462 | - array( |
|
463 | - 'subsections' => $this->_copy_attendee_info_inputs(), |
|
464 | - 'layout_strategy' => new EE_Template_Layout( |
|
465 | - array( |
|
466 | - 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
467 | - . $this->_slug |
|
468 | - . DS |
|
469 | - . 'copy_attendee_info.template.php', |
|
470 | - 'begin_template_file' => null, |
|
471 | - 'input_template_file' => null, |
|
472 | - 'subsection_template_file' => null, |
|
473 | - 'end_template_file' => null, |
|
474 | - ) |
|
475 | - ), |
|
476 | - ) |
|
477 | - ); |
|
478 | - } |
|
450 | + /** |
|
451 | + * @return EE_Form_Section_Proper |
|
452 | + * @throws EE_Error |
|
453 | + * @throws InvalidArgumentException |
|
454 | + * @throws ReflectionException |
|
455 | + * @throws InvalidDataTypeException |
|
456 | + * @throws InvalidInterfaceException |
|
457 | + */ |
|
458 | + private function _copy_attendee_info_form() |
|
459 | + { |
|
460 | + // array of params to pass to parent constructor |
|
461 | + return new EE_Form_Section_Proper( |
|
462 | + array( |
|
463 | + 'subsections' => $this->_copy_attendee_info_inputs(), |
|
464 | + 'layout_strategy' => new EE_Template_Layout( |
|
465 | + array( |
|
466 | + 'layout_template_file' => SPCO_REG_STEPS_PATH |
|
467 | + . $this->_slug |
|
468 | + . DS |
|
469 | + . 'copy_attendee_info.template.php', |
|
470 | + 'begin_template_file' => null, |
|
471 | + 'input_template_file' => null, |
|
472 | + 'subsection_template_file' => null, |
|
473 | + 'end_template_file' => null, |
|
474 | + ) |
|
475 | + ), |
|
476 | + ) |
|
477 | + ); |
|
478 | + } |
|
479 | 479 | |
480 | 480 | |
481 | - /** |
|
482 | - * @return EE_Form_Section_HTML |
|
483 | - * @throws DomainException |
|
484 | - * @throws InvalidArgumentException |
|
485 | - * @throws InvalidDataTypeException |
|
486 | - * @throws InvalidInterfaceException |
|
487 | - */ |
|
488 | - private function _auto_copy_attendee_info() |
|
489 | - { |
|
490 | - return new EE_Form_Section_HTML( |
|
491 | - EEH_Template::locate_template( |
|
492 | - SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php', |
|
493 | - apply_filters( |
|
494 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
|
495 | - array() |
|
496 | - ), |
|
497 | - true, |
|
498 | - true |
|
499 | - ) |
|
500 | - ); |
|
501 | - } |
|
481 | + /** |
|
482 | + * @return EE_Form_Section_HTML |
|
483 | + * @throws DomainException |
|
484 | + * @throws InvalidArgumentException |
|
485 | + * @throws InvalidDataTypeException |
|
486 | + * @throws InvalidInterfaceException |
|
487 | + */ |
|
488 | + private function _auto_copy_attendee_info() |
|
489 | + { |
|
490 | + return new EE_Form_Section_HTML( |
|
491 | + EEH_Template::locate_template( |
|
492 | + SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php', |
|
493 | + apply_filters( |
|
494 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
|
495 | + array() |
|
496 | + ), |
|
497 | + true, |
|
498 | + true |
|
499 | + ) |
|
500 | + ); |
|
501 | + } |
|
502 | 502 | |
503 | 503 | |
504 | - /** |
|
505 | - * @return array |
|
506 | - * @throws EE_Error |
|
507 | - * @throws InvalidArgumentException |
|
508 | - * @throws ReflectionException |
|
509 | - * @throws InvalidDataTypeException |
|
510 | - * @throws InvalidInterfaceException |
|
511 | - */ |
|
512 | - private function _copy_attendee_info_inputs() |
|
513 | - { |
|
514 | - $copy_attendee_info_inputs = array(); |
|
515 | - $prev_ticket = null; |
|
516 | - // grab the saved registrations from the transaction |
|
517 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
518 | - foreach ($registrations as $registration) { |
|
519 | - // for all attendees other than the primary attendee |
|
520 | - if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
521 | - // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
|
522 | - if ($registration->ticket()->ID() !== $prev_ticket) { |
|
523 | - $item_name = $registration->ticket()->name(); |
|
524 | - $item_name .= $registration->ticket()->description() !== '' |
|
525 | - ? ' - ' . $registration->ticket()->description() |
|
526 | - : ''; |
|
527 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = |
|
528 | - new EE_Form_Section_HTML( |
|
529 | - '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
530 | - ); |
|
531 | - $prev_ticket = $registration->ticket()->ID(); |
|
532 | - } |
|
504 | + /** |
|
505 | + * @return array |
|
506 | + * @throws EE_Error |
|
507 | + * @throws InvalidArgumentException |
|
508 | + * @throws ReflectionException |
|
509 | + * @throws InvalidDataTypeException |
|
510 | + * @throws InvalidInterfaceException |
|
511 | + */ |
|
512 | + private function _copy_attendee_info_inputs() |
|
513 | + { |
|
514 | + $copy_attendee_info_inputs = array(); |
|
515 | + $prev_ticket = null; |
|
516 | + // grab the saved registrations from the transaction |
|
517 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
518 | + foreach ($registrations as $registration) { |
|
519 | + // for all attendees other than the primary attendee |
|
520 | + if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
521 | + // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
|
522 | + if ($registration->ticket()->ID() !== $prev_ticket) { |
|
523 | + $item_name = $registration->ticket()->name(); |
|
524 | + $item_name .= $registration->ticket()->description() !== '' |
|
525 | + ? ' - ' . $registration->ticket()->description() |
|
526 | + : ''; |
|
527 | + $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = |
|
528 | + new EE_Form_Section_HTML( |
|
529 | + '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
530 | + ); |
|
531 | + $prev_ticket = $registration->ticket()->ID(); |
|
532 | + } |
|
533 | 533 | |
534 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = |
|
535 | - new EE_Checkbox_Multi_Input( |
|
536 | - array( |
|
537 | - $registration->ID() => sprintf( |
|
538 | - esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'), |
|
539 | - $registration->count() |
|
540 | - ), |
|
541 | - ), |
|
542 | - array( |
|
543 | - 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
544 | - 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
|
545 | - 'display_html_label_text' => false, |
|
546 | - ) |
|
547 | - ); |
|
548 | - } |
|
549 | - } |
|
550 | - return $copy_attendee_info_inputs; |
|
551 | - } |
|
534 | + $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = |
|
535 | + new EE_Checkbox_Multi_Input( |
|
536 | + array( |
|
537 | + $registration->ID() => sprintf( |
|
538 | + esc_html_x('Attendee #%s', 'Attendee #123', 'event_espresso'), |
|
539 | + $registration->count() |
|
540 | + ), |
|
541 | + ), |
|
542 | + array( |
|
543 | + 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
544 | + 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
|
545 | + 'display_html_label_text' => false, |
|
546 | + ) |
|
547 | + ); |
|
548 | + } |
|
549 | + } |
|
550 | + return $copy_attendee_info_inputs; |
|
551 | + } |
|
552 | 552 | |
553 | 553 | |
554 | - /** |
|
555 | - * @param EE_Registration $registration |
|
556 | - * @return EE_Form_Input_Base |
|
557 | - * @throws EE_Error |
|
558 | - */ |
|
559 | - private function _additional_primary_registrant_inputs(EE_Registration $registration) |
|
560 | - { |
|
561 | - // generate hidden input |
|
562 | - return new EE_Hidden_Input( |
|
563 | - array( |
|
564 | - 'html_id' => 'primary_registrant', |
|
565 | - 'default' => $registration->reg_url_link(), |
|
566 | - ) |
|
567 | - ); |
|
568 | - } |
|
554 | + /** |
|
555 | + * @param EE_Registration $registration |
|
556 | + * @return EE_Form_Input_Base |
|
557 | + * @throws EE_Error |
|
558 | + */ |
|
559 | + private function _additional_primary_registrant_inputs(EE_Registration $registration) |
|
560 | + { |
|
561 | + // generate hidden input |
|
562 | + return new EE_Hidden_Input( |
|
563 | + array( |
|
564 | + 'html_id' => 'primary_registrant', |
|
565 | + 'default' => $registration->reg_url_link(), |
|
566 | + ) |
|
567 | + ); |
|
568 | + } |
|
569 | 569 | |
570 | 570 | |
571 | - /** |
|
572 | - * @param EE_Registration $registration |
|
573 | - * @param EE_Question $question |
|
574 | - * @return EE_Form_Input_Base |
|
575 | - * @throws EE_Error |
|
576 | - * @throws InvalidArgumentException |
|
577 | - * @throws InvalidDataTypeException |
|
578 | - * @throws InvalidInterfaceException |
|
579 | - * @throws ReflectionException |
|
580 | - */ |
|
581 | - public function reg_form_question(EE_Registration $registration, EE_Question $question) |
|
582 | - { |
|
571 | + /** |
|
572 | + * @param EE_Registration $registration |
|
573 | + * @param EE_Question $question |
|
574 | + * @return EE_Form_Input_Base |
|
575 | + * @throws EE_Error |
|
576 | + * @throws InvalidArgumentException |
|
577 | + * @throws InvalidDataTypeException |
|
578 | + * @throws InvalidInterfaceException |
|
579 | + * @throws ReflectionException |
|
580 | + */ |
|
581 | + public function reg_form_question(EE_Registration $registration, EE_Question $question) |
|
582 | + { |
|
583 | 583 | |
584 | - // if this question was for an attendee detail, then check for that answer |
|
585 | - $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( |
|
586 | - $registration, |
|
587 | - $question->system_ID() |
|
588 | - ); |
|
589 | - $answer = $answer_value === null |
|
590 | - ? EEM_Answer::instance()->get_one( |
|
591 | - array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
592 | - ) |
|
593 | - : null; |
|
594 | - // if NOT returning to edit an existing registration |
|
595 | - // OR if this question is for an attendee property |
|
596 | - // OR we still don't have an EE_Answer object |
|
597 | - if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
598 | - // create an EE_Answer object for storing everything in |
|
599 | - $answer = EE_Answer::new_instance( |
|
600 | - array( |
|
601 | - 'QST_ID' => $question->ID(), |
|
602 | - 'REG_ID' => $registration->ID(), |
|
603 | - ) |
|
604 | - ); |
|
605 | - } |
|
606 | - // verify instance |
|
607 | - if ($answer instanceof EE_Answer) { |
|
608 | - if (! empty($answer_value)) { |
|
609 | - $answer->set('ANS_value', $answer_value); |
|
610 | - } |
|
611 | - $answer->cache('Question', $question); |
|
612 | - // remember system ID had a bug where sometimes it could be null |
|
613 | - $answer_cache_id = $question->is_system_question() |
|
614 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
615 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
616 | - $registration->cache('Answer', $answer, $answer_cache_id); |
|
617 | - } |
|
618 | - return $this->_generate_question_input($registration, $question, $answer); |
|
619 | - } |
|
584 | + // if this question was for an attendee detail, then check for that answer |
|
585 | + $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( |
|
586 | + $registration, |
|
587 | + $question->system_ID() |
|
588 | + ); |
|
589 | + $answer = $answer_value === null |
|
590 | + ? EEM_Answer::instance()->get_one( |
|
591 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
592 | + ) |
|
593 | + : null; |
|
594 | + // if NOT returning to edit an existing registration |
|
595 | + // OR if this question is for an attendee property |
|
596 | + // OR we still don't have an EE_Answer object |
|
597 | + if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
598 | + // create an EE_Answer object for storing everything in |
|
599 | + $answer = EE_Answer::new_instance( |
|
600 | + array( |
|
601 | + 'QST_ID' => $question->ID(), |
|
602 | + 'REG_ID' => $registration->ID(), |
|
603 | + ) |
|
604 | + ); |
|
605 | + } |
|
606 | + // verify instance |
|
607 | + if ($answer instanceof EE_Answer) { |
|
608 | + if (! empty($answer_value)) { |
|
609 | + $answer->set('ANS_value', $answer_value); |
|
610 | + } |
|
611 | + $answer->cache('Question', $question); |
|
612 | + // remember system ID had a bug where sometimes it could be null |
|
613 | + $answer_cache_id = $question->is_system_question() |
|
614 | + ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
615 | + : $question->ID() . '-' . $registration->reg_url_link(); |
|
616 | + $registration->cache('Answer', $answer, $answer_cache_id); |
|
617 | + } |
|
618 | + return $this->_generate_question_input($registration, $question, $answer); |
|
619 | + } |
|
620 | 620 | |
621 | 621 | |
622 | - /** |
|
623 | - * @param EE_Registration $registration |
|
624 | - * @param EE_Question $question |
|
625 | - * @param $answer |
|
626 | - * @return EE_Form_Input_Base |
|
627 | - * @throws EE_Error |
|
628 | - * @throws InvalidArgumentException |
|
629 | - * @throws ReflectionException |
|
630 | - * @throws InvalidDataTypeException |
|
631 | - * @throws InvalidInterfaceException |
|
632 | - */ |
|
633 | - private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) |
|
634 | - { |
|
635 | - $identifier = $question->is_system_question() |
|
636 | - ? $question->system_ID() |
|
637 | - : $question->ID(); |
|
638 | - $this->_required_questions[ $identifier ] = $question->required() ? true : false; |
|
639 | - add_filter( |
|
640 | - 'FHEE__EE_Question__generate_form_input__country_options', |
|
641 | - array($this, 'use_cached_countries_for_form_input'), |
|
642 | - 10, |
|
643 | - 4 |
|
644 | - ); |
|
645 | - add_filter( |
|
646 | - 'FHEE__EE_Question__generate_form_input__state_options', |
|
647 | - array($this, 'use_cached_states_for_form_input'), |
|
648 | - 10, |
|
649 | - 4 |
|
650 | - ); |
|
651 | - $input_constructor_args = array( |
|
652 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
653 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
654 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
655 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
656 | - 'html_label_class' => 'ee-reg-qstn', |
|
657 | - ); |
|
658 | - $input_constructor_args['html_label_id'] .= '-lbl'; |
|
659 | - if ($answer instanceof EE_Answer && $answer->ID()) { |
|
660 | - $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
661 | - $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
662 | - $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
663 | - } |
|
664 | - $form_input = $question->generate_form_input( |
|
665 | - $registration, |
|
666 | - $answer, |
|
667 | - $input_constructor_args |
|
668 | - ); |
|
669 | - remove_filter( |
|
670 | - 'FHEE__EE_Question__generate_form_input__country_options', |
|
671 | - array($this, 'use_cached_countries_for_form_input') |
|
672 | - ); |
|
673 | - remove_filter( |
|
674 | - 'FHEE__EE_Question__generate_form_input__state_options', |
|
675 | - array($this, 'use_cached_states_for_form_input') |
|
676 | - ); |
|
677 | - return $form_input; |
|
678 | - } |
|
622 | + /** |
|
623 | + * @param EE_Registration $registration |
|
624 | + * @param EE_Question $question |
|
625 | + * @param $answer |
|
626 | + * @return EE_Form_Input_Base |
|
627 | + * @throws EE_Error |
|
628 | + * @throws InvalidArgumentException |
|
629 | + * @throws ReflectionException |
|
630 | + * @throws InvalidDataTypeException |
|
631 | + * @throws InvalidInterfaceException |
|
632 | + */ |
|
633 | + private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) |
|
634 | + { |
|
635 | + $identifier = $question->is_system_question() |
|
636 | + ? $question->system_ID() |
|
637 | + : $question->ID(); |
|
638 | + $this->_required_questions[ $identifier ] = $question->required() ? true : false; |
|
639 | + add_filter( |
|
640 | + 'FHEE__EE_Question__generate_form_input__country_options', |
|
641 | + array($this, 'use_cached_countries_for_form_input'), |
|
642 | + 10, |
|
643 | + 4 |
|
644 | + ); |
|
645 | + add_filter( |
|
646 | + 'FHEE__EE_Question__generate_form_input__state_options', |
|
647 | + array($this, 'use_cached_states_for_form_input'), |
|
648 | + 10, |
|
649 | + 4 |
|
650 | + ); |
|
651 | + $input_constructor_args = array( |
|
652 | + 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
653 | + 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
654 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
655 | + 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
656 | + 'html_label_class' => 'ee-reg-qstn', |
|
657 | + ); |
|
658 | + $input_constructor_args['html_label_id'] .= '-lbl'; |
|
659 | + if ($answer instanceof EE_Answer && $answer->ID()) { |
|
660 | + $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
661 | + $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
662 | + $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
663 | + } |
|
664 | + $form_input = $question->generate_form_input( |
|
665 | + $registration, |
|
666 | + $answer, |
|
667 | + $input_constructor_args |
|
668 | + ); |
|
669 | + remove_filter( |
|
670 | + 'FHEE__EE_Question__generate_form_input__country_options', |
|
671 | + array($this, 'use_cached_countries_for_form_input') |
|
672 | + ); |
|
673 | + remove_filter( |
|
674 | + 'FHEE__EE_Question__generate_form_input__state_options', |
|
675 | + array($this, 'use_cached_states_for_form_input') |
|
676 | + ); |
|
677 | + return $form_input; |
|
678 | + } |
|
679 | 679 | |
680 | 680 | |
681 | - /** |
|
682 | - * Gets the list of countries for the form input |
|
683 | - * |
|
684 | - * @param array|null $countries_list |
|
685 | - * @param EE_Question $question |
|
686 | - * @param EE_Registration $registration |
|
687 | - * @param EE_Answer $answer |
|
688 | - * @return array 2d keys are country IDs, values are their names |
|
689 | - * @throws EE_Error |
|
690 | - * @throws InvalidArgumentException |
|
691 | - * @throws InvalidDataTypeException |
|
692 | - * @throws InvalidInterfaceException |
|
693 | - * @throws ReflectionException |
|
694 | - */ |
|
695 | - public function use_cached_countries_for_form_input( |
|
696 | - $countries_list, |
|
697 | - EE_Question $question = null, |
|
698 | - EE_Registration $registration = null, |
|
699 | - EE_Answer $answer = null |
|
700 | - ) { |
|
701 | - $country_options = array('' => ''); |
|
702 | - // get possibly cached list of countries |
|
703 | - $countries = $this->checkout->action === 'process_reg_step' |
|
704 | - ? EEM_Country::instance()->get_all_countries() |
|
705 | - : EEM_Country::instance()->get_all_active_countries(); |
|
706 | - if (! empty($countries)) { |
|
707 | - foreach ($countries as $country) { |
|
708 | - if ($country instanceof EE_Country) { |
|
709 | - $country_options[ $country->ID() ] = $country->name(); |
|
710 | - } |
|
711 | - } |
|
712 | - } |
|
713 | - if ($question instanceof EE_Question && $registration instanceof EE_Registration) { |
|
714 | - $answer = EEM_Answer::instance()->get_one( |
|
715 | - array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
716 | - ); |
|
717 | - } else { |
|
718 | - $answer = EE_Answer::new_instance(); |
|
719 | - } |
|
720 | - $country_options = apply_filters( |
|
721 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
722 | - $country_options, |
|
723 | - $this, |
|
724 | - $registration, |
|
725 | - $question, |
|
726 | - $answer |
|
727 | - ); |
|
728 | - return $country_options; |
|
729 | - } |
|
681 | + /** |
|
682 | + * Gets the list of countries for the form input |
|
683 | + * |
|
684 | + * @param array|null $countries_list |
|
685 | + * @param EE_Question $question |
|
686 | + * @param EE_Registration $registration |
|
687 | + * @param EE_Answer $answer |
|
688 | + * @return array 2d keys are country IDs, values are their names |
|
689 | + * @throws EE_Error |
|
690 | + * @throws InvalidArgumentException |
|
691 | + * @throws InvalidDataTypeException |
|
692 | + * @throws InvalidInterfaceException |
|
693 | + * @throws ReflectionException |
|
694 | + */ |
|
695 | + public function use_cached_countries_for_form_input( |
|
696 | + $countries_list, |
|
697 | + EE_Question $question = null, |
|
698 | + EE_Registration $registration = null, |
|
699 | + EE_Answer $answer = null |
|
700 | + ) { |
|
701 | + $country_options = array('' => ''); |
|
702 | + // get possibly cached list of countries |
|
703 | + $countries = $this->checkout->action === 'process_reg_step' |
|
704 | + ? EEM_Country::instance()->get_all_countries() |
|
705 | + : EEM_Country::instance()->get_all_active_countries(); |
|
706 | + if (! empty($countries)) { |
|
707 | + foreach ($countries as $country) { |
|
708 | + if ($country instanceof EE_Country) { |
|
709 | + $country_options[ $country->ID() ] = $country->name(); |
|
710 | + } |
|
711 | + } |
|
712 | + } |
|
713 | + if ($question instanceof EE_Question && $registration instanceof EE_Registration) { |
|
714 | + $answer = EEM_Answer::instance()->get_one( |
|
715 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
716 | + ); |
|
717 | + } else { |
|
718 | + $answer = EE_Answer::new_instance(); |
|
719 | + } |
|
720 | + $country_options = apply_filters( |
|
721 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
722 | + $country_options, |
|
723 | + $this, |
|
724 | + $registration, |
|
725 | + $question, |
|
726 | + $answer |
|
727 | + ); |
|
728 | + return $country_options; |
|
729 | + } |
|
730 | 730 | |
731 | 731 | |
732 | - /** |
|
733 | - * Gets the list of states for the form input |
|
734 | - * |
|
735 | - * @param array|null $states_list |
|
736 | - * @param EE_Question $question |
|
737 | - * @param EE_Registration $registration |
|
738 | - * @param EE_Answer $answer |
|
739 | - * @return array 2d keys are state IDs, values are their names |
|
740 | - * @throws EE_Error |
|
741 | - * @throws InvalidArgumentException |
|
742 | - * @throws InvalidDataTypeException |
|
743 | - * @throws InvalidInterfaceException |
|
744 | - * @throws ReflectionException |
|
745 | - */ |
|
746 | - public function use_cached_states_for_form_input( |
|
747 | - $states_list, |
|
748 | - EE_Question $question = null, |
|
749 | - EE_Registration $registration = null, |
|
750 | - EE_Answer $answer = null |
|
751 | - ) { |
|
752 | - $state_options = array('' => array('' => '')); |
|
753 | - $states = $this->checkout->action === 'process_reg_step' |
|
754 | - ? EEM_State::instance()->get_all_states() |
|
755 | - : EEM_State::instance()->get_all_active_states(); |
|
756 | - if (! empty($states)) { |
|
757 | - foreach ($states as $state) { |
|
758 | - if ($state instanceof EE_State) { |
|
759 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
760 | - } |
|
761 | - } |
|
762 | - } |
|
763 | - $state_options = apply_filters( |
|
764 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
765 | - $state_options, |
|
766 | - $this, |
|
767 | - $registration, |
|
768 | - $question, |
|
769 | - $answer |
|
770 | - ); |
|
771 | - return $state_options; |
|
772 | - } |
|
732 | + /** |
|
733 | + * Gets the list of states for the form input |
|
734 | + * |
|
735 | + * @param array|null $states_list |
|
736 | + * @param EE_Question $question |
|
737 | + * @param EE_Registration $registration |
|
738 | + * @param EE_Answer $answer |
|
739 | + * @return array 2d keys are state IDs, values are their names |
|
740 | + * @throws EE_Error |
|
741 | + * @throws InvalidArgumentException |
|
742 | + * @throws InvalidDataTypeException |
|
743 | + * @throws InvalidInterfaceException |
|
744 | + * @throws ReflectionException |
|
745 | + */ |
|
746 | + public function use_cached_states_for_form_input( |
|
747 | + $states_list, |
|
748 | + EE_Question $question = null, |
|
749 | + EE_Registration $registration = null, |
|
750 | + EE_Answer $answer = null |
|
751 | + ) { |
|
752 | + $state_options = array('' => array('' => '')); |
|
753 | + $states = $this->checkout->action === 'process_reg_step' |
|
754 | + ? EEM_State::instance()->get_all_states() |
|
755 | + : EEM_State::instance()->get_all_active_states(); |
|
756 | + if (! empty($states)) { |
|
757 | + foreach ($states as $state) { |
|
758 | + if ($state instanceof EE_State) { |
|
759 | + $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
760 | + } |
|
761 | + } |
|
762 | + } |
|
763 | + $state_options = apply_filters( |
|
764 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
765 | + $state_options, |
|
766 | + $this, |
|
767 | + $registration, |
|
768 | + $question, |
|
769 | + $answer |
|
770 | + ); |
|
771 | + return $state_options; |
|
772 | + } |
|
773 | 773 | |
774 | 774 | |
775 | - /********************************************************************************************************/ |
|
776 | - /**************************************** PROCESS REG STEP ****************************************/ |
|
777 | - /********************************************************************************************************/ |
|
775 | + /********************************************************************************************************/ |
|
776 | + /**************************************** PROCESS REG STEP ****************************************/ |
|
777 | + /********************************************************************************************************/ |
|
778 | 778 | |
779 | 779 | |
780 | - /** |
|
781 | - * @return bool |
|
782 | - * @throws EE_Error |
|
783 | - * @throws InvalidArgumentException |
|
784 | - * @throws ReflectionException |
|
785 | - * @throws RuntimeException |
|
786 | - * @throws InvalidDataTypeException |
|
787 | - * @throws InvalidInterfaceException |
|
788 | - */ |
|
789 | - public function process_reg_step() |
|
790 | - { |
|
791 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
792 | - // grab validated data from form |
|
793 | - $valid_data = $this->checkout->current_step->valid_data(); |
|
794 | - // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
795 | - // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ ); |
|
796 | - // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
797 | - if (empty($valid_data)) { |
|
798 | - EE_Error::add_error( |
|
799 | - esc_html__('No valid question responses were received.', 'event_espresso'), |
|
800 | - __FILE__, |
|
801 | - __FUNCTION__, |
|
802 | - __LINE__ |
|
803 | - ); |
|
804 | - return false; |
|
805 | - } |
|
806 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
807 | - EE_Error::add_error( |
|
808 | - esc_html__( |
|
809 | - 'A valid transaction could not be initiated for processing your registrations.', |
|
810 | - 'event_espresso' |
|
811 | - ), |
|
812 | - __FILE__, |
|
813 | - __FUNCTION__, |
|
814 | - __LINE__ |
|
815 | - ); |
|
816 | - return false; |
|
817 | - } |
|
818 | - // get cached registrations |
|
819 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
820 | - // verify we got the goods |
|
821 | - if (empty($registrations)) { |
|
822 | - // combine the old translated string with a new one, in order to not break translations |
|
823 | - $error_message = esc_html__( |
|
824 | - 'Your form data could not be applied to any valid registrations.', |
|
825 | - 'event_espresso' |
|
826 | - ) |
|
827 | - . sprintf( |
|
828 | - esc_html_x( |
|
829 | - '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
830 | - '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
831 | - 'event_espresso' |
|
832 | - ), |
|
833 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
834 | - '</a>', |
|
835 | - '<br />' |
|
836 | - ); |
|
837 | - EE_Error::add_error( |
|
838 | - $error_message, |
|
839 | - __FILE__, |
|
840 | - __FUNCTION__, |
|
841 | - __LINE__ |
|
842 | - ); |
|
843 | - return false; |
|
844 | - } |
|
845 | - // extract attendee info from form data and save to model objects |
|
846 | - $registrations_processed = $this->_process_registrations($registrations, $valid_data); |
|
847 | - // if first pass thru SPCO, |
|
848 | - // then let's check processed registrations against the total number of tickets in the cart |
|
849 | - if ($registrations_processed === false) { |
|
850 | - // but return immediately if the previous step exited early due to errors |
|
851 | - return false; |
|
852 | - } |
|
853 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
854 | - // generate a correctly translated string for all possible singular/plural combinations |
|
855 | - if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
856 | - $error_msg = sprintf( |
|
857 | - esc_html_x( |
|
858 | - 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
859 | - 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
860 | - 'event_espresso' |
|
861 | - ), |
|
862 | - $this->checkout->total_ticket_count, |
|
863 | - $registrations_processed |
|
864 | - ); |
|
865 | - } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
866 | - $error_msg = sprintf( |
|
867 | - esc_html_x( |
|
868 | - 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
869 | - 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
870 | - 'event_espresso' |
|
871 | - ), |
|
872 | - $this->checkout->total_ticket_count, |
|
873 | - $registrations_processed |
|
874 | - ); |
|
875 | - } else { |
|
876 | - $error_msg = sprintf( |
|
877 | - esc_html__( |
|
878 | - 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
879 | - 'event_espresso' |
|
880 | - ), |
|
881 | - $this->checkout->total_ticket_count, |
|
882 | - $registrations_processed |
|
883 | - ); |
|
884 | - } |
|
885 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
886 | - return false; |
|
887 | - } |
|
888 | - // mark this reg step as completed |
|
889 | - $this->set_completed(); |
|
890 | - $this->_set_success_message( |
|
891 | - esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
892 | - ); |
|
893 | - // do action in case a plugin wants to do something with the data submitted in step 1. |
|
894 | - // passes EE_Single_Page_Checkout, and it's posted data |
|
895 | - do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
896 | - return true; |
|
897 | - } |
|
780 | + /** |
|
781 | + * @return bool |
|
782 | + * @throws EE_Error |
|
783 | + * @throws InvalidArgumentException |
|
784 | + * @throws ReflectionException |
|
785 | + * @throws RuntimeException |
|
786 | + * @throws InvalidDataTypeException |
|
787 | + * @throws InvalidInterfaceException |
|
788 | + */ |
|
789 | + public function process_reg_step() |
|
790 | + { |
|
791 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
792 | + // grab validated data from form |
|
793 | + $valid_data = $this->checkout->current_step->valid_data(); |
|
794 | + // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
795 | + // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ ); |
|
796 | + // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
797 | + if (empty($valid_data)) { |
|
798 | + EE_Error::add_error( |
|
799 | + esc_html__('No valid question responses were received.', 'event_espresso'), |
|
800 | + __FILE__, |
|
801 | + __FUNCTION__, |
|
802 | + __LINE__ |
|
803 | + ); |
|
804 | + return false; |
|
805 | + } |
|
806 | + if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
807 | + EE_Error::add_error( |
|
808 | + esc_html__( |
|
809 | + 'A valid transaction could not be initiated for processing your registrations.', |
|
810 | + 'event_espresso' |
|
811 | + ), |
|
812 | + __FILE__, |
|
813 | + __FUNCTION__, |
|
814 | + __LINE__ |
|
815 | + ); |
|
816 | + return false; |
|
817 | + } |
|
818 | + // get cached registrations |
|
819 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
820 | + // verify we got the goods |
|
821 | + if (empty($registrations)) { |
|
822 | + // combine the old translated string with a new one, in order to not break translations |
|
823 | + $error_message = esc_html__( |
|
824 | + 'Your form data could not be applied to any valid registrations.', |
|
825 | + 'event_espresso' |
|
826 | + ) |
|
827 | + . sprintf( |
|
828 | + esc_html_x( |
|
829 | + '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
830 | + '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
831 | + 'event_espresso' |
|
832 | + ), |
|
833 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
834 | + '</a>', |
|
835 | + '<br />' |
|
836 | + ); |
|
837 | + EE_Error::add_error( |
|
838 | + $error_message, |
|
839 | + __FILE__, |
|
840 | + __FUNCTION__, |
|
841 | + __LINE__ |
|
842 | + ); |
|
843 | + return false; |
|
844 | + } |
|
845 | + // extract attendee info from form data and save to model objects |
|
846 | + $registrations_processed = $this->_process_registrations($registrations, $valid_data); |
|
847 | + // if first pass thru SPCO, |
|
848 | + // then let's check processed registrations against the total number of tickets in the cart |
|
849 | + if ($registrations_processed === false) { |
|
850 | + // but return immediately if the previous step exited early due to errors |
|
851 | + return false; |
|
852 | + } |
|
853 | + if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
854 | + // generate a correctly translated string for all possible singular/plural combinations |
|
855 | + if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
856 | + $error_msg = sprintf( |
|
857 | + esc_html_x( |
|
858 | + 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
859 | + 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
860 | + 'event_espresso' |
|
861 | + ), |
|
862 | + $this->checkout->total_ticket_count, |
|
863 | + $registrations_processed |
|
864 | + ); |
|
865 | + } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
866 | + $error_msg = sprintf( |
|
867 | + esc_html_x( |
|
868 | + 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
869 | + 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
870 | + 'event_espresso' |
|
871 | + ), |
|
872 | + $this->checkout->total_ticket_count, |
|
873 | + $registrations_processed |
|
874 | + ); |
|
875 | + } else { |
|
876 | + $error_msg = sprintf( |
|
877 | + esc_html__( |
|
878 | + 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
879 | + 'event_espresso' |
|
880 | + ), |
|
881 | + $this->checkout->total_ticket_count, |
|
882 | + $registrations_processed |
|
883 | + ); |
|
884 | + } |
|
885 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
886 | + return false; |
|
887 | + } |
|
888 | + // mark this reg step as completed |
|
889 | + $this->set_completed(); |
|
890 | + $this->_set_success_message( |
|
891 | + esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
892 | + ); |
|
893 | + // do action in case a plugin wants to do something with the data submitted in step 1. |
|
894 | + // passes EE_Single_Page_Checkout, and it's posted data |
|
895 | + do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
896 | + return true; |
|
897 | + } |
|
898 | 898 | |
899 | 899 | |
900 | - /** |
|
901 | - * _process_registrations |
|
902 | - * |
|
903 | - * @param EE_Registration[] $registrations |
|
904 | - * @param array[][] $valid_data |
|
905 | - * @return bool|int |
|
906 | - * @throws EntityNotFoundException |
|
907 | - * @throws EE_Error |
|
908 | - * @throws InvalidArgumentException |
|
909 | - * @throws ReflectionException |
|
910 | - * @throws RuntimeException |
|
911 | - * @throws InvalidDataTypeException |
|
912 | - * @throws InvalidInterfaceException |
|
913 | - */ |
|
914 | - private function _process_registrations($registrations = array(), $valid_data = array()) |
|
915 | - { |
|
916 | - // load resources and set some defaults |
|
917 | - EE_Registry::instance()->load_model('Attendee'); |
|
918 | - // holder for primary registrant attendee object |
|
919 | - $this->checkout->primary_attendee_obj = null; |
|
920 | - // array for tracking reg form data for the primary registrant |
|
921 | - $primary_registrant = array( |
|
922 | - 'line_item_id' => null, |
|
923 | - ); |
|
924 | - $copy_primary = false; |
|
925 | - // reg form sections that do not contain inputs |
|
926 | - $non_input_form_sections = array( |
|
927 | - 'primary_registrant', |
|
928 | - 'additional_attendee_reg_info', |
|
929 | - 'spco_copy_attendee_chk', |
|
930 | - ); |
|
931 | - // attendee counter |
|
932 | - $att_nmbr = 0; |
|
933 | - // grab the saved registrations from the transaction |
|
934 | - foreach ($registrations as $registration) { |
|
935 | - // verify EE_Registration object |
|
936 | - if (! $registration instanceof EE_Registration) { |
|
937 | - EE_Error::add_error( |
|
938 | - esc_html__( |
|
939 | - 'An invalid Registration object was discovered when attempting to process your registration information.', |
|
940 | - 'event_espresso' |
|
941 | - ), |
|
942 | - __FILE__, |
|
943 | - __FUNCTION__, |
|
944 | - __LINE__ |
|
945 | - ); |
|
946 | - return false; |
|
947 | - } |
|
948 | - /** @var string $reg_url_link */ |
|
949 | - $reg_url_link = $registration->reg_url_link(); |
|
950 | - // reg_url_link exists ? |
|
951 | - if (! empty($reg_url_link)) { |
|
952 | - // should this registration be processed during this visit ? |
|
953 | - if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
954 | - // if NOT revisiting, then let's save the registration now, |
|
955 | - // so that we have a REG_ID to use when generating other objects |
|
956 | - if (! $this->checkout->revisit) { |
|
957 | - $registration->save(); |
|
958 | - } |
|
959 | - /** |
|
960 | - * This allows plugins to trigger a fail on processing of a |
|
961 | - * registration for any conditions they may have for it to pass. |
|
962 | - * |
|
963 | - * @var bool if true is returned by the plugin then the |
|
964 | - * registration processing is halted. |
|
965 | - */ |
|
966 | - if (apply_filters( |
|
967 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
|
968 | - false, |
|
969 | - $att_nmbr, |
|
970 | - $registration, |
|
971 | - $registrations, |
|
972 | - $valid_data, |
|
973 | - $this |
|
974 | - )) { |
|
975 | - return false; |
|
976 | - } |
|
900 | + /** |
|
901 | + * _process_registrations |
|
902 | + * |
|
903 | + * @param EE_Registration[] $registrations |
|
904 | + * @param array[][] $valid_data |
|
905 | + * @return bool|int |
|
906 | + * @throws EntityNotFoundException |
|
907 | + * @throws EE_Error |
|
908 | + * @throws InvalidArgumentException |
|
909 | + * @throws ReflectionException |
|
910 | + * @throws RuntimeException |
|
911 | + * @throws InvalidDataTypeException |
|
912 | + * @throws InvalidInterfaceException |
|
913 | + */ |
|
914 | + private function _process_registrations($registrations = array(), $valid_data = array()) |
|
915 | + { |
|
916 | + // load resources and set some defaults |
|
917 | + EE_Registry::instance()->load_model('Attendee'); |
|
918 | + // holder for primary registrant attendee object |
|
919 | + $this->checkout->primary_attendee_obj = null; |
|
920 | + // array for tracking reg form data for the primary registrant |
|
921 | + $primary_registrant = array( |
|
922 | + 'line_item_id' => null, |
|
923 | + ); |
|
924 | + $copy_primary = false; |
|
925 | + // reg form sections that do not contain inputs |
|
926 | + $non_input_form_sections = array( |
|
927 | + 'primary_registrant', |
|
928 | + 'additional_attendee_reg_info', |
|
929 | + 'spco_copy_attendee_chk', |
|
930 | + ); |
|
931 | + // attendee counter |
|
932 | + $att_nmbr = 0; |
|
933 | + // grab the saved registrations from the transaction |
|
934 | + foreach ($registrations as $registration) { |
|
935 | + // verify EE_Registration object |
|
936 | + if (! $registration instanceof EE_Registration) { |
|
937 | + EE_Error::add_error( |
|
938 | + esc_html__( |
|
939 | + 'An invalid Registration object was discovered when attempting to process your registration information.', |
|
940 | + 'event_espresso' |
|
941 | + ), |
|
942 | + __FILE__, |
|
943 | + __FUNCTION__, |
|
944 | + __LINE__ |
|
945 | + ); |
|
946 | + return false; |
|
947 | + } |
|
948 | + /** @var string $reg_url_link */ |
|
949 | + $reg_url_link = $registration->reg_url_link(); |
|
950 | + // reg_url_link exists ? |
|
951 | + if (! empty($reg_url_link)) { |
|
952 | + // should this registration be processed during this visit ? |
|
953 | + if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
954 | + // if NOT revisiting, then let's save the registration now, |
|
955 | + // so that we have a REG_ID to use when generating other objects |
|
956 | + if (! $this->checkout->revisit) { |
|
957 | + $registration->save(); |
|
958 | + } |
|
959 | + /** |
|
960 | + * This allows plugins to trigger a fail on processing of a |
|
961 | + * registration for any conditions they may have for it to pass. |
|
962 | + * |
|
963 | + * @var bool if true is returned by the plugin then the |
|
964 | + * registration processing is halted. |
|
965 | + */ |
|
966 | + if (apply_filters( |
|
967 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
|
968 | + false, |
|
969 | + $att_nmbr, |
|
970 | + $registration, |
|
971 | + $registrations, |
|
972 | + $valid_data, |
|
973 | + $this |
|
974 | + )) { |
|
975 | + return false; |
|
976 | + } |
|
977 | 977 | |
978 | - // Houston, we have a registration! |
|
979 | - $att_nmbr++; |
|
980 | - $this->_attendee_data[ $reg_url_link ] = array(); |
|
981 | - // grab any existing related answer objects |
|
982 | - $this->_registration_answers = $registration->answers(); |
|
983 | - // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
|
984 | - if (isset($valid_data[ $reg_url_link ])) { |
|
985 | - // do we need to copy basic info from primary attendee ? |
|
986 | - $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) |
|
987 | - && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0; |
|
988 | - // filter form input data for this registration |
|
989 | - $valid_data[ $reg_url_link ] = (array) apply_filters( |
|
990 | - 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
991 | - $valid_data[ $reg_url_link ] |
|
992 | - ); |
|
993 | - if (isset($valid_data['primary_attendee'])) { |
|
994 | - $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
|
995 | - ? $valid_data['primary_attendee'] |
|
996 | - : false; |
|
997 | - unset($valid_data['primary_attendee']); |
|
998 | - } |
|
999 | - // now loop through our array of valid post data && process attendee reg forms |
|
1000 | - foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) { |
|
1001 | - if (! in_array($form_section, $non_input_form_sections, true)) { |
|
1002 | - foreach ($form_inputs as $form_input => $input_value) { |
|
1003 | - // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
|
1004 | - // check for critical inputs |
|
1005 | - if (! $this->_verify_critical_attendee_details_are_set_and_validate_email( |
|
1006 | - $form_input, |
|
1007 | - $input_value |
|
1008 | - ) |
|
1009 | - ) { |
|
1010 | - return false; |
|
1011 | - } |
|
1012 | - // store a bit of data about the primary attendee |
|
1013 | - if ($att_nmbr === 1 |
|
1014 | - && ! empty($input_value) |
|
1015 | - && $reg_url_link === $primary_registrant['line_item_id'] |
|
1016 | - ) { |
|
1017 | - $primary_registrant[ $form_input ] = $input_value; |
|
1018 | - } elseif ($copy_primary |
|
1019 | - && $input_value === null |
|
1020 | - && isset($primary_registrant[ $form_input ]) |
|
1021 | - ) { |
|
1022 | - $input_value = $primary_registrant[ $form_input ]; |
|
1023 | - } |
|
1024 | - // now attempt to save the input data |
|
1025 | - if (! $this->_save_registration_form_input( |
|
1026 | - $registration, |
|
1027 | - $form_input, |
|
1028 | - $input_value |
|
1029 | - ) |
|
1030 | - ) { |
|
1031 | - EE_Error::add_error( |
|
1032 | - sprintf( |
|
1033 | - esc_html_x( |
|
1034 | - 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', |
|
1035 | - 'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"', |
|
1036 | - 'event_espresso' |
|
1037 | - ), |
|
1038 | - $form_input, |
|
1039 | - $input_value |
|
1040 | - ), |
|
1041 | - __FILE__, |
|
1042 | - __FUNCTION__, |
|
1043 | - __LINE__ |
|
1044 | - ); |
|
1045 | - return false; |
|
1046 | - } |
|
1047 | - } |
|
1048 | - } |
|
1049 | - } // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) |
|
1050 | - } |
|
1051 | - // EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ ); |
|
1052 | - // this registration does not require additional attendee information ? |
|
1053 | - if ($copy_primary |
|
1054 | - && $att_nmbr > 1 |
|
1055 | - && $this->checkout->primary_attendee_obj instanceof EE_Attendee |
|
1056 | - ) { |
|
1057 | - // just copy the primary registrant |
|
1058 | - $attendee = $this->checkout->primary_attendee_obj; |
|
1059 | - } else { |
|
1060 | - // ensure critical details are set for additional attendees |
|
1061 | - $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
1062 | - ? $this->_copy_critical_attendee_details_from_primary_registrant( |
|
1063 | - $this->_attendee_data[ $reg_url_link ] |
|
1064 | - ) |
|
1065 | - : $this->_attendee_data[ $reg_url_link ]; |
|
1066 | - // execute create attendee command (which may return an existing attendee) |
|
1067 | - $attendee = EE_Registry::instance()->BUS->execute( |
|
1068 | - new CreateAttendeeCommand( |
|
1069 | - $this->_attendee_data[ $reg_url_link ], |
|
1070 | - $registration |
|
1071 | - ) |
|
1072 | - ); |
|
1073 | - // who's #1 ? |
|
1074 | - if ($att_nmbr === 1) { |
|
1075 | - $this->checkout->primary_attendee_obj = $attendee; |
|
1076 | - } |
|
1077 | - } |
|
1078 | - // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ ); |
|
1079 | - // add relation to registration, set attendee ID, and cache attendee |
|
1080 | - $this->_associate_attendee_with_registration($registration, $attendee); |
|
1081 | - // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
|
1082 | - if (! $registration->attendee() instanceof EE_Attendee) { |
|
1083 | - EE_Error::add_error( |
|
1084 | - sprintf( |
|
1085 | - esc_html_x( |
|
1086 | - 'Registration %s has an invalid or missing Attendee object.', |
|
1087 | - 'Registration 123-456-789 has an invalid or missing Attendee object.', |
|
1088 | - 'event_espresso' |
|
1089 | - ), |
|
1090 | - $reg_url_link |
|
1091 | - ), |
|
1092 | - __FILE__, |
|
1093 | - __FUNCTION__, |
|
1094 | - __LINE__ |
|
1095 | - ); |
|
1096 | - return false; |
|
1097 | - } |
|
1098 | - /** @type EE_Registration_Processor $registration_processor */ |
|
1099 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1100 | - // at this point, we should have enough details about the registrant to consider the registration |
|
1101 | - // NOT incomplete |
|
1102 | - $registration_processor->toggle_incomplete_registration_status_to_default( |
|
1103 | - $registration, |
|
1104 | - false, |
|
1105 | - new Context( |
|
1106 | - 'spco_reg_step_attendee_information_process_registrations', |
|
1107 | - esc_html__( |
|
1108 | - 'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.', |
|
1109 | - 'event_espresso' |
|
1110 | - ) |
|
1111 | - ) |
|
1112 | - ); |
|
1113 | - // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to |
|
1114 | - // abandoned |
|
1115 | - $this->checkout->transaction->toggle_failed_transaction_status(); |
|
1116 | - // if we've gotten this far, then let's save what we have |
|
1117 | - $registration->save(); |
|
1118 | - // add relation between TXN and registration |
|
1119 | - $this->_associate_registration_with_transaction($registration); |
|
1120 | - } |
|
1121 | - } else { |
|
1122 | - EE_Error::add_error( |
|
1123 | - esc_html__( |
|
1124 | - 'An invalid or missing line item ID was encountered while attempting to process the registration form.', |
|
1125 | - 'event_espresso' |
|
1126 | - ), |
|
1127 | - __FILE__, |
|
1128 | - __FUNCTION__, |
|
1129 | - __LINE__ |
|
1130 | - ); |
|
1131 | - // remove malformed data |
|
1132 | - unset($valid_data[ $reg_url_link ]); |
|
1133 | - return false; |
|
1134 | - } |
|
1135 | - } // end of foreach ( $this->checkout->transaction->registrations() as $registration ) |
|
1136 | - return $att_nmbr; |
|
1137 | - } |
|
978 | + // Houston, we have a registration! |
|
979 | + $att_nmbr++; |
|
980 | + $this->_attendee_data[ $reg_url_link ] = array(); |
|
981 | + // grab any existing related answer objects |
|
982 | + $this->_registration_answers = $registration->answers(); |
|
983 | + // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
|
984 | + if (isset($valid_data[ $reg_url_link ])) { |
|
985 | + // do we need to copy basic info from primary attendee ? |
|
986 | + $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) |
|
987 | + && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0; |
|
988 | + // filter form input data for this registration |
|
989 | + $valid_data[ $reg_url_link ] = (array) apply_filters( |
|
990 | + 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
991 | + $valid_data[ $reg_url_link ] |
|
992 | + ); |
|
993 | + if (isset($valid_data['primary_attendee'])) { |
|
994 | + $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
|
995 | + ? $valid_data['primary_attendee'] |
|
996 | + : false; |
|
997 | + unset($valid_data['primary_attendee']); |
|
998 | + } |
|
999 | + // now loop through our array of valid post data && process attendee reg forms |
|
1000 | + foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) { |
|
1001 | + if (! in_array($form_section, $non_input_form_sections, true)) { |
|
1002 | + foreach ($form_inputs as $form_input => $input_value) { |
|
1003 | + // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
|
1004 | + // check for critical inputs |
|
1005 | + if (! $this->_verify_critical_attendee_details_are_set_and_validate_email( |
|
1006 | + $form_input, |
|
1007 | + $input_value |
|
1008 | + ) |
|
1009 | + ) { |
|
1010 | + return false; |
|
1011 | + } |
|
1012 | + // store a bit of data about the primary attendee |
|
1013 | + if ($att_nmbr === 1 |
|
1014 | + && ! empty($input_value) |
|
1015 | + && $reg_url_link === $primary_registrant['line_item_id'] |
|
1016 | + ) { |
|
1017 | + $primary_registrant[ $form_input ] = $input_value; |
|
1018 | + } elseif ($copy_primary |
|
1019 | + && $input_value === null |
|
1020 | + && isset($primary_registrant[ $form_input ]) |
|
1021 | + ) { |
|
1022 | + $input_value = $primary_registrant[ $form_input ]; |
|
1023 | + } |
|
1024 | + // now attempt to save the input data |
|
1025 | + if (! $this->_save_registration_form_input( |
|
1026 | + $registration, |
|
1027 | + $form_input, |
|
1028 | + $input_value |
|
1029 | + ) |
|
1030 | + ) { |
|
1031 | + EE_Error::add_error( |
|
1032 | + sprintf( |
|
1033 | + esc_html_x( |
|
1034 | + 'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"', |
|
1035 | + 'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"', |
|
1036 | + 'event_espresso' |
|
1037 | + ), |
|
1038 | + $form_input, |
|
1039 | + $input_value |
|
1040 | + ), |
|
1041 | + __FILE__, |
|
1042 | + __FUNCTION__, |
|
1043 | + __LINE__ |
|
1044 | + ); |
|
1045 | + return false; |
|
1046 | + } |
|
1047 | + } |
|
1048 | + } |
|
1049 | + } // end of foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) |
|
1050 | + } |
|
1051 | + // EEH_Debug_Tools::printr( $this->_attendee_data, '$this->_attendee_data', __FILE__, __LINE__ ); |
|
1052 | + // this registration does not require additional attendee information ? |
|
1053 | + if ($copy_primary |
|
1054 | + && $att_nmbr > 1 |
|
1055 | + && $this->checkout->primary_attendee_obj instanceof EE_Attendee |
|
1056 | + ) { |
|
1057 | + // just copy the primary registrant |
|
1058 | + $attendee = $this->checkout->primary_attendee_obj; |
|
1059 | + } else { |
|
1060 | + // ensure critical details are set for additional attendees |
|
1061 | + $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
1062 | + ? $this->_copy_critical_attendee_details_from_primary_registrant( |
|
1063 | + $this->_attendee_data[ $reg_url_link ] |
|
1064 | + ) |
|
1065 | + : $this->_attendee_data[ $reg_url_link ]; |
|
1066 | + // execute create attendee command (which may return an existing attendee) |
|
1067 | + $attendee = EE_Registry::instance()->BUS->execute( |
|
1068 | + new CreateAttendeeCommand( |
|
1069 | + $this->_attendee_data[ $reg_url_link ], |
|
1070 | + $registration |
|
1071 | + ) |
|
1072 | + ); |
|
1073 | + // who's #1 ? |
|
1074 | + if ($att_nmbr === 1) { |
|
1075 | + $this->checkout->primary_attendee_obj = $attendee; |
|
1076 | + } |
|
1077 | + } |
|
1078 | + // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ ); |
|
1079 | + // add relation to registration, set attendee ID, and cache attendee |
|
1080 | + $this->_associate_attendee_with_registration($registration, $attendee); |
|
1081 | + // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
|
1082 | + if (! $registration->attendee() instanceof EE_Attendee) { |
|
1083 | + EE_Error::add_error( |
|
1084 | + sprintf( |
|
1085 | + esc_html_x( |
|
1086 | + 'Registration %s has an invalid or missing Attendee object.', |
|
1087 | + 'Registration 123-456-789 has an invalid or missing Attendee object.', |
|
1088 | + 'event_espresso' |
|
1089 | + ), |
|
1090 | + $reg_url_link |
|
1091 | + ), |
|
1092 | + __FILE__, |
|
1093 | + __FUNCTION__, |
|
1094 | + __LINE__ |
|
1095 | + ); |
|
1096 | + return false; |
|
1097 | + } |
|
1098 | + /** @type EE_Registration_Processor $registration_processor */ |
|
1099 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1100 | + // at this point, we should have enough details about the registrant to consider the registration |
|
1101 | + // NOT incomplete |
|
1102 | + $registration_processor->toggle_incomplete_registration_status_to_default( |
|
1103 | + $registration, |
|
1104 | + false, |
|
1105 | + new Context( |
|
1106 | + 'spco_reg_step_attendee_information_process_registrations', |
|
1107 | + esc_html__( |
|
1108 | + 'Finished populating registration with details from the registration form after submitting the Attendee Information Reg Step.', |
|
1109 | + 'event_espresso' |
|
1110 | + ) |
|
1111 | + ) |
|
1112 | + ); |
|
1113 | + // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to |
|
1114 | + // abandoned |
|
1115 | + $this->checkout->transaction->toggle_failed_transaction_status(); |
|
1116 | + // if we've gotten this far, then let's save what we have |
|
1117 | + $registration->save(); |
|
1118 | + // add relation between TXN and registration |
|
1119 | + $this->_associate_registration_with_transaction($registration); |
|
1120 | + } |
|
1121 | + } else { |
|
1122 | + EE_Error::add_error( |
|
1123 | + esc_html__( |
|
1124 | + 'An invalid or missing line item ID was encountered while attempting to process the registration form.', |
|
1125 | + 'event_espresso' |
|
1126 | + ), |
|
1127 | + __FILE__, |
|
1128 | + __FUNCTION__, |
|
1129 | + __LINE__ |
|
1130 | + ); |
|
1131 | + // remove malformed data |
|
1132 | + unset($valid_data[ $reg_url_link ]); |
|
1133 | + return false; |
|
1134 | + } |
|
1135 | + } // end of foreach ( $this->checkout->transaction->registrations() as $registration ) |
|
1136 | + return $att_nmbr; |
|
1137 | + } |
|
1138 | 1138 | |
1139 | 1139 | |
1140 | - /** |
|
1141 | - * _save_registration_form_input |
|
1142 | - * |
|
1143 | - * @param EE_Registration $registration |
|
1144 | - * @param string $form_input |
|
1145 | - * @param string $input_value |
|
1146 | - * @return bool |
|
1147 | - * @throws EE_Error |
|
1148 | - * @throws InvalidArgumentException |
|
1149 | - * @throws InvalidDataTypeException |
|
1150 | - * @throws InvalidInterfaceException |
|
1151 | - * @throws ReflectionException |
|
1152 | - */ |
|
1153 | - private function _save_registration_form_input( |
|
1154 | - EE_Registration $registration, |
|
1155 | - $form_input = '', |
|
1156 | - $input_value = '' |
|
1157 | - ) { |
|
1158 | - // \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
|
1159 | - // \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ ); |
|
1160 | - // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ ); |
|
1161 | - // allow for plugins to hook in and do their own processing of the form input. |
|
1162 | - // For plugins to bypass normal processing here, they just need to return a boolean value. |
|
1163 | - if (apply_filters( |
|
1164 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
|
1165 | - false, |
|
1166 | - $registration, |
|
1167 | - $form_input, |
|
1168 | - $input_value, |
|
1169 | - $this |
|
1170 | - )) { |
|
1171 | - return true; |
|
1172 | - } |
|
1173 | - /* |
|
1140 | + /** |
|
1141 | + * _save_registration_form_input |
|
1142 | + * |
|
1143 | + * @param EE_Registration $registration |
|
1144 | + * @param string $form_input |
|
1145 | + * @param string $input_value |
|
1146 | + * @return bool |
|
1147 | + * @throws EE_Error |
|
1148 | + * @throws InvalidArgumentException |
|
1149 | + * @throws InvalidDataTypeException |
|
1150 | + * @throws InvalidInterfaceException |
|
1151 | + * @throws ReflectionException |
|
1152 | + */ |
|
1153 | + private function _save_registration_form_input( |
|
1154 | + EE_Registration $registration, |
|
1155 | + $form_input = '', |
|
1156 | + $input_value = '' |
|
1157 | + ) { |
|
1158 | + // \EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
|
1159 | + // \EEH_Debug_Tools::printr( $form_input, '$form_input', __FILE__, __LINE__ ); |
|
1160 | + // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ ); |
|
1161 | + // allow for plugins to hook in and do their own processing of the form input. |
|
1162 | + // For plugins to bypass normal processing here, they just need to return a boolean value. |
|
1163 | + if (apply_filters( |
|
1164 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
|
1165 | + false, |
|
1166 | + $registration, |
|
1167 | + $form_input, |
|
1168 | + $input_value, |
|
1169 | + $this |
|
1170 | + )) { |
|
1171 | + return true; |
|
1172 | + } |
|
1173 | + /* |
|
1174 | 1174 | * $answer_cache_id is the key used to find the EE_Answer we want |
1175 | 1175 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
1176 | 1176 | */ |
1177 | - $answer_cache_id = $this->checkout->reg_url_link |
|
1178 | - ? $form_input . '-' . $registration->reg_url_link() |
|
1179 | - : $form_input; |
|
1180 | - $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ]) |
|
1181 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer; |
|
1182 | - // rename form_inputs if they are EE_Attendee properties |
|
1183 | - switch ((string) $form_input) { |
|
1184 | - case 'state': |
|
1185 | - case 'STA_ID': |
|
1186 | - $attendee_property = true; |
|
1187 | - $form_input = 'STA_ID'; |
|
1188 | - break; |
|
1177 | + $answer_cache_id = $this->checkout->reg_url_link |
|
1178 | + ? $form_input . '-' . $registration->reg_url_link() |
|
1179 | + : $form_input; |
|
1180 | + $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ]) |
|
1181 | + && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer; |
|
1182 | + // rename form_inputs if they are EE_Attendee properties |
|
1183 | + switch ((string) $form_input) { |
|
1184 | + case 'state': |
|
1185 | + case 'STA_ID': |
|
1186 | + $attendee_property = true; |
|
1187 | + $form_input = 'STA_ID'; |
|
1188 | + break; |
|
1189 | 1189 | |
1190 | - case 'country': |
|
1191 | - case 'CNT_ISO': |
|
1192 | - $attendee_property = true; |
|
1193 | - $form_input = 'CNT_ISO'; |
|
1194 | - break; |
|
1190 | + case 'country': |
|
1191 | + case 'CNT_ISO': |
|
1192 | + $attendee_property = true; |
|
1193 | + $form_input = 'CNT_ISO'; |
|
1194 | + break; |
|
1195 | 1195 | |
1196 | - default: |
|
1197 | - $ATT_input = 'ATT_' . $form_input; |
|
1198 | - // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
|
1199 | - $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
|
1200 | - $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
1201 | - } |
|
1202 | - // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
|
1203 | - // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
|
1204 | - // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
|
1205 | - // if this form input has a corresponding attendee property |
|
1206 | - if ($attendee_property) { |
|
1207 | - $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
1208 | - if ($answer_is_obj) { |
|
1209 | - // and delete the corresponding answer since we won't be storing this data in that object |
|
1210 | - $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer'); |
|
1211 | - $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
1212 | - } |
|
1213 | - return true; |
|
1214 | - } |
|
1215 | - if ($answer_is_obj) { |
|
1216 | - // save this data to the answer object |
|
1217 | - $this->_registration_answers[ $answer_cache_id ]->set_value($input_value); |
|
1218 | - $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
1219 | - return $result !== false; |
|
1220 | - } |
|
1221 | - foreach ($this->_registration_answers as $answer) { |
|
1222 | - if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
1223 | - $answer->set_value($input_value); |
|
1224 | - $result = $answer->save(); |
|
1225 | - return $result !== false; |
|
1226 | - } |
|
1227 | - } |
|
1228 | - return false; |
|
1229 | - } |
|
1196 | + default: |
|
1197 | + $ATT_input = 'ATT_' . $form_input; |
|
1198 | + // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
|
1199 | + $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
|
1200 | + $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
1201 | + } |
|
1202 | + // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
|
1203 | + // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
|
1204 | + // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
|
1205 | + // if this form input has a corresponding attendee property |
|
1206 | + if ($attendee_property) { |
|
1207 | + $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
1208 | + if ($answer_is_obj) { |
|
1209 | + // and delete the corresponding answer since we won't be storing this data in that object |
|
1210 | + $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer'); |
|
1211 | + $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
1212 | + } |
|
1213 | + return true; |
|
1214 | + } |
|
1215 | + if ($answer_is_obj) { |
|
1216 | + // save this data to the answer object |
|
1217 | + $this->_registration_answers[ $answer_cache_id ]->set_value($input_value); |
|
1218 | + $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
1219 | + return $result !== false; |
|
1220 | + } |
|
1221 | + foreach ($this->_registration_answers as $answer) { |
|
1222 | + if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
1223 | + $answer->set_value($input_value); |
|
1224 | + $result = $answer->save(); |
|
1225 | + return $result !== false; |
|
1226 | + } |
|
1227 | + } |
|
1228 | + return false; |
|
1229 | + } |
|
1230 | 1230 | |
1231 | 1231 | |
1232 | - /** |
|
1233 | - * _verify_critical_attendee_details_are_set |
|
1234 | - * |
|
1235 | - * @param string $form_input |
|
1236 | - * @param string $input_value |
|
1237 | - * @return boolean |
|
1238 | - */ |
|
1239 | - private function _verify_critical_attendee_details_are_set_and_validate_email( |
|
1240 | - $form_input = '', |
|
1241 | - $input_value = '' |
|
1242 | - ) { |
|
1243 | - if (empty($input_value)) { |
|
1244 | - // if the form input isn't marked as being required, then just return |
|
1245 | - if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) { |
|
1246 | - return true; |
|
1247 | - } |
|
1248 | - switch ($form_input) { |
|
1249 | - case 'fname': |
|
1250 | - EE_Error::add_error( |
|
1251 | - esc_html__('First Name is a required value.', 'event_espresso'), |
|
1252 | - __FILE__, |
|
1253 | - __FUNCTION__, |
|
1254 | - __LINE__ |
|
1255 | - ); |
|
1256 | - return false; |
|
1257 | - break; |
|
1258 | - case 'lname': |
|
1259 | - EE_Error::add_error( |
|
1260 | - esc_html__('Last Name is a required value.', 'event_espresso'), |
|
1261 | - __FILE__, |
|
1262 | - __FUNCTION__, |
|
1263 | - __LINE__ |
|
1264 | - ); |
|
1265 | - return false; |
|
1266 | - break; |
|
1267 | - case 'email': |
|
1268 | - EE_Error::add_error( |
|
1269 | - esc_html__('Please enter a valid email address.', 'event_espresso'), |
|
1270 | - __FILE__, |
|
1271 | - __FUNCTION__, |
|
1272 | - __LINE__ |
|
1273 | - ); |
|
1274 | - return false; |
|
1275 | - break; |
|
1276 | - } |
|
1277 | - } |
|
1278 | - return true; |
|
1279 | - } |
|
1232 | + /** |
|
1233 | + * _verify_critical_attendee_details_are_set |
|
1234 | + * |
|
1235 | + * @param string $form_input |
|
1236 | + * @param string $input_value |
|
1237 | + * @return boolean |
|
1238 | + */ |
|
1239 | + private function _verify_critical_attendee_details_are_set_and_validate_email( |
|
1240 | + $form_input = '', |
|
1241 | + $input_value = '' |
|
1242 | + ) { |
|
1243 | + if (empty($input_value)) { |
|
1244 | + // if the form input isn't marked as being required, then just return |
|
1245 | + if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) { |
|
1246 | + return true; |
|
1247 | + } |
|
1248 | + switch ($form_input) { |
|
1249 | + case 'fname': |
|
1250 | + EE_Error::add_error( |
|
1251 | + esc_html__('First Name is a required value.', 'event_espresso'), |
|
1252 | + __FILE__, |
|
1253 | + __FUNCTION__, |
|
1254 | + __LINE__ |
|
1255 | + ); |
|
1256 | + return false; |
|
1257 | + break; |
|
1258 | + case 'lname': |
|
1259 | + EE_Error::add_error( |
|
1260 | + esc_html__('Last Name is a required value.', 'event_espresso'), |
|
1261 | + __FILE__, |
|
1262 | + __FUNCTION__, |
|
1263 | + __LINE__ |
|
1264 | + ); |
|
1265 | + return false; |
|
1266 | + break; |
|
1267 | + case 'email': |
|
1268 | + EE_Error::add_error( |
|
1269 | + esc_html__('Please enter a valid email address.', 'event_espresso'), |
|
1270 | + __FILE__, |
|
1271 | + __FUNCTION__, |
|
1272 | + __LINE__ |
|
1273 | + ); |
|
1274 | + return false; |
|
1275 | + break; |
|
1276 | + } |
|
1277 | + } |
|
1278 | + return true; |
|
1279 | + } |
|
1280 | 1280 | |
1281 | 1281 | |
1282 | - /** |
|
1283 | - * _associate_attendee_with_registration |
|
1284 | - * |
|
1285 | - * @param EE_Registration $registration |
|
1286 | - * @param EE_Attendee $attendee |
|
1287 | - * @return void |
|
1288 | - * @throws EE_Error |
|
1289 | - * @throws InvalidArgumentException |
|
1290 | - * @throws ReflectionException |
|
1291 | - * @throws RuntimeException |
|
1292 | - * @throws InvalidDataTypeException |
|
1293 | - * @throws InvalidInterfaceException |
|
1294 | - */ |
|
1295 | - private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) |
|
1296 | - { |
|
1297 | - // add relation to attendee |
|
1298 | - $registration->_add_relation_to($attendee, 'Attendee'); |
|
1299 | - $registration->set_attendee_id($attendee->ID()); |
|
1300 | - $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1301 | - } |
|
1282 | + /** |
|
1283 | + * _associate_attendee_with_registration |
|
1284 | + * |
|
1285 | + * @param EE_Registration $registration |
|
1286 | + * @param EE_Attendee $attendee |
|
1287 | + * @return void |
|
1288 | + * @throws EE_Error |
|
1289 | + * @throws InvalidArgumentException |
|
1290 | + * @throws ReflectionException |
|
1291 | + * @throws RuntimeException |
|
1292 | + * @throws InvalidDataTypeException |
|
1293 | + * @throws InvalidInterfaceException |
|
1294 | + */ |
|
1295 | + private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) |
|
1296 | + { |
|
1297 | + // add relation to attendee |
|
1298 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1299 | + $registration->set_attendee_id($attendee->ID()); |
|
1300 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1301 | + } |
|
1302 | 1302 | |
1303 | 1303 | |
1304 | - /** |
|
1305 | - * _associate_registration_with_transaction |
|
1306 | - * |
|
1307 | - * @param EE_Registration $registration |
|
1308 | - * @return void |
|
1309 | - * @throws EE_Error |
|
1310 | - * @throws InvalidArgumentException |
|
1311 | - * @throws ReflectionException |
|
1312 | - * @throws InvalidDataTypeException |
|
1313 | - * @throws InvalidInterfaceException |
|
1314 | - */ |
|
1315 | - private function _associate_registration_with_transaction(EE_Registration $registration) |
|
1316 | - { |
|
1317 | - // add relation to registration |
|
1318 | - $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
1319 | - $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
1320 | - } |
|
1304 | + /** |
|
1305 | + * _associate_registration_with_transaction |
|
1306 | + * |
|
1307 | + * @param EE_Registration $registration |
|
1308 | + * @return void |
|
1309 | + * @throws EE_Error |
|
1310 | + * @throws InvalidArgumentException |
|
1311 | + * @throws ReflectionException |
|
1312 | + * @throws InvalidDataTypeException |
|
1313 | + * @throws InvalidInterfaceException |
|
1314 | + */ |
|
1315 | + private function _associate_registration_with_transaction(EE_Registration $registration) |
|
1316 | + { |
|
1317 | + // add relation to registration |
|
1318 | + $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
1319 | + $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
1320 | + } |
|
1321 | 1321 | |
1322 | 1322 | |
1323 | - /** |
|
1324 | - * _copy_critical_attendee_details_from_primary_registrant |
|
1325 | - * ensures that all attendees at least have data for first name, last name, and email address |
|
1326 | - * |
|
1327 | - * @param array $attendee_data |
|
1328 | - * @return array |
|
1329 | - * @throws EE_Error |
|
1330 | - * @throws InvalidArgumentException |
|
1331 | - * @throws ReflectionException |
|
1332 | - * @throws InvalidDataTypeException |
|
1333 | - * @throws InvalidInterfaceException |
|
1334 | - */ |
|
1335 | - private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) |
|
1336 | - { |
|
1337 | - // bare minimum critical details include first name, last name, email address |
|
1338 | - $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
1339 | - // add address info to critical details? |
|
1340 | - if (apply_filters( |
|
1341 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
|
1342 | - false |
|
1343 | - )) { |
|
1344 | - $address_details = array( |
|
1345 | - 'ATT_address', |
|
1346 | - 'ATT_address2', |
|
1347 | - 'ATT_city', |
|
1348 | - 'STA_ID', |
|
1349 | - 'CNT_ISO', |
|
1350 | - 'ATT_zip', |
|
1351 | - 'ATT_phone', |
|
1352 | - ); |
|
1353 | - $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
|
1354 | - } |
|
1355 | - foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
1356 | - if (! isset($attendee_data[ $critical_attendee_detail ]) |
|
1357 | - || empty($attendee_data[ $critical_attendee_detail ]) |
|
1358 | - ) { |
|
1359 | - $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
1360 | - $critical_attendee_detail |
|
1361 | - ); |
|
1362 | - } |
|
1363 | - } |
|
1364 | - return $attendee_data; |
|
1365 | - } |
|
1323 | + /** |
|
1324 | + * _copy_critical_attendee_details_from_primary_registrant |
|
1325 | + * ensures that all attendees at least have data for first name, last name, and email address |
|
1326 | + * |
|
1327 | + * @param array $attendee_data |
|
1328 | + * @return array |
|
1329 | + * @throws EE_Error |
|
1330 | + * @throws InvalidArgumentException |
|
1331 | + * @throws ReflectionException |
|
1332 | + * @throws InvalidDataTypeException |
|
1333 | + * @throws InvalidInterfaceException |
|
1334 | + */ |
|
1335 | + private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) |
|
1336 | + { |
|
1337 | + // bare minimum critical details include first name, last name, email address |
|
1338 | + $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
1339 | + // add address info to critical details? |
|
1340 | + if (apply_filters( |
|
1341 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
|
1342 | + false |
|
1343 | + )) { |
|
1344 | + $address_details = array( |
|
1345 | + 'ATT_address', |
|
1346 | + 'ATT_address2', |
|
1347 | + 'ATT_city', |
|
1348 | + 'STA_ID', |
|
1349 | + 'CNT_ISO', |
|
1350 | + 'ATT_zip', |
|
1351 | + 'ATT_phone', |
|
1352 | + ); |
|
1353 | + $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
|
1354 | + } |
|
1355 | + foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
1356 | + if (! isset($attendee_data[ $critical_attendee_detail ]) |
|
1357 | + || empty($attendee_data[ $critical_attendee_detail ]) |
|
1358 | + ) { |
|
1359 | + $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
1360 | + $critical_attendee_detail |
|
1361 | + ); |
|
1362 | + } |
|
1363 | + } |
|
1364 | + return $attendee_data; |
|
1365 | + } |
|
1366 | 1366 | |
1367 | 1367 | |
1368 | - /** |
|
1369 | - * update_reg_step |
|
1370 | - * this is the final step after a user revisits the site to edit their attendee information |
|
1371 | - * this gets called AFTER the process_reg_step() method above |
|
1372 | - * |
|
1373 | - * @return bool |
|
1374 | - * @throws EE_Error |
|
1375 | - * @throws InvalidArgumentException |
|
1376 | - * @throws ReflectionException |
|
1377 | - * @throws RuntimeException |
|
1378 | - * @throws InvalidDataTypeException |
|
1379 | - * @throws InvalidInterfaceException |
|
1380 | - */ |
|
1381 | - public function update_reg_step() |
|
1382 | - { |
|
1383 | - // save everything |
|
1384 | - if ($this->process_reg_step()) { |
|
1385 | - $this->checkout->redirect = true; |
|
1386 | - $this->checkout->redirect_url = add_query_arg( |
|
1387 | - array( |
|
1388 | - 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
1389 | - 'revisit' => true, |
|
1390 | - ), |
|
1391 | - $this->checkout->thank_you_page_url |
|
1392 | - ); |
|
1393 | - $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1394 | - return true; |
|
1395 | - } |
|
1396 | - return false; |
|
1397 | - } |
|
1368 | + /** |
|
1369 | + * update_reg_step |
|
1370 | + * this is the final step after a user revisits the site to edit their attendee information |
|
1371 | + * this gets called AFTER the process_reg_step() method above |
|
1372 | + * |
|
1373 | + * @return bool |
|
1374 | + * @throws EE_Error |
|
1375 | + * @throws InvalidArgumentException |
|
1376 | + * @throws ReflectionException |
|
1377 | + * @throws RuntimeException |
|
1378 | + * @throws InvalidDataTypeException |
|
1379 | + * @throws InvalidInterfaceException |
|
1380 | + */ |
|
1381 | + public function update_reg_step() |
|
1382 | + { |
|
1383 | + // save everything |
|
1384 | + if ($this->process_reg_step()) { |
|
1385 | + $this->checkout->redirect = true; |
|
1386 | + $this->checkout->redirect_url = add_query_arg( |
|
1387 | + array( |
|
1388 | + 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
1389 | + 'revisit' => true, |
|
1390 | + ), |
|
1391 | + $this->checkout->thank_you_page_url |
|
1392 | + ); |
|
1393 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1394 | + return true; |
|
1395 | + } |
|
1396 | + return false; |
|
1397 | + } |
|
1398 | 1398 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | $this->_slug = 'attendee_information'; |
50 | 50 | $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
51 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php'; |
|
51 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php'; |
|
52 | 52 | $this->checkout = $checkout; |
53 | 53 | $this->_reset_success_message(); |
54 | 54 | $this->set_instructions( |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | if ($registration instanceof EE_Registration |
148 | 148 | && $this->checkout->visit_allows_processing_of_this_registration($registration) |
149 | 149 | ) { |
150 | - $subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form($registration); |
|
151 | - if (! $this->checkout->admin_request) { |
|
152 | - $template_args['registrations'][ $registration->reg_url_link() ] = $registration; |
|
153 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
154 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
150 | + $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); |
|
151 | + if ( ! $this->checkout->admin_request) { |
|
152 | + $template_args['registrations'][$registration->reg_url_link()] = $registration; |
|
153 | + $template_args['ticket_count'][$registration->ticket()->ID()] = isset( |
|
154 | + $template_args['ticket_count'][$registration->ticket()->ID()] |
|
155 | 155 | ) |
156 | - ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
156 | + ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 |
|
157 | 157 | : 1; |
158 | 158 | $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
159 | 159 | $this->checkout->cart->get_grand_total(), |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $ticket_line_item = is_array($ticket_line_item) |
164 | 164 | ? reset($ticket_line_item) |
165 | 165 | : $ticket_line_item; |
166 | - $template_args['ticket_line_item'][ $registration->ticket()->ID() ] = |
|
166 | + $template_args['ticket_line_item'][$registration->ticket()->ID()] = |
|
167 | 167 | $Line_Item_Display->display_line_item($ticket_line_item); |
168 | 168 | } |
169 | 169 | if ($registration->is_primary_registrant()) { |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | ? $this->_copy_attendee_info_form() |
180 | 180 | : $this->_auto_copy_attendee_info(); |
181 | 181 | // generate hidden input |
182 | - if (isset($subsections[ $primary_registrant ]) |
|
183 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
182 | + if (isset($subsections[$primary_registrant]) |
|
183 | + && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper |
|
184 | 184 | ) { |
185 | - $subsections[ $primary_registrant ]->add_subsections( |
|
185 | + $subsections[$primary_registrant]->add_subsections( |
|
186 | 186 | $copy_options, |
187 | 187 | 'primary_registrant', |
188 | 188 | false |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | if ($question_groups) { |
244 | 244 | // array of params to pass to parent constructor |
245 | 245 | $form_args = array( |
246 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
246 | + 'html_id' => 'ee-registration-'.$registration->reg_url_link(), |
|
247 | 247 | 'html_class' => 'ee-reg-form-attendee-dv', |
248 | 248 | 'html_style' => $this->checkout->admin_request |
249 | 249 | ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | ); |
266 | 266 | foreach ($question_groups as $question_group) { |
267 | 267 | if ($question_group instanceof EE_Question_Group) { |
268 | - $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
|
268 | + $form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form( |
|
269 | 269 | $registration, |
270 | 270 | $question_group |
271 | 271 | ); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | // generate hidden input |
306 | 306 | return new EE_Hidden_Input( |
307 | 307 | array( |
308 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
308 | + 'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(), |
|
309 | 309 | 'default' => $additional_attendee_reg_info, |
310 | 310 | ) |
311 | 311 | ); |
@@ -326,12 +326,12 @@ discard block |
||
326 | 326 | { |
327 | 327 | // array of params to pass to parent constructor |
328 | 328 | $form_args = array( |
329 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' . $registration->ID(), |
|
329 | + 'html_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-'.$registration->ID(), |
|
330 | 330 | 'html_class' => $this->checkout->admin_request |
331 | 331 | ? 'form-table ee-reg-form-qstn-grp-dv' |
332 | 332 | : 'ee-reg-form-qstn-grp-dv', |
333 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-' |
|
334 | - . $registration->ID() . '-lbl', |
|
333 | + 'html_label_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-' |
|
334 | + . $registration->ID().'-lbl', |
|
335 | 335 | 'subsections' => array( |
336 | 336 | 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group), |
337 | 337 | ), |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | // where params |
343 | 343 | $query_params = array('QST_deleted' => 0); |
344 | 344 | // don't load admin only questions on the frontend |
345 | - if (! $this->checkout->admin_request) { |
|
345 | + if ( ! $this->checkout->admin_request) { |
|
346 | 346 | $query_params['QST_admin_only'] = array('!=', true); |
347 | 347 | } |
348 | 348 | $questions = $question_group->get_many_related( |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | $identifier = $question->is_system_question() |
377 | 377 | ? $question->system_ID() |
378 | 378 | : $question->ID(); |
379 | - $form_args['subsections'][ $identifier ] = $this->reg_form_question($registration, $question); |
|
379 | + $form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | $form_args['subsections'] = apply_filters( |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | { |
490 | 490 | return new EE_Form_Section_HTML( |
491 | 491 | EEH_Template::locate_template( |
492 | - SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php', |
|
492 | + SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php', |
|
493 | 493 | apply_filters( |
494 | 494 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
495 | 495 | array() |
@@ -522,16 +522,16 @@ discard block |
||
522 | 522 | if ($registration->ticket()->ID() !== $prev_ticket) { |
523 | 523 | $item_name = $registration->ticket()->name(); |
524 | 524 | $item_name .= $registration->ticket()->description() !== '' |
525 | - ? ' - ' . $registration->ticket()->description() |
|
525 | + ? ' - '.$registration->ticket()->description() |
|
526 | 526 | : ''; |
527 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = |
|
527 | + $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = |
|
528 | 528 | new EE_Form_Section_HTML( |
529 | - '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
529 | + '<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>' |
|
530 | 530 | ); |
531 | 531 | $prev_ticket = $registration->ticket()->ID(); |
532 | 532 | } |
533 | 533 | |
534 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = |
|
534 | + $copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = |
|
535 | 535 | new EE_Checkbox_Multi_Input( |
536 | 536 | array( |
537 | 537 | $registration->ID() => sprintf( |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | ), |
541 | 541 | ), |
542 | 542 | array( |
543 | - 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
543 | + 'html_id' => 'spco-copy-attendee-chk-'.$registration->reg_url_link(), |
|
544 | 544 | 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
545 | 545 | 'display_html_label_text' => false, |
546 | 546 | ) |
@@ -605,14 +605,14 @@ discard block |
||
605 | 605 | } |
606 | 606 | // verify instance |
607 | 607 | if ($answer instanceof EE_Answer) { |
608 | - if (! empty($answer_value)) { |
|
608 | + if ( ! empty($answer_value)) { |
|
609 | 609 | $answer->set('ANS_value', $answer_value); |
610 | 610 | } |
611 | 611 | $answer->cache('Question', $question); |
612 | 612 | // remember system ID had a bug where sometimes it could be null |
613 | 613 | $answer_cache_id = $question->is_system_question() |
614 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
615 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
614 | + ? $question->system_ID().'-'.$registration->reg_url_link() |
|
615 | + : $question->ID().'-'.$registration->reg_url_link(); |
|
616 | 616 | $registration->cache('Answer', $answer, $answer_cache_id); |
617 | 617 | } |
618 | 618 | return $this->_generate_question_input($registration, $question, $answer); |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | $identifier = $question->is_system_question() |
636 | 636 | ? $question->system_ID() |
637 | 637 | : $question->ID(); |
638 | - $this->_required_questions[ $identifier ] = $question->required() ? true : false; |
|
638 | + $this->_required_questions[$identifier] = $question->required() ? true : false; |
|
639 | 639 | add_filter( |
640 | 640 | 'FHEE__EE_Question__generate_form_input__country_options', |
641 | 641 | array($this, 'use_cached_countries_for_form_input'), |
@@ -649,17 +649,17 @@ discard block |
||
649 | 649 | 4 |
650 | 650 | ); |
651 | 651 | $input_constructor_args = array( |
652 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
653 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
654 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
655 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
652 | + 'html_name' => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']', |
|
653 | + 'html_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
654 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-'.$identifier, |
|
655 | + 'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
656 | 656 | 'html_label_class' => 'ee-reg-qstn', |
657 | 657 | ); |
658 | 658 | $input_constructor_args['html_label_id'] .= '-lbl'; |
659 | 659 | if ($answer instanceof EE_Answer && $answer->ID()) { |
660 | - $input_constructor_args['html_name'] .= '[' . $answer->ID() . ']'; |
|
661 | - $input_constructor_args['html_id'] .= '-' . $answer->ID(); |
|
662 | - $input_constructor_args['html_label_id'] .= '-' . $answer->ID(); |
|
660 | + $input_constructor_args['html_name'] .= '['.$answer->ID().']'; |
|
661 | + $input_constructor_args['html_id'] .= '-'.$answer->ID(); |
|
662 | + $input_constructor_args['html_label_id'] .= '-'.$answer->ID(); |
|
663 | 663 | } |
664 | 664 | $form_input = $question->generate_form_input( |
665 | 665 | $registration, |
@@ -703,10 +703,10 @@ discard block |
||
703 | 703 | $countries = $this->checkout->action === 'process_reg_step' |
704 | 704 | ? EEM_Country::instance()->get_all_countries() |
705 | 705 | : EEM_Country::instance()->get_all_active_countries(); |
706 | - if (! empty($countries)) { |
|
706 | + if ( ! empty($countries)) { |
|
707 | 707 | foreach ($countries as $country) { |
708 | 708 | if ($country instanceof EE_Country) { |
709 | - $country_options[ $country->ID() ] = $country->name(); |
|
709 | + $country_options[$country->ID()] = $country->name(); |
|
710 | 710 | } |
711 | 711 | } |
712 | 712 | } |
@@ -753,10 +753,10 @@ discard block |
||
753 | 753 | $states = $this->checkout->action === 'process_reg_step' |
754 | 754 | ? EEM_State::instance()->get_all_states() |
755 | 755 | : EEM_State::instance()->get_all_active_states(); |
756 | - if (! empty($states)) { |
|
756 | + if ( ! empty($states)) { |
|
757 | 757 | foreach ($states as $state) { |
758 | 758 | if ($state instanceof EE_State) { |
759 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
759 | + $state_options[$state->country()->name()][$state->ID()] = $state->name(); |
|
760 | 760 | } |
761 | 761 | } |
762 | 762 | } |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | ); |
804 | 804 | return false; |
805 | 805 | } |
806 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
806 | + if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
807 | 807 | EE_Error::add_error( |
808 | 808 | esc_html__( |
809 | 809 | 'A valid transaction could not be initiated for processing your registrations.', |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
831 | 831 | 'event_espresso' |
832 | 832 | ), |
833 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
833 | + '<a href="'.get_post_type_archive_link('espresso_events').'" >', |
|
834 | 834 | '</a>', |
835 | 835 | '<br />' |
836 | 836 | ); |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | // but return immediately if the previous step exited early due to errors |
851 | 851 | return false; |
852 | 852 | } |
853 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
853 | + if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
854 | 854 | // generate a correctly translated string for all possible singular/plural combinations |
855 | 855 | if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
856 | 856 | $error_msg = sprintf( |
@@ -933,7 +933,7 @@ discard block |
||
933 | 933 | // grab the saved registrations from the transaction |
934 | 934 | foreach ($registrations as $registration) { |
935 | 935 | // verify EE_Registration object |
936 | - if (! $registration instanceof EE_Registration) { |
|
936 | + if ( ! $registration instanceof EE_Registration) { |
|
937 | 937 | EE_Error::add_error( |
938 | 938 | esc_html__( |
939 | 939 | 'An invalid Registration object was discovered when attempting to process your registration information.', |
@@ -948,12 +948,12 @@ discard block |
||
948 | 948 | /** @var string $reg_url_link */ |
949 | 949 | $reg_url_link = $registration->reg_url_link(); |
950 | 950 | // reg_url_link exists ? |
951 | - if (! empty($reg_url_link)) { |
|
951 | + if ( ! empty($reg_url_link)) { |
|
952 | 952 | // should this registration be processed during this visit ? |
953 | 953 | if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
954 | 954 | // if NOT revisiting, then let's save the registration now, |
955 | 955 | // so that we have a REG_ID to use when generating other objects |
956 | - if (! $this->checkout->revisit) { |
|
956 | + if ( ! $this->checkout->revisit) { |
|
957 | 957 | $registration->save(); |
958 | 958 | } |
959 | 959 | /** |
@@ -977,18 +977,18 @@ discard block |
||
977 | 977 | |
978 | 978 | // Houston, we have a registration! |
979 | 979 | $att_nmbr++; |
980 | - $this->_attendee_data[ $reg_url_link ] = array(); |
|
980 | + $this->_attendee_data[$reg_url_link] = array(); |
|
981 | 981 | // grab any existing related answer objects |
982 | 982 | $this->_registration_answers = $registration->answers(); |
983 | 983 | // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
984 | - if (isset($valid_data[ $reg_url_link ])) { |
|
984 | + if (isset($valid_data[$reg_url_link])) { |
|
985 | 985 | // do we need to copy basic info from primary attendee ? |
986 | - $copy_primary = isset($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) |
|
987 | - && absint($valid_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0; |
|
986 | + $copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info']) |
|
987 | + && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0; |
|
988 | 988 | // filter form input data for this registration |
989 | - $valid_data[ $reg_url_link ] = (array) apply_filters( |
|
989 | + $valid_data[$reg_url_link] = (array) apply_filters( |
|
990 | 990 | 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
991 | - $valid_data[ $reg_url_link ] |
|
991 | + $valid_data[$reg_url_link] |
|
992 | 992 | ); |
993 | 993 | if (isset($valid_data['primary_attendee'])) { |
994 | 994 | $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
@@ -997,12 +997,12 @@ discard block |
||
997 | 997 | unset($valid_data['primary_attendee']); |
998 | 998 | } |
999 | 999 | // now loop through our array of valid post data && process attendee reg forms |
1000 | - foreach ($valid_data[ $reg_url_link ] as $form_section => $form_inputs) { |
|
1001 | - if (! in_array($form_section, $non_input_form_sections, true)) { |
|
1000 | + foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) { |
|
1001 | + if ( ! in_array($form_section, $non_input_form_sections, true)) { |
|
1002 | 1002 | foreach ($form_inputs as $form_input => $input_value) { |
1003 | 1003 | // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
1004 | 1004 | // check for critical inputs |
1005 | - if (! $this->_verify_critical_attendee_details_are_set_and_validate_email( |
|
1005 | + if ( ! $this->_verify_critical_attendee_details_are_set_and_validate_email( |
|
1006 | 1006 | $form_input, |
1007 | 1007 | $input_value |
1008 | 1008 | ) |
@@ -1014,15 +1014,15 @@ discard block |
||
1014 | 1014 | && ! empty($input_value) |
1015 | 1015 | && $reg_url_link === $primary_registrant['line_item_id'] |
1016 | 1016 | ) { |
1017 | - $primary_registrant[ $form_input ] = $input_value; |
|
1017 | + $primary_registrant[$form_input] = $input_value; |
|
1018 | 1018 | } elseif ($copy_primary |
1019 | 1019 | && $input_value === null |
1020 | - && isset($primary_registrant[ $form_input ]) |
|
1020 | + && isset($primary_registrant[$form_input]) |
|
1021 | 1021 | ) { |
1022 | - $input_value = $primary_registrant[ $form_input ]; |
|
1022 | + $input_value = $primary_registrant[$form_input]; |
|
1023 | 1023 | } |
1024 | 1024 | // now attempt to save the input data |
1025 | - if (! $this->_save_registration_form_input( |
|
1025 | + if ( ! $this->_save_registration_form_input( |
|
1026 | 1026 | $registration, |
1027 | 1027 | $form_input, |
1028 | 1028 | $input_value |
@@ -1058,15 +1058,15 @@ discard block |
||
1058 | 1058 | $attendee = $this->checkout->primary_attendee_obj; |
1059 | 1059 | } else { |
1060 | 1060 | // ensure critical details are set for additional attendees |
1061 | - $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
1061 | + $this->_attendee_data[$reg_url_link] = $att_nmbr > 1 |
|
1062 | 1062 | ? $this->_copy_critical_attendee_details_from_primary_registrant( |
1063 | - $this->_attendee_data[ $reg_url_link ] |
|
1063 | + $this->_attendee_data[$reg_url_link] |
|
1064 | 1064 | ) |
1065 | - : $this->_attendee_data[ $reg_url_link ]; |
|
1065 | + : $this->_attendee_data[$reg_url_link]; |
|
1066 | 1066 | // execute create attendee command (which may return an existing attendee) |
1067 | 1067 | $attendee = EE_Registry::instance()->BUS->execute( |
1068 | 1068 | new CreateAttendeeCommand( |
1069 | - $this->_attendee_data[ $reg_url_link ], |
|
1069 | + $this->_attendee_data[$reg_url_link], |
|
1070 | 1070 | $registration |
1071 | 1071 | ) |
1072 | 1072 | ); |
@@ -1079,7 +1079,7 @@ discard block |
||
1079 | 1079 | // add relation to registration, set attendee ID, and cache attendee |
1080 | 1080 | $this->_associate_attendee_with_registration($registration, $attendee); |
1081 | 1081 | // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
1082 | - if (! $registration->attendee() instanceof EE_Attendee) { |
|
1082 | + if ( ! $registration->attendee() instanceof EE_Attendee) { |
|
1083 | 1083 | EE_Error::add_error( |
1084 | 1084 | sprintf( |
1085 | 1085 | esc_html_x( |
@@ -1129,7 +1129,7 @@ discard block |
||
1129 | 1129 | __LINE__ |
1130 | 1130 | ); |
1131 | 1131 | // remove malformed data |
1132 | - unset($valid_data[ $reg_url_link ]); |
|
1132 | + unset($valid_data[$reg_url_link]); |
|
1133 | 1133 | return false; |
1134 | 1134 | } |
1135 | 1135 | } // end of foreach ( $this->checkout->transaction->registrations() as $registration ) |
@@ -1175,10 +1175,10 @@ discard block |
||
1175 | 1175 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
1176 | 1176 | */ |
1177 | 1177 | $answer_cache_id = $this->checkout->reg_url_link |
1178 | - ? $form_input . '-' . $registration->reg_url_link() |
|
1178 | + ? $form_input.'-'.$registration->reg_url_link() |
|
1179 | 1179 | : $form_input; |
1180 | - $answer_is_obj = isset($this->_registration_answers[ $answer_cache_id ]) |
|
1181 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer; |
|
1180 | + $answer_is_obj = isset($this->_registration_answers[$answer_cache_id]) |
|
1181 | + && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer; |
|
1182 | 1182 | // rename form_inputs if they are EE_Attendee properties |
1183 | 1183 | switch ((string) $form_input) { |
1184 | 1184 | case 'state': |
@@ -1194,28 +1194,28 @@ discard block |
||
1194 | 1194 | break; |
1195 | 1195 | |
1196 | 1196 | default: |
1197 | - $ATT_input = 'ATT_' . $form_input; |
|
1197 | + $ATT_input = 'ATT_'.$form_input; |
|
1198 | 1198 | // EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
1199 | 1199 | $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
1200 | - $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
1200 | + $form_input = $attendee_property ? 'ATT_'.$form_input : $form_input; |
|
1201 | 1201 | } |
1202 | 1202 | // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
1203 | 1203 | // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
1204 | 1204 | // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
1205 | 1205 | // if this form input has a corresponding attendee property |
1206 | 1206 | if ($attendee_property) { |
1207 | - $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
1207 | + $this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value; |
|
1208 | 1208 | if ($answer_is_obj) { |
1209 | 1209 | // and delete the corresponding answer since we won't be storing this data in that object |
1210 | - $registration->_remove_relation_to($this->_registration_answers[ $answer_cache_id ], 'Answer'); |
|
1211 | - $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
1210 | + $registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer'); |
|
1211 | + $this->_registration_answers[$answer_cache_id]->delete_permanently(); |
|
1212 | 1212 | } |
1213 | 1213 | return true; |
1214 | 1214 | } |
1215 | 1215 | if ($answer_is_obj) { |
1216 | 1216 | // save this data to the answer object |
1217 | - $this->_registration_answers[ $answer_cache_id ]->set_value($input_value); |
|
1218 | - $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
1217 | + $this->_registration_answers[$answer_cache_id]->set_value($input_value); |
|
1218 | + $result = $this->_registration_answers[$answer_cache_id]->save(); |
|
1219 | 1219 | return $result !== false; |
1220 | 1220 | } |
1221 | 1221 | foreach ($this->_registration_answers as $answer) { |
@@ -1242,7 +1242,7 @@ discard block |
||
1242 | 1242 | ) { |
1243 | 1243 | if (empty($input_value)) { |
1244 | 1244 | // if the form input isn't marked as being required, then just return |
1245 | - if (! isset($this->_required_questions[ $form_input ]) || ! $this->_required_questions[ $form_input ]) { |
|
1245 | + if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) { |
|
1246 | 1246 | return true; |
1247 | 1247 | } |
1248 | 1248 | switch ($form_input) { |
@@ -1353,10 +1353,10 @@ discard block |
||
1353 | 1353 | $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
1354 | 1354 | } |
1355 | 1355 | foreach ($critical_attendee_details as $critical_attendee_detail) { |
1356 | - if (! isset($attendee_data[ $critical_attendee_detail ]) |
|
1357 | - || empty($attendee_data[ $critical_attendee_detail ]) |
|
1356 | + if ( ! isset($attendee_data[$critical_attendee_detail]) |
|
1357 | + || empty($attendee_data[$critical_attendee_detail]) |
|
1358 | 1358 | ) { |
1359 | - $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
1359 | + $attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get( |
|
1360 | 1360 | $critical_attendee_detail |
1361 | 1361 | ); |
1362 | 1362 | } |
@@ -9,27 +9,27 @@ discard block |
||
9 | 9 | <h1><?php _e("Database Update Crash Report Sent", "event_espresso"); ?></h1> |
10 | 10 | <p> |
11 | 11 | <?php _e( |
12 | - "A crash report email was sent to Event Espresso. You should hear back from us soon.", |
|
13 | - "event_espresso" |
|
14 | - ); ?></p> |
|
12 | + "A crash report email was sent to Event Espresso. You should hear back from us soon.", |
|
13 | + "event_espresso" |
|
14 | + ); ?></p> |
|
15 | 15 | <?php } else {// didn't send email properly ?> |
16 | 16 | <h1><?php _e("Migration Report not sent", "event_espresso"); ?></h1> |
17 | 17 | <p> |
18 | 18 | <?php _e( |
19 | - "An error occurred and we were not able to automatically send a report to Event Espresso support.", |
|
20 | - "event_espresso" |
|
21 | - ); ?></p> |
|
19 | + "An error occurred and we were not able to automatically send a report to Event Espresso support.", |
|
20 | + "event_espresso" |
|
21 | + ); ?></p> |
|
22 | 22 | <p> |
23 | 23 | <?php printf( |
24 | - esc_html__("Please copy-and-paste the system information below to %s", "event_espresso"), |
|
25 | - '<a href="mailto:' . EE_SUPPORT_EMAIL . '">' . EE_SUPPORT_EMAIL . "</a>" |
|
26 | - ); ?></p> |
|
24 | + esc_html__("Please copy-and-paste the system information below to %s", "event_espresso"), |
|
25 | + '<a href="mailto:' . EE_SUPPORT_EMAIL . '">' . EE_SUPPORT_EMAIL . "</a>" |
|
26 | + ); ?></p> |
|
27 | 27 | <label> |
28 | 28 | <?php _e("system status info", "event_espresso"); ?> |
29 | 29 | <textarea name="system_status_info" class="system_status_info"> |
30 | 30 | <?php print_r( |
31 | - EEM_System_Status::instance()->get_system_stati() |
|
32 | - ); ?></textarea> |
|
31 | + EEM_System_Status::instance()->get_system_stati() |
|
32 | + ); ?></textarea> |
|
33 | 33 | </label> |
34 | 34 | <?php } ?> |
35 | 35 | |
@@ -50,32 +50,32 @@ discard block |
||
50 | 50 | <td> |
51 | 51 | <p> |
52 | 52 | <?php |
53 | - printf( |
|
54 | - esc_html__( |
|
55 | - 'First, %1$s check the forums %2$s to see if there is a solution before re-attempting the Database Update. Often it helps to deactivate other plugins which may have conflicts; or it may help to add %3$s to your %4$s wp-config.php%5$s (which will make the update run slower, but may resolve any memory exhaustion errors.', |
|
56 | - 'event_espresso' |
|
57 | - ), |
|
58 | - "<a href='" . EE_SUPPORT_EMAIL . "' target='_blank'>", |
|
59 | - '</a>', |
|
60 | - '<pre lang="php">define( \'EE_MIGRATION_STEP_SIZE\', 10 );</pre>', |
|
61 | - '<b>', |
|
62 | - '</b>' |
|
63 | - ); |
|
64 | - ?> |
|
53 | + printf( |
|
54 | + esc_html__( |
|
55 | + 'First, %1$s check the forums %2$s to see if there is a solution before re-attempting the Database Update. Often it helps to deactivate other plugins which may have conflicts; or it may help to add %3$s to your %4$s wp-config.php%5$s (which will make the update run slower, but may resolve any memory exhaustion errors.', |
|
56 | + 'event_espresso' |
|
57 | + ), |
|
58 | + "<a href='" . EE_SUPPORT_EMAIL . "' target='_blank'>", |
|
59 | + '</a>', |
|
60 | + '<pre lang="php">define( \'EE_MIGRATION_STEP_SIZE\', 10 );</pre>', |
|
61 | + '<b>', |
|
62 | + '</b>' |
|
63 | + ); |
|
64 | + ?> |
|
65 | 65 | </p> |
66 | 66 | |
67 | 67 | <p> |
68 | 68 | <?php |
69 | - printf( |
|
70 | - esc_html__( |
|
71 | - 'To retry updating your data: restore to the backup you made before the update and reactivate EE (and any addons you are using) and re-run the Database Update. If you did not make a database backup and are migrating from EE3: delete your EE4 data (use the %1$s Reset/Delete Data tab above%2$s), and then reactivate EE4, and then re-run the migration and updates. If you did not make a database backup, are only updating from a previous install of EE4, have found a solution to the fatal error you received, and are willing to possibly have some data lost, %3$sattempt to continue migrating%2$s.', |
|
72 | - 'event_espresso' |
|
73 | - ), |
|
74 | - "<a href='$reset_db_page_url'>", |
|
75 | - "</a>", |
|
76 | - "<a class='button-primary' href='$reattempt_action_url'>" |
|
77 | - ); |
|
78 | - ?> |
|
69 | + printf( |
|
70 | + esc_html__( |
|
71 | + 'To retry updating your data: restore to the backup you made before the update and reactivate EE (and any addons you are using) and re-run the Database Update. If you did not make a database backup and are migrating from EE3: delete your EE4 data (use the %1$s Reset/Delete Data tab above%2$s), and then reactivate EE4, and then re-run the migration and updates. If you did not make a database backup, are only updating from a previous install of EE4, have found a solution to the fatal error you received, and are willing to possibly have some data lost, %3$sattempt to continue migrating%2$s.', |
|
72 | + 'event_espresso' |
|
73 | + ), |
|
74 | + "<a href='$reset_db_page_url'>", |
|
75 | + "</a>", |
|
76 | + "<a class='button-primary' href='$reattempt_action_url'>" |
|
77 | + ); |
|
78 | + ?> |
|
79 | 79 | </p> |
80 | 80 | </td> |
81 | 81 | </tr> |
@@ -85,66 +85,66 @@ discard block |
||
85 | 85 | </td> |
86 | 86 | <td> |
87 | 87 | <?php |
88 | - printf( |
|
89 | - esc_html__( |
|
90 | - 'Just make sure you\'ve %1$s checked for a solution in the forums,%2$s and properly contacted Support. We will get back to you as soon as possible', |
|
91 | - 'event_espresso' |
|
92 | - ), |
|
93 | - "<a href='" . EE_SUPPORT_EMAIL . "'>", |
|
94 | - "</a>" |
|
95 | - ); |
|
96 | - ?> |
|
88 | + printf( |
|
89 | + esc_html__( |
|
90 | + 'Just make sure you\'ve %1$s checked for a solution in the forums,%2$s and properly contacted Support. We will get back to you as soon as possible', |
|
91 | + 'event_espresso' |
|
92 | + ), |
|
93 | + "<a href='" . EE_SUPPORT_EMAIL . "'>", |
|
94 | + "</a>" |
|
95 | + ); |
|
96 | + ?> |
|
97 | 97 | </td> |
98 | 98 | </tr> |
99 | 99 | <tr> |
100 | 100 | <td> |
101 | 101 | <p class='big-text'> |
102 | 102 | <?php printf( |
103 | - esc_html__('I don\'t need my old EE %s data', 'event_espresso'), |
|
104 | - $most_recent_migration->slug() |
|
105 | - ); ?></p> |
|
103 | + esc_html__('I don\'t need my old EE %s data', 'event_espresso'), |
|
104 | + $most_recent_migration->slug() |
|
105 | + ); ?></p> |
|
106 | 106 | </td> |
107 | 107 | <td> |
108 | 108 | <?php |
109 | - printf( |
|
110 | - esc_html__( |
|
111 | - 'If you are ok with losing all the EE %1$s data, you can skip the Database Updates and %2$s use EE4 with only default Data%3$s', |
|
112 | - 'event_espresso' |
|
113 | - ), |
|
114 | - $most_recent_migration->slug(), |
|
115 | - "<a id='do-not-migrate' class='do-not-migrate button-primary' href='$reset_db_action_url'>", |
|
116 | - "</a>" |
|
117 | - ); |
|
118 | - ?> |
|
109 | + printf( |
|
110 | + esc_html__( |
|
111 | + 'If you are ok with losing all the EE %1$s data, you can skip the Database Updates and %2$s use EE4 with only default Data%3$s', |
|
112 | + 'event_espresso' |
|
113 | + ), |
|
114 | + $most_recent_migration->slug(), |
|
115 | + "<a id='do-not-migrate' class='do-not-migrate button-primary' href='$reset_db_action_url'>", |
|
116 | + "</a>" |
|
117 | + ); |
|
118 | + ?> |
|
119 | 119 | </td> |
120 | 120 | </tr> |
121 | 121 | <tr> |
122 | 122 | <td> |
123 | 123 | <p class='big-text'> |
124 | 124 | <?php printf( |
125 | - esc_html__('I want to go back to my old version of EE %1$s', 'event_espresso'), |
|
126 | - $most_recent_migration->slug() |
|
127 | - ); ?> |
|
125 | + esc_html__('I want to go back to my old version of EE %1$s', 'event_espresso'), |
|
126 | + $most_recent_migration->slug() |
|
127 | + ); ?> |
|
128 | 128 | </td> |
129 | 129 | <td> |
130 | 130 | <p> |
131 | 131 | <?php |
132 | - printf( |
|
133 | - esc_html__( |
|
134 | - 'Then we suggest you re-activate the old version of EE %3$s and restore your database to the backup you made just before the Database Update . If you didn\'t backup your database and are migrating from EE3, you can also delete your EE4 data (use on the %1$s"Reset/Delete Data" tab above%2$s), and then reactivate EE3 from the plugins page. Note: some of your EE3 shortcodes may have been changed to their EE4 equivalents, so you will need to change them back.', |
|
135 | - 'event_espresso' |
|
136 | - ), |
|
137 | - "<a href='$reset_db_page_url'>", |
|
138 | - "</a>", |
|
139 | - $most_recent_migration->slug() |
|
140 | - ); |
|
141 | - ?> |
|
132 | + printf( |
|
133 | + esc_html__( |
|
134 | + 'Then we suggest you re-activate the old version of EE %3$s and restore your database to the backup you made just before the Database Update . If you didn\'t backup your database and are migrating from EE3, you can also delete your EE4 data (use on the %1$s"Reset/Delete Data" tab above%2$s), and then reactivate EE3 from the plugins page. Note: some of your EE3 shortcodes may have been changed to their EE4 equivalents, so you will need to change them back.', |
|
135 | + 'event_espresso' |
|
136 | + ), |
|
137 | + "<a href='$reset_db_page_url'>", |
|
138 | + "</a>", |
|
139 | + $most_recent_migration->slug() |
|
140 | + ); |
|
141 | + ?> |
|
142 | 142 | </p> |
143 | 143 | <p> |
144 | 144 | <?php _e( |
145 | - "If you ever decide to re-attempt using EE4, you will again be given the option to migrate your EE3 data or not.", |
|
146 | - 'event_espresso' |
|
147 | - ); ?></p> |
|
145 | + "If you ever decide to re-attempt using EE4, you will again be given the option to migrate your EE3 data or not.", |
|
146 | + 'event_espresso' |
|
147 | + ); ?></p> |
|
148 | 148 | </td> |
149 | 149 | </tr> |
150 | 150 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | <p> |
23 | 23 | <?php printf( |
24 | 24 | esc_html__("Please copy-and-paste the system information below to %s", "event_espresso"), |
25 | - '<a href="mailto:' . EE_SUPPORT_EMAIL . '">' . EE_SUPPORT_EMAIL . "</a>" |
|
25 | + '<a href="mailto:'.EE_SUPPORT_EMAIL.'">'.EE_SUPPORT_EMAIL."</a>" |
|
26 | 26 | ); ?></p> |
27 | 27 | <label> |
28 | 28 | <?php _e("system status info", "event_espresso"); ?> |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'First, %1$s check the forums %2$s to see if there is a solution before re-attempting the Database Update. Often it helps to deactivate other plugins which may have conflicts; or it may help to add %3$s to your %4$s wp-config.php%5$s (which will make the update run slower, but may resolve any memory exhaustion errors.', |
56 | 56 | 'event_espresso' |
57 | 57 | ), |
58 | - "<a href='" . EE_SUPPORT_EMAIL . "' target='_blank'>", |
|
58 | + "<a href='".EE_SUPPORT_EMAIL."' target='_blank'>", |
|
59 | 59 | '</a>', |
60 | 60 | '<pre lang="php">define( \'EE_MIGRATION_STEP_SIZE\', 10 );</pre>', |
61 | 61 | '<b>', |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | 'Just make sure you\'ve %1$s checked for a solution in the forums,%2$s and properly contacted Support. We will get back to you as soon as possible', |
91 | 91 | 'event_espresso' |
92 | 92 | ), |
93 | - "<a href='" . EE_SUPPORT_EMAIL . "'>", |
|
93 | + "<a href='".EE_SUPPORT_EMAIL."'>", |
|
94 | 94 | "</a>" |
95 | 95 | ); |
96 | 96 | ?> |
@@ -3,19 +3,19 @@ discard block |
||
3 | 3 | ?> |
4 | 4 | <h1><?php esc_html_e("Data Migration Error", "event_espresso"); ?></h1> |
5 | 5 | <p class='error'><?php |
6 | - printf( |
|
7 | - esc_html__( |
|
8 | - "Your last Database Update had a %s fatal error and was halted%s.", |
|
9 | - "event_espresso" |
|
10 | - ), |
|
11 | - "<b>", |
|
12 | - "</b>" |
|
13 | - ); ?></p> |
|
6 | + printf( |
|
7 | + esc_html__( |
|
8 | + "Your last Database Update had a %s fatal error and was halted%s.", |
|
9 | + "event_espresso" |
|
10 | + ), |
|
11 | + "<b>", |
|
12 | + "</b>" |
|
13 | + ); ?></p> |
|
14 | 14 | <a id="show-hide-migration-warnings" class="display-the-hidden"><?php |
15 | - esc_html_e( |
|
16 | - "Show Errors", |
|
17 | - 'event_espresso' |
|
18 | - ); ?></a> |
|
15 | + esc_html_e( |
|
16 | + "Show Errors", |
|
17 | + 'event_espresso' |
|
18 | + ); ?></a> |
|
19 | 19 | <ul class="migration-warnings" style="display:none"> |
20 | 20 | <?php foreach ($most_recent_migration->get_errors() as $error) { ?> |
21 | 21 | <li style="overflow-y:auto;max-height:100px"><?php echo esc_html($error) ?></li> |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | </ul> |
24 | 24 | <h2> |
25 | 25 | <?php esc_html_e( |
26 | - "Fill out the below form to automatically Send Event Espresso a Crash Report", |
|
27 | - "event_espresso" |
|
28 | - ); ?></h2> |
|
26 | + "Fill out the below form to automatically Send Event Espresso a Crash Report", |
|
27 | + "event_espresso" |
|
28 | + ); ?></h2> |
|
29 | 29 | <form action='<?php echo EE_Admin_Page::add_query_args_and_nonce( |
30 | - array('action' => 'send_migration_crash_report'), |
|
31 | - EE_MAINTENANCE_ADMIN_URL |
|
30 | + array('action' => 'send_migration_crash_report'), |
|
31 | + EE_MAINTENANCE_ADMIN_URL |
|
32 | 32 | ); ?>' method='post'> |
33 | 33 | <table class='widefat'> |
34 | 34 | <tr> |
@@ -39,46 +39,46 @@ discard block |
||
39 | 39 | <tr> |
40 | 40 | <td><label for='from_name'><?php esc_html_e("Your Name", "event_espresso"); ?></label></td> |
41 | 41 | <td><input name='from_name' id='from_name' type='text' style="width:200px" value='<?php |
42 | - printf( |
|
43 | - esc_html__("Admin of %s", "event_espresso"), |
|
44 | - get_bloginfo('name', 'display') |
|
45 | - ); ?>'></td> |
|
42 | + printf( |
|
43 | + esc_html__("Admin of %s", "event_espresso"), |
|
44 | + get_bloginfo('name', 'display') |
|
45 | + ); ?>'></td> |
|
46 | 46 | </tr> |
47 | 47 | <tr> |
48 | 48 | <td><label for='body'><?php esc_html_e("Comments", "event_espresso"); ?></label></td> |
49 | 49 | <td><textarea name="body" id="body" class='system_status_info'> |
50 | 50 | <?php esc_html_e( |
51 | - "Enter any comments about why you think the error may have occurred", |
|
52 | - "event_espresso" |
|
53 | - ); ?></textarea> |
|
51 | + "Enter any comments about why you think the error may have occurred", |
|
52 | + "event_espresso" |
|
53 | + ); ?></textarea> |
|
54 | 54 | <p class='description'> |
55 | 55 | <?php esc_html_e( |
56 | - "Note: the System Information report will also be added to the email's body, which contains information about your Event Espresso, Wordpress, and PHP settings which can be helpful in debugging the problem.", |
|
57 | - "event_espresso" |
|
58 | - ); ?></p></td> |
|
56 | + "Note: the System Information report will also be added to the email's body, which contains information about your Event Espresso, Wordpress, and PHP settings which can be helpful in debugging the problem.", |
|
57 | + "event_espresso" |
|
58 | + ); ?></p></td> |
|
59 | 59 | </tr> |
60 | 60 | <tr> |
61 | 61 | <td colspan="2"><input type="submit" value="<?php |
62 | - esc_html_e( |
|
63 | - "Mail Crash Report to Event Espresso", |
|
64 | - "event_espresso" |
|
65 | - ); ?>"/></td> |
|
62 | + esc_html_e( |
|
63 | + "Mail Crash Report to Event Espresso", |
|
64 | + "event_espresso" |
|
65 | + ); ?>"/></td> |
|
66 | 66 | </tr> |
67 | 67 | </table> |
68 | 68 | </form> |
69 | 69 | <br> |
70 | 70 | <p> |
71 | 71 | <?php printf( |
72 | - esc_html__('...or copy-and-paste the below information to %1$s %2$s %3$s', "event_espresso"), |
|
73 | - '<a href="mailto:' . EE_SUPPORT_EMAIL . '">', |
|
74 | - EE_SUPPORT_EMAIL, |
|
75 | - "</a>" |
|
76 | - ); ?></p> |
|
72 | + esc_html__('...or copy-and-paste the below information to %1$s %2$s %3$s', "event_espresso"), |
|
73 | + '<a href="mailto:' . EE_SUPPORT_EMAIL . '">', |
|
74 | + EE_SUPPORT_EMAIL, |
|
75 | + "</a>" |
|
76 | + ); ?></p> |
|
77 | 77 | <textarea class="system_status_info"><?php print_r(EEM_System_Status::instance()->get_system_stati()) ?></textarea> |
78 | 78 | <p><?php printf(esc_html__('%1$sNext Step%2$s', 'event_espresso'), "<a href='$next_url'>", "</a>"); ?></p> |
79 | 79 | <p> |
80 | 80 | <?php printf( |
81 | - esc_html__('...or %1$sDON\'T send crash report%2$s.', 'event_espresso'), |
|
82 | - "<a href='$next_url'>", |
|
83 | - "</a>" |
|
84 | - ); ?></p> |
|
81 | + esc_html__('...or %1$sDON\'T send crash report%2$s.', 'event_espresso'), |
|
82 | + "<a href='$next_url'>", |
|
83 | + "</a>" |
|
84 | + ); ?></p> |
@@ -21,161 +21,161 @@ |
||
21 | 21 | abstract class AssetManager implements AssetManagerInterface |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var AssetCollection $assets |
|
26 | - */ |
|
27 | - protected $assets; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var DomainInterface |
|
31 | - */ |
|
32 | - protected $domain; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var Registry $registry |
|
36 | - */ |
|
37 | - protected $registry; |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * AssetRegister constructor. |
|
42 | - * |
|
43 | - * @param DomainInterface $domain |
|
44 | - * @param AssetCollection $assets |
|
45 | - * @param Registry $registry |
|
46 | - */ |
|
47 | - public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry) |
|
48 | - { |
|
49 | - $this->domain = $domain; |
|
50 | - $this->assets = $assets; |
|
51 | - $this->registry = $registry; |
|
52 | - add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
53 | - add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
54 | - add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2); |
|
55 | - add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2); |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @return void |
|
61 | - * @throws DuplicateCollectionIdentifierException |
|
62 | - * @throws InvalidDataTypeException |
|
63 | - * @throws InvalidEntityException |
|
64 | - * @since $VID:$ |
|
65 | - */ |
|
66 | - public function addManifestFile() |
|
67 | - { |
|
68 | - // if a manifest file has already been added for this domain, then just return that one |
|
69 | - if ($this->assets->has($this->domain->assetNamespace())) { |
|
70 | - return; |
|
71 | - } |
|
72 | - $asset = new ManifestFile($this->domain); |
|
73 | - $this->assets->add($asset, $this->domain->assetNamespace()); |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * @return ManifestFile[] |
|
79 | - * @since $VID:$ |
|
80 | - */ |
|
81 | - public function getManifestFile() |
|
82 | - { |
|
83 | - return $this->assets->getManifestFiles(); |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @param string $handle |
|
89 | - * @param string $source |
|
90 | - * @param array $dependencies |
|
91 | - * @param bool $load_in_footer |
|
92 | - * @return JavascriptAsset |
|
93 | - * @throws DuplicateCollectionIdentifierException |
|
94 | - * @throws InvalidDataTypeException |
|
95 | - * @throws InvalidEntityException |
|
96 | - * @since $VID:$ |
|
97 | - */ |
|
98 | - public function addJavascript( |
|
99 | - $handle, |
|
100 | - $source, |
|
101 | - array $dependencies = array(), |
|
102 | - $load_in_footer = true |
|
103 | - ) { |
|
104 | - $asset = new JavascriptAsset( |
|
105 | - $handle, |
|
106 | - $source, |
|
107 | - $dependencies, |
|
108 | - $load_in_footer, |
|
109 | - $this->domain |
|
110 | - ); |
|
111 | - $this->assets->add($asset, $handle); |
|
112 | - return $asset; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @return JavascriptAsset[] |
|
118 | - * @since $VID:$ |
|
119 | - */ |
|
120 | - public function getJavascriptAssets() |
|
121 | - { |
|
122 | - return $this->assets->getJavascriptAssets(); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @param string $handle |
|
128 | - * @param string $source |
|
129 | - * @param array $dependencies |
|
130 | - * @param string $media |
|
131 | - * @return StylesheetAsset |
|
132 | - * @throws DuplicateCollectionIdentifierException |
|
133 | - * @throws InvalidDataTypeException |
|
134 | - * @throws InvalidEntityException |
|
135 | - * @since $VID:$ |
|
136 | - */ |
|
137 | - public function addStylesheet( |
|
138 | - $handle, |
|
139 | - $source, |
|
140 | - array $dependencies = array(), |
|
141 | - $media = 'all' |
|
142 | - ) { |
|
143 | - $asset = new StylesheetAsset( |
|
144 | - $handle, |
|
145 | - $source, |
|
146 | - $dependencies, |
|
147 | - $this->domain, |
|
148 | - $media |
|
149 | - ); |
|
150 | - $this->assets->add($asset, $handle); |
|
151 | - return $asset; |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * @return StylesheetAsset[] |
|
157 | - * @since $VID:$ |
|
158 | - */ |
|
159 | - public function getStylesheetAssets() |
|
160 | - { |
|
161 | - return $this->assets->getStylesheetAssets(); |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * @param string $handle |
|
167 | - * @return bool |
|
168 | - * @since $VID:$ |
|
169 | - */ |
|
170 | - public function enqueueAsset($handle) |
|
171 | - { |
|
172 | - if ($this->assets->has($handle)) { |
|
173 | - $asset = $this->assets->get($handle); |
|
174 | - if ($asset->isRegistered()) { |
|
175 | - $asset->enqueueAsset(); |
|
176 | - return true; |
|
177 | - } |
|
178 | - } |
|
179 | - return false; |
|
180 | - } |
|
24 | + /** |
|
25 | + * @var AssetCollection $assets |
|
26 | + */ |
|
27 | + protected $assets; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var DomainInterface |
|
31 | + */ |
|
32 | + protected $domain; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var Registry $registry |
|
36 | + */ |
|
37 | + protected $registry; |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * AssetRegister constructor. |
|
42 | + * |
|
43 | + * @param DomainInterface $domain |
|
44 | + * @param AssetCollection $assets |
|
45 | + * @param Registry $registry |
|
46 | + */ |
|
47 | + public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry) |
|
48 | + { |
|
49 | + $this->domain = $domain; |
|
50 | + $this->assets = $assets; |
|
51 | + $this->registry = $registry; |
|
52 | + add_action('wp_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
53 | + add_action('admin_enqueue_scripts', array($this, 'addManifestFile'), 0); |
|
54 | + add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2); |
|
55 | + add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2); |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @return void |
|
61 | + * @throws DuplicateCollectionIdentifierException |
|
62 | + * @throws InvalidDataTypeException |
|
63 | + * @throws InvalidEntityException |
|
64 | + * @since $VID:$ |
|
65 | + */ |
|
66 | + public function addManifestFile() |
|
67 | + { |
|
68 | + // if a manifest file has already been added for this domain, then just return that one |
|
69 | + if ($this->assets->has($this->domain->assetNamespace())) { |
|
70 | + return; |
|
71 | + } |
|
72 | + $asset = new ManifestFile($this->domain); |
|
73 | + $this->assets->add($asset, $this->domain->assetNamespace()); |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * @return ManifestFile[] |
|
79 | + * @since $VID:$ |
|
80 | + */ |
|
81 | + public function getManifestFile() |
|
82 | + { |
|
83 | + return $this->assets->getManifestFiles(); |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @param string $handle |
|
89 | + * @param string $source |
|
90 | + * @param array $dependencies |
|
91 | + * @param bool $load_in_footer |
|
92 | + * @return JavascriptAsset |
|
93 | + * @throws DuplicateCollectionIdentifierException |
|
94 | + * @throws InvalidDataTypeException |
|
95 | + * @throws InvalidEntityException |
|
96 | + * @since $VID:$ |
|
97 | + */ |
|
98 | + public function addJavascript( |
|
99 | + $handle, |
|
100 | + $source, |
|
101 | + array $dependencies = array(), |
|
102 | + $load_in_footer = true |
|
103 | + ) { |
|
104 | + $asset = new JavascriptAsset( |
|
105 | + $handle, |
|
106 | + $source, |
|
107 | + $dependencies, |
|
108 | + $load_in_footer, |
|
109 | + $this->domain |
|
110 | + ); |
|
111 | + $this->assets->add($asset, $handle); |
|
112 | + return $asset; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @return JavascriptAsset[] |
|
118 | + * @since $VID:$ |
|
119 | + */ |
|
120 | + public function getJavascriptAssets() |
|
121 | + { |
|
122 | + return $this->assets->getJavascriptAssets(); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @param string $handle |
|
128 | + * @param string $source |
|
129 | + * @param array $dependencies |
|
130 | + * @param string $media |
|
131 | + * @return StylesheetAsset |
|
132 | + * @throws DuplicateCollectionIdentifierException |
|
133 | + * @throws InvalidDataTypeException |
|
134 | + * @throws InvalidEntityException |
|
135 | + * @since $VID:$ |
|
136 | + */ |
|
137 | + public function addStylesheet( |
|
138 | + $handle, |
|
139 | + $source, |
|
140 | + array $dependencies = array(), |
|
141 | + $media = 'all' |
|
142 | + ) { |
|
143 | + $asset = new StylesheetAsset( |
|
144 | + $handle, |
|
145 | + $source, |
|
146 | + $dependencies, |
|
147 | + $this->domain, |
|
148 | + $media |
|
149 | + ); |
|
150 | + $this->assets->add($asset, $handle); |
|
151 | + return $asset; |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * @return StylesheetAsset[] |
|
157 | + * @since $VID:$ |
|
158 | + */ |
|
159 | + public function getStylesheetAssets() |
|
160 | + { |
|
161 | + return $this->assets->getStylesheetAssets(); |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * @param string $handle |
|
167 | + * @return bool |
|
168 | + * @since $VID:$ |
|
169 | + */ |
|
170 | + public function enqueueAsset($handle) |
|
171 | + { |
|
172 | + if ($this->assets->has($handle)) { |
|
173 | + $asset = $this->assets->get($handle); |
|
174 | + if ($asset->isRegistered()) { |
|
175 | + $asset->enqueueAsset(); |
|
176 | + return true; |
|
177 | + } |
|
178 | + } |
|
179 | + return false; |
|
180 | + } |
|
181 | 181 | } |
@@ -22,1224 +22,1224 @@ |
||
22 | 22 | class EE_Register_Addon implements EEI_Plugin_API |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * possibly truncated version of the EE core version string |
|
27 | - * |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - protected static $_core_version = ''; |
|
25 | + /** |
|
26 | + * possibly truncated version of the EE core version string |
|
27 | + * |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + protected static $_core_version = ''; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Holds values for registered addons |
|
34 | - * |
|
35 | - * @var array |
|
36 | - */ |
|
37 | - protected static $_settings = array(); |
|
32 | + /** |
|
33 | + * Holds values for registered addons |
|
34 | + * |
|
35 | + * @var array |
|
36 | + */ |
|
37 | + protected static $_settings = array(); |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var array $_incompatible_addons keys are addon SLUGS |
|
41 | - * (first argument passed to EE_Register_Addon::register()), keys are |
|
42 | - * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004). |
|
43 | - * Generally this should be used sparingly, as we don't want to muddle up |
|
44 | - * EE core with knowledge of ALL the addons out there. |
|
45 | - * If you want NO versions of an addon to run with a certain version of core, |
|
46 | - * it's usually best to define the addon's "min_core_version" as part of its call |
|
47 | - * to EE_Register_Addon::register(), rather than using this array with a super high value for its |
|
48 | - * minimum plugin version. |
|
49 | - * @access protected |
|
50 | - */ |
|
51 | - protected static $_incompatible_addons = array( |
|
52 | - 'Multi_Event_Registration' => '2.0.11.rc.002', |
|
53 | - 'Promotions' => '1.0.0.rc.084', |
|
54 | - ); |
|
39 | + /** |
|
40 | + * @var array $_incompatible_addons keys are addon SLUGS |
|
41 | + * (first argument passed to EE_Register_Addon::register()), keys are |
|
42 | + * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004). |
|
43 | + * Generally this should be used sparingly, as we don't want to muddle up |
|
44 | + * EE core with knowledge of ALL the addons out there. |
|
45 | + * If you want NO versions of an addon to run with a certain version of core, |
|
46 | + * it's usually best to define the addon's "min_core_version" as part of its call |
|
47 | + * to EE_Register_Addon::register(), rather than using this array with a super high value for its |
|
48 | + * minimum plugin version. |
|
49 | + * @access protected |
|
50 | + */ |
|
51 | + protected static $_incompatible_addons = array( |
|
52 | + 'Multi_Event_Registration' => '2.0.11.rc.002', |
|
53 | + 'Promotions' => '1.0.0.rc.084', |
|
54 | + ); |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * We should always be comparing core to a version like '4.3.0.rc.000', |
|
59 | - * not just '4.3.0'. |
|
60 | - * So if the addon developer doesn't provide that full version string, |
|
61 | - * fill in the blanks for them |
|
62 | - * |
|
63 | - * @param string $min_core_version |
|
64 | - * @return string always like '4.3.0.rc.000' |
|
65 | - */ |
|
66 | - protected static function _effective_version($min_core_version) |
|
67 | - { |
|
68 | - // versions: 4 . 3 . 1 . p . 123 |
|
69 | - // offsets: 0 . 1 . 2 . 3 . 4 |
|
70 | - $version_parts = explode('.', $min_core_version); |
|
71 | - // check they specified the micro version (after 2nd period) |
|
72 | - if (! isset($version_parts[2])) { |
|
73 | - $version_parts[2] = '0'; |
|
74 | - } |
|
75 | - // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
|
76 | - // soon we can assume that's 'rc', but this current version is 'alpha' |
|
77 | - if (! isset($version_parts[3])) { |
|
78 | - $version_parts[3] = 'dev'; |
|
79 | - } |
|
80 | - if (! isset($version_parts[4])) { |
|
81 | - $version_parts[4] = '000'; |
|
82 | - } |
|
83 | - return implode('.', $version_parts); |
|
84 | - } |
|
57 | + /** |
|
58 | + * We should always be comparing core to a version like '4.3.0.rc.000', |
|
59 | + * not just '4.3.0'. |
|
60 | + * So if the addon developer doesn't provide that full version string, |
|
61 | + * fill in the blanks for them |
|
62 | + * |
|
63 | + * @param string $min_core_version |
|
64 | + * @return string always like '4.3.0.rc.000' |
|
65 | + */ |
|
66 | + protected static function _effective_version($min_core_version) |
|
67 | + { |
|
68 | + // versions: 4 . 3 . 1 . p . 123 |
|
69 | + // offsets: 0 . 1 . 2 . 3 . 4 |
|
70 | + $version_parts = explode('.', $min_core_version); |
|
71 | + // check they specified the micro version (after 2nd period) |
|
72 | + if (! isset($version_parts[2])) { |
|
73 | + $version_parts[2] = '0'; |
|
74 | + } |
|
75 | + // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
|
76 | + // soon we can assume that's 'rc', but this current version is 'alpha' |
|
77 | + if (! isset($version_parts[3])) { |
|
78 | + $version_parts[3] = 'dev'; |
|
79 | + } |
|
80 | + if (! isset($version_parts[4])) { |
|
81 | + $version_parts[4] = '000'; |
|
82 | + } |
|
83 | + return implode('.', $version_parts); |
|
84 | + } |
|
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * Returns whether or not the min core version requirement of the addon is met |
|
89 | - * |
|
90 | - * @param string $min_core_version the minimum core version required by the addon |
|
91 | - * @param string $actual_core_version the actual core version, optional |
|
92 | - * @return boolean |
|
93 | - */ |
|
94 | - public static function _meets_min_core_version_requirement( |
|
95 | - $min_core_version, |
|
96 | - $actual_core_version = EVENT_ESPRESSO_VERSION |
|
97 | - ) { |
|
98 | - return version_compare( |
|
99 | - self::_effective_version($actual_core_version), |
|
100 | - self::_effective_version($min_core_version), |
|
101 | - '>=' |
|
102 | - ); |
|
103 | - } |
|
87 | + /** |
|
88 | + * Returns whether or not the min core version requirement of the addon is met |
|
89 | + * |
|
90 | + * @param string $min_core_version the minimum core version required by the addon |
|
91 | + * @param string $actual_core_version the actual core version, optional |
|
92 | + * @return boolean |
|
93 | + */ |
|
94 | + public static function _meets_min_core_version_requirement( |
|
95 | + $min_core_version, |
|
96 | + $actual_core_version = EVENT_ESPRESSO_VERSION |
|
97 | + ) { |
|
98 | + return version_compare( |
|
99 | + self::_effective_version($actual_core_version), |
|
100 | + self::_effective_version($min_core_version), |
|
101 | + '>=' |
|
102 | + ); |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * Method for registering new EE_Addons. |
|
108 | - * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE |
|
109 | - * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it |
|
110 | - * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon |
|
111 | - * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after |
|
112 | - * 'activate_plugin', it registers the addon still, but its components are not registered |
|
113 | - * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do |
|
114 | - * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns |
|
115 | - * (so that we can detect that the addon has activated on the subsequent request) |
|
116 | - * |
|
117 | - * @since 4.3.0 |
|
118 | - * @param string $addon_name [Required] the EE_Addon's name. |
|
119 | - * @param array $setup_args { |
|
120 | - * An array of arguments provided for registering |
|
121 | - * the message type. |
|
122 | - * @type string $class_name the addon's main file name. |
|
123 | - * If left blank, generated from the addon name, |
|
124 | - * changes something like "calendar" to |
|
125 | - * "EE_Calendar" |
|
126 | - * @type string $min_core_version the minimum version of EE Core that the |
|
127 | - * addon will work with. eg "4.8.1.rc.084" |
|
128 | - * @type string $version the "software" version for the addon. eg |
|
129 | - * "1.0.0.p" for a first stable release, or |
|
130 | - * "1.0.0.rc.043" for a version in progress |
|
131 | - * @type string $main_file_path the full server path to the main file |
|
132 | - * loaded directly by WP |
|
133 | - * @type DomainInterface $domain child class of |
|
134 | - * EventEspresso\core\domain\DomainBase |
|
135 | - * @type string $domain_fqcn Fully Qualified Class Name |
|
136 | - * for the addon's Domain class |
|
137 | - * (see EventEspresso\core\domain\Domain) |
|
138 | - * @type string $admin_path full server path to the folder where the |
|
139 | - * addon\'s admin files reside |
|
140 | - * @type string $admin_callback a method to be called when the EE Admin is |
|
141 | - * first invoked, can be used for hooking into |
|
142 | - * any admin page |
|
143 | - * @type string $config_section the section name for this addon's |
|
144 | - * configuration settings section |
|
145 | - * (defaults to "addons") |
|
146 | - * @type string $config_class the class name for this addon's |
|
147 | - * configuration settings object |
|
148 | - * @type string $config_name the class name for this addon's |
|
149 | - * configuration settings object |
|
150 | - * @type string $autoloader_paths [Required] an array of class names and the full |
|
151 | - * server paths to those files. |
|
152 | - * @type string $autoloader_folders an array of "full server paths" for any |
|
153 | - * folders containing classes that might be |
|
154 | - * invoked by the addon |
|
155 | - * @type string $dms_paths [Required] an array of full server paths to |
|
156 | - * folders that contain data migration scripts. |
|
157 | - * The key should be the EE_Addon class name that |
|
158 | - * this set of data migration scripts belongs to. |
|
159 | - * If the EE_Addon class is namespaced, then this |
|
160 | - * needs to be the Fully Qualified Class Name |
|
161 | - * @type string $module_paths an array of full server paths to any |
|
162 | - * EED_Modules used by the addon |
|
163 | - * @type string $shortcode_paths an array of full server paths to folders |
|
164 | - * that contain EES_Shortcodes |
|
165 | - * @type string $widget_paths an array of full server paths to folders |
|
166 | - * that contain WP_Widgets |
|
167 | - * @type string $pue_options |
|
168 | - * @type array $capabilities an array indexed by role name |
|
169 | - * (i.e administrator,author ) and the values |
|
170 | - * are an array of caps to add to the role. |
|
171 | - * 'administrator' => array( |
|
172 | - * 'read_addon', |
|
173 | - * 'edit_addon', |
|
174 | - * etc. |
|
175 | - * ). |
|
176 | - * @type EE_Meta_Capability_Map[] $capability_maps an array of EE_Meta_Capability_Map object |
|
177 | - * for any addons that need to register any |
|
178 | - * special meta mapped capabilities. Should |
|
179 | - * be indexed where the key is the |
|
180 | - * EE_Meta_Capability_Map class name and the |
|
181 | - * values are the arguments sent to the class. |
|
182 | - * @type array $model_paths array of folders containing DB models |
|
183 | - * @see EE_Register_Model |
|
184 | - * @type array $class_paths array of folders containing DB classes |
|
185 | - * @see EE_Register_Model |
|
186 | - * @type array $model_extension_paths array of folders containing DB model |
|
187 | - * extensions |
|
188 | - * @see EE_Register_Model_Extension |
|
189 | - * @type array $class_extension_paths array of folders containing DB class |
|
190 | - * extensions |
|
191 | - * @see EE_Register_Model_Extension |
|
192 | - * @type array message_types { |
|
193 | - * An array of message types with the key as |
|
194 | - * the message type name and the values as |
|
195 | - * below: |
|
196 | - * @type string $mtfilename [Required] The filename of the message type |
|
197 | - * being registered. This will be the main |
|
198 | - * EE_{Message Type Name}_message_type class. |
|
199 | - * for example: |
|
200 | - * EE_Declined_Registration_message_type.class.php |
|
201 | - * @type array $autoloadpaths [Required] An array of paths to add to the |
|
202 | - * messages autoloader for the new message type. |
|
203 | - * @type array $messengers_to_activate_with An array of messengers that this message |
|
204 | - * type should activate with. Each value in |
|
205 | - * the |
|
206 | - * array |
|
207 | - * should match the name property of a |
|
208 | - * EE_messenger. Optional. |
|
209 | - * @type array $messengers_to_validate_with An array of messengers that this message |
|
210 | - * type should validate with. Each value in |
|
211 | - * the |
|
212 | - * array |
|
213 | - * should match the name property of an |
|
214 | - * EE_messenger. |
|
215 | - * Optional. |
|
216 | - * } |
|
217 | - * @type array $custom_post_types |
|
218 | - * @type array $custom_taxonomies |
|
219 | - * @type array $payment_method_paths each element is the folder containing the |
|
220 | - * EE_PMT_Base child class |
|
221 | - * (eg, |
|
222 | - * '/wp-content/plugins/my_plugin/Payomatic/' |
|
223 | - * which contains the files |
|
224 | - * EE_PMT_Payomatic.pm.php) |
|
225 | - * @type array $default_terms |
|
226 | - * @type array $namespace { |
|
227 | - * An array with two items for registering the |
|
228 | - * addon's namespace. (If, for some reason, you |
|
229 | - * require additional namespaces, |
|
230 | - * use |
|
231 | - * EventEspresso\core\Psr4Autoloader::addNamespace() |
|
232 | - * directly) |
|
233 | - * @see EventEspresso\core\Psr4Autoloader::addNamespace() |
|
234 | - * @type string $FQNS the namespace prefix |
|
235 | - * @type string $DIR a base directory for class files in the |
|
236 | - * namespace. |
|
237 | - * } |
|
238 | - * } |
|
239 | - * @type string $privacy_policies FQNSs (namespaces, each of which contains only |
|
240 | - * privacy policy classes) or FQCNs (specific |
|
241 | - * classnames of privacy policy classes) |
|
242 | - * @type string $personal_data_exporters FQNSs (namespaces, each of which contains only |
|
243 | - * privacy policy classes) or FQCNs (specific |
|
244 | - * classnames of privacy policy classes) |
|
245 | - * @type string $personal_data_erasers FQNSs (namespaces, each of which contains only |
|
246 | - * privacy policy classes) or FQCNs (specific |
|
247 | - * classnames of privacy policy classes) |
|
248 | - * @return void |
|
249 | - * @throws DomainException |
|
250 | - * @throws EE_Error |
|
251 | - * @throws InvalidArgumentException |
|
252 | - * @throws ReflectionException |
|
253 | - * @throws InvalidDataTypeException |
|
254 | - * @throws InvalidInterfaceException |
|
255 | - */ |
|
256 | - public static function register($addon_name = '', $setup_args = array()) |
|
257 | - { |
|
258 | - // required fields MUST be present, so let's make sure they are. |
|
259 | - EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
|
260 | - // get class name for addon |
|
261 | - $class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args); |
|
262 | - // setup $_settings array from incoming values. |
|
263 | - $addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args); |
|
264 | - // setup PUE |
|
265 | - EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
|
266 | - // does this addon work with this version of core or WordPress ? |
|
267 | - if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
268 | - return; |
|
269 | - } |
|
270 | - // register namespaces |
|
271 | - EE_Register_Addon::_setup_namespaces($addon_settings); |
|
272 | - // check if this is an activation request |
|
273 | - if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
274 | - // dont bother setting up the rest of the addon atm |
|
275 | - return; |
|
276 | - } |
|
277 | - // we need cars |
|
278 | - EE_Register_Addon::_setup_autoloaders($addon_name); |
|
279 | - // register new models and extensions |
|
280 | - EE_Register_Addon::_register_models_and_extensions($addon_name); |
|
281 | - // setup DMS |
|
282 | - EE_Register_Addon::_register_data_migration_scripts($addon_name); |
|
283 | - // if config_class is present let's register config. |
|
284 | - EE_Register_Addon::_register_config($addon_name); |
|
285 | - // register admin pages |
|
286 | - EE_Register_Addon::_register_admin_pages($addon_name); |
|
287 | - // add to list of modules to be registered |
|
288 | - EE_Register_Addon::_register_modules($addon_name); |
|
289 | - // add to list of shortcodes to be registered |
|
290 | - EE_Register_Addon::_register_shortcodes($addon_name); |
|
291 | - // add to list of widgets to be registered |
|
292 | - EE_Register_Addon::_register_widgets($addon_name); |
|
293 | - // register capability related stuff. |
|
294 | - EE_Register_Addon::_register_capabilities($addon_name); |
|
295 | - // any message type to register? |
|
296 | - EE_Register_Addon::_register_message_types($addon_name); |
|
297 | - // any custom post type/ custom capabilities or default terms to register |
|
298 | - EE_Register_Addon::_register_custom_post_types($addon_name); |
|
299 | - // and any payment methods |
|
300 | - EE_Register_Addon::_register_payment_methods($addon_name); |
|
301 | - // and privacy policy generators |
|
302 | - EE_Register_Addon::registerPrivacyPolicies($addon_name); |
|
303 | - // and privacy policy generators |
|
304 | - EE_Register_Addon::registerPersonalDataExporters($addon_name); |
|
305 | - // and privacy policy generators |
|
306 | - EE_Register_Addon::registerPersonalDataErasers($addon_name); |
|
307 | - // load and instantiate main addon class |
|
308 | - $addon = EE_Register_Addon::_load_and_init_addon_class($addon_name); |
|
309 | - // delay calling after_registration hook on each addon until after all add-ons have been registered. |
|
310 | - add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999); |
|
311 | - } |
|
106 | + /** |
|
107 | + * Method for registering new EE_Addons. |
|
108 | + * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE |
|
109 | + * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it |
|
110 | + * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon |
|
111 | + * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after |
|
112 | + * 'activate_plugin', it registers the addon still, but its components are not registered |
|
113 | + * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do |
|
114 | + * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns |
|
115 | + * (so that we can detect that the addon has activated on the subsequent request) |
|
116 | + * |
|
117 | + * @since 4.3.0 |
|
118 | + * @param string $addon_name [Required] the EE_Addon's name. |
|
119 | + * @param array $setup_args { |
|
120 | + * An array of arguments provided for registering |
|
121 | + * the message type. |
|
122 | + * @type string $class_name the addon's main file name. |
|
123 | + * If left blank, generated from the addon name, |
|
124 | + * changes something like "calendar" to |
|
125 | + * "EE_Calendar" |
|
126 | + * @type string $min_core_version the minimum version of EE Core that the |
|
127 | + * addon will work with. eg "4.8.1.rc.084" |
|
128 | + * @type string $version the "software" version for the addon. eg |
|
129 | + * "1.0.0.p" for a first stable release, or |
|
130 | + * "1.0.0.rc.043" for a version in progress |
|
131 | + * @type string $main_file_path the full server path to the main file |
|
132 | + * loaded directly by WP |
|
133 | + * @type DomainInterface $domain child class of |
|
134 | + * EventEspresso\core\domain\DomainBase |
|
135 | + * @type string $domain_fqcn Fully Qualified Class Name |
|
136 | + * for the addon's Domain class |
|
137 | + * (see EventEspresso\core\domain\Domain) |
|
138 | + * @type string $admin_path full server path to the folder where the |
|
139 | + * addon\'s admin files reside |
|
140 | + * @type string $admin_callback a method to be called when the EE Admin is |
|
141 | + * first invoked, can be used for hooking into |
|
142 | + * any admin page |
|
143 | + * @type string $config_section the section name for this addon's |
|
144 | + * configuration settings section |
|
145 | + * (defaults to "addons") |
|
146 | + * @type string $config_class the class name for this addon's |
|
147 | + * configuration settings object |
|
148 | + * @type string $config_name the class name for this addon's |
|
149 | + * configuration settings object |
|
150 | + * @type string $autoloader_paths [Required] an array of class names and the full |
|
151 | + * server paths to those files. |
|
152 | + * @type string $autoloader_folders an array of "full server paths" for any |
|
153 | + * folders containing classes that might be |
|
154 | + * invoked by the addon |
|
155 | + * @type string $dms_paths [Required] an array of full server paths to |
|
156 | + * folders that contain data migration scripts. |
|
157 | + * The key should be the EE_Addon class name that |
|
158 | + * this set of data migration scripts belongs to. |
|
159 | + * If the EE_Addon class is namespaced, then this |
|
160 | + * needs to be the Fully Qualified Class Name |
|
161 | + * @type string $module_paths an array of full server paths to any |
|
162 | + * EED_Modules used by the addon |
|
163 | + * @type string $shortcode_paths an array of full server paths to folders |
|
164 | + * that contain EES_Shortcodes |
|
165 | + * @type string $widget_paths an array of full server paths to folders |
|
166 | + * that contain WP_Widgets |
|
167 | + * @type string $pue_options |
|
168 | + * @type array $capabilities an array indexed by role name |
|
169 | + * (i.e administrator,author ) and the values |
|
170 | + * are an array of caps to add to the role. |
|
171 | + * 'administrator' => array( |
|
172 | + * 'read_addon', |
|
173 | + * 'edit_addon', |
|
174 | + * etc. |
|
175 | + * ). |
|
176 | + * @type EE_Meta_Capability_Map[] $capability_maps an array of EE_Meta_Capability_Map object |
|
177 | + * for any addons that need to register any |
|
178 | + * special meta mapped capabilities. Should |
|
179 | + * be indexed where the key is the |
|
180 | + * EE_Meta_Capability_Map class name and the |
|
181 | + * values are the arguments sent to the class. |
|
182 | + * @type array $model_paths array of folders containing DB models |
|
183 | + * @see EE_Register_Model |
|
184 | + * @type array $class_paths array of folders containing DB classes |
|
185 | + * @see EE_Register_Model |
|
186 | + * @type array $model_extension_paths array of folders containing DB model |
|
187 | + * extensions |
|
188 | + * @see EE_Register_Model_Extension |
|
189 | + * @type array $class_extension_paths array of folders containing DB class |
|
190 | + * extensions |
|
191 | + * @see EE_Register_Model_Extension |
|
192 | + * @type array message_types { |
|
193 | + * An array of message types with the key as |
|
194 | + * the message type name and the values as |
|
195 | + * below: |
|
196 | + * @type string $mtfilename [Required] The filename of the message type |
|
197 | + * being registered. This will be the main |
|
198 | + * EE_{Message Type Name}_message_type class. |
|
199 | + * for example: |
|
200 | + * EE_Declined_Registration_message_type.class.php |
|
201 | + * @type array $autoloadpaths [Required] An array of paths to add to the |
|
202 | + * messages autoloader for the new message type. |
|
203 | + * @type array $messengers_to_activate_with An array of messengers that this message |
|
204 | + * type should activate with. Each value in |
|
205 | + * the |
|
206 | + * array |
|
207 | + * should match the name property of a |
|
208 | + * EE_messenger. Optional. |
|
209 | + * @type array $messengers_to_validate_with An array of messengers that this message |
|
210 | + * type should validate with. Each value in |
|
211 | + * the |
|
212 | + * array |
|
213 | + * should match the name property of an |
|
214 | + * EE_messenger. |
|
215 | + * Optional. |
|
216 | + * } |
|
217 | + * @type array $custom_post_types |
|
218 | + * @type array $custom_taxonomies |
|
219 | + * @type array $payment_method_paths each element is the folder containing the |
|
220 | + * EE_PMT_Base child class |
|
221 | + * (eg, |
|
222 | + * '/wp-content/plugins/my_plugin/Payomatic/' |
|
223 | + * which contains the files |
|
224 | + * EE_PMT_Payomatic.pm.php) |
|
225 | + * @type array $default_terms |
|
226 | + * @type array $namespace { |
|
227 | + * An array with two items for registering the |
|
228 | + * addon's namespace. (If, for some reason, you |
|
229 | + * require additional namespaces, |
|
230 | + * use |
|
231 | + * EventEspresso\core\Psr4Autoloader::addNamespace() |
|
232 | + * directly) |
|
233 | + * @see EventEspresso\core\Psr4Autoloader::addNamespace() |
|
234 | + * @type string $FQNS the namespace prefix |
|
235 | + * @type string $DIR a base directory for class files in the |
|
236 | + * namespace. |
|
237 | + * } |
|
238 | + * } |
|
239 | + * @type string $privacy_policies FQNSs (namespaces, each of which contains only |
|
240 | + * privacy policy classes) or FQCNs (specific |
|
241 | + * classnames of privacy policy classes) |
|
242 | + * @type string $personal_data_exporters FQNSs (namespaces, each of which contains only |
|
243 | + * privacy policy classes) or FQCNs (specific |
|
244 | + * classnames of privacy policy classes) |
|
245 | + * @type string $personal_data_erasers FQNSs (namespaces, each of which contains only |
|
246 | + * privacy policy classes) or FQCNs (specific |
|
247 | + * classnames of privacy policy classes) |
|
248 | + * @return void |
|
249 | + * @throws DomainException |
|
250 | + * @throws EE_Error |
|
251 | + * @throws InvalidArgumentException |
|
252 | + * @throws ReflectionException |
|
253 | + * @throws InvalidDataTypeException |
|
254 | + * @throws InvalidInterfaceException |
|
255 | + */ |
|
256 | + public static function register($addon_name = '', $setup_args = array()) |
|
257 | + { |
|
258 | + // required fields MUST be present, so let's make sure they are. |
|
259 | + EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
|
260 | + // get class name for addon |
|
261 | + $class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args); |
|
262 | + // setup $_settings array from incoming values. |
|
263 | + $addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args); |
|
264 | + // setup PUE |
|
265 | + EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
|
266 | + // does this addon work with this version of core or WordPress ? |
|
267 | + if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
268 | + return; |
|
269 | + } |
|
270 | + // register namespaces |
|
271 | + EE_Register_Addon::_setup_namespaces($addon_settings); |
|
272 | + // check if this is an activation request |
|
273 | + if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
274 | + // dont bother setting up the rest of the addon atm |
|
275 | + return; |
|
276 | + } |
|
277 | + // we need cars |
|
278 | + EE_Register_Addon::_setup_autoloaders($addon_name); |
|
279 | + // register new models and extensions |
|
280 | + EE_Register_Addon::_register_models_and_extensions($addon_name); |
|
281 | + // setup DMS |
|
282 | + EE_Register_Addon::_register_data_migration_scripts($addon_name); |
|
283 | + // if config_class is present let's register config. |
|
284 | + EE_Register_Addon::_register_config($addon_name); |
|
285 | + // register admin pages |
|
286 | + EE_Register_Addon::_register_admin_pages($addon_name); |
|
287 | + // add to list of modules to be registered |
|
288 | + EE_Register_Addon::_register_modules($addon_name); |
|
289 | + // add to list of shortcodes to be registered |
|
290 | + EE_Register_Addon::_register_shortcodes($addon_name); |
|
291 | + // add to list of widgets to be registered |
|
292 | + EE_Register_Addon::_register_widgets($addon_name); |
|
293 | + // register capability related stuff. |
|
294 | + EE_Register_Addon::_register_capabilities($addon_name); |
|
295 | + // any message type to register? |
|
296 | + EE_Register_Addon::_register_message_types($addon_name); |
|
297 | + // any custom post type/ custom capabilities or default terms to register |
|
298 | + EE_Register_Addon::_register_custom_post_types($addon_name); |
|
299 | + // and any payment methods |
|
300 | + EE_Register_Addon::_register_payment_methods($addon_name); |
|
301 | + // and privacy policy generators |
|
302 | + EE_Register_Addon::registerPrivacyPolicies($addon_name); |
|
303 | + // and privacy policy generators |
|
304 | + EE_Register_Addon::registerPersonalDataExporters($addon_name); |
|
305 | + // and privacy policy generators |
|
306 | + EE_Register_Addon::registerPersonalDataErasers($addon_name); |
|
307 | + // load and instantiate main addon class |
|
308 | + $addon = EE_Register_Addon::_load_and_init_addon_class($addon_name); |
|
309 | + // delay calling after_registration hook on each addon until after all add-ons have been registered. |
|
310 | + add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999); |
|
311 | + } |
|
312 | 312 | |
313 | 313 | |
314 | - /** |
|
315 | - * @param string $addon_name |
|
316 | - * @param array $setup_args |
|
317 | - * @return void |
|
318 | - * @throws EE_Error |
|
319 | - */ |
|
320 | - private static function _verify_parameters($addon_name, array $setup_args) |
|
321 | - { |
|
322 | - // required fields MUST be present, so let's make sure they are. |
|
323 | - if (empty($addon_name) || ! is_array($setup_args)) { |
|
324 | - throw new EE_Error( |
|
325 | - __( |
|
326 | - 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', |
|
327 | - 'event_espresso' |
|
328 | - ) |
|
329 | - ); |
|
330 | - } |
|
331 | - if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
332 | - throw new EE_Error( |
|
333 | - sprintf( |
|
334 | - __( |
|
335 | - 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', |
|
336 | - 'event_espresso' |
|
337 | - ), |
|
338 | - implode(',', array_keys($setup_args)) |
|
339 | - ) |
|
340 | - ); |
|
341 | - } |
|
342 | - // check that addon has not already been registered with that name |
|
343 | - if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) { |
|
344 | - throw new EE_Error( |
|
345 | - sprintf( |
|
346 | - __( |
|
347 | - 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', |
|
348 | - 'event_espresso' |
|
349 | - ), |
|
350 | - $addon_name |
|
351 | - ) |
|
352 | - ); |
|
353 | - } |
|
354 | - } |
|
314 | + /** |
|
315 | + * @param string $addon_name |
|
316 | + * @param array $setup_args |
|
317 | + * @return void |
|
318 | + * @throws EE_Error |
|
319 | + */ |
|
320 | + private static function _verify_parameters($addon_name, array $setup_args) |
|
321 | + { |
|
322 | + // required fields MUST be present, so let's make sure they are. |
|
323 | + if (empty($addon_name) || ! is_array($setup_args)) { |
|
324 | + throw new EE_Error( |
|
325 | + __( |
|
326 | + 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', |
|
327 | + 'event_espresso' |
|
328 | + ) |
|
329 | + ); |
|
330 | + } |
|
331 | + if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
332 | + throw new EE_Error( |
|
333 | + sprintf( |
|
334 | + __( |
|
335 | + 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', |
|
336 | + 'event_espresso' |
|
337 | + ), |
|
338 | + implode(',', array_keys($setup_args)) |
|
339 | + ) |
|
340 | + ); |
|
341 | + } |
|
342 | + // check that addon has not already been registered with that name |
|
343 | + if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) { |
|
344 | + throw new EE_Error( |
|
345 | + sprintf( |
|
346 | + __( |
|
347 | + 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', |
|
348 | + 'event_espresso' |
|
349 | + ), |
|
350 | + $addon_name |
|
351 | + ) |
|
352 | + ); |
|
353 | + } |
|
354 | + } |
|
355 | 355 | |
356 | 356 | |
357 | - /** |
|
358 | - * @param string $addon_name |
|
359 | - * @param array $setup_args |
|
360 | - * @return string |
|
361 | - */ |
|
362 | - private static function _parse_class_name($addon_name, array $setup_args) |
|
363 | - { |
|
364 | - if (empty($setup_args['class_name'])) { |
|
365 | - // generate one by first separating name with spaces |
|
366 | - $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
367 | - // capitalize, then replace spaces with underscores |
|
368 | - $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
369 | - } else { |
|
370 | - $class_name = $setup_args['class_name']; |
|
371 | - } |
|
372 | - // check if classname is fully qualified or is a legacy classname already prefixed with 'EE_' |
|
373 | - return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0 |
|
374 | - ? $class_name |
|
375 | - : 'EE_' . $class_name; |
|
376 | - } |
|
357 | + /** |
|
358 | + * @param string $addon_name |
|
359 | + * @param array $setup_args |
|
360 | + * @return string |
|
361 | + */ |
|
362 | + private static function _parse_class_name($addon_name, array $setup_args) |
|
363 | + { |
|
364 | + if (empty($setup_args['class_name'])) { |
|
365 | + // generate one by first separating name with spaces |
|
366 | + $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
367 | + // capitalize, then replace spaces with underscores |
|
368 | + $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
369 | + } else { |
|
370 | + $class_name = $setup_args['class_name']; |
|
371 | + } |
|
372 | + // check if classname is fully qualified or is a legacy classname already prefixed with 'EE_' |
|
373 | + return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0 |
|
374 | + ? $class_name |
|
375 | + : 'EE_' . $class_name; |
|
376 | + } |
|
377 | 377 | |
378 | 378 | |
379 | - /** |
|
380 | - * @param string $class_name |
|
381 | - * @param array $setup_args |
|
382 | - * @return array |
|
383 | - */ |
|
384 | - private static function _get_addon_settings($class_name, array $setup_args) |
|
385 | - { |
|
386 | - // setup $_settings array from incoming values. |
|
387 | - $addon_settings = array( |
|
388 | - // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
|
389 | - 'class_name' => $class_name, |
|
390 | - // the addon slug for use in URLs, etc |
|
391 | - 'plugin_slug' => isset($setup_args['plugin_slug']) |
|
392 | - ? (string) $setup_args['plugin_slug'] |
|
393 | - : '', |
|
394 | - // page slug to be used when generating the "Settings" link on the WP plugin page |
|
395 | - 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
|
396 | - ? (string) $setup_args['plugin_action_slug'] |
|
397 | - : '', |
|
398 | - // the "software" version for the addon |
|
399 | - 'version' => isset($setup_args['version']) |
|
400 | - ? (string) $setup_args['version'] |
|
401 | - : '', |
|
402 | - // the minimum version of EE Core that the addon will work with |
|
403 | - 'min_core_version' => isset($setup_args['min_core_version']) |
|
404 | - ? (string) $setup_args['min_core_version'] |
|
405 | - : '', |
|
406 | - // the minimum version of WordPress that the addon will work with |
|
407 | - 'min_wp_version' => isset($setup_args['min_wp_version']) |
|
408 | - ? (string) $setup_args['min_wp_version'] |
|
409 | - : EE_MIN_WP_VER_REQUIRED, |
|
410 | - // full server path to main file (file loaded directly by WP) |
|
411 | - 'main_file_path' => isset($setup_args['main_file_path']) |
|
412 | - ? (string) $setup_args['main_file_path'] |
|
413 | - : '', |
|
414 | - // instance of \EventEspresso\core\domain\DomainInterface |
|
415 | - 'domain' => isset($setup_args['domain']) && $setup_args['domain'] instanceof DomainInterface |
|
416 | - ? $setup_args['domain'] |
|
417 | - : null, |
|
418 | - // Fully Qualified Class Name for the addon's Domain class |
|
419 | - 'domain_fqcn' => isset($setup_args['domain_fqcn']) |
|
420 | - ? (string) $setup_args['domain_fqcn'] |
|
421 | - : '', |
|
422 | - // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
|
423 | - 'admin_path' => isset($setup_args['admin_path']) |
|
424 | - ? (string) $setup_args['admin_path'] : '', |
|
425 | - // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
|
426 | - 'admin_callback' => isset($setup_args['admin_callback']) |
|
427 | - ? (string) $setup_args['admin_callback'] |
|
428 | - : '', |
|
429 | - // the section name for this addon's configuration settings section (defaults to "addons") |
|
430 | - 'config_section' => isset($setup_args['config_section']) |
|
431 | - ? (string) $setup_args['config_section'] |
|
432 | - : 'addons', |
|
433 | - // the class name for this addon's configuration settings object |
|
434 | - 'config_class' => isset($setup_args['config_class']) |
|
435 | - ? (string) $setup_args['config_class'] : '', |
|
436 | - // the name given to the config for this addons' configuration settings object (optional) |
|
437 | - 'config_name' => isset($setup_args['config_name']) |
|
438 | - ? (string) $setup_args['config_name'] : '', |
|
439 | - // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
|
440 | - 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
|
441 | - ? (array) $setup_args['autoloader_paths'] |
|
442 | - : array(), |
|
443 | - // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
|
444 | - 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
|
445 | - ? (array) $setup_args['autoloader_folders'] |
|
446 | - : array(), |
|
447 | - // array of full server paths to any EE_DMS data migration scripts used by the addon. |
|
448 | - // The key should be the EE_Addon class name that this set of data migration scripts belongs to. |
|
449 | - // If the EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name |
|
450 | - 'dms_paths' => isset($setup_args['dms_paths']) |
|
451 | - ? (array) $setup_args['dms_paths'] |
|
452 | - : array(), |
|
453 | - // array of full server paths to any EED_Modules used by the addon |
|
454 | - 'module_paths' => isset($setup_args['module_paths']) |
|
455 | - ? (array) $setup_args['module_paths'] |
|
456 | - : array(), |
|
457 | - // array of full server paths to any EES_Shortcodes used by the addon |
|
458 | - 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
459 | - ? (array) $setup_args['shortcode_paths'] |
|
460 | - : array(), |
|
461 | - 'shortcode_fqcns' => isset($setup_args['shortcode_fqcns']) |
|
462 | - ? (array) $setup_args['shortcode_fqcns'] |
|
463 | - : array(), |
|
464 | - // array of full server paths to any WP_Widgets used by the addon |
|
465 | - 'widget_paths' => isset($setup_args['widget_paths']) |
|
466 | - ? (array) $setup_args['widget_paths'] |
|
467 | - : array(), |
|
468 | - // array of PUE options used by the addon |
|
469 | - 'pue_options' => isset($setup_args['pue_options']) |
|
470 | - ? (array) $setup_args['pue_options'] |
|
471 | - : array(), |
|
472 | - 'message_types' => isset($setup_args['message_types']) |
|
473 | - ? (array) $setup_args['message_types'] |
|
474 | - : array(), |
|
475 | - 'capabilities' => isset($setup_args['capabilities']) |
|
476 | - ? (array) $setup_args['capabilities'] |
|
477 | - : array(), |
|
478 | - 'capability_maps' => isset($setup_args['capability_maps']) |
|
479 | - ? (array) $setup_args['capability_maps'] |
|
480 | - : array(), |
|
481 | - 'model_paths' => isset($setup_args['model_paths']) |
|
482 | - ? (array) $setup_args['model_paths'] |
|
483 | - : array(), |
|
484 | - 'class_paths' => isset($setup_args['class_paths']) |
|
485 | - ? (array) $setup_args['class_paths'] |
|
486 | - : array(), |
|
487 | - 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
|
488 | - ? (array) $setup_args['model_extension_paths'] |
|
489 | - : array(), |
|
490 | - 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
|
491 | - ? (array) $setup_args['class_extension_paths'] |
|
492 | - : array(), |
|
493 | - 'custom_post_types' => isset($setup_args['custom_post_types']) |
|
494 | - ? (array) $setup_args['custom_post_types'] |
|
495 | - : array(), |
|
496 | - 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
|
497 | - ? (array) $setup_args['custom_taxonomies'] |
|
498 | - : array(), |
|
499 | - 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
500 | - ? (array) $setup_args['payment_method_paths'] |
|
501 | - : array(), |
|
502 | - 'default_terms' => isset($setup_args['default_terms']) |
|
503 | - ? (array) $setup_args['default_terms'] |
|
504 | - : array(), |
|
505 | - // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
506 | - // that can be used for adding upgrading/marketing info |
|
507 | - 'plugins_page_row' => isset($setup_args['plugins_page_row']) |
|
508 | - ? $setup_args['plugins_page_row'] |
|
509 | - : '', |
|
510 | - 'namespace' => isset( |
|
511 | - $setup_args['namespace']['FQNS'], |
|
512 | - $setup_args['namespace']['DIR'] |
|
513 | - ) |
|
514 | - ? (array) $setup_args['namespace'] |
|
515 | - : array(), |
|
516 | - 'privacy_policies' => isset($setup_args['privacy_policies']) |
|
517 | - ? (array) $setup_args['privacy_policies'] |
|
518 | - : '', |
|
519 | - ); |
|
520 | - // if plugin_action_slug is NOT set, but an admin page path IS set, |
|
521 | - // then let's just use the plugin_slug since that will be used for linking to the admin page |
|
522 | - $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) |
|
523 | - && ! empty($addon_settings['admin_path']) |
|
524 | - ? $addon_settings['plugin_slug'] |
|
525 | - : $addon_settings['plugin_action_slug']; |
|
526 | - // full server path to main file (file loaded directly by WP) |
|
527 | - $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
528 | - return $addon_settings; |
|
529 | - } |
|
379 | + /** |
|
380 | + * @param string $class_name |
|
381 | + * @param array $setup_args |
|
382 | + * @return array |
|
383 | + */ |
|
384 | + private static function _get_addon_settings($class_name, array $setup_args) |
|
385 | + { |
|
386 | + // setup $_settings array from incoming values. |
|
387 | + $addon_settings = array( |
|
388 | + // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
|
389 | + 'class_name' => $class_name, |
|
390 | + // the addon slug for use in URLs, etc |
|
391 | + 'plugin_slug' => isset($setup_args['plugin_slug']) |
|
392 | + ? (string) $setup_args['plugin_slug'] |
|
393 | + : '', |
|
394 | + // page slug to be used when generating the "Settings" link on the WP plugin page |
|
395 | + 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
|
396 | + ? (string) $setup_args['plugin_action_slug'] |
|
397 | + : '', |
|
398 | + // the "software" version for the addon |
|
399 | + 'version' => isset($setup_args['version']) |
|
400 | + ? (string) $setup_args['version'] |
|
401 | + : '', |
|
402 | + // the minimum version of EE Core that the addon will work with |
|
403 | + 'min_core_version' => isset($setup_args['min_core_version']) |
|
404 | + ? (string) $setup_args['min_core_version'] |
|
405 | + : '', |
|
406 | + // the minimum version of WordPress that the addon will work with |
|
407 | + 'min_wp_version' => isset($setup_args['min_wp_version']) |
|
408 | + ? (string) $setup_args['min_wp_version'] |
|
409 | + : EE_MIN_WP_VER_REQUIRED, |
|
410 | + // full server path to main file (file loaded directly by WP) |
|
411 | + 'main_file_path' => isset($setup_args['main_file_path']) |
|
412 | + ? (string) $setup_args['main_file_path'] |
|
413 | + : '', |
|
414 | + // instance of \EventEspresso\core\domain\DomainInterface |
|
415 | + 'domain' => isset($setup_args['domain']) && $setup_args['domain'] instanceof DomainInterface |
|
416 | + ? $setup_args['domain'] |
|
417 | + : null, |
|
418 | + // Fully Qualified Class Name for the addon's Domain class |
|
419 | + 'domain_fqcn' => isset($setup_args['domain_fqcn']) |
|
420 | + ? (string) $setup_args['domain_fqcn'] |
|
421 | + : '', |
|
422 | + // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
|
423 | + 'admin_path' => isset($setup_args['admin_path']) |
|
424 | + ? (string) $setup_args['admin_path'] : '', |
|
425 | + // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
|
426 | + 'admin_callback' => isset($setup_args['admin_callback']) |
|
427 | + ? (string) $setup_args['admin_callback'] |
|
428 | + : '', |
|
429 | + // the section name for this addon's configuration settings section (defaults to "addons") |
|
430 | + 'config_section' => isset($setup_args['config_section']) |
|
431 | + ? (string) $setup_args['config_section'] |
|
432 | + : 'addons', |
|
433 | + // the class name for this addon's configuration settings object |
|
434 | + 'config_class' => isset($setup_args['config_class']) |
|
435 | + ? (string) $setup_args['config_class'] : '', |
|
436 | + // the name given to the config for this addons' configuration settings object (optional) |
|
437 | + 'config_name' => isset($setup_args['config_name']) |
|
438 | + ? (string) $setup_args['config_name'] : '', |
|
439 | + // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
|
440 | + 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
|
441 | + ? (array) $setup_args['autoloader_paths'] |
|
442 | + : array(), |
|
443 | + // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
|
444 | + 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
|
445 | + ? (array) $setup_args['autoloader_folders'] |
|
446 | + : array(), |
|
447 | + // array of full server paths to any EE_DMS data migration scripts used by the addon. |
|
448 | + // The key should be the EE_Addon class name that this set of data migration scripts belongs to. |
|
449 | + // If the EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name |
|
450 | + 'dms_paths' => isset($setup_args['dms_paths']) |
|
451 | + ? (array) $setup_args['dms_paths'] |
|
452 | + : array(), |
|
453 | + // array of full server paths to any EED_Modules used by the addon |
|
454 | + 'module_paths' => isset($setup_args['module_paths']) |
|
455 | + ? (array) $setup_args['module_paths'] |
|
456 | + : array(), |
|
457 | + // array of full server paths to any EES_Shortcodes used by the addon |
|
458 | + 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
459 | + ? (array) $setup_args['shortcode_paths'] |
|
460 | + : array(), |
|
461 | + 'shortcode_fqcns' => isset($setup_args['shortcode_fqcns']) |
|
462 | + ? (array) $setup_args['shortcode_fqcns'] |
|
463 | + : array(), |
|
464 | + // array of full server paths to any WP_Widgets used by the addon |
|
465 | + 'widget_paths' => isset($setup_args['widget_paths']) |
|
466 | + ? (array) $setup_args['widget_paths'] |
|
467 | + : array(), |
|
468 | + // array of PUE options used by the addon |
|
469 | + 'pue_options' => isset($setup_args['pue_options']) |
|
470 | + ? (array) $setup_args['pue_options'] |
|
471 | + : array(), |
|
472 | + 'message_types' => isset($setup_args['message_types']) |
|
473 | + ? (array) $setup_args['message_types'] |
|
474 | + : array(), |
|
475 | + 'capabilities' => isset($setup_args['capabilities']) |
|
476 | + ? (array) $setup_args['capabilities'] |
|
477 | + : array(), |
|
478 | + 'capability_maps' => isset($setup_args['capability_maps']) |
|
479 | + ? (array) $setup_args['capability_maps'] |
|
480 | + : array(), |
|
481 | + 'model_paths' => isset($setup_args['model_paths']) |
|
482 | + ? (array) $setup_args['model_paths'] |
|
483 | + : array(), |
|
484 | + 'class_paths' => isset($setup_args['class_paths']) |
|
485 | + ? (array) $setup_args['class_paths'] |
|
486 | + : array(), |
|
487 | + 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
|
488 | + ? (array) $setup_args['model_extension_paths'] |
|
489 | + : array(), |
|
490 | + 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
|
491 | + ? (array) $setup_args['class_extension_paths'] |
|
492 | + : array(), |
|
493 | + 'custom_post_types' => isset($setup_args['custom_post_types']) |
|
494 | + ? (array) $setup_args['custom_post_types'] |
|
495 | + : array(), |
|
496 | + 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
|
497 | + ? (array) $setup_args['custom_taxonomies'] |
|
498 | + : array(), |
|
499 | + 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
500 | + ? (array) $setup_args['payment_method_paths'] |
|
501 | + : array(), |
|
502 | + 'default_terms' => isset($setup_args['default_terms']) |
|
503 | + ? (array) $setup_args['default_terms'] |
|
504 | + : array(), |
|
505 | + // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
506 | + // that can be used for adding upgrading/marketing info |
|
507 | + 'plugins_page_row' => isset($setup_args['plugins_page_row']) |
|
508 | + ? $setup_args['plugins_page_row'] |
|
509 | + : '', |
|
510 | + 'namespace' => isset( |
|
511 | + $setup_args['namespace']['FQNS'], |
|
512 | + $setup_args['namespace']['DIR'] |
|
513 | + ) |
|
514 | + ? (array) $setup_args['namespace'] |
|
515 | + : array(), |
|
516 | + 'privacy_policies' => isset($setup_args['privacy_policies']) |
|
517 | + ? (array) $setup_args['privacy_policies'] |
|
518 | + : '', |
|
519 | + ); |
|
520 | + // if plugin_action_slug is NOT set, but an admin page path IS set, |
|
521 | + // then let's just use the plugin_slug since that will be used for linking to the admin page |
|
522 | + $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) |
|
523 | + && ! empty($addon_settings['admin_path']) |
|
524 | + ? $addon_settings['plugin_slug'] |
|
525 | + : $addon_settings['plugin_action_slug']; |
|
526 | + // full server path to main file (file loaded directly by WP) |
|
527 | + $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
528 | + return $addon_settings; |
|
529 | + } |
|
530 | 530 | |
531 | 531 | |
532 | - /** |
|
533 | - * @param string $addon_name |
|
534 | - * @param array $addon_settings |
|
535 | - * @return boolean |
|
536 | - */ |
|
537 | - private static function _addon_is_compatible($addon_name, array $addon_settings) |
|
538 | - { |
|
539 | - global $wp_version; |
|
540 | - $incompatibility_message = ''; |
|
541 | - // check whether this addon version is compatible with EE core |
|
542 | - if (isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ]) |
|
543 | - && ! self::_meets_min_core_version_requirement( |
|
544 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
545 | - $addon_settings['version'] |
|
546 | - ) |
|
547 | - ) { |
|
548 | - $incompatibility_message = sprintf( |
|
549 | - __( |
|
550 | - '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.', |
|
551 | - 'event_espresso' |
|
552 | - ), |
|
553 | - $addon_name, |
|
554 | - '<br />', |
|
555 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
556 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
557 | - '</span><br />' |
|
558 | - ); |
|
559 | - } elseif (! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
560 | - ) { |
|
561 | - $incompatibility_message = sprintf( |
|
562 | - __( |
|
563 | - '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".', |
|
564 | - 'event_espresso' |
|
565 | - ), |
|
566 | - $addon_name, |
|
567 | - self::_effective_version($addon_settings['min_core_version']), |
|
568 | - self::_effective_version(espresso_version()), |
|
569 | - '<br />', |
|
570 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
571 | - '</span><br />' |
|
572 | - ); |
|
573 | - } elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
574 | - $incompatibility_message = sprintf( |
|
575 | - __( |
|
576 | - '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
|
577 | - 'event_espresso' |
|
578 | - ), |
|
579 | - $addon_name, |
|
580 | - $addon_settings['min_wp_version'], |
|
581 | - '<br />', |
|
582 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
583 | - '</span><br />' |
|
584 | - ); |
|
585 | - } |
|
586 | - if (! empty($incompatibility_message)) { |
|
587 | - // remove 'activate' from the REQUEST |
|
588 | - // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
|
589 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
590 | - if (current_user_can('activate_plugins')) { |
|
591 | - // show an error message indicating the plugin didn't activate properly |
|
592 | - EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
593 | - } |
|
594 | - // BAIL FROM THE ADDON REGISTRATION PROCESS |
|
595 | - return false; |
|
596 | - } |
|
597 | - // addon IS compatible |
|
598 | - return true; |
|
599 | - } |
|
532 | + /** |
|
533 | + * @param string $addon_name |
|
534 | + * @param array $addon_settings |
|
535 | + * @return boolean |
|
536 | + */ |
|
537 | + private static function _addon_is_compatible($addon_name, array $addon_settings) |
|
538 | + { |
|
539 | + global $wp_version; |
|
540 | + $incompatibility_message = ''; |
|
541 | + // check whether this addon version is compatible with EE core |
|
542 | + if (isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ]) |
|
543 | + && ! self::_meets_min_core_version_requirement( |
|
544 | + EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
545 | + $addon_settings['version'] |
|
546 | + ) |
|
547 | + ) { |
|
548 | + $incompatibility_message = sprintf( |
|
549 | + __( |
|
550 | + '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.', |
|
551 | + 'event_espresso' |
|
552 | + ), |
|
553 | + $addon_name, |
|
554 | + '<br />', |
|
555 | + EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
556 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
557 | + '</span><br />' |
|
558 | + ); |
|
559 | + } elseif (! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
560 | + ) { |
|
561 | + $incompatibility_message = sprintf( |
|
562 | + __( |
|
563 | + '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".', |
|
564 | + 'event_espresso' |
|
565 | + ), |
|
566 | + $addon_name, |
|
567 | + self::_effective_version($addon_settings['min_core_version']), |
|
568 | + self::_effective_version(espresso_version()), |
|
569 | + '<br />', |
|
570 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
571 | + '</span><br />' |
|
572 | + ); |
|
573 | + } elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
574 | + $incompatibility_message = sprintf( |
|
575 | + __( |
|
576 | + '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
|
577 | + 'event_espresso' |
|
578 | + ), |
|
579 | + $addon_name, |
|
580 | + $addon_settings['min_wp_version'], |
|
581 | + '<br />', |
|
582 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
583 | + '</span><br />' |
|
584 | + ); |
|
585 | + } |
|
586 | + if (! empty($incompatibility_message)) { |
|
587 | + // remove 'activate' from the REQUEST |
|
588 | + // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
|
589 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
590 | + if (current_user_can('activate_plugins')) { |
|
591 | + // show an error message indicating the plugin didn't activate properly |
|
592 | + EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
593 | + } |
|
594 | + // BAIL FROM THE ADDON REGISTRATION PROCESS |
|
595 | + return false; |
|
596 | + } |
|
597 | + // addon IS compatible |
|
598 | + return true; |
|
599 | + } |
|
600 | 600 | |
601 | 601 | |
602 | - /** |
|
603 | - * if plugin update engine is being used for auto-updates, |
|
604 | - * then let's set that up now before going any further so that ALL addons can be updated |
|
605 | - * (not needed if PUE is not being used) |
|
606 | - * |
|
607 | - * @param string $addon_name |
|
608 | - * @param string $class_name |
|
609 | - * @param array $setup_args |
|
610 | - * @return void |
|
611 | - */ |
|
612 | - private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
|
613 | - { |
|
614 | - if (! empty($setup_args['pue_options'])) { |
|
615 | - self::$_settings[ $addon_name ]['pue_options'] = array( |
|
616 | - 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
|
617 | - ? (string) $setup_args['pue_options']['pue_plugin_slug'] |
|
618 | - : 'espresso_' . strtolower($class_name), |
|
619 | - 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
|
620 | - ? (string) $setup_args['pue_options']['plugin_basename'] |
|
621 | - : plugin_basename($setup_args['main_file_path']), |
|
622 | - 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
|
623 | - ? (string) $setup_args['pue_options']['checkPeriod'] |
|
624 | - : '24', |
|
625 | - 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
|
626 | - ? (string) $setup_args['pue_options']['use_wp_update'] |
|
627 | - : false, |
|
628 | - ); |
|
629 | - add_action( |
|
630 | - 'AHEE__EE_System__brew_espresso__after_pue_init', |
|
631 | - array('EE_Register_Addon', 'load_pue_update') |
|
632 | - ); |
|
633 | - } |
|
634 | - } |
|
602 | + /** |
|
603 | + * if plugin update engine is being used for auto-updates, |
|
604 | + * then let's set that up now before going any further so that ALL addons can be updated |
|
605 | + * (not needed if PUE is not being used) |
|
606 | + * |
|
607 | + * @param string $addon_name |
|
608 | + * @param string $class_name |
|
609 | + * @param array $setup_args |
|
610 | + * @return void |
|
611 | + */ |
|
612 | + private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
|
613 | + { |
|
614 | + if (! empty($setup_args['pue_options'])) { |
|
615 | + self::$_settings[ $addon_name ]['pue_options'] = array( |
|
616 | + 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
|
617 | + ? (string) $setup_args['pue_options']['pue_plugin_slug'] |
|
618 | + : 'espresso_' . strtolower($class_name), |
|
619 | + 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
|
620 | + ? (string) $setup_args['pue_options']['plugin_basename'] |
|
621 | + : plugin_basename($setup_args['main_file_path']), |
|
622 | + 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
|
623 | + ? (string) $setup_args['pue_options']['checkPeriod'] |
|
624 | + : '24', |
|
625 | + 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
|
626 | + ? (string) $setup_args['pue_options']['use_wp_update'] |
|
627 | + : false, |
|
628 | + ); |
|
629 | + add_action( |
|
630 | + 'AHEE__EE_System__brew_espresso__after_pue_init', |
|
631 | + array('EE_Register_Addon', 'load_pue_update') |
|
632 | + ); |
|
633 | + } |
|
634 | + } |
|
635 | 635 | |
636 | 636 | |
637 | - /** |
|
638 | - * register namespaces right away before any other files or classes get loaded, but AFTER the version checks |
|
639 | - * |
|
640 | - * @param array $addon_settings |
|
641 | - * @return void |
|
642 | - */ |
|
643 | - private static function _setup_namespaces(array $addon_settings) |
|
644 | - { |
|
645 | - // |
|
646 | - if (isset( |
|
647 | - $addon_settings['namespace']['FQNS'], |
|
648 | - $addon_settings['namespace']['DIR'] |
|
649 | - )) { |
|
650 | - EE_Psr4AutoloaderInit::psr4_loader()->addNamespace( |
|
651 | - $addon_settings['namespace']['FQNS'], |
|
652 | - $addon_settings['namespace']['DIR'] |
|
653 | - ); |
|
654 | - } |
|
655 | - } |
|
637 | + /** |
|
638 | + * register namespaces right away before any other files or classes get loaded, but AFTER the version checks |
|
639 | + * |
|
640 | + * @param array $addon_settings |
|
641 | + * @return void |
|
642 | + */ |
|
643 | + private static function _setup_namespaces(array $addon_settings) |
|
644 | + { |
|
645 | + // |
|
646 | + if (isset( |
|
647 | + $addon_settings['namespace']['FQNS'], |
|
648 | + $addon_settings['namespace']['DIR'] |
|
649 | + )) { |
|
650 | + EE_Psr4AutoloaderInit::psr4_loader()->addNamespace( |
|
651 | + $addon_settings['namespace']['FQNS'], |
|
652 | + $addon_settings['namespace']['DIR'] |
|
653 | + ); |
|
654 | + } |
|
655 | + } |
|
656 | 656 | |
657 | 657 | |
658 | - /** |
|
659 | - * @param string $addon_name |
|
660 | - * @param array $addon_settings |
|
661 | - * @return bool |
|
662 | - * @throws EE_Error |
|
663 | - * @throws InvalidArgumentException |
|
664 | - * @throws ReflectionException |
|
665 | - * @throws InvalidDataTypeException |
|
666 | - * @throws InvalidInterfaceException |
|
667 | - */ |
|
668 | - private static function _addon_activation($addon_name, array $addon_settings) |
|
669 | - { |
|
670 | - // this is an activation request |
|
671 | - if (did_action( |
|
672 | - 'activate_plugin' |
|
673 | - )) {// to find if THIS is the addon that was activated, just check if we have already registered it or not |
|
674 | - // (as the newly-activated addon wasn't around the first time addons were registered). |
|
675 | - // Note: the presence of pue_options in the addon registration options will initialize the $_settings |
|
676 | - // property for the add-on, but the add-on is only partially initialized. Hence, the additional check. |
|
677 | - if (! isset(self::$_settings[ $addon_name ]) |
|
678 | - || (isset(self::$_settings[ $addon_name ]) |
|
679 | - && ! isset(self::$_settings[ $addon_name ]['class_name']) |
|
680 | - ) |
|
681 | - ) { |
|
682 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
683 | - $addon = self::_load_and_init_addon_class($addon_name); |
|
684 | - $addon->set_activation_indicator_option(); |
|
685 | - // dont bother setting up the rest of the addon. |
|
686 | - // we know it was just activated and the request will end soon |
|
687 | - } |
|
688 | - return true; |
|
689 | - } |
|
690 | - // make sure this was called in the right place! |
|
691 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
692 | - || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
693 | - ) { |
|
694 | - EE_Error::doing_it_wrong( |
|
695 | - __METHOD__, |
|
696 | - sprintf( |
|
697 | - __( |
|
698 | - 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', |
|
699 | - 'event_espresso' |
|
700 | - ), |
|
701 | - $addon_name |
|
702 | - ), |
|
703 | - '4.3.0' |
|
704 | - ); |
|
705 | - } |
|
706 | - // make sure addon settings are set correctly without overwriting anything existing |
|
707 | - if (isset(self::$_settings[ $addon_name ])) { |
|
708 | - self::$_settings[ $addon_name ] += $addon_settings; |
|
709 | - } else { |
|
710 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
711 | - } |
|
712 | - return false; |
|
713 | - } |
|
658 | + /** |
|
659 | + * @param string $addon_name |
|
660 | + * @param array $addon_settings |
|
661 | + * @return bool |
|
662 | + * @throws EE_Error |
|
663 | + * @throws InvalidArgumentException |
|
664 | + * @throws ReflectionException |
|
665 | + * @throws InvalidDataTypeException |
|
666 | + * @throws InvalidInterfaceException |
|
667 | + */ |
|
668 | + private static function _addon_activation($addon_name, array $addon_settings) |
|
669 | + { |
|
670 | + // this is an activation request |
|
671 | + if (did_action( |
|
672 | + 'activate_plugin' |
|
673 | + )) {// to find if THIS is the addon that was activated, just check if we have already registered it or not |
|
674 | + // (as the newly-activated addon wasn't around the first time addons were registered). |
|
675 | + // Note: the presence of pue_options in the addon registration options will initialize the $_settings |
|
676 | + // property for the add-on, but the add-on is only partially initialized. Hence, the additional check. |
|
677 | + if (! isset(self::$_settings[ $addon_name ]) |
|
678 | + || (isset(self::$_settings[ $addon_name ]) |
|
679 | + && ! isset(self::$_settings[ $addon_name ]['class_name']) |
|
680 | + ) |
|
681 | + ) { |
|
682 | + self::$_settings[ $addon_name ] = $addon_settings; |
|
683 | + $addon = self::_load_and_init_addon_class($addon_name); |
|
684 | + $addon->set_activation_indicator_option(); |
|
685 | + // dont bother setting up the rest of the addon. |
|
686 | + // we know it was just activated and the request will end soon |
|
687 | + } |
|
688 | + return true; |
|
689 | + } |
|
690 | + // make sure this was called in the right place! |
|
691 | + if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
692 | + || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
693 | + ) { |
|
694 | + EE_Error::doing_it_wrong( |
|
695 | + __METHOD__, |
|
696 | + sprintf( |
|
697 | + __( |
|
698 | + 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', |
|
699 | + 'event_espresso' |
|
700 | + ), |
|
701 | + $addon_name |
|
702 | + ), |
|
703 | + '4.3.0' |
|
704 | + ); |
|
705 | + } |
|
706 | + // make sure addon settings are set correctly without overwriting anything existing |
|
707 | + if (isset(self::$_settings[ $addon_name ])) { |
|
708 | + self::$_settings[ $addon_name ] += $addon_settings; |
|
709 | + } else { |
|
710 | + self::$_settings[ $addon_name ] = $addon_settings; |
|
711 | + } |
|
712 | + return false; |
|
713 | + } |
|
714 | 714 | |
715 | 715 | |
716 | - /** |
|
717 | - * @param string $addon_name |
|
718 | - * @return void |
|
719 | - * @throws EE_Error |
|
720 | - */ |
|
721 | - private static function _setup_autoloaders($addon_name) |
|
722 | - { |
|
723 | - if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) { |
|
724 | - // setup autoloader for single file |
|
725 | - EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']); |
|
726 | - } |
|
727 | - // setup autoloaders for folders |
|
728 | - if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) { |
|
729 | - foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) { |
|
730 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
731 | - } |
|
732 | - } |
|
733 | - } |
|
716 | + /** |
|
717 | + * @param string $addon_name |
|
718 | + * @return void |
|
719 | + * @throws EE_Error |
|
720 | + */ |
|
721 | + private static function _setup_autoloaders($addon_name) |
|
722 | + { |
|
723 | + if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) { |
|
724 | + // setup autoloader for single file |
|
725 | + EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']); |
|
726 | + } |
|
727 | + // setup autoloaders for folders |
|
728 | + if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) { |
|
729 | + foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) { |
|
730 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
731 | + } |
|
732 | + } |
|
733 | + } |
|
734 | 734 | |
735 | 735 | |
736 | - /** |
|
737 | - * register new models and extensions |
|
738 | - * |
|
739 | - * @param string $addon_name |
|
740 | - * @return void |
|
741 | - * @throws EE_Error |
|
742 | - */ |
|
743 | - private static function _register_models_and_extensions($addon_name) |
|
744 | - { |
|
745 | - // register new models |
|
746 | - if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
747 | - || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
748 | - ) { |
|
749 | - EE_Register_Model::register( |
|
750 | - $addon_name, |
|
751 | - array( |
|
752 | - 'model_paths' => self::$_settings[ $addon_name ]['model_paths'], |
|
753 | - 'class_paths' => self::$_settings[ $addon_name ]['class_paths'], |
|
754 | - ) |
|
755 | - ); |
|
756 | - } |
|
757 | - // register model extensions |
|
758 | - if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
759 | - || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
760 | - ) { |
|
761 | - EE_Register_Model_Extensions::register( |
|
762 | - $addon_name, |
|
763 | - array( |
|
764 | - 'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'], |
|
765 | - 'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'], |
|
766 | - ) |
|
767 | - ); |
|
768 | - } |
|
769 | - } |
|
736 | + /** |
|
737 | + * register new models and extensions |
|
738 | + * |
|
739 | + * @param string $addon_name |
|
740 | + * @return void |
|
741 | + * @throws EE_Error |
|
742 | + */ |
|
743 | + private static function _register_models_and_extensions($addon_name) |
|
744 | + { |
|
745 | + // register new models |
|
746 | + if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
747 | + || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
748 | + ) { |
|
749 | + EE_Register_Model::register( |
|
750 | + $addon_name, |
|
751 | + array( |
|
752 | + 'model_paths' => self::$_settings[ $addon_name ]['model_paths'], |
|
753 | + 'class_paths' => self::$_settings[ $addon_name ]['class_paths'], |
|
754 | + ) |
|
755 | + ); |
|
756 | + } |
|
757 | + // register model extensions |
|
758 | + if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
759 | + || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
760 | + ) { |
|
761 | + EE_Register_Model_Extensions::register( |
|
762 | + $addon_name, |
|
763 | + array( |
|
764 | + 'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'], |
|
765 | + 'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'], |
|
766 | + ) |
|
767 | + ); |
|
768 | + } |
|
769 | + } |
|
770 | 770 | |
771 | 771 | |
772 | - /** |
|
773 | - * @param string $addon_name |
|
774 | - * @return void |
|
775 | - * @throws EE_Error |
|
776 | - */ |
|
777 | - private static function _register_data_migration_scripts($addon_name) |
|
778 | - { |
|
779 | - // setup DMS |
|
780 | - if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
781 | - EE_Register_Data_Migration_Scripts::register( |
|
782 | - $addon_name, |
|
783 | - array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths']) |
|
784 | - ); |
|
785 | - } |
|
786 | - } |
|
772 | + /** |
|
773 | + * @param string $addon_name |
|
774 | + * @return void |
|
775 | + * @throws EE_Error |
|
776 | + */ |
|
777 | + private static function _register_data_migration_scripts($addon_name) |
|
778 | + { |
|
779 | + // setup DMS |
|
780 | + if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
781 | + EE_Register_Data_Migration_Scripts::register( |
|
782 | + $addon_name, |
|
783 | + array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths']) |
|
784 | + ); |
|
785 | + } |
|
786 | + } |
|
787 | 787 | |
788 | 788 | |
789 | - /** |
|
790 | - * @param string $addon_name |
|
791 | - * @return void |
|
792 | - * @throws EE_Error |
|
793 | - */ |
|
794 | - private static function _register_config($addon_name) |
|
795 | - { |
|
796 | - // if config_class is present let's register config. |
|
797 | - if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
798 | - EE_Register_Config::register( |
|
799 | - self::$_settings[ $addon_name ]['config_class'], |
|
800 | - array( |
|
801 | - 'config_section' => self::$_settings[ $addon_name ]['config_section'], |
|
802 | - 'config_name' => self::$_settings[ $addon_name ]['config_name'], |
|
803 | - ) |
|
804 | - ); |
|
805 | - } |
|
806 | - } |
|
789 | + /** |
|
790 | + * @param string $addon_name |
|
791 | + * @return void |
|
792 | + * @throws EE_Error |
|
793 | + */ |
|
794 | + private static function _register_config($addon_name) |
|
795 | + { |
|
796 | + // if config_class is present let's register config. |
|
797 | + if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
798 | + EE_Register_Config::register( |
|
799 | + self::$_settings[ $addon_name ]['config_class'], |
|
800 | + array( |
|
801 | + 'config_section' => self::$_settings[ $addon_name ]['config_section'], |
|
802 | + 'config_name' => self::$_settings[ $addon_name ]['config_name'], |
|
803 | + ) |
|
804 | + ); |
|
805 | + } |
|
806 | + } |
|
807 | 807 | |
808 | 808 | |
809 | - /** |
|
810 | - * @param string $addon_name |
|
811 | - * @return void |
|
812 | - * @throws EE_Error |
|
813 | - */ |
|
814 | - private static function _register_admin_pages($addon_name) |
|
815 | - { |
|
816 | - if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
817 | - EE_Register_Admin_Page::register( |
|
818 | - $addon_name, |
|
819 | - array('page_path' => self::$_settings[ $addon_name ]['admin_path']) |
|
820 | - ); |
|
821 | - } |
|
822 | - } |
|
809 | + /** |
|
810 | + * @param string $addon_name |
|
811 | + * @return void |
|
812 | + * @throws EE_Error |
|
813 | + */ |
|
814 | + private static function _register_admin_pages($addon_name) |
|
815 | + { |
|
816 | + if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
817 | + EE_Register_Admin_Page::register( |
|
818 | + $addon_name, |
|
819 | + array('page_path' => self::$_settings[ $addon_name ]['admin_path']) |
|
820 | + ); |
|
821 | + } |
|
822 | + } |
|
823 | 823 | |
824 | 824 | |
825 | - /** |
|
826 | - * @param string $addon_name |
|
827 | - * @return void |
|
828 | - * @throws EE_Error |
|
829 | - */ |
|
830 | - private static function _register_modules($addon_name) |
|
831 | - { |
|
832 | - if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
833 | - EE_Register_Module::register( |
|
834 | - $addon_name, |
|
835 | - array('module_paths' => self::$_settings[ $addon_name ]['module_paths']) |
|
836 | - ); |
|
837 | - } |
|
838 | - } |
|
825 | + /** |
|
826 | + * @param string $addon_name |
|
827 | + * @return void |
|
828 | + * @throws EE_Error |
|
829 | + */ |
|
830 | + private static function _register_modules($addon_name) |
|
831 | + { |
|
832 | + if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
833 | + EE_Register_Module::register( |
|
834 | + $addon_name, |
|
835 | + array('module_paths' => self::$_settings[ $addon_name ]['module_paths']) |
|
836 | + ); |
|
837 | + } |
|
838 | + } |
|
839 | 839 | |
840 | 840 | |
841 | - /** |
|
842 | - * @param string $addon_name |
|
843 | - * @return void |
|
844 | - * @throws EE_Error |
|
845 | - */ |
|
846 | - private static function _register_shortcodes($addon_name) |
|
847 | - { |
|
848 | - if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
849 | - || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
850 | - ) { |
|
851 | - EE_Register_Shortcode::register( |
|
852 | - $addon_name, |
|
853 | - array( |
|
854 | - 'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
855 | - ? self::$_settings[ $addon_name ]['shortcode_paths'] |
|
856 | - : array(), |
|
857 | - 'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
858 | - ? self::$_settings[ $addon_name ]['shortcode_fqcns'] |
|
859 | - : array(), |
|
860 | - ) |
|
861 | - ); |
|
862 | - } |
|
863 | - } |
|
841 | + /** |
|
842 | + * @param string $addon_name |
|
843 | + * @return void |
|
844 | + * @throws EE_Error |
|
845 | + */ |
|
846 | + private static function _register_shortcodes($addon_name) |
|
847 | + { |
|
848 | + if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
849 | + || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
850 | + ) { |
|
851 | + EE_Register_Shortcode::register( |
|
852 | + $addon_name, |
|
853 | + array( |
|
854 | + 'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
855 | + ? self::$_settings[ $addon_name ]['shortcode_paths'] |
|
856 | + : array(), |
|
857 | + 'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
858 | + ? self::$_settings[ $addon_name ]['shortcode_fqcns'] |
|
859 | + : array(), |
|
860 | + ) |
|
861 | + ); |
|
862 | + } |
|
863 | + } |
|
864 | 864 | |
865 | 865 | |
866 | - /** |
|
867 | - * @param string $addon_name |
|
868 | - * @return void |
|
869 | - * @throws EE_Error |
|
870 | - */ |
|
871 | - private static function _register_widgets($addon_name) |
|
872 | - { |
|
873 | - if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
874 | - EE_Register_Widget::register( |
|
875 | - $addon_name, |
|
876 | - array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths']) |
|
877 | - ); |
|
878 | - } |
|
879 | - } |
|
866 | + /** |
|
867 | + * @param string $addon_name |
|
868 | + * @return void |
|
869 | + * @throws EE_Error |
|
870 | + */ |
|
871 | + private static function _register_widgets($addon_name) |
|
872 | + { |
|
873 | + if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
874 | + EE_Register_Widget::register( |
|
875 | + $addon_name, |
|
876 | + array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths']) |
|
877 | + ); |
|
878 | + } |
|
879 | + } |
|
880 | 880 | |
881 | 881 | |
882 | - /** |
|
883 | - * @param string $addon_name |
|
884 | - * @return void |
|
885 | - * @throws EE_Error |
|
886 | - */ |
|
887 | - private static function _register_capabilities($addon_name) |
|
888 | - { |
|
889 | - if (! empty(self::$_settings[ $addon_name ]['capabilities'])) { |
|
890 | - EE_Register_Capabilities::register( |
|
891 | - $addon_name, |
|
892 | - array( |
|
893 | - 'capabilities' => self::$_settings[ $addon_name ]['capabilities'], |
|
894 | - 'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'], |
|
895 | - ) |
|
896 | - ); |
|
897 | - } |
|
898 | - } |
|
882 | + /** |
|
883 | + * @param string $addon_name |
|
884 | + * @return void |
|
885 | + * @throws EE_Error |
|
886 | + */ |
|
887 | + private static function _register_capabilities($addon_name) |
|
888 | + { |
|
889 | + if (! empty(self::$_settings[ $addon_name ]['capabilities'])) { |
|
890 | + EE_Register_Capabilities::register( |
|
891 | + $addon_name, |
|
892 | + array( |
|
893 | + 'capabilities' => self::$_settings[ $addon_name ]['capabilities'], |
|
894 | + 'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'], |
|
895 | + ) |
|
896 | + ); |
|
897 | + } |
|
898 | + } |
|
899 | 899 | |
900 | 900 | |
901 | - /** |
|
902 | - * @param string $addon_name |
|
903 | - * @return void |
|
904 | - * @throws EE_Error |
|
905 | - */ |
|
906 | - private static function _register_message_types($addon_name) |
|
907 | - { |
|
908 | - if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
909 | - add_action( |
|
910 | - 'EE_Brewing_Regular___messages_caf', |
|
911 | - array('EE_Register_Addon', 'register_message_types') |
|
912 | - ); |
|
913 | - } |
|
914 | - } |
|
901 | + /** |
|
902 | + * @param string $addon_name |
|
903 | + * @return void |
|
904 | + * @throws EE_Error |
|
905 | + */ |
|
906 | + private static function _register_message_types($addon_name) |
|
907 | + { |
|
908 | + if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
909 | + add_action( |
|
910 | + 'EE_Brewing_Regular___messages_caf', |
|
911 | + array('EE_Register_Addon', 'register_message_types') |
|
912 | + ); |
|
913 | + } |
|
914 | + } |
|
915 | 915 | |
916 | 916 | |
917 | - /** |
|
918 | - * @param string $addon_name |
|
919 | - * @return void |
|
920 | - * @throws EE_Error |
|
921 | - */ |
|
922 | - private static function _register_custom_post_types($addon_name) |
|
923 | - { |
|
924 | - if (! empty(self::$_settings[ $addon_name ]['custom_post_types']) |
|
925 | - || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies']) |
|
926 | - ) { |
|
927 | - EE_Register_CPT::register( |
|
928 | - $addon_name, |
|
929 | - array( |
|
930 | - 'cpts' => self::$_settings[ $addon_name ]['custom_post_types'], |
|
931 | - 'cts' => self::$_settings[ $addon_name ]['custom_taxonomies'], |
|
932 | - 'default_terms' => self::$_settings[ $addon_name ]['default_terms'], |
|
933 | - ) |
|
934 | - ); |
|
935 | - } |
|
936 | - } |
|
917 | + /** |
|
918 | + * @param string $addon_name |
|
919 | + * @return void |
|
920 | + * @throws EE_Error |
|
921 | + */ |
|
922 | + private static function _register_custom_post_types($addon_name) |
|
923 | + { |
|
924 | + if (! empty(self::$_settings[ $addon_name ]['custom_post_types']) |
|
925 | + || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies']) |
|
926 | + ) { |
|
927 | + EE_Register_CPT::register( |
|
928 | + $addon_name, |
|
929 | + array( |
|
930 | + 'cpts' => self::$_settings[ $addon_name ]['custom_post_types'], |
|
931 | + 'cts' => self::$_settings[ $addon_name ]['custom_taxonomies'], |
|
932 | + 'default_terms' => self::$_settings[ $addon_name ]['default_terms'], |
|
933 | + ) |
|
934 | + ); |
|
935 | + } |
|
936 | + } |
|
937 | 937 | |
938 | 938 | |
939 | - /** |
|
940 | - * @param string $addon_name |
|
941 | - * @return void |
|
942 | - * @throws InvalidArgumentException |
|
943 | - * @throws InvalidInterfaceException |
|
944 | - * @throws InvalidDataTypeException |
|
945 | - * @throws DomainException |
|
946 | - * @throws EE_Error |
|
947 | - */ |
|
948 | - private static function _register_payment_methods($addon_name) |
|
949 | - { |
|
950 | - if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
951 | - EE_Register_Payment_Method::register( |
|
952 | - $addon_name, |
|
953 | - array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths']) |
|
954 | - ); |
|
955 | - } |
|
956 | - } |
|
939 | + /** |
|
940 | + * @param string $addon_name |
|
941 | + * @return void |
|
942 | + * @throws InvalidArgumentException |
|
943 | + * @throws InvalidInterfaceException |
|
944 | + * @throws InvalidDataTypeException |
|
945 | + * @throws DomainException |
|
946 | + * @throws EE_Error |
|
947 | + */ |
|
948 | + private static function _register_payment_methods($addon_name) |
|
949 | + { |
|
950 | + if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
951 | + EE_Register_Payment_Method::register( |
|
952 | + $addon_name, |
|
953 | + array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths']) |
|
954 | + ); |
|
955 | + } |
|
956 | + } |
|
957 | 957 | |
958 | 958 | |
959 | - /** |
|
960 | - * @param string $addon_name |
|
961 | - * @return void |
|
962 | - * @throws InvalidArgumentException |
|
963 | - * @throws InvalidInterfaceException |
|
964 | - * @throws InvalidDataTypeException |
|
965 | - * @throws DomainException |
|
966 | - * @throws EE_Error |
|
967 | - */ |
|
968 | - private static function registerPrivacyPolicies($addon_name) |
|
969 | - { |
|
970 | - if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) { |
|
971 | - EE_Register_Privacy_Policy::register( |
|
972 | - $addon_name, |
|
973 | - self::$_settings[ $addon_name ]['privacy_policies'] |
|
974 | - ); |
|
975 | - } |
|
976 | - } |
|
959 | + /** |
|
960 | + * @param string $addon_name |
|
961 | + * @return void |
|
962 | + * @throws InvalidArgumentException |
|
963 | + * @throws InvalidInterfaceException |
|
964 | + * @throws InvalidDataTypeException |
|
965 | + * @throws DomainException |
|
966 | + * @throws EE_Error |
|
967 | + */ |
|
968 | + private static function registerPrivacyPolicies($addon_name) |
|
969 | + { |
|
970 | + if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) { |
|
971 | + EE_Register_Privacy_Policy::register( |
|
972 | + $addon_name, |
|
973 | + self::$_settings[ $addon_name ]['privacy_policies'] |
|
974 | + ); |
|
975 | + } |
|
976 | + } |
|
977 | 977 | |
978 | 978 | |
979 | - /** |
|
980 | - * @param string $addon_name |
|
981 | - * @return void |
|
982 | - */ |
|
983 | - private static function registerPersonalDataExporters($addon_name) |
|
984 | - { |
|
985 | - if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) { |
|
986 | - EE_Register_Personal_Data_Eraser::register( |
|
987 | - $addon_name, |
|
988 | - self::$_settings[ $addon_name ]['personal_data_exporters'] |
|
989 | - ); |
|
990 | - } |
|
991 | - } |
|
979 | + /** |
|
980 | + * @param string $addon_name |
|
981 | + * @return void |
|
982 | + */ |
|
983 | + private static function registerPersonalDataExporters($addon_name) |
|
984 | + { |
|
985 | + if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) { |
|
986 | + EE_Register_Personal_Data_Eraser::register( |
|
987 | + $addon_name, |
|
988 | + self::$_settings[ $addon_name ]['personal_data_exporters'] |
|
989 | + ); |
|
990 | + } |
|
991 | + } |
|
992 | 992 | |
993 | 993 | |
994 | - /** |
|
995 | - * @param string $addon_name |
|
996 | - * @return void |
|
997 | - */ |
|
998 | - private static function registerPersonalDataErasers($addon_name) |
|
999 | - { |
|
1000 | - if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) { |
|
1001 | - EE_Register_Personal_Data_Eraser::register( |
|
1002 | - $addon_name, |
|
1003 | - self::$_settings[ $addon_name ]['personal_data_erasers'] |
|
1004 | - ); |
|
1005 | - } |
|
1006 | - } |
|
994 | + /** |
|
995 | + * @param string $addon_name |
|
996 | + * @return void |
|
997 | + */ |
|
998 | + private static function registerPersonalDataErasers($addon_name) |
|
999 | + { |
|
1000 | + if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) { |
|
1001 | + EE_Register_Personal_Data_Eraser::register( |
|
1002 | + $addon_name, |
|
1003 | + self::$_settings[ $addon_name ]['personal_data_erasers'] |
|
1004 | + ); |
|
1005 | + } |
|
1006 | + } |
|
1007 | 1007 | |
1008 | 1008 | |
1009 | - /** |
|
1010 | - * Loads and instantiates the EE_Addon class and adds it onto the registry |
|
1011 | - * |
|
1012 | - * @param string $addon_name |
|
1013 | - * @return EE_Addon |
|
1014 | - * @throws InvalidArgumentException |
|
1015 | - * @throws InvalidInterfaceException |
|
1016 | - * @throws InvalidDataTypeException |
|
1017 | - * @throws ReflectionException |
|
1018 | - * @throws EE_Error |
|
1019 | - */ |
|
1020 | - private static function _load_and_init_addon_class($addon_name) |
|
1021 | - { |
|
1022 | - $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader(); |
|
1023 | - $addon = $loader->getShared( |
|
1024 | - self::$_settings[ $addon_name ]['class_name'], |
|
1025 | - array('EE_Registry::create(addon)' => true) |
|
1026 | - ); |
|
1027 | - // setter inject dep map if required |
|
1028 | - if ($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null) { |
|
1029 | - $addon->setDependencyMap($loader->getShared('EE_Dependency_Map')); |
|
1030 | - } |
|
1031 | - // setter inject domain if required |
|
1032 | - if ($addon instanceof RequiresDomainInterface |
|
1033 | - && $addon->domain() === null |
|
1034 | - ) { |
|
1035 | - // using supplied Domain object |
|
1036 | - $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface |
|
1037 | - ? self::$_settings[ $addon_name ]['domain'] |
|
1038 | - : null; |
|
1039 | - // or construct one using Domain FQCN |
|
1040 | - if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') { |
|
1041 | - $domain = $loader->getShared( |
|
1042 | - self::$_settings[ $addon_name ]['domain_fqcn'], |
|
1043 | - array( |
|
1044 | - new EventEspresso\core\domain\values\FilePath( |
|
1045 | - self::$_settings[ $addon_name ]['main_file_path'] |
|
1046 | - ), |
|
1047 | - EventEspresso\core\domain\values\Version::fromString( |
|
1048 | - self::$_settings[ $addon_name ]['version'] |
|
1049 | - ), |
|
1050 | - ) |
|
1051 | - ); |
|
1052 | - } |
|
1053 | - if ($domain instanceof DomainInterface) { |
|
1054 | - $addon->setDomain($domain); |
|
1055 | - } |
|
1056 | - } |
|
1057 | - $addon->set_name($addon_name); |
|
1058 | - $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']); |
|
1059 | - $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']); |
|
1060 | - $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']); |
|
1061 | - $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']); |
|
1062 | - $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']); |
|
1063 | - $addon->set_version(self::$_settings[ $addon_name ]['version']); |
|
1064 | - $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version'])); |
|
1065 | - $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']); |
|
1066 | - $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']); |
|
1067 | - $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']); |
|
1068 | - // unfortunately this can't be hooked in upon construction, because we don't have |
|
1069 | - // the plugin mainfile's path upon construction. |
|
1070 | - register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
1071 | - // call any additional admin_callback functions during load_admin_controller hook |
|
1072 | - if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) { |
|
1073 | - add_action( |
|
1074 | - 'AHEE__EE_System__load_controllers__load_admin_controllers', |
|
1075 | - array($addon, self::$_settings[ $addon_name ]['admin_callback']) |
|
1076 | - ); |
|
1077 | - } |
|
1078 | - return $addon; |
|
1079 | - } |
|
1009 | + /** |
|
1010 | + * Loads and instantiates the EE_Addon class and adds it onto the registry |
|
1011 | + * |
|
1012 | + * @param string $addon_name |
|
1013 | + * @return EE_Addon |
|
1014 | + * @throws InvalidArgumentException |
|
1015 | + * @throws InvalidInterfaceException |
|
1016 | + * @throws InvalidDataTypeException |
|
1017 | + * @throws ReflectionException |
|
1018 | + * @throws EE_Error |
|
1019 | + */ |
|
1020 | + private static function _load_and_init_addon_class($addon_name) |
|
1021 | + { |
|
1022 | + $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader(); |
|
1023 | + $addon = $loader->getShared( |
|
1024 | + self::$_settings[ $addon_name ]['class_name'], |
|
1025 | + array('EE_Registry::create(addon)' => true) |
|
1026 | + ); |
|
1027 | + // setter inject dep map if required |
|
1028 | + if ($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null) { |
|
1029 | + $addon->setDependencyMap($loader->getShared('EE_Dependency_Map')); |
|
1030 | + } |
|
1031 | + // setter inject domain if required |
|
1032 | + if ($addon instanceof RequiresDomainInterface |
|
1033 | + && $addon->domain() === null |
|
1034 | + ) { |
|
1035 | + // using supplied Domain object |
|
1036 | + $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface |
|
1037 | + ? self::$_settings[ $addon_name ]['domain'] |
|
1038 | + : null; |
|
1039 | + // or construct one using Domain FQCN |
|
1040 | + if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') { |
|
1041 | + $domain = $loader->getShared( |
|
1042 | + self::$_settings[ $addon_name ]['domain_fqcn'], |
|
1043 | + array( |
|
1044 | + new EventEspresso\core\domain\values\FilePath( |
|
1045 | + self::$_settings[ $addon_name ]['main_file_path'] |
|
1046 | + ), |
|
1047 | + EventEspresso\core\domain\values\Version::fromString( |
|
1048 | + self::$_settings[ $addon_name ]['version'] |
|
1049 | + ), |
|
1050 | + ) |
|
1051 | + ); |
|
1052 | + } |
|
1053 | + if ($domain instanceof DomainInterface) { |
|
1054 | + $addon->setDomain($domain); |
|
1055 | + } |
|
1056 | + } |
|
1057 | + $addon->set_name($addon_name); |
|
1058 | + $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']); |
|
1059 | + $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']); |
|
1060 | + $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']); |
|
1061 | + $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']); |
|
1062 | + $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']); |
|
1063 | + $addon->set_version(self::$_settings[ $addon_name ]['version']); |
|
1064 | + $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version'])); |
|
1065 | + $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']); |
|
1066 | + $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']); |
|
1067 | + $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']); |
|
1068 | + // unfortunately this can't be hooked in upon construction, because we don't have |
|
1069 | + // the plugin mainfile's path upon construction. |
|
1070 | + register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
1071 | + // call any additional admin_callback functions during load_admin_controller hook |
|
1072 | + if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) { |
|
1073 | + add_action( |
|
1074 | + 'AHEE__EE_System__load_controllers__load_admin_controllers', |
|
1075 | + array($addon, self::$_settings[ $addon_name ]['admin_callback']) |
|
1076 | + ); |
|
1077 | + } |
|
1078 | + return $addon; |
|
1079 | + } |
|
1080 | 1080 | |
1081 | 1081 | |
1082 | - /** |
|
1083 | - * load_pue_update - Update notifications |
|
1084 | - * |
|
1085 | - * @return void |
|
1086 | - * @throws InvalidArgumentException |
|
1087 | - * @throws InvalidDataTypeException |
|
1088 | - * @throws InvalidInterfaceException |
|
1089 | - */ |
|
1090 | - public static function load_pue_update() |
|
1091 | - { |
|
1092 | - // load PUE client |
|
1093 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
1094 | - // cycle thru settings |
|
1095 | - foreach (self::$_settings as $settings) { |
|
1096 | - if (! empty($settings['pue_options'])) { |
|
1097 | - // initiate the class and start the plugin update engine! |
|
1098 | - new PluginUpdateEngineChecker( |
|
1099 | - // host file URL |
|
1100 | - 'https://eventespresso.com', |
|
1101 | - // plugin slug(s) |
|
1102 | - array( |
|
1103 | - 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
1104 | - 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
1105 | - ), |
|
1106 | - // options |
|
1107 | - array( |
|
1108 | - 'apikey' => EE_Registry::instance()->NET_CFG->core->site_license_key, |
|
1109 | - 'lang_domain' => 'event_espresso', |
|
1110 | - 'checkPeriod' => $settings['pue_options']['checkPeriod'], |
|
1111 | - 'option_key' => 'site_license_key', |
|
1112 | - 'options_page_slug' => 'event_espresso', |
|
1113 | - 'plugin_basename' => $settings['pue_options']['plugin_basename'], |
|
1114 | - // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP |
|
1115 | - 'use_wp_update' => $settings['pue_options']['use_wp_update'], |
|
1116 | - ) |
|
1117 | - ); |
|
1118 | - } |
|
1119 | - } |
|
1120 | - } |
|
1082 | + /** |
|
1083 | + * load_pue_update - Update notifications |
|
1084 | + * |
|
1085 | + * @return void |
|
1086 | + * @throws InvalidArgumentException |
|
1087 | + * @throws InvalidDataTypeException |
|
1088 | + * @throws InvalidInterfaceException |
|
1089 | + */ |
|
1090 | + public static function load_pue_update() |
|
1091 | + { |
|
1092 | + // load PUE client |
|
1093 | + require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
1094 | + // cycle thru settings |
|
1095 | + foreach (self::$_settings as $settings) { |
|
1096 | + if (! empty($settings['pue_options'])) { |
|
1097 | + // initiate the class and start the plugin update engine! |
|
1098 | + new PluginUpdateEngineChecker( |
|
1099 | + // host file URL |
|
1100 | + 'https://eventespresso.com', |
|
1101 | + // plugin slug(s) |
|
1102 | + array( |
|
1103 | + 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
1104 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
1105 | + ), |
|
1106 | + // options |
|
1107 | + array( |
|
1108 | + 'apikey' => EE_Registry::instance()->NET_CFG->core->site_license_key, |
|
1109 | + 'lang_domain' => 'event_espresso', |
|
1110 | + 'checkPeriod' => $settings['pue_options']['checkPeriod'], |
|
1111 | + 'option_key' => 'site_license_key', |
|
1112 | + 'options_page_slug' => 'event_espresso', |
|
1113 | + 'plugin_basename' => $settings['pue_options']['plugin_basename'], |
|
1114 | + // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP |
|
1115 | + 'use_wp_update' => $settings['pue_options']['use_wp_update'], |
|
1116 | + ) |
|
1117 | + ); |
|
1118 | + } |
|
1119 | + } |
|
1120 | + } |
|
1121 | 1121 | |
1122 | 1122 | |
1123 | - /** |
|
1124 | - * Callback for EE_Brewing_Regular__messages_caf hook used to register message types. |
|
1125 | - * |
|
1126 | - * @since 4.4.0 |
|
1127 | - * @return void |
|
1128 | - * @throws EE_Error |
|
1129 | - */ |
|
1130 | - public static function register_message_types() |
|
1131 | - { |
|
1132 | - foreach (self::$_settings as $addon_name => $settings) { |
|
1133 | - if (! empty($settings['message_types'])) { |
|
1134 | - foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) { |
|
1135 | - EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
1136 | - } |
|
1137 | - } |
|
1138 | - } |
|
1139 | - } |
|
1123 | + /** |
|
1124 | + * Callback for EE_Brewing_Regular__messages_caf hook used to register message types. |
|
1125 | + * |
|
1126 | + * @since 4.4.0 |
|
1127 | + * @return void |
|
1128 | + * @throws EE_Error |
|
1129 | + */ |
|
1130 | + public static function register_message_types() |
|
1131 | + { |
|
1132 | + foreach (self::$_settings as $addon_name => $settings) { |
|
1133 | + if (! empty($settings['message_types'])) { |
|
1134 | + foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) { |
|
1135 | + EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
1136 | + } |
|
1137 | + } |
|
1138 | + } |
|
1139 | + } |
|
1140 | 1140 | |
1141 | 1141 | |
1142 | - /** |
|
1143 | - * This deregisters an addon that was previously registered with a specific addon_name. |
|
1144 | - * |
|
1145 | - * @since 4.3.0 |
|
1146 | - * @param string $addon_name the name for the addon that was previously registered |
|
1147 | - * @throws DomainException |
|
1148 | - * @throws EE_Error |
|
1149 | - * @throws InvalidArgumentException |
|
1150 | - * @throws InvalidDataTypeException |
|
1151 | - * @throws InvalidInterfaceException |
|
1152 | - */ |
|
1153 | - public static function deregister($addon_name = null) |
|
1154 | - { |
|
1155 | - if (isset(self::$_settings[ $addon_name ]['class_name'])) { |
|
1156 | - try { |
|
1157 | - do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
|
1158 | - $class_name = self::$_settings[ $addon_name ]['class_name']; |
|
1159 | - if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
1160 | - // setup DMS |
|
1161 | - EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
1162 | - } |
|
1163 | - if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
1164 | - // register admin page |
|
1165 | - EE_Register_Admin_Page::deregister($addon_name); |
|
1166 | - } |
|
1167 | - if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
1168 | - // add to list of modules to be registered |
|
1169 | - EE_Register_Module::deregister($addon_name); |
|
1170 | - } |
|
1171 | - if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
1172 | - || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
1173 | - ) { |
|
1174 | - // add to list of shortcodes to be registered |
|
1175 | - EE_Register_Shortcode::deregister($addon_name); |
|
1176 | - } |
|
1177 | - if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
1178 | - // if config_class present let's register config. |
|
1179 | - EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']); |
|
1180 | - } |
|
1181 | - if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
1182 | - // add to list of widgets to be registered |
|
1183 | - EE_Register_Widget::deregister($addon_name); |
|
1184 | - } |
|
1185 | - if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
1186 | - || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
1187 | - ) { |
|
1188 | - // add to list of shortcodes to be registered |
|
1189 | - EE_Register_Model::deregister($addon_name); |
|
1190 | - } |
|
1191 | - if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
1192 | - || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
1193 | - ) { |
|
1194 | - // add to list of shortcodes to be registered |
|
1195 | - EE_Register_Model_Extensions::deregister($addon_name); |
|
1196 | - } |
|
1197 | - if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
1198 | - foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) { |
|
1199 | - EE_Register_Message_Type::deregister($message_type); |
|
1200 | - } |
|
1201 | - } |
|
1202 | - // deregister capabilities for addon |
|
1203 | - if (! empty(self::$_settings[ $addon_name ]['capabilities']) |
|
1204 | - || ! empty(self::$_settings[ $addon_name ]['capability_maps']) |
|
1205 | - ) { |
|
1206 | - EE_Register_Capabilities::deregister($addon_name); |
|
1207 | - } |
|
1208 | - // deregister custom_post_types for addon |
|
1209 | - if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) { |
|
1210 | - EE_Register_CPT::deregister($addon_name); |
|
1211 | - } |
|
1212 | - if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
1213 | - EE_Register_Payment_Method::deregister($addon_name); |
|
1214 | - } |
|
1215 | - $addon = EE_Registry::instance()->getAddon($class_name); |
|
1216 | - if ($addon instanceof EE_Addon) { |
|
1217 | - remove_action( |
|
1218 | - 'deactivate_' . $addon->get_main_plugin_file_basename(), |
|
1219 | - array($addon, 'deactivation') |
|
1220 | - ); |
|
1221 | - remove_action( |
|
1222 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
1223 | - array($addon, 'initialize_db_if_no_migrations_required') |
|
1224 | - ); |
|
1225 | - // remove `after_registration` call |
|
1226 | - remove_action( |
|
1227 | - 'AHEE__EE_System__load_espresso_addons__complete', |
|
1228 | - array($addon, 'after_registration'), |
|
1229 | - 999 |
|
1230 | - ); |
|
1231 | - } |
|
1232 | - EE_Registry::instance()->removeAddon($class_name); |
|
1233 | - } catch (OutOfBoundsException $addon_not_yet_registered_exception) { |
|
1234 | - // the add-on was not yet registered in the registry, |
|
1235 | - // so RegistryContainer::__get() throws this exception. |
|
1236 | - // also no need to worry about this or log it, |
|
1237 | - // it's ok to deregister an add-on before its registered in the registry |
|
1238 | - } catch (Exception $e) { |
|
1239 | - new ExceptionLogger($e); |
|
1240 | - } |
|
1241 | - unset(self::$_settings[ $addon_name ]); |
|
1242 | - do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name); |
|
1243 | - } |
|
1244 | - } |
|
1142 | + /** |
|
1143 | + * This deregisters an addon that was previously registered with a specific addon_name. |
|
1144 | + * |
|
1145 | + * @since 4.3.0 |
|
1146 | + * @param string $addon_name the name for the addon that was previously registered |
|
1147 | + * @throws DomainException |
|
1148 | + * @throws EE_Error |
|
1149 | + * @throws InvalidArgumentException |
|
1150 | + * @throws InvalidDataTypeException |
|
1151 | + * @throws InvalidInterfaceException |
|
1152 | + */ |
|
1153 | + public static function deregister($addon_name = null) |
|
1154 | + { |
|
1155 | + if (isset(self::$_settings[ $addon_name ]['class_name'])) { |
|
1156 | + try { |
|
1157 | + do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
|
1158 | + $class_name = self::$_settings[ $addon_name ]['class_name']; |
|
1159 | + if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
1160 | + // setup DMS |
|
1161 | + EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
1162 | + } |
|
1163 | + if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
1164 | + // register admin page |
|
1165 | + EE_Register_Admin_Page::deregister($addon_name); |
|
1166 | + } |
|
1167 | + if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
1168 | + // add to list of modules to be registered |
|
1169 | + EE_Register_Module::deregister($addon_name); |
|
1170 | + } |
|
1171 | + if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
1172 | + || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
1173 | + ) { |
|
1174 | + // add to list of shortcodes to be registered |
|
1175 | + EE_Register_Shortcode::deregister($addon_name); |
|
1176 | + } |
|
1177 | + if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
1178 | + // if config_class present let's register config. |
|
1179 | + EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']); |
|
1180 | + } |
|
1181 | + if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
1182 | + // add to list of widgets to be registered |
|
1183 | + EE_Register_Widget::deregister($addon_name); |
|
1184 | + } |
|
1185 | + if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
1186 | + || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
1187 | + ) { |
|
1188 | + // add to list of shortcodes to be registered |
|
1189 | + EE_Register_Model::deregister($addon_name); |
|
1190 | + } |
|
1191 | + if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
1192 | + || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
1193 | + ) { |
|
1194 | + // add to list of shortcodes to be registered |
|
1195 | + EE_Register_Model_Extensions::deregister($addon_name); |
|
1196 | + } |
|
1197 | + if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
1198 | + foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) { |
|
1199 | + EE_Register_Message_Type::deregister($message_type); |
|
1200 | + } |
|
1201 | + } |
|
1202 | + // deregister capabilities for addon |
|
1203 | + if (! empty(self::$_settings[ $addon_name ]['capabilities']) |
|
1204 | + || ! empty(self::$_settings[ $addon_name ]['capability_maps']) |
|
1205 | + ) { |
|
1206 | + EE_Register_Capabilities::deregister($addon_name); |
|
1207 | + } |
|
1208 | + // deregister custom_post_types for addon |
|
1209 | + if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) { |
|
1210 | + EE_Register_CPT::deregister($addon_name); |
|
1211 | + } |
|
1212 | + if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
1213 | + EE_Register_Payment_Method::deregister($addon_name); |
|
1214 | + } |
|
1215 | + $addon = EE_Registry::instance()->getAddon($class_name); |
|
1216 | + if ($addon instanceof EE_Addon) { |
|
1217 | + remove_action( |
|
1218 | + 'deactivate_' . $addon->get_main_plugin_file_basename(), |
|
1219 | + array($addon, 'deactivation') |
|
1220 | + ); |
|
1221 | + remove_action( |
|
1222 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
1223 | + array($addon, 'initialize_db_if_no_migrations_required') |
|
1224 | + ); |
|
1225 | + // remove `after_registration` call |
|
1226 | + remove_action( |
|
1227 | + 'AHEE__EE_System__load_espresso_addons__complete', |
|
1228 | + array($addon, 'after_registration'), |
|
1229 | + 999 |
|
1230 | + ); |
|
1231 | + } |
|
1232 | + EE_Registry::instance()->removeAddon($class_name); |
|
1233 | + } catch (OutOfBoundsException $addon_not_yet_registered_exception) { |
|
1234 | + // the add-on was not yet registered in the registry, |
|
1235 | + // so RegistryContainer::__get() throws this exception. |
|
1236 | + // also no need to worry about this or log it, |
|
1237 | + // it's ok to deregister an add-on before its registered in the registry |
|
1238 | + } catch (Exception $e) { |
|
1239 | + new ExceptionLogger($e); |
|
1240 | + } |
|
1241 | + unset(self::$_settings[ $addon_name ]); |
|
1242 | + do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name); |
|
1243 | + } |
|
1244 | + } |
|
1245 | 1245 | } |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | // offsets: 0 . 1 . 2 . 3 . 4 |
70 | 70 | $version_parts = explode('.', $min_core_version); |
71 | 71 | // check they specified the micro version (after 2nd period) |
72 | - if (! isset($version_parts[2])) { |
|
72 | + if ( ! isset($version_parts[2])) { |
|
73 | 73 | $version_parts[2] = '0'; |
74 | 74 | } |
75 | 75 | // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
76 | 76 | // soon we can assume that's 'rc', but this current version is 'alpha' |
77 | - if (! isset($version_parts[3])) { |
|
77 | + if ( ! isset($version_parts[3])) { |
|
78 | 78 | $version_parts[3] = 'dev'; |
79 | 79 | } |
80 | - if (! isset($version_parts[4])) { |
|
80 | + if ( ! isset($version_parts[4])) { |
|
81 | 81 | $version_parts[4] = '000'; |
82 | 82 | } |
83 | 83 | return implode('.', $version_parts); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | // setup PUE |
265 | 265 | EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
266 | 266 | // does this addon work with this version of core or WordPress ? |
267 | - if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
267 | + if ( ! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
268 | 268 | return; |
269 | 269 | } |
270 | 270 | // register namespaces |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | ) |
329 | 329 | ); |
330 | 330 | } |
331 | - if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
331 | + if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
332 | 332 | throw new EE_Error( |
333 | 333 | sprintf( |
334 | 334 | __( |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | ); |
341 | 341 | } |
342 | 342 | // check that addon has not already been registered with that name |
343 | - if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) { |
|
343 | + if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
344 | 344 | throw new EE_Error( |
345 | 345 | sprintf( |
346 | 346 | __( |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | // check if classname is fully qualified or is a legacy classname already prefixed with 'EE_' |
373 | 373 | return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0 |
374 | 374 | ? $class_name |
375 | - : 'EE_' . $class_name; |
|
375 | + : 'EE_'.$class_name; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -539,9 +539,9 @@ discard block |
||
539 | 539 | global $wp_version; |
540 | 540 | $incompatibility_message = ''; |
541 | 541 | // check whether this addon version is compatible with EE core |
542 | - if (isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ]) |
|
542 | + if (isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) |
|
543 | 543 | && ! self::_meets_min_core_version_requirement( |
544 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
544 | + EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
545 | 545 | $addon_settings['version'] |
546 | 546 | ) |
547 | 547 | ) { |
@@ -552,11 +552,11 @@ discard block |
||
552 | 552 | ), |
553 | 553 | $addon_name, |
554 | 554 | '<br />', |
555 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
555 | + EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
556 | 556 | '<span style="font-weight: bold; color: #D54E21;">', |
557 | 557 | '</span><br />' |
558 | 558 | ); |
559 | - } elseif (! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
559 | + } elseif ( ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
560 | 560 | ) { |
561 | 561 | $incompatibility_message = sprintf( |
562 | 562 | __( |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | '</span><br />' |
584 | 584 | ); |
585 | 585 | } |
586 | - if (! empty($incompatibility_message)) { |
|
586 | + if ( ! empty($incompatibility_message)) { |
|
587 | 587 | // remove 'activate' from the REQUEST |
588 | 588 | // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
589 | 589 | unset($_GET['activate'], $_REQUEST['activate']); |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | */ |
612 | 612 | private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
613 | 613 | { |
614 | - if (! empty($setup_args['pue_options'])) { |
|
615 | - self::$_settings[ $addon_name ]['pue_options'] = array( |
|
614 | + if ( ! empty($setup_args['pue_options'])) { |
|
615 | + self::$_settings[$addon_name]['pue_options'] = array( |
|
616 | 616 | 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
617 | 617 | ? (string) $setup_args['pue_options']['pue_plugin_slug'] |
618 | - : 'espresso_' . strtolower($class_name), |
|
618 | + : 'espresso_'.strtolower($class_name), |
|
619 | 619 | 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
620 | 620 | ? (string) $setup_args['pue_options']['plugin_basename'] |
621 | 621 | : plugin_basename($setup_args['main_file_path']), |
@@ -674,12 +674,12 @@ discard block |
||
674 | 674 | // (as the newly-activated addon wasn't around the first time addons were registered). |
675 | 675 | // Note: the presence of pue_options in the addon registration options will initialize the $_settings |
676 | 676 | // property for the add-on, but the add-on is only partially initialized. Hence, the additional check. |
677 | - if (! isset(self::$_settings[ $addon_name ]) |
|
678 | - || (isset(self::$_settings[ $addon_name ]) |
|
679 | - && ! isset(self::$_settings[ $addon_name ]['class_name']) |
|
677 | + if ( ! isset(self::$_settings[$addon_name]) |
|
678 | + || (isset(self::$_settings[$addon_name]) |
|
679 | + && ! isset(self::$_settings[$addon_name]['class_name']) |
|
680 | 680 | ) |
681 | 681 | ) { |
682 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
682 | + self::$_settings[$addon_name] = $addon_settings; |
|
683 | 683 | $addon = self::_load_and_init_addon_class($addon_name); |
684 | 684 | $addon->set_activation_indicator_option(); |
685 | 685 | // dont bother setting up the rest of the addon. |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | return true; |
689 | 689 | } |
690 | 690 | // make sure this was called in the right place! |
691 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
691 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') |
|
692 | 692 | || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
693 | 693 | ) { |
694 | 694 | EE_Error::doing_it_wrong( |
@@ -704,10 +704,10 @@ discard block |
||
704 | 704 | ); |
705 | 705 | } |
706 | 706 | // make sure addon settings are set correctly without overwriting anything existing |
707 | - if (isset(self::$_settings[ $addon_name ])) { |
|
708 | - self::$_settings[ $addon_name ] += $addon_settings; |
|
707 | + if (isset(self::$_settings[$addon_name])) { |
|
708 | + self::$_settings[$addon_name] += $addon_settings; |
|
709 | 709 | } else { |
710 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
710 | + self::$_settings[$addon_name] = $addon_settings; |
|
711 | 711 | } |
712 | 712 | return false; |
713 | 713 | } |
@@ -720,13 +720,13 @@ discard block |
||
720 | 720 | */ |
721 | 721 | private static function _setup_autoloaders($addon_name) |
722 | 722 | { |
723 | - if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) { |
|
723 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
724 | 724 | // setup autoloader for single file |
725 | - EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']); |
|
725 | + EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
726 | 726 | } |
727 | 727 | // setup autoloaders for folders |
728 | - if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) { |
|
729 | - foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) { |
|
728 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
729 | + foreach ((array) self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
730 | 730 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
731 | 731 | } |
732 | 732 | } |
@@ -743,26 +743,26 @@ discard block |
||
743 | 743 | private static function _register_models_and_extensions($addon_name) |
744 | 744 | { |
745 | 745 | // register new models |
746 | - if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
747 | - || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
746 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) |
|
747 | + || ! empty(self::$_settings[$addon_name]['class_paths']) |
|
748 | 748 | ) { |
749 | 749 | EE_Register_Model::register( |
750 | 750 | $addon_name, |
751 | 751 | array( |
752 | - 'model_paths' => self::$_settings[ $addon_name ]['model_paths'], |
|
753 | - 'class_paths' => self::$_settings[ $addon_name ]['class_paths'], |
|
752 | + 'model_paths' => self::$_settings[$addon_name]['model_paths'], |
|
753 | + 'class_paths' => self::$_settings[$addon_name]['class_paths'], |
|
754 | 754 | ) |
755 | 755 | ); |
756 | 756 | } |
757 | 757 | // register model extensions |
758 | - if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
759 | - || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
758 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
759 | + || ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
760 | 760 | ) { |
761 | 761 | EE_Register_Model_Extensions::register( |
762 | 762 | $addon_name, |
763 | 763 | array( |
764 | - 'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'], |
|
765 | - 'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'], |
|
764 | + 'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], |
|
765 | + 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'], |
|
766 | 766 | ) |
767 | 767 | ); |
768 | 768 | } |
@@ -777,10 +777,10 @@ discard block |
||
777 | 777 | private static function _register_data_migration_scripts($addon_name) |
778 | 778 | { |
779 | 779 | // setup DMS |
780 | - if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
780 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
781 | 781 | EE_Register_Data_Migration_Scripts::register( |
782 | 782 | $addon_name, |
783 | - array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths']) |
|
783 | + array('dms_paths' => self::$_settings[$addon_name]['dms_paths']) |
|
784 | 784 | ); |
785 | 785 | } |
786 | 786 | } |
@@ -794,12 +794,12 @@ discard block |
||
794 | 794 | private static function _register_config($addon_name) |
795 | 795 | { |
796 | 796 | // if config_class is present let's register config. |
797 | - if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
797 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
798 | 798 | EE_Register_Config::register( |
799 | - self::$_settings[ $addon_name ]['config_class'], |
|
799 | + self::$_settings[$addon_name]['config_class'], |
|
800 | 800 | array( |
801 | - 'config_section' => self::$_settings[ $addon_name ]['config_section'], |
|
802 | - 'config_name' => self::$_settings[ $addon_name ]['config_name'], |
|
801 | + 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
802 | + 'config_name' => self::$_settings[$addon_name]['config_name'], |
|
803 | 803 | ) |
804 | 804 | ); |
805 | 805 | } |
@@ -813,10 +813,10 @@ discard block |
||
813 | 813 | */ |
814 | 814 | private static function _register_admin_pages($addon_name) |
815 | 815 | { |
816 | - if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
816 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
817 | 817 | EE_Register_Admin_Page::register( |
818 | 818 | $addon_name, |
819 | - array('page_path' => self::$_settings[ $addon_name ]['admin_path']) |
|
819 | + array('page_path' => self::$_settings[$addon_name]['admin_path']) |
|
820 | 820 | ); |
821 | 821 | } |
822 | 822 | } |
@@ -829,10 +829,10 @@ discard block |
||
829 | 829 | */ |
830 | 830 | private static function _register_modules($addon_name) |
831 | 831 | { |
832 | - if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
832 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
833 | 833 | EE_Register_Module::register( |
834 | 834 | $addon_name, |
835 | - array('module_paths' => self::$_settings[ $addon_name ]['module_paths']) |
|
835 | + array('module_paths' => self::$_settings[$addon_name]['module_paths']) |
|
836 | 836 | ); |
837 | 837 | } |
838 | 838 | } |
@@ -845,17 +845,17 @@ discard block |
||
845 | 845 | */ |
846 | 846 | private static function _register_shortcodes($addon_name) |
847 | 847 | { |
848 | - if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
849 | - || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
848 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths']) |
|
849 | + || ! empty(self::$_settings[$addon_name]['shortcode_fqcns']) |
|
850 | 850 | ) { |
851 | 851 | EE_Register_Shortcode::register( |
852 | 852 | $addon_name, |
853 | 853 | array( |
854 | - 'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
855 | - ? self::$_settings[ $addon_name ]['shortcode_paths'] |
|
854 | + 'shortcode_paths' => isset(self::$_settings[$addon_name]['shortcode_paths']) |
|
855 | + ? self::$_settings[$addon_name]['shortcode_paths'] |
|
856 | 856 | : array(), |
857 | - 'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
858 | - ? self::$_settings[ $addon_name ]['shortcode_fqcns'] |
|
857 | + 'shortcode_fqcns' => isset(self::$_settings[$addon_name]['shortcode_fqcns']) |
|
858 | + ? self::$_settings[$addon_name]['shortcode_fqcns'] |
|
859 | 859 | : array(), |
860 | 860 | ) |
861 | 861 | ); |
@@ -870,10 +870,10 @@ discard block |
||
870 | 870 | */ |
871 | 871 | private static function _register_widgets($addon_name) |
872 | 872 | { |
873 | - if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
873 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
874 | 874 | EE_Register_Widget::register( |
875 | 875 | $addon_name, |
876 | - array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths']) |
|
876 | + array('widget_paths' => self::$_settings[$addon_name]['widget_paths']) |
|
877 | 877 | ); |
878 | 878 | } |
879 | 879 | } |
@@ -886,12 +886,12 @@ discard block |
||
886 | 886 | */ |
887 | 887 | private static function _register_capabilities($addon_name) |
888 | 888 | { |
889 | - if (! empty(self::$_settings[ $addon_name ]['capabilities'])) { |
|
889 | + if ( ! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
890 | 890 | EE_Register_Capabilities::register( |
891 | 891 | $addon_name, |
892 | 892 | array( |
893 | - 'capabilities' => self::$_settings[ $addon_name ]['capabilities'], |
|
894 | - 'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'], |
|
893 | + 'capabilities' => self::$_settings[$addon_name]['capabilities'], |
|
894 | + 'capability_maps' => self::$_settings[$addon_name]['capability_maps'], |
|
895 | 895 | ) |
896 | 896 | ); |
897 | 897 | } |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | */ |
906 | 906 | private static function _register_message_types($addon_name) |
907 | 907 | { |
908 | - if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
908 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
909 | 909 | add_action( |
910 | 910 | 'EE_Brewing_Regular___messages_caf', |
911 | 911 | array('EE_Register_Addon', 'register_message_types') |
@@ -921,15 +921,15 @@ discard block |
||
921 | 921 | */ |
922 | 922 | private static function _register_custom_post_types($addon_name) |
923 | 923 | { |
924 | - if (! empty(self::$_settings[ $addon_name ]['custom_post_types']) |
|
925 | - || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies']) |
|
924 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types']) |
|
925 | + || ! empty(self::$_settings[$addon_name]['custom_taxonomies']) |
|
926 | 926 | ) { |
927 | 927 | EE_Register_CPT::register( |
928 | 928 | $addon_name, |
929 | 929 | array( |
930 | - 'cpts' => self::$_settings[ $addon_name ]['custom_post_types'], |
|
931 | - 'cts' => self::$_settings[ $addon_name ]['custom_taxonomies'], |
|
932 | - 'default_terms' => self::$_settings[ $addon_name ]['default_terms'], |
|
930 | + 'cpts' => self::$_settings[$addon_name]['custom_post_types'], |
|
931 | + 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], |
|
932 | + 'default_terms' => self::$_settings[$addon_name]['default_terms'], |
|
933 | 933 | ) |
934 | 934 | ); |
935 | 935 | } |
@@ -947,10 +947,10 @@ discard block |
||
947 | 947 | */ |
948 | 948 | private static function _register_payment_methods($addon_name) |
949 | 949 | { |
950 | - if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
950 | + if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
951 | 951 | EE_Register_Payment_Method::register( |
952 | 952 | $addon_name, |
953 | - array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths']) |
|
953 | + array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']) |
|
954 | 954 | ); |
955 | 955 | } |
956 | 956 | } |
@@ -967,10 +967,10 @@ discard block |
||
967 | 967 | */ |
968 | 968 | private static function registerPrivacyPolicies($addon_name) |
969 | 969 | { |
970 | - if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) { |
|
970 | + if ( ! empty(self::$_settings[$addon_name]['privacy_policies'])) { |
|
971 | 971 | EE_Register_Privacy_Policy::register( |
972 | 972 | $addon_name, |
973 | - self::$_settings[ $addon_name ]['privacy_policies'] |
|
973 | + self::$_settings[$addon_name]['privacy_policies'] |
|
974 | 974 | ); |
975 | 975 | } |
976 | 976 | } |
@@ -982,10 +982,10 @@ discard block |
||
982 | 982 | */ |
983 | 983 | private static function registerPersonalDataExporters($addon_name) |
984 | 984 | { |
985 | - if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) { |
|
985 | + if ( ! empty(self::$_settings[$addon_name]['personal_data_exporters'])) { |
|
986 | 986 | EE_Register_Personal_Data_Eraser::register( |
987 | 987 | $addon_name, |
988 | - self::$_settings[ $addon_name ]['personal_data_exporters'] |
|
988 | + self::$_settings[$addon_name]['personal_data_exporters'] |
|
989 | 989 | ); |
990 | 990 | } |
991 | 991 | } |
@@ -997,10 +997,10 @@ discard block |
||
997 | 997 | */ |
998 | 998 | private static function registerPersonalDataErasers($addon_name) |
999 | 999 | { |
1000 | - if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) { |
|
1000 | + if ( ! empty(self::$_settings[$addon_name]['personal_data_erasers'])) { |
|
1001 | 1001 | EE_Register_Personal_Data_Eraser::register( |
1002 | 1002 | $addon_name, |
1003 | - self::$_settings[ $addon_name ]['personal_data_erasers'] |
|
1003 | + self::$_settings[$addon_name]['personal_data_erasers'] |
|
1004 | 1004 | ); |
1005 | 1005 | } |
1006 | 1006 | } |
@@ -1021,7 +1021,7 @@ discard block |
||
1021 | 1021 | { |
1022 | 1022 | $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader(); |
1023 | 1023 | $addon = $loader->getShared( |
1024 | - self::$_settings[ $addon_name ]['class_name'], |
|
1024 | + self::$_settings[$addon_name]['class_name'], |
|
1025 | 1025 | array('EE_Registry::create(addon)' => true) |
1026 | 1026 | ); |
1027 | 1027 | // setter inject dep map if required |
@@ -1033,19 +1033,19 @@ discard block |
||
1033 | 1033 | && $addon->domain() === null |
1034 | 1034 | ) { |
1035 | 1035 | // using supplied Domain object |
1036 | - $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface |
|
1037 | - ? self::$_settings[ $addon_name ]['domain'] |
|
1036 | + $domain = self::$_settings[$addon_name]['domain'] instanceof DomainInterface |
|
1037 | + ? self::$_settings[$addon_name]['domain'] |
|
1038 | 1038 | : null; |
1039 | 1039 | // or construct one using Domain FQCN |
1040 | - if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') { |
|
1040 | + if ($domain === null && self::$_settings[$addon_name]['domain_fqcn'] !== '') { |
|
1041 | 1041 | $domain = $loader->getShared( |
1042 | - self::$_settings[ $addon_name ]['domain_fqcn'], |
|
1042 | + self::$_settings[$addon_name]['domain_fqcn'], |
|
1043 | 1043 | array( |
1044 | 1044 | new EventEspresso\core\domain\values\FilePath( |
1045 | - self::$_settings[ $addon_name ]['main_file_path'] |
|
1045 | + self::$_settings[$addon_name]['main_file_path'] |
|
1046 | 1046 | ), |
1047 | 1047 | EventEspresso\core\domain\values\Version::fromString( |
1048 | - self::$_settings[ $addon_name ]['version'] |
|
1048 | + self::$_settings[$addon_name]['version'] |
|
1049 | 1049 | ), |
1050 | 1050 | ) |
1051 | 1051 | ); |
@@ -1055,24 +1055,24 @@ discard block |
||
1055 | 1055 | } |
1056 | 1056 | } |
1057 | 1057 | $addon->set_name($addon_name); |
1058 | - $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']); |
|
1059 | - $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']); |
|
1060 | - $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']); |
|
1061 | - $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']); |
|
1062 | - $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']); |
|
1063 | - $addon->set_version(self::$_settings[ $addon_name ]['version']); |
|
1064 | - $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version'])); |
|
1065 | - $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']); |
|
1066 | - $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']); |
|
1067 | - $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']); |
|
1058 | + $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']); |
|
1059 | + $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']); |
|
1060 | + $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']); |
|
1061 | + $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']); |
|
1062 | + $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']); |
|
1063 | + $addon->set_version(self::$_settings[$addon_name]['version']); |
|
1064 | + $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version'])); |
|
1065 | + $addon->set_config_section(self::$_settings[$addon_name]['config_section']); |
|
1066 | + $addon->set_config_class(self::$_settings[$addon_name]['config_class']); |
|
1067 | + $addon->set_config_name(self::$_settings[$addon_name]['config_name']); |
|
1068 | 1068 | // unfortunately this can't be hooked in upon construction, because we don't have |
1069 | 1069 | // the plugin mainfile's path upon construction. |
1070 | 1070 | register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
1071 | 1071 | // call any additional admin_callback functions during load_admin_controller hook |
1072 | - if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) { |
|
1072 | + if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
1073 | 1073 | add_action( |
1074 | 1074 | 'AHEE__EE_System__load_controllers__load_admin_controllers', |
1075 | - array($addon, self::$_settings[ $addon_name ]['admin_callback']) |
|
1075 | + array($addon, self::$_settings[$addon_name]['admin_callback']) |
|
1076 | 1076 | ); |
1077 | 1077 | } |
1078 | 1078 | return $addon; |
@@ -1090,10 +1090,10 @@ discard block |
||
1090 | 1090 | public static function load_pue_update() |
1091 | 1091 | { |
1092 | 1092 | // load PUE client |
1093 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
1093 | + require_once EE_THIRD_PARTY.'pue'.DS.'pue-client.php'; |
|
1094 | 1094 | // cycle thru settings |
1095 | 1095 | foreach (self::$_settings as $settings) { |
1096 | - if (! empty($settings['pue_options'])) { |
|
1096 | + if ( ! empty($settings['pue_options'])) { |
|
1097 | 1097 | // initiate the class and start the plugin update engine! |
1098 | 1098 | new PluginUpdateEngineChecker( |
1099 | 1099 | // host file URL |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | // plugin slug(s) |
1102 | 1102 | array( |
1103 | 1103 | 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
1104 | - 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
1104 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr'), |
|
1105 | 1105 | ), |
1106 | 1106 | // options |
1107 | 1107 | array( |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | public static function register_message_types() |
1131 | 1131 | { |
1132 | 1132 | foreach (self::$_settings as $addon_name => $settings) { |
1133 | - if (! empty($settings['message_types'])) { |
|
1133 | + if ( ! empty($settings['message_types'])) { |
|
1134 | 1134 | foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) { |
1135 | 1135 | EE_Register_Message_Type::register($message_type, $message_type_settings); |
1136 | 1136 | } |
@@ -1152,70 +1152,70 @@ discard block |
||
1152 | 1152 | */ |
1153 | 1153 | public static function deregister($addon_name = null) |
1154 | 1154 | { |
1155 | - if (isset(self::$_settings[ $addon_name ]['class_name'])) { |
|
1155 | + if (isset(self::$_settings[$addon_name]['class_name'])) { |
|
1156 | 1156 | try { |
1157 | 1157 | do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
1158 | - $class_name = self::$_settings[ $addon_name ]['class_name']; |
|
1159 | - if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
1158 | + $class_name = self::$_settings[$addon_name]['class_name']; |
|
1159 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
1160 | 1160 | // setup DMS |
1161 | 1161 | EE_Register_Data_Migration_Scripts::deregister($addon_name); |
1162 | 1162 | } |
1163 | - if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
1163 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
1164 | 1164 | // register admin page |
1165 | 1165 | EE_Register_Admin_Page::deregister($addon_name); |
1166 | 1166 | } |
1167 | - if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
1167 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
1168 | 1168 | // add to list of modules to be registered |
1169 | 1169 | EE_Register_Module::deregister($addon_name); |
1170 | 1170 | } |
1171 | - if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
1172 | - || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
1171 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths']) |
|
1172 | + || ! empty(self::$_settings[$addon_name]['shortcode_fqcns']) |
|
1173 | 1173 | ) { |
1174 | 1174 | // add to list of shortcodes to be registered |
1175 | 1175 | EE_Register_Shortcode::deregister($addon_name); |
1176 | 1176 | } |
1177 | - if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
1177 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
1178 | 1178 | // if config_class present let's register config. |
1179 | - EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']); |
|
1179 | + EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']); |
|
1180 | 1180 | } |
1181 | - if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
1181 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
1182 | 1182 | // add to list of widgets to be registered |
1183 | 1183 | EE_Register_Widget::deregister($addon_name); |
1184 | 1184 | } |
1185 | - if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
1186 | - || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
1185 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) |
|
1186 | + || ! empty(self::$_settings[$addon_name]['class_paths']) |
|
1187 | 1187 | ) { |
1188 | 1188 | // add to list of shortcodes to be registered |
1189 | 1189 | EE_Register_Model::deregister($addon_name); |
1190 | 1190 | } |
1191 | - if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
1192 | - || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
1191 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
1192 | + || ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
1193 | 1193 | ) { |
1194 | 1194 | // add to list of shortcodes to be registered |
1195 | 1195 | EE_Register_Model_Extensions::deregister($addon_name); |
1196 | 1196 | } |
1197 | - if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
1198 | - foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) { |
|
1197 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
1198 | + foreach ((array) self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) { |
|
1199 | 1199 | EE_Register_Message_Type::deregister($message_type); |
1200 | 1200 | } |
1201 | 1201 | } |
1202 | 1202 | // deregister capabilities for addon |
1203 | - if (! empty(self::$_settings[ $addon_name ]['capabilities']) |
|
1204 | - || ! empty(self::$_settings[ $addon_name ]['capability_maps']) |
|
1203 | + if ( ! empty(self::$_settings[$addon_name]['capabilities']) |
|
1204 | + || ! empty(self::$_settings[$addon_name]['capability_maps']) |
|
1205 | 1205 | ) { |
1206 | 1206 | EE_Register_Capabilities::deregister($addon_name); |
1207 | 1207 | } |
1208 | 1208 | // deregister custom_post_types for addon |
1209 | - if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) { |
|
1209 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
1210 | 1210 | EE_Register_CPT::deregister($addon_name); |
1211 | 1211 | } |
1212 | - if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
1212 | + if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
1213 | 1213 | EE_Register_Payment_Method::deregister($addon_name); |
1214 | 1214 | } |
1215 | 1215 | $addon = EE_Registry::instance()->getAddon($class_name); |
1216 | 1216 | if ($addon instanceof EE_Addon) { |
1217 | 1217 | remove_action( |
1218 | - 'deactivate_' . $addon->get_main_plugin_file_basename(), |
|
1218 | + 'deactivate_'.$addon->get_main_plugin_file_basename(), |
|
1219 | 1219 | array($addon, 'deactivation') |
1220 | 1220 | ); |
1221 | 1221 | remove_action( |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | } catch (Exception $e) { |
1239 | 1239 | new ExceptionLogger($e); |
1240 | 1240 | } |
1241 | - unset(self::$_settings[ $addon_name ]); |
|
1241 | + unset(self::$_settings[$addon_name]); |
|
1242 | 1242 | do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name); |
1243 | 1243 | } |
1244 | 1244 | } |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | ?> |
8 | 8 | <h2><?php esc_html_e('Event Registration Data', 'event_espresso'); ?></h2> |
9 | 9 | <p><?php |
10 | - esc_html_e( |
|
11 | - 'We collect information about you during event registration. This information may include but is not limited to:', |
|
12 | - 'event_espresso' |
|
13 | - ); ?></p> |
|
10 | + esc_html_e( |
|
11 | + 'We collect information about you during event registration. This information may include but is not limited to:', |
|
12 | + 'event_espresso' |
|
13 | + ); ?></p> |
|
14 | 14 | <ul> |
15 | 15 | <li><?php esc_html_e('Your names', 'event_espresso'); ?></li> |
16 | 16 | <li><?php esc_html_e('Billing address', 'event_espresso'); ?></li> |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | <li><?php esc_html_e('Phone number', 'event_espresso'); ?></li> |
20 | 20 | <li><?php esc_html_e('Location and traffic data (including IP address and browser type)', 'event_espresso'); ?></li> |
21 | 21 | <li><?php |
22 | - esc_html_e( |
|
23 | - 'Any other details that might be requested from you for the purpose of processing your registration or ticket purchase', |
|
24 | - 'event_espresso' |
|
25 | - ); ?></li> |
|
22 | + esc_html_e( |
|
23 | + 'Any other details that might be requested from you for the purpose of processing your registration or ticket purchase', |
|
24 | + 'event_espresso' |
|
25 | + ); ?></li> |
|
26 | 26 | </ul> |
27 | 27 | |
28 | 28 | <p><?php esc_html_e('Handling this data also allows us to:', 'event_espresso'); ?></p> |
@@ -30,103 +30,103 @@ discard block |
||
30 | 30 | <li><?php esc_html_e('Send you important account/purchase/service information.', 'event_espresso'); ?></li> |
31 | 31 | <li><?php esc_html_e('Respond to your queries, refund requests, or complaints.', 'event_espresso'); ?></li> |
32 | 32 | <li><?php |
33 | - esc_html_e( |
|
34 | - 'Process payments and prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', |
|
35 | - 'event_espresso' |
|
36 | - ); ?></li> |
|
33 | + esc_html_e( |
|
34 | + 'Process payments and prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', |
|
35 | + 'event_espresso' |
|
36 | + ); ?></li> |
|
37 | 37 | <li><?php |
38 | - esc_html_e( |
|
39 | - 'Set up and administer your account, provide technical and customer support, and to verify your identity.', |
|
40 | - 'event_espresso' |
|
41 | - ); ?></li> |
|
38 | + esc_html_e( |
|
39 | + 'Set up and administer your account, provide technical and customer support, and to verify your identity.', |
|
40 | + 'event_espresso' |
|
41 | + ); ?></li> |
|
42 | 42 | </ul> |
43 | 43 | |
44 | 44 | <?php if (! empty($active_onsite_payment_methods) || ! empty($active_offsite_payment_methods)) { ?> |
45 | 45 | <h2><?php esc_html_e('Billing Information', 'event_espresso'); ?> </h2> |
46 | 46 | <?php |
47 | 47 | // if onsite or offsite payment methods are active |
48 | - if (! empty($active_onsite_payment_methods)) { ?> |
|
48 | + if (! empty($active_onsite_payment_methods)) { ?> |
|
49 | 49 | <p><?php |
50 | - esc_html_e( |
|
51 | - 'In order to process payments, we collect billing information on-site. Sensitive billing information is not stored on our server, but may be handled while in-transit to the payment processing server.', |
|
52 | - 'event_espresso' |
|
53 | - ); ?></p> |
|
50 | + esc_html_e( |
|
51 | + 'In order to process payments, we collect billing information on-site. Sensitive billing information is not stored on our server, but may be handled while in-transit to the payment processing server.', |
|
52 | + 'event_espresso' |
|
53 | + ); ?></p> |
|
54 | 54 | <p><?php |
55 | - printf( |
|
56 | - esc_html_x( |
|
57 | - 'Please see the privacy policy of %1$s.', |
|
58 | - 'Please see the privacy policy of PayPal Pro', |
|
59 | - 'event_espresso' |
|
60 | - ), |
|
61 | - implode( |
|
62 | - ', ', |
|
63 | - array_merge( |
|
64 | - $active_onsite_payment_methods, |
|
65 | - $active_offsite_payment_methods |
|
66 | - ) |
|
67 | - ) |
|
68 | - ); ?></p> |
|
55 | + printf( |
|
56 | + esc_html_x( |
|
57 | + 'Please see the privacy policy of %1$s.', |
|
58 | + 'Please see the privacy policy of PayPal Pro', |
|
59 | + 'event_espresso' |
|
60 | + ), |
|
61 | + implode( |
|
62 | + ', ', |
|
63 | + array_merge( |
|
64 | + $active_onsite_payment_methods, |
|
65 | + $active_offsite_payment_methods |
|
66 | + ) |
|
67 | + ) |
|
68 | + ); ?></p> |
|
69 | 69 | <p><?php |
70 | - esc_html_e( |
|
71 | - 'Masked billing information may be stored on our servers (eg only the last 4 digits of credit card numbers are stored: **** **** **** 1234).', |
|
72 | - 'event_espresso' |
|
73 | - ); ?></p> |
|
70 | + esc_html_e( |
|
71 | + 'Masked billing information may be stored on our servers (eg only the last 4 digits of credit card numbers are stored: **** **** **** 1234).', |
|
72 | + 'event_espresso' |
|
73 | + ); ?></p> |
|
74 | 74 | <?php } // IF OFFSITE PAYMENT METHOD ACTIVE |
75 | - elseif (! empty($active_onsite_payment_methods)) { ?> |
|
75 | + elseif (! empty($active_onsite_payment_methods)) { ?> |
|
76 | 76 | <p><?php |
77 | - printf( |
|
78 | - esc_html_x( |
|
79 | - 'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of %1$s.', |
|
80 | - 'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of PayPal Pro.', |
|
81 | - 'event_espresso' |
|
82 | - ), |
|
83 | - implode(', ', $active_offsite_payment_methods) |
|
84 | - ); ?></p> |
|
77 | + printf( |
|
78 | + esc_html_x( |
|
79 | + 'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of %1$s.', |
|
80 | + 'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of PayPal Pro.', |
|
81 | + 'event_espresso' |
|
82 | + ), |
|
83 | + implode(', ', $active_offsite_payment_methods) |
|
84 | + ); ?></p> |
|
85 | 85 | <?php } ?> |
86 | 86 | <h2><?php esc_html_e('Payment Logging', 'event_espresso'); ?></h2> |
87 | 87 | <p><?php |
88 | - esc_html_e( |
|
89 | - 'Site administrators may keep a log of communications with the payment processors in order to verify payments are being processed correctly. These logs are automatically deleted after a week.', |
|
90 | - 'event_espresso' |
|
91 | - ); ?></p> |
|
88 | + esc_html_e( |
|
89 | + 'Site administrators may keep a log of communications with the payment processors in order to verify payments are being processed correctly. These logs are automatically deleted after a week.', |
|
90 | + 'event_espresso' |
|
91 | + ); ?></p> |
|
92 | 92 | <?php } ?> |
93 | 93 | |
94 | 94 | <h2><?php esc_html_e('Event Registration Cookies', 'event_espresso'); ?></h2> |
95 | 95 | <p><?php |
96 | - printf( |
|
97 | - esc_html_x( |
|
98 | - 'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts %1$s.', |
|
99 | - 'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts 2 hours.', |
|
100 | - 'event_espresso' |
|
101 | - ), |
|
102 | - $session_lifespan |
|
103 | - ); ?></p> |
|
96 | + printf( |
|
97 | + esc_html_x( |
|
98 | + 'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts %1$s.', |
|
99 | + 'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts 2 hours.', |
|
100 | + 'event_espresso' |
|
101 | + ), |
|
102 | + $session_lifespan |
|
103 | + ); ?></p> |
|
104 | 104 | |
105 | 105 | <h2><?php esc_html_e('Email History Data', 'event_espresso'); ?></h2> |
106 | 106 | <p><?php |
107 | - esc_html_e( |
|
108 | - 'We keep a record of the emails sent to you. This is to ensure communication is successfully sent and its information is accurate.', |
|
109 | - 'event_espresso' |
|
110 | - ); ?></p> |
|
107 | + esc_html_e( |
|
108 | + 'We keep a record of the emails sent to you. This is to ensure communication is successfully sent and its information is accurate.', |
|
109 | + 'event_espresso' |
|
110 | + ); ?></p> |
|
111 | 111 | |
112 | 112 | <h2><?php esc_html_e('Event Check-In Record', 'event_espresso'); ?></h2> |
113 | 113 | <p><?php |
114 | - esc_html_e( |
|
115 | - 'When you attend an event, an event manager may record the time you check in or out of the event.', |
|
116 | - 'event_espresso' |
|
117 | - ); ?></p> |
|
114 | + esc_html_e( |
|
115 | + 'When you attend an event, an event manager may record the time you check in or out of the event.', |
|
116 | + 'event_espresso' |
|
117 | + ); ?></p> |
|
118 | 118 | |
119 | 119 | <h2><?php esc_html_e('Event Registration Data Retention', 'event_espresso'); ?></h2> |
120 | 120 | <p><?php |
121 | - esc_html_e( |
|
122 | - 'Personal data is stored at least until the date of the event, and may be kept indefinitely in case of future registrations.', |
|
123 | - 'event_espresso' |
|
124 | - ); ?></p> |
|
121 | + esc_html_e( |
|
122 | + 'Personal data is stored at least until the date of the event, and may be kept indefinitely in case of future registrations.', |
|
123 | + 'event_espresso' |
|
124 | + ); ?></p> |
|
125 | 125 | |
126 | 126 | <h2><?php esc_html_e('Event Registration Data Erasure and Export', 'event_espresso'); ?></h2> |
127 | 127 | <p><?php |
128 | - esc_html_e( |
|
129 | - 'You have the right to request your personal data be sent to you electronically, and the right to request your registration data be erased after the event. To do so, please contact the event manager or site administrator.', |
|
130 | - 'event_espresso' |
|
131 | - ); ?></p> |
|
128 | + esc_html_e( |
|
129 | + 'You have the right to request your personal data be sent to you electronically, and the right to request your registration data be erased after the event. To do so, please contact the event manager or site administrator.', |
|
130 | + 'event_espresso' |
|
131 | + ); ?></p> |
|
132 | 132 |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | ); ?></li> |
42 | 42 | </ul> |
43 | 43 | |
44 | -<?php if (! empty($active_onsite_payment_methods) || ! empty($active_offsite_payment_methods)) { ?> |
|
44 | +<?php if ( ! empty($active_onsite_payment_methods) || ! empty($active_offsite_payment_methods)) { ?> |
|
45 | 45 | <h2><?php esc_html_e('Billing Information', 'event_espresso'); ?> </h2> |
46 | 46 | <?php |
47 | 47 | // if onsite or offsite payment methods are active |
48 | - if (! empty($active_onsite_payment_methods)) { ?> |
|
48 | + if ( ! empty($active_onsite_payment_methods)) { ?> |
|
49 | 49 | <p><?php |
50 | 50 | esc_html_e( |
51 | 51 | 'In order to process payments, we collect billing information on-site. Sensitive billing information is not stored on our server, but may be handled while in-transit to the payment processing server.', |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | 'event_espresso' |
73 | 73 | ); ?></p> |
74 | 74 | <?php } // IF OFFSITE PAYMENT METHOD ACTIVE |
75 | - elseif (! empty($active_onsite_payment_methods)) { ?> |
|
75 | + elseif ( ! empty($active_onsite_payment_methods)) { ?> |
|
76 | 76 | <p><?php |
77 | 77 | printf( |
78 | 78 | esc_html_x( |
@@ -33,7 +33,6 @@ |
||
33 | 33 | /** |
34 | 34 | * For all the registered `PrivacyPolicyInterface`s, add their privacy policy content |
35 | 35 | * |
36 | - * @param WP_Post $post |
|
37 | 36 | */ |
38 | 37 | public function addPrivacyPolicy() |
39 | 38 | { |
@@ -24,64 +24,64 @@ |
||
24 | 24 | class PrivacyPolicyManager |
25 | 25 | { |
26 | 26 | |
27 | - public function __construct() |
|
28 | - { |
|
29 | - add_action('admin_init', array($this, 'addPrivacyPolicy'), 9); |
|
30 | - } |
|
27 | + public function __construct() |
|
28 | + { |
|
29 | + add_action('admin_init', array($this, 'addPrivacyPolicy'), 9); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * For all the registered `PrivacyPolicyInterface`s, add their privacy policy content |
|
35 | - * |
|
36 | - * @param WP_Post $post |
|
37 | - */ |
|
38 | - public function addPrivacyPolicy() |
|
39 | - { |
|
40 | - $policy_page_id = (int) get_option('wp_page_for_privacy_policy'); |
|
41 | - if (! $policy_page_id) { |
|
42 | - return; |
|
43 | - } |
|
44 | - // load all the privacy policy stuff |
|
45 | - // add post policy text |
|
46 | - foreach ($this->loadPrivacyPolicyCollection() as $privacy_policy) { |
|
47 | - wp_add_privacy_policy_content($privacy_policy->getName(), $privacy_policy->getContent()); |
|
48 | - } |
|
49 | - } |
|
33 | + /** |
|
34 | + * For all the registered `PrivacyPolicyInterface`s, add their privacy policy content |
|
35 | + * |
|
36 | + * @param WP_Post $post |
|
37 | + */ |
|
38 | + public function addPrivacyPolicy() |
|
39 | + { |
|
40 | + $policy_page_id = (int) get_option('wp_page_for_privacy_policy'); |
|
41 | + if (! $policy_page_id) { |
|
42 | + return; |
|
43 | + } |
|
44 | + // load all the privacy policy stuff |
|
45 | + // add post policy text |
|
46 | + foreach ($this->loadPrivacyPolicyCollection() as $privacy_policy) { |
|
47 | + wp_add_privacy_policy_content($privacy_policy->getName(), $privacy_policy->getContent()); |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @return CollectionInterface|PrivacyPolicyInterface[] |
|
54 | - * @throws InvalidIdentifierException |
|
55 | - * @throws InvalidInterfaceException |
|
56 | - * @throws InvalidFilePathException |
|
57 | - * @throws InvalidEntityException |
|
58 | - * @throws InvalidDataTypeException |
|
59 | - * @throws InvalidClassException |
|
60 | - */ |
|
61 | - protected function loadPrivacyPolicyCollection() |
|
62 | - { |
|
63 | - $loader = new CollectionLoader( |
|
64 | - new CollectionDetails( |
|
65 | - // collection name |
|
66 | - 'privacy_policies', |
|
67 | - // collection interface |
|
68 | - 'EventEspresso\core\services\privacy\policy\PrivacyPolicyInterface', |
|
69 | - // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
70 | - apply_filters( |
|
71 | - 'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
|
72 | - array('EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy') |
|
73 | - ), |
|
74 | - // filepaths to classes to add |
|
75 | - array(), |
|
76 | - // file mask to use if parsing folder for files to add |
|
77 | - '', |
|
78 | - // what to use as identifier for collection entities |
|
79 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
80 | - CollectionDetails::ID_CLASS_NAME |
|
81 | - ) |
|
82 | - ); |
|
83 | - return $loader->getCollection(); |
|
84 | - } |
|
52 | + /** |
|
53 | + * @return CollectionInterface|PrivacyPolicyInterface[] |
|
54 | + * @throws InvalidIdentifierException |
|
55 | + * @throws InvalidInterfaceException |
|
56 | + * @throws InvalidFilePathException |
|
57 | + * @throws InvalidEntityException |
|
58 | + * @throws InvalidDataTypeException |
|
59 | + * @throws InvalidClassException |
|
60 | + */ |
|
61 | + protected function loadPrivacyPolicyCollection() |
|
62 | + { |
|
63 | + $loader = new CollectionLoader( |
|
64 | + new CollectionDetails( |
|
65 | + // collection name |
|
66 | + 'privacy_policies', |
|
67 | + // collection interface |
|
68 | + 'EventEspresso\core\services\privacy\policy\PrivacyPolicyInterface', |
|
69 | + // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
70 | + apply_filters( |
|
71 | + 'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
|
72 | + array('EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy') |
|
73 | + ), |
|
74 | + // filepaths to classes to add |
|
75 | + array(), |
|
76 | + // file mask to use if parsing folder for files to add |
|
77 | + '', |
|
78 | + // what to use as identifier for collection entities |
|
79 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
80 | + CollectionDetails::ID_CLASS_NAME |
|
81 | + ) |
|
82 | + ); |
|
83 | + return $loader->getCollection(); |
|
84 | + } |
|
85 | 85 | } |
86 | 86 | // End of file PrivacyPolicyManager.php |
87 | 87 | // Location: EventEspresso\core\domain\services\admin/PrivacyPolicyManager.php |
@@ -38,7 +38,7 @@ |
||
38 | 38 | public function addPrivacyPolicy() |
39 | 39 | { |
40 | 40 | $policy_page_id = (int) get_option('wp_page_for_privacy_policy'); |
41 | - if (! $policy_page_id) { |
|
41 | + if ( ! $policy_page_id) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | // load all the privacy policy stuff |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - 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 | - ); ?> |
|
52 | + 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 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
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.4.0'); |
|
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 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.62.rc.057'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.62.rc.057'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |