@@ -20,18 +20,18 @@ |
||
20 | 20 | */ |
21 | 21 | public function __construct($pm_instance = null) |
22 | 22 | { |
23 | - require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php'); |
|
23 | + require_once($this->file_folder().'EEG_Paypal_Express.gateway.php'); |
|
24 | 24 | $this->_gateway = new EEG_Paypal_Express(); |
25 | 25 | |
26 | 26 | $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso'); |
27 | - $this->_template_path = $this->file_folder() . 'templates/'; |
|
27 | + $this->_template_path = $this->file_folder().'templates/'; |
|
28 | 28 | $this->_default_description = esc_html__( |
29 | 29 | // @codingStandardsIgnoreStart |
30 | 30 | 'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.', |
31 | 31 | // @codingStandardsIgnoreEnd |
32 | 32 | 'event_espresso' |
33 | 33 | ); |
34 | - $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png'; |
|
34 | + $this->_default_button_url = $this->file_url().'lib/paypal-express-checkout-logo-gold-160.png'; |
|
35 | 35 | |
36 | 36 | parent::__construct($pm_instance); |
37 | 37 | } |
@@ -14,89 +14,89 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_PMT_Paypal_Express extends EE_PMT_Base |
16 | 16 | { |
17 | - /** |
|
18 | - * EE_PMT_Paypal_Express constructor. |
|
19 | - */ |
|
20 | - public function __construct($pm_instance = null) |
|
21 | - { |
|
22 | - require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php'); |
|
23 | - $this->_gateway = new EEG_Paypal_Express(); |
|
17 | + /** |
|
18 | + * EE_PMT_Paypal_Express constructor. |
|
19 | + */ |
|
20 | + public function __construct($pm_instance = null) |
|
21 | + { |
|
22 | + require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php'); |
|
23 | + $this->_gateway = new EEG_Paypal_Express(); |
|
24 | 24 | |
25 | - $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso'); |
|
26 | - $this->_template_path = $this->file_folder() . 'templates/'; |
|
27 | - $this->_default_description = esc_html__( |
|
28 | - // @codingStandardsIgnoreStart |
|
29 | - 'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.', |
|
30 | - // @codingStandardsIgnoreEnd |
|
31 | - 'event_espresso' |
|
32 | - ); |
|
33 | - $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png'; |
|
25 | + $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso'); |
|
26 | + $this->_template_path = $this->file_folder() . 'templates/'; |
|
27 | + $this->_default_description = esc_html__( |
|
28 | + // @codingStandardsIgnoreStart |
|
29 | + 'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.', |
|
30 | + // @codingStandardsIgnoreEnd |
|
31 | + 'event_espresso' |
|
32 | + ); |
|
33 | + $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png'; |
|
34 | 34 | |
35 | - parent::__construct($pm_instance); |
|
36 | - } |
|
35 | + parent::__construct($pm_instance); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Adds the help tab. |
|
41 | - * |
|
42 | - * @see EE_PMT_Base::help_tabs_config() |
|
43 | - * @return array |
|
44 | - */ |
|
45 | - public function help_tabs_config() |
|
46 | - { |
|
47 | - return array( |
|
48 | - $this->get_help_tab_name() => array( |
|
49 | - 'title' => esc_html__('PayPal Express Settings', 'event_espresso'), |
|
50 | - 'filename' => 'payment_methods_overview_paypal_express' |
|
51 | - ) |
|
52 | - ); |
|
53 | - } |
|
39 | + /** |
|
40 | + * Adds the help tab. |
|
41 | + * |
|
42 | + * @see EE_PMT_Base::help_tabs_config() |
|
43 | + * @return array |
|
44 | + */ |
|
45 | + public function help_tabs_config() |
|
46 | + { |
|
47 | + return array( |
|
48 | + $this->get_help_tab_name() => array( |
|
49 | + 'title' => esc_html__('PayPal Express Settings', 'event_espresso'), |
|
50 | + 'filename' => 'payment_methods_overview_paypal_express' |
|
51 | + ) |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Gets the form for all the settings related to this payment method type. |
|
58 | - * |
|
59 | - * @return EE_Payment_Method_Form |
|
60 | - */ |
|
61 | - public function generate_new_settings_form() |
|
62 | - { |
|
63 | - return new SettingsForm(array(), $this->get_help_tab_link()); |
|
64 | - } |
|
56 | + /** |
|
57 | + * Gets the form for all the settings related to this payment method type. |
|
58 | + * |
|
59 | + * @return EE_Payment_Method_Form |
|
60 | + */ |
|
61 | + public function generate_new_settings_form() |
|
62 | + { |
|
63 | + return new SettingsForm(array(), $this->get_help_tab_link()); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * Creates a billing form for this payment method type. |
|
69 | - * |
|
70 | - * @param \EE_Transaction $transaction |
|
71 | - * @return \EE_Billing_Info_Form |
|
72 | - */ |
|
73 | - public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
74 | - { |
|
75 | - if ($this->_pm_instance->debug_mode()) { |
|
76 | - $form = new EE_Billing_Info_Form( |
|
77 | - $this->_pm_instance, |
|
78 | - array( |
|
79 | - 'name' => 'paypal_express_Info_Form', |
|
80 | - 'subsections' => array( |
|
81 | - 'paypal_express_debug_info' => new EE_Form_Section_Proper( |
|
82 | - array( |
|
83 | - 'layout_strategy' => new EE_Template_Layout( |
|
84 | - array( |
|
85 | - 'layout_template_file' => $this->_template_path |
|
86 | - . 'paypal_express_debug_info.template.php', |
|
87 | - 'template_args' => array( |
|
88 | - 'debug_mode' => $this->_pm_instance->debug_mode() |
|
89 | - ) |
|
90 | - ) |
|
91 | - ) |
|
92 | - ) |
|
93 | - ) |
|
94 | - ) |
|
95 | - ) |
|
96 | - ); |
|
97 | - return $form; |
|
98 | - } |
|
67 | + /** |
|
68 | + * Creates a billing form for this payment method type. |
|
69 | + * |
|
70 | + * @param \EE_Transaction $transaction |
|
71 | + * @return \EE_Billing_Info_Form |
|
72 | + */ |
|
73 | + public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
74 | + { |
|
75 | + if ($this->_pm_instance->debug_mode()) { |
|
76 | + $form = new EE_Billing_Info_Form( |
|
77 | + $this->_pm_instance, |
|
78 | + array( |
|
79 | + 'name' => 'paypal_express_Info_Form', |
|
80 | + 'subsections' => array( |
|
81 | + 'paypal_express_debug_info' => new EE_Form_Section_Proper( |
|
82 | + array( |
|
83 | + 'layout_strategy' => new EE_Template_Layout( |
|
84 | + array( |
|
85 | + 'layout_template_file' => $this->_template_path |
|
86 | + . 'paypal_express_debug_info.template.php', |
|
87 | + 'template_args' => array( |
|
88 | + 'debug_mode' => $this->_pm_instance->debug_mode() |
|
89 | + ) |
|
90 | + ) |
|
91 | + ) |
|
92 | + ) |
|
93 | + ) |
|
94 | + ) |
|
95 | + ) |
|
96 | + ); |
|
97 | + return $form; |
|
98 | + } |
|
99 | 99 | |
100 | - return false; |
|
101 | - } |
|
100 | + return false; |
|
101 | + } |
|
102 | 102 | } |
@@ -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/'); |
|
23 | - define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/'); |
|
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/'); |
|
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/'); |
|
23 | + define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets/'); |
|
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/'); |
|
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 | ); |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | // update the existing related questions |
710 | 710 | // BUT FIRST... delete the phone question from the Question_Group_Question |
711 | 711 | // if it is being added to this question group (therefore removed from the existing group) |
712 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) { |
|
712 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) { |
|
713 | 713 | // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
714 | 714 | EEM_Question_Group_Question::instance()->delete( |
715 | 715 | array( |
@@ -724,22 +724,22 @@ discard block |
||
724 | 724 | $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
725 | 725 | $questions = $question_group->questions(); |
726 | 726 | // make sure system phone question is added to list of questions for this group |
727 | - if (! isset($questions[ $phone_question_id ])) { |
|
728 | - $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
727 | + if ( ! isset($questions[$phone_question_id])) { |
|
728 | + $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | foreach ($questions as $question_ID => $question) { |
732 | 732 | // first we always check for order. |
733 | - if (! empty($this->_req_data['question_orders'][ $question_ID ])) { |
|
733 | + if ( ! empty($this->_req_data['question_orders'][$question_ID])) { |
|
734 | 734 | // update question order |
735 | 735 | $question_group->update_question_order( |
736 | 736 | $question_ID, |
737 | - $this->_req_data['question_orders'][ $question_ID ] |
|
737 | + $this->_req_data['question_orders'][$question_ID] |
|
738 | 738 | ); |
739 | 739 | } |
740 | 740 | |
741 | 741 | // then we always check if adding or removing. |
742 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) { |
|
742 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) { |
|
743 | 743 | $question_group->add_question($question_ID); |
744 | 744 | } else { |
745 | 745 | // not found, remove it (but only if not a system question for the personal group |
@@ -760,8 +760,8 @@ discard block |
||
760 | 760 | if (isset($this->_req_data['questions'])) { |
761 | 761 | foreach ($this->_req_data['questions'] as $QST_ID) { |
762 | 762 | $question_group->add_question($QST_ID); |
763 | - if (isset($this->_req_data['question_orders'][ $QST_ID ])) { |
|
764 | - $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]); |
|
763 | + if (isset($this->_req_data['question_orders'][$QST_ID])) { |
|
764 | + $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]); |
|
765 | 765 | } |
766 | 766 | } |
767 | 767 | } |
@@ -902,33 +902,33 @@ discard block |
||
902 | 902 | // echo "trash $trash"; |
903 | 903 | // var_dump($this->_req_data['checkbox']);die; |
904 | 904 | if (isset($this->_req_data['checkbox'])) { |
905 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
905 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
906 | 906 | // if array has more than one element than success message should be plural |
907 | 907 | $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
908 | 908 | // cycle thru bulk action checkboxes |
909 | 909 | while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
910 | - if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
910 | + if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
911 | 911 | $success = 0; |
912 | 912 | } |
913 | 913 | } |
914 | 914 | } else { |
915 | 915 | // grab single id and delete |
916 | 916 | $ID = absint($this->_req_data['checkbox']); |
917 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
917 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
918 | 918 | $success = 0; |
919 | 919 | } |
920 | 920 | } |
921 | 921 | } else { |
922 | 922 | // delete via trash link |
923 | 923 | // grab single id and delete |
924 | - $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
925 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
924 | + $ID = absint($this->_req_data[$model->primary_key_name()]); |
|
925 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
926 | 926 | $success = 0; |
927 | 927 | } |
928 | 928 | } |
929 | 929 | |
930 | 930 | |
931 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) ); |
|
931 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups'; // strtolower( $model->item_name(2) ); |
|
932 | 932 | // echo "action :$action"; |
933 | 933 | // $action = 'questions' ? 'default' : $action; |
934 | 934 | if ($trash) { |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | ? (int) $this->_req_data['curpage'] |
1049 | 1049 | : null; |
1050 | 1050 | |
1051 | - if (! empty($row_ids)) { |
|
1051 | + if ( ! empty($row_ids)) { |
|
1052 | 1052 | // figure out where we start the row_id count at for the current page. |
1053 | 1053 | $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
1054 | 1054 | |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | // Update the questions when re-ordering |
1058 | 1058 | $updated = EEM_Question_Group::instance()->update( |
1059 | 1059 | array('QSG_order' => $qsgcount), |
1060 | - array(array('QSG_ID' => $row_ids[ $i ])) |
|
1060 | + array(array('QSG_ID' => $row_ids[$i])) |
|
1061 | 1061 | ); |
1062 | 1062 | if ($updated === false) { |
1063 | 1063 | $success = false; |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | $this->_set_add_edit_form_tags('update_reg_form_settings'); |
1104 | 1104 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
1105 | 1105 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
1106 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
1106 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php', |
|
1107 | 1107 | $this->_template_args, |
1108 | 1108 | true |
1109 | 1109 | ); |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | $prev_email_validation_level = 'basic'; |
1241 | 1241 | } |
1242 | 1242 | // confirm our i18n email validation will work on the server |
1243 | - if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1243 | + if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1244 | 1244 | // or reset email validation level to previous value |
1245 | 1245 | $email_validation_level = $prev_email_validation_level; |
1246 | 1246 | } |
@@ -1286,7 +1286,7 @@ discard block |
||
1286 | 1286 | private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
1287 | 1287 | { |
1288 | 1288 | // first check that PCRE is enabled |
1289 | - if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1289 | + if ( ! defined('PREG_BAD_UTF8_ERROR')) { |
|
1290 | 1290 | EE_Error::add_error( |
1291 | 1291 | sprintf( |
1292 | 1292 | esc_html__( |
@@ -13,1433 +13,1433 @@ |
||
13 | 13 | */ |
14 | 14 | class Extend_Registration_Form_Admin_Page extends Registration_Form_Admin_Page |
15 | 15 | { |
16 | - /** |
|
17 | - * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
18 | - */ |
|
19 | - public function __construct($routing = true) |
|
20 | - { |
|
21 | - define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/'); |
|
22 | - define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/'); |
|
23 | - define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
24 | - define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/'); |
|
25 | - define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
26 | - parent::__construct($routing); |
|
27 | - } |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - protected function _extend_page_config() |
|
34 | - { |
|
35 | - $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
|
36 | - $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) |
|
37 | - ? $this->_req_data['QST_ID'] : 0; |
|
38 | - $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) |
|
39 | - ? $this->_req_data['QSG_ID'] : 0; |
|
40 | - |
|
41 | - $new_page_routes = array( |
|
42 | - 'question_groups' => array( |
|
43 | - 'func' => '_question_groups_overview_list_table', |
|
44 | - 'capability' => 'ee_read_question_groups', |
|
45 | - ), |
|
46 | - 'add_question' => array( |
|
47 | - 'func' => '_edit_question', |
|
48 | - 'capability' => 'ee_edit_questions', |
|
49 | - ), |
|
50 | - 'insert_question' => array( |
|
51 | - 'func' => '_insert_or_update_question', |
|
52 | - 'args' => array('new_question' => true), |
|
53 | - 'capability' => 'ee_edit_questions', |
|
54 | - 'noheader' => true, |
|
55 | - ), |
|
56 | - 'duplicate_question' => array( |
|
57 | - 'func' => '_duplicate_question', |
|
58 | - 'capability' => 'ee_edit_questions', |
|
59 | - 'noheader' => true, |
|
60 | - ), |
|
61 | - 'trash_question' => array( |
|
62 | - 'func' => '_trash_question', |
|
63 | - 'capability' => 'ee_delete_question', |
|
64 | - 'obj_id' => $qst_id, |
|
65 | - 'noheader' => true, |
|
66 | - ), |
|
67 | - |
|
68 | - 'restore_question' => array( |
|
69 | - 'func' => '_trash_or_restore_questions', |
|
70 | - 'capability' => 'ee_delete_question', |
|
71 | - 'obj_id' => $qst_id, |
|
72 | - 'args' => array('trash' => false), |
|
73 | - 'noheader' => true, |
|
74 | - ), |
|
75 | - |
|
76 | - 'delete_question' => array( |
|
77 | - 'func' => '_delete_question', |
|
78 | - 'capability' => 'ee_delete_question', |
|
79 | - 'obj_id' => $qst_id, |
|
80 | - 'noheader' => true, |
|
81 | - ), |
|
82 | - |
|
83 | - 'trash_questions' => array( |
|
84 | - 'func' => '_trash_or_restore_questions', |
|
85 | - 'capability' => 'ee_delete_questions', |
|
86 | - 'args' => array('trash' => true), |
|
87 | - 'noheader' => true, |
|
88 | - ), |
|
89 | - |
|
90 | - 'restore_questions' => array( |
|
91 | - 'func' => '_trash_or_restore_questions', |
|
92 | - 'capability' => 'ee_delete_questions', |
|
93 | - 'args' => array('trash' => false), |
|
94 | - 'noheader' => true, |
|
95 | - ), |
|
96 | - |
|
97 | - 'delete_questions' => array( |
|
98 | - 'func' => '_delete_questions', |
|
99 | - 'args' => array(), |
|
100 | - 'capability' => 'ee_delete_questions', |
|
101 | - 'noheader' => true, |
|
102 | - ), |
|
103 | - |
|
104 | - 'add_question_group' => array( |
|
105 | - 'func' => '_edit_question_group', |
|
106 | - 'capability' => 'ee_edit_question_groups', |
|
107 | - ), |
|
108 | - |
|
109 | - 'edit_question_group' => array( |
|
110 | - 'func' => '_edit_question_group', |
|
111 | - 'capability' => 'ee_edit_question_group', |
|
112 | - 'obj_id' => $qsg_id, |
|
113 | - 'args' => array('edit'), |
|
114 | - ), |
|
115 | - |
|
116 | - 'delete_question_groups' => array( |
|
117 | - 'func' => '_delete_question_groups', |
|
118 | - 'capability' => 'ee_delete_question_groups', |
|
119 | - 'noheader' => true, |
|
120 | - ), |
|
121 | - |
|
122 | - 'delete_question_group' => array( |
|
123 | - 'func' => '_delete_question_groups', |
|
124 | - 'capability' => 'ee_delete_question_group', |
|
125 | - 'obj_id' => $qsg_id, |
|
126 | - 'noheader' => true, |
|
127 | - ), |
|
128 | - |
|
129 | - 'trash_question_group' => array( |
|
130 | - 'func' => '_trash_or_restore_question_groups', |
|
131 | - 'args' => array('trash' => true), |
|
132 | - 'capability' => 'ee_delete_question_group', |
|
133 | - 'obj_id' => $qsg_id, |
|
134 | - 'noheader' => true, |
|
135 | - ), |
|
136 | - |
|
137 | - 'restore_question_group' => array( |
|
138 | - 'func' => '_trash_or_restore_question_groups', |
|
139 | - 'args' => array('trash' => false), |
|
140 | - 'capability' => 'ee_delete_question_group', |
|
141 | - 'obj_id' => $qsg_id, |
|
142 | - 'noheader' => true, |
|
143 | - ), |
|
144 | - |
|
145 | - 'insert_question_group' => array( |
|
146 | - 'func' => '_insert_or_update_question_group', |
|
147 | - 'args' => array('new_question_group' => true), |
|
148 | - 'capability' => 'ee_edit_question_groups', |
|
149 | - 'noheader' => true, |
|
150 | - ), |
|
151 | - |
|
152 | - 'update_question_group' => array( |
|
153 | - 'func' => '_insert_or_update_question_group', |
|
154 | - 'args' => array('new_question_group' => false), |
|
155 | - 'capability' => 'ee_edit_question_group', |
|
156 | - 'obj_id' => $qsg_id, |
|
157 | - 'noheader' => true, |
|
158 | - ), |
|
159 | - |
|
160 | - 'trash_question_groups' => array( |
|
161 | - 'func' => '_trash_or_restore_question_groups', |
|
162 | - 'args' => array('trash' => true), |
|
163 | - 'capability' => 'ee_delete_question_groups', |
|
164 | - 'noheader' => array('trash' => false), |
|
165 | - ), |
|
166 | - |
|
167 | - 'restore_question_groups' => array( |
|
168 | - 'func' => '_trash_or_restore_question_groups', |
|
169 | - 'args' => array('trash' => false), |
|
170 | - 'capability' => 'ee_delete_question_groups', |
|
171 | - 'noheader' => true, |
|
172 | - ), |
|
173 | - |
|
174 | - |
|
175 | - 'espresso_update_question_group_order' => array( |
|
176 | - 'func' => 'update_question_group_order', |
|
177 | - 'capability' => 'ee_edit_question_groups', |
|
178 | - 'noheader' => true, |
|
179 | - ), |
|
180 | - |
|
181 | - 'view_reg_form_settings' => array( |
|
182 | - 'func' => '_reg_form_settings', |
|
183 | - 'capability' => 'manage_options', |
|
184 | - ), |
|
185 | - |
|
186 | - 'update_reg_form_settings' => array( |
|
187 | - 'func' => '_update_reg_form_settings', |
|
188 | - 'capability' => 'manage_options', |
|
189 | - 'noheader' => true, |
|
190 | - ), |
|
191 | - ); |
|
192 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
193 | - |
|
194 | - $new_page_config = array( |
|
195 | - |
|
196 | - 'question_groups' => array( |
|
197 | - 'nav' => array( |
|
198 | - 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
199 | - 'order' => 20, |
|
200 | - ), |
|
201 | - 'list_table' => 'Registration_Form_Question_Groups_Admin_List_Table', |
|
202 | - 'help_tabs' => array( |
|
203 | - 'registration_form_question_groups_help_tab' => array( |
|
204 | - 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
205 | - 'filename' => 'registration_form_question_groups', |
|
206 | - ), |
|
207 | - 'registration_form_question_groups_table_column_headings_help_tab' => array( |
|
208 | - 'title' => esc_html__('Question Groups Table Column Headings', 'event_espresso'), |
|
209 | - 'filename' => 'registration_form_question_groups_table_column_headings', |
|
210 | - ), |
|
211 | - 'registration_form_question_groups_views_bulk_actions_search_help_tab' => array( |
|
212 | - 'title' => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'), |
|
213 | - 'filename' => 'registration_form_question_groups_views_bulk_actions_search', |
|
214 | - ), |
|
215 | - ), |
|
216 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
217 | - 'require_nonce' => false, |
|
218 | - ), |
|
219 | - |
|
220 | - 'add_question' => array( |
|
221 | - 'nav' => array( |
|
222 | - 'label' => esc_html__('Add Question', 'event_espresso'), |
|
223 | - 'order' => 5, |
|
224 | - 'persistent' => false, |
|
225 | - ), |
|
226 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
227 | - 'help_tabs' => array( |
|
228 | - 'registration_form_add_question_help_tab' => array( |
|
229 | - 'title' => esc_html__('Add Question', 'event_espresso'), |
|
230 | - 'filename' => 'registration_form_add_question', |
|
231 | - ), |
|
232 | - ), |
|
233 | - 'require_nonce' => false, |
|
234 | - ), |
|
235 | - |
|
236 | - 'add_question_group' => array( |
|
237 | - 'nav' => array( |
|
238 | - 'label' => esc_html__('Add Question Group', 'event_espresso'), |
|
239 | - 'order' => 5, |
|
240 | - 'persistent' => false, |
|
241 | - ), |
|
242 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
243 | - 'help_tabs' => array( |
|
244 | - 'registration_form_add_question_group_help_tab' => array( |
|
245 | - 'title' => esc_html__('Add Question Group', 'event_espresso'), |
|
246 | - 'filename' => 'registration_form_add_question_group', |
|
247 | - ), |
|
248 | - ), |
|
249 | - 'require_nonce' => false, |
|
250 | - ), |
|
251 | - |
|
252 | - 'edit_question_group' => array( |
|
253 | - 'nav' => array( |
|
254 | - 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
|
255 | - 'order' => 5, |
|
256 | - 'persistent' => false, |
|
257 | - 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg( |
|
258 | - array('question_group_id' => $this->_req_data['question_group_id']), |
|
259 | - $this->_current_page_view_url |
|
260 | - ) : $this->_admin_base_url, |
|
261 | - ), |
|
262 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
263 | - 'help_tabs' => array( |
|
264 | - 'registration_form_edit_question_group_help_tab' => array( |
|
265 | - 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
|
266 | - 'filename' => 'registration_form_edit_question_group', |
|
267 | - ), |
|
268 | - ), |
|
269 | - 'require_nonce' => false, |
|
270 | - ), |
|
271 | - |
|
272 | - 'view_reg_form_settings' => array( |
|
273 | - 'nav' => array( |
|
274 | - 'label' => esc_html__('Reg Form Settings', 'event_espresso'), |
|
275 | - 'order' => 40, |
|
276 | - ), |
|
277 | - 'labels' => array( |
|
278 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
279 | - ), |
|
280 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
281 | - 'help_tabs' => array( |
|
282 | - 'registration_form_reg_form_settings_help_tab' => array( |
|
283 | - 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
|
284 | - 'filename' => 'registration_form_reg_form_settings', |
|
285 | - ), |
|
286 | - ), |
|
287 | - 'require_nonce' => false, |
|
288 | - ), |
|
289 | - |
|
290 | - ); |
|
291 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
292 | - |
|
293 | - // change the list table we're going to use so it's the NEW list table! |
|
294 | - $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
|
295 | - |
|
296 | - |
|
297 | - // additional labels |
|
298 | - $new_labels = array( |
|
299 | - 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
|
300 | - 'delete_question' => esc_html__('Delete Question', 'event_espresso'), |
|
301 | - 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
|
302 | - 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
|
303 | - 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
|
304 | - ); |
|
305 | - $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
306 | - } |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * @return void |
|
311 | - */ |
|
312 | - protected function _ajax_hooks() |
|
313 | - { |
|
314 | - add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order')); |
|
315 | - } |
|
316 | - |
|
317 | - |
|
318 | - /** |
|
319 | - * @return void |
|
320 | - */ |
|
321 | - public function load_scripts_styles_question_groups() |
|
322 | - { |
|
323 | - wp_enqueue_script('espresso_ajax_table_sorting'); |
|
324 | - } |
|
325 | - |
|
326 | - |
|
327 | - /** |
|
328 | - * @return void |
|
329 | - */ |
|
330 | - public function load_scripts_styles_add_question_group() |
|
331 | - { |
|
332 | - $this->load_scripts_styles_forms(); |
|
333 | - $this->load_sortable_question_script(); |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - /** |
|
338 | - * @return void |
|
339 | - */ |
|
340 | - public function load_scripts_styles_edit_question_group() |
|
341 | - { |
|
342 | - $this->load_scripts_styles_forms(); |
|
343 | - $this->load_sortable_question_script(); |
|
344 | - } |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * registers and enqueues script for questions |
|
349 | - * |
|
350 | - * @return void |
|
351 | - */ |
|
352 | - public function load_sortable_question_script() |
|
353 | - { |
|
354 | - wp_register_script( |
|
355 | - 'ee-question-sortable', |
|
356 | - REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
357 | - array('jquery-ui-sortable'), |
|
358 | - EVENT_ESPRESSO_VERSION, |
|
359 | - true |
|
360 | - ); |
|
361 | - wp_enqueue_script('ee-question-sortable'); |
|
362 | - } |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * @return void |
|
367 | - */ |
|
368 | - protected function _set_list_table_views_default() |
|
369 | - { |
|
370 | - $this->_views = array( |
|
371 | - 'all' => array( |
|
372 | - 'slug' => 'all', |
|
373 | - 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
374 | - 'count' => 0, |
|
375 | - 'bulk_action' => array( |
|
376 | - 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
|
377 | - ), |
|
378 | - ), |
|
379 | - ); |
|
380 | - |
|
381 | - if ( |
|
382 | - EE_Registry::instance()->CAP->current_user_can( |
|
383 | - 'ee_delete_questions', |
|
384 | - 'espresso_registration_form_trash_questions' |
|
385 | - ) |
|
386 | - ) { |
|
387 | - $this->_views['trash'] = array( |
|
388 | - 'slug' => 'trash', |
|
389 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
390 | - 'count' => 0, |
|
391 | - 'bulk_action' => array( |
|
392 | - 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
|
393 | - 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
|
394 | - ), |
|
395 | - ); |
|
396 | - } |
|
397 | - } |
|
398 | - |
|
399 | - |
|
400 | - /** |
|
401 | - * @return void |
|
402 | - */ |
|
403 | - protected function _set_list_table_views_question_groups() |
|
404 | - { |
|
405 | - $this->_views = array( |
|
406 | - 'all' => array( |
|
407 | - 'slug' => 'all', |
|
408 | - 'label' => esc_html__('All', 'event_espresso'), |
|
409 | - 'count' => 0, |
|
410 | - 'bulk_action' => array( |
|
411 | - 'trash_question_groups' => esc_html__('Trash', 'event_espresso'), |
|
412 | - ), |
|
413 | - ), |
|
414 | - ); |
|
415 | - |
|
416 | - if ( |
|
417 | - EE_Registry::instance()->CAP->current_user_can( |
|
418 | - 'ee_delete_question_groups', |
|
419 | - 'espresso_registration_form_trash_question_groups' |
|
420 | - ) |
|
421 | - ) { |
|
422 | - $this->_views['trash'] = array( |
|
423 | - 'slug' => 'trash', |
|
424 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
425 | - 'count' => 0, |
|
426 | - 'bulk_action' => array( |
|
427 | - 'delete_question_groups' => esc_html__('Delete Permanently', 'event_espresso'), |
|
428 | - 'restore_question_groups' => esc_html__('Restore', 'event_espresso'), |
|
429 | - ), |
|
430 | - ); |
|
431 | - } |
|
432 | - } |
|
433 | - |
|
434 | - |
|
435 | - /** |
|
436 | - * @return void |
|
437 | - * @throws EE_Error |
|
438 | - * @throws InvalidArgumentException |
|
439 | - * @throws InvalidDataTypeException |
|
440 | - * @throws InvalidInterfaceException |
|
441 | - */ |
|
442 | - protected function _questions_overview_list_table() |
|
443 | - { |
|
444 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
445 | - 'add_question', |
|
446 | - 'add_question', |
|
447 | - array(), |
|
448 | - 'add-new-h2' |
|
449 | - ); |
|
450 | - parent::_questions_overview_list_table(); |
|
451 | - } |
|
452 | - |
|
453 | - |
|
454 | - /** |
|
455 | - * @return void |
|
456 | - * @throws DomainException |
|
457 | - * @throws EE_Error |
|
458 | - * @throws InvalidArgumentException |
|
459 | - * @throws InvalidDataTypeException |
|
460 | - * @throws InvalidInterfaceException |
|
461 | - */ |
|
462 | - protected function _question_groups_overview_list_table() |
|
463 | - { |
|
464 | - $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
|
465 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
466 | - 'add_question_group', |
|
467 | - 'add_question_group', |
|
468 | - array(), |
|
469 | - 'add-new-h2' |
|
470 | - ); |
|
471 | - $this->display_admin_list_table_page_with_sidebar(); |
|
472 | - } |
|
473 | - |
|
474 | - |
|
475 | - /** |
|
476 | - * @return void |
|
477 | - * @throws EE_Error |
|
478 | - * @throws InvalidArgumentException |
|
479 | - * @throws InvalidDataTypeException |
|
480 | - * @throws InvalidInterfaceException |
|
481 | - */ |
|
482 | - protected function _delete_question() |
|
483 | - { |
|
484 | - $success = $this->_delete_items($this->_question_model); |
|
485 | - $this->_redirect_after_action( |
|
486 | - $success, |
|
487 | - $this->_question_model->item_name($success), |
|
488 | - 'deleted', |
|
489 | - array('action' => 'default', 'status' => 'all') |
|
490 | - ); |
|
491 | - } |
|
492 | - |
|
493 | - |
|
494 | - /** |
|
495 | - * @return void |
|
496 | - * @throws EE_Error |
|
497 | - * @throws InvalidArgumentException |
|
498 | - * @throws InvalidDataTypeException |
|
499 | - * @throws InvalidInterfaceException |
|
500 | - */ |
|
501 | - protected function _delete_questions() |
|
502 | - { |
|
503 | - $success = $this->_delete_items($this->_question_model); |
|
504 | - $this->_redirect_after_action( |
|
505 | - $success, |
|
506 | - $this->_question_model->item_name($success), |
|
507 | - 'deleted permanently', |
|
508 | - array('action' => 'default', 'status' => 'trash') |
|
509 | - ); |
|
510 | - } |
|
511 | - |
|
512 | - |
|
513 | - /** |
|
514 | - * Performs the deletion of a single or multiple questions or question groups. |
|
515 | - * |
|
516 | - * @param EEM_Soft_Delete_Base $model |
|
517 | - * @return int number of items deleted permanently |
|
518 | - * @throws EE_Error |
|
519 | - * @throws InvalidArgumentException |
|
520 | - * @throws InvalidDataTypeException |
|
521 | - * @throws InvalidInterfaceException |
|
522 | - */ |
|
523 | - private function _delete_items(EEM_Soft_Delete_Base $model) |
|
524 | - { |
|
525 | - $success = 0; |
|
526 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
527 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
528 | - // if array has more than one element than success message should be plural |
|
529 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
530 | - // cycle thru bulk action checkboxes |
|
531 | - while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
532 | - if (! $this->_delete_item($ID, $model)) { |
|
533 | - $success = 0; |
|
534 | - } |
|
535 | - } |
|
536 | - } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
537 | - $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
538 | - } elseif (! empty($this->_req_data['QST_ID'])) { |
|
539 | - $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
540 | - } else { |
|
541 | - EE_Error::add_error( |
|
542 | - sprintf( |
|
543 | - esc_html__( |
|
544 | - "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.", |
|
545 | - "event_espresso" |
|
546 | - ) |
|
547 | - ), |
|
548 | - __FILE__, |
|
549 | - __FUNCTION__, |
|
550 | - __LINE__ |
|
551 | - ); |
|
552 | - } |
|
553 | - return $success; |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - /** |
|
558 | - * Deletes the specified question (and its associated question options) or question group |
|
559 | - * |
|
560 | - * @param int $id |
|
561 | - * @param EEM_Soft_Delete_Base $model |
|
562 | - * @return boolean |
|
563 | - * @throws EE_Error |
|
564 | - * @throws InvalidArgumentException |
|
565 | - * @throws InvalidDataTypeException |
|
566 | - * @throws InvalidInterfaceException |
|
567 | - */ |
|
568 | - protected function _delete_item($id, $model) |
|
569 | - { |
|
570 | - if ($model instanceof EEM_Question) { |
|
571 | - EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id)))); |
|
572 | - } |
|
573 | - return $model->delete_permanently_by_ID(absint($id)); |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - /****************************** QUESTION GROUPS ******************************/ |
|
578 | - |
|
579 | - |
|
580 | - /** |
|
581 | - * @param string $type |
|
582 | - * @return void |
|
583 | - * @throws DomainException |
|
584 | - * @throws EE_Error |
|
585 | - * @throws InvalidArgumentException |
|
586 | - * @throws InvalidDataTypeException |
|
587 | - * @throws InvalidInterfaceException |
|
588 | - */ |
|
589 | - protected function _edit_question_group($type = 'add') |
|
590 | - { |
|
591 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
592 | - $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) |
|
593 | - ? absint($this->_req_data['QSG_ID']) |
|
594 | - : false; |
|
595 | - |
|
596 | - switch ($this->_req_action) { |
|
597 | - case 'add_question_group': |
|
598 | - $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
599 | - break; |
|
600 | - case 'edit_question_group': |
|
601 | - $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
602 | - break; |
|
603 | - default: |
|
604 | - $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
605 | - } |
|
606 | - // add ID to title if editing |
|
607 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
608 | - if ($ID) { |
|
609 | - /** @var EE_Question_Group $questionGroup */ |
|
610 | - $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
611 | - $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
612 | - $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
|
613 | - } else { |
|
614 | - /** @var EE_Question_Group $questionGroup */ |
|
615 | - $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
|
616 | - $questionGroup->set_order_to_latest(); |
|
617 | - $this->_set_add_edit_form_tags('insert_question_group'); |
|
618 | - } |
|
619 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
620 | - $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
621 | - $this->_template_args['QSG_ID'] = $ID ? $ID : true; |
|
622 | - $this->_template_args['question_group'] = $questionGroup; |
|
623 | - |
|
624 | - $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
|
625 | - $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL); |
|
626 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
627 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
628 | - $this->_template_args, |
|
629 | - true |
|
630 | - ); |
|
631 | - |
|
632 | - // the details template wrapper |
|
633 | - $this->display_admin_page_with_sidebar(); |
|
634 | - } |
|
635 | - |
|
636 | - |
|
637 | - /** |
|
638 | - * @return void |
|
639 | - * @throws EE_Error |
|
640 | - * @throws InvalidArgumentException |
|
641 | - * @throws InvalidDataTypeException |
|
642 | - * @throws InvalidInterfaceException |
|
643 | - */ |
|
644 | - protected function _delete_question_groups() |
|
645 | - { |
|
646 | - $success = $this->_delete_items($this->_question_group_model); |
|
647 | - $this->_redirect_after_action( |
|
648 | - $success, |
|
649 | - $this->_question_group_model->item_name($success), |
|
650 | - 'deleted permanently', |
|
651 | - array('action' => 'question_groups', 'status' => 'trash') |
|
652 | - ); |
|
653 | - } |
|
654 | - |
|
655 | - |
|
656 | - /** |
|
657 | - * @param bool $new_question_group |
|
658 | - * @throws EE_Error |
|
659 | - * @throws InvalidArgumentException |
|
660 | - * @throws InvalidDataTypeException |
|
661 | - * @throws InvalidInterfaceException |
|
662 | - */ |
|
663 | - protected function _insert_or_update_question_group($new_question_group = true) |
|
664 | - { |
|
665 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
666 | - $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
667 | - if ($new_question_group) { |
|
668 | - // make sure identifier is unique |
|
669 | - $identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : ''; |
|
670 | - $identifier_exists = ! empty($identifier_value) |
|
671 | - ? $this->_question_group_model->count([['QSG_identifier' => $set_column_values['QSG_identifier']]]) > 0 |
|
672 | - : false; |
|
673 | - if ($identifier_exists) { |
|
674 | - $set_column_values['QSG_identifier'] .= uniqid('id', true); |
|
675 | - } |
|
676 | - $QSG_ID = $this->_question_group_model->insert($set_column_values); |
|
677 | - $success = $QSG_ID ? 1 : 0; |
|
678 | - if ($success === 0) { |
|
679 | - EE_Error::add_error( |
|
680 | - esc_html__('Something went wrong saving the question group.', 'event_espresso'), |
|
681 | - __FILE__, |
|
682 | - __FUNCTION__, |
|
683 | - __LINE__ |
|
684 | - ); |
|
685 | - $this->_redirect_after_action( |
|
686 | - false, |
|
687 | - '', |
|
688 | - '', |
|
689 | - array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
690 | - true |
|
691 | - ); |
|
692 | - } |
|
693 | - } else { |
|
694 | - $QSG_ID = absint($this->_req_data['QSG_ID']); |
|
695 | - unset($set_column_values['QSG_ID']); |
|
696 | - $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID))); |
|
697 | - } |
|
698 | - |
|
699 | - $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( |
|
700 | - EEM_Attendee::system_question_phone |
|
701 | - ); |
|
702 | - // update the existing related questions |
|
703 | - // BUT FIRST... delete the phone question from the Question_Group_Question |
|
704 | - // if it is being added to this question group (therefore removed from the existing group) |
|
705 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) { |
|
706 | - // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
|
707 | - EEM_Question_Group_Question::instance()->delete( |
|
708 | - array( |
|
709 | - array( |
|
710 | - 'QST_ID' => $phone_question_id, |
|
711 | - 'QSG_ID' => array('!=', $QSG_ID), |
|
712 | - ), |
|
713 | - ) |
|
714 | - ); |
|
715 | - } |
|
716 | - /** @type EE_Question_Group $question_group */ |
|
717 | - $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
718 | - $questions = $question_group->questions(); |
|
719 | - // make sure system phone question is added to list of questions for this group |
|
720 | - if (! isset($questions[ $phone_question_id ])) { |
|
721 | - $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
722 | - } |
|
723 | - |
|
724 | - foreach ($questions as $question_ID => $question) { |
|
725 | - // first we always check for order. |
|
726 | - if (! empty($this->_req_data['question_orders'][ $question_ID ])) { |
|
727 | - // update question order |
|
728 | - $question_group->update_question_order( |
|
729 | - $question_ID, |
|
730 | - $this->_req_data['question_orders'][ $question_ID ] |
|
731 | - ); |
|
732 | - } |
|
733 | - |
|
734 | - // then we always check if adding or removing. |
|
735 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) { |
|
736 | - $question_group->add_question($question_ID); |
|
737 | - } else { |
|
738 | - // not found, remove it (but only if not a system question for the personal group |
|
739 | - // with the exception of lname system question - we allow removal of it) |
|
740 | - if ( |
|
741 | - in_array( |
|
742 | - $question->system_ID(), |
|
743 | - EEM_Question::instance()->required_system_questions_in_system_question_group( |
|
744 | - $question_group->system_group() |
|
745 | - ) |
|
746 | - ) |
|
747 | - ) { |
|
748 | - continue; |
|
749 | - } else { |
|
750 | - $question_group->remove_question($question_ID); |
|
751 | - } |
|
752 | - } |
|
753 | - } |
|
754 | - // save new related questions |
|
755 | - if (isset($this->_req_data['questions'])) { |
|
756 | - foreach ($this->_req_data['questions'] as $QST_ID) { |
|
757 | - $question_group->add_question($QST_ID); |
|
758 | - if (isset($this->_req_data['question_orders'][ $QST_ID ])) { |
|
759 | - $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]); |
|
760 | - } |
|
761 | - } |
|
762 | - } |
|
763 | - |
|
764 | - if ($success !== false) { |
|
765 | - $msg = $new_question_group |
|
766 | - ? sprintf( |
|
767 | - esc_html__('The %s has been created', 'event_espresso'), |
|
768 | - $this->_question_group_model->item_name() |
|
769 | - ) |
|
770 | - : sprintf( |
|
771 | - esc_html__( |
|
772 | - 'The %s has been updated', |
|
773 | - 'event_espresso' |
|
774 | - ), |
|
775 | - $this->_question_group_model->item_name() |
|
776 | - ); |
|
777 | - EE_Error::add_success($msg); |
|
778 | - } |
|
779 | - $this->_redirect_after_action( |
|
780 | - false, |
|
781 | - '', |
|
782 | - '', |
|
783 | - array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
784 | - true |
|
785 | - ); |
|
786 | - } |
|
787 | - |
|
788 | - |
|
789 | - /** |
|
790 | - * duplicates a question and all its question options and redirects to the new question. |
|
791 | - * |
|
792 | - * @return void |
|
793 | - * @throws EE_Error |
|
794 | - * @throws InvalidArgumentException |
|
795 | - * @throws ReflectionException |
|
796 | - * @throws InvalidDataTypeException |
|
797 | - * @throws InvalidInterfaceException |
|
798 | - */ |
|
799 | - public function _duplicate_question() |
|
800 | - { |
|
801 | - $question_ID = (int) $this->_req_data['QST_ID']; |
|
802 | - $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
803 | - if ($question instanceof EE_Question) { |
|
804 | - $new_question = $question->duplicate(); |
|
805 | - if ($new_question instanceof EE_Question) { |
|
806 | - $this->_redirect_after_action( |
|
807 | - true, |
|
808 | - esc_html__('Question', 'event_espresso'), |
|
809 | - esc_html__('Duplicated', 'event_espresso'), |
|
810 | - array('action' => 'edit_question', 'QST_ID' => $new_question->ID()), |
|
811 | - true |
|
812 | - ); |
|
813 | - } else { |
|
814 | - global $wpdb; |
|
815 | - EE_Error::add_error( |
|
816 | - sprintf( |
|
817 | - esc_html__( |
|
818 | - 'Could not duplicate question with ID %1$d because: %2$s', |
|
819 | - 'event_espresso' |
|
820 | - ), |
|
821 | - $question_ID, |
|
822 | - $wpdb->last_error |
|
823 | - ), |
|
824 | - __FILE__, |
|
825 | - __FUNCTION__, |
|
826 | - __LINE__ |
|
827 | - ); |
|
828 | - $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
829 | - } |
|
830 | - } else { |
|
831 | - EE_Error::add_error( |
|
832 | - sprintf( |
|
833 | - esc_html__( |
|
834 | - 'Could not duplicate question with ID %d because it didn\'t exist!', |
|
835 | - 'event_espresso' |
|
836 | - ), |
|
837 | - $question_ID |
|
838 | - ), |
|
839 | - __FILE__, |
|
840 | - __FUNCTION__, |
|
841 | - __LINE__ |
|
842 | - ); |
|
843 | - $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
844 | - } |
|
845 | - } |
|
846 | - |
|
847 | - |
|
848 | - /** |
|
849 | - * @param bool $trash |
|
850 | - * @throws EE_Error |
|
851 | - */ |
|
852 | - protected function _trash_or_restore_question_groups($trash = true) |
|
853 | - { |
|
854 | - $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
855 | - } |
|
856 | - |
|
857 | - |
|
858 | - /** |
|
859 | - *_trash_question |
|
860 | - * |
|
861 | - * @return void |
|
862 | - * @throws EE_Error |
|
863 | - */ |
|
864 | - protected function _trash_question() |
|
865 | - { |
|
866 | - $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
867 | - $query_args = array('action' => 'default', 'status' => 'all'); |
|
868 | - $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
|
869 | - } |
|
870 | - |
|
871 | - |
|
872 | - /** |
|
873 | - * @param bool $trash |
|
874 | - * @throws EE_Error |
|
875 | - */ |
|
876 | - protected function _trash_or_restore_questions($trash = true) |
|
877 | - { |
|
878 | - $this->_trash_or_restore_items($this->_question_model, $trash); |
|
879 | - } |
|
880 | - |
|
881 | - |
|
882 | - /** |
|
883 | - * Internally used to delete or restore items, using the request data. Meant to be |
|
884 | - * flexible between question or question groups |
|
885 | - * |
|
886 | - * @param EEM_Soft_Delete_Base $model |
|
887 | - * @param boolean $trash whether to trash or restore |
|
888 | - * @throws EE_Error |
|
889 | - */ |
|
890 | - private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true) |
|
891 | - { |
|
892 | - |
|
893 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
894 | - |
|
895 | - $success = 1; |
|
896 | - // Checkboxes |
|
897 | - // echo "trash $trash"; |
|
898 | - // var_dump($this->_req_data['checkbox']);die; |
|
899 | - if (isset($this->_req_data['checkbox'])) { |
|
900 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
901 | - // if array has more than one element than success message should be plural |
|
902 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
903 | - // cycle thru bulk action checkboxes |
|
904 | - while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
905 | - if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
906 | - $success = 0; |
|
907 | - } |
|
908 | - } |
|
909 | - } else { |
|
910 | - // grab single id and delete |
|
911 | - $ID = absint($this->_req_data['checkbox']); |
|
912 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
913 | - $success = 0; |
|
914 | - } |
|
915 | - } |
|
916 | - } else { |
|
917 | - // delete via trash link |
|
918 | - // grab single id and delete |
|
919 | - $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
920 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
921 | - $success = 0; |
|
922 | - } |
|
923 | - } |
|
924 | - |
|
925 | - |
|
926 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) ); |
|
927 | - // echo "action :$action"; |
|
928 | - // $action = 'questions' ? 'default' : $action; |
|
929 | - if ($trash) { |
|
930 | - $action_desc = 'trashed'; |
|
931 | - $status = 'trash'; |
|
932 | - } else { |
|
933 | - $action_desc = 'restored'; |
|
934 | - $status = 'all'; |
|
935 | - } |
|
936 | - $this->_redirect_after_action( |
|
937 | - $success, |
|
938 | - $model->item_name($success), |
|
939 | - $action_desc, |
|
940 | - array('action' => $action, 'status' => $status) |
|
941 | - ); |
|
942 | - } |
|
943 | - |
|
944 | - |
|
945 | - /** |
|
946 | - * @param $per_page |
|
947 | - * @param int $current_page |
|
948 | - * @param bool|false $count |
|
949 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
950 | - * @throws EE_Error |
|
951 | - * @throws InvalidArgumentException |
|
952 | - * @throws InvalidDataTypeException |
|
953 | - * @throws InvalidInterfaceException |
|
954 | - */ |
|
955 | - public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
956 | - { |
|
957 | - $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
958 | - |
|
959 | - if ($count) { |
|
960 | - // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
961 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
962 | - $results = $this->_question_model->count_deleted($where); |
|
963 | - } else { |
|
964 | - // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
965 | - $results = $this->_question_model->get_all_deleted($query_params); |
|
966 | - } |
|
967 | - return $results; |
|
968 | - } |
|
969 | - |
|
970 | - |
|
971 | - /** |
|
972 | - * @param $per_page |
|
973 | - * @param int $current_page |
|
974 | - * @param bool|false $count |
|
975 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
976 | - * @throws EE_Error |
|
977 | - * @throws InvalidArgumentException |
|
978 | - * @throws InvalidDataTypeException |
|
979 | - * @throws InvalidInterfaceException |
|
980 | - */ |
|
981 | - public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
982 | - { |
|
983 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
984 | - $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
985 | - if ($count) { |
|
986 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
987 | - $results = $questionGroupModel->count($where); |
|
988 | - } else { |
|
989 | - $results = $questionGroupModel->get_all($query_params); |
|
990 | - } |
|
991 | - return $results; |
|
992 | - } |
|
993 | - |
|
994 | - |
|
995 | - /** |
|
996 | - * @param $per_page |
|
997 | - * @param int $current_page |
|
998 | - * @param bool $count |
|
999 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
1000 | - * @throws EE_Error |
|
1001 | - * @throws InvalidArgumentException |
|
1002 | - * @throws InvalidDataTypeException |
|
1003 | - * @throws InvalidInterfaceException |
|
1004 | - */ |
|
1005 | - public function get_trashed_question_groups($per_page, $current_page = 1, $count = false) |
|
1006 | - { |
|
1007 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
1008 | - $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
1009 | - if ($count) { |
|
1010 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
1011 | - $query_params['limit'] = null; |
|
1012 | - $results = $questionGroupModel->count_deleted($where); |
|
1013 | - } else { |
|
1014 | - $results = $questionGroupModel->get_all_deleted($query_params); |
|
1015 | - } |
|
1016 | - return $results; |
|
1017 | - } |
|
1018 | - |
|
1019 | - |
|
1020 | - /** |
|
1021 | - * method for performing updates to question order |
|
1022 | - * |
|
1023 | - * @return void results array |
|
1024 | - * @throws EE_Error |
|
1025 | - * @throws InvalidArgumentException |
|
1026 | - * @throws InvalidDataTypeException |
|
1027 | - * @throws InvalidInterfaceException |
|
1028 | - */ |
|
1029 | - public function update_question_group_order() |
|
1030 | - { |
|
1031 | - |
|
1032 | - $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
1033 | - |
|
1034 | - // grab our row IDs |
|
1035 | - $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
1036 | - ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
1037 | - : array(); |
|
1038 | - |
|
1039 | - $perpage = ! empty($this->_req_data['perpage']) |
|
1040 | - ? (int) $this->_req_data['perpage'] |
|
1041 | - : null; |
|
1042 | - $curpage = ! empty($this->_req_data['curpage']) |
|
1043 | - ? (int) $this->_req_data['curpage'] |
|
1044 | - : null; |
|
1045 | - |
|
1046 | - if (! empty($row_ids)) { |
|
1047 | - // figure out where we start the row_id count at for the current page. |
|
1048 | - $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
1049 | - |
|
1050 | - $row_count = count($row_ids); |
|
1051 | - for ($i = 0; $i < $row_count; $i++) { |
|
1052 | - // Update the questions when re-ordering |
|
1053 | - $updated = EEM_Question_Group::instance()->update( |
|
1054 | - array('QSG_order' => $qsgcount), |
|
1055 | - array(array('QSG_ID' => $row_ids[ $i ])) |
|
1056 | - ); |
|
1057 | - if ($updated === false) { |
|
1058 | - $success = false; |
|
1059 | - } |
|
1060 | - $qsgcount++; |
|
1061 | - } |
|
1062 | - } else { |
|
1063 | - $success = false; |
|
1064 | - } |
|
1065 | - |
|
1066 | - $errors = ! $success |
|
1067 | - ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
1068 | - : false; |
|
1069 | - |
|
1070 | - echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors)); |
|
1071 | - die(); |
|
1072 | - } |
|
1073 | - |
|
1074 | - |
|
1075 | - |
|
1076 | - /*************************************** REGISTRATION SETTINGS ***************************************/ |
|
1077 | - |
|
1078 | - |
|
1079 | - /** |
|
1080 | - * @throws DomainException |
|
1081 | - * @throws EE_Error |
|
1082 | - * @throws InvalidArgumentException |
|
1083 | - * @throws InvalidDataTypeException |
|
1084 | - * @throws InvalidInterfaceException |
|
1085 | - */ |
|
1086 | - protected function _reg_form_settings() |
|
1087 | - { |
|
1088 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
1089 | - add_action( |
|
1090 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1091 | - array($this, 'email_validation_settings_form'), |
|
1092 | - 2 |
|
1093 | - ); |
|
1094 | - add_action( |
|
1095 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1096 | - array($this, 'copy_attendee_info_settings_form'), |
|
1097 | - 4 |
|
1098 | - ); |
|
1099 | - $this->_template_args = (array) apply_filters( |
|
1100 | - 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
|
1101 | - $this->_template_args |
|
1102 | - ); |
|
1103 | - $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
1104 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1105 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1106 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
1107 | - $this->_template_args, |
|
1108 | - true |
|
1109 | - ); |
|
1110 | - $this->display_admin_page_with_sidebar(); |
|
1111 | - } |
|
1112 | - |
|
1113 | - |
|
1114 | - /** |
|
1115 | - * @return void |
|
1116 | - * @throws EE_Error |
|
1117 | - * @throws InvalidArgumentException |
|
1118 | - * @throws ReflectionException |
|
1119 | - * @throws InvalidDataTypeException |
|
1120 | - * @throws InvalidInterfaceException |
|
1121 | - */ |
|
1122 | - protected function _update_reg_form_settings() |
|
1123 | - { |
|
1124 | - EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form( |
|
1125 | - EE_Registry::instance()->CFG->registration |
|
1126 | - ); |
|
1127 | - EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form( |
|
1128 | - EE_Registry::instance()->CFG->registration |
|
1129 | - ); |
|
1130 | - EE_Registry::instance()->CFG->registration = apply_filters( |
|
1131 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
1132 | - EE_Registry::instance()->CFG->registration |
|
1133 | - ); |
|
1134 | - $success = $this->_update_espresso_configuration( |
|
1135 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
1136 | - EE_Registry::instance()->CFG, |
|
1137 | - __FILE__, |
|
1138 | - __FUNCTION__, |
|
1139 | - __LINE__ |
|
1140 | - ); |
|
1141 | - $this->_redirect_after_action( |
|
1142 | - $success, |
|
1143 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
1144 | - 'updated', |
|
1145 | - array('action' => 'view_reg_form_settings') |
|
1146 | - ); |
|
1147 | - } |
|
1148 | - |
|
1149 | - |
|
1150 | - /** |
|
1151 | - * @return void |
|
1152 | - * @throws EE_Error |
|
1153 | - * @throws InvalidArgumentException |
|
1154 | - * @throws InvalidDataTypeException |
|
1155 | - * @throws InvalidInterfaceException |
|
1156 | - */ |
|
1157 | - public function copy_attendee_info_settings_form() |
|
1158 | - { |
|
1159 | - echo $this->_copy_attendee_info_settings_form()->get_html(); |
|
1160 | - } |
|
1161 | - |
|
1162 | - /** |
|
1163 | - * _copy_attendee_info_settings_form |
|
1164 | - * |
|
1165 | - * @access protected |
|
1166 | - * @return EE_Form_Section_Proper |
|
1167 | - * @throws \EE_Error |
|
1168 | - */ |
|
1169 | - protected function _copy_attendee_info_settings_form() |
|
1170 | - { |
|
1171 | - return new EE_Form_Section_Proper( |
|
1172 | - array( |
|
1173 | - 'name' => 'copy_attendee_info_settings', |
|
1174 | - 'html_id' => 'copy_attendee_info_settings', |
|
1175 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1176 | - 'subsections' => apply_filters( |
|
1177 | - 'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections', |
|
1178 | - array( |
|
1179 | - 'copy_attendee_info_hdr' => new EE_Form_Section_HTML( |
|
1180 | - EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso')) |
|
1181 | - ), |
|
1182 | - 'copy_attendee_info' => new EE_Yes_No_Input( |
|
1183 | - array( |
|
1184 | - 'html_label_text' => esc_html__( |
|
1185 | - 'Allow copy #1 attendee info to extra attendees?', |
|
1186 | - 'event_espresso' |
|
1187 | - ), |
|
1188 | - 'html_help_text' => esc_html__( |
|
1189 | - 'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.', |
|
1190 | - 'event_espresso' |
|
1191 | - ), |
|
1192 | - 'default' => EE_Registry::instance()->CFG->registration->copyAttendeeInfo(), |
|
1193 | - 'required' => false, |
|
1194 | - 'display_html_label_text' => false, |
|
1195 | - ) |
|
1196 | - ), |
|
1197 | - ) |
|
1198 | - ), |
|
1199 | - ) |
|
1200 | - ); |
|
1201 | - } |
|
1202 | - |
|
1203 | - /** |
|
1204 | - * @param EE_Registration_Config $EE_Registration_Config |
|
1205 | - * @return EE_Registration_Config |
|
1206 | - * @throws EE_Error |
|
1207 | - * @throws InvalidArgumentException |
|
1208 | - * @throws ReflectionException |
|
1209 | - * @throws InvalidDataTypeException |
|
1210 | - * @throws InvalidInterfaceException |
|
1211 | - */ |
|
1212 | - public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1213 | - { |
|
1214 | - $prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo(); |
|
1215 | - try { |
|
1216 | - $copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form(); |
|
1217 | - // if not displaying a form, then check for form submission |
|
1218 | - if ($copy_attendee_info_settings_form->was_submitted()) { |
|
1219 | - // capture form data |
|
1220 | - $copy_attendee_info_settings_form->receive_form_submission(); |
|
1221 | - // validate form data |
|
1222 | - if ($copy_attendee_info_settings_form->is_valid()) { |
|
1223 | - // grab validated data from form |
|
1224 | - $valid_data = $copy_attendee_info_settings_form->valid_data(); |
|
1225 | - if (isset($valid_data['copy_attendee_info'])) { |
|
1226 | - $EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']); |
|
1227 | - } else { |
|
1228 | - EE_Error::add_error( |
|
1229 | - esc_html__( |
|
1230 | - 'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.', |
|
1231 | - 'event_espresso' |
|
1232 | - ), |
|
1233 | - __FILE__, |
|
1234 | - __FUNCTION__, |
|
1235 | - __LINE__ |
|
1236 | - ); |
|
1237 | - } |
|
1238 | - } else { |
|
1239 | - if ($copy_attendee_info_settings_form->submission_error_message() !== '') { |
|
1240 | - EE_Error::add_error( |
|
1241 | - $copy_attendee_info_settings_form->submission_error_message(), |
|
1242 | - __FILE__, |
|
1243 | - __FUNCTION__, |
|
1244 | - __LINE__ |
|
1245 | - ); |
|
1246 | - } |
|
1247 | - } |
|
1248 | - } |
|
1249 | - } catch (EE_Error $e) { |
|
1250 | - $e->get_error(); |
|
1251 | - } |
|
1252 | - return $EE_Registration_Config; |
|
1253 | - } |
|
1254 | - |
|
1255 | - |
|
1256 | - /** |
|
1257 | - * @return void |
|
1258 | - * @throws EE_Error |
|
1259 | - * @throws InvalidArgumentException |
|
1260 | - * @throws InvalidDataTypeException |
|
1261 | - * @throws InvalidInterfaceException |
|
1262 | - */ |
|
1263 | - public function email_validation_settings_form() |
|
1264 | - { |
|
1265 | - echo $this->_email_validation_settings_form()->get_html(); |
|
1266 | - } |
|
1267 | - |
|
1268 | - |
|
1269 | - /** |
|
1270 | - * _email_validation_settings_form |
|
1271 | - * |
|
1272 | - * @access protected |
|
1273 | - * @return EE_Form_Section_Proper |
|
1274 | - * @throws \EE_Error |
|
1275 | - */ |
|
1276 | - protected function _email_validation_settings_form() |
|
1277 | - { |
|
1278 | - return new EE_Form_Section_Proper( |
|
1279 | - array( |
|
1280 | - 'name' => 'email_validation_settings', |
|
1281 | - 'html_id' => 'email_validation_settings', |
|
1282 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1283 | - 'subsections' => apply_filters( |
|
1284 | - 'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections', |
|
1285 | - array( |
|
1286 | - 'email_validation_hdr' => new EE_Form_Section_HTML( |
|
1287 | - EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
1288 | - ), |
|
1289 | - 'email_validation_level' => new EE_Select_Input( |
|
1290 | - array( |
|
1291 | - 'basic' => esc_html__('Basic', 'event_espresso'), |
|
1292 | - 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
1293 | - 'i18n' => esc_html__('International', 'event_espresso'), |
|
1294 | - 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
1295 | - ), |
|
1296 | - array( |
|
1297 | - 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
1298 | - . EEH_Template::get_help_tab_link('email_validation_info'), |
|
1299 | - 'html_help_text' => esc_html__( |
|
1300 | - '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.', |
|
1301 | - 'event_espresso' |
|
1302 | - ), |
|
1303 | - 'default' => isset( |
|
1304 | - EE_Registry::instance()->CFG->registration->email_validation_level |
|
1305 | - ) |
|
1306 | - ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
1307 | - : 'wp_default', |
|
1308 | - 'required' => false, |
|
1309 | - ) |
|
1310 | - ), |
|
1311 | - ) |
|
1312 | - ), |
|
1313 | - ) |
|
1314 | - ); |
|
1315 | - } |
|
1316 | - |
|
1317 | - |
|
1318 | - /** |
|
1319 | - * @param EE_Registration_Config $EE_Registration_Config |
|
1320 | - * @return EE_Registration_Config |
|
1321 | - * @throws EE_Error |
|
1322 | - * @throws InvalidArgumentException |
|
1323 | - * @throws ReflectionException |
|
1324 | - * @throws InvalidDataTypeException |
|
1325 | - * @throws InvalidInterfaceException |
|
1326 | - */ |
|
1327 | - public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1328 | - { |
|
1329 | - $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
1330 | - try { |
|
1331 | - $email_validation_settings_form = $this->_email_validation_settings_form(); |
|
1332 | - // if not displaying a form, then check for form submission |
|
1333 | - if ($email_validation_settings_form->was_submitted()) { |
|
1334 | - // capture form data |
|
1335 | - $email_validation_settings_form->receive_form_submission(); |
|
1336 | - // validate form data |
|
1337 | - if ($email_validation_settings_form->is_valid()) { |
|
1338 | - // grab validated data from form |
|
1339 | - $valid_data = $email_validation_settings_form->valid_data(); |
|
1340 | - if (isset($valid_data['email_validation_level'])) { |
|
1341 | - $email_validation_level = $valid_data['email_validation_level']; |
|
1342 | - // now if they want to use international email addresses |
|
1343 | - if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
1344 | - // in case we need to reset their email validation level, |
|
1345 | - // make sure that the previous value wasn't already set to one of the i18n options. |
|
1346 | - if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') { |
|
1347 | - // if so, then reset it back to "basic" since that is the only other option that, |
|
1348 | - // despite offering poor validation, supports i18n email addresses |
|
1349 | - $prev_email_validation_level = 'basic'; |
|
1350 | - } |
|
1351 | - // confirm our i18n email validation will work on the server |
|
1352 | - if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1353 | - // or reset email validation level to previous value |
|
1354 | - $email_validation_level = $prev_email_validation_level; |
|
1355 | - } |
|
1356 | - } |
|
1357 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1358 | - } else { |
|
1359 | - EE_Error::add_error( |
|
1360 | - esc_html__( |
|
1361 | - 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
|
1362 | - 'event_espresso' |
|
1363 | - ), |
|
1364 | - __FILE__, |
|
1365 | - __FUNCTION__, |
|
1366 | - __LINE__ |
|
1367 | - ); |
|
1368 | - } |
|
1369 | - } else { |
|
1370 | - if ($email_validation_settings_form->submission_error_message() !== '') { |
|
1371 | - EE_Error::add_error( |
|
1372 | - $email_validation_settings_form->submission_error_message(), |
|
1373 | - __FILE__, |
|
1374 | - __FUNCTION__, |
|
1375 | - __LINE__ |
|
1376 | - ); |
|
1377 | - } |
|
1378 | - } |
|
1379 | - } |
|
1380 | - } catch (EE_Error $e) { |
|
1381 | - $e->get_error(); |
|
1382 | - } |
|
1383 | - return $EE_Registration_Config; |
|
1384 | - } |
|
1385 | - |
|
1386 | - |
|
1387 | - /** |
|
1388 | - * confirms that the server's PHP version has the PCRE module enabled, |
|
1389 | - * and that the PCRE version works with our i18n email validation |
|
1390 | - * |
|
1391 | - * @param EE_Registration_Config $EE_Registration_Config |
|
1392 | - * @param string $email_validation_level |
|
1393 | - * @return bool |
|
1394 | - */ |
|
1395 | - private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1396 | - { |
|
1397 | - // first check that PCRE is enabled |
|
1398 | - if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1399 | - EE_Error::add_error( |
|
1400 | - sprintf( |
|
1401 | - esc_html__( |
|
1402 | - '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.', |
|
1403 | - 'event_espresso' |
|
1404 | - ), |
|
1405 | - '<br />' |
|
1406 | - ), |
|
1407 | - __FILE__, |
|
1408 | - __FUNCTION__, |
|
1409 | - __LINE__ |
|
1410 | - ); |
|
1411 | - return false; |
|
1412 | - } else { |
|
1413 | - // PCRE support is enabled, but let's still |
|
1414 | - // perform a test to see if the server will support it. |
|
1415 | - // but first, save the updated validation level to the config, |
|
1416 | - // so that the validation strategy picks it up. |
|
1417 | - // this will get bumped back down if it doesn't work |
|
1418 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1419 | - try { |
|
1420 | - $email_validator = new EE_Email_Validation_Strategy(); |
|
1421 | - $i18n_email_address = apply_filters( |
|
1422 | - 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1423 | - 'jägerjü[email protected]' |
|
1424 | - ); |
|
1425 | - $email_validator->validate($i18n_email_address); |
|
1426 | - } catch (Exception $e) { |
|
1427 | - EE_Error::add_error( |
|
1428 | - sprintf( |
|
1429 | - esc_html__( |
|
1430 | - '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', |
|
1431 | - 'event_espresso' |
|
1432 | - ), |
|
1433 | - '<br />', |
|
1434 | - '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>' |
|
1435 | - ), |
|
1436 | - __FILE__, |
|
1437 | - __FUNCTION__, |
|
1438 | - __LINE__ |
|
1439 | - ); |
|
1440 | - return false; |
|
1441 | - } |
|
1442 | - } |
|
1443 | - return true; |
|
1444 | - } |
|
16 | + /** |
|
17 | + * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
18 | + */ |
|
19 | + public function __construct($routing = true) |
|
20 | + { |
|
21 | + define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/'); |
|
22 | + define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/'); |
|
23 | + define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
24 | + define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/'); |
|
25 | + define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
26 | + parent::__construct($routing); |
|
27 | + } |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + protected function _extend_page_config() |
|
34 | + { |
|
35 | + $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
|
36 | + $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) |
|
37 | + ? $this->_req_data['QST_ID'] : 0; |
|
38 | + $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) |
|
39 | + ? $this->_req_data['QSG_ID'] : 0; |
|
40 | + |
|
41 | + $new_page_routes = array( |
|
42 | + 'question_groups' => array( |
|
43 | + 'func' => '_question_groups_overview_list_table', |
|
44 | + 'capability' => 'ee_read_question_groups', |
|
45 | + ), |
|
46 | + 'add_question' => array( |
|
47 | + 'func' => '_edit_question', |
|
48 | + 'capability' => 'ee_edit_questions', |
|
49 | + ), |
|
50 | + 'insert_question' => array( |
|
51 | + 'func' => '_insert_or_update_question', |
|
52 | + 'args' => array('new_question' => true), |
|
53 | + 'capability' => 'ee_edit_questions', |
|
54 | + 'noheader' => true, |
|
55 | + ), |
|
56 | + 'duplicate_question' => array( |
|
57 | + 'func' => '_duplicate_question', |
|
58 | + 'capability' => 'ee_edit_questions', |
|
59 | + 'noheader' => true, |
|
60 | + ), |
|
61 | + 'trash_question' => array( |
|
62 | + 'func' => '_trash_question', |
|
63 | + 'capability' => 'ee_delete_question', |
|
64 | + 'obj_id' => $qst_id, |
|
65 | + 'noheader' => true, |
|
66 | + ), |
|
67 | + |
|
68 | + 'restore_question' => array( |
|
69 | + 'func' => '_trash_or_restore_questions', |
|
70 | + 'capability' => 'ee_delete_question', |
|
71 | + 'obj_id' => $qst_id, |
|
72 | + 'args' => array('trash' => false), |
|
73 | + 'noheader' => true, |
|
74 | + ), |
|
75 | + |
|
76 | + 'delete_question' => array( |
|
77 | + 'func' => '_delete_question', |
|
78 | + 'capability' => 'ee_delete_question', |
|
79 | + 'obj_id' => $qst_id, |
|
80 | + 'noheader' => true, |
|
81 | + ), |
|
82 | + |
|
83 | + 'trash_questions' => array( |
|
84 | + 'func' => '_trash_or_restore_questions', |
|
85 | + 'capability' => 'ee_delete_questions', |
|
86 | + 'args' => array('trash' => true), |
|
87 | + 'noheader' => true, |
|
88 | + ), |
|
89 | + |
|
90 | + 'restore_questions' => array( |
|
91 | + 'func' => '_trash_or_restore_questions', |
|
92 | + 'capability' => 'ee_delete_questions', |
|
93 | + 'args' => array('trash' => false), |
|
94 | + 'noheader' => true, |
|
95 | + ), |
|
96 | + |
|
97 | + 'delete_questions' => array( |
|
98 | + 'func' => '_delete_questions', |
|
99 | + 'args' => array(), |
|
100 | + 'capability' => 'ee_delete_questions', |
|
101 | + 'noheader' => true, |
|
102 | + ), |
|
103 | + |
|
104 | + 'add_question_group' => array( |
|
105 | + 'func' => '_edit_question_group', |
|
106 | + 'capability' => 'ee_edit_question_groups', |
|
107 | + ), |
|
108 | + |
|
109 | + 'edit_question_group' => array( |
|
110 | + 'func' => '_edit_question_group', |
|
111 | + 'capability' => 'ee_edit_question_group', |
|
112 | + 'obj_id' => $qsg_id, |
|
113 | + 'args' => array('edit'), |
|
114 | + ), |
|
115 | + |
|
116 | + 'delete_question_groups' => array( |
|
117 | + 'func' => '_delete_question_groups', |
|
118 | + 'capability' => 'ee_delete_question_groups', |
|
119 | + 'noheader' => true, |
|
120 | + ), |
|
121 | + |
|
122 | + 'delete_question_group' => array( |
|
123 | + 'func' => '_delete_question_groups', |
|
124 | + 'capability' => 'ee_delete_question_group', |
|
125 | + 'obj_id' => $qsg_id, |
|
126 | + 'noheader' => true, |
|
127 | + ), |
|
128 | + |
|
129 | + 'trash_question_group' => array( |
|
130 | + 'func' => '_trash_or_restore_question_groups', |
|
131 | + 'args' => array('trash' => true), |
|
132 | + 'capability' => 'ee_delete_question_group', |
|
133 | + 'obj_id' => $qsg_id, |
|
134 | + 'noheader' => true, |
|
135 | + ), |
|
136 | + |
|
137 | + 'restore_question_group' => array( |
|
138 | + 'func' => '_trash_or_restore_question_groups', |
|
139 | + 'args' => array('trash' => false), |
|
140 | + 'capability' => 'ee_delete_question_group', |
|
141 | + 'obj_id' => $qsg_id, |
|
142 | + 'noheader' => true, |
|
143 | + ), |
|
144 | + |
|
145 | + 'insert_question_group' => array( |
|
146 | + 'func' => '_insert_or_update_question_group', |
|
147 | + 'args' => array('new_question_group' => true), |
|
148 | + 'capability' => 'ee_edit_question_groups', |
|
149 | + 'noheader' => true, |
|
150 | + ), |
|
151 | + |
|
152 | + 'update_question_group' => array( |
|
153 | + 'func' => '_insert_or_update_question_group', |
|
154 | + 'args' => array('new_question_group' => false), |
|
155 | + 'capability' => 'ee_edit_question_group', |
|
156 | + 'obj_id' => $qsg_id, |
|
157 | + 'noheader' => true, |
|
158 | + ), |
|
159 | + |
|
160 | + 'trash_question_groups' => array( |
|
161 | + 'func' => '_trash_or_restore_question_groups', |
|
162 | + 'args' => array('trash' => true), |
|
163 | + 'capability' => 'ee_delete_question_groups', |
|
164 | + 'noheader' => array('trash' => false), |
|
165 | + ), |
|
166 | + |
|
167 | + 'restore_question_groups' => array( |
|
168 | + 'func' => '_trash_or_restore_question_groups', |
|
169 | + 'args' => array('trash' => false), |
|
170 | + 'capability' => 'ee_delete_question_groups', |
|
171 | + 'noheader' => true, |
|
172 | + ), |
|
173 | + |
|
174 | + |
|
175 | + 'espresso_update_question_group_order' => array( |
|
176 | + 'func' => 'update_question_group_order', |
|
177 | + 'capability' => 'ee_edit_question_groups', |
|
178 | + 'noheader' => true, |
|
179 | + ), |
|
180 | + |
|
181 | + 'view_reg_form_settings' => array( |
|
182 | + 'func' => '_reg_form_settings', |
|
183 | + 'capability' => 'manage_options', |
|
184 | + ), |
|
185 | + |
|
186 | + 'update_reg_form_settings' => array( |
|
187 | + 'func' => '_update_reg_form_settings', |
|
188 | + 'capability' => 'manage_options', |
|
189 | + 'noheader' => true, |
|
190 | + ), |
|
191 | + ); |
|
192 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
193 | + |
|
194 | + $new_page_config = array( |
|
195 | + |
|
196 | + 'question_groups' => array( |
|
197 | + 'nav' => array( |
|
198 | + 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
199 | + 'order' => 20, |
|
200 | + ), |
|
201 | + 'list_table' => 'Registration_Form_Question_Groups_Admin_List_Table', |
|
202 | + 'help_tabs' => array( |
|
203 | + 'registration_form_question_groups_help_tab' => array( |
|
204 | + 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
205 | + 'filename' => 'registration_form_question_groups', |
|
206 | + ), |
|
207 | + 'registration_form_question_groups_table_column_headings_help_tab' => array( |
|
208 | + 'title' => esc_html__('Question Groups Table Column Headings', 'event_espresso'), |
|
209 | + 'filename' => 'registration_form_question_groups_table_column_headings', |
|
210 | + ), |
|
211 | + 'registration_form_question_groups_views_bulk_actions_search_help_tab' => array( |
|
212 | + 'title' => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'), |
|
213 | + 'filename' => 'registration_form_question_groups_views_bulk_actions_search', |
|
214 | + ), |
|
215 | + ), |
|
216 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
217 | + 'require_nonce' => false, |
|
218 | + ), |
|
219 | + |
|
220 | + 'add_question' => array( |
|
221 | + 'nav' => array( |
|
222 | + 'label' => esc_html__('Add Question', 'event_espresso'), |
|
223 | + 'order' => 5, |
|
224 | + 'persistent' => false, |
|
225 | + ), |
|
226 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
227 | + 'help_tabs' => array( |
|
228 | + 'registration_form_add_question_help_tab' => array( |
|
229 | + 'title' => esc_html__('Add Question', 'event_espresso'), |
|
230 | + 'filename' => 'registration_form_add_question', |
|
231 | + ), |
|
232 | + ), |
|
233 | + 'require_nonce' => false, |
|
234 | + ), |
|
235 | + |
|
236 | + 'add_question_group' => array( |
|
237 | + 'nav' => array( |
|
238 | + 'label' => esc_html__('Add Question Group', 'event_espresso'), |
|
239 | + 'order' => 5, |
|
240 | + 'persistent' => false, |
|
241 | + ), |
|
242 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
243 | + 'help_tabs' => array( |
|
244 | + 'registration_form_add_question_group_help_tab' => array( |
|
245 | + 'title' => esc_html__('Add Question Group', 'event_espresso'), |
|
246 | + 'filename' => 'registration_form_add_question_group', |
|
247 | + ), |
|
248 | + ), |
|
249 | + 'require_nonce' => false, |
|
250 | + ), |
|
251 | + |
|
252 | + 'edit_question_group' => array( |
|
253 | + 'nav' => array( |
|
254 | + 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
|
255 | + 'order' => 5, |
|
256 | + 'persistent' => false, |
|
257 | + 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg( |
|
258 | + array('question_group_id' => $this->_req_data['question_group_id']), |
|
259 | + $this->_current_page_view_url |
|
260 | + ) : $this->_admin_base_url, |
|
261 | + ), |
|
262 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
263 | + 'help_tabs' => array( |
|
264 | + 'registration_form_edit_question_group_help_tab' => array( |
|
265 | + 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
|
266 | + 'filename' => 'registration_form_edit_question_group', |
|
267 | + ), |
|
268 | + ), |
|
269 | + 'require_nonce' => false, |
|
270 | + ), |
|
271 | + |
|
272 | + 'view_reg_form_settings' => array( |
|
273 | + 'nav' => array( |
|
274 | + 'label' => esc_html__('Reg Form Settings', 'event_espresso'), |
|
275 | + 'order' => 40, |
|
276 | + ), |
|
277 | + 'labels' => array( |
|
278 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
279 | + ), |
|
280 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
281 | + 'help_tabs' => array( |
|
282 | + 'registration_form_reg_form_settings_help_tab' => array( |
|
283 | + 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
|
284 | + 'filename' => 'registration_form_reg_form_settings', |
|
285 | + ), |
|
286 | + ), |
|
287 | + 'require_nonce' => false, |
|
288 | + ), |
|
289 | + |
|
290 | + ); |
|
291 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
292 | + |
|
293 | + // change the list table we're going to use so it's the NEW list table! |
|
294 | + $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
|
295 | + |
|
296 | + |
|
297 | + // additional labels |
|
298 | + $new_labels = array( |
|
299 | + 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
|
300 | + 'delete_question' => esc_html__('Delete Question', 'event_espresso'), |
|
301 | + 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
|
302 | + 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
|
303 | + 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
|
304 | + ); |
|
305 | + $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * @return void |
|
311 | + */ |
|
312 | + protected function _ajax_hooks() |
|
313 | + { |
|
314 | + add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order')); |
|
315 | + } |
|
316 | + |
|
317 | + |
|
318 | + /** |
|
319 | + * @return void |
|
320 | + */ |
|
321 | + public function load_scripts_styles_question_groups() |
|
322 | + { |
|
323 | + wp_enqueue_script('espresso_ajax_table_sorting'); |
|
324 | + } |
|
325 | + |
|
326 | + |
|
327 | + /** |
|
328 | + * @return void |
|
329 | + */ |
|
330 | + public function load_scripts_styles_add_question_group() |
|
331 | + { |
|
332 | + $this->load_scripts_styles_forms(); |
|
333 | + $this->load_sortable_question_script(); |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + /** |
|
338 | + * @return void |
|
339 | + */ |
|
340 | + public function load_scripts_styles_edit_question_group() |
|
341 | + { |
|
342 | + $this->load_scripts_styles_forms(); |
|
343 | + $this->load_sortable_question_script(); |
|
344 | + } |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * registers and enqueues script for questions |
|
349 | + * |
|
350 | + * @return void |
|
351 | + */ |
|
352 | + public function load_sortable_question_script() |
|
353 | + { |
|
354 | + wp_register_script( |
|
355 | + 'ee-question-sortable', |
|
356 | + REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
357 | + array('jquery-ui-sortable'), |
|
358 | + EVENT_ESPRESSO_VERSION, |
|
359 | + true |
|
360 | + ); |
|
361 | + wp_enqueue_script('ee-question-sortable'); |
|
362 | + } |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * @return void |
|
367 | + */ |
|
368 | + protected function _set_list_table_views_default() |
|
369 | + { |
|
370 | + $this->_views = array( |
|
371 | + 'all' => array( |
|
372 | + 'slug' => 'all', |
|
373 | + 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
374 | + 'count' => 0, |
|
375 | + 'bulk_action' => array( |
|
376 | + 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
|
377 | + ), |
|
378 | + ), |
|
379 | + ); |
|
380 | + |
|
381 | + if ( |
|
382 | + EE_Registry::instance()->CAP->current_user_can( |
|
383 | + 'ee_delete_questions', |
|
384 | + 'espresso_registration_form_trash_questions' |
|
385 | + ) |
|
386 | + ) { |
|
387 | + $this->_views['trash'] = array( |
|
388 | + 'slug' => 'trash', |
|
389 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
390 | + 'count' => 0, |
|
391 | + 'bulk_action' => array( |
|
392 | + 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
|
393 | + 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
|
394 | + ), |
|
395 | + ); |
|
396 | + } |
|
397 | + } |
|
398 | + |
|
399 | + |
|
400 | + /** |
|
401 | + * @return void |
|
402 | + */ |
|
403 | + protected function _set_list_table_views_question_groups() |
|
404 | + { |
|
405 | + $this->_views = array( |
|
406 | + 'all' => array( |
|
407 | + 'slug' => 'all', |
|
408 | + 'label' => esc_html__('All', 'event_espresso'), |
|
409 | + 'count' => 0, |
|
410 | + 'bulk_action' => array( |
|
411 | + 'trash_question_groups' => esc_html__('Trash', 'event_espresso'), |
|
412 | + ), |
|
413 | + ), |
|
414 | + ); |
|
415 | + |
|
416 | + if ( |
|
417 | + EE_Registry::instance()->CAP->current_user_can( |
|
418 | + 'ee_delete_question_groups', |
|
419 | + 'espresso_registration_form_trash_question_groups' |
|
420 | + ) |
|
421 | + ) { |
|
422 | + $this->_views['trash'] = array( |
|
423 | + 'slug' => 'trash', |
|
424 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
425 | + 'count' => 0, |
|
426 | + 'bulk_action' => array( |
|
427 | + 'delete_question_groups' => esc_html__('Delete Permanently', 'event_espresso'), |
|
428 | + 'restore_question_groups' => esc_html__('Restore', 'event_espresso'), |
|
429 | + ), |
|
430 | + ); |
|
431 | + } |
|
432 | + } |
|
433 | + |
|
434 | + |
|
435 | + /** |
|
436 | + * @return void |
|
437 | + * @throws EE_Error |
|
438 | + * @throws InvalidArgumentException |
|
439 | + * @throws InvalidDataTypeException |
|
440 | + * @throws InvalidInterfaceException |
|
441 | + */ |
|
442 | + protected function _questions_overview_list_table() |
|
443 | + { |
|
444 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
445 | + 'add_question', |
|
446 | + 'add_question', |
|
447 | + array(), |
|
448 | + 'add-new-h2' |
|
449 | + ); |
|
450 | + parent::_questions_overview_list_table(); |
|
451 | + } |
|
452 | + |
|
453 | + |
|
454 | + /** |
|
455 | + * @return void |
|
456 | + * @throws DomainException |
|
457 | + * @throws EE_Error |
|
458 | + * @throws InvalidArgumentException |
|
459 | + * @throws InvalidDataTypeException |
|
460 | + * @throws InvalidInterfaceException |
|
461 | + */ |
|
462 | + protected function _question_groups_overview_list_table() |
|
463 | + { |
|
464 | + $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
|
465 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
466 | + 'add_question_group', |
|
467 | + 'add_question_group', |
|
468 | + array(), |
|
469 | + 'add-new-h2' |
|
470 | + ); |
|
471 | + $this->display_admin_list_table_page_with_sidebar(); |
|
472 | + } |
|
473 | + |
|
474 | + |
|
475 | + /** |
|
476 | + * @return void |
|
477 | + * @throws EE_Error |
|
478 | + * @throws InvalidArgumentException |
|
479 | + * @throws InvalidDataTypeException |
|
480 | + * @throws InvalidInterfaceException |
|
481 | + */ |
|
482 | + protected function _delete_question() |
|
483 | + { |
|
484 | + $success = $this->_delete_items($this->_question_model); |
|
485 | + $this->_redirect_after_action( |
|
486 | + $success, |
|
487 | + $this->_question_model->item_name($success), |
|
488 | + 'deleted', |
|
489 | + array('action' => 'default', 'status' => 'all') |
|
490 | + ); |
|
491 | + } |
|
492 | + |
|
493 | + |
|
494 | + /** |
|
495 | + * @return void |
|
496 | + * @throws EE_Error |
|
497 | + * @throws InvalidArgumentException |
|
498 | + * @throws InvalidDataTypeException |
|
499 | + * @throws InvalidInterfaceException |
|
500 | + */ |
|
501 | + protected function _delete_questions() |
|
502 | + { |
|
503 | + $success = $this->_delete_items($this->_question_model); |
|
504 | + $this->_redirect_after_action( |
|
505 | + $success, |
|
506 | + $this->_question_model->item_name($success), |
|
507 | + 'deleted permanently', |
|
508 | + array('action' => 'default', 'status' => 'trash') |
|
509 | + ); |
|
510 | + } |
|
511 | + |
|
512 | + |
|
513 | + /** |
|
514 | + * Performs the deletion of a single or multiple questions or question groups. |
|
515 | + * |
|
516 | + * @param EEM_Soft_Delete_Base $model |
|
517 | + * @return int number of items deleted permanently |
|
518 | + * @throws EE_Error |
|
519 | + * @throws InvalidArgumentException |
|
520 | + * @throws InvalidDataTypeException |
|
521 | + * @throws InvalidInterfaceException |
|
522 | + */ |
|
523 | + private function _delete_items(EEM_Soft_Delete_Base $model) |
|
524 | + { |
|
525 | + $success = 0; |
|
526 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
527 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
528 | + // if array has more than one element than success message should be plural |
|
529 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
530 | + // cycle thru bulk action checkboxes |
|
531 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
532 | + if (! $this->_delete_item($ID, $model)) { |
|
533 | + $success = 0; |
|
534 | + } |
|
535 | + } |
|
536 | + } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
537 | + $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
538 | + } elseif (! empty($this->_req_data['QST_ID'])) { |
|
539 | + $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
540 | + } else { |
|
541 | + EE_Error::add_error( |
|
542 | + sprintf( |
|
543 | + esc_html__( |
|
544 | + "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.", |
|
545 | + "event_espresso" |
|
546 | + ) |
|
547 | + ), |
|
548 | + __FILE__, |
|
549 | + __FUNCTION__, |
|
550 | + __LINE__ |
|
551 | + ); |
|
552 | + } |
|
553 | + return $success; |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + /** |
|
558 | + * Deletes the specified question (and its associated question options) or question group |
|
559 | + * |
|
560 | + * @param int $id |
|
561 | + * @param EEM_Soft_Delete_Base $model |
|
562 | + * @return boolean |
|
563 | + * @throws EE_Error |
|
564 | + * @throws InvalidArgumentException |
|
565 | + * @throws InvalidDataTypeException |
|
566 | + * @throws InvalidInterfaceException |
|
567 | + */ |
|
568 | + protected function _delete_item($id, $model) |
|
569 | + { |
|
570 | + if ($model instanceof EEM_Question) { |
|
571 | + EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id)))); |
|
572 | + } |
|
573 | + return $model->delete_permanently_by_ID(absint($id)); |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + /****************************** QUESTION GROUPS ******************************/ |
|
578 | + |
|
579 | + |
|
580 | + /** |
|
581 | + * @param string $type |
|
582 | + * @return void |
|
583 | + * @throws DomainException |
|
584 | + * @throws EE_Error |
|
585 | + * @throws InvalidArgumentException |
|
586 | + * @throws InvalidDataTypeException |
|
587 | + * @throws InvalidInterfaceException |
|
588 | + */ |
|
589 | + protected function _edit_question_group($type = 'add') |
|
590 | + { |
|
591 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
592 | + $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) |
|
593 | + ? absint($this->_req_data['QSG_ID']) |
|
594 | + : false; |
|
595 | + |
|
596 | + switch ($this->_req_action) { |
|
597 | + case 'add_question_group': |
|
598 | + $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
599 | + break; |
|
600 | + case 'edit_question_group': |
|
601 | + $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
602 | + break; |
|
603 | + default: |
|
604 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
605 | + } |
|
606 | + // add ID to title if editing |
|
607 | + $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
608 | + if ($ID) { |
|
609 | + /** @var EE_Question_Group $questionGroup */ |
|
610 | + $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
611 | + $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
612 | + $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
|
613 | + } else { |
|
614 | + /** @var EE_Question_Group $questionGroup */ |
|
615 | + $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
|
616 | + $questionGroup->set_order_to_latest(); |
|
617 | + $this->_set_add_edit_form_tags('insert_question_group'); |
|
618 | + } |
|
619 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
620 | + $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
621 | + $this->_template_args['QSG_ID'] = $ID ? $ID : true; |
|
622 | + $this->_template_args['question_group'] = $questionGroup; |
|
623 | + |
|
624 | + $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
|
625 | + $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL); |
|
626 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
627 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
628 | + $this->_template_args, |
|
629 | + true |
|
630 | + ); |
|
631 | + |
|
632 | + // the details template wrapper |
|
633 | + $this->display_admin_page_with_sidebar(); |
|
634 | + } |
|
635 | + |
|
636 | + |
|
637 | + /** |
|
638 | + * @return void |
|
639 | + * @throws EE_Error |
|
640 | + * @throws InvalidArgumentException |
|
641 | + * @throws InvalidDataTypeException |
|
642 | + * @throws InvalidInterfaceException |
|
643 | + */ |
|
644 | + protected function _delete_question_groups() |
|
645 | + { |
|
646 | + $success = $this->_delete_items($this->_question_group_model); |
|
647 | + $this->_redirect_after_action( |
|
648 | + $success, |
|
649 | + $this->_question_group_model->item_name($success), |
|
650 | + 'deleted permanently', |
|
651 | + array('action' => 'question_groups', 'status' => 'trash') |
|
652 | + ); |
|
653 | + } |
|
654 | + |
|
655 | + |
|
656 | + /** |
|
657 | + * @param bool $new_question_group |
|
658 | + * @throws EE_Error |
|
659 | + * @throws InvalidArgumentException |
|
660 | + * @throws InvalidDataTypeException |
|
661 | + * @throws InvalidInterfaceException |
|
662 | + */ |
|
663 | + protected function _insert_or_update_question_group($new_question_group = true) |
|
664 | + { |
|
665 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
666 | + $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
667 | + if ($new_question_group) { |
|
668 | + // make sure identifier is unique |
|
669 | + $identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : ''; |
|
670 | + $identifier_exists = ! empty($identifier_value) |
|
671 | + ? $this->_question_group_model->count([['QSG_identifier' => $set_column_values['QSG_identifier']]]) > 0 |
|
672 | + : false; |
|
673 | + if ($identifier_exists) { |
|
674 | + $set_column_values['QSG_identifier'] .= uniqid('id', true); |
|
675 | + } |
|
676 | + $QSG_ID = $this->_question_group_model->insert($set_column_values); |
|
677 | + $success = $QSG_ID ? 1 : 0; |
|
678 | + if ($success === 0) { |
|
679 | + EE_Error::add_error( |
|
680 | + esc_html__('Something went wrong saving the question group.', 'event_espresso'), |
|
681 | + __FILE__, |
|
682 | + __FUNCTION__, |
|
683 | + __LINE__ |
|
684 | + ); |
|
685 | + $this->_redirect_after_action( |
|
686 | + false, |
|
687 | + '', |
|
688 | + '', |
|
689 | + array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
690 | + true |
|
691 | + ); |
|
692 | + } |
|
693 | + } else { |
|
694 | + $QSG_ID = absint($this->_req_data['QSG_ID']); |
|
695 | + unset($set_column_values['QSG_ID']); |
|
696 | + $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID))); |
|
697 | + } |
|
698 | + |
|
699 | + $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( |
|
700 | + EEM_Attendee::system_question_phone |
|
701 | + ); |
|
702 | + // update the existing related questions |
|
703 | + // BUT FIRST... delete the phone question from the Question_Group_Question |
|
704 | + // if it is being added to this question group (therefore removed from the existing group) |
|
705 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) { |
|
706 | + // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
|
707 | + EEM_Question_Group_Question::instance()->delete( |
|
708 | + array( |
|
709 | + array( |
|
710 | + 'QST_ID' => $phone_question_id, |
|
711 | + 'QSG_ID' => array('!=', $QSG_ID), |
|
712 | + ), |
|
713 | + ) |
|
714 | + ); |
|
715 | + } |
|
716 | + /** @type EE_Question_Group $question_group */ |
|
717 | + $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
718 | + $questions = $question_group->questions(); |
|
719 | + // make sure system phone question is added to list of questions for this group |
|
720 | + if (! isset($questions[ $phone_question_id ])) { |
|
721 | + $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
722 | + } |
|
723 | + |
|
724 | + foreach ($questions as $question_ID => $question) { |
|
725 | + // first we always check for order. |
|
726 | + if (! empty($this->_req_data['question_orders'][ $question_ID ])) { |
|
727 | + // update question order |
|
728 | + $question_group->update_question_order( |
|
729 | + $question_ID, |
|
730 | + $this->_req_data['question_orders'][ $question_ID ] |
|
731 | + ); |
|
732 | + } |
|
733 | + |
|
734 | + // then we always check if adding or removing. |
|
735 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) { |
|
736 | + $question_group->add_question($question_ID); |
|
737 | + } else { |
|
738 | + // not found, remove it (but only if not a system question for the personal group |
|
739 | + // with the exception of lname system question - we allow removal of it) |
|
740 | + if ( |
|
741 | + in_array( |
|
742 | + $question->system_ID(), |
|
743 | + EEM_Question::instance()->required_system_questions_in_system_question_group( |
|
744 | + $question_group->system_group() |
|
745 | + ) |
|
746 | + ) |
|
747 | + ) { |
|
748 | + continue; |
|
749 | + } else { |
|
750 | + $question_group->remove_question($question_ID); |
|
751 | + } |
|
752 | + } |
|
753 | + } |
|
754 | + // save new related questions |
|
755 | + if (isset($this->_req_data['questions'])) { |
|
756 | + foreach ($this->_req_data['questions'] as $QST_ID) { |
|
757 | + $question_group->add_question($QST_ID); |
|
758 | + if (isset($this->_req_data['question_orders'][ $QST_ID ])) { |
|
759 | + $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]); |
|
760 | + } |
|
761 | + } |
|
762 | + } |
|
763 | + |
|
764 | + if ($success !== false) { |
|
765 | + $msg = $new_question_group |
|
766 | + ? sprintf( |
|
767 | + esc_html__('The %s has been created', 'event_espresso'), |
|
768 | + $this->_question_group_model->item_name() |
|
769 | + ) |
|
770 | + : sprintf( |
|
771 | + esc_html__( |
|
772 | + 'The %s has been updated', |
|
773 | + 'event_espresso' |
|
774 | + ), |
|
775 | + $this->_question_group_model->item_name() |
|
776 | + ); |
|
777 | + EE_Error::add_success($msg); |
|
778 | + } |
|
779 | + $this->_redirect_after_action( |
|
780 | + false, |
|
781 | + '', |
|
782 | + '', |
|
783 | + array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
784 | + true |
|
785 | + ); |
|
786 | + } |
|
787 | + |
|
788 | + |
|
789 | + /** |
|
790 | + * duplicates a question and all its question options and redirects to the new question. |
|
791 | + * |
|
792 | + * @return void |
|
793 | + * @throws EE_Error |
|
794 | + * @throws InvalidArgumentException |
|
795 | + * @throws ReflectionException |
|
796 | + * @throws InvalidDataTypeException |
|
797 | + * @throws InvalidInterfaceException |
|
798 | + */ |
|
799 | + public function _duplicate_question() |
|
800 | + { |
|
801 | + $question_ID = (int) $this->_req_data['QST_ID']; |
|
802 | + $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
803 | + if ($question instanceof EE_Question) { |
|
804 | + $new_question = $question->duplicate(); |
|
805 | + if ($new_question instanceof EE_Question) { |
|
806 | + $this->_redirect_after_action( |
|
807 | + true, |
|
808 | + esc_html__('Question', 'event_espresso'), |
|
809 | + esc_html__('Duplicated', 'event_espresso'), |
|
810 | + array('action' => 'edit_question', 'QST_ID' => $new_question->ID()), |
|
811 | + true |
|
812 | + ); |
|
813 | + } else { |
|
814 | + global $wpdb; |
|
815 | + EE_Error::add_error( |
|
816 | + sprintf( |
|
817 | + esc_html__( |
|
818 | + 'Could not duplicate question with ID %1$d because: %2$s', |
|
819 | + 'event_espresso' |
|
820 | + ), |
|
821 | + $question_ID, |
|
822 | + $wpdb->last_error |
|
823 | + ), |
|
824 | + __FILE__, |
|
825 | + __FUNCTION__, |
|
826 | + __LINE__ |
|
827 | + ); |
|
828 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
829 | + } |
|
830 | + } else { |
|
831 | + EE_Error::add_error( |
|
832 | + sprintf( |
|
833 | + esc_html__( |
|
834 | + 'Could not duplicate question with ID %d because it didn\'t exist!', |
|
835 | + 'event_espresso' |
|
836 | + ), |
|
837 | + $question_ID |
|
838 | + ), |
|
839 | + __FILE__, |
|
840 | + __FUNCTION__, |
|
841 | + __LINE__ |
|
842 | + ); |
|
843 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
844 | + } |
|
845 | + } |
|
846 | + |
|
847 | + |
|
848 | + /** |
|
849 | + * @param bool $trash |
|
850 | + * @throws EE_Error |
|
851 | + */ |
|
852 | + protected function _trash_or_restore_question_groups($trash = true) |
|
853 | + { |
|
854 | + $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
855 | + } |
|
856 | + |
|
857 | + |
|
858 | + /** |
|
859 | + *_trash_question |
|
860 | + * |
|
861 | + * @return void |
|
862 | + * @throws EE_Error |
|
863 | + */ |
|
864 | + protected function _trash_question() |
|
865 | + { |
|
866 | + $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
867 | + $query_args = array('action' => 'default', 'status' => 'all'); |
|
868 | + $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
|
869 | + } |
|
870 | + |
|
871 | + |
|
872 | + /** |
|
873 | + * @param bool $trash |
|
874 | + * @throws EE_Error |
|
875 | + */ |
|
876 | + protected function _trash_or_restore_questions($trash = true) |
|
877 | + { |
|
878 | + $this->_trash_or_restore_items($this->_question_model, $trash); |
|
879 | + } |
|
880 | + |
|
881 | + |
|
882 | + /** |
|
883 | + * Internally used to delete or restore items, using the request data. Meant to be |
|
884 | + * flexible between question or question groups |
|
885 | + * |
|
886 | + * @param EEM_Soft_Delete_Base $model |
|
887 | + * @param boolean $trash whether to trash or restore |
|
888 | + * @throws EE_Error |
|
889 | + */ |
|
890 | + private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true) |
|
891 | + { |
|
892 | + |
|
893 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
894 | + |
|
895 | + $success = 1; |
|
896 | + // Checkboxes |
|
897 | + // echo "trash $trash"; |
|
898 | + // var_dump($this->_req_data['checkbox']);die; |
|
899 | + if (isset($this->_req_data['checkbox'])) { |
|
900 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
901 | + // if array has more than one element than success message should be plural |
|
902 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
903 | + // cycle thru bulk action checkboxes |
|
904 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
905 | + if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
906 | + $success = 0; |
|
907 | + } |
|
908 | + } |
|
909 | + } else { |
|
910 | + // grab single id and delete |
|
911 | + $ID = absint($this->_req_data['checkbox']); |
|
912 | + if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
913 | + $success = 0; |
|
914 | + } |
|
915 | + } |
|
916 | + } else { |
|
917 | + // delete via trash link |
|
918 | + // grab single id and delete |
|
919 | + $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
920 | + if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
921 | + $success = 0; |
|
922 | + } |
|
923 | + } |
|
924 | + |
|
925 | + |
|
926 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) ); |
|
927 | + // echo "action :$action"; |
|
928 | + // $action = 'questions' ? 'default' : $action; |
|
929 | + if ($trash) { |
|
930 | + $action_desc = 'trashed'; |
|
931 | + $status = 'trash'; |
|
932 | + } else { |
|
933 | + $action_desc = 'restored'; |
|
934 | + $status = 'all'; |
|
935 | + } |
|
936 | + $this->_redirect_after_action( |
|
937 | + $success, |
|
938 | + $model->item_name($success), |
|
939 | + $action_desc, |
|
940 | + array('action' => $action, 'status' => $status) |
|
941 | + ); |
|
942 | + } |
|
943 | + |
|
944 | + |
|
945 | + /** |
|
946 | + * @param $per_page |
|
947 | + * @param int $current_page |
|
948 | + * @param bool|false $count |
|
949 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
950 | + * @throws EE_Error |
|
951 | + * @throws InvalidArgumentException |
|
952 | + * @throws InvalidDataTypeException |
|
953 | + * @throws InvalidInterfaceException |
|
954 | + */ |
|
955 | + public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
956 | + { |
|
957 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
958 | + |
|
959 | + if ($count) { |
|
960 | + // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
961 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
962 | + $results = $this->_question_model->count_deleted($where); |
|
963 | + } else { |
|
964 | + // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
965 | + $results = $this->_question_model->get_all_deleted($query_params); |
|
966 | + } |
|
967 | + return $results; |
|
968 | + } |
|
969 | + |
|
970 | + |
|
971 | + /** |
|
972 | + * @param $per_page |
|
973 | + * @param int $current_page |
|
974 | + * @param bool|false $count |
|
975 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
976 | + * @throws EE_Error |
|
977 | + * @throws InvalidArgumentException |
|
978 | + * @throws InvalidDataTypeException |
|
979 | + * @throws InvalidInterfaceException |
|
980 | + */ |
|
981 | + public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
982 | + { |
|
983 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
984 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
985 | + if ($count) { |
|
986 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
987 | + $results = $questionGroupModel->count($where); |
|
988 | + } else { |
|
989 | + $results = $questionGroupModel->get_all($query_params); |
|
990 | + } |
|
991 | + return $results; |
|
992 | + } |
|
993 | + |
|
994 | + |
|
995 | + /** |
|
996 | + * @param $per_page |
|
997 | + * @param int $current_page |
|
998 | + * @param bool $count |
|
999 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
1000 | + * @throws EE_Error |
|
1001 | + * @throws InvalidArgumentException |
|
1002 | + * @throws InvalidDataTypeException |
|
1003 | + * @throws InvalidInterfaceException |
|
1004 | + */ |
|
1005 | + public function get_trashed_question_groups($per_page, $current_page = 1, $count = false) |
|
1006 | + { |
|
1007 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
1008 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
1009 | + if ($count) { |
|
1010 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
1011 | + $query_params['limit'] = null; |
|
1012 | + $results = $questionGroupModel->count_deleted($where); |
|
1013 | + } else { |
|
1014 | + $results = $questionGroupModel->get_all_deleted($query_params); |
|
1015 | + } |
|
1016 | + return $results; |
|
1017 | + } |
|
1018 | + |
|
1019 | + |
|
1020 | + /** |
|
1021 | + * method for performing updates to question order |
|
1022 | + * |
|
1023 | + * @return void results array |
|
1024 | + * @throws EE_Error |
|
1025 | + * @throws InvalidArgumentException |
|
1026 | + * @throws InvalidDataTypeException |
|
1027 | + * @throws InvalidInterfaceException |
|
1028 | + */ |
|
1029 | + public function update_question_group_order() |
|
1030 | + { |
|
1031 | + |
|
1032 | + $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
1033 | + |
|
1034 | + // grab our row IDs |
|
1035 | + $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
1036 | + ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
1037 | + : array(); |
|
1038 | + |
|
1039 | + $perpage = ! empty($this->_req_data['perpage']) |
|
1040 | + ? (int) $this->_req_data['perpage'] |
|
1041 | + : null; |
|
1042 | + $curpage = ! empty($this->_req_data['curpage']) |
|
1043 | + ? (int) $this->_req_data['curpage'] |
|
1044 | + : null; |
|
1045 | + |
|
1046 | + if (! empty($row_ids)) { |
|
1047 | + // figure out where we start the row_id count at for the current page. |
|
1048 | + $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
1049 | + |
|
1050 | + $row_count = count($row_ids); |
|
1051 | + for ($i = 0; $i < $row_count; $i++) { |
|
1052 | + // Update the questions when re-ordering |
|
1053 | + $updated = EEM_Question_Group::instance()->update( |
|
1054 | + array('QSG_order' => $qsgcount), |
|
1055 | + array(array('QSG_ID' => $row_ids[ $i ])) |
|
1056 | + ); |
|
1057 | + if ($updated === false) { |
|
1058 | + $success = false; |
|
1059 | + } |
|
1060 | + $qsgcount++; |
|
1061 | + } |
|
1062 | + } else { |
|
1063 | + $success = false; |
|
1064 | + } |
|
1065 | + |
|
1066 | + $errors = ! $success |
|
1067 | + ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
1068 | + : false; |
|
1069 | + |
|
1070 | + echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors)); |
|
1071 | + die(); |
|
1072 | + } |
|
1073 | + |
|
1074 | + |
|
1075 | + |
|
1076 | + /*************************************** REGISTRATION SETTINGS ***************************************/ |
|
1077 | + |
|
1078 | + |
|
1079 | + /** |
|
1080 | + * @throws DomainException |
|
1081 | + * @throws EE_Error |
|
1082 | + * @throws InvalidArgumentException |
|
1083 | + * @throws InvalidDataTypeException |
|
1084 | + * @throws InvalidInterfaceException |
|
1085 | + */ |
|
1086 | + protected function _reg_form_settings() |
|
1087 | + { |
|
1088 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
1089 | + add_action( |
|
1090 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1091 | + array($this, 'email_validation_settings_form'), |
|
1092 | + 2 |
|
1093 | + ); |
|
1094 | + add_action( |
|
1095 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1096 | + array($this, 'copy_attendee_info_settings_form'), |
|
1097 | + 4 |
|
1098 | + ); |
|
1099 | + $this->_template_args = (array) apply_filters( |
|
1100 | + 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
|
1101 | + $this->_template_args |
|
1102 | + ); |
|
1103 | + $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
1104 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1105 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1106 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
1107 | + $this->_template_args, |
|
1108 | + true |
|
1109 | + ); |
|
1110 | + $this->display_admin_page_with_sidebar(); |
|
1111 | + } |
|
1112 | + |
|
1113 | + |
|
1114 | + /** |
|
1115 | + * @return void |
|
1116 | + * @throws EE_Error |
|
1117 | + * @throws InvalidArgumentException |
|
1118 | + * @throws ReflectionException |
|
1119 | + * @throws InvalidDataTypeException |
|
1120 | + * @throws InvalidInterfaceException |
|
1121 | + */ |
|
1122 | + protected function _update_reg_form_settings() |
|
1123 | + { |
|
1124 | + EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form( |
|
1125 | + EE_Registry::instance()->CFG->registration |
|
1126 | + ); |
|
1127 | + EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form( |
|
1128 | + EE_Registry::instance()->CFG->registration |
|
1129 | + ); |
|
1130 | + EE_Registry::instance()->CFG->registration = apply_filters( |
|
1131 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
1132 | + EE_Registry::instance()->CFG->registration |
|
1133 | + ); |
|
1134 | + $success = $this->_update_espresso_configuration( |
|
1135 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
1136 | + EE_Registry::instance()->CFG, |
|
1137 | + __FILE__, |
|
1138 | + __FUNCTION__, |
|
1139 | + __LINE__ |
|
1140 | + ); |
|
1141 | + $this->_redirect_after_action( |
|
1142 | + $success, |
|
1143 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
1144 | + 'updated', |
|
1145 | + array('action' => 'view_reg_form_settings') |
|
1146 | + ); |
|
1147 | + } |
|
1148 | + |
|
1149 | + |
|
1150 | + /** |
|
1151 | + * @return void |
|
1152 | + * @throws EE_Error |
|
1153 | + * @throws InvalidArgumentException |
|
1154 | + * @throws InvalidDataTypeException |
|
1155 | + * @throws InvalidInterfaceException |
|
1156 | + */ |
|
1157 | + public function copy_attendee_info_settings_form() |
|
1158 | + { |
|
1159 | + echo $this->_copy_attendee_info_settings_form()->get_html(); |
|
1160 | + } |
|
1161 | + |
|
1162 | + /** |
|
1163 | + * _copy_attendee_info_settings_form |
|
1164 | + * |
|
1165 | + * @access protected |
|
1166 | + * @return EE_Form_Section_Proper |
|
1167 | + * @throws \EE_Error |
|
1168 | + */ |
|
1169 | + protected function _copy_attendee_info_settings_form() |
|
1170 | + { |
|
1171 | + return new EE_Form_Section_Proper( |
|
1172 | + array( |
|
1173 | + 'name' => 'copy_attendee_info_settings', |
|
1174 | + 'html_id' => 'copy_attendee_info_settings', |
|
1175 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1176 | + 'subsections' => apply_filters( |
|
1177 | + 'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections', |
|
1178 | + array( |
|
1179 | + 'copy_attendee_info_hdr' => new EE_Form_Section_HTML( |
|
1180 | + EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso')) |
|
1181 | + ), |
|
1182 | + 'copy_attendee_info' => new EE_Yes_No_Input( |
|
1183 | + array( |
|
1184 | + 'html_label_text' => esc_html__( |
|
1185 | + 'Allow copy #1 attendee info to extra attendees?', |
|
1186 | + 'event_espresso' |
|
1187 | + ), |
|
1188 | + 'html_help_text' => esc_html__( |
|
1189 | + 'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.', |
|
1190 | + 'event_espresso' |
|
1191 | + ), |
|
1192 | + 'default' => EE_Registry::instance()->CFG->registration->copyAttendeeInfo(), |
|
1193 | + 'required' => false, |
|
1194 | + 'display_html_label_text' => false, |
|
1195 | + ) |
|
1196 | + ), |
|
1197 | + ) |
|
1198 | + ), |
|
1199 | + ) |
|
1200 | + ); |
|
1201 | + } |
|
1202 | + |
|
1203 | + /** |
|
1204 | + * @param EE_Registration_Config $EE_Registration_Config |
|
1205 | + * @return EE_Registration_Config |
|
1206 | + * @throws EE_Error |
|
1207 | + * @throws InvalidArgumentException |
|
1208 | + * @throws ReflectionException |
|
1209 | + * @throws InvalidDataTypeException |
|
1210 | + * @throws InvalidInterfaceException |
|
1211 | + */ |
|
1212 | + public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1213 | + { |
|
1214 | + $prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo(); |
|
1215 | + try { |
|
1216 | + $copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form(); |
|
1217 | + // if not displaying a form, then check for form submission |
|
1218 | + if ($copy_attendee_info_settings_form->was_submitted()) { |
|
1219 | + // capture form data |
|
1220 | + $copy_attendee_info_settings_form->receive_form_submission(); |
|
1221 | + // validate form data |
|
1222 | + if ($copy_attendee_info_settings_form->is_valid()) { |
|
1223 | + // grab validated data from form |
|
1224 | + $valid_data = $copy_attendee_info_settings_form->valid_data(); |
|
1225 | + if (isset($valid_data['copy_attendee_info'])) { |
|
1226 | + $EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']); |
|
1227 | + } else { |
|
1228 | + EE_Error::add_error( |
|
1229 | + esc_html__( |
|
1230 | + 'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.', |
|
1231 | + 'event_espresso' |
|
1232 | + ), |
|
1233 | + __FILE__, |
|
1234 | + __FUNCTION__, |
|
1235 | + __LINE__ |
|
1236 | + ); |
|
1237 | + } |
|
1238 | + } else { |
|
1239 | + if ($copy_attendee_info_settings_form->submission_error_message() !== '') { |
|
1240 | + EE_Error::add_error( |
|
1241 | + $copy_attendee_info_settings_form->submission_error_message(), |
|
1242 | + __FILE__, |
|
1243 | + __FUNCTION__, |
|
1244 | + __LINE__ |
|
1245 | + ); |
|
1246 | + } |
|
1247 | + } |
|
1248 | + } |
|
1249 | + } catch (EE_Error $e) { |
|
1250 | + $e->get_error(); |
|
1251 | + } |
|
1252 | + return $EE_Registration_Config; |
|
1253 | + } |
|
1254 | + |
|
1255 | + |
|
1256 | + /** |
|
1257 | + * @return void |
|
1258 | + * @throws EE_Error |
|
1259 | + * @throws InvalidArgumentException |
|
1260 | + * @throws InvalidDataTypeException |
|
1261 | + * @throws InvalidInterfaceException |
|
1262 | + */ |
|
1263 | + public function email_validation_settings_form() |
|
1264 | + { |
|
1265 | + echo $this->_email_validation_settings_form()->get_html(); |
|
1266 | + } |
|
1267 | + |
|
1268 | + |
|
1269 | + /** |
|
1270 | + * _email_validation_settings_form |
|
1271 | + * |
|
1272 | + * @access protected |
|
1273 | + * @return EE_Form_Section_Proper |
|
1274 | + * @throws \EE_Error |
|
1275 | + */ |
|
1276 | + protected function _email_validation_settings_form() |
|
1277 | + { |
|
1278 | + return new EE_Form_Section_Proper( |
|
1279 | + array( |
|
1280 | + 'name' => 'email_validation_settings', |
|
1281 | + 'html_id' => 'email_validation_settings', |
|
1282 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1283 | + 'subsections' => apply_filters( |
|
1284 | + 'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections', |
|
1285 | + array( |
|
1286 | + 'email_validation_hdr' => new EE_Form_Section_HTML( |
|
1287 | + EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
1288 | + ), |
|
1289 | + 'email_validation_level' => new EE_Select_Input( |
|
1290 | + array( |
|
1291 | + 'basic' => esc_html__('Basic', 'event_espresso'), |
|
1292 | + 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
1293 | + 'i18n' => esc_html__('International', 'event_espresso'), |
|
1294 | + 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
1295 | + ), |
|
1296 | + array( |
|
1297 | + 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
1298 | + . EEH_Template::get_help_tab_link('email_validation_info'), |
|
1299 | + 'html_help_text' => esc_html__( |
|
1300 | + '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.', |
|
1301 | + 'event_espresso' |
|
1302 | + ), |
|
1303 | + 'default' => isset( |
|
1304 | + EE_Registry::instance()->CFG->registration->email_validation_level |
|
1305 | + ) |
|
1306 | + ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
1307 | + : 'wp_default', |
|
1308 | + 'required' => false, |
|
1309 | + ) |
|
1310 | + ), |
|
1311 | + ) |
|
1312 | + ), |
|
1313 | + ) |
|
1314 | + ); |
|
1315 | + } |
|
1316 | + |
|
1317 | + |
|
1318 | + /** |
|
1319 | + * @param EE_Registration_Config $EE_Registration_Config |
|
1320 | + * @return EE_Registration_Config |
|
1321 | + * @throws EE_Error |
|
1322 | + * @throws InvalidArgumentException |
|
1323 | + * @throws ReflectionException |
|
1324 | + * @throws InvalidDataTypeException |
|
1325 | + * @throws InvalidInterfaceException |
|
1326 | + */ |
|
1327 | + public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1328 | + { |
|
1329 | + $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
1330 | + try { |
|
1331 | + $email_validation_settings_form = $this->_email_validation_settings_form(); |
|
1332 | + // if not displaying a form, then check for form submission |
|
1333 | + if ($email_validation_settings_form->was_submitted()) { |
|
1334 | + // capture form data |
|
1335 | + $email_validation_settings_form->receive_form_submission(); |
|
1336 | + // validate form data |
|
1337 | + if ($email_validation_settings_form->is_valid()) { |
|
1338 | + // grab validated data from form |
|
1339 | + $valid_data = $email_validation_settings_form->valid_data(); |
|
1340 | + if (isset($valid_data['email_validation_level'])) { |
|
1341 | + $email_validation_level = $valid_data['email_validation_level']; |
|
1342 | + // now if they want to use international email addresses |
|
1343 | + if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
1344 | + // in case we need to reset their email validation level, |
|
1345 | + // make sure that the previous value wasn't already set to one of the i18n options. |
|
1346 | + if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') { |
|
1347 | + // if so, then reset it back to "basic" since that is the only other option that, |
|
1348 | + // despite offering poor validation, supports i18n email addresses |
|
1349 | + $prev_email_validation_level = 'basic'; |
|
1350 | + } |
|
1351 | + // confirm our i18n email validation will work on the server |
|
1352 | + if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1353 | + // or reset email validation level to previous value |
|
1354 | + $email_validation_level = $prev_email_validation_level; |
|
1355 | + } |
|
1356 | + } |
|
1357 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1358 | + } else { |
|
1359 | + EE_Error::add_error( |
|
1360 | + esc_html__( |
|
1361 | + 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
|
1362 | + 'event_espresso' |
|
1363 | + ), |
|
1364 | + __FILE__, |
|
1365 | + __FUNCTION__, |
|
1366 | + __LINE__ |
|
1367 | + ); |
|
1368 | + } |
|
1369 | + } else { |
|
1370 | + if ($email_validation_settings_form->submission_error_message() !== '') { |
|
1371 | + EE_Error::add_error( |
|
1372 | + $email_validation_settings_form->submission_error_message(), |
|
1373 | + __FILE__, |
|
1374 | + __FUNCTION__, |
|
1375 | + __LINE__ |
|
1376 | + ); |
|
1377 | + } |
|
1378 | + } |
|
1379 | + } |
|
1380 | + } catch (EE_Error $e) { |
|
1381 | + $e->get_error(); |
|
1382 | + } |
|
1383 | + return $EE_Registration_Config; |
|
1384 | + } |
|
1385 | + |
|
1386 | + |
|
1387 | + /** |
|
1388 | + * confirms that the server's PHP version has the PCRE module enabled, |
|
1389 | + * and that the PCRE version works with our i18n email validation |
|
1390 | + * |
|
1391 | + * @param EE_Registration_Config $EE_Registration_Config |
|
1392 | + * @param string $email_validation_level |
|
1393 | + * @return bool |
|
1394 | + */ |
|
1395 | + private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1396 | + { |
|
1397 | + // first check that PCRE is enabled |
|
1398 | + if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1399 | + EE_Error::add_error( |
|
1400 | + sprintf( |
|
1401 | + esc_html__( |
|
1402 | + '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.', |
|
1403 | + 'event_espresso' |
|
1404 | + ), |
|
1405 | + '<br />' |
|
1406 | + ), |
|
1407 | + __FILE__, |
|
1408 | + __FUNCTION__, |
|
1409 | + __LINE__ |
|
1410 | + ); |
|
1411 | + return false; |
|
1412 | + } else { |
|
1413 | + // PCRE support is enabled, but let's still |
|
1414 | + // perform a test to see if the server will support it. |
|
1415 | + // but first, save the updated validation level to the config, |
|
1416 | + // so that the validation strategy picks it up. |
|
1417 | + // this will get bumped back down if it doesn't work |
|
1418 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1419 | + try { |
|
1420 | + $email_validator = new EE_Email_Validation_Strategy(); |
|
1421 | + $i18n_email_address = apply_filters( |
|
1422 | + 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1423 | + 'jägerjü[email protected]' |
|
1424 | + ); |
|
1425 | + $email_validator->validate($i18n_email_address); |
|
1426 | + } catch (Exception $e) { |
|
1427 | + EE_Error::add_error( |
|
1428 | + sprintf( |
|
1429 | + esc_html__( |
|
1430 | + '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', |
|
1431 | + 'event_espresso' |
|
1432 | + ), |
|
1433 | + '<br />', |
|
1434 | + '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>' |
|
1435 | + ), |
|
1436 | + __FILE__, |
|
1437 | + __FUNCTION__, |
|
1438 | + __LINE__ |
|
1439 | + ); |
|
1440 | + return false; |
|
1441 | + } |
|
1442 | + } |
|
1443 | + return true; |
|
1444 | + } |
|
1445 | 1445 | } |
@@ -6,22 +6,22 @@ discard block |
||
6 | 6 | */ |
7 | 7 | function espresso_load_error_handling() |
8 | 8 | { |
9 | - static $error_handling_loaded = false; |
|
10 | - if ($error_handling_loaded) { |
|
11 | - return; |
|
12 | - } |
|
13 | - // load debugging tools |
|
14 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
15 | - require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
16 | - \EEH_Debug_Tools::instance(); |
|
17 | - } |
|
18 | - // load error handling |
|
19 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
20 | - require_once EE_CORE . 'EE_Error.core.php'; |
|
21 | - } else { |
|
22 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
23 | - } |
|
24 | - $error_handling_loaded = true; |
|
9 | + static $error_handling_loaded = false; |
|
10 | + if ($error_handling_loaded) { |
|
11 | + return; |
|
12 | + } |
|
13 | + // load debugging tools |
|
14 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
15 | + require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
16 | + \EEH_Debug_Tools::instance(); |
|
17 | + } |
|
18 | + // load error handling |
|
19 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
20 | + require_once EE_CORE . 'EE_Error.core.php'; |
|
21 | + } else { |
|
22 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
23 | + } |
|
24 | + $error_handling_loaded = true; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
@@ -35,19 +35,19 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function espresso_load_required($classname, $full_path_to_file) |
37 | 37 | { |
38 | - if (is_readable($full_path_to_file)) { |
|
39 | - require_once $full_path_to_file; |
|
40 | - } else { |
|
41 | - throw new \EE_Error( |
|
42 | - sprintf( |
|
43 | - esc_html__( |
|
44 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
45 | - 'event_espresso' |
|
46 | - ), |
|
47 | - $classname |
|
48 | - ) |
|
49 | - ); |
|
50 | - } |
|
38 | + if (is_readable($full_path_to_file)) { |
|
39 | + require_once $full_path_to_file; |
|
40 | + } else { |
|
41 | + throw new \EE_Error( |
|
42 | + sprintf( |
|
43 | + esc_html__( |
|
44 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
45 | + 'event_espresso' |
|
46 | + ), |
|
47 | + $classname |
|
48 | + ) |
|
49 | + ); |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -66,52 +66,52 @@ discard block |
||
66 | 66 | */ |
67 | 67 | function bootstrap_espresso() |
68 | 68 | { |
69 | - require_once __DIR__ . '/espresso_definitions.php'; |
|
70 | - try { |
|
71 | - espresso_load_error_handling(); |
|
72 | - // include WordPress shims for functions introduced in later versions of WordPress |
|
73 | - espresso_load_required( |
|
74 | - '', |
|
75 | - EE_CORE . 'wordpress-shims.php' |
|
76 | - ); |
|
77 | - espresso_load_required( |
|
78 | - '', |
|
79 | - EE_CORE . 'third-party-compatibility.php' |
|
80 | - ); |
|
81 | - espresso_load_required( |
|
82 | - 'EEH_Base', |
|
83 | - EE_CORE . 'helpers/EEH_Base.helper.php' |
|
84 | - ); |
|
85 | - espresso_load_required( |
|
86 | - 'EEH_File', |
|
87 | - EE_CORE . 'interfaces/EEHI_File.interface.php' |
|
88 | - ); |
|
89 | - espresso_load_required( |
|
90 | - 'EEH_File', |
|
91 | - EE_CORE . 'helpers/EEH_File.helper.php' |
|
92 | - ); |
|
93 | - espresso_load_required( |
|
94 | - 'EEH_Array', |
|
95 | - EE_CORE . 'helpers/EEH_Array.helper.php' |
|
96 | - ); |
|
97 | - espresso_load_required( |
|
98 | - 'EE_Base', |
|
99 | - EE_CORE . 'EE_Base.core.php' |
|
100 | - ); |
|
101 | - // instantiate and configure PSR4 autoloader |
|
102 | - espresso_load_required( |
|
103 | - 'Psr4Autoloader', |
|
104 | - EE_CORE . 'Psr4Autoloader.php' |
|
105 | - ); |
|
106 | - espresso_load_required( |
|
107 | - 'EE_Psr4AutoloaderInit', |
|
108 | - EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
109 | - ); |
|
110 | - $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
111 | - $AutoloaderInit->initializeAutoloader(); |
|
112 | - new EventEspresso\core\services\bootstrap\BootstrapCore(); |
|
113 | - } catch (Exception $e) { |
|
114 | - require_once EE_CORE . 'exceptions/ExceptionStackTraceDisplay.php'; |
|
115 | - new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
116 | - } |
|
69 | + require_once __DIR__ . '/espresso_definitions.php'; |
|
70 | + try { |
|
71 | + espresso_load_error_handling(); |
|
72 | + // include WordPress shims for functions introduced in later versions of WordPress |
|
73 | + espresso_load_required( |
|
74 | + '', |
|
75 | + EE_CORE . 'wordpress-shims.php' |
|
76 | + ); |
|
77 | + espresso_load_required( |
|
78 | + '', |
|
79 | + EE_CORE . 'third-party-compatibility.php' |
|
80 | + ); |
|
81 | + espresso_load_required( |
|
82 | + 'EEH_Base', |
|
83 | + EE_CORE . 'helpers/EEH_Base.helper.php' |
|
84 | + ); |
|
85 | + espresso_load_required( |
|
86 | + 'EEH_File', |
|
87 | + EE_CORE . 'interfaces/EEHI_File.interface.php' |
|
88 | + ); |
|
89 | + espresso_load_required( |
|
90 | + 'EEH_File', |
|
91 | + EE_CORE . 'helpers/EEH_File.helper.php' |
|
92 | + ); |
|
93 | + espresso_load_required( |
|
94 | + 'EEH_Array', |
|
95 | + EE_CORE . 'helpers/EEH_Array.helper.php' |
|
96 | + ); |
|
97 | + espresso_load_required( |
|
98 | + 'EE_Base', |
|
99 | + EE_CORE . 'EE_Base.core.php' |
|
100 | + ); |
|
101 | + // instantiate and configure PSR4 autoloader |
|
102 | + espresso_load_required( |
|
103 | + 'Psr4Autoloader', |
|
104 | + EE_CORE . 'Psr4Autoloader.php' |
|
105 | + ); |
|
106 | + espresso_load_required( |
|
107 | + 'EE_Psr4AutoloaderInit', |
|
108 | + EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
109 | + ); |
|
110 | + $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
111 | + $AutoloaderInit->initializeAutoloader(); |
|
112 | + new EventEspresso\core\services\bootstrap\BootstrapCore(); |
|
113 | + } catch (Exception $e) { |
|
114 | + require_once EE_CORE . 'exceptions/ExceptionStackTraceDisplay.php'; |
|
115 | + new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
116 | + } |
|
117 | 117 | } |
@@ -11,13 +11,13 @@ discard block |
||
11 | 11 | return; |
12 | 12 | } |
13 | 13 | // load debugging tools |
14 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
15 | - require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
14 | + if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) { |
|
15 | + require_once EE_HELPERS.'EEH_Debug_Tools.helper.php'; |
|
16 | 16 | \EEH_Debug_Tools::instance(); |
17 | 17 | } |
18 | 18 | // load error handling |
19 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
20 | - require_once EE_CORE . 'EE_Error.core.php'; |
|
19 | + if (is_readable(EE_CORE.'EE_Error.core.php')) { |
|
20 | + require_once EE_CORE.'EE_Error.core.php'; |
|
21 | 21 | } else { |
22 | 22 | wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
23 | 23 | } |
@@ -66,52 +66,52 @@ discard block |
||
66 | 66 | */ |
67 | 67 | function bootstrap_espresso() |
68 | 68 | { |
69 | - require_once __DIR__ . '/espresso_definitions.php'; |
|
69 | + require_once __DIR__.'/espresso_definitions.php'; |
|
70 | 70 | try { |
71 | 71 | espresso_load_error_handling(); |
72 | 72 | // include WordPress shims for functions introduced in later versions of WordPress |
73 | 73 | espresso_load_required( |
74 | 74 | '', |
75 | - EE_CORE . 'wordpress-shims.php' |
|
75 | + EE_CORE.'wordpress-shims.php' |
|
76 | 76 | ); |
77 | 77 | espresso_load_required( |
78 | 78 | '', |
79 | - EE_CORE . 'third-party-compatibility.php' |
|
79 | + EE_CORE.'third-party-compatibility.php' |
|
80 | 80 | ); |
81 | 81 | espresso_load_required( |
82 | 82 | 'EEH_Base', |
83 | - EE_CORE . 'helpers/EEH_Base.helper.php' |
|
83 | + EE_CORE.'helpers/EEH_Base.helper.php' |
|
84 | 84 | ); |
85 | 85 | espresso_load_required( |
86 | 86 | 'EEH_File', |
87 | - EE_CORE . 'interfaces/EEHI_File.interface.php' |
|
87 | + EE_CORE.'interfaces/EEHI_File.interface.php' |
|
88 | 88 | ); |
89 | 89 | espresso_load_required( |
90 | 90 | 'EEH_File', |
91 | - EE_CORE . 'helpers/EEH_File.helper.php' |
|
91 | + EE_CORE.'helpers/EEH_File.helper.php' |
|
92 | 92 | ); |
93 | 93 | espresso_load_required( |
94 | 94 | 'EEH_Array', |
95 | - EE_CORE . 'helpers/EEH_Array.helper.php' |
|
95 | + EE_CORE.'helpers/EEH_Array.helper.php' |
|
96 | 96 | ); |
97 | 97 | espresso_load_required( |
98 | 98 | 'EE_Base', |
99 | - EE_CORE . 'EE_Base.core.php' |
|
99 | + EE_CORE.'EE_Base.core.php' |
|
100 | 100 | ); |
101 | 101 | // instantiate and configure PSR4 autoloader |
102 | 102 | espresso_load_required( |
103 | 103 | 'Psr4Autoloader', |
104 | - EE_CORE . 'Psr4Autoloader.php' |
|
104 | + EE_CORE.'Psr4Autoloader.php' |
|
105 | 105 | ); |
106 | 106 | espresso_load_required( |
107 | 107 | 'EE_Psr4AutoloaderInit', |
108 | - EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
108 | + EE_CORE.'EE_Psr4AutoloaderInit.core.php' |
|
109 | 109 | ); |
110 | 110 | $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
111 | 111 | $AutoloaderInit->initializeAutoloader(); |
112 | 112 | new EventEspresso\core\services\bootstrap\BootstrapCore(); |
113 | 113 | } catch (Exception $e) { |
114 | - require_once EE_CORE . 'exceptions/ExceptionStackTraceDisplay.php'; |
|
114 | + require_once EE_CORE.'exceptions/ExceptionStackTraceDisplay.php'; |
|
115 | 115 | new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
116 | 116 | } |
117 | 117 | } |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | */ |
38 | 38 | protected function setNamespace($namespace, $namespace_base_dir) |
39 | 39 | { |
40 | - if (! is_string($namespace)) { |
|
40 | + if ( ! is_string($namespace)) { |
|
41 | 41 | throw new InvalidDataTypeException('$namespace', $namespace, 'string'); |
42 | 42 | } |
43 | - if (! is_string($namespace_base_dir)) { |
|
43 | + if ( ! is_string($namespace_base_dir)) { |
|
44 | 44 | throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string'); |
45 | 45 | } |
46 | - $this->namespaces[ $namespace ] = $namespace_base_dir; |
|
46 | + $this->namespaces[$namespace] = $namespace_base_dir; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function locate($namespaces) |
80 | 80 | { |
81 | - if (! (is_string($namespaces) || is_array($namespaces))) { |
|
81 | + if ( ! (is_string($namespaces) || is_array($namespaces))) { |
|
82 | 82 | throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array'); |
83 | 83 | } |
84 | 84 | foreach ((array) $namespaces as $namespace) { |
85 | 85 | foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) { |
86 | - $this->FQCNs[ $key ] = $file; |
|
86 | + $this->FQCNs[$key] = $file; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | return $this->FQCNs; |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | } |
114 | 114 | foreach ($iterator as $file) { |
115 | 115 | if ($file->isFile() && $file->getExtension() === 'php') { |
116 | - $file = $file->getPath() . '/' . $file->getBasename('.php'); |
|
116 | + $file = $file->getPath().'/'.$file->getBasename('.php'); |
|
117 | 117 | foreach ($this->namespaces as $namespace => $base_dir) { |
118 | 118 | $namespace .= Psr4Autoloader::NS; |
119 | 119 | if (strpos($file, $base_dir) === 0) { |
120 | - $this->FQCNs[] = Psr4Autoloader::NS . str_replace( |
|
120 | + $this->FQCNs[] = Psr4Autoloader::NS.str_replace( |
|
121 | 121 | array($base_dir, '/'), |
122 | 122 | array($namespace, Psr4Autoloader::NS), |
123 | 123 | $file |
@@ -151,11 +151,11 @@ discard block |
||
151 | 151 | // we're only interested in the Vendor and secondary base, so pull those from the array |
152 | 152 | $vendor_base = array_slice($namespace_segments, 0, 2); |
153 | 153 | $namespace = $prefix = null; |
154 | - while (! empty($vendor_base)) { |
|
154 | + while ( ! empty($vendor_base)) { |
|
155 | 155 | $namespace = implode(Psr4Autoloader::NS, $vendor_base); |
156 | 156 | // check if there's a base directory registered for that namespace |
157 | - $prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS); |
|
158 | - if (! empty($prefix) && ! empty($prefix[0])) { |
|
157 | + $prefix = $psr4_loader->prefixes($namespace.Psr4Autoloader::NS); |
|
158 | + if ( ! empty($prefix) && ! empty($prefix[0])) { |
|
159 | 159 | // found one! |
160 | 160 | break; |
161 | 161 | } |
@@ -168,6 +168,6 @@ discard block |
||
168 | 168 | } |
169 | 169 | $this->setNamespace($namespace, $prefix[0]); |
170 | 170 | // but if it's good, add that base directory to the rest of the path, and return it |
171 | - return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/'; |
|
171 | + return $prefix[0].implode('/', array_diff($namespace_segments, $vendor_base)).'/'; |
|
172 | 172 | } |
173 | 173 | } |
@@ -17,156 +17,156 @@ |
||
17 | 17 | */ |
18 | 18 | class FqcnLocator extends Locator |
19 | 19 | { |
20 | - /** |
|
21 | - * @var array $FQCNs |
|
22 | - */ |
|
23 | - protected $FQCNs = array(); |
|
24 | - |
|
25 | - /** |
|
26 | - * @var array $namespaces |
|
27 | - */ |
|
28 | - protected $namespaces = array(); |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * @access protected |
|
33 | - * @param string $namespace |
|
34 | - * @param string $namespace_base_dir |
|
35 | - * @throws InvalidDataTypeException |
|
36 | - */ |
|
37 | - protected function setNamespace($namespace, $namespace_base_dir) |
|
38 | - { |
|
39 | - if (! is_string($namespace)) { |
|
40 | - throw new InvalidDataTypeException('$namespace', $namespace, 'string'); |
|
41 | - } |
|
42 | - if (! is_string($namespace_base_dir)) { |
|
43 | - throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string'); |
|
44 | - } |
|
45 | - $this->namespaces[ $namespace ] = $namespace_base_dir; |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * @access public |
|
51 | - * @return array |
|
52 | - */ |
|
53 | - public function getFQCNs() |
|
54 | - { |
|
55 | - return $this->FQCNs; |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @access public |
|
61 | - * @return int |
|
62 | - */ |
|
63 | - public function count() |
|
64 | - { |
|
65 | - return count($this->FQCNs); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * given a valid namespace, will find all files that match the provided mask |
|
71 | - * |
|
72 | - * @access public |
|
73 | - * @param string|array $namespaces |
|
74 | - * @return array |
|
75 | - * @throws InvalidClassException |
|
76 | - * @throws InvalidDataTypeException |
|
77 | - */ |
|
78 | - public function locate($namespaces) |
|
79 | - { |
|
80 | - if (! (is_string($namespaces) || is_array($namespaces))) { |
|
81 | - throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array'); |
|
82 | - } |
|
83 | - foreach ((array) $namespaces as $namespace) { |
|
84 | - foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) { |
|
85 | - $this->FQCNs[ $key ] = $file; |
|
86 | - } |
|
87 | - } |
|
88 | - return $this->FQCNs; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * given a partial namespace, will find all files in that folder |
|
94 | - * ** PLZ NOTE ** |
|
95 | - * This assumes that all files within the specified folder should be loaded |
|
96 | - * |
|
97 | - * @access protected |
|
98 | - * @param string $partial_namespace |
|
99 | - * @return array |
|
100 | - * @throws InvalidClassException |
|
101 | - * @throws InvalidDataTypeException |
|
102 | - */ |
|
103 | - protected function findFQCNsByNamespace($partial_namespace) |
|
104 | - { |
|
105 | - $iterator = new FilesystemIterator( |
|
106 | - $this->getDirectoryFromPartialNamespace($partial_namespace) |
|
107 | - ); |
|
108 | - $iterator->setFlags(FilesystemIterator::CURRENT_AS_FILEINFO); |
|
109 | - $iterator->setFlags(FilesystemIterator::UNIX_PATHS); |
|
110 | - if (iterator_count($iterator) === 0) { |
|
111 | - return array(); |
|
112 | - } |
|
113 | - foreach ($iterator as $file) { |
|
114 | - if ($file->isFile() && $file->getExtension() === 'php') { |
|
115 | - $file = $file->getPath() . '/' . $file->getBasename('.php'); |
|
116 | - foreach ($this->namespaces as $namespace => $base_dir) { |
|
117 | - $namespace .= Psr4Autoloader::NS; |
|
118 | - if (strpos($file, $base_dir) === 0) { |
|
119 | - $this->FQCNs[] = Psr4Autoloader::NS . str_replace( |
|
120 | - array($base_dir, '/'), |
|
121 | - array($namespace, Psr4Autoloader::NS), |
|
122 | - $file |
|
123 | - ); |
|
124 | - } |
|
125 | - } |
|
126 | - } |
|
127 | - } |
|
128 | - return $this->FQCNs; |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * getDirectoryFromPartialNamespace |
|
134 | - * |
|
135 | - * @access protected |
|
136 | - * @param string $partial_namespace almost fully qualified class name ? |
|
137 | - * @return string |
|
138 | - * @throws InvalidDataTypeException |
|
139 | - * @throws InvalidClassException |
|
140 | - */ |
|
141 | - protected function getDirectoryFromPartialNamespace($partial_namespace) |
|
142 | - { |
|
143 | - if (empty($partial_namespace)) { |
|
144 | - throw new InvalidClassException($partial_namespace); |
|
145 | - } |
|
146 | - // load our PSR-4 Autoloader so we can get the list of registered namespaces from it |
|
147 | - $psr4_loader = \EE_Psr4AutoloaderInit::psr4_loader(); |
|
148 | - // breakup the incoming namespace into segments so we can loop thru them |
|
149 | - $namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS)); |
|
150 | - // we're only interested in the Vendor and secondary base, so pull those from the array |
|
151 | - $vendor_base = array_slice($namespace_segments, 0, 2); |
|
152 | - $namespace = $prefix = null; |
|
153 | - while (! empty($vendor_base)) { |
|
154 | - $namespace = implode(Psr4Autoloader::NS, $vendor_base); |
|
155 | - // check if there's a base directory registered for that namespace |
|
156 | - $prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS); |
|
157 | - if (! empty($prefix) && ! empty($prefix[0])) { |
|
158 | - // found one! |
|
159 | - break; |
|
160 | - } |
|
161 | - // remove base and try vendor only portion of namespace |
|
162 | - array_pop($vendor_base); |
|
163 | - } |
|
164 | - // nope? then the incoming namespace is invalid |
|
165 | - if (empty($prefix) || empty($prefix[0])) { |
|
166 | - throw new InvalidClassException($partial_namespace); |
|
167 | - } |
|
168 | - $this->setNamespace($namespace, $prefix[0]); |
|
169 | - // but if it's good, add that base directory to the rest of the path, and return it |
|
170 | - return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/'; |
|
171 | - } |
|
20 | + /** |
|
21 | + * @var array $FQCNs |
|
22 | + */ |
|
23 | + protected $FQCNs = array(); |
|
24 | + |
|
25 | + /** |
|
26 | + * @var array $namespaces |
|
27 | + */ |
|
28 | + protected $namespaces = array(); |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * @access protected |
|
33 | + * @param string $namespace |
|
34 | + * @param string $namespace_base_dir |
|
35 | + * @throws InvalidDataTypeException |
|
36 | + */ |
|
37 | + protected function setNamespace($namespace, $namespace_base_dir) |
|
38 | + { |
|
39 | + if (! is_string($namespace)) { |
|
40 | + throw new InvalidDataTypeException('$namespace', $namespace, 'string'); |
|
41 | + } |
|
42 | + if (! is_string($namespace_base_dir)) { |
|
43 | + throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string'); |
|
44 | + } |
|
45 | + $this->namespaces[ $namespace ] = $namespace_base_dir; |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * @access public |
|
51 | + * @return array |
|
52 | + */ |
|
53 | + public function getFQCNs() |
|
54 | + { |
|
55 | + return $this->FQCNs; |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @access public |
|
61 | + * @return int |
|
62 | + */ |
|
63 | + public function count() |
|
64 | + { |
|
65 | + return count($this->FQCNs); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * given a valid namespace, will find all files that match the provided mask |
|
71 | + * |
|
72 | + * @access public |
|
73 | + * @param string|array $namespaces |
|
74 | + * @return array |
|
75 | + * @throws InvalidClassException |
|
76 | + * @throws InvalidDataTypeException |
|
77 | + */ |
|
78 | + public function locate($namespaces) |
|
79 | + { |
|
80 | + if (! (is_string($namespaces) || is_array($namespaces))) { |
|
81 | + throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array'); |
|
82 | + } |
|
83 | + foreach ((array) $namespaces as $namespace) { |
|
84 | + foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) { |
|
85 | + $this->FQCNs[ $key ] = $file; |
|
86 | + } |
|
87 | + } |
|
88 | + return $this->FQCNs; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * given a partial namespace, will find all files in that folder |
|
94 | + * ** PLZ NOTE ** |
|
95 | + * This assumes that all files within the specified folder should be loaded |
|
96 | + * |
|
97 | + * @access protected |
|
98 | + * @param string $partial_namespace |
|
99 | + * @return array |
|
100 | + * @throws InvalidClassException |
|
101 | + * @throws InvalidDataTypeException |
|
102 | + */ |
|
103 | + protected function findFQCNsByNamespace($partial_namespace) |
|
104 | + { |
|
105 | + $iterator = new FilesystemIterator( |
|
106 | + $this->getDirectoryFromPartialNamespace($partial_namespace) |
|
107 | + ); |
|
108 | + $iterator->setFlags(FilesystemIterator::CURRENT_AS_FILEINFO); |
|
109 | + $iterator->setFlags(FilesystemIterator::UNIX_PATHS); |
|
110 | + if (iterator_count($iterator) === 0) { |
|
111 | + return array(); |
|
112 | + } |
|
113 | + foreach ($iterator as $file) { |
|
114 | + if ($file->isFile() && $file->getExtension() === 'php') { |
|
115 | + $file = $file->getPath() . '/' . $file->getBasename('.php'); |
|
116 | + foreach ($this->namespaces as $namespace => $base_dir) { |
|
117 | + $namespace .= Psr4Autoloader::NS; |
|
118 | + if (strpos($file, $base_dir) === 0) { |
|
119 | + $this->FQCNs[] = Psr4Autoloader::NS . str_replace( |
|
120 | + array($base_dir, '/'), |
|
121 | + array($namespace, Psr4Autoloader::NS), |
|
122 | + $file |
|
123 | + ); |
|
124 | + } |
|
125 | + } |
|
126 | + } |
|
127 | + } |
|
128 | + return $this->FQCNs; |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * getDirectoryFromPartialNamespace |
|
134 | + * |
|
135 | + * @access protected |
|
136 | + * @param string $partial_namespace almost fully qualified class name ? |
|
137 | + * @return string |
|
138 | + * @throws InvalidDataTypeException |
|
139 | + * @throws InvalidClassException |
|
140 | + */ |
|
141 | + protected function getDirectoryFromPartialNamespace($partial_namespace) |
|
142 | + { |
|
143 | + if (empty($partial_namespace)) { |
|
144 | + throw new InvalidClassException($partial_namespace); |
|
145 | + } |
|
146 | + // load our PSR-4 Autoloader so we can get the list of registered namespaces from it |
|
147 | + $psr4_loader = \EE_Psr4AutoloaderInit::psr4_loader(); |
|
148 | + // breakup the incoming namespace into segments so we can loop thru them |
|
149 | + $namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS)); |
|
150 | + // we're only interested in the Vendor and secondary base, so pull those from the array |
|
151 | + $vendor_base = array_slice($namespace_segments, 0, 2); |
|
152 | + $namespace = $prefix = null; |
|
153 | + while (! empty($vendor_base)) { |
|
154 | + $namespace = implode(Psr4Autoloader::NS, $vendor_base); |
|
155 | + // check if there's a base directory registered for that namespace |
|
156 | + $prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS); |
|
157 | + if (! empty($prefix) && ! empty($prefix[0])) { |
|
158 | + // found one! |
|
159 | + break; |
|
160 | + } |
|
161 | + // remove base and try vendor only portion of namespace |
|
162 | + array_pop($vendor_base); |
|
163 | + } |
|
164 | + // nope? then the incoming namespace is invalid |
|
165 | + if (empty($prefix) || empty($prefix[0])) { |
|
166 | + throw new InvalidClassException($partial_namespace); |
|
167 | + } |
|
168 | + $this->setNamespace($namespace, $prefix[0]); |
|
169 | + // but if it's good, add that base directory to the rest of the path, and return it |
|
170 | + return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/'; |
|
171 | + } |
|
172 | 172 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | { |
91 | 91 | espresso_load_required( |
92 | 92 | 'EE_Request', |
93 | - EE_CORE . 'request_stack/EE_Request.core.php' |
|
93 | + EE_CORE.'request_stack/EE_Request.core.php' |
|
94 | 94 | ); |
95 | 95 | $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER); |
96 | 96 | $this->legacy_request->setRequest($this->request); |
@@ -28,84 +28,84 @@ |
||
28 | 28 | */ |
29 | 29 | class BootstrapRequestResponseObjects |
30 | 30 | { |
31 | - /** |
|
32 | - * @type LegacyRequestInterface $legacy_request |
|
33 | - */ |
|
34 | - protected $legacy_request; |
|
31 | + /** |
|
32 | + * @type LegacyRequestInterface $legacy_request |
|
33 | + */ |
|
34 | + protected $legacy_request; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @type LoaderInterface $loader |
|
38 | - */ |
|
39 | - protected $loader; |
|
36 | + /** |
|
37 | + * @type LoaderInterface $loader |
|
38 | + */ |
|
39 | + protected $loader; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var RequestInterface $request |
|
43 | - */ |
|
44 | - protected $request; |
|
41 | + /** |
|
42 | + * @var RequestInterface $request |
|
43 | + */ |
|
44 | + protected $request; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @var ResponseInterface $response |
|
48 | - */ |
|
49 | - protected $response; |
|
46 | + /** |
|
47 | + * @var ResponseInterface $response |
|
48 | + */ |
|
49 | + protected $response; |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * BootstrapRequestResponseObjects constructor. |
|
54 | - * |
|
55 | - * @param LoaderInterface $loader |
|
56 | - */ |
|
57 | - public function __construct(LoaderInterface $loader) |
|
58 | - { |
|
59 | - $this->loader = $loader; |
|
60 | - } |
|
52 | + /** |
|
53 | + * BootstrapRequestResponseObjects constructor. |
|
54 | + * |
|
55 | + * @param LoaderInterface $loader |
|
56 | + */ |
|
57 | + public function __construct(LoaderInterface $loader) |
|
58 | + { |
|
59 | + $this->loader = $loader; |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @return void |
|
65 | - */ |
|
66 | - public function buildRequestResponse() |
|
67 | - { |
|
68 | - $request_params = new RequestParams(new RequestSanitizer()); |
|
69 | - $server_params = new ServerParams(new ServerSanitizer()); |
|
70 | - // load our Request and Response objects |
|
71 | - $this->request = new Request($request_params, $server_params); |
|
72 | - $this->response = new Response(); |
|
73 | - $this->loader->share(RequestParams::class, $request_params); |
|
74 | - $this->loader->share(ServerParams::class, $server_params); |
|
75 | - } |
|
63 | + /** |
|
64 | + * @return void |
|
65 | + */ |
|
66 | + public function buildRequestResponse() |
|
67 | + { |
|
68 | + $request_params = new RequestParams(new RequestSanitizer()); |
|
69 | + $server_params = new ServerParams(new ServerSanitizer()); |
|
70 | + // load our Request and Response objects |
|
71 | + $this->request = new Request($request_params, $server_params); |
|
72 | + $this->response = new Response(); |
|
73 | + $this->loader->share(RequestParams::class, $request_params); |
|
74 | + $this->loader->share(ServerParams::class, $server_params); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * @return void |
|
80 | - * @throws InvalidArgumentException |
|
81 | - */ |
|
82 | - public function shareRequestResponse() |
|
83 | - { |
|
84 | - $this->loader->share('EventEspresso\core\services\request\Request', $this->request); |
|
85 | - $this->loader->share('EventEspresso\core\services\request\Response', $this->response); |
|
86 | - EE_Dependency_Map::instance()->setRequest($this->request); |
|
87 | - EE_Dependency_Map::instance()->setResponse($this->response); |
|
88 | - } |
|
78 | + /** |
|
79 | + * @return void |
|
80 | + * @throws InvalidArgumentException |
|
81 | + */ |
|
82 | + public function shareRequestResponse() |
|
83 | + { |
|
84 | + $this->loader->share('EventEspresso\core\services\request\Request', $this->request); |
|
85 | + $this->loader->share('EventEspresso\core\services\request\Response', $this->response); |
|
86 | + EE_Dependency_Map::instance()->setRequest($this->request); |
|
87 | + EE_Dependency_Map::instance()->setResponse($this->response); |
|
88 | + } |
|
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * @return void |
|
93 | - * @throws InvalidArgumentException |
|
94 | - * @throws EE_Error |
|
95 | - */ |
|
96 | - public function setupLegacyRequest() |
|
97 | - { |
|
98 | - espresso_load_required( |
|
99 | - 'EE_Request', |
|
100 | - EE_CORE . 'request_stack/EE_Request.core.php' |
|
101 | - ); |
|
102 | - $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER); |
|
103 | - $this->legacy_request->setRequest($this->request); |
|
104 | - $this->legacy_request->admin = $this->request->isAdmin(); |
|
105 | - $this->legacy_request->ajax = $this->request->isAjax(); |
|
106 | - $this->legacy_request->front_ajax = $this->request->isFrontAjax(); |
|
107 | - EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request); |
|
108 | - $this->loader->share('EE_Request', $this->legacy_request); |
|
109 | - $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request); |
|
110 | - } |
|
91 | + /** |
|
92 | + * @return void |
|
93 | + * @throws InvalidArgumentException |
|
94 | + * @throws EE_Error |
|
95 | + */ |
|
96 | + public function setupLegacyRequest() |
|
97 | + { |
|
98 | + espresso_load_required( |
|
99 | + 'EE_Request', |
|
100 | + EE_CORE . 'request_stack/EE_Request.core.php' |
|
101 | + ); |
|
102 | + $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER); |
|
103 | + $this->legacy_request->setRequest($this->request); |
|
104 | + $this->legacy_request->admin = $this->request->isAdmin(); |
|
105 | + $this->legacy_request->ajax = $this->request->isAjax(); |
|
106 | + $this->legacy_request->front_ajax = $this->request->isFrontAjax(); |
|
107 | + EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request); |
|
108 | + $this->loader->share('EE_Request', $this->legacy_request); |
|
109 | + $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request); |
|
110 | + } |
|
111 | 111 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | // load interfaces |
200 | 200 | espresso_load_required( |
201 | 201 | 'EEH_Autoloader', |
202 | - EE_CORE . 'helpers/EEH_Autoloader.helper.php' |
|
202 | + EE_CORE.'helpers/EEH_Autoloader.helper.php' |
|
203 | 203 | ); |
204 | 204 | EEH_Autoloader::instance(); |
205 | 205 | } |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | protected function setAutoloadersForRequiredFiles() |
214 | 214 | { |
215 | 215 | // load interfaces |
216 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
216 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces', true); |
|
217 | 217 | // load helpers |
218 | 218 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
219 | 219 | // register legacy request stack classes just in case |
220 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/'); |
|
220 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'request_stack/'); |
|
221 | 221 | // register legacy middleware classes just in case |
222 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/'); |
|
222 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'middleware/'); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 |
@@ -46,225 +46,225 @@ |
||
46 | 46 | */ |
47 | 47 | class BootstrapCore |
48 | 48 | { |
49 | - /** |
|
50 | - * @type LoaderInterface $loader |
|
51 | - */ |
|
52 | - private $loader; |
|
49 | + /** |
|
50 | + * @type LoaderInterface $loader |
|
51 | + */ |
|
52 | + private $loader; |
|
53 | 53 | |
54 | - /** |
|
55 | - * @var RequestInterface $request |
|
56 | - */ |
|
57 | - protected $request; |
|
54 | + /** |
|
55 | + * @var RequestInterface $request |
|
56 | + */ |
|
57 | + protected $request; |
|
58 | 58 | |
59 | - /** |
|
60 | - * @var ResponseInterface $response |
|
61 | - */ |
|
62 | - protected $response; |
|
59 | + /** |
|
60 | + * @var ResponseInterface $response |
|
61 | + */ |
|
62 | + protected $response; |
|
63 | 63 | |
64 | - /** |
|
65 | - * @var RequestStackBuilder $request_stack_builder |
|
66 | - */ |
|
67 | - protected $request_stack_builder; |
|
64 | + /** |
|
65 | + * @var RequestStackBuilder $request_stack_builder |
|
66 | + */ |
|
67 | + protected $request_stack_builder; |
|
68 | 68 | |
69 | - /** |
|
70 | - * @var RequestStack $request_stack |
|
71 | - */ |
|
72 | - protected $request_stack; |
|
69 | + /** |
|
70 | + * @var RequestStack $request_stack |
|
71 | + */ |
|
72 | + protected $request_stack; |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * BootstrapCore constructor. |
|
77 | - */ |
|
78 | - public function __construct() |
|
79 | - { |
|
80 | - do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct'); |
|
81 | - // construct request stack and run middleware apps as soon as all WP plugins are loaded |
|
82 | - add_action('plugins_loaded', array($this, 'initialize'), 0); |
|
83 | - } |
|
75 | + /** |
|
76 | + * BootstrapCore constructor. |
|
77 | + */ |
|
78 | + public function __construct() |
|
79 | + { |
|
80 | + do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct'); |
|
81 | + // construct request stack and run middleware apps as soon as all WP plugins are loaded |
|
82 | + add_action('plugins_loaded', array($this, 'initialize'), 0); |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | - /** |
|
87 | - * @throws DomainException |
|
88 | - * @throws EE_Error |
|
89 | - * @throws Exception |
|
90 | - * @throws InvalidArgumentException |
|
91 | - * @throws InvalidClassException |
|
92 | - * @throws InvalidDataTypeException |
|
93 | - * @throws InvalidFilePathException |
|
94 | - * @throws InvalidInterfaceException |
|
95 | - * @throws InvalidRequestStackMiddlewareException |
|
96 | - * @throws OutOfBoundsException |
|
97 | - * @throws ReflectionException |
|
98 | - */ |
|
99 | - public function initialize() |
|
100 | - { |
|
101 | - $this->bootstrapDependencyInjectionContainer(); |
|
102 | - $this->bootstrapDomain(); |
|
103 | - $bootstrap_request = $this->bootstrapRequestResponseObjects(); |
|
104 | - add_action( |
|
105 | - 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', |
|
106 | - array($bootstrap_request, 'setupLegacyRequest') |
|
107 | - ); |
|
108 | - $this->runRequestStack(); |
|
109 | - } |
|
86 | + /** |
|
87 | + * @throws DomainException |
|
88 | + * @throws EE_Error |
|
89 | + * @throws Exception |
|
90 | + * @throws InvalidArgumentException |
|
91 | + * @throws InvalidClassException |
|
92 | + * @throws InvalidDataTypeException |
|
93 | + * @throws InvalidFilePathException |
|
94 | + * @throws InvalidInterfaceException |
|
95 | + * @throws InvalidRequestStackMiddlewareException |
|
96 | + * @throws OutOfBoundsException |
|
97 | + * @throws ReflectionException |
|
98 | + */ |
|
99 | + public function initialize() |
|
100 | + { |
|
101 | + $this->bootstrapDependencyInjectionContainer(); |
|
102 | + $this->bootstrapDomain(); |
|
103 | + $bootstrap_request = $this->bootstrapRequestResponseObjects(); |
|
104 | + add_action( |
|
105 | + 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', |
|
106 | + array($bootstrap_request, 'setupLegacyRequest') |
|
107 | + ); |
|
108 | + $this->runRequestStack(); |
|
109 | + } |
|
110 | 110 | |
111 | 111 | |
112 | - /** |
|
113 | - * @throws ReflectionException |
|
114 | - * @throws EE_Error |
|
115 | - * @throws InvalidArgumentException |
|
116 | - * @throws InvalidDataTypeException |
|
117 | - * @throws InvalidInterfaceException |
|
118 | - * @throws OutOfBoundsException |
|
119 | - */ |
|
120 | - private function bootstrapDependencyInjectionContainer() |
|
121 | - { |
|
122 | - $bootstrap_di = new BootstrapDependencyInjectionContainer(); |
|
123 | - $bootstrap_di->buildLegacyDependencyInjectionContainer(); |
|
124 | - $bootstrap_di->buildLoader(); |
|
125 | - $registry = $bootstrap_di->getRegistry(); |
|
126 | - $dependency_map = $bootstrap_di->getDependencyMap(); |
|
127 | - $dependency_map->initialize(); |
|
128 | - $registry->initialize(); |
|
129 | - $this->loader = $bootstrap_di->getLoader(); |
|
130 | - } |
|
112 | + /** |
|
113 | + * @throws ReflectionException |
|
114 | + * @throws EE_Error |
|
115 | + * @throws InvalidArgumentException |
|
116 | + * @throws InvalidDataTypeException |
|
117 | + * @throws InvalidInterfaceException |
|
118 | + * @throws OutOfBoundsException |
|
119 | + */ |
|
120 | + private function bootstrapDependencyInjectionContainer() |
|
121 | + { |
|
122 | + $bootstrap_di = new BootstrapDependencyInjectionContainer(); |
|
123 | + $bootstrap_di->buildLegacyDependencyInjectionContainer(); |
|
124 | + $bootstrap_di->buildLoader(); |
|
125 | + $registry = $bootstrap_di->getRegistry(); |
|
126 | + $dependency_map = $bootstrap_di->getDependencyMap(); |
|
127 | + $dependency_map->initialize(); |
|
128 | + $registry->initialize(); |
|
129 | + $this->loader = $bootstrap_di->getLoader(); |
|
130 | + } |
|
131 | 131 | |
132 | 132 | |
133 | - /** |
|
134 | - * configures the Domain object for core |
|
135 | - * |
|
136 | - * @return void |
|
137 | - * @throws DomainException |
|
138 | - * @throws InvalidArgumentException |
|
139 | - * @throws InvalidDataTypeException |
|
140 | - * @throws InvalidClassException |
|
141 | - * @throws InvalidFilePathException |
|
142 | - * @throws InvalidInterfaceException |
|
143 | - */ |
|
144 | - private function bootstrapDomain() |
|
145 | - { |
|
146 | - DomainFactory::getEventEspressoCoreDomain(); |
|
147 | - } |
|
133 | + /** |
|
134 | + * configures the Domain object for core |
|
135 | + * |
|
136 | + * @return void |
|
137 | + * @throws DomainException |
|
138 | + * @throws InvalidArgumentException |
|
139 | + * @throws InvalidDataTypeException |
|
140 | + * @throws InvalidClassException |
|
141 | + * @throws InvalidFilePathException |
|
142 | + * @throws InvalidInterfaceException |
|
143 | + */ |
|
144 | + private function bootstrapDomain() |
|
145 | + { |
|
146 | + DomainFactory::getEventEspressoCoreDomain(); |
|
147 | + } |
|
148 | 148 | |
149 | 149 | |
150 | - /** |
|
151 | - * sets up the request and response objects |
|
152 | - * |
|
153 | - * @return BootstrapRequestResponseObjects |
|
154 | - * @throws InvalidArgumentException |
|
155 | - */ |
|
156 | - private function bootstrapRequestResponseObjects() |
|
157 | - { |
|
158 | - /** @var BootstrapRequestResponseObjects $bootstrap_request */ |
|
159 | - $bootstrap_request = $this->loader->getShared( |
|
160 | - 'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects', |
|
161 | - array($this->loader) |
|
162 | - ); |
|
163 | - $bootstrap_request->buildRequestResponse(); |
|
164 | - $bootstrap_request->shareRequestResponse(); |
|
165 | - $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request'); |
|
166 | - $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response'); |
|
167 | - return $bootstrap_request; |
|
168 | - } |
|
150 | + /** |
|
151 | + * sets up the request and response objects |
|
152 | + * |
|
153 | + * @return BootstrapRequestResponseObjects |
|
154 | + * @throws InvalidArgumentException |
|
155 | + */ |
|
156 | + private function bootstrapRequestResponseObjects() |
|
157 | + { |
|
158 | + /** @var BootstrapRequestResponseObjects $bootstrap_request */ |
|
159 | + $bootstrap_request = $this->loader->getShared( |
|
160 | + 'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects', |
|
161 | + array($this->loader) |
|
162 | + ); |
|
163 | + $bootstrap_request->buildRequestResponse(); |
|
164 | + $bootstrap_request->shareRequestResponse(); |
|
165 | + $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request'); |
|
166 | + $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response'); |
|
167 | + return $bootstrap_request; |
|
168 | + } |
|
169 | 169 | |
170 | 170 | |
171 | - /** |
|
172 | - * run_request_stack |
|
173 | - * construct request stack and run middleware apps |
|
174 | - * |
|
175 | - * @throws EE_Error |
|
176 | - * @throws Exception |
|
177 | - */ |
|
178 | - public function runRequestStack() |
|
179 | - { |
|
180 | - $this->loadAutoloader(); |
|
181 | - $this->setAutoloadersForRequiredFiles(); |
|
182 | - $this->request_stack_builder = $this->buildRequestStack(); |
|
183 | - $this->request_stack = $this->request_stack_builder->resolve( |
|
184 | - new RequestStackCoreApp() |
|
185 | - ); |
|
186 | - $this->request_stack->handleRequest($this->request, $this->response); |
|
187 | - $this->request_stack->handleResponse(); |
|
188 | - } |
|
171 | + /** |
|
172 | + * run_request_stack |
|
173 | + * construct request stack and run middleware apps |
|
174 | + * |
|
175 | + * @throws EE_Error |
|
176 | + * @throws Exception |
|
177 | + */ |
|
178 | + public function runRequestStack() |
|
179 | + { |
|
180 | + $this->loadAutoloader(); |
|
181 | + $this->setAutoloadersForRequiredFiles(); |
|
182 | + $this->request_stack_builder = $this->buildRequestStack(); |
|
183 | + $this->request_stack = $this->request_stack_builder->resolve( |
|
184 | + new RequestStackCoreApp() |
|
185 | + ); |
|
186 | + $this->request_stack->handleRequest($this->request, $this->response); |
|
187 | + $this->request_stack->handleResponse(); |
|
188 | + } |
|
189 | 189 | |
190 | 190 | |
191 | - /** |
|
192 | - * load_autoloader |
|
193 | - * |
|
194 | - * @throws EE_Error |
|
195 | - */ |
|
196 | - protected function loadAutoloader() |
|
197 | - { |
|
198 | - // load interfaces |
|
199 | - espresso_load_required( |
|
200 | - 'EEH_Autoloader', |
|
201 | - EE_CORE . 'helpers/EEH_Autoloader.helper.php' |
|
202 | - ); |
|
203 | - EEH_Autoloader::instance(); |
|
204 | - } |
|
191 | + /** |
|
192 | + * load_autoloader |
|
193 | + * |
|
194 | + * @throws EE_Error |
|
195 | + */ |
|
196 | + protected function loadAutoloader() |
|
197 | + { |
|
198 | + // load interfaces |
|
199 | + espresso_load_required( |
|
200 | + 'EEH_Autoloader', |
|
201 | + EE_CORE . 'helpers/EEH_Autoloader.helper.php' |
|
202 | + ); |
|
203 | + EEH_Autoloader::instance(); |
|
204 | + } |
|
205 | 205 | |
206 | 206 | |
207 | - /** |
|
208 | - * load_required_files |
|
209 | - * |
|
210 | - * @throws EE_Error |
|
211 | - */ |
|
212 | - protected function setAutoloadersForRequiredFiles() |
|
213 | - { |
|
214 | - // load interfaces |
|
215 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
216 | - // load helpers |
|
217 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
218 | - // register legacy request stack classes just in case |
|
219 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/'); |
|
220 | - // register legacy middleware classes just in case |
|
221 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/'); |
|
222 | - } |
|
207 | + /** |
|
208 | + * load_required_files |
|
209 | + * |
|
210 | + * @throws EE_Error |
|
211 | + */ |
|
212 | + protected function setAutoloadersForRequiredFiles() |
|
213 | + { |
|
214 | + // load interfaces |
|
215 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
216 | + // load helpers |
|
217 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
218 | + // register legacy request stack classes just in case |
|
219 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/'); |
|
220 | + // register legacy middleware classes just in case |
|
221 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/'); |
|
222 | + } |
|
223 | 223 | |
224 | 224 | |
225 | - /** |
|
226 | - * build_request_stack |
|
227 | - * |
|
228 | - * @return RequestStackBuilder |
|
229 | - */ |
|
230 | - public function buildRequestStack() |
|
231 | - { |
|
232 | - $request_stack_builder = new RequestStackBuilder($this->loader); |
|
233 | - /** |
|
234 | - * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT |
|
235 | - * so items at the beginning of the final middleware stack will run last. |
|
236 | - * First parameter is the middleware classname, second is an array of arguments |
|
237 | - */ |
|
238 | - $stack_apps = apply_filters( |
|
239 | - 'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps', |
|
240 | - array( |
|
241 | - // first in last out |
|
242 | - 'EventEspresso\core\services\request\middleware\BotDetector' => array(), |
|
243 | - 'EventEspresso\core\services\request\middleware\DetectFileEditorRequest' => array(), |
|
244 | - 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(), |
|
245 | - 'EventEspresso\core\services\request\middleware\RecommendedVersions' => array(), |
|
246 | - // last in first out |
|
247 | - 'EventEspresso\core\services\request\middleware\DetectLogin' => array(), |
|
248 | - ) |
|
249 | - ); |
|
250 | - // legacy filter for backwards compatibility |
|
251 | - $stack_apps = apply_filters( |
|
252 | - 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
|
253 | - $stack_apps |
|
254 | - ); |
|
255 | - // load middleware onto stack : FILO (First In Last Out) |
|
256 | - // items at the beginning of the $stack_apps array will run last |
|
257 | - foreach ((array) $stack_apps as $stack_app => $stack_app_args) { |
|
258 | - $request_stack_builder->push(array($stack_app, $stack_app_args)); |
|
259 | - } |
|
260 | - // finally, we'll add this on its own because we need it to always be part of the stack |
|
261 | - // and we also need it to always run first because the rest of the system relies on it |
|
262 | - $request_stack_builder->push( |
|
263 | - array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array()) |
|
264 | - ); |
|
265 | - return apply_filters( |
|
266 | - 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
|
267 | - $request_stack_builder |
|
268 | - ); |
|
269 | - } |
|
225 | + /** |
|
226 | + * build_request_stack |
|
227 | + * |
|
228 | + * @return RequestStackBuilder |
|
229 | + */ |
|
230 | + public function buildRequestStack() |
|
231 | + { |
|
232 | + $request_stack_builder = new RequestStackBuilder($this->loader); |
|
233 | + /** |
|
234 | + * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT |
|
235 | + * so items at the beginning of the final middleware stack will run last. |
|
236 | + * First parameter is the middleware classname, second is an array of arguments |
|
237 | + */ |
|
238 | + $stack_apps = apply_filters( |
|
239 | + 'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps', |
|
240 | + array( |
|
241 | + // first in last out |
|
242 | + 'EventEspresso\core\services\request\middleware\BotDetector' => array(), |
|
243 | + 'EventEspresso\core\services\request\middleware\DetectFileEditorRequest' => array(), |
|
244 | + 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(), |
|
245 | + 'EventEspresso\core\services\request\middleware\RecommendedVersions' => array(), |
|
246 | + // last in first out |
|
247 | + 'EventEspresso\core\services\request\middleware\DetectLogin' => array(), |
|
248 | + ) |
|
249 | + ); |
|
250 | + // legacy filter for backwards compatibility |
|
251 | + $stack_apps = apply_filters( |
|
252 | + 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
|
253 | + $stack_apps |
|
254 | + ); |
|
255 | + // load middleware onto stack : FILO (First In Last Out) |
|
256 | + // items at the beginning of the $stack_apps array will run last |
|
257 | + foreach ((array) $stack_apps as $stack_app => $stack_app_args) { |
|
258 | + $request_stack_builder->push(array($stack_app, $stack_app_args)); |
|
259 | + } |
|
260 | + // finally, we'll add this on its own because we need it to always be part of the stack |
|
261 | + // and we also need it to always run first because the rest of the system relies on it |
|
262 | + $request_stack_builder->push( |
|
263 | + array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array()) |
|
264 | + ); |
|
265 | + return apply_filters( |
|
266 | + 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
|
267 | + $request_stack_builder |
|
268 | + ); |
|
269 | + } |
|
270 | 270 | } |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | array(), |
130 | 130 | CoffeeMaker::BREW_LOAD_ONLY, |
131 | 131 | array( |
132 | - EE_INTERFACES . '*.php', |
|
133 | - EE_INTERFACES . '*.interfaces.php', |
|
132 | + EE_INTERFACES.'*.php', |
|
133 | + EE_INTERFACES.'*.interfaces.php', |
|
134 | 134 | ) |
135 | 135 | ) |
136 | 136 | ); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | array(), |
143 | 143 | array(), |
144 | 144 | CoffeeMaker::BREW_SHARED, |
145 | - EE_MODELS . '*.model.php' |
|
145 | + EE_MODELS.'*.model.php' |
|
146 | 146 | ) |
147 | 147 | ); |
148 | 148 | // add a wildcard recipe for loading core classes |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | array(), |
155 | 155 | CoffeeMaker::BREW_SHARED, |
156 | 156 | array( |
157 | - EE_CORE . '*.core.php', |
|
158 | - EE_ADMIN . '*.core.php', |
|
159 | - EE_CPTS . '*.core.php', |
|
160 | - EE_CORE . 'data_migration_scripts/*.core.php', |
|
157 | + EE_CORE.'*.core.php', |
|
158 | + EE_ADMIN.'*.core.php', |
|
159 | + EE_CPTS.'*.core.php', |
|
160 | + EE_CORE.'data_migration_scripts/*.core.php', |
|
161 | 161 | ) |
162 | 162 | ) |
163 | 163 | ); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | array(), |
170 | 170 | array(), |
171 | 171 | CoffeeMaker::BREW_LOAD_ONLY, |
172 | - array(EE_ADMIN . '*.core.php') |
|
172 | + array(EE_ADMIN.'*.core.php') |
|
173 | 173 | ) |
174 | 174 | ); |
175 | 175 | // add a wildcard recipe for loading core classes |
@@ -19,192 +19,192 @@ |
||
19 | 19 | */ |
20 | 20 | class OpenCoffeeShop |
21 | 21 | { |
22 | - /** |
|
23 | - * @var CoffeeShop $CoffeeShop |
|
24 | - */ |
|
25 | - private $CoffeeShop; |
|
22 | + /** |
|
23 | + * @var CoffeeShop $CoffeeShop |
|
24 | + */ |
|
25 | + private $CoffeeShop; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * OpenCoffeeShop constructor |
|
30 | - * |
|
31 | - * @throws InvalidInterfaceException |
|
32 | - */ |
|
33 | - public function __construct() |
|
34 | - { |
|
35 | - // instantiate the DI container |
|
36 | - $this->CoffeeShop = new CoffeeShop(); |
|
37 | - } |
|
28 | + /** |
|
29 | + * OpenCoffeeShop constructor |
|
30 | + * |
|
31 | + * @throws InvalidInterfaceException |
|
32 | + */ |
|
33 | + public function __construct() |
|
34 | + { |
|
35 | + // instantiate the DI container |
|
36 | + $this->CoffeeShop = new CoffeeShop(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
41 | - /** |
|
42 | - * @return CoffeeShop |
|
43 | - */ |
|
44 | - public function CoffeeShop() |
|
45 | - { |
|
46 | - return $this->CoffeeShop; |
|
47 | - } |
|
40 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
41 | + /** |
|
42 | + * @return CoffeeShop |
|
43 | + */ |
|
44 | + public function CoffeeShop() |
|
45 | + { |
|
46 | + return $this->CoffeeShop; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * configure coffee makers which control the different kinds of brews |
|
52 | - * ( shared services, new factory objects, etc ) |
|
53 | - * |
|
54 | - * @throws InvalidEntityException |
|
55 | - */ |
|
56 | - public function setupCoffeeMakers() |
|
57 | - { |
|
58 | - // create a dependency injector class for resolving class constructor arguments |
|
59 | - $DependencyInjector = new DependencyInjector( |
|
60 | - $this->CoffeeShop, |
|
61 | - new \EEH_Array() |
|
62 | - ); |
|
63 | - // and some coffeemakers, one for creating new instances |
|
64 | - $this->CoffeeShop->addCoffeeMaker( |
|
65 | - new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
66 | - CoffeeMaker::BREW_NEW |
|
67 | - ); |
|
68 | - // one for shared services |
|
69 | - $this->CoffeeShop->addCoffeeMaker( |
|
70 | - new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
71 | - CoffeeMaker::BREW_SHARED |
|
72 | - ); |
|
73 | - // and one for classes that only get loaded |
|
74 | - $this->CoffeeShop->addCoffeeMaker( |
|
75 | - new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
76 | - CoffeeMaker::BREW_LOAD_ONLY |
|
77 | - ); |
|
78 | - } |
|
50 | + /** |
|
51 | + * configure coffee makers which control the different kinds of brews |
|
52 | + * ( shared services, new factory objects, etc ) |
|
53 | + * |
|
54 | + * @throws InvalidEntityException |
|
55 | + */ |
|
56 | + public function setupCoffeeMakers() |
|
57 | + { |
|
58 | + // create a dependency injector class for resolving class constructor arguments |
|
59 | + $DependencyInjector = new DependencyInjector( |
|
60 | + $this->CoffeeShop, |
|
61 | + new \EEH_Array() |
|
62 | + ); |
|
63 | + // and some coffeemakers, one for creating new instances |
|
64 | + $this->CoffeeShop->addCoffeeMaker( |
|
65 | + new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
66 | + CoffeeMaker::BREW_NEW |
|
67 | + ); |
|
68 | + // one for shared services |
|
69 | + $this->CoffeeShop->addCoffeeMaker( |
|
70 | + new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
71 | + CoffeeMaker::BREW_SHARED |
|
72 | + ); |
|
73 | + // and one for classes that only get loaded |
|
74 | + $this->CoffeeShop->addCoffeeMaker( |
|
75 | + new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
76 | + CoffeeMaker::BREW_LOAD_ONLY |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * Recipes define how to load legacy classes |
|
83 | - * |
|
84 | - * @throws InvalidIdentifierException |
|
85 | - */ |
|
86 | - public function addRecipes() |
|
87 | - { |
|
88 | - // add default recipe, which should handle loading for most PSR-4 compatible classes |
|
89 | - // as long as they are not type hinting for interfaces |
|
90 | - $this->CoffeeShop->addRecipe( |
|
91 | - new Recipe( |
|
92 | - Recipe::DEFAULT_ID |
|
93 | - ) |
|
94 | - ); |
|
95 | - // PSR-4 compatible class with aliases |
|
96 | - $this->CoffeeShop->addRecipe( |
|
97 | - new Recipe( |
|
98 | - 'CommandHandlerManager', |
|
99 | - 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
100 | - array( |
|
101 | - 'CommandHandlerManagerInterface', |
|
102 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
103 | - ), |
|
104 | - array(), |
|
105 | - CoffeeMaker::BREW_SHARED |
|
106 | - ) |
|
107 | - ); |
|
108 | - // PSR-4 compatible class with aliases, which dependency on CommandHandlerManager |
|
109 | - $this->CoffeeShop->addRecipe( |
|
110 | - new Recipe( |
|
111 | - 'CommandBus', |
|
112 | - 'EventEspresso\core\services\commands\CommandBus', |
|
113 | - array( |
|
114 | - 'CommandBusInterface', |
|
115 | - 'EventEspresso\core\services\commands\CommandBusInterface', |
|
116 | - ), |
|
117 | - array(), |
|
118 | - CoffeeMaker::BREW_SHARED |
|
119 | - ) |
|
120 | - ); |
|
121 | - // LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath |
|
122 | - // add a wildcard recipe for loading legacy core interfaces |
|
123 | - $this->CoffeeShop->addRecipe( |
|
124 | - new Recipe( |
|
125 | - 'EEI_*', |
|
126 | - '', |
|
127 | - array(), |
|
128 | - array(), |
|
129 | - CoffeeMaker::BREW_LOAD_ONLY, |
|
130 | - array( |
|
131 | - EE_INTERFACES . '*.php', |
|
132 | - EE_INTERFACES . '*.interfaces.php', |
|
133 | - ) |
|
134 | - ) |
|
135 | - ); |
|
136 | - // add a wildcard recipe for loading models |
|
137 | - $this->CoffeeShop->addRecipe( |
|
138 | - new Recipe( |
|
139 | - 'EEM_*', |
|
140 | - '', |
|
141 | - array(), |
|
142 | - array(), |
|
143 | - CoffeeMaker::BREW_SHARED, |
|
144 | - EE_MODELS . '*.model.php' |
|
145 | - ) |
|
146 | - ); |
|
147 | - // add a wildcard recipe for loading core classes |
|
148 | - $this->CoffeeShop->addRecipe( |
|
149 | - new Recipe( |
|
150 | - 'EE_*', |
|
151 | - '', |
|
152 | - array(), |
|
153 | - array(), |
|
154 | - CoffeeMaker::BREW_SHARED, |
|
155 | - array( |
|
156 | - EE_CORE . '*.core.php', |
|
157 | - EE_ADMIN . '*.core.php', |
|
158 | - EE_CPTS . '*.core.php', |
|
159 | - EE_CORE . 'data_migration_scripts/*.core.php', |
|
160 | - ) |
|
161 | - ) |
|
162 | - ); |
|
163 | - // load admin page parent class |
|
164 | - $this->CoffeeShop->addRecipe( |
|
165 | - new Recipe( |
|
166 | - 'EE_Admin_Page*', |
|
167 | - '', |
|
168 | - array(), |
|
169 | - array(), |
|
170 | - CoffeeMaker::BREW_LOAD_ONLY, |
|
171 | - array(EE_ADMIN . '*.core.php') |
|
172 | - ) |
|
173 | - ); |
|
174 | - // add a wildcard recipe for loading core classes |
|
175 | - // $this->CoffeeShop->addRecipe( |
|
176 | - // new Recipe( |
|
177 | - // '*_Admin_Page', |
|
178 | - // '', |
|
179 | - // array(), |
|
180 | - // array(), |
|
181 | - // CoffeeMaker::BREW_SHARED, |
|
182 | - // array( |
|
183 | - // EE_ADMIN_PAGES . 'transactions/*.core.php', |
|
184 | - // ) |
|
185 | - // ) |
|
186 | - // ); |
|
187 | - } |
|
81 | + /** |
|
82 | + * Recipes define how to load legacy classes |
|
83 | + * |
|
84 | + * @throws InvalidIdentifierException |
|
85 | + */ |
|
86 | + public function addRecipes() |
|
87 | + { |
|
88 | + // add default recipe, which should handle loading for most PSR-4 compatible classes |
|
89 | + // as long as they are not type hinting for interfaces |
|
90 | + $this->CoffeeShop->addRecipe( |
|
91 | + new Recipe( |
|
92 | + Recipe::DEFAULT_ID |
|
93 | + ) |
|
94 | + ); |
|
95 | + // PSR-4 compatible class with aliases |
|
96 | + $this->CoffeeShop->addRecipe( |
|
97 | + new Recipe( |
|
98 | + 'CommandHandlerManager', |
|
99 | + 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
100 | + array( |
|
101 | + 'CommandHandlerManagerInterface', |
|
102 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
103 | + ), |
|
104 | + array(), |
|
105 | + CoffeeMaker::BREW_SHARED |
|
106 | + ) |
|
107 | + ); |
|
108 | + // PSR-4 compatible class with aliases, which dependency on CommandHandlerManager |
|
109 | + $this->CoffeeShop->addRecipe( |
|
110 | + new Recipe( |
|
111 | + 'CommandBus', |
|
112 | + 'EventEspresso\core\services\commands\CommandBus', |
|
113 | + array( |
|
114 | + 'CommandBusInterface', |
|
115 | + 'EventEspresso\core\services\commands\CommandBusInterface', |
|
116 | + ), |
|
117 | + array(), |
|
118 | + CoffeeMaker::BREW_SHARED |
|
119 | + ) |
|
120 | + ); |
|
121 | + // LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath |
|
122 | + // add a wildcard recipe for loading legacy core interfaces |
|
123 | + $this->CoffeeShop->addRecipe( |
|
124 | + new Recipe( |
|
125 | + 'EEI_*', |
|
126 | + '', |
|
127 | + array(), |
|
128 | + array(), |
|
129 | + CoffeeMaker::BREW_LOAD_ONLY, |
|
130 | + array( |
|
131 | + EE_INTERFACES . '*.php', |
|
132 | + EE_INTERFACES . '*.interfaces.php', |
|
133 | + ) |
|
134 | + ) |
|
135 | + ); |
|
136 | + // add a wildcard recipe for loading models |
|
137 | + $this->CoffeeShop->addRecipe( |
|
138 | + new Recipe( |
|
139 | + 'EEM_*', |
|
140 | + '', |
|
141 | + array(), |
|
142 | + array(), |
|
143 | + CoffeeMaker::BREW_SHARED, |
|
144 | + EE_MODELS . '*.model.php' |
|
145 | + ) |
|
146 | + ); |
|
147 | + // add a wildcard recipe for loading core classes |
|
148 | + $this->CoffeeShop->addRecipe( |
|
149 | + new Recipe( |
|
150 | + 'EE_*', |
|
151 | + '', |
|
152 | + array(), |
|
153 | + array(), |
|
154 | + CoffeeMaker::BREW_SHARED, |
|
155 | + array( |
|
156 | + EE_CORE . '*.core.php', |
|
157 | + EE_ADMIN . '*.core.php', |
|
158 | + EE_CPTS . '*.core.php', |
|
159 | + EE_CORE . 'data_migration_scripts/*.core.php', |
|
160 | + ) |
|
161 | + ) |
|
162 | + ); |
|
163 | + // load admin page parent class |
|
164 | + $this->CoffeeShop->addRecipe( |
|
165 | + new Recipe( |
|
166 | + 'EE_Admin_Page*', |
|
167 | + '', |
|
168 | + array(), |
|
169 | + array(), |
|
170 | + CoffeeMaker::BREW_LOAD_ONLY, |
|
171 | + array(EE_ADMIN . '*.core.php') |
|
172 | + ) |
|
173 | + ); |
|
174 | + // add a wildcard recipe for loading core classes |
|
175 | + // $this->CoffeeShop->addRecipe( |
|
176 | + // new Recipe( |
|
177 | + // '*_Admin_Page', |
|
178 | + // '', |
|
179 | + // array(), |
|
180 | + // array(), |
|
181 | + // CoffeeMaker::BREW_SHARED, |
|
182 | + // array( |
|
183 | + // EE_ADMIN_PAGES . 'transactions/*.core.php', |
|
184 | + // ) |
|
185 | + // ) |
|
186 | + // ); |
|
187 | + } |
|
188 | 188 | |
189 | 189 | |
190 | - /** |
|
191 | - * bootstrap EE and the request stack |
|
192 | - * |
|
193 | - * @throws ServiceNotFoundException |
|
194 | - * @throws InvalidClassException |
|
195 | - * @throws InvalidDataTypeException |
|
196 | - * @throws InvalidIdentifierException |
|
197 | - * @throws exceptions\ServiceExistsException |
|
198 | - * @throws OutOfBoundsException |
|
199 | - * @throws exceptions\InstantiationException |
|
200 | - */ |
|
201 | - public function firstBrew() |
|
202 | - { |
|
203 | - $this->CoffeeShop->brew( |
|
204 | - 'EventEspresso\core\services\request\Request', |
|
205 | - array($_GET, $_POST, $_COOKIE, $_SERVER) |
|
206 | - ); |
|
207 | - $this->CoffeeShop->brew('EventEspresso\core\services\request\Response'); |
|
208 | - $this->CoffeeShop->brew('EE_Bootstrap'); |
|
209 | - } |
|
190 | + /** |
|
191 | + * bootstrap EE and the request stack |
|
192 | + * |
|
193 | + * @throws ServiceNotFoundException |
|
194 | + * @throws InvalidClassException |
|
195 | + * @throws InvalidDataTypeException |
|
196 | + * @throws InvalidIdentifierException |
|
197 | + * @throws exceptions\ServiceExistsException |
|
198 | + * @throws OutOfBoundsException |
|
199 | + * @throws exceptions\InstantiationException |
|
200 | + */ |
|
201 | + public function firstBrew() |
|
202 | + { |
|
203 | + $this->CoffeeShop->brew( |
|
204 | + 'EventEspresso\core\services\request\Request', |
|
205 | + array($_GET, $_POST, $_COOKIE, $_SERVER) |
|
206 | + ); |
|
207 | + $this->CoffeeShop->brew('EventEspresso\core\services\request\Response'); |
|
208 | + $this->CoffeeShop->brew('EE_Bootstrap'); |
|
209 | + } |
|
210 | 210 | } |
@@ -15,94 +15,94 @@ |
||
15 | 15 | */ |
16 | 16 | class LicenseService |
17 | 17 | { |
18 | - /** |
|
19 | - * @var Config |
|
20 | - */ |
|
21 | - private $config; |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * @var Stats |
|
26 | - */ |
|
27 | - private $stats_collection; |
|
28 | - |
|
29 | - public function __construct(Stats $stats_collection, Config $config) |
|
30 | - { |
|
31 | - $this->config = $config; |
|
32 | - $this->stats_collection = $stats_collection; |
|
33 | - $this->loadPueClient(); |
|
34 | - } |
|
35 | - |
|
36 | - private function loadPueClient() |
|
37 | - { |
|
38 | - // PUE Auto Upgrades stuff |
|
39 | - if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file |
|
40 | - require_once(EE_THIRD_PARTY . 'pue/pue-client.php'); |
|
41 | - |
|
42 | - // $options needs to be an array with the included keys as listed. |
|
43 | - $options = array( |
|
44 | - // 'optionName' => '', //(optional) - used as the reference for saving update information in the |
|
45 | - // clients options table. Will be automatically set if left blank. |
|
46 | - 'apikey' => $this->config->siteLicenseKey(), |
|
47 | - // (required), you will need to obtain the apikey that the client gets from your site and |
|
48 | - // then saves in their sites options table (see 'getting an api-key' below) |
|
49 | - 'lang_domain' => $this->config->i18nDomain(), |
|
50 | - // (optional) - put here whatever reference you are using for the localization of your plugin (if it's |
|
51 | - // localized). That way strings in this file will be included in the translation for your plugin. |
|
52 | - 'checkPeriod' => $this->config->checkPeriod(), |
|
53 | - // (optional) - use this parameter to indicate how often you want the client's install to ping your |
|
54 | - // server for update checks. The integer indicates hours. If you don't include this parameter it will |
|
55 | - // default to 12 hours. |
|
56 | - 'option_key' => $this->config->optionKey(), |
|
57 | - // this is what is used to reference the api_key in your plugin options. PUE uses this to trigger |
|
58 | - // updating your information message whenever this option_key is modified. |
|
59 | - 'options_page_slug' => $this->config->optionsPageSlug(), |
|
60 | - 'plugin_basename' => EE_PLUGIN_BASENAME, |
|
61 | - 'use_wp_update' => true, |
|
62 | - // if TRUE then you want FREE versions of the plugin to be updated from WP |
|
63 | - 'extra_stats' => $this->stats_collection->statsCallback(), |
|
64 | - 'turn_on_notices_saved' => true, |
|
65 | - ); |
|
66 | - // initiate the class and start the plugin update engine! |
|
67 | - new PluginUpdateEngineChecker( |
|
68 | - $this->config->hostServerUrl(), |
|
69 | - $this->config->pluginSlug(), |
|
70 | - $options |
|
71 | - ); |
|
72 | - } |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * This is a handy helper method for retrieving whether there is an update available for the given plugin. |
|
78 | - * |
|
79 | - * @param string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to |
|
80 | - * identify plugins. Defaults to core update |
|
81 | - * @return boolean True if update available, false if not. |
|
82 | - */ |
|
83 | - public static function isUpdateAvailable($basename = '') |
|
84 | - { |
|
85 | - $basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME; |
|
86 | - |
|
87 | - $update = false; |
|
88 | - |
|
89 | - // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core" |
|
90 | - $folder = '/' . dirname($basename); |
|
91 | - |
|
92 | - $plugins = get_plugins($folder); |
|
93 | - $current = get_site_transient('update_plugins'); |
|
94 | - |
|
95 | - foreach ((array) $plugins as $plugin_file => $plugin_data) { |
|
96 | - if (isset($current->response['plugin_file'])) { |
|
97 | - $update = true; |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - // it's possible that there is an update but an invalid site-license-key is in use |
|
102 | - if (get_site_option('pue_json_error_' . $basename)) { |
|
103 | - $update = true; |
|
104 | - } |
|
105 | - |
|
106 | - return $update; |
|
107 | - } |
|
18 | + /** |
|
19 | + * @var Config |
|
20 | + */ |
|
21 | + private $config; |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * @var Stats |
|
26 | + */ |
|
27 | + private $stats_collection; |
|
28 | + |
|
29 | + public function __construct(Stats $stats_collection, Config $config) |
|
30 | + { |
|
31 | + $this->config = $config; |
|
32 | + $this->stats_collection = $stats_collection; |
|
33 | + $this->loadPueClient(); |
|
34 | + } |
|
35 | + |
|
36 | + private function loadPueClient() |
|
37 | + { |
|
38 | + // PUE Auto Upgrades stuff |
|
39 | + if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file |
|
40 | + require_once(EE_THIRD_PARTY . 'pue/pue-client.php'); |
|
41 | + |
|
42 | + // $options needs to be an array with the included keys as listed. |
|
43 | + $options = array( |
|
44 | + // 'optionName' => '', //(optional) - used as the reference for saving update information in the |
|
45 | + // clients options table. Will be automatically set if left blank. |
|
46 | + 'apikey' => $this->config->siteLicenseKey(), |
|
47 | + // (required), you will need to obtain the apikey that the client gets from your site and |
|
48 | + // then saves in their sites options table (see 'getting an api-key' below) |
|
49 | + 'lang_domain' => $this->config->i18nDomain(), |
|
50 | + // (optional) - put here whatever reference you are using for the localization of your plugin (if it's |
|
51 | + // localized). That way strings in this file will be included in the translation for your plugin. |
|
52 | + 'checkPeriod' => $this->config->checkPeriod(), |
|
53 | + // (optional) - use this parameter to indicate how often you want the client's install to ping your |
|
54 | + // server for update checks. The integer indicates hours. If you don't include this parameter it will |
|
55 | + // default to 12 hours. |
|
56 | + 'option_key' => $this->config->optionKey(), |
|
57 | + // this is what is used to reference the api_key in your plugin options. PUE uses this to trigger |
|
58 | + // updating your information message whenever this option_key is modified. |
|
59 | + 'options_page_slug' => $this->config->optionsPageSlug(), |
|
60 | + 'plugin_basename' => EE_PLUGIN_BASENAME, |
|
61 | + 'use_wp_update' => true, |
|
62 | + // if TRUE then you want FREE versions of the plugin to be updated from WP |
|
63 | + 'extra_stats' => $this->stats_collection->statsCallback(), |
|
64 | + 'turn_on_notices_saved' => true, |
|
65 | + ); |
|
66 | + // initiate the class and start the plugin update engine! |
|
67 | + new PluginUpdateEngineChecker( |
|
68 | + $this->config->hostServerUrl(), |
|
69 | + $this->config->pluginSlug(), |
|
70 | + $options |
|
71 | + ); |
|
72 | + } |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * This is a handy helper method for retrieving whether there is an update available for the given plugin. |
|
78 | + * |
|
79 | + * @param string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to |
|
80 | + * identify plugins. Defaults to core update |
|
81 | + * @return boolean True if update available, false if not. |
|
82 | + */ |
|
83 | + public static function isUpdateAvailable($basename = '') |
|
84 | + { |
|
85 | + $basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME; |
|
86 | + |
|
87 | + $update = false; |
|
88 | + |
|
89 | + // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core" |
|
90 | + $folder = '/' . dirname($basename); |
|
91 | + |
|
92 | + $plugins = get_plugins($folder); |
|
93 | + $current = get_site_transient('update_plugins'); |
|
94 | + |
|
95 | + foreach ((array) $plugins as $plugin_file => $plugin_data) { |
|
96 | + if (isset($current->response['plugin_file'])) { |
|
97 | + $update = true; |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + // it's possible that there is an update but an invalid site-license-key is in use |
|
102 | + if (get_site_option('pue_json_error_' . $basename)) { |
|
103 | + $update = true; |
|
104 | + } |
|
105 | + |
|
106 | + return $update; |
|
107 | + } |
|
108 | 108 | } |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | private function loadPueClient() |
37 | 37 | { |
38 | 38 | // PUE Auto Upgrades stuff |
39 | - if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file |
|
40 | - require_once(EE_THIRD_PARTY . 'pue/pue-client.php'); |
|
39 | + if (is_readable(EE_THIRD_PARTY.'pue/pue-client.php')) { // include the file |
|
40 | + require_once(EE_THIRD_PARTY.'pue/pue-client.php'); |
|
41 | 41 | |
42 | 42 | // $options needs to be an array with the included keys as listed. |
43 | 43 | $options = array( |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $update = false; |
88 | 88 | |
89 | 89 | // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core" |
90 | - $folder = '/' . dirname($basename); |
|
90 | + $folder = '/'.dirname($basename); |
|
91 | 91 | |
92 | 92 | $plugins = get_plugins($folder); |
93 | 93 | $current = get_site_transient('update_plugins'); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | // it's possible that there is an update but an invalid site-license-key is in use |
102 | - if (get_site_option('pue_json_error_' . $basename)) { |
|
102 | + if (get_site_option('pue_json_error_'.$basename)) { |
|
103 | 103 | $update = true; |
104 | 104 | } |
105 | 105 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | // core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css |
27 | 27 | wp_enqueue_style( |
28 | 28 | 'ee_progress_steps_display_number_bubbles', |
29 | - plugin_dir_url(__FILE__) . 'number_bubbles.css' |
|
29 | + plugin_dir_url(__FILE__).'number_bubbles.css' |
|
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
@@ -39,6 +39,6 @@ discard block |
||
39 | 39 | public function getTemplate() |
40 | 40 | { |
41 | 41 | // return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php'; |
42 | - return __DIR__ . '/number_bubbles.template.php'; |
|
42 | + return __DIR__.'/number_bubbles.template.php'; |
|
43 | 43 | } |
44 | 44 | } |
@@ -14,29 +14,29 @@ |
||
14 | 14 | */ |
15 | 15 | class NumberBubblesProgressStepsDisplay implements ProgressStepsDisplayInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * used for setting up css and js required for the display strategy |
|
19 | - * |
|
20 | - * @return void |
|
21 | - */ |
|
22 | - public function enqueueStylesAndScripts() |
|
23 | - { |
|
24 | - // core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css |
|
25 | - wp_enqueue_style( |
|
26 | - 'ee_progress_steps_display_number_bubbles', |
|
27 | - plugin_dir_url(__FILE__) . 'number_bubbles.css' |
|
28 | - ); |
|
29 | - } |
|
17 | + /** |
|
18 | + * used for setting up css and js required for the display strategy |
|
19 | + * |
|
20 | + * @return void |
|
21 | + */ |
|
22 | + public function enqueueStylesAndScripts() |
|
23 | + { |
|
24 | + // core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css |
|
25 | + wp_enqueue_style( |
|
26 | + 'ee_progress_steps_display_number_bubbles', |
|
27 | + plugin_dir_url(__FILE__) . 'number_bubbles.css' |
|
28 | + ); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * loads and returns a full server path to the template used for the display strategy |
|
34 | - * |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function getTemplate() |
|
38 | - { |
|
39 | - // return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php'; |
|
40 | - return __DIR__ . '/number_bubbles.template.php'; |
|
41 | - } |
|
32 | + /** |
|
33 | + * loads and returns a full server path to the template used for the display strategy |
|
34 | + * |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function getTemplate() |
|
38 | + { |
|
39 | + // return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php'; |
|
40 | + return __DIR__ . '/number_bubbles.template.php'; |
|
41 | + } |
|
42 | 42 | } |