@@ -14,99 +14,99 @@ |
||
14 | 14 | |
15 | 15 | |
16 | 16 | |
17 | - /** |
|
18 | - * |
|
19 | - * @param EE_Payment_Method $pm_instance |
|
20 | - * @return EE_PMT_Bank |
|
21 | - */ |
|
22 | - public function __construct($pm_instance = null) |
|
23 | - { |
|
24 | - $this->_pretty_name = __("Bank", 'event_espresso'); |
|
25 | - parent::__construct($pm_instance); |
|
26 | - $this->_default_button_url = $this->file_url().'lib/bank-logo.png'; |
|
27 | - $this->_default_description = __('Make payment using an electronic funds transfer from your bank.', 'event_espresso'); |
|
28 | - } |
|
29 | - |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * Creates the billing form for this payment method type |
|
34 | - * @param \EE_Transaction $transaction |
|
35 | - * @return NULL |
|
36 | - */ |
|
37 | - public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
38 | - { |
|
39 | - return null; |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * Gets the form for all the settings related to this payment method type |
|
46 | - * @return EE_Payment_Method_Form |
|
47 | - */ |
|
48 | - public function generate_new_settings_form() |
|
49 | - { |
|
50 | - return new EE_Payment_Method_Form(array( |
|
51 | - 'extra_meta_inputs'=>array( |
|
52 | - 'page_title'=>new EE_Text_Input(array( |
|
53 | - 'html_label_text'=> sprintf(__("Title %s", "event_espresso"), $this->get_help_tab_link()), |
|
54 | - 'default'=> __("Electronic Funds Transfers", 'event_espresso') |
|
55 | - )), |
|
56 | - 'payment_instructions'=>new EE_Text_Area_Input(array( |
|
57 | - 'html_label_text'=> sprintf(__("Payment Instructions %s", "event_espresso"), $this->get_help_tab_link()), |
|
58 | - 'html_help_text' => __('Provide instructions on how registrants can send the bank draft payment. Eg, mention your account name, bank account number, bank name, bank routing code, and bank address, etc.', 'event_espresso'), |
|
59 | - 'default'=> sprintf( |
|
60 | - __('Please initiate an electronic payment using the following bank information: %1$sAccount Owner: Luke Skywalker%1$sBank Account # 1234567890%1$sBank Name: Rebellion Bank%1$sRouting Number: 12345%1$sBank Address: 12345 Wookie Rd., Planet Corellian.%1$sPayment must be received within 48 hours of event date.', 'event_espresso'), |
|
61 | - "\n" |
|
62 | - ), |
|
63 | - 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
64 | - )), |
|
65 | - ), |
|
66 | - 'exclude'=>array('PMD_debug_mode') |
|
67 | - )); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * Adds the help tab |
|
74 | - * @see EE_PMT_Base::help_tabs_config() |
|
75 | - * @return array |
|
76 | - */ |
|
77 | - public function help_tabs_config() |
|
78 | - { |
|
79 | - return array( |
|
80 | - $this->get_help_tab_name() => array( |
|
81 | - 'title' => __('Bank Draft Settings', 'event_espresso'), |
|
82 | - 'filename' => 'payment_methods_overview_bank_draft' |
|
83 | - ), |
|
84 | - ); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * For adding any html output ab ove the payment overview. |
|
91 | - * Many gateways won't want ot display anything, so this function just returns an empty string. |
|
92 | - * Other gateways may want to override this, such as offline gateways. |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function payment_overview_content(EE_Payment $payment) |
|
96 | - { |
|
97 | - $extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array(); |
|
98 | - $template_vars = array_merge( |
|
99 | - array( |
|
100 | - 'payment_method'=>$this->_pm_instance, |
|
101 | - 'payment'=>$payment, |
|
102 | - 'page_title'=>'', |
|
103 | - 'payment_instructions'=>'', |
|
104 | - ), |
|
105 | - $extra_meta_for_payment_method |
|
106 | - ); |
|
107 | - return EEH_Template::locate_template( |
|
108 | - 'payment_methods/Bank/templates/bank_payment_details_content.template.php', |
|
109 | - $template_vars |
|
110 | - ); |
|
111 | - } |
|
17 | + /** |
|
18 | + * |
|
19 | + * @param EE_Payment_Method $pm_instance |
|
20 | + * @return EE_PMT_Bank |
|
21 | + */ |
|
22 | + public function __construct($pm_instance = null) |
|
23 | + { |
|
24 | + $this->_pretty_name = __("Bank", 'event_espresso'); |
|
25 | + parent::__construct($pm_instance); |
|
26 | + $this->_default_button_url = $this->file_url().'lib/bank-logo.png'; |
|
27 | + $this->_default_description = __('Make payment using an electronic funds transfer from your bank.', 'event_espresso'); |
|
28 | + } |
|
29 | + |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * Creates the billing form for this payment method type |
|
34 | + * @param \EE_Transaction $transaction |
|
35 | + * @return NULL |
|
36 | + */ |
|
37 | + public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
38 | + { |
|
39 | + return null; |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * Gets the form for all the settings related to this payment method type |
|
46 | + * @return EE_Payment_Method_Form |
|
47 | + */ |
|
48 | + public function generate_new_settings_form() |
|
49 | + { |
|
50 | + return new EE_Payment_Method_Form(array( |
|
51 | + 'extra_meta_inputs'=>array( |
|
52 | + 'page_title'=>new EE_Text_Input(array( |
|
53 | + 'html_label_text'=> sprintf(__("Title %s", "event_espresso"), $this->get_help_tab_link()), |
|
54 | + 'default'=> __("Electronic Funds Transfers", 'event_espresso') |
|
55 | + )), |
|
56 | + 'payment_instructions'=>new EE_Text_Area_Input(array( |
|
57 | + 'html_label_text'=> sprintf(__("Payment Instructions %s", "event_espresso"), $this->get_help_tab_link()), |
|
58 | + 'html_help_text' => __('Provide instructions on how registrants can send the bank draft payment. Eg, mention your account name, bank account number, bank name, bank routing code, and bank address, etc.', 'event_espresso'), |
|
59 | + 'default'=> sprintf( |
|
60 | + __('Please initiate an electronic payment using the following bank information: %1$sAccount Owner: Luke Skywalker%1$sBank Account # 1234567890%1$sBank Name: Rebellion Bank%1$sRouting Number: 12345%1$sBank Address: 12345 Wookie Rd., Planet Corellian.%1$sPayment must be received within 48 hours of event date.', 'event_espresso'), |
|
61 | + "\n" |
|
62 | + ), |
|
63 | + 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
64 | + )), |
|
65 | + ), |
|
66 | + 'exclude'=>array('PMD_debug_mode') |
|
67 | + )); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * Adds the help tab |
|
74 | + * @see EE_PMT_Base::help_tabs_config() |
|
75 | + * @return array |
|
76 | + */ |
|
77 | + public function help_tabs_config() |
|
78 | + { |
|
79 | + return array( |
|
80 | + $this->get_help_tab_name() => array( |
|
81 | + 'title' => __('Bank Draft Settings', 'event_espresso'), |
|
82 | + 'filename' => 'payment_methods_overview_bank_draft' |
|
83 | + ), |
|
84 | + ); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * For adding any html output ab ove the payment overview. |
|
91 | + * Many gateways won't want ot display anything, so this function just returns an empty string. |
|
92 | + * Other gateways may want to override this, such as offline gateways. |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function payment_overview_content(EE_Payment $payment) |
|
96 | + { |
|
97 | + $extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array(); |
|
98 | + $template_vars = array_merge( |
|
99 | + array( |
|
100 | + 'payment_method'=>$this->_pm_instance, |
|
101 | + 'payment'=>$payment, |
|
102 | + 'page_title'=>'', |
|
103 | + 'payment_instructions'=>'', |
|
104 | + ), |
|
105 | + $extra_meta_for_payment_method |
|
106 | + ); |
|
107 | + return EEH_Template::locate_template( |
|
108 | + 'payment_methods/Bank/templates/bank_payment_details_content.template.php', |
|
109 | + $template_vars |
|
110 | + ); |
|
111 | + } |
|
112 | 112 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | __('Please initiate an electronic payment using the following bank information: %1$sAccount Owner: Luke Skywalker%1$sBank Account # 1234567890%1$sBank Name: Rebellion Bank%1$sRouting Number: 12345%1$sBank Address: 12345 Wookie Rd., Planet Corellian.%1$sPayment must be received within 48 hours of event date.', 'event_espresso'), |
61 | 61 | "\n" |
62 | 62 | ), |
63 | - 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
63 | + 'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()), |
|
64 | 64 | )), |
65 | 65 | ), |
66 | 66 | 'exclude'=>array('PMD_debug_mode') |
@@ -13,121 +13,121 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * @param null $pm_instance |
|
18 | - * @return EE_PMT_Check |
|
19 | - */ |
|
20 | - public function __construct($pm_instance = null) |
|
21 | - { |
|
22 | - $this->_pretty_name = __("Check", 'event_espresso'); |
|
23 | - $this->_default_description = __('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso'); |
|
24 | - parent::__construct($pm_instance); |
|
25 | - $this->_default_button_url = $this->file_url().'lib/check-logo.png'; |
|
26 | - } |
|
16 | + /** |
|
17 | + * @param null $pm_instance |
|
18 | + * @return EE_PMT_Check |
|
19 | + */ |
|
20 | + public function __construct($pm_instance = null) |
|
21 | + { |
|
22 | + $this->_pretty_name = __("Check", 'event_espresso'); |
|
23 | + $this->_default_description = __('After clicking "Finalize Registration", you will be given instructions on how to complete your payment.', 'event_espresso'); |
|
24 | + parent::__construct($pm_instance); |
|
25 | + $this->_default_button_url = $this->file_url().'lib/check-logo.png'; |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * Creates the billing form for this payment method type |
|
32 | - * @param \EE_Transaction $transaction |
|
33 | - * @return NULL |
|
34 | - */ |
|
35 | - public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
36 | - { |
|
37 | - return null; |
|
38 | - } |
|
30 | + /** |
|
31 | + * Creates the billing form for this payment method type |
|
32 | + * @param \EE_Transaction $transaction |
|
33 | + * @return NULL |
|
34 | + */ |
|
35 | + public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
36 | + { |
|
37 | + return null; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * Overrides parent to dynamically set some defaults, but only when the form is requested |
|
44 | - * @return EE_Form_Section_Proper |
|
45 | - */ |
|
46 | - public function generate_new_settings_form() |
|
47 | - { |
|
48 | - if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
49 | - $organization = EE_Registry::instance()->CFG->organization; |
|
50 | - $organization_name = $organization->get_pretty('name'); |
|
51 | - $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : ''; |
|
52 | - $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : ''; |
|
53 | - $default_address .= $organization->city != '' ? $organization->get_pretty('city') : ''; |
|
54 | - $default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />'; |
|
55 | - $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
56 | - $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ; |
|
57 | - $default_address .= $state ? $state->name() . '<br />' : ''; |
|
58 | - $default_address .= $country ? $country->name(). '<br />' : ''; |
|
59 | - $default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : ''; |
|
60 | - } else { |
|
61 | - $default_address = 'unknown'; |
|
62 | - $organization_name = 'unknown'; |
|
63 | - } |
|
64 | - return new EE_Payment_Method_Form(array( |
|
65 | - 'extra_meta_inputs'=>array( |
|
66 | - 'check_title'=> new EE_Text_Input(array( |
|
67 | - 'html_label_text'=> sprintf(__("Title %s", "event_espresso"), $this->get_help_tab_link()), |
|
68 | - 'default'=> __("Check/Money Order Payments", 'event_espresso'), |
|
69 | - )), |
|
70 | - 'payment_instructions'=>new EE_Text_Area_Input(array( |
|
71 | - 'html_label_text'=> sprintf(__("Instructions %s", "event_espresso"), $this->get_help_tab_link()), |
|
72 | - 'default'=> __("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'), |
|
73 | - 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
74 | - )), |
|
75 | - 'payable_to'=>new EE_Text_Input(array( |
|
76 | - 'html_label_text'=> sprintf(__("Payable To %s", "event_espresso"), $this->get_help_tab_link()), |
|
77 | - 'default'=>$organization_name |
|
78 | - )), |
|
79 | - 'address_to_send_payment'=>new EE_Text_Area_Input(array( |
|
80 | - 'html_label_text'=> sprintf(__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()), |
|
81 | - 'default'=>$default_address, |
|
82 | - 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
83 | - )), |
|
84 | - ), |
|
85 | - 'exclude'=>array('PMD_debug_mode') |
|
86 | - )); |
|
87 | - } |
|
42 | + /** |
|
43 | + * Overrides parent to dynamically set some defaults, but only when the form is requested |
|
44 | + * @return EE_Form_Section_Proper |
|
45 | + */ |
|
46 | + public function generate_new_settings_form() |
|
47 | + { |
|
48 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
49 | + $organization = EE_Registry::instance()->CFG->organization; |
|
50 | + $organization_name = $organization->get_pretty('name'); |
|
51 | + $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : ''; |
|
52 | + $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : ''; |
|
53 | + $default_address .= $organization->city != '' ? $organization->get_pretty('city') : ''; |
|
54 | + $default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />'; |
|
55 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
56 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ; |
|
57 | + $default_address .= $state ? $state->name() . '<br />' : ''; |
|
58 | + $default_address .= $country ? $country->name(). '<br />' : ''; |
|
59 | + $default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : ''; |
|
60 | + } else { |
|
61 | + $default_address = 'unknown'; |
|
62 | + $organization_name = 'unknown'; |
|
63 | + } |
|
64 | + return new EE_Payment_Method_Form(array( |
|
65 | + 'extra_meta_inputs'=>array( |
|
66 | + 'check_title'=> new EE_Text_Input(array( |
|
67 | + 'html_label_text'=> sprintf(__("Title %s", "event_espresso"), $this->get_help_tab_link()), |
|
68 | + 'default'=> __("Check/Money Order Payments", 'event_espresso'), |
|
69 | + )), |
|
70 | + 'payment_instructions'=>new EE_Text_Area_Input(array( |
|
71 | + 'html_label_text'=> sprintf(__("Instructions %s", "event_espresso"), $this->get_help_tab_link()), |
|
72 | + 'default'=> __("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'), |
|
73 | + 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
74 | + )), |
|
75 | + 'payable_to'=>new EE_Text_Input(array( |
|
76 | + 'html_label_text'=> sprintf(__("Payable To %s", "event_espresso"), $this->get_help_tab_link()), |
|
77 | + 'default'=>$organization_name |
|
78 | + )), |
|
79 | + 'address_to_send_payment'=>new EE_Text_Area_Input(array( |
|
80 | + 'html_label_text'=> sprintf(__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()), |
|
81 | + 'default'=>$default_address, |
|
82 | + 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
83 | + )), |
|
84 | + ), |
|
85 | + 'exclude'=>array('PMD_debug_mode') |
|
86 | + )); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * Adds the help tab |
|
93 | - * @see EE_PMT_Base::help_tabs_config() |
|
94 | - * @return array |
|
95 | - */ |
|
96 | - public function help_tabs_config() |
|
97 | - { |
|
98 | - return array( |
|
99 | - $this->get_help_tab_name() => array( |
|
100 | - 'title' => __('Check Settings', 'event_espresso'), |
|
101 | - 'filename' => 'payment_methods_overview_check' |
|
102 | - ), |
|
103 | - ); |
|
104 | - } |
|
91 | + /** |
|
92 | + * Adds the help tab |
|
93 | + * @see EE_PMT_Base::help_tabs_config() |
|
94 | + * @return array |
|
95 | + */ |
|
96 | + public function help_tabs_config() |
|
97 | + { |
|
98 | + return array( |
|
99 | + $this->get_help_tab_name() => array( |
|
100 | + 'title' => __('Check Settings', 'event_espresso'), |
|
101 | + 'filename' => 'payment_methods_overview_check' |
|
102 | + ), |
|
103 | + ); |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | 107 | |
108 | - /** |
|
109 | - * For adding any html output ab ove the payment overview. |
|
110 | - * Many gateways won't want ot display anything, so this function just returns an empty string. |
|
111 | - * Other gateways may want to override this, such as offline gateways. |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function payment_overview_content(EE_Payment $payment) |
|
115 | - { |
|
116 | - $extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array(); |
|
117 | - $template_vars = array_merge( |
|
118 | - array( |
|
119 | - 'payment_method'=>$this->_pm_instance, |
|
120 | - 'payment'=>$payment, |
|
121 | - 'check_title'=>'', |
|
122 | - 'payment_instructions'=>'', |
|
123 | - 'payable_to'=>'', |
|
124 | - 'address_to_send_payment'=>'', |
|
125 | - ), |
|
126 | - $extra_meta_for_payment_method |
|
127 | - ); |
|
128 | - return EEH_Template::locate_template( |
|
129 | - 'payment_methods/Check/templates/check_payment_details_content.template.php', |
|
130 | - $template_vars |
|
131 | - ); |
|
132 | - } |
|
108 | + /** |
|
109 | + * For adding any html output ab ove the payment overview. |
|
110 | + * Many gateways won't want ot display anything, so this function just returns an empty string. |
|
111 | + * Other gateways may want to override this, such as offline gateways. |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function payment_overview_content(EE_Payment $payment) |
|
115 | + { |
|
116 | + $extra_meta_for_payment_method = $this->_pm_instance->all_extra_meta_array(); |
|
117 | + $template_vars = array_merge( |
|
118 | + array( |
|
119 | + 'payment_method'=>$this->_pm_instance, |
|
120 | + 'payment'=>$payment, |
|
121 | + 'check_title'=>'', |
|
122 | + 'payment_instructions'=>'', |
|
123 | + 'payable_to'=>'', |
|
124 | + 'address_to_send_payment'=>'', |
|
125 | + ), |
|
126 | + $extra_meta_for_payment_method |
|
127 | + ); |
|
128 | + return EEH_Template::locate_template( |
|
129 | + 'payment_methods/Check/templates/check_payment_details_content.template.php', |
|
130 | + $template_vars |
|
131 | + ); |
|
132 | + } |
|
133 | 133 | } |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
49 | 49 | $organization = EE_Registry::instance()->CFG->organization; |
50 | 50 | $organization_name = $organization->get_pretty('name'); |
51 | - $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1') . '<br />' : ''; |
|
52 | - $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2') . '<br />' : ''; |
|
51 | + $default_address = $organization->address_1 != '' ? $organization->get_pretty('address_1').'<br />' : ''; |
|
52 | + $default_address .= $organization->address_2 != '' ? $organization->get_pretty('address_2').'<br />' : ''; |
|
53 | 53 | $default_address .= $organization->city != '' ? $organization->get_pretty('city') : ''; |
54 | - $default_address .= ( $organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />'; |
|
54 | + $default_address .= ($organization->city != '' && $organization->STA_ID != '') ? ', ' : '<br />'; |
|
55 | 55 | $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
56 | - $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO) ; |
|
57 | - $default_address .= $state ? $state->name() . '<br />' : ''; |
|
58 | - $default_address .= $country ? $country->name(). '<br />' : ''; |
|
56 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($organization->CNT_ISO); |
|
57 | + $default_address .= $state ? $state->name().'<br />' : ''; |
|
58 | + $default_address .= $country ? $country->name().'<br />' : ''; |
|
59 | 59 | $default_address .= $organization->zip != '' ? $organization->get_pretty('zip') : ''; |
60 | 60 | } else { |
61 | 61 | $default_address = 'unknown'; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | 'payment_instructions'=>new EE_Text_Area_Input(array( |
71 | 71 | 'html_label_text'=> sprintf(__("Instructions %s", "event_espresso"), $this->get_help_tab_link()), |
72 | 72 | 'default'=> __("Please send Check/Money Order to the address below. Payment must be received within 48 hours of event date.", 'event_espresso'), |
73 | - 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
73 | + 'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()), |
|
74 | 74 | )), |
75 | 75 | 'payable_to'=>new EE_Text_Input(array( |
76 | 76 | 'html_label_text'=> sprintf(__("Payable To %s", "event_espresso"), $this->get_help_tab_link()), |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | 'address_to_send_payment'=>new EE_Text_Area_Input(array( |
80 | 80 | 'html_label_text'=> sprintf(__("Address Payable %s", "event_espresso"), $this->get_help_tab_link()), |
81 | 81 | 'default'=>$default_address, |
82 | - 'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ), |
|
82 | + 'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()), |
|
83 | 83 | )), |
84 | 84 | ), |
85 | 85 | 'exclude'=>array('PMD_debug_mode') |
@@ -13,105 +13,105 @@ |
||
13 | 13 | class EE_PMT_Paypal_Standard extends EE_PMT_Base |
14 | 14 | { |
15 | 15 | |
16 | - const shipping_info_none = 1; |
|
17 | - const shipping_info_optional = 0; |
|
18 | - const shipping_info_required = 2; |
|
19 | - |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * @param null $pm_instance |
|
24 | - * @return \EE_PMT_Paypal_Standard |
|
25 | - * @throws \EE_Error |
|
26 | - */ |
|
27 | - public function __construct($pm_instance = null) |
|
28 | - { |
|
29 | - require_once($this->file_folder().'EEG_Paypal_Standard.gateway.php'); |
|
30 | - $this->_gateway = new EEG_Paypal_Standard(); |
|
31 | - $this->_pretty_name = __("PayPal Standard", 'event_espresso'); |
|
32 | - $this->_default_description = sprintf( |
|
33 | - __( |
|
34 | - 'Upon submitting this form, you will be forwarded to PayPal to make your payment. %1$sMake sure you return to this site in order to properly finalize your registration.%2$s', |
|
35 | - 'event_espresso' |
|
36 | - ), |
|
37 | - '<strong>', |
|
38 | - '</strong>' |
|
39 | - ); |
|
40 | - parent::__construct($pm_instance); |
|
41 | - $this->_default_button_url = $this->file_url().'lib/paypal-logo.png'; |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * Creates the billing form for this payment method type |
|
48 | - * @param \EE_Transaction $transaction |
|
49 | - * @return NULL |
|
50 | - */ |
|
51 | - public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
52 | - { |
|
53 | - return null; |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * Gets the form for all the settings related to this payment method type |
|
60 | - * |
|
61 | - * @return EE_Payment_Method_Form |
|
62 | - * @throws \EE_Error |
|
63 | - */ |
|
64 | - public function generate_new_settings_form() |
|
65 | - { |
|
66 | - require_once($this->file_folder() . 'EE_Paypal_Standard_Form.form.php'); |
|
67 | - $form = new EE_Paypal_Standard_Form($this); |
|
68 | - $form->get_input('PMD_debug_mode')->set_html_label_text( |
|
69 | - sprintf(__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link()) |
|
70 | - ); |
|
71 | - $form->get_input('shipping_details')->set_html_label_text( |
|
72 | - sprintf(__("Shipping Address Options %s", "event_espresso"), $this->get_help_tab_link()) |
|
73 | - ); |
|
74 | - return $form; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * Adds the help tab |
|
81 | - * @see EE_PMT_Base::help_tabs_config() |
|
82 | - * @return array |
|
83 | - */ |
|
84 | - public function help_tabs_config() |
|
85 | - { |
|
86 | - return array( |
|
87 | - $this->get_help_tab_name() => array( |
|
88 | - 'title'=> __("PayPal Standard Settings", 'event_espresso'), |
|
89 | - 'filename'=>'payment_methods_overview_paypalstandard' |
|
90 | - ) |
|
91 | - ); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * Logic to be accomplished when the payment attempt is complete. |
|
98 | - * Most payment methods don't need to do anything at this point; but some, like Mijireh, do. |
|
99 | - * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from |
|
100 | - * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status |
|
101 | - * of the payment). Fed a transaction because it's always assumed to be the last payment that |
|
102 | - * |
|
103 | - * @param EE_Transaction $transaction |
|
104 | - * @return EE_Payment |
|
105 | - * @throws \EE_Error |
|
106 | - */ |
|
107 | - public function finalize_payment_for($transaction) |
|
108 | - { |
|
109 | - // PayPal standard actually sends the IPN info along with the user when they return to our site |
|
110 | - // so in case the IPN is arriving later, let's try to process an IPN! |
|
111 | - if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
|
112 | - return $this->handle_ipn($_POST, $transaction); |
|
113 | - } else { |
|
114 | - return parent::finalize_payment_for($transaction); |
|
115 | - } |
|
116 | - } |
|
16 | + const shipping_info_none = 1; |
|
17 | + const shipping_info_optional = 0; |
|
18 | + const shipping_info_required = 2; |
|
19 | + |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * @param null $pm_instance |
|
24 | + * @return \EE_PMT_Paypal_Standard |
|
25 | + * @throws \EE_Error |
|
26 | + */ |
|
27 | + public function __construct($pm_instance = null) |
|
28 | + { |
|
29 | + require_once($this->file_folder().'EEG_Paypal_Standard.gateway.php'); |
|
30 | + $this->_gateway = new EEG_Paypal_Standard(); |
|
31 | + $this->_pretty_name = __("PayPal Standard", 'event_espresso'); |
|
32 | + $this->_default_description = sprintf( |
|
33 | + __( |
|
34 | + 'Upon submitting this form, you will be forwarded to PayPal to make your payment. %1$sMake sure you return to this site in order to properly finalize your registration.%2$s', |
|
35 | + 'event_espresso' |
|
36 | + ), |
|
37 | + '<strong>', |
|
38 | + '</strong>' |
|
39 | + ); |
|
40 | + parent::__construct($pm_instance); |
|
41 | + $this->_default_button_url = $this->file_url().'lib/paypal-logo.png'; |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * Creates the billing form for this payment method type |
|
48 | + * @param \EE_Transaction $transaction |
|
49 | + * @return NULL |
|
50 | + */ |
|
51 | + public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
52 | + { |
|
53 | + return null; |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * Gets the form for all the settings related to this payment method type |
|
60 | + * |
|
61 | + * @return EE_Payment_Method_Form |
|
62 | + * @throws \EE_Error |
|
63 | + */ |
|
64 | + public function generate_new_settings_form() |
|
65 | + { |
|
66 | + require_once($this->file_folder() . 'EE_Paypal_Standard_Form.form.php'); |
|
67 | + $form = new EE_Paypal_Standard_Form($this); |
|
68 | + $form->get_input('PMD_debug_mode')->set_html_label_text( |
|
69 | + sprintf(__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link()) |
|
70 | + ); |
|
71 | + $form->get_input('shipping_details')->set_html_label_text( |
|
72 | + sprintf(__("Shipping Address Options %s", "event_espresso"), $this->get_help_tab_link()) |
|
73 | + ); |
|
74 | + return $form; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * Adds the help tab |
|
81 | + * @see EE_PMT_Base::help_tabs_config() |
|
82 | + * @return array |
|
83 | + */ |
|
84 | + public function help_tabs_config() |
|
85 | + { |
|
86 | + return array( |
|
87 | + $this->get_help_tab_name() => array( |
|
88 | + 'title'=> __("PayPal Standard Settings", 'event_espresso'), |
|
89 | + 'filename'=>'payment_methods_overview_paypalstandard' |
|
90 | + ) |
|
91 | + ); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * Logic to be accomplished when the payment attempt is complete. |
|
98 | + * Most payment methods don't need to do anything at this point; but some, like Mijireh, do. |
|
99 | + * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from |
|
100 | + * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status |
|
101 | + * of the payment). Fed a transaction because it's always assumed to be the last payment that |
|
102 | + * |
|
103 | + * @param EE_Transaction $transaction |
|
104 | + * @return EE_Payment |
|
105 | + * @throws \EE_Error |
|
106 | + */ |
|
107 | + public function finalize_payment_for($transaction) |
|
108 | + { |
|
109 | + // PayPal standard actually sends the IPN info along with the user when they return to our site |
|
110 | + // so in case the IPN is arriving later, let's try to process an IPN! |
|
111 | + if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
|
112 | + return $this->handle_ipn($_POST, $transaction); |
|
113 | + } else { |
|
114 | + return parent::finalize_payment_for($transaction); |
|
115 | + } |
|
116 | + } |
|
117 | 117 | } |
@@ -14,98 +14,98 @@ |
||
14 | 14 | |
15 | 15 | |
16 | 16 | |
17 | - /** |
|
18 | - * |
|
19 | - * @param EE_Payment_Method $pm_instance |
|
20 | - * @return EE_PMT_Mijireh |
|
21 | - */ |
|
22 | - public function __construct($pm_instance = null) |
|
23 | - { |
|
24 | - require_once($this->file_folder().'EEG_Mijireh.gateway.php'); |
|
25 | - $this->_gateway = new EEG_Mijireh(); |
|
26 | - $this->_pretty_name = __("Mijireh", 'event_espresso'); |
|
27 | - $this->_default_description = __('After clicking "Finalize Registration", you will be able to enter your billing information and complete your payment.', 'event_espresso'); |
|
28 | - parent::__construct($pm_instance); |
|
29 | - $this->_default_button_url = $this->file_url() . 'lib/mijireh-checkout-logo.png'; |
|
30 | - } |
|
31 | - |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Adds the help tab |
|
36 | - * @see EE_PMT_Base::help_tabs_config() |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public function help_tabs_config() |
|
40 | - { |
|
41 | - return array( |
|
42 | - $this->get_help_tab_name() => array( |
|
43 | - 'title' => __('Mijireh Settings', 'event_espresso'), |
|
44 | - 'filename' => 'payment_methods_overview_mijireh' |
|
45 | - ), |
|
46 | - ); |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * Gets the form for all the settings related to this payment method type |
|
53 | - * @return EE_Payment_Method_Form |
|
54 | - */ |
|
55 | - public function generate_new_settings_form() |
|
56 | - { |
|
57 | - $form = new EE_Payment_Method_Form( |
|
58 | - array( |
|
59 | - 'extra_meta_inputs' => array( |
|
60 | - 'access_key' => new EE_Text_Input( |
|
61 | - array( |
|
62 | - 'html_label_text' => sprintf( |
|
63 | - __("Mijireh Access Key %s", 'event_espresso'), |
|
64 | - $this->get_help_tab_link() |
|
65 | - ), |
|
66 | - 'required' => true |
|
67 | - ) |
|
68 | - ), |
|
69 | - ), |
|
70 | - 'exclude' => array( 'PMD_debug_mode' ), |
|
71 | - ) |
|
72 | - ); |
|
73 | - $form->add_subsections( |
|
74 | - array( |
|
75 | - 'slurper_area' => new EE_Form_Section_HTML_From_Template( |
|
76 | - $this->file_folder() . '/templates/mijireh_settings_after_form.template.php' |
|
77 | - ) |
|
78 | - ), |
|
79 | - null, // no specific subsection targeted |
|
80 | - false // add to end |
|
81 | - ); |
|
82 | - return $form; |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * Creates the billing form for this payment method type |
|
89 | - * @param \EE_Transaction $transaction |
|
90 | - * @return NULL |
|
91 | - */ |
|
92 | - public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
93 | - { |
|
94 | - return null; |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * |
|
101 | - * mijireh doesn't send an IPN in the usual sense |
|
102 | - * they just send the user back to our thank you page |
|
103 | - * and then we need to directly query them for the payment's status |
|
104 | - * @param EE_Transaction $transaction |
|
105 | - * @return \EE_Payment |
|
106 | - */ |
|
107 | - public function finalize_payment_for($transaction) |
|
108 | - { |
|
109 | - return $this->handle_ipn($_REQUEST, $transaction); |
|
110 | - } |
|
17 | + /** |
|
18 | + * |
|
19 | + * @param EE_Payment_Method $pm_instance |
|
20 | + * @return EE_PMT_Mijireh |
|
21 | + */ |
|
22 | + public function __construct($pm_instance = null) |
|
23 | + { |
|
24 | + require_once($this->file_folder().'EEG_Mijireh.gateway.php'); |
|
25 | + $this->_gateway = new EEG_Mijireh(); |
|
26 | + $this->_pretty_name = __("Mijireh", 'event_espresso'); |
|
27 | + $this->_default_description = __('After clicking "Finalize Registration", you will be able to enter your billing information and complete your payment.', 'event_espresso'); |
|
28 | + parent::__construct($pm_instance); |
|
29 | + $this->_default_button_url = $this->file_url() . 'lib/mijireh-checkout-logo.png'; |
|
30 | + } |
|
31 | + |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Adds the help tab |
|
36 | + * @see EE_PMT_Base::help_tabs_config() |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public function help_tabs_config() |
|
40 | + { |
|
41 | + return array( |
|
42 | + $this->get_help_tab_name() => array( |
|
43 | + 'title' => __('Mijireh Settings', 'event_espresso'), |
|
44 | + 'filename' => 'payment_methods_overview_mijireh' |
|
45 | + ), |
|
46 | + ); |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * Gets the form for all the settings related to this payment method type |
|
53 | + * @return EE_Payment_Method_Form |
|
54 | + */ |
|
55 | + public function generate_new_settings_form() |
|
56 | + { |
|
57 | + $form = new EE_Payment_Method_Form( |
|
58 | + array( |
|
59 | + 'extra_meta_inputs' => array( |
|
60 | + 'access_key' => new EE_Text_Input( |
|
61 | + array( |
|
62 | + 'html_label_text' => sprintf( |
|
63 | + __("Mijireh Access Key %s", 'event_espresso'), |
|
64 | + $this->get_help_tab_link() |
|
65 | + ), |
|
66 | + 'required' => true |
|
67 | + ) |
|
68 | + ), |
|
69 | + ), |
|
70 | + 'exclude' => array( 'PMD_debug_mode' ), |
|
71 | + ) |
|
72 | + ); |
|
73 | + $form->add_subsections( |
|
74 | + array( |
|
75 | + 'slurper_area' => new EE_Form_Section_HTML_From_Template( |
|
76 | + $this->file_folder() . '/templates/mijireh_settings_after_form.template.php' |
|
77 | + ) |
|
78 | + ), |
|
79 | + null, // no specific subsection targeted |
|
80 | + false // add to end |
|
81 | + ); |
|
82 | + return $form; |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * Creates the billing form for this payment method type |
|
89 | + * @param \EE_Transaction $transaction |
|
90 | + * @return NULL |
|
91 | + */ |
|
92 | + public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
93 | + { |
|
94 | + return null; |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * |
|
101 | + * mijireh doesn't send an IPN in the usual sense |
|
102 | + * they just send the user back to our thank you page |
|
103 | + * and then we need to directly query them for the payment's status |
|
104 | + * @param EE_Transaction $transaction |
|
105 | + * @return \EE_Payment |
|
106 | + */ |
|
107 | + public function finalize_payment_for($transaction) |
|
108 | + { |
|
109 | + return $this->handle_ipn($_REQUEST, $transaction); |
|
110 | + } |
|
111 | 111 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $this->_pretty_name = __("Mijireh", 'event_espresso'); |
27 | 27 | $this->_default_description = __('After clicking "Finalize Registration", you will be able to enter your billing information and complete your payment.', 'event_espresso'); |
28 | 28 | parent::__construct($pm_instance); |
29 | - $this->_default_button_url = $this->file_url() . 'lib/mijireh-checkout-logo.png'; |
|
29 | + $this->_default_button_url = $this->file_url().'lib/mijireh-checkout-logo.png'; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | ) |
68 | 68 | ), |
69 | 69 | ), |
70 | - 'exclude' => array( 'PMD_debug_mode' ), |
|
70 | + 'exclude' => array('PMD_debug_mode'), |
|
71 | 71 | ) |
72 | 72 | ); |
73 | 73 | $form->add_subsections( |
74 | 74 | array( |
75 | 75 | 'slurper_area' => new EE_Form_Section_HTML_From_Template( |
76 | - $this->file_folder() . '/templates/mijireh_settings_after_form.template.php' |
|
76 | + $this->file_folder().'/templates/mijireh_settings_after_form.template.php' |
|
77 | 77 | ) |
78 | 78 | ), |
79 | 79 | null, // no specific subsection targeted |
@@ -12,275 +12,275 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * @param EE_Payment_Method $pm_instance |
|
17 | - * @return EE_PMT_Aim |
|
18 | - * @throws \EE_Error |
|
19 | - */ |
|
20 | - public function __construct($pm_instance = null) |
|
21 | - { |
|
22 | - $this->_setup_properties(); |
|
23 | - parent::__construct($pm_instance); |
|
24 | - } |
|
15 | + /** |
|
16 | + * @param EE_Payment_Method $pm_instance |
|
17 | + * @return EE_PMT_Aim |
|
18 | + * @throws \EE_Error |
|
19 | + */ |
|
20 | + public function __construct($pm_instance = null) |
|
21 | + { |
|
22 | + $this->_setup_properties(); |
|
23 | + parent::__construct($pm_instance); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Sets up payment method type properties for this gateway, which is normally |
|
28 | - * done in the constructor, but we want this to be easy for similar gateways to override |
|
29 | - * while still calling the parent constructor. |
|
30 | - * So children should override this method instead of __construct |
|
31 | - */ |
|
32 | - protected function _setup_properties() |
|
33 | - { |
|
34 | - require_once($this->file_folder().'EEG_Aim.gateway.php'); |
|
35 | - $this->_gateway = new EEG_Aim(); |
|
36 | - $this->_pretty_name = __("Authorize.net AIM", 'event_espresso'); |
|
37 | - $this->_default_description = __('Please provide the following billing information.', 'event_espresso'); |
|
38 | - $this->_requires_https = true; |
|
39 | - } |
|
26 | + /** |
|
27 | + * Sets up payment method type properties for this gateway, which is normally |
|
28 | + * done in the constructor, but we want this to be easy for similar gateways to override |
|
29 | + * while still calling the parent constructor. |
|
30 | + * So children should override this method instead of __construct |
|
31 | + */ |
|
32 | + protected function _setup_properties() |
|
33 | + { |
|
34 | + require_once($this->file_folder().'EEG_Aim.gateway.php'); |
|
35 | + $this->_gateway = new EEG_Aim(); |
|
36 | + $this->_pretty_name = __("Authorize.net AIM", 'event_espresso'); |
|
37 | + $this->_default_description = __('Please provide the following billing information.', 'event_espresso'); |
|
38 | + $this->_requires_https = true; |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * Creates the billing form for this payment method type |
|
45 | - * |
|
46 | - * @param \EE_Transaction $transaction |
|
47 | - * @return EE_Billing_Info_Form |
|
48 | - * @throws \EE_Error |
|
49 | - */ |
|
50 | - public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
51 | - { |
|
52 | - $billing_form = new EE_Billing_Attendee_Info_Form($this->_pm_instance, array( |
|
53 | - 'name'=>'AIM_Form', |
|
54 | - 'subsections'=>array( |
|
55 | - 'credit_card'=>new EE_Credit_Card_Input(array( |
|
56 | - 'required'=>true, |
|
57 | - 'html_label_text' => __('Card Number', 'event_espresso') |
|
58 | - )), |
|
59 | - 'exp_month'=>new EE_Credit_Card_Month_Input(true, array( |
|
60 | - 'required'=>true, |
|
61 | - 'html_label_text' => __('Expiry Month', 'event_espresso') |
|
62 | - )), |
|
63 | - 'exp_year'=>new EE_Credit_Card_Year_Input(array( |
|
64 | - 'required'=>true, |
|
65 | - 'html_label_text' => __('Expiry Year', 'event_espresso') |
|
66 | - )), |
|
67 | - 'cvv'=>new EE_CVV_Input(array( |
|
68 | - 'required'=>true, |
|
69 | - 'html_label_text' => __('CVV', 'event_espresso') )), |
|
70 | - ) |
|
71 | - )); |
|
72 | - $billing_form->add_subsections(array( |
|
73 | - 'company' => new EE_Text_Input(array( |
|
74 | - 'html_label_text' => __('Company', 'event_espresso') |
|
75 | - )) |
|
76 | - ), 'email', false); |
|
77 | - $billing_form->add_subsections( |
|
78 | - array( |
|
79 | - 'fax' => new EE_Text_Input(array( |
|
80 | - 'html_label_text' => __('Fax', 'event_espresso') |
|
81 | - )) |
|
82 | - ), |
|
83 | - 'phone', |
|
84 | - false |
|
85 | - ); |
|
86 | - $settings_form = $this->settings_form(); |
|
87 | - if ($settings_form->get_input('excluded_billing_inputs') instanceof EE_Checkbox_Multi_Input) { |
|
88 | - $billing_form->exclude($settings_form->get_input('excluded_billing_inputs')->normalized_value()); |
|
89 | - } |
|
90 | - if ($settings_form->get_input('required_billing_inputs') instanceof EE_Checkbox_Multi_Input) { |
|
91 | - $required_inputs = $settings_form->get_input('required_billing_inputs')->normalized_value(); |
|
92 | - // only change the requirement of inputs which are allowed to be changed |
|
93 | - /** @var EE_Form_Input_Base[] $inputs_to_evaluate */ |
|
94 | - $inputs_to_evaluate = array_intersect_key( |
|
95 | - $billing_form->inputs(), |
|
96 | - $this->billing_input_names() |
|
97 | - ); |
|
98 | - foreach ($inputs_to_evaluate as $input_name => $input) { |
|
99 | - if (in_array($input_name, $required_inputs)) { |
|
100 | - $input->set_required(true); |
|
101 | - } else { |
|
102 | - $input->set_required(false); |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
106 | - return $this->apply_billing_form_debug_settings($billing_form); |
|
107 | - } |
|
43 | + /** |
|
44 | + * Creates the billing form for this payment method type |
|
45 | + * |
|
46 | + * @param \EE_Transaction $transaction |
|
47 | + * @return EE_Billing_Info_Form |
|
48 | + * @throws \EE_Error |
|
49 | + */ |
|
50 | + public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
51 | + { |
|
52 | + $billing_form = new EE_Billing_Attendee_Info_Form($this->_pm_instance, array( |
|
53 | + 'name'=>'AIM_Form', |
|
54 | + 'subsections'=>array( |
|
55 | + 'credit_card'=>new EE_Credit_Card_Input(array( |
|
56 | + 'required'=>true, |
|
57 | + 'html_label_text' => __('Card Number', 'event_espresso') |
|
58 | + )), |
|
59 | + 'exp_month'=>new EE_Credit_Card_Month_Input(true, array( |
|
60 | + 'required'=>true, |
|
61 | + 'html_label_text' => __('Expiry Month', 'event_espresso') |
|
62 | + )), |
|
63 | + 'exp_year'=>new EE_Credit_Card_Year_Input(array( |
|
64 | + 'required'=>true, |
|
65 | + 'html_label_text' => __('Expiry Year', 'event_espresso') |
|
66 | + )), |
|
67 | + 'cvv'=>new EE_CVV_Input(array( |
|
68 | + 'required'=>true, |
|
69 | + 'html_label_text' => __('CVV', 'event_espresso') )), |
|
70 | + ) |
|
71 | + )); |
|
72 | + $billing_form->add_subsections(array( |
|
73 | + 'company' => new EE_Text_Input(array( |
|
74 | + 'html_label_text' => __('Company', 'event_espresso') |
|
75 | + )) |
|
76 | + ), 'email', false); |
|
77 | + $billing_form->add_subsections( |
|
78 | + array( |
|
79 | + 'fax' => new EE_Text_Input(array( |
|
80 | + 'html_label_text' => __('Fax', 'event_espresso') |
|
81 | + )) |
|
82 | + ), |
|
83 | + 'phone', |
|
84 | + false |
|
85 | + ); |
|
86 | + $settings_form = $this->settings_form(); |
|
87 | + if ($settings_form->get_input('excluded_billing_inputs') instanceof EE_Checkbox_Multi_Input) { |
|
88 | + $billing_form->exclude($settings_form->get_input('excluded_billing_inputs')->normalized_value()); |
|
89 | + } |
|
90 | + if ($settings_form->get_input('required_billing_inputs') instanceof EE_Checkbox_Multi_Input) { |
|
91 | + $required_inputs = $settings_form->get_input('required_billing_inputs')->normalized_value(); |
|
92 | + // only change the requirement of inputs which are allowed to be changed |
|
93 | + /** @var EE_Form_Input_Base[] $inputs_to_evaluate */ |
|
94 | + $inputs_to_evaluate = array_intersect_key( |
|
95 | + $billing_form->inputs(), |
|
96 | + $this->billing_input_names() |
|
97 | + ); |
|
98 | + foreach ($inputs_to_evaluate as $input_name => $input) { |
|
99 | + if (in_array($input_name, $required_inputs)) { |
|
100 | + $input->set_required(true); |
|
101 | + } else { |
|
102 | + $input->set_required(false); |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | + return $this->apply_billing_form_debug_settings($billing_form); |
|
107 | + } |
|
108 | 108 | |
109 | 109 | |
110 | 110 | |
111 | - /** |
|
112 | - * apply_billing_form_debug_settings |
|
113 | - * applies debug data to the form |
|
114 | - * |
|
115 | - * @param \EE_Billing_Info_Form $billing_form |
|
116 | - * @return \EE_Billing_Info_Form |
|
117 | - * @throws \EE_Error |
|
118 | - */ |
|
119 | - public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) |
|
120 | - { |
|
121 | - if ($this->_pm_instance->debug_mode() |
|
122 | - || $this->_pm_instance->get_extra_meta('test_transactions', true, false) |
|
123 | - ) { |
|
124 | - $billing_form->get_input('credit_card')->set_default('4007000000027'); |
|
125 | - $billing_form->get_input('exp_year')->set_default('2020'); |
|
126 | - if ($billing_form->get_subsection('cvv') instanceof EE_Form_Input_Base) { |
|
127 | - $billing_form->get_input('cvv')->set_default('123'); |
|
128 | - } |
|
129 | - $billing_form->add_subsections( |
|
130 | - array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ), |
|
131 | - 'credit_card' |
|
132 | - ); |
|
133 | - $billing_form->add_subsections( |
|
134 | - array( |
|
135 | - 'debug_content' => new EE_Form_Section_HTML_From_Template( |
|
136 | - __DIR__.'/templates/authorize_net_aim_debug_info.template.php' |
|
137 | - ) |
|
138 | - ), |
|
139 | - 'first_name' |
|
140 | - ); |
|
141 | - } |
|
142 | - return $billing_form; |
|
143 | - } |
|
111 | + /** |
|
112 | + * apply_billing_form_debug_settings |
|
113 | + * applies debug data to the form |
|
114 | + * |
|
115 | + * @param \EE_Billing_Info_Form $billing_form |
|
116 | + * @return \EE_Billing_Info_Form |
|
117 | + * @throws \EE_Error |
|
118 | + */ |
|
119 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) |
|
120 | + { |
|
121 | + if ($this->_pm_instance->debug_mode() |
|
122 | + || $this->_pm_instance->get_extra_meta('test_transactions', true, false) |
|
123 | + ) { |
|
124 | + $billing_form->get_input('credit_card')->set_default('4007000000027'); |
|
125 | + $billing_form->get_input('exp_year')->set_default('2020'); |
|
126 | + if ($billing_form->get_subsection('cvv') instanceof EE_Form_Input_Base) { |
|
127 | + $billing_form->get_input('cvv')->set_default('123'); |
|
128 | + } |
|
129 | + $billing_form->add_subsections( |
|
130 | + array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ), |
|
131 | + 'credit_card' |
|
132 | + ); |
|
133 | + $billing_form->add_subsections( |
|
134 | + array( |
|
135 | + 'debug_content' => new EE_Form_Section_HTML_From_Template( |
|
136 | + __DIR__.'/templates/authorize_net_aim_debug_info.template.php' |
|
137 | + ) |
|
138 | + ), |
|
139 | + 'first_name' |
|
140 | + ); |
|
141 | + } |
|
142 | + return $billing_form; |
|
143 | + } |
|
144 | 144 | |
145 | 145 | |
146 | 146 | |
147 | - /** |
|
148 | - * Gets the form for all the settings related to this payment method type |
|
149 | - * @return EE_Payment_Method_Form |
|
150 | - */ |
|
151 | - public function generate_new_settings_form() |
|
152 | - { |
|
153 | - $billing_input_names = $this->billing_input_names(); |
|
154 | - return new EE_Payment_Method_Form( |
|
155 | - array( |
|
156 | - 'extra_meta_inputs'=>array( |
|
157 | - 'login_id'=>new EE_Text_Input( |
|
158 | - array( |
|
159 | - 'html_label_text'=> sprintf(__("Authorize.net API Login ID %s", "event_espresso"), $this->get_help_tab_link()), |
|
160 | - 'required' => true ) |
|
161 | - ), |
|
162 | - 'transaction_key'=>new EE_Text_Input( |
|
163 | - array( |
|
164 | - 'html_label_text'=> sprintf(__("Authorize.net Transaction Key %s", "event_espresso"), $this->get_help_tab_link()), |
|
165 | - 'required' => true ) |
|
166 | - ), |
|
167 | - 'test_transactions'=>new EE_Yes_No_Input( |
|
168 | - array( |
|
169 | - 'html_label_text'=> sprintf(__("Send test transactions? %s", 'event_espresso'), $this->get_help_tab_link()), |
|
170 | - 'html_help_text'=> __("Send test transactions, even to live server", 'event_espresso'), |
|
171 | - 'default' => false, |
|
172 | - 'required' => true |
|
173 | - ) |
|
174 | - ), |
|
175 | - 'excluded_billing_inputs' => new EE_Checkbox_Multi_Input( |
|
176 | - $billing_input_names, |
|
177 | - array( |
|
178 | - 'html_label_text' => sprintf(__("Excluded Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()), |
|
179 | - 'default' => array( |
|
180 | - 'company', |
|
181 | - 'fax', |
|
182 | - ) |
|
183 | - ) |
|
184 | - ), |
|
185 | - 'required_billing_inputs' => new EE_Checkbox_Multi_Input( |
|
186 | - $billing_input_names, |
|
187 | - array( |
|
188 | - 'html_label_text' => sprintf(__("Required Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()), |
|
189 | - 'default' => array_diff( |
|
190 | - array_keys($billing_input_names), |
|
191 | - array( 'address2', 'phone', 'company', 'fax' ) |
|
192 | - ), |
|
193 | - 'html_help_text' => __('Note: if fields are excluded they cannot be required.', 'event_espresso') |
|
194 | - ) |
|
195 | - ), |
|
196 | - 'server' => new EE_Select_Input( |
|
197 | - apply_filters( |
|
198 | - 'FHEE__EE_PMT_Aim__generate_new_settings_form__server_select_input__options', |
|
199 | - array( |
|
200 | - 'akamai' => __('Authorize.net/Akamai (default)', 'event_espresso'), |
|
201 | - 'authorize.net' => __('Authorize.net (deprecated)', 'event_espresso'), |
|
202 | - ), |
|
203 | - $this |
|
204 | - ), |
|
205 | - array( |
|
206 | - 'html_label_text' => __('Server', 'event_espresso'), |
|
207 | - 'html_help_text' => __('The Gateway Server where payment requests will be sent', 'event_espresso') |
|
208 | - ) |
|
209 | - ) |
|
147 | + /** |
|
148 | + * Gets the form for all the settings related to this payment method type |
|
149 | + * @return EE_Payment_Method_Form |
|
150 | + */ |
|
151 | + public function generate_new_settings_form() |
|
152 | + { |
|
153 | + $billing_input_names = $this->billing_input_names(); |
|
154 | + return new EE_Payment_Method_Form( |
|
155 | + array( |
|
156 | + 'extra_meta_inputs'=>array( |
|
157 | + 'login_id'=>new EE_Text_Input( |
|
158 | + array( |
|
159 | + 'html_label_text'=> sprintf(__("Authorize.net API Login ID %s", "event_espresso"), $this->get_help_tab_link()), |
|
160 | + 'required' => true ) |
|
161 | + ), |
|
162 | + 'transaction_key'=>new EE_Text_Input( |
|
163 | + array( |
|
164 | + 'html_label_text'=> sprintf(__("Authorize.net Transaction Key %s", "event_espresso"), $this->get_help_tab_link()), |
|
165 | + 'required' => true ) |
|
166 | + ), |
|
167 | + 'test_transactions'=>new EE_Yes_No_Input( |
|
168 | + array( |
|
169 | + 'html_label_text'=> sprintf(__("Send test transactions? %s", 'event_espresso'), $this->get_help_tab_link()), |
|
170 | + 'html_help_text'=> __("Send test transactions, even to live server", 'event_espresso'), |
|
171 | + 'default' => false, |
|
172 | + 'required' => true |
|
173 | + ) |
|
174 | + ), |
|
175 | + 'excluded_billing_inputs' => new EE_Checkbox_Multi_Input( |
|
176 | + $billing_input_names, |
|
177 | + array( |
|
178 | + 'html_label_text' => sprintf(__("Excluded Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()), |
|
179 | + 'default' => array( |
|
180 | + 'company', |
|
181 | + 'fax', |
|
182 | + ) |
|
183 | + ) |
|
184 | + ), |
|
185 | + 'required_billing_inputs' => new EE_Checkbox_Multi_Input( |
|
186 | + $billing_input_names, |
|
187 | + array( |
|
188 | + 'html_label_text' => sprintf(__("Required Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()), |
|
189 | + 'default' => array_diff( |
|
190 | + array_keys($billing_input_names), |
|
191 | + array( 'address2', 'phone', 'company', 'fax' ) |
|
192 | + ), |
|
193 | + 'html_help_text' => __('Note: if fields are excluded they cannot be required.', 'event_espresso') |
|
194 | + ) |
|
195 | + ), |
|
196 | + 'server' => new EE_Select_Input( |
|
197 | + apply_filters( |
|
198 | + 'FHEE__EE_PMT_Aim__generate_new_settings_form__server_select_input__options', |
|
199 | + array( |
|
200 | + 'akamai' => __('Authorize.net/Akamai (default)', 'event_espresso'), |
|
201 | + 'authorize.net' => __('Authorize.net (deprecated)', 'event_espresso'), |
|
202 | + ), |
|
203 | + $this |
|
204 | + ), |
|
205 | + array( |
|
206 | + 'html_label_text' => __('Server', 'event_espresso'), |
|
207 | + 'html_help_text' => __('The Gateway Server where payment requests will be sent', 'event_espresso') |
|
208 | + ) |
|
209 | + ) |
|
210 | 210 | |
211 | - ) |
|
212 | - ) |
|
213 | - ); |
|
214 | - } |
|
211 | + ) |
|
212 | + ) |
|
213 | + ); |
|
214 | + } |
|
215 | 215 | |
216 | - /** |
|
217 | - * Returns an array where keys are the slugs for billing inputs, and values |
|
218 | - * are their i18n names |
|
219 | - * @return array |
|
220 | - */ |
|
221 | - public function billing_input_names() |
|
222 | - { |
|
223 | - return array( |
|
224 | - 'first_name' => __('First Name', 'event_espresso'), |
|
225 | - 'last_name' => __('Last Name', 'event_espresso'), |
|
226 | - 'email' => __('Email', 'event_espresso'), |
|
227 | - 'company' => __('Company', 'event_espresso'), |
|
228 | - 'address' => __('Address', 'event_espresso'), |
|
229 | - 'address2' => __('Address2', 'event_espresso'), |
|
230 | - 'city' => __('City', 'event_espresso'), |
|
231 | - 'state' => __('State', 'event_espresso'), |
|
232 | - 'country' => __('Country', 'event_espresso'), |
|
233 | - 'zip' => __('Zip', 'event_espresso'), |
|
234 | - 'phone' => __('Phone', 'event_espresso'), |
|
235 | - 'fax' => __('Fax', 'event_espresso'), |
|
236 | - 'cvv' => __('CVV', 'event_espresso') |
|
237 | - ); |
|
238 | - } |
|
216 | + /** |
|
217 | + * Returns an array where keys are the slugs for billing inputs, and values |
|
218 | + * are their i18n names |
|
219 | + * @return array |
|
220 | + */ |
|
221 | + public function billing_input_names() |
|
222 | + { |
|
223 | + return array( |
|
224 | + 'first_name' => __('First Name', 'event_espresso'), |
|
225 | + 'last_name' => __('Last Name', 'event_espresso'), |
|
226 | + 'email' => __('Email', 'event_espresso'), |
|
227 | + 'company' => __('Company', 'event_espresso'), |
|
228 | + 'address' => __('Address', 'event_espresso'), |
|
229 | + 'address2' => __('Address2', 'event_espresso'), |
|
230 | + 'city' => __('City', 'event_espresso'), |
|
231 | + 'state' => __('State', 'event_espresso'), |
|
232 | + 'country' => __('Country', 'event_espresso'), |
|
233 | + 'zip' => __('Zip', 'event_espresso'), |
|
234 | + 'phone' => __('Phone', 'event_espresso'), |
|
235 | + 'fax' => __('Fax', 'event_espresso'), |
|
236 | + 'cvv' => __('CVV', 'event_espresso') |
|
237 | + ); |
|
238 | + } |
|
239 | 239 | |
240 | - /** |
|
241 | - * Overrides parent so we always have all billing inputs in the returned array, |
|
242 | - * not just the ones included at the time. This helps simplify the gateway code |
|
243 | - * |
|
244 | - * @param EE_Billing_Info_Form $billing_form |
|
245 | - * @return array |
|
246 | - */ |
|
247 | - protected function _get_billing_values_from_form($billing_form) |
|
248 | - { |
|
249 | - $all_billing_values_empty = array(); |
|
250 | - foreach (array_keys($this->billing_input_names()) as $input_name) { |
|
251 | - $all_billing_values_empty[ $input_name ] = ''; |
|
252 | - } |
|
253 | - return array_merge( |
|
254 | - $all_billing_values_empty, |
|
255 | - parent::_get_billing_values_from_form($billing_form) |
|
256 | - ); |
|
257 | - } |
|
240 | + /** |
|
241 | + * Overrides parent so we always have all billing inputs in the returned array, |
|
242 | + * not just the ones included at the time. This helps simplify the gateway code |
|
243 | + * |
|
244 | + * @param EE_Billing_Info_Form $billing_form |
|
245 | + * @return array |
|
246 | + */ |
|
247 | + protected function _get_billing_values_from_form($billing_form) |
|
248 | + { |
|
249 | + $all_billing_values_empty = array(); |
|
250 | + foreach (array_keys($this->billing_input_names()) as $input_name) { |
|
251 | + $all_billing_values_empty[ $input_name ] = ''; |
|
252 | + } |
|
253 | + return array_merge( |
|
254 | + $all_billing_values_empty, |
|
255 | + parent::_get_billing_values_from_form($billing_form) |
|
256 | + ); |
|
257 | + } |
|
258 | 258 | |
259 | 259 | |
260 | 260 | |
261 | - /** |
|
262 | - * Adds the help tab |
|
263 | - * @see EE_PMT_Base::help_tabs_config() |
|
264 | - * @return array |
|
265 | - */ |
|
266 | - public function help_tabs_config() |
|
267 | - { |
|
268 | - return array( |
|
269 | - $this->get_help_tab_name() => array( |
|
270 | - 'title' => __('Authorize.net AIM Settings', 'event_espresso'), |
|
271 | - 'filename' => 'payment_methods_overview_aim' |
|
272 | - ), |
|
273 | - ); |
|
274 | - } |
|
261 | + /** |
|
262 | + * Adds the help tab |
|
263 | + * @see EE_PMT_Base::help_tabs_config() |
|
264 | + * @return array |
|
265 | + */ |
|
266 | + public function help_tabs_config() |
|
267 | + { |
|
268 | + return array( |
|
269 | + $this->get_help_tab_name() => array( |
|
270 | + 'title' => __('Authorize.net AIM Settings', 'event_espresso'), |
|
271 | + 'filename' => 'payment_methods_overview_aim' |
|
272 | + ), |
|
273 | + ); |
|
274 | + } |
|
275 | 275 | |
276 | 276 | |
277 | 277 | |
278 | - /** |
|
279 | - * Gets a list of instructions and/or information regarding how the payment is to be completed |
|
280 | - * @return string |
|
281 | - */ |
|
282 | - public function payment_information() |
|
283 | - { |
|
284 | - // TODO: Implement payment_information() method. |
|
285 | - } |
|
278 | + /** |
|
279 | + * Gets a list of instructions and/or information regarding how the payment is to be completed |
|
280 | + * @return string |
|
281 | + */ |
|
282 | + public function payment_information() |
|
283 | + { |
|
284 | + // TODO: Implement payment_information() method. |
|
285 | + } |
|
286 | 286 | } |
@@ -18,332 +18,332 @@ |
||
18 | 18 | class EED_Recaptcha_Invisible extends EED_Module |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var EE_Registration_Config $config |
|
23 | - */ |
|
24 | - private static $config; |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * @return EED_Module|EED_Recaptcha |
|
29 | - */ |
|
30 | - public static function instance() |
|
31 | - { |
|
32 | - return parent::get_instance(__CLASS__); |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * @return void |
|
38 | - * @throws InvalidInterfaceException |
|
39 | - * @throws InvalidDataTypeException |
|
40 | - * @throws InvalidArgumentException |
|
41 | - */ |
|
42 | - public static function set_hooks() |
|
43 | - { |
|
44 | - EED_Recaptcha_Invisible::setProperties(); |
|
45 | - if (EED_Recaptcha_Invisible::useInvisibleRecaptcha()) { |
|
46 | - if (EED_Recaptcha_Invisible::protectForm('ticket_selector')) { |
|
47 | - // ticket selection |
|
48 | - add_filter( |
|
49 | - 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
|
50 | - array('EED_Recaptcha_Invisible', 'ticketSelectorForm'), |
|
51 | - 10, |
|
52 | - 3 |
|
53 | - ); |
|
54 | - add_action( |
|
55 | - 'EED_Ticket_Selector__process_ticket_selections__before', |
|
56 | - array('EED_Recaptcha_Invisible', 'processTicketSelectorForm') |
|
57 | - ); |
|
58 | - } |
|
59 | - if (EED_Recaptcha_Invisible::protectForm('registration_form')) { |
|
60 | - // checkout |
|
61 | - add_action( |
|
62 | - 'AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form', |
|
63 | - array('EED_Recaptcha_Invisible', 'spcoRegStepForm') |
|
64 | - ); |
|
65 | - add_filter( |
|
66 | - 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', |
|
67 | - array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'), |
|
68 | - 10, |
|
69 | - 2 |
|
70 | - ); |
|
71 | - } |
|
72 | - add_action('loop_end', array('EED_Recaptcha_Invisible', 'localizeScriptVars')); |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * @return void |
|
79 | - * @throws InvalidInterfaceException |
|
80 | - * @throws InvalidDataTypeException |
|
81 | - * @throws InvalidArgumentException |
|
82 | - */ |
|
83 | - public static function set_hooks_admin() |
|
84 | - { |
|
85 | - EED_Recaptcha_Invisible::setProperties(); |
|
86 | - if (EED_Recaptcha_Invisible::protectForm('ticket_selector')) { |
|
87 | - add_action( |
|
88 | - 'EED_Ticket_Selector__process_ticket_selections__before', |
|
89 | - array('EED_Recaptcha_Invisible', 'processTicketSelectorForm') |
|
90 | - ); |
|
91 | - } |
|
92 | - if (EED_Recaptcha_Invisible::protectForm('registration_form')) { |
|
93 | - add_filter( |
|
94 | - 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', |
|
95 | - array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'), |
|
96 | - 10, |
|
97 | - 2 |
|
98 | - ); |
|
99 | - } |
|
100 | - // admin settings |
|
101 | - add_action( |
|
102 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
103 | - array('EED_Recaptcha_Invisible', 'adminSettings') |
|
104 | - ); |
|
105 | - add_filter( |
|
106 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
107 | - array('EED_Recaptcha_Invisible', 'updateAdminSettings') |
|
108 | - ); |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * @return void |
|
114 | - * @throws InvalidInterfaceException |
|
115 | - * @throws InvalidDataTypeException |
|
116 | - * @throws InvalidArgumentException |
|
117 | - */ |
|
118 | - public static function setProperties() |
|
119 | - { |
|
120 | - |
|
121 | - EED_Recaptcha_Invisible::$config = EE_Registry::instance()->CFG->registration; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * @return boolean |
|
127 | - */ |
|
128 | - public static function useInvisibleRecaptcha() |
|
129 | - { |
|
130 | - return EED_Recaptcha_Invisible::$config->use_captcha |
|
131 | - && EED_Recaptcha_Invisible::$config->recaptcha_theme === 'invisible'; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @param string $form |
|
137 | - * @return boolean |
|
138 | - */ |
|
139 | - public static function protectForm($form) |
|
140 | - { |
|
141 | - return is_array(EED_Recaptcha_Invisible::$config->recaptcha_protected_forms) |
|
142 | - && in_array($form, EED_Recaptcha_Invisible::$config->recaptcha_protected_forms, true); |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @return void |
|
148 | - * @throws InvalidInterfaceException |
|
149 | - * @throws InvalidDataTypeException |
|
150 | - * @throws InvalidArgumentException |
|
151 | - */ |
|
152 | - public static function localizeScriptVars() |
|
153 | - { |
|
154 | - /** @var \EventEspresso\core\services\request\Request $request */ |
|
155 | - $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request'); |
|
156 | - // Invisible Recaptcha is ONLY ever required for the frontend and admin |
|
157 | - // so we don't need to load any JS assets for other types of requests (like AJAX or API). |
|
158 | - if (! ($request->isAdmin() || $request->isFrontend())) { |
|
159 | - return; |
|
160 | - } |
|
161 | - wp_localize_script( |
|
162 | - EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA, |
|
163 | - 'eeRecaptcha', |
|
164 | - RecaptchaFactory::create()->getLocalizedVars() |
|
165 | - ); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * @return string |
|
171 | - */ |
|
172 | - public static function assetsUrl() |
|
173 | - { |
|
174 | - return plugin_dir_url(__FILE__) . 'assets/'; |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * @param \WP $WP |
|
180 | - */ |
|
181 | - public function run($WP) |
|
182 | - { |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * @param RequestInterface $request |
|
188 | - * @return bool |
|
189 | - * @throws InvalidArgumentException |
|
190 | - * @throws InvalidDataTypeException |
|
191 | - * @throws InvalidInterfaceException |
|
192 | - * @throws RuntimeException |
|
193 | - */ |
|
194 | - public static function verifyToken(RequestInterface $request) |
|
195 | - { |
|
196 | - return RecaptchaFactory::create()->verifyToken($request); |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * @param EE_Form_Section_Proper $reg_form |
|
202 | - * @return void |
|
203 | - * @throws EE_Error |
|
204 | - * @throws InvalidArgumentException |
|
205 | - * @throws InvalidDataTypeException |
|
206 | - * @throws InvalidInterfaceException |
|
207 | - * @throws DomainException |
|
208 | - */ |
|
209 | - public static function spcoRegStepForm(EE_Form_Section_Proper $reg_form) |
|
210 | - { |
|
211 | - // do nothing if form isn't for a reg step or test has already been passed |
|
212 | - if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) { |
|
213 | - return; |
|
214 | - } |
|
215 | - $default_hidden_inputs = $reg_form->get_subsection('default_hidden_inputs'); |
|
216 | - if ($default_hidden_inputs instanceof EE_Form_Section_Proper) { |
|
217 | - $invisible_recaptcha = RecaptchaFactory::create(); |
|
218 | - $invisible_recaptcha->addToFormSection($default_hidden_inputs); |
|
219 | - } |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * @param EE_Form_Section_Proper $reg_form |
|
225 | - * @return bool |
|
226 | - * @throws InvalidDataTypeException |
|
227 | - * @throws InvalidInterfaceException |
|
228 | - * @throws EE_Error |
|
229 | - * @throws InvalidArgumentException |
|
230 | - */ |
|
231 | - public static function processSpcoRegStepForm(EE_Form_Section_Proper $reg_form) |
|
232 | - { |
|
233 | - return strpos($reg_form->name(), 'reg-step-form') !== false |
|
234 | - && ! RecaptchaFactory::create()->recaptchaPassed(); |
|
235 | - } |
|
236 | - |
|
237 | - |
|
238 | - /** |
|
239 | - * @param array|null $req_data |
|
240 | - * @param EE_Form_Section_Proper $reg_form |
|
241 | - * @return array |
|
242 | - * @throws EE_Error |
|
243 | - * @throws InvalidArgumentException |
|
244 | - * @throws InvalidDataTypeException |
|
245 | - * @throws InvalidInterfaceException |
|
246 | - * @throws RuntimeException |
|
247 | - */ |
|
248 | - public static function receiveSpcoRegStepForm($req_data = array(), EE_Form_Section_Proper $reg_form) |
|
249 | - { |
|
250 | - // do nothing if form isn't for a reg step or test has already been passed |
|
251 | - if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) { |
|
252 | - return $req_data; |
|
253 | - } |
|
254 | - /** @var RequestInterface $request */ |
|
255 | - $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
256 | - if (! EED_Recaptcha_Invisible::verifyToken($request)) { |
|
257 | - if ($request->isAjax()) { |
|
258 | - $json_response = new EE_SPCO_JSON_Response(); |
|
259 | - $json_response->echoAndExit(); |
|
260 | - } |
|
261 | - EEH_URL::safeRedirectAndExit( |
|
262 | - EE_Registry::instance()->CFG->core->reg_page_url() |
|
263 | - ); |
|
264 | - } |
|
265 | - return $req_data; |
|
266 | - } |
|
267 | - |
|
268 | - |
|
269 | - /** |
|
270 | - * @param string $html |
|
271 | - * @param EE_Event $event |
|
272 | - * @param bool $iframe |
|
273 | - * @return string |
|
274 | - * @throws EE_Error |
|
275 | - * @throws InvalidArgumentException |
|
276 | - * @throws InvalidDataTypeException |
|
277 | - * @throws InvalidInterfaceException |
|
278 | - * @throws ReflectionException |
|
279 | - * @throws DomainException |
|
280 | - */ |
|
281 | - public static function ticketSelectorForm($html = '', EE_Event $event, $iframe = false) |
|
282 | - { |
|
283 | - $recaptcha = RecaptchaFactory::create(); |
|
284 | - // do nothing if test has already been passed |
|
285 | - if ($recaptcha->recaptchaPassed()) { |
|
286 | - return $html; |
|
287 | - } |
|
288 | - $html .= $recaptcha->getInputHtml( |
|
289 | - array( |
|
290 | - 'recaptcha_id' => $event->ID(), |
|
291 | - 'iframe' => $iframe, |
|
292 | - 'localized_vars' => $recaptcha->getLocalizedVars(), |
|
293 | - ) |
|
294 | - ); |
|
295 | - return $html; |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * @return void |
|
301 | - * @throws InvalidArgumentException |
|
302 | - * @throws InvalidInterfaceException |
|
303 | - * @throws InvalidDataTypeException |
|
304 | - * @throws RuntimeException |
|
305 | - */ |
|
306 | - public static function processTicketSelectorForm() |
|
307 | - { |
|
308 | - // do nothing if test has already been passed |
|
309 | - if (RecaptchaFactory::create()->recaptchaPassed()) { |
|
310 | - return; |
|
311 | - } |
|
312 | - /** @var RequestInterface $request */ |
|
313 | - $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
314 | - if (! EED_Recaptcha_Invisible::verifyToken($request)) { |
|
315 | - $event_id = $request->getRequestParam('tkt-slctr-event-id'); |
|
316 | - $return_url = $request->requestParamIsSet("tkt-slctr-return-url-{$event_id}") |
|
317 | - ? $request->getRequestParam("tkt-slctr-return-url-{$event_id}") |
|
318 | - : get_permalink($event_id); |
|
319 | - EEH_URL::safeRedirectAndExit($return_url); |
|
320 | - } |
|
321 | - } |
|
322 | - |
|
323 | - |
|
324 | - /** |
|
325 | - * @throws EE_Error |
|
326 | - * @throws InvalidArgumentException |
|
327 | - * @throws InvalidDataTypeException |
|
328 | - * @throws InvalidInterfaceException |
|
329 | - */ |
|
330 | - public static function adminSettings() |
|
331 | - { |
|
332 | - RecaptchaFactory::getAdminModule()->adminSettings(); |
|
333 | - } |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * @param EE_Registration_Config $EE_Registration_Config |
|
338 | - * @return EE_Registration_Config |
|
339 | - * @throws EE_Error |
|
340 | - * @throws InvalidArgumentException |
|
341 | - * @throws InvalidDataTypeException |
|
342 | - * @throws InvalidInterfaceException |
|
343 | - * @throws ReflectionException |
|
344 | - */ |
|
345 | - public static function updateAdminSettings(EE_Registration_Config $EE_Registration_Config) |
|
346 | - { |
|
347 | - return RecaptchaFactory::getAdminModule()->updateAdminSettings($EE_Registration_Config); |
|
348 | - } |
|
21 | + /** |
|
22 | + * @var EE_Registration_Config $config |
|
23 | + */ |
|
24 | + private static $config; |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * @return EED_Module|EED_Recaptcha |
|
29 | + */ |
|
30 | + public static function instance() |
|
31 | + { |
|
32 | + return parent::get_instance(__CLASS__); |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * @return void |
|
38 | + * @throws InvalidInterfaceException |
|
39 | + * @throws InvalidDataTypeException |
|
40 | + * @throws InvalidArgumentException |
|
41 | + */ |
|
42 | + public static function set_hooks() |
|
43 | + { |
|
44 | + EED_Recaptcha_Invisible::setProperties(); |
|
45 | + if (EED_Recaptcha_Invisible::useInvisibleRecaptcha()) { |
|
46 | + if (EED_Recaptcha_Invisible::protectForm('ticket_selector')) { |
|
47 | + // ticket selection |
|
48 | + add_filter( |
|
49 | + 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
|
50 | + array('EED_Recaptcha_Invisible', 'ticketSelectorForm'), |
|
51 | + 10, |
|
52 | + 3 |
|
53 | + ); |
|
54 | + add_action( |
|
55 | + 'EED_Ticket_Selector__process_ticket_selections__before', |
|
56 | + array('EED_Recaptcha_Invisible', 'processTicketSelectorForm') |
|
57 | + ); |
|
58 | + } |
|
59 | + if (EED_Recaptcha_Invisible::protectForm('registration_form')) { |
|
60 | + // checkout |
|
61 | + add_action( |
|
62 | + 'AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form', |
|
63 | + array('EED_Recaptcha_Invisible', 'spcoRegStepForm') |
|
64 | + ); |
|
65 | + add_filter( |
|
66 | + 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', |
|
67 | + array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'), |
|
68 | + 10, |
|
69 | + 2 |
|
70 | + ); |
|
71 | + } |
|
72 | + add_action('loop_end', array('EED_Recaptcha_Invisible', 'localizeScriptVars')); |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * @return void |
|
79 | + * @throws InvalidInterfaceException |
|
80 | + * @throws InvalidDataTypeException |
|
81 | + * @throws InvalidArgumentException |
|
82 | + */ |
|
83 | + public static function set_hooks_admin() |
|
84 | + { |
|
85 | + EED_Recaptcha_Invisible::setProperties(); |
|
86 | + if (EED_Recaptcha_Invisible::protectForm('ticket_selector')) { |
|
87 | + add_action( |
|
88 | + 'EED_Ticket_Selector__process_ticket_selections__before', |
|
89 | + array('EED_Recaptcha_Invisible', 'processTicketSelectorForm') |
|
90 | + ); |
|
91 | + } |
|
92 | + if (EED_Recaptcha_Invisible::protectForm('registration_form')) { |
|
93 | + add_filter( |
|
94 | + 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', |
|
95 | + array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'), |
|
96 | + 10, |
|
97 | + 2 |
|
98 | + ); |
|
99 | + } |
|
100 | + // admin settings |
|
101 | + add_action( |
|
102 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
103 | + array('EED_Recaptcha_Invisible', 'adminSettings') |
|
104 | + ); |
|
105 | + add_filter( |
|
106 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
107 | + array('EED_Recaptcha_Invisible', 'updateAdminSettings') |
|
108 | + ); |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * @return void |
|
114 | + * @throws InvalidInterfaceException |
|
115 | + * @throws InvalidDataTypeException |
|
116 | + * @throws InvalidArgumentException |
|
117 | + */ |
|
118 | + public static function setProperties() |
|
119 | + { |
|
120 | + |
|
121 | + EED_Recaptcha_Invisible::$config = EE_Registry::instance()->CFG->registration; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * @return boolean |
|
127 | + */ |
|
128 | + public static function useInvisibleRecaptcha() |
|
129 | + { |
|
130 | + return EED_Recaptcha_Invisible::$config->use_captcha |
|
131 | + && EED_Recaptcha_Invisible::$config->recaptcha_theme === 'invisible'; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @param string $form |
|
137 | + * @return boolean |
|
138 | + */ |
|
139 | + public static function protectForm($form) |
|
140 | + { |
|
141 | + return is_array(EED_Recaptcha_Invisible::$config->recaptcha_protected_forms) |
|
142 | + && in_array($form, EED_Recaptcha_Invisible::$config->recaptcha_protected_forms, true); |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @return void |
|
148 | + * @throws InvalidInterfaceException |
|
149 | + * @throws InvalidDataTypeException |
|
150 | + * @throws InvalidArgumentException |
|
151 | + */ |
|
152 | + public static function localizeScriptVars() |
|
153 | + { |
|
154 | + /** @var \EventEspresso\core\services\request\Request $request */ |
|
155 | + $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request'); |
|
156 | + // Invisible Recaptcha is ONLY ever required for the frontend and admin |
|
157 | + // so we don't need to load any JS assets for other types of requests (like AJAX or API). |
|
158 | + if (! ($request->isAdmin() || $request->isFrontend())) { |
|
159 | + return; |
|
160 | + } |
|
161 | + wp_localize_script( |
|
162 | + EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA, |
|
163 | + 'eeRecaptcha', |
|
164 | + RecaptchaFactory::create()->getLocalizedVars() |
|
165 | + ); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * @return string |
|
171 | + */ |
|
172 | + public static function assetsUrl() |
|
173 | + { |
|
174 | + return plugin_dir_url(__FILE__) . 'assets/'; |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * @param \WP $WP |
|
180 | + */ |
|
181 | + public function run($WP) |
|
182 | + { |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * @param RequestInterface $request |
|
188 | + * @return bool |
|
189 | + * @throws InvalidArgumentException |
|
190 | + * @throws InvalidDataTypeException |
|
191 | + * @throws InvalidInterfaceException |
|
192 | + * @throws RuntimeException |
|
193 | + */ |
|
194 | + public static function verifyToken(RequestInterface $request) |
|
195 | + { |
|
196 | + return RecaptchaFactory::create()->verifyToken($request); |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * @param EE_Form_Section_Proper $reg_form |
|
202 | + * @return void |
|
203 | + * @throws EE_Error |
|
204 | + * @throws InvalidArgumentException |
|
205 | + * @throws InvalidDataTypeException |
|
206 | + * @throws InvalidInterfaceException |
|
207 | + * @throws DomainException |
|
208 | + */ |
|
209 | + public static function spcoRegStepForm(EE_Form_Section_Proper $reg_form) |
|
210 | + { |
|
211 | + // do nothing if form isn't for a reg step or test has already been passed |
|
212 | + if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) { |
|
213 | + return; |
|
214 | + } |
|
215 | + $default_hidden_inputs = $reg_form->get_subsection('default_hidden_inputs'); |
|
216 | + if ($default_hidden_inputs instanceof EE_Form_Section_Proper) { |
|
217 | + $invisible_recaptcha = RecaptchaFactory::create(); |
|
218 | + $invisible_recaptcha->addToFormSection($default_hidden_inputs); |
|
219 | + } |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * @param EE_Form_Section_Proper $reg_form |
|
225 | + * @return bool |
|
226 | + * @throws InvalidDataTypeException |
|
227 | + * @throws InvalidInterfaceException |
|
228 | + * @throws EE_Error |
|
229 | + * @throws InvalidArgumentException |
|
230 | + */ |
|
231 | + public static function processSpcoRegStepForm(EE_Form_Section_Proper $reg_form) |
|
232 | + { |
|
233 | + return strpos($reg_form->name(), 'reg-step-form') !== false |
|
234 | + && ! RecaptchaFactory::create()->recaptchaPassed(); |
|
235 | + } |
|
236 | + |
|
237 | + |
|
238 | + /** |
|
239 | + * @param array|null $req_data |
|
240 | + * @param EE_Form_Section_Proper $reg_form |
|
241 | + * @return array |
|
242 | + * @throws EE_Error |
|
243 | + * @throws InvalidArgumentException |
|
244 | + * @throws InvalidDataTypeException |
|
245 | + * @throws InvalidInterfaceException |
|
246 | + * @throws RuntimeException |
|
247 | + */ |
|
248 | + public static function receiveSpcoRegStepForm($req_data = array(), EE_Form_Section_Proper $reg_form) |
|
249 | + { |
|
250 | + // do nothing if form isn't for a reg step or test has already been passed |
|
251 | + if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) { |
|
252 | + return $req_data; |
|
253 | + } |
|
254 | + /** @var RequestInterface $request */ |
|
255 | + $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
256 | + if (! EED_Recaptcha_Invisible::verifyToken($request)) { |
|
257 | + if ($request->isAjax()) { |
|
258 | + $json_response = new EE_SPCO_JSON_Response(); |
|
259 | + $json_response->echoAndExit(); |
|
260 | + } |
|
261 | + EEH_URL::safeRedirectAndExit( |
|
262 | + EE_Registry::instance()->CFG->core->reg_page_url() |
|
263 | + ); |
|
264 | + } |
|
265 | + return $req_data; |
|
266 | + } |
|
267 | + |
|
268 | + |
|
269 | + /** |
|
270 | + * @param string $html |
|
271 | + * @param EE_Event $event |
|
272 | + * @param bool $iframe |
|
273 | + * @return string |
|
274 | + * @throws EE_Error |
|
275 | + * @throws InvalidArgumentException |
|
276 | + * @throws InvalidDataTypeException |
|
277 | + * @throws InvalidInterfaceException |
|
278 | + * @throws ReflectionException |
|
279 | + * @throws DomainException |
|
280 | + */ |
|
281 | + public static function ticketSelectorForm($html = '', EE_Event $event, $iframe = false) |
|
282 | + { |
|
283 | + $recaptcha = RecaptchaFactory::create(); |
|
284 | + // do nothing if test has already been passed |
|
285 | + if ($recaptcha->recaptchaPassed()) { |
|
286 | + return $html; |
|
287 | + } |
|
288 | + $html .= $recaptcha->getInputHtml( |
|
289 | + array( |
|
290 | + 'recaptcha_id' => $event->ID(), |
|
291 | + 'iframe' => $iframe, |
|
292 | + 'localized_vars' => $recaptcha->getLocalizedVars(), |
|
293 | + ) |
|
294 | + ); |
|
295 | + return $html; |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * @return void |
|
301 | + * @throws InvalidArgumentException |
|
302 | + * @throws InvalidInterfaceException |
|
303 | + * @throws InvalidDataTypeException |
|
304 | + * @throws RuntimeException |
|
305 | + */ |
|
306 | + public static function processTicketSelectorForm() |
|
307 | + { |
|
308 | + // do nothing if test has already been passed |
|
309 | + if (RecaptchaFactory::create()->recaptchaPassed()) { |
|
310 | + return; |
|
311 | + } |
|
312 | + /** @var RequestInterface $request */ |
|
313 | + $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
314 | + if (! EED_Recaptcha_Invisible::verifyToken($request)) { |
|
315 | + $event_id = $request->getRequestParam('tkt-slctr-event-id'); |
|
316 | + $return_url = $request->requestParamIsSet("tkt-slctr-return-url-{$event_id}") |
|
317 | + ? $request->getRequestParam("tkt-slctr-return-url-{$event_id}") |
|
318 | + : get_permalink($event_id); |
|
319 | + EEH_URL::safeRedirectAndExit($return_url); |
|
320 | + } |
|
321 | + } |
|
322 | + |
|
323 | + |
|
324 | + /** |
|
325 | + * @throws EE_Error |
|
326 | + * @throws InvalidArgumentException |
|
327 | + * @throws InvalidDataTypeException |
|
328 | + * @throws InvalidInterfaceException |
|
329 | + */ |
|
330 | + public static function adminSettings() |
|
331 | + { |
|
332 | + RecaptchaFactory::getAdminModule()->adminSettings(); |
|
333 | + } |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * @param EE_Registration_Config $EE_Registration_Config |
|
338 | + * @return EE_Registration_Config |
|
339 | + * @throws EE_Error |
|
340 | + * @throws InvalidArgumentException |
|
341 | + * @throws InvalidDataTypeException |
|
342 | + * @throws InvalidInterfaceException |
|
343 | + * @throws ReflectionException |
|
344 | + */ |
|
345 | + public static function updateAdminSettings(EE_Registration_Config $EE_Registration_Config) |
|
346 | + { |
|
347 | + return RecaptchaFactory::getAdminModule()->updateAdminSettings($EE_Registration_Config); |
|
348 | + } |
|
349 | 349 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request'); |
156 | 156 | // Invisible Recaptcha is ONLY ever required for the frontend and admin |
157 | 157 | // so we don't need to load any JS assets for other types of requests (like AJAX or API). |
158 | - if (! ($request->isAdmin() || $request->isFrontend())) { |
|
158 | + if ( ! ($request->isAdmin() || $request->isFrontend())) { |
|
159 | 159 | return; |
160 | 160 | } |
161 | 161 | wp_localize_script( |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public static function assetsUrl() |
173 | 173 | { |
174 | - return plugin_dir_url(__FILE__) . 'assets/'; |
|
174 | + return plugin_dir_url(__FILE__).'assets/'; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | public static function spcoRegStepForm(EE_Form_Section_Proper $reg_form) |
210 | 210 | { |
211 | 211 | // do nothing if form isn't for a reg step or test has already been passed |
212 | - if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) { |
|
212 | + if ( ! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | $default_hidden_inputs = $reg_form->get_subsection('default_hidden_inputs'); |
@@ -248,12 +248,12 @@ discard block |
||
248 | 248 | public static function receiveSpcoRegStepForm($req_data = array(), EE_Form_Section_Proper $reg_form) |
249 | 249 | { |
250 | 250 | // do nothing if form isn't for a reg step or test has already been passed |
251 | - if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) { |
|
251 | + if ( ! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) { |
|
252 | 252 | return $req_data; |
253 | 253 | } |
254 | 254 | /** @var RequestInterface $request */ |
255 | 255 | $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
256 | - if (! EED_Recaptcha_Invisible::verifyToken($request)) { |
|
256 | + if ( ! EED_Recaptcha_Invisible::verifyToken($request)) { |
|
257 | 257 | if ($request->isAjax()) { |
258 | 258 | $json_response = new EE_SPCO_JSON_Response(); |
259 | 259 | $json_response->echoAndExit(); |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | } |
312 | 312 | /** @var RequestInterface $request */ |
313 | 313 | $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
314 | - if (! EED_Recaptcha_Invisible::verifyToken($request)) { |
|
314 | + if ( ! EED_Recaptcha_Invisible::verifyToken($request)) { |
|
315 | 315 | $event_id = $request->getRequestParam('tkt-slctr-event-id'); |
316 | 316 | $return_url = $request->requestParamIsSet("tkt-slctr-return-url-{$event_id}") |
317 | 317 | ? $request->getRequestParam("tkt-slctr-return-url-{$event_id}") |
@@ -18,380 +18,380 @@ |
||
18 | 18 | class EED_Recaptcha extends EED_Module |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var EE_Registration_Config $config |
|
23 | - */ |
|
24 | - private static $config; |
|
25 | - |
|
26 | - /** |
|
27 | - * @type bool $_not_a_robot |
|
28 | - */ |
|
29 | - private static $_not_a_robot; |
|
30 | - |
|
31 | - /** |
|
32 | - * @type string $_recaptcha_response |
|
33 | - */ |
|
34 | - private static $_recaptcha_response; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @return EED_Module|EED_Recaptcha |
|
39 | - */ |
|
40 | - public static function instance() |
|
41 | - { |
|
42 | - return parent::get_instance(__CLASS__); |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
48 | - * |
|
49 | - * @return void |
|
50 | - * @throws InvalidArgumentException |
|
51 | - * @throws InvalidInterfaceException |
|
52 | - * @throws InvalidDataTypeException |
|
53 | - */ |
|
54 | - public static function set_hooks() |
|
55 | - { |
|
56 | - EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration; |
|
57 | - // use_captcha ? |
|
58 | - if (EED_Recaptcha::useRecaptcha() |
|
59 | - && EED_Recaptcha::notPaymentOptionsRevisit() |
|
60 | - ) { |
|
61 | - EED_Recaptcha::set_definitions(); |
|
62 | - EED_Recaptcha::enqueue_styles_and_scripts(); |
|
63 | - add_action('wp', array('EED_Recaptcha', 'set_late_hooks'), 1, 0); |
|
64 | - add_action( |
|
65 | - 'AHEE__before_spco_whats_next_buttons', |
|
66 | - array('EED_Recaptcha', 'display_recaptcha'), |
|
67 | - 10, |
|
68 | - 0 |
|
69 | - ); |
|
70 | - add_filter( |
|
71 | - 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
72 | - array('EED_Recaptcha', 'not_a_robot') |
|
73 | - ); |
|
74 | - add_filter( |
|
75 | - 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
|
76 | - array('EED_Recaptcha', 'not_a_robot') |
|
77 | - ); |
|
78 | - add_filter( |
|
79 | - 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
|
80 | - array('EED_Recaptcha', 'recaptcha_response') |
|
81 | - ); |
|
82 | - add_filter( |
|
83 | - 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
|
84 | - array('EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method') |
|
85 | - ); |
|
86 | - } |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
92 | - * |
|
93 | - * @return void |
|
94 | - * @throws InvalidArgumentException |
|
95 | - * @throws InvalidInterfaceException |
|
96 | - * @throws InvalidDataTypeException |
|
97 | - */ |
|
98 | - public static function set_hooks_admin() |
|
99 | - { |
|
100 | - EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration; |
|
101 | - EED_Recaptcha::set_definitions(); |
|
102 | - // use_captcha ? |
|
103 | - if (EED_Recaptcha::useRecaptcha() |
|
104 | - && EED_Recaptcha::notPaymentOptionsRevisit() |
|
105 | - && EE_Registry::instance()->REQ->get('step', '') !== '' |
|
106 | - ) { |
|
107 | - EED_Recaptcha::enqueue_styles_and_scripts(); |
|
108 | - add_filter( |
|
109 | - 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
110 | - array('EED_Recaptcha', 'not_a_robot') |
|
111 | - ); |
|
112 | - add_filter( |
|
113 | - 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
|
114 | - array('EED_Recaptcha', 'not_a_robot') |
|
115 | - ); |
|
116 | - add_filter( |
|
117 | - 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
|
118 | - array('EED_Recaptcha', 'recaptcha_response') |
|
119 | - ); |
|
120 | - } |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @return void |
|
126 | - */ |
|
127 | - public static function set_definitions() |
|
128 | - { |
|
129 | - if (is_user_logged_in()) { |
|
130 | - EED_Recaptcha::$_not_a_robot = true; |
|
131 | - } |
|
132 | - define( |
|
133 | - 'RECAPTCHA_BASE_PATH', |
|
134 | - rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/' |
|
135 | - ); |
|
136 | - define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__)); |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @return void |
|
142 | - */ |
|
143 | - public static function set_late_hooks() |
|
144 | - { |
|
145 | - add_filter( |
|
146 | - 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
147 | - array('EED_Recaptcha', 'not_a_robot') |
|
148 | - ); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * @return boolean |
|
154 | - */ |
|
155 | - public static function useRecaptcha() |
|
156 | - { |
|
157 | - return EED_Recaptcha::$config->use_captcha |
|
158 | - && EED_Recaptcha::$config->recaptcha_theme !== 'invisible'; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * @return boolean |
|
164 | - * @throws InvalidArgumentException |
|
165 | - * @throws InvalidInterfaceException |
|
166 | - * @throws InvalidDataTypeException |
|
167 | - */ |
|
168 | - public static function notPaymentOptionsRevisit() |
|
169 | - { |
|
170 | - return ! ( |
|
171 | - EE_Registry::instance()->REQ->get('step', '') === 'payment_options' |
|
172 | - && (boolean) EE_Registry::instance()->REQ->get('revisit', false) === true |
|
173 | - ); |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * @return void |
|
179 | - * @throws InvalidArgumentException |
|
180 | - * @throws InvalidInterfaceException |
|
181 | - * @throws InvalidDataTypeException |
|
182 | - */ |
|
183 | - public static function enqueue_styles_and_scripts() |
|
184 | - { |
|
185 | - wp_register_script( |
|
186 | - 'espresso_recaptcha', |
|
187 | - RECAPTCHA_BASE_URL . 'scripts/espresso_recaptcha.js', |
|
188 | - array('single_page_checkout'), |
|
189 | - EVENT_ESPRESSO_VERSION, |
|
190 | - true |
|
191 | - ); |
|
192 | - wp_register_script( |
|
193 | - 'google_recaptcha', |
|
194 | - 'https://www.google.com/recaptcha/api.js?hl=' . EED_Recaptcha::$config->recaptcha_language, |
|
195 | - array('espresso_recaptcha'), |
|
196 | - EVENT_ESPRESSO_VERSION, |
|
197 | - true |
|
198 | - ); |
|
199 | - EE_Registry::$i18n_js_strings['no_SPCO_error'] = __( |
|
200 | - 'It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', |
|
201 | - 'event_espresso' |
|
202 | - ); |
|
203 | - EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __( |
|
204 | - 'There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', |
|
205 | - 'event_espresso' |
|
206 | - ); |
|
207 | - EE_Registry::$i18n_js_strings['recaptcha_fail'] = __( |
|
208 | - 'Please complete the anti-spam test before proceeding.', |
|
209 | - 'event_espresso' |
|
210 | - ); |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * @param \WP $WP |
|
216 | - */ |
|
217 | - public function run($WP) |
|
218 | - { |
|
219 | - } |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * @return boolean |
|
224 | - * @throws InvalidArgumentException |
|
225 | - * @throws InvalidInterfaceException |
|
226 | - * @throws InvalidDataTypeException |
|
227 | - */ |
|
228 | - public static function not_a_robot() |
|
229 | - { |
|
230 | - $not_a_robot = is_bool(EED_Recaptcha::$_not_a_robot) |
|
231 | - ? EED_Recaptcha::$_not_a_robot |
|
232 | - : EED_Recaptcha::recaptcha_passed(); |
|
233 | - return $not_a_robot; |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - /** |
|
238 | - * @return void |
|
239 | - * @throws DomainException |
|
240 | - * @throws InvalidArgumentException |
|
241 | - * @throws InvalidInterfaceException |
|
242 | - * @throws InvalidDataTypeException |
|
243 | - */ |
|
244 | - public static function display_recaptcha() |
|
245 | - { |
|
246 | - // logged in means you have already passed a turing test of sorts |
|
247 | - if (is_user_logged_in()) { |
|
248 | - return; |
|
249 | - } |
|
250 | - // don't display if not using recaptcha or user is logged in |
|
251 | - if (EED_Recaptcha::useRecaptcha() && ! EED_Recaptcha::$_not_a_robot) { |
|
252 | - // only display if they have NOT passed the test yet |
|
253 | - EEH_Template::display_template( |
|
254 | - RECAPTCHA_BASE_PATH . '/templates/recaptcha.template.php', |
|
255 | - array( |
|
256 | - 'recaptcha_publickey' => EED_Recaptcha::$config->recaptcha_publickey, |
|
257 | - 'recaptcha_theme' => EED_Recaptcha::$config->recaptcha_theme, |
|
258 | - 'recaptcha_type' => EED_Recaptcha::$config->recaptcha_type, |
|
259 | - ) |
|
260 | - ); |
|
261 | - wp_enqueue_script('google_recaptcha'); |
|
262 | - } |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * @return array |
|
268 | - * @throws InvalidArgumentException |
|
269 | - * @throws InvalidInterfaceException |
|
270 | - * @throws InvalidDataTypeException |
|
271 | - */ |
|
272 | - public static function bypass_recaptcha_for_spco_load_payment_method() |
|
273 | - { |
|
274 | - return array( |
|
275 | - 'EESID' => EE_Registry::instance()->SSN->id(), |
|
276 | - 'step' => 'payment_options', |
|
277 | - 'action' => 'switch_spco_billing_form', |
|
278 | - ); |
|
279 | - } |
|
280 | - |
|
281 | - |
|
282 | - /** |
|
283 | - * @return boolean |
|
284 | - * @throws InvalidArgumentException |
|
285 | - * @throws InvalidInterfaceException |
|
286 | - * @throws InvalidDataTypeException |
|
287 | - */ |
|
288 | - public static function recaptcha_passed() |
|
289 | - { |
|
290 | - // logged in means you have already passed a turing test of sorts |
|
291 | - if (is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha()) { |
|
292 | - return true; |
|
293 | - } |
|
294 | - // was test already passed? |
|
295 | - $recaptcha_passed = EE_Registry::instance()->SSN->get_session_data('recaptcha_passed'); |
|
296 | - $recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN); |
|
297 | - // verify recaptcha |
|
298 | - EED_Recaptcha::_get_recaptcha_response(); |
|
299 | - if (! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
300 | - $recaptcha_passed = EED_Recaptcha::_process_recaptcha_response(); |
|
301 | - EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed)); |
|
302 | - } |
|
303 | - EED_Recaptcha::$_not_a_robot = $recaptcha_passed; |
|
304 | - return $recaptcha_passed; |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * @param array $recaptcha_response |
|
310 | - * @return array |
|
311 | - */ |
|
312 | - public static function recaptcha_response($recaptcha_response = array()) |
|
313 | - { |
|
314 | - if (EED_Recaptcha::_bypass_recaptcha()) { |
|
315 | - $recaptcha_response['bypass_recaptcha'] = true; |
|
316 | - $recaptcha_response['recaptcha_passed'] = true; |
|
317 | - } else { |
|
318 | - $recaptcha_response['recaptcha_passed'] = EED_Recaptcha::$_not_a_robot; |
|
319 | - } |
|
320 | - return $recaptcha_response; |
|
321 | - } |
|
322 | - |
|
323 | - |
|
324 | - /** |
|
325 | - * @return boolean |
|
326 | - */ |
|
327 | - private static function _bypass_recaptcha() |
|
328 | - { |
|
329 | - // an array of key value pairs that must match exactly with the incoming request, |
|
330 | - // in order to bypass recaptcha for the current request ONLY |
|
331 | - $bypass_request_params_array = (array) apply_filters( |
|
332 | - 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
|
333 | - array() |
|
334 | - ); |
|
335 | - // does $bypass_request_params_array have any values ? |
|
336 | - if (empty($bypass_request_params_array)) { |
|
337 | - return false; |
|
338 | - } |
|
339 | - // initially set bypass to TRUE |
|
340 | - $bypass_recaptcha = true; |
|
341 | - foreach ($bypass_request_params_array as $key => $value) { |
|
342 | - // if $key is not found or value doesn't match exactly, then toggle bypass to FALSE, |
|
343 | - // otherwise carry over it's value. This way, one missed setting results in no bypass |
|
344 | - $bypass_recaptcha = isset($_REQUEST[ $key ]) && $_REQUEST[ $key ] === $value |
|
345 | - ? $bypass_recaptcha |
|
346 | - : false; |
|
347 | - } |
|
348 | - return $bypass_recaptcha; |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - /** |
|
353 | - * @return void |
|
354 | - * @throws InvalidArgumentException |
|
355 | - * @throws InvalidInterfaceException |
|
356 | - * @throws InvalidDataTypeException |
|
357 | - */ |
|
358 | - private static function _get_recaptcha_response() |
|
359 | - { |
|
360 | - EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get( |
|
361 | - 'g-recaptcha-response', |
|
362 | - false |
|
363 | - ); |
|
364 | - } |
|
365 | - |
|
366 | - |
|
367 | - /** |
|
368 | - * @return boolean |
|
369 | - * @throws InvalidArgumentException |
|
370 | - * @throws InvalidInterfaceException |
|
371 | - * @throws InvalidDataTypeException |
|
372 | - */ |
|
373 | - private static function _process_recaptcha_response() |
|
374 | - { |
|
375 | - // verify library is loaded |
|
376 | - if (! class_exists('\ReCaptcha\ReCaptcha')) { |
|
377 | - require_once RECAPTCHA_BASE_PATH . '/autoload.php'; |
|
378 | - } |
|
379 | - // The response from reCAPTCHA |
|
380 | - EED_Recaptcha::_get_recaptcha_response(); |
|
381 | - $recaptcha_response = EED_Recaptcha::$_recaptcha_response; |
|
382 | - // Was there a reCAPTCHA response? |
|
383 | - if ($recaptcha_response) { |
|
384 | - // if allow_url_fopen is Off, then set a different request method |
|
385 | - $request_method = ! ini_get('allow_url_fopen') ? new SocketPost() : null; |
|
386 | - $recaptcha = new ReCaptcha( |
|
387 | - EED_Recaptcha::$config->recaptcha_privatekey, |
|
388 | - $request_method |
|
389 | - ); |
|
390 | - $recaptcha_response = $recaptcha->verify( |
|
391 | - EED_Recaptcha::$_recaptcha_response, |
|
392 | - $_SERVER['REMOTE_ADDR'] |
|
393 | - ); |
|
394 | - } |
|
395 | - return $recaptcha_response instanceof Response && $recaptcha_response->isSuccess(); |
|
396 | - } |
|
21 | + /** |
|
22 | + * @var EE_Registration_Config $config |
|
23 | + */ |
|
24 | + private static $config; |
|
25 | + |
|
26 | + /** |
|
27 | + * @type bool $_not_a_robot |
|
28 | + */ |
|
29 | + private static $_not_a_robot; |
|
30 | + |
|
31 | + /** |
|
32 | + * @type string $_recaptcha_response |
|
33 | + */ |
|
34 | + private static $_recaptcha_response; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @return EED_Module|EED_Recaptcha |
|
39 | + */ |
|
40 | + public static function instance() |
|
41 | + { |
|
42 | + return parent::get_instance(__CLASS__); |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
48 | + * |
|
49 | + * @return void |
|
50 | + * @throws InvalidArgumentException |
|
51 | + * @throws InvalidInterfaceException |
|
52 | + * @throws InvalidDataTypeException |
|
53 | + */ |
|
54 | + public static function set_hooks() |
|
55 | + { |
|
56 | + EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration; |
|
57 | + // use_captcha ? |
|
58 | + if (EED_Recaptcha::useRecaptcha() |
|
59 | + && EED_Recaptcha::notPaymentOptionsRevisit() |
|
60 | + ) { |
|
61 | + EED_Recaptcha::set_definitions(); |
|
62 | + EED_Recaptcha::enqueue_styles_and_scripts(); |
|
63 | + add_action('wp', array('EED_Recaptcha', 'set_late_hooks'), 1, 0); |
|
64 | + add_action( |
|
65 | + 'AHEE__before_spco_whats_next_buttons', |
|
66 | + array('EED_Recaptcha', 'display_recaptcha'), |
|
67 | + 10, |
|
68 | + 0 |
|
69 | + ); |
|
70 | + add_filter( |
|
71 | + 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
72 | + array('EED_Recaptcha', 'not_a_robot') |
|
73 | + ); |
|
74 | + add_filter( |
|
75 | + 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
|
76 | + array('EED_Recaptcha', 'not_a_robot') |
|
77 | + ); |
|
78 | + add_filter( |
|
79 | + 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
|
80 | + array('EED_Recaptcha', 'recaptcha_response') |
|
81 | + ); |
|
82 | + add_filter( |
|
83 | + 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
|
84 | + array('EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method') |
|
85 | + ); |
|
86 | + } |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
92 | + * |
|
93 | + * @return void |
|
94 | + * @throws InvalidArgumentException |
|
95 | + * @throws InvalidInterfaceException |
|
96 | + * @throws InvalidDataTypeException |
|
97 | + */ |
|
98 | + public static function set_hooks_admin() |
|
99 | + { |
|
100 | + EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration; |
|
101 | + EED_Recaptcha::set_definitions(); |
|
102 | + // use_captcha ? |
|
103 | + if (EED_Recaptcha::useRecaptcha() |
|
104 | + && EED_Recaptcha::notPaymentOptionsRevisit() |
|
105 | + && EE_Registry::instance()->REQ->get('step', '') !== '' |
|
106 | + ) { |
|
107 | + EED_Recaptcha::enqueue_styles_and_scripts(); |
|
108 | + add_filter( |
|
109 | + 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
110 | + array('EED_Recaptcha', 'not_a_robot') |
|
111 | + ); |
|
112 | + add_filter( |
|
113 | + 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
|
114 | + array('EED_Recaptcha', 'not_a_robot') |
|
115 | + ); |
|
116 | + add_filter( |
|
117 | + 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
|
118 | + array('EED_Recaptcha', 'recaptcha_response') |
|
119 | + ); |
|
120 | + } |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @return void |
|
126 | + */ |
|
127 | + public static function set_definitions() |
|
128 | + { |
|
129 | + if (is_user_logged_in()) { |
|
130 | + EED_Recaptcha::$_not_a_robot = true; |
|
131 | + } |
|
132 | + define( |
|
133 | + 'RECAPTCHA_BASE_PATH', |
|
134 | + rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/' |
|
135 | + ); |
|
136 | + define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__)); |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @return void |
|
142 | + */ |
|
143 | + public static function set_late_hooks() |
|
144 | + { |
|
145 | + add_filter( |
|
146 | + 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
147 | + array('EED_Recaptcha', 'not_a_robot') |
|
148 | + ); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * @return boolean |
|
154 | + */ |
|
155 | + public static function useRecaptcha() |
|
156 | + { |
|
157 | + return EED_Recaptcha::$config->use_captcha |
|
158 | + && EED_Recaptcha::$config->recaptcha_theme !== 'invisible'; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * @return boolean |
|
164 | + * @throws InvalidArgumentException |
|
165 | + * @throws InvalidInterfaceException |
|
166 | + * @throws InvalidDataTypeException |
|
167 | + */ |
|
168 | + public static function notPaymentOptionsRevisit() |
|
169 | + { |
|
170 | + return ! ( |
|
171 | + EE_Registry::instance()->REQ->get('step', '') === 'payment_options' |
|
172 | + && (boolean) EE_Registry::instance()->REQ->get('revisit', false) === true |
|
173 | + ); |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * @return void |
|
179 | + * @throws InvalidArgumentException |
|
180 | + * @throws InvalidInterfaceException |
|
181 | + * @throws InvalidDataTypeException |
|
182 | + */ |
|
183 | + public static function enqueue_styles_and_scripts() |
|
184 | + { |
|
185 | + wp_register_script( |
|
186 | + 'espresso_recaptcha', |
|
187 | + RECAPTCHA_BASE_URL . 'scripts/espresso_recaptcha.js', |
|
188 | + array('single_page_checkout'), |
|
189 | + EVENT_ESPRESSO_VERSION, |
|
190 | + true |
|
191 | + ); |
|
192 | + wp_register_script( |
|
193 | + 'google_recaptcha', |
|
194 | + 'https://www.google.com/recaptcha/api.js?hl=' . EED_Recaptcha::$config->recaptcha_language, |
|
195 | + array('espresso_recaptcha'), |
|
196 | + EVENT_ESPRESSO_VERSION, |
|
197 | + true |
|
198 | + ); |
|
199 | + EE_Registry::$i18n_js_strings['no_SPCO_error'] = __( |
|
200 | + 'It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', |
|
201 | + 'event_espresso' |
|
202 | + ); |
|
203 | + EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __( |
|
204 | + 'There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', |
|
205 | + 'event_espresso' |
|
206 | + ); |
|
207 | + EE_Registry::$i18n_js_strings['recaptcha_fail'] = __( |
|
208 | + 'Please complete the anti-spam test before proceeding.', |
|
209 | + 'event_espresso' |
|
210 | + ); |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * @param \WP $WP |
|
216 | + */ |
|
217 | + public function run($WP) |
|
218 | + { |
|
219 | + } |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * @return boolean |
|
224 | + * @throws InvalidArgumentException |
|
225 | + * @throws InvalidInterfaceException |
|
226 | + * @throws InvalidDataTypeException |
|
227 | + */ |
|
228 | + public static function not_a_robot() |
|
229 | + { |
|
230 | + $not_a_robot = is_bool(EED_Recaptcha::$_not_a_robot) |
|
231 | + ? EED_Recaptcha::$_not_a_robot |
|
232 | + : EED_Recaptcha::recaptcha_passed(); |
|
233 | + return $not_a_robot; |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + /** |
|
238 | + * @return void |
|
239 | + * @throws DomainException |
|
240 | + * @throws InvalidArgumentException |
|
241 | + * @throws InvalidInterfaceException |
|
242 | + * @throws InvalidDataTypeException |
|
243 | + */ |
|
244 | + public static function display_recaptcha() |
|
245 | + { |
|
246 | + // logged in means you have already passed a turing test of sorts |
|
247 | + if (is_user_logged_in()) { |
|
248 | + return; |
|
249 | + } |
|
250 | + // don't display if not using recaptcha or user is logged in |
|
251 | + if (EED_Recaptcha::useRecaptcha() && ! EED_Recaptcha::$_not_a_robot) { |
|
252 | + // only display if they have NOT passed the test yet |
|
253 | + EEH_Template::display_template( |
|
254 | + RECAPTCHA_BASE_PATH . '/templates/recaptcha.template.php', |
|
255 | + array( |
|
256 | + 'recaptcha_publickey' => EED_Recaptcha::$config->recaptcha_publickey, |
|
257 | + 'recaptcha_theme' => EED_Recaptcha::$config->recaptcha_theme, |
|
258 | + 'recaptcha_type' => EED_Recaptcha::$config->recaptcha_type, |
|
259 | + ) |
|
260 | + ); |
|
261 | + wp_enqueue_script('google_recaptcha'); |
|
262 | + } |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * @return array |
|
268 | + * @throws InvalidArgumentException |
|
269 | + * @throws InvalidInterfaceException |
|
270 | + * @throws InvalidDataTypeException |
|
271 | + */ |
|
272 | + public static function bypass_recaptcha_for_spco_load_payment_method() |
|
273 | + { |
|
274 | + return array( |
|
275 | + 'EESID' => EE_Registry::instance()->SSN->id(), |
|
276 | + 'step' => 'payment_options', |
|
277 | + 'action' => 'switch_spco_billing_form', |
|
278 | + ); |
|
279 | + } |
|
280 | + |
|
281 | + |
|
282 | + /** |
|
283 | + * @return boolean |
|
284 | + * @throws InvalidArgumentException |
|
285 | + * @throws InvalidInterfaceException |
|
286 | + * @throws InvalidDataTypeException |
|
287 | + */ |
|
288 | + public static function recaptcha_passed() |
|
289 | + { |
|
290 | + // logged in means you have already passed a turing test of sorts |
|
291 | + if (is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha()) { |
|
292 | + return true; |
|
293 | + } |
|
294 | + // was test already passed? |
|
295 | + $recaptcha_passed = EE_Registry::instance()->SSN->get_session_data('recaptcha_passed'); |
|
296 | + $recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN); |
|
297 | + // verify recaptcha |
|
298 | + EED_Recaptcha::_get_recaptcha_response(); |
|
299 | + if (! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
300 | + $recaptcha_passed = EED_Recaptcha::_process_recaptcha_response(); |
|
301 | + EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed)); |
|
302 | + } |
|
303 | + EED_Recaptcha::$_not_a_robot = $recaptcha_passed; |
|
304 | + return $recaptcha_passed; |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * @param array $recaptcha_response |
|
310 | + * @return array |
|
311 | + */ |
|
312 | + public static function recaptcha_response($recaptcha_response = array()) |
|
313 | + { |
|
314 | + if (EED_Recaptcha::_bypass_recaptcha()) { |
|
315 | + $recaptcha_response['bypass_recaptcha'] = true; |
|
316 | + $recaptcha_response['recaptcha_passed'] = true; |
|
317 | + } else { |
|
318 | + $recaptcha_response['recaptcha_passed'] = EED_Recaptcha::$_not_a_robot; |
|
319 | + } |
|
320 | + return $recaptcha_response; |
|
321 | + } |
|
322 | + |
|
323 | + |
|
324 | + /** |
|
325 | + * @return boolean |
|
326 | + */ |
|
327 | + private static function _bypass_recaptcha() |
|
328 | + { |
|
329 | + // an array of key value pairs that must match exactly with the incoming request, |
|
330 | + // in order to bypass recaptcha for the current request ONLY |
|
331 | + $bypass_request_params_array = (array) apply_filters( |
|
332 | + 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
|
333 | + array() |
|
334 | + ); |
|
335 | + // does $bypass_request_params_array have any values ? |
|
336 | + if (empty($bypass_request_params_array)) { |
|
337 | + return false; |
|
338 | + } |
|
339 | + // initially set bypass to TRUE |
|
340 | + $bypass_recaptcha = true; |
|
341 | + foreach ($bypass_request_params_array as $key => $value) { |
|
342 | + // if $key is not found or value doesn't match exactly, then toggle bypass to FALSE, |
|
343 | + // otherwise carry over it's value. This way, one missed setting results in no bypass |
|
344 | + $bypass_recaptcha = isset($_REQUEST[ $key ]) && $_REQUEST[ $key ] === $value |
|
345 | + ? $bypass_recaptcha |
|
346 | + : false; |
|
347 | + } |
|
348 | + return $bypass_recaptcha; |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + /** |
|
353 | + * @return void |
|
354 | + * @throws InvalidArgumentException |
|
355 | + * @throws InvalidInterfaceException |
|
356 | + * @throws InvalidDataTypeException |
|
357 | + */ |
|
358 | + private static function _get_recaptcha_response() |
|
359 | + { |
|
360 | + EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get( |
|
361 | + 'g-recaptcha-response', |
|
362 | + false |
|
363 | + ); |
|
364 | + } |
|
365 | + |
|
366 | + |
|
367 | + /** |
|
368 | + * @return boolean |
|
369 | + * @throws InvalidArgumentException |
|
370 | + * @throws InvalidInterfaceException |
|
371 | + * @throws InvalidDataTypeException |
|
372 | + */ |
|
373 | + private static function _process_recaptcha_response() |
|
374 | + { |
|
375 | + // verify library is loaded |
|
376 | + if (! class_exists('\ReCaptcha\ReCaptcha')) { |
|
377 | + require_once RECAPTCHA_BASE_PATH . '/autoload.php'; |
|
378 | + } |
|
379 | + // The response from reCAPTCHA |
|
380 | + EED_Recaptcha::_get_recaptcha_response(); |
|
381 | + $recaptcha_response = EED_Recaptcha::$_recaptcha_response; |
|
382 | + // Was there a reCAPTCHA response? |
|
383 | + if ($recaptcha_response) { |
|
384 | + // if allow_url_fopen is Off, then set a different request method |
|
385 | + $request_method = ! ini_get('allow_url_fopen') ? new SocketPost() : null; |
|
386 | + $recaptcha = new ReCaptcha( |
|
387 | + EED_Recaptcha::$config->recaptcha_privatekey, |
|
388 | + $request_method |
|
389 | + ); |
|
390 | + $recaptcha_response = $recaptcha->verify( |
|
391 | + EED_Recaptcha::$_recaptcha_response, |
|
392 | + $_SERVER['REMOTE_ADDR'] |
|
393 | + ); |
|
394 | + } |
|
395 | + return $recaptcha_response instanceof Response && $recaptcha_response->isSuccess(); |
|
396 | + } |
|
397 | 397 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | define( |
133 | 133 | 'RECAPTCHA_BASE_PATH', |
134 | - rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/' |
|
134 | + rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/').'/' |
|
135 | 135 | ); |
136 | 136 | define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__)); |
137 | 137 | } |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | { |
185 | 185 | wp_register_script( |
186 | 186 | 'espresso_recaptcha', |
187 | - RECAPTCHA_BASE_URL . 'scripts/espresso_recaptcha.js', |
|
187 | + RECAPTCHA_BASE_URL.'scripts/espresso_recaptcha.js', |
|
188 | 188 | array('single_page_checkout'), |
189 | 189 | EVENT_ESPRESSO_VERSION, |
190 | 190 | true |
191 | 191 | ); |
192 | 192 | wp_register_script( |
193 | 193 | 'google_recaptcha', |
194 | - 'https://www.google.com/recaptcha/api.js?hl=' . EED_Recaptcha::$config->recaptcha_language, |
|
194 | + 'https://www.google.com/recaptcha/api.js?hl='.EED_Recaptcha::$config->recaptcha_language, |
|
195 | 195 | array('espresso_recaptcha'), |
196 | 196 | EVENT_ESPRESSO_VERSION, |
197 | 197 | true |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | if (EED_Recaptcha::useRecaptcha() && ! EED_Recaptcha::$_not_a_robot) { |
252 | 252 | // only display if they have NOT passed the test yet |
253 | 253 | EEH_Template::display_template( |
254 | - RECAPTCHA_BASE_PATH . '/templates/recaptcha.template.php', |
|
254 | + RECAPTCHA_BASE_PATH.'/templates/recaptcha.template.php', |
|
255 | 255 | array( |
256 | 256 | 'recaptcha_publickey' => EED_Recaptcha::$config->recaptcha_publickey, |
257 | 257 | 'recaptcha_theme' => EED_Recaptcha::$config->recaptcha_theme, |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | $recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN); |
297 | 297 | // verify recaptcha |
298 | 298 | EED_Recaptcha::_get_recaptcha_response(); |
299 | - if (! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
299 | + if ( ! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
300 | 300 | $recaptcha_passed = EED_Recaptcha::_process_recaptcha_response(); |
301 | 301 | EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed)); |
302 | 302 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | foreach ($bypass_request_params_array as $key => $value) { |
342 | 342 | // if $key is not found or value doesn't match exactly, then toggle bypass to FALSE, |
343 | 343 | // otherwise carry over it's value. This way, one missed setting results in no bypass |
344 | - $bypass_recaptcha = isset($_REQUEST[ $key ]) && $_REQUEST[ $key ] === $value |
|
344 | + $bypass_recaptcha = isset($_REQUEST[$key]) && $_REQUEST[$key] === $value |
|
345 | 345 | ? $bypass_recaptcha |
346 | 346 | : false; |
347 | 347 | } |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | private static function _process_recaptcha_response() |
374 | 374 | { |
375 | 375 | // verify library is loaded |
376 | - if (! class_exists('\ReCaptcha\ReCaptcha')) { |
|
377 | - require_once RECAPTCHA_BASE_PATH . '/autoload.php'; |
|
376 | + if ( ! class_exists('\ReCaptcha\ReCaptcha')) { |
|
377 | + require_once RECAPTCHA_BASE_PATH.'/autoload.php'; |
|
378 | 378 | } |
379 | 379 | // The response from reCAPTCHA |
380 | 380 | EED_Recaptcha::_get_recaptcha_response(); |
@@ -25,228 +25,228 @@ |
||
25 | 25 | { |
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * @return EED_Event_Single_Caff |
|
30 | - */ |
|
31 | - public static function instance() |
|
32 | - { |
|
33 | - return parent::get_instance(__CLASS__); |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
39 | - * |
|
40 | - * @access public |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - public static function set_hooks() |
|
44 | - { |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
49 | - * |
|
50 | - * @access public |
|
51 | - * @return void |
|
52 | - */ |
|
53 | - public static function set_hooks_admin() |
|
54 | - { |
|
55 | - self::setDefinitions(); |
|
56 | - add_action( |
|
57 | - 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__template_settings', |
|
58 | - array('EED_Event_Single_Caff', 'load_scripts_styles'), |
|
59 | - 10 |
|
60 | - ); |
|
61 | - add_action( |
|
62 | - 'AHEE__template_settings__template__before_settings_form', |
|
63 | - array('EED_Event_Single_Caff', 'template_settings_form'), |
|
64 | - 10 |
|
65 | - ); |
|
66 | - add_filter( |
|
67 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
68 | - array('EED_Event_Single_Caff', 'update_template_settings'), |
|
69 | - 10, |
|
70 | - 2 |
|
71 | - ); |
|
72 | - // AJAX |
|
73 | - add_action( |
|
74 | - 'wp_ajax_espresso_update_event_single_order', |
|
75 | - array('EED_Event_Single_Caff', 'update_event_single_order') |
|
76 | - ); |
|
77 | - add_action( |
|
78 | - 'wp_ajax_nopriv_espresso_update_event_single_order', |
|
79 | - array('EED_Event_Single_Caff', 'update_event_single_order') |
|
80 | - ); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - public static function load_scripts_styles() |
|
85 | - { |
|
86 | - add_action('admin_enqueue_scripts', array('EED_Event_Single_Caff', 'enqueue_scripts_styles'), 10); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - public static function enqueue_scripts_styles() |
|
91 | - { |
|
92 | - wp_register_style( |
|
93 | - 'eed-event-single-sortable', |
|
94 | - EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css', |
|
95 | - array(), |
|
96 | - EVENT_ESPRESSO_VERSION |
|
97 | - ); |
|
98 | - wp_enqueue_style('eed-event-single-sortable'); |
|
99 | - wp_register_script( |
|
100 | - 'eed-event-single-sortable', |
|
101 | - EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js', |
|
102 | - array('jquery-ui-sortable'), |
|
103 | - EVENT_ESPRESSO_VERSION, |
|
104 | - true |
|
105 | - ); |
|
106 | - wp_enqueue_script('eed-event-single-sortable'); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * Set constants only if they haven't been set yet. |
|
112 | - */ |
|
113 | - public static function setDefinitions() |
|
114 | - { |
|
115 | - if (! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) { |
|
116 | - define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/'); |
|
117 | - define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * template_settings_form |
|
124 | - * |
|
125 | - * @access public |
|
126 | - * @static |
|
127 | - * @return void |
|
128 | - */ |
|
129 | - public static function template_settings_form() |
|
130 | - { |
|
131 | - $config = EE_Registry::instance()->CFG->template_settings; |
|
132 | - $config = isset($config->EED_Event_Single) && $config->EED_Event_Single instanceof EE_Event_Single_Config |
|
133 | - ? $config->EED_Event_Single : new EE_Event_Single_Config(); |
|
134 | - $config->use_sortable_display_order = isset($config->use_sortable_display_order) |
|
135 | - ? $config->use_sortable_display_order : false; |
|
136 | - $config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config); |
|
137 | - |
|
138 | - $event_single_order_array = array(); |
|
139 | - $event_single_order_array[ $config->display_order_tickets ] = 'tickets'; |
|
140 | - $event_single_order_array[ $config->display_order_datetimes ] = 'datetimes'; |
|
141 | - $event_single_order_array[ $config->display_order_event ] = 'event'; |
|
142 | - $event_single_order_array[ $config->display_order_venue ] = 'venue'; |
|
143 | - // get template parts |
|
144 | - $template_parts = EED_Event_Single::instance()->initialize_template_parts($config); |
|
145 | - // convert to array so that we can add more properties |
|
146 | - $config = get_object_vars($config); |
|
147 | - $config['event_single_display_order'] = $template_parts->generate_sortable_list_of_template_parts( |
|
148 | - 'event-single-sortable-js', |
|
149 | - '', |
|
150 | - 'single-sortable-li single-sortable-js' |
|
151 | - ); |
|
152 | - EEH_Template::display_template( |
|
153 | - EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php', |
|
154 | - $config |
|
155 | - ); |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * update_template_settings |
|
161 | - * |
|
162 | - * @param EE_Template_Config $CFG |
|
163 | - * @param array $REQ |
|
164 | - * @return EE_Template_Config |
|
165 | - */ |
|
166 | - public static function update_template_settings(EE_Template_Config $CFG, $REQ) |
|
167 | - { |
|
168 | - if (! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) { |
|
169 | - $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
|
170 | - } |
|
171 | - $display_order_event = $CFG->EED_Event_Single->display_order_event !== null |
|
172 | - ? $CFG->EED_Event_Single->display_order_event |
|
173 | - : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
174 | - $display_order_datetimes = $CFG->EED_Event_Single->display_order_datetimes !== null |
|
175 | - ? $CFG->EED_Event_Single->display_order_datetimes |
|
176 | - : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
177 | - $display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null |
|
178 | - ? $CFG->EED_Event_Single->display_order_tickets |
|
179 | - : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
180 | - $display_order_venue = $CFG->EED_Event_Single->display_order_venue !== null |
|
181 | - ? $CFG->EED_Event_Single->display_order_venue |
|
182 | - : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
183 | - $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
|
184 | - $CFG->EED_Event_Single->display_status_banner_single = ! empty($REQ['display_status_banner_single']) |
|
185 | - && $REQ['display_status_banner_single']; |
|
186 | - $CFG->EED_Event_Single->display_venue = ! empty($REQ['display_venue']) && $REQ['display_venue']; |
|
187 | - $CFG->EED_Event_Single->use_sortable_display_order = ! empty($REQ['EED_Events_Single_use_sortable_display_order']) |
|
188 | - ? absint($REQ['EED_Events_Single_use_sortable_display_order']) |
|
189 | - : 0; |
|
190 | - $CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order |
|
191 | - ? $display_order_event |
|
192 | - : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
193 | - $CFG->EED_Event_Single->display_order_datetimes = $CFG->EED_Event_Single->use_sortable_display_order |
|
194 | - ? $display_order_datetimes |
|
195 | - : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
196 | - $CFG->EED_Event_Single->display_order_tickets = $CFG->EED_Event_Single->use_sortable_display_order |
|
197 | - ? $display_order_tickets |
|
198 | - : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
199 | - $CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order |
|
200 | - ? $display_order_venue |
|
201 | - : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
202 | - do_action('AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ); |
|
203 | - return $CFG; |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * update_event_single_order |
|
209 | - * |
|
210 | - * @access public |
|
211 | - * @return void |
|
212 | - */ |
|
213 | - public static function update_event_single_order() |
|
214 | - { |
|
215 | - $config_saved = false; |
|
216 | - $template_parts = sanitize_text_field($_POST['elements']); |
|
217 | - if (! empty($template_parts)) { |
|
218 | - $template_parts = explode(',', trim($template_parts, ',')); |
|
219 | - foreach ($template_parts as $key => $template_part) { |
|
220 | - $template_part = "display_order_$template_part"; |
|
221 | - $priority = ($key * 10) + EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
222 | - EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority; |
|
223 | - do_action("AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority); |
|
224 | - } |
|
225 | - $config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false); |
|
226 | - } |
|
227 | - if ($config_saved) { |
|
228 | - EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso')); |
|
229 | - } else { |
|
230 | - EE_Error::add_error( |
|
231 | - __('Display Order was not updated.', 'event_espresso'), |
|
232 | - __FILE__, |
|
233 | - __FUNCTION__, |
|
234 | - __LINE__ |
|
235 | - ); |
|
236 | - } |
|
237 | - echo wp_json_encode(EE_Error::get_notices(false)); |
|
238 | - exit(); |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * run - initial module setup |
|
244 | - * |
|
245 | - * @access public |
|
246 | - * @param WP $WP |
|
247 | - * @return void |
|
248 | - */ |
|
249 | - public function run($WP) |
|
250 | - { |
|
251 | - } |
|
28 | + /** |
|
29 | + * @return EED_Event_Single_Caff |
|
30 | + */ |
|
31 | + public static function instance() |
|
32 | + { |
|
33 | + return parent::get_instance(__CLASS__); |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
39 | + * |
|
40 | + * @access public |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + public static function set_hooks() |
|
44 | + { |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
49 | + * |
|
50 | + * @access public |
|
51 | + * @return void |
|
52 | + */ |
|
53 | + public static function set_hooks_admin() |
|
54 | + { |
|
55 | + self::setDefinitions(); |
|
56 | + add_action( |
|
57 | + 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__template_settings', |
|
58 | + array('EED_Event_Single_Caff', 'load_scripts_styles'), |
|
59 | + 10 |
|
60 | + ); |
|
61 | + add_action( |
|
62 | + 'AHEE__template_settings__template__before_settings_form', |
|
63 | + array('EED_Event_Single_Caff', 'template_settings_form'), |
|
64 | + 10 |
|
65 | + ); |
|
66 | + add_filter( |
|
67 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
68 | + array('EED_Event_Single_Caff', 'update_template_settings'), |
|
69 | + 10, |
|
70 | + 2 |
|
71 | + ); |
|
72 | + // AJAX |
|
73 | + add_action( |
|
74 | + 'wp_ajax_espresso_update_event_single_order', |
|
75 | + array('EED_Event_Single_Caff', 'update_event_single_order') |
|
76 | + ); |
|
77 | + add_action( |
|
78 | + 'wp_ajax_nopriv_espresso_update_event_single_order', |
|
79 | + array('EED_Event_Single_Caff', 'update_event_single_order') |
|
80 | + ); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + public static function load_scripts_styles() |
|
85 | + { |
|
86 | + add_action('admin_enqueue_scripts', array('EED_Event_Single_Caff', 'enqueue_scripts_styles'), 10); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + public static function enqueue_scripts_styles() |
|
91 | + { |
|
92 | + wp_register_style( |
|
93 | + 'eed-event-single-sortable', |
|
94 | + EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css', |
|
95 | + array(), |
|
96 | + EVENT_ESPRESSO_VERSION |
|
97 | + ); |
|
98 | + wp_enqueue_style('eed-event-single-sortable'); |
|
99 | + wp_register_script( |
|
100 | + 'eed-event-single-sortable', |
|
101 | + EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js', |
|
102 | + array('jquery-ui-sortable'), |
|
103 | + EVENT_ESPRESSO_VERSION, |
|
104 | + true |
|
105 | + ); |
|
106 | + wp_enqueue_script('eed-event-single-sortable'); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * Set constants only if they haven't been set yet. |
|
112 | + */ |
|
113 | + public static function setDefinitions() |
|
114 | + { |
|
115 | + if (! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) { |
|
116 | + define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/'); |
|
117 | + define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * template_settings_form |
|
124 | + * |
|
125 | + * @access public |
|
126 | + * @static |
|
127 | + * @return void |
|
128 | + */ |
|
129 | + public static function template_settings_form() |
|
130 | + { |
|
131 | + $config = EE_Registry::instance()->CFG->template_settings; |
|
132 | + $config = isset($config->EED_Event_Single) && $config->EED_Event_Single instanceof EE_Event_Single_Config |
|
133 | + ? $config->EED_Event_Single : new EE_Event_Single_Config(); |
|
134 | + $config->use_sortable_display_order = isset($config->use_sortable_display_order) |
|
135 | + ? $config->use_sortable_display_order : false; |
|
136 | + $config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config); |
|
137 | + |
|
138 | + $event_single_order_array = array(); |
|
139 | + $event_single_order_array[ $config->display_order_tickets ] = 'tickets'; |
|
140 | + $event_single_order_array[ $config->display_order_datetimes ] = 'datetimes'; |
|
141 | + $event_single_order_array[ $config->display_order_event ] = 'event'; |
|
142 | + $event_single_order_array[ $config->display_order_venue ] = 'venue'; |
|
143 | + // get template parts |
|
144 | + $template_parts = EED_Event_Single::instance()->initialize_template_parts($config); |
|
145 | + // convert to array so that we can add more properties |
|
146 | + $config = get_object_vars($config); |
|
147 | + $config['event_single_display_order'] = $template_parts->generate_sortable_list_of_template_parts( |
|
148 | + 'event-single-sortable-js', |
|
149 | + '', |
|
150 | + 'single-sortable-li single-sortable-js' |
|
151 | + ); |
|
152 | + EEH_Template::display_template( |
|
153 | + EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php', |
|
154 | + $config |
|
155 | + ); |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * update_template_settings |
|
161 | + * |
|
162 | + * @param EE_Template_Config $CFG |
|
163 | + * @param array $REQ |
|
164 | + * @return EE_Template_Config |
|
165 | + */ |
|
166 | + public static function update_template_settings(EE_Template_Config $CFG, $REQ) |
|
167 | + { |
|
168 | + if (! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) { |
|
169 | + $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
|
170 | + } |
|
171 | + $display_order_event = $CFG->EED_Event_Single->display_order_event !== null |
|
172 | + ? $CFG->EED_Event_Single->display_order_event |
|
173 | + : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
174 | + $display_order_datetimes = $CFG->EED_Event_Single->display_order_datetimes !== null |
|
175 | + ? $CFG->EED_Event_Single->display_order_datetimes |
|
176 | + : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
177 | + $display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null |
|
178 | + ? $CFG->EED_Event_Single->display_order_tickets |
|
179 | + : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
180 | + $display_order_venue = $CFG->EED_Event_Single->display_order_venue !== null |
|
181 | + ? $CFG->EED_Event_Single->display_order_venue |
|
182 | + : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
183 | + $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
|
184 | + $CFG->EED_Event_Single->display_status_banner_single = ! empty($REQ['display_status_banner_single']) |
|
185 | + && $REQ['display_status_banner_single']; |
|
186 | + $CFG->EED_Event_Single->display_venue = ! empty($REQ['display_venue']) && $REQ['display_venue']; |
|
187 | + $CFG->EED_Event_Single->use_sortable_display_order = ! empty($REQ['EED_Events_Single_use_sortable_display_order']) |
|
188 | + ? absint($REQ['EED_Events_Single_use_sortable_display_order']) |
|
189 | + : 0; |
|
190 | + $CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order |
|
191 | + ? $display_order_event |
|
192 | + : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
193 | + $CFG->EED_Event_Single->display_order_datetimes = $CFG->EED_Event_Single->use_sortable_display_order |
|
194 | + ? $display_order_datetimes |
|
195 | + : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
196 | + $CFG->EED_Event_Single->display_order_tickets = $CFG->EED_Event_Single->use_sortable_display_order |
|
197 | + ? $display_order_tickets |
|
198 | + : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
199 | + $CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order |
|
200 | + ? $display_order_venue |
|
201 | + : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
202 | + do_action('AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ); |
|
203 | + return $CFG; |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * update_event_single_order |
|
209 | + * |
|
210 | + * @access public |
|
211 | + * @return void |
|
212 | + */ |
|
213 | + public static function update_event_single_order() |
|
214 | + { |
|
215 | + $config_saved = false; |
|
216 | + $template_parts = sanitize_text_field($_POST['elements']); |
|
217 | + if (! empty($template_parts)) { |
|
218 | + $template_parts = explode(',', trim($template_parts, ',')); |
|
219 | + foreach ($template_parts as $key => $template_part) { |
|
220 | + $template_part = "display_order_$template_part"; |
|
221 | + $priority = ($key * 10) + EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
222 | + EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority; |
|
223 | + do_action("AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority); |
|
224 | + } |
|
225 | + $config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false); |
|
226 | + } |
|
227 | + if ($config_saved) { |
|
228 | + EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso')); |
|
229 | + } else { |
|
230 | + EE_Error::add_error( |
|
231 | + __('Display Order was not updated.', 'event_espresso'), |
|
232 | + __FILE__, |
|
233 | + __FUNCTION__, |
|
234 | + __LINE__ |
|
235 | + ); |
|
236 | + } |
|
237 | + echo wp_json_encode(EE_Error::get_notices(false)); |
|
238 | + exit(); |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * run - initial module setup |
|
244 | + * |
|
245 | + * @access public |
|
246 | + * @param WP $WP |
|
247 | + * @return void |
|
248 | + */ |
|
249 | + public function run($WP) |
|
250 | + { |
|
251 | + } |
|
252 | 252 | } |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | { |
92 | 92 | wp_register_style( |
93 | 93 | 'eed-event-single-sortable', |
94 | - EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css', |
|
94 | + EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.css', |
|
95 | 95 | array(), |
96 | 96 | EVENT_ESPRESSO_VERSION |
97 | 97 | ); |
98 | 98 | wp_enqueue_style('eed-event-single-sortable'); |
99 | 99 | wp_register_script( |
100 | 100 | 'eed-event-single-sortable', |
101 | - EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js', |
|
101 | + EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.js', |
|
102 | 102 | array('jquery-ui-sortable'), |
103 | 103 | EVENT_ESPRESSO_VERSION, |
104 | 104 | true |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public static function setDefinitions() |
114 | 114 | { |
115 | - if (! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) { |
|
116 | - define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/'); |
|
117 | - define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
115 | + if ( ! defined('EVENT_SINGLE_CAFF_TEMPLATES_PATH')) { |
|
116 | + define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates/'); |
|
117 | + define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets/'); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | $config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config); |
137 | 137 | |
138 | 138 | $event_single_order_array = array(); |
139 | - $event_single_order_array[ $config->display_order_tickets ] = 'tickets'; |
|
140 | - $event_single_order_array[ $config->display_order_datetimes ] = 'datetimes'; |
|
141 | - $event_single_order_array[ $config->display_order_event ] = 'event'; |
|
142 | - $event_single_order_array[ $config->display_order_venue ] = 'venue'; |
|
139 | + $event_single_order_array[$config->display_order_tickets] = 'tickets'; |
|
140 | + $event_single_order_array[$config->display_order_datetimes] = 'datetimes'; |
|
141 | + $event_single_order_array[$config->display_order_event] = 'event'; |
|
142 | + $event_single_order_array[$config->display_order_venue] = 'venue'; |
|
143 | 143 | // get template parts |
144 | 144 | $template_parts = EED_Event_Single::instance()->initialize_template_parts($config); |
145 | 145 | // convert to array so that we can add more properties |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | 'single-sortable-li single-sortable-js' |
151 | 151 | ); |
152 | 152 | EEH_Template::display_template( |
153 | - EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php', |
|
153 | + EVENT_SINGLE_CAFF_TEMPLATES_PATH.'admin-event-single-settings.template.php', |
|
154 | 154 | $config |
155 | 155 | ); |
156 | 156 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public static function update_template_settings(EE_Template_Config $CFG, $REQ) |
167 | 167 | { |
168 | - if (! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) { |
|
168 | + if ( ! $CFG->EED_Event_Single instanceof EE_Event_Single_Config) { |
|
169 | 169 | $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
170 | 170 | } |
171 | 171 | $display_order_event = $CFG->EED_Event_Single->display_order_event !== null |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | { |
215 | 215 | $config_saved = false; |
216 | 216 | $template_parts = sanitize_text_field($_POST['elements']); |
217 | - if (! empty($template_parts)) { |
|
217 | + if ( ! empty($template_parts)) { |
|
218 | 218 | $template_parts = explode(',', trim($template_parts, ',')); |
219 | 219 | foreach ($template_parts as $key => $template_part) { |
220 | 220 | $template_part = "display_order_$template_part"; |
@@ -17,318 +17,318 @@ |
||
17 | 17 | { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * @return EED_Module|EED_Ticket_Selector_Caff |
|
22 | - */ |
|
23 | - public static function instance() |
|
24 | - { |
|
25 | - return parent::get_instance(__CLASS__); |
|
26 | - } |
|
20 | + /** |
|
21 | + * @return EED_Module|EED_Ticket_Selector_Caff |
|
22 | + */ |
|
23 | + public static function instance() |
|
24 | + { |
|
25 | + return parent::get_instance(__CLASS__); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
31 | - * |
|
32 | - * @access public |
|
33 | - * @return void |
|
34 | - */ |
|
35 | - public static function set_hooks() |
|
36 | - { |
|
37 | - add_action( |
|
38 | - 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
39 | - array('EED_Ticket_Selector_Caff', 'ticket_price_details'), |
|
40 | - 10, |
|
41 | - 3 |
|
42 | - ); |
|
43 | - } |
|
29 | + /** |
|
30 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
31 | + * |
|
32 | + * @access public |
|
33 | + * @return void |
|
34 | + */ |
|
35 | + public static function set_hooks() |
|
36 | + { |
|
37 | + add_action( |
|
38 | + 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
39 | + array('EED_Ticket_Selector_Caff', 'ticket_price_details'), |
|
40 | + 10, |
|
41 | + 3 |
|
42 | + ); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
47 | - * |
|
48 | - * @access public |
|
49 | - * @return void |
|
50 | - */ |
|
51 | - public static function set_hooks_admin() |
|
52 | - { |
|
53 | - define( |
|
54 | - 'TICKET_SELECTOR_CAFF_TEMPLATES_PATH', |
|
55 | - str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/' |
|
56 | - ); |
|
57 | - add_action( |
|
58 | - 'AHEE__template_settings__template__before_settings_form', |
|
59 | - array('EED_Ticket_Selector_Caff', 'template_settings_form'), |
|
60 | - 10 |
|
61 | - ); |
|
62 | - add_filter( |
|
63 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
64 | - array('EED_Ticket_Selector_Caff', 'update_template_settings'), |
|
65 | - 10, |
|
66 | - 2 |
|
67 | - ); |
|
68 | - } |
|
45 | + /** |
|
46 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
47 | + * |
|
48 | + * @access public |
|
49 | + * @return void |
|
50 | + */ |
|
51 | + public static function set_hooks_admin() |
|
52 | + { |
|
53 | + define( |
|
54 | + 'TICKET_SELECTOR_CAFF_TEMPLATES_PATH', |
|
55 | + str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/' |
|
56 | + ); |
|
57 | + add_action( |
|
58 | + 'AHEE__template_settings__template__before_settings_form', |
|
59 | + array('EED_Ticket_Selector_Caff', 'template_settings_form'), |
|
60 | + 10 |
|
61 | + ); |
|
62 | + add_filter( |
|
63 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
64 | + array('EED_Ticket_Selector_Caff', 'update_template_settings'), |
|
65 | + 10, |
|
66 | + 2 |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * @param \WP $WP |
|
73 | - */ |
|
74 | - public function run($WP) |
|
75 | - { |
|
76 | - $this->set_config(); |
|
77 | - } |
|
71 | + /** |
|
72 | + * @param \WP $WP |
|
73 | + */ |
|
74 | + public function run($WP) |
|
75 | + { |
|
76 | + $this->set_config(); |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * @static |
|
82 | - * @return void |
|
83 | - * @throws EE_Error |
|
84 | - * @throws InvalidArgumentException |
|
85 | - * @throws InvalidDataTypeException |
|
86 | - * @throws InvalidInterfaceException |
|
87 | - */ |
|
88 | - public static function template_settings_form() |
|
89 | - { |
|
90 | - echo EED_Ticket_Selector_Caff::_ticket_selector_settings_form()->get_html(); |
|
91 | - } |
|
80 | + /** |
|
81 | + * @static |
|
82 | + * @return void |
|
83 | + * @throws EE_Error |
|
84 | + * @throws InvalidArgumentException |
|
85 | + * @throws InvalidDataTypeException |
|
86 | + * @throws InvalidInterfaceException |
|
87 | + */ |
|
88 | + public static function template_settings_form() |
|
89 | + { |
|
90 | + echo EED_Ticket_Selector_Caff::_ticket_selector_settings_form()->get_html(); |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * @return \EE_Form_Section_Proper |
|
96 | - * @throws \EE_Error |
|
97 | - */ |
|
98 | - public static function _ticket_selector_settings_form() |
|
99 | - { |
|
94 | + /** |
|
95 | + * @return \EE_Form_Section_Proper |
|
96 | + * @throws \EE_Error |
|
97 | + */ |
|
98 | + public static function _ticket_selector_settings_form() |
|
99 | + { |
|
100 | 100 | |
101 | - return new EE_Form_Section_Proper( |
|
102 | - array( |
|
103 | - 'name' => 'ticket_selector_settings_form', |
|
104 | - 'html_id' => 'ticket_selector_settings_form', |
|
105 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
106 | - 'subsections' => apply_filters( |
|
107 | - 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections', |
|
108 | - array( |
|
109 | - 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
|
110 | - EEH_HTML::br(2) . |
|
111 | - EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso')) |
|
112 | - ), |
|
113 | - 'appearance_settings' => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(), |
|
114 | - ) |
|
115 | - ), |
|
116 | - ) |
|
117 | - ); |
|
118 | - } |
|
101 | + return new EE_Form_Section_Proper( |
|
102 | + array( |
|
103 | + 'name' => 'ticket_selector_settings_form', |
|
104 | + 'html_id' => 'ticket_selector_settings_form', |
|
105 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
106 | + 'subsections' => apply_filters( |
|
107 | + 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections', |
|
108 | + array( |
|
109 | + 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
|
110 | + EEH_HTML::br(2) . |
|
111 | + EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso')) |
|
112 | + ), |
|
113 | + 'appearance_settings' => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(), |
|
114 | + ) |
|
115 | + ), |
|
116 | + ) |
|
117 | + ); |
|
118 | + } |
|
119 | 119 | |
120 | 120 | |
121 | - /** |
|
122 | - * @return \EE_Form_Section_Proper |
|
123 | - * @throws \EE_Error |
|
124 | - */ |
|
125 | - public static function _ticket_selector_appearance_settings() |
|
126 | - { |
|
127 | - if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
128 | - ) { |
|
129 | - EED_Ticket_Selector::instance()->set_config(); |
|
130 | - EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance() |
|
131 | - ->config(); |
|
132 | - } |
|
133 | - $EE_Ticket_Selector_Config = EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector; |
|
134 | - // get option for whether to show datetime selector in TS |
|
135 | - $show_datetime_selector = $EE_Ticket_Selector_Config->getShowDatetimeSelector(); |
|
136 | - // and option for how may datetimes must exist if display is conditional |
|
137 | - $datetime_selector_threshold = $EE_Ticket_Selector_Config->getDatetimeSelectorThreshold(); |
|
121 | + /** |
|
122 | + * @return \EE_Form_Section_Proper |
|
123 | + * @throws \EE_Error |
|
124 | + */ |
|
125 | + public static function _ticket_selector_appearance_settings() |
|
126 | + { |
|
127 | + if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
128 | + ) { |
|
129 | + EED_Ticket_Selector::instance()->set_config(); |
|
130 | + EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance() |
|
131 | + ->config(); |
|
132 | + } |
|
133 | + $EE_Ticket_Selector_Config = EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector; |
|
134 | + // get option for whether to show datetime selector in TS |
|
135 | + $show_datetime_selector = $EE_Ticket_Selector_Config->getShowDatetimeSelector(); |
|
136 | + // and option for how may datetimes must exist if display is conditional |
|
137 | + $datetime_selector_threshold = $EE_Ticket_Selector_Config->getDatetimeSelectorThreshold(); |
|
138 | 138 | |
139 | - return new EE_Form_Section_Proper( |
|
140 | - array( |
|
141 | - 'name' => 'ticket_selector_settings_tbl', |
|
142 | - 'html_id' => 'ticket_selector_settings_tbl', |
|
143 | - 'html_class' => 'form-table', |
|
144 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
145 | - 'subsections' => apply_filters( |
|
146 | - 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_appearance_settings__form_subsections', |
|
147 | - array( |
|
148 | - 'show_ticket_details' => new EE_Yes_No_Input( |
|
149 | - array( |
|
150 | - 'html_label_text' => esc_html__( |
|
151 | - 'Show Ticket Details?', |
|
152 | - 'event_espresso' |
|
153 | - ), |
|
154 | - 'html_help_text' => esc_html__( |
|
155 | - 'This lets you choose whether the extra ticket details section is displayed with the ticket selector.', |
|
156 | - 'event_espresso' |
|
157 | - ), |
|
158 | - 'default' => isset($EE_Ticket_Selector_Config->show_ticket_details) |
|
159 | - ? $EE_Ticket_Selector_Config->show_ticket_details |
|
160 | - : true, |
|
161 | - 'display_html_label_text' => false, |
|
162 | - ) |
|
163 | - ), |
|
164 | - 'show_ticket_sale_columns' => new EE_Yes_No_Input( |
|
165 | - array( |
|
166 | - 'html_label_text' => esc_html__( |
|
167 | - 'Show Ticket Sale Info?', |
|
168 | - 'event_espresso' |
|
169 | - ), |
|
170 | - 'html_help_text' => esc_html__( |
|
171 | - 'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.', |
|
172 | - 'event_espresso' |
|
173 | - ), |
|
174 | - 'default' => isset($EE_Ticket_Selector_Config->show_ticket_sale_columns) |
|
175 | - ? $EE_Ticket_Selector_Config->show_ticket_sale_columns |
|
176 | - : true, |
|
177 | - 'display_html_label_text' => false, |
|
178 | - ) |
|
179 | - ), |
|
180 | - 'show_expired_tickets' => new EE_Yes_No_Input( |
|
181 | - array( |
|
182 | - 'html_label_text' => esc_html__( |
|
183 | - 'Show Expired Tickets?', |
|
184 | - 'event_espresso' |
|
185 | - ), |
|
186 | - 'html_help_text' => esc_html__( |
|
187 | - 'Indicate whether to show expired tickets in the ticket selector', |
|
188 | - 'event_espresso' |
|
189 | - ), |
|
190 | - 'default' => isset($EE_Ticket_Selector_Config->show_expired_tickets) |
|
191 | - ? $EE_Ticket_Selector_Config->show_expired_tickets |
|
192 | - : true, |
|
193 | - 'display_html_label_text' => false, |
|
194 | - ) |
|
195 | - ), |
|
196 | - 'show_datetime_selector' => new EE_Select_Input( |
|
197 | - $EE_Ticket_Selector_Config->getShowDatetimeSelectorOptions(false), |
|
198 | - array( |
|
199 | - 'html_label_text' => esc_html__( |
|
200 | - 'Show Date & Time Filter?', |
|
201 | - 'event_espresso' |
|
202 | - ), |
|
203 | - 'html_help_text' => sprintf( |
|
204 | - esc_html__( |
|
205 | - 'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates and times for the available tickets. Ticket options can be unselected, which removes (hides) them from the list of tickets being displayed.%1$sOptions include:%1$s • %2$sdo not show date & time filter%3$s%1$s this option will NEVER display a date filter, regardless of how many dates exist.%1$s • %2$smaybe show date & time filter%3$s%1$s this option will conditionally display the date filter when the number of dates for the event matches the value set for "Date Filter Threshold".', |
|
206 | - 'event_espresso' |
|
207 | - ), |
|
208 | - '<br>', |
|
209 | - '<strong>', |
|
210 | - '</strong>' |
|
211 | - ), |
|
212 | - 'default' => ! empty($show_datetime_selector) |
|
213 | - ? $show_datetime_selector |
|
214 | - : EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
215 | - 'display_html_label_text' => false, |
|
216 | - ) |
|
217 | - ), |
|
218 | - 'datetime_selector_threshold' => new EE_Select_Input( |
|
219 | - array_combine($r = range(1, 10), $r), |
|
220 | - array( |
|
221 | - 'html_label_text' => esc_html__( |
|
222 | - 'Date & Time Filter Threshold', |
|
223 | - 'event_espresso' |
|
224 | - ), |
|
225 | - 'html_help_text' => esc_html__( |
|
226 | - 'The number of unique dates an event has to have before conditionally displaying a date & time filter', |
|
227 | - 'event_espresso' |
|
228 | - ), |
|
229 | - 'default' => ! empty($datetime_selector_threshold) |
|
230 | - ? $datetime_selector_threshold |
|
231 | - : 3, |
|
232 | - 'display_html_label_text' => false, |
|
233 | - ) |
|
234 | - ), |
|
235 | - 'datetime_selector_max_checked' => new EE_Integer_Input( |
|
236 | - array( |
|
237 | - 'html_label_text' => esc_html__( |
|
238 | - 'Date & Time Filter Max Checked', |
|
239 | - 'event_espresso' |
|
240 | - ), |
|
241 | - 'html_help_text' => sprintf( |
|
242 | - esc_html__( |
|
243 | - 'Determines the maximum number of dates that will be checked upon initial loading for a Date and Time Filter.%1$sIf set to zero or left blank, then ALL dates will be checked upon initial loading.', |
|
244 | - 'event_espresso' |
|
245 | - ), |
|
246 | - '<br>' |
|
247 | - ), |
|
248 | - 'default' => $EE_Ticket_Selector_Config->getDatetimeSelectorMaxChecked(), |
|
249 | - 'display_html_label_text' => false, |
|
250 | - 'min_value' => 0, |
|
251 | - ) |
|
252 | - ), |
|
253 | - ) |
|
254 | - ), |
|
255 | - ) |
|
256 | - ); |
|
257 | - } |
|
139 | + return new EE_Form_Section_Proper( |
|
140 | + array( |
|
141 | + 'name' => 'ticket_selector_settings_tbl', |
|
142 | + 'html_id' => 'ticket_selector_settings_tbl', |
|
143 | + 'html_class' => 'form-table', |
|
144 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
145 | + 'subsections' => apply_filters( |
|
146 | + 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_appearance_settings__form_subsections', |
|
147 | + array( |
|
148 | + 'show_ticket_details' => new EE_Yes_No_Input( |
|
149 | + array( |
|
150 | + 'html_label_text' => esc_html__( |
|
151 | + 'Show Ticket Details?', |
|
152 | + 'event_espresso' |
|
153 | + ), |
|
154 | + 'html_help_text' => esc_html__( |
|
155 | + 'This lets you choose whether the extra ticket details section is displayed with the ticket selector.', |
|
156 | + 'event_espresso' |
|
157 | + ), |
|
158 | + 'default' => isset($EE_Ticket_Selector_Config->show_ticket_details) |
|
159 | + ? $EE_Ticket_Selector_Config->show_ticket_details |
|
160 | + : true, |
|
161 | + 'display_html_label_text' => false, |
|
162 | + ) |
|
163 | + ), |
|
164 | + 'show_ticket_sale_columns' => new EE_Yes_No_Input( |
|
165 | + array( |
|
166 | + 'html_label_text' => esc_html__( |
|
167 | + 'Show Ticket Sale Info?', |
|
168 | + 'event_espresso' |
|
169 | + ), |
|
170 | + 'html_help_text' => esc_html__( |
|
171 | + 'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.', |
|
172 | + 'event_espresso' |
|
173 | + ), |
|
174 | + 'default' => isset($EE_Ticket_Selector_Config->show_ticket_sale_columns) |
|
175 | + ? $EE_Ticket_Selector_Config->show_ticket_sale_columns |
|
176 | + : true, |
|
177 | + 'display_html_label_text' => false, |
|
178 | + ) |
|
179 | + ), |
|
180 | + 'show_expired_tickets' => new EE_Yes_No_Input( |
|
181 | + array( |
|
182 | + 'html_label_text' => esc_html__( |
|
183 | + 'Show Expired Tickets?', |
|
184 | + 'event_espresso' |
|
185 | + ), |
|
186 | + 'html_help_text' => esc_html__( |
|
187 | + 'Indicate whether to show expired tickets in the ticket selector', |
|
188 | + 'event_espresso' |
|
189 | + ), |
|
190 | + 'default' => isset($EE_Ticket_Selector_Config->show_expired_tickets) |
|
191 | + ? $EE_Ticket_Selector_Config->show_expired_tickets |
|
192 | + : true, |
|
193 | + 'display_html_label_text' => false, |
|
194 | + ) |
|
195 | + ), |
|
196 | + 'show_datetime_selector' => new EE_Select_Input( |
|
197 | + $EE_Ticket_Selector_Config->getShowDatetimeSelectorOptions(false), |
|
198 | + array( |
|
199 | + 'html_label_text' => esc_html__( |
|
200 | + 'Show Date & Time Filter?', |
|
201 | + 'event_espresso' |
|
202 | + ), |
|
203 | + 'html_help_text' => sprintf( |
|
204 | + esc_html__( |
|
205 | + 'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates and times for the available tickets. Ticket options can be unselected, which removes (hides) them from the list of tickets being displayed.%1$sOptions include:%1$s • %2$sdo not show date & time filter%3$s%1$s this option will NEVER display a date filter, regardless of how many dates exist.%1$s • %2$smaybe show date & time filter%3$s%1$s this option will conditionally display the date filter when the number of dates for the event matches the value set for "Date Filter Threshold".', |
|
206 | + 'event_espresso' |
|
207 | + ), |
|
208 | + '<br>', |
|
209 | + '<strong>', |
|
210 | + '</strong>' |
|
211 | + ), |
|
212 | + 'default' => ! empty($show_datetime_selector) |
|
213 | + ? $show_datetime_selector |
|
214 | + : EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
215 | + 'display_html_label_text' => false, |
|
216 | + ) |
|
217 | + ), |
|
218 | + 'datetime_selector_threshold' => new EE_Select_Input( |
|
219 | + array_combine($r = range(1, 10), $r), |
|
220 | + array( |
|
221 | + 'html_label_text' => esc_html__( |
|
222 | + 'Date & Time Filter Threshold', |
|
223 | + 'event_espresso' |
|
224 | + ), |
|
225 | + 'html_help_text' => esc_html__( |
|
226 | + 'The number of unique dates an event has to have before conditionally displaying a date & time filter', |
|
227 | + 'event_espresso' |
|
228 | + ), |
|
229 | + 'default' => ! empty($datetime_selector_threshold) |
|
230 | + ? $datetime_selector_threshold |
|
231 | + : 3, |
|
232 | + 'display_html_label_text' => false, |
|
233 | + ) |
|
234 | + ), |
|
235 | + 'datetime_selector_max_checked' => new EE_Integer_Input( |
|
236 | + array( |
|
237 | + 'html_label_text' => esc_html__( |
|
238 | + 'Date & Time Filter Max Checked', |
|
239 | + 'event_espresso' |
|
240 | + ), |
|
241 | + 'html_help_text' => sprintf( |
|
242 | + esc_html__( |
|
243 | + 'Determines the maximum number of dates that will be checked upon initial loading for a Date and Time Filter.%1$sIf set to zero or left blank, then ALL dates will be checked upon initial loading.', |
|
244 | + 'event_espresso' |
|
245 | + ), |
|
246 | + '<br>' |
|
247 | + ), |
|
248 | + 'default' => $EE_Ticket_Selector_Config->getDatetimeSelectorMaxChecked(), |
|
249 | + 'display_html_label_text' => false, |
|
250 | + 'min_value' => 0, |
|
251 | + ) |
|
252 | + ), |
|
253 | + ) |
|
254 | + ), |
|
255 | + ) |
|
256 | + ); |
|
257 | + } |
|
258 | 258 | |
259 | 259 | |
260 | - /** |
|
261 | - * callback for updating template settings |
|
262 | - * |
|
263 | - * @since 4.6.18.rc.006 |
|
264 | - * @param EE_Template_Config $CFG |
|
265 | - * @param array $REQ incoming request |
|
266 | - * @return EE_Template_Config |
|
267 | - * @throws EE_Error |
|
268 | - * @throws InvalidArgumentException |
|
269 | - * @throws ReflectionException |
|
270 | - * @throws InvalidDataTypeException |
|
271 | - * @throws InvalidInterfaceException |
|
272 | - */ |
|
273 | - public static function update_template_settings(EE_Template_Config $CFG, $REQ) |
|
274 | - { |
|
275 | - if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
276 | - EED_Ticket_Selector::instance()->set_config(); |
|
277 | - $CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config(); |
|
278 | - } |
|
279 | - try { |
|
280 | - $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form(); |
|
260 | + /** |
|
261 | + * callback for updating template settings |
|
262 | + * |
|
263 | + * @since 4.6.18.rc.006 |
|
264 | + * @param EE_Template_Config $CFG |
|
265 | + * @param array $REQ incoming request |
|
266 | + * @return EE_Template_Config |
|
267 | + * @throws EE_Error |
|
268 | + * @throws InvalidArgumentException |
|
269 | + * @throws ReflectionException |
|
270 | + * @throws InvalidDataTypeException |
|
271 | + * @throws InvalidInterfaceException |
|
272 | + */ |
|
273 | + public static function update_template_settings(EE_Template_Config $CFG, $REQ) |
|
274 | + { |
|
275 | + if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
276 | + EED_Ticket_Selector::instance()->set_config(); |
|
277 | + $CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config(); |
|
278 | + } |
|
279 | + try { |
|
280 | + $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form(); |
|
281 | 281 | |
282 | - // check for form submission |
|
283 | - if ($ticket_selector_form->was_submitted()) { |
|
284 | - // capture form data |
|
285 | - $ticket_selector_form->receive_form_submission(); |
|
282 | + // check for form submission |
|
283 | + if ($ticket_selector_form->was_submitted()) { |
|
284 | + // capture form data |
|
285 | + $ticket_selector_form->receive_form_submission(); |
|
286 | 286 | |
287 | - // validate form data |
|
288 | - if ($ticket_selector_form->is_valid()) { |
|
289 | - // grab validated data from form |
|
290 | - $valid_data = $ticket_selector_form->valid_data(); |
|
287 | + // validate form data |
|
288 | + if ($ticket_selector_form->is_valid()) { |
|
289 | + // grab validated data from form |
|
290 | + $valid_data = $ticket_selector_form->valid_data(); |
|
291 | 291 | |
292 | - // set data on config |
|
293 | - $CFG->EED_Ticket_Selector->show_ticket_sale_columns = $valid_data['appearance_settings']['show_ticket_sale_columns']; |
|
294 | - $CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details']; |
|
295 | - $CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets']; |
|
296 | - $CFG->EED_Ticket_Selector->setShowDatetimeSelector( |
|
297 | - $valid_data['appearance_settings']['show_datetime_selector'] |
|
298 | - ); |
|
299 | - $CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold( |
|
300 | - $valid_data['appearance_settings']['datetime_selector_threshold'] |
|
301 | - ); |
|
302 | - $CFG->EED_Ticket_Selector->setDatetimeSelectorMaxChecked( |
|
303 | - $valid_data['appearance_settings']['datetime_selector_max_checked'] |
|
304 | - ); |
|
305 | - } else { |
|
306 | - if ($ticket_selector_form->submission_error_message() !== '') { |
|
307 | - EE_Error::add_error( |
|
308 | - $ticket_selector_form->submission_error_message(), |
|
309 | - __FILE__, |
|
310 | - __FUNCTION__, |
|
311 | - __LINE__ |
|
312 | - ); |
|
313 | - } |
|
314 | - } |
|
315 | - } |
|
316 | - } catch (EE_Error $e) { |
|
317 | - $e->get_error(); |
|
318 | - } |
|
292 | + // set data on config |
|
293 | + $CFG->EED_Ticket_Selector->show_ticket_sale_columns = $valid_data['appearance_settings']['show_ticket_sale_columns']; |
|
294 | + $CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details']; |
|
295 | + $CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets']; |
|
296 | + $CFG->EED_Ticket_Selector->setShowDatetimeSelector( |
|
297 | + $valid_data['appearance_settings']['show_datetime_selector'] |
|
298 | + ); |
|
299 | + $CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold( |
|
300 | + $valid_data['appearance_settings']['datetime_selector_threshold'] |
|
301 | + ); |
|
302 | + $CFG->EED_Ticket_Selector->setDatetimeSelectorMaxChecked( |
|
303 | + $valid_data['appearance_settings']['datetime_selector_max_checked'] |
|
304 | + ); |
|
305 | + } else { |
|
306 | + if ($ticket_selector_form->submission_error_message() !== '') { |
|
307 | + EE_Error::add_error( |
|
308 | + $ticket_selector_form->submission_error_message(), |
|
309 | + __FILE__, |
|
310 | + __FUNCTION__, |
|
311 | + __LINE__ |
|
312 | + ); |
|
313 | + } |
|
314 | + } |
|
315 | + } |
|
316 | + } catch (EE_Error $e) { |
|
317 | + $e->get_error(); |
|
318 | + } |
|
319 | 319 | |
320 | - return $CFG; |
|
321 | - } |
|
320 | + return $CFG; |
|
321 | + } |
|
322 | 322 | |
323 | 323 | |
324 | - /** |
|
325 | - * @param \EE_Ticket $ticket |
|
326 | - * @param int $ticket_price |
|
327 | - * @param bool $display_ticket_price |
|
328 | - */ |
|
329 | - public static function ticket_price_details(EE_Ticket $ticket, $ticket_price = 0, $display_ticket_price = false) |
|
330 | - { |
|
331 | - require str_replace('\\', '/', plugin_dir_path(__FILE__)) |
|
332 | - . 'templates/ticket_selector_price_details.template.php'; |
|
333 | - } |
|
324 | + /** |
|
325 | + * @param \EE_Ticket $ticket |
|
326 | + * @param int $ticket_price |
|
327 | + * @param bool $display_ticket_price |
|
328 | + */ |
|
329 | + public static function ticket_price_details(EE_Ticket $ticket, $ticket_price = 0, $display_ticket_price = false) |
|
330 | + { |
|
331 | + require str_replace('\\', '/', plugin_dir_path(__FILE__)) |
|
332 | + . 'templates/ticket_selector_price_details.template.php'; |
|
333 | + } |
|
334 | 334 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | { |
53 | 53 | define( |
54 | 54 | 'TICKET_SELECTOR_CAFF_TEMPLATES_PATH', |
55 | - str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/' |
|
55 | + str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/' |
|
56 | 56 | ); |
57 | 57 | add_action( |
58 | 58 | 'AHEE__template_settings__template__before_settings_form', |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections', |
108 | 108 | array( |
109 | 109 | 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
110 | - EEH_HTML::br(2) . |
|
110 | + EEH_HTML::br(2). |
|
111 | 111 | EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso')) |
112 | 112 | ), |
113 | 113 | 'appearance_settings' => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(), |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public static function _ticket_selector_appearance_settings() |
126 | 126 | { |
127 | - if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
127 | + if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
128 | 128 | ) { |
129 | 129 | EED_Ticket_Selector::instance()->set_config(); |
130 | 130 | EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance() |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public static function update_template_settings(EE_Template_Config $CFG, $REQ) |
274 | 274 | { |
275 | - if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
275 | + if ( ! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
276 | 276 | EED_Ticket_Selector::instance()->set_config(); |
277 | 277 | $CFG->EED_Ticket_Selector = EED_Ticket_Selector::instance()->config(); |
278 | 278 | } |