@@ -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 | } |
@@ -13,260 +13,260 @@ |
||
13 | 13 | class EED_Events_Archive_Caff extends EED_Events_Archive |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @return EED_Events_Archive_Caff|EED_Module |
|
18 | - */ |
|
19 | - public static function instance() |
|
20 | - { |
|
21 | - return parent::get_instance(__CLASS__); |
|
22 | - } |
|
16 | + /** |
|
17 | + * @return EED_Events_Archive_Caff|EED_Module |
|
18 | + */ |
|
19 | + public static function instance() |
|
20 | + { |
|
21 | + return parent::get_instance(__CLASS__); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
27 | - * |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public static function set_hooks() |
|
31 | - { |
|
32 | - } |
|
25 | + /** |
|
26 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
27 | + * |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public static function set_hooks() |
|
31 | + { |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
36 | - * |
|
37 | - * @access public |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - public static function set_hooks_admin() |
|
41 | - { |
|
42 | - self::setDefinitions(); |
|
43 | - add_action( |
|
44 | - 'AHEE__template_settings__template__before_settings_form', |
|
45 | - array('EED_Events_Archive_Caff', 'template_settings_form'), |
|
46 | - 10 |
|
47 | - ); |
|
48 | - add_filter( |
|
49 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
50 | - array('EED_Events_Archive_Caff', 'update_template_settings'), |
|
51 | - 10, |
|
52 | - 2 |
|
53 | - ); |
|
54 | - // AJAX |
|
55 | - add_action( |
|
56 | - 'wp_ajax_espresso_update_event_archive_order', |
|
57 | - array('EED_Events_Archive_Caff', 'update_event_archive_order') |
|
58 | - ); |
|
59 | - add_action( |
|
60 | - 'wp_ajax_nopriv_espresso_update_event_archive_order', |
|
61 | - array('EED_Events_Archive_Caff', 'update_event_archive_order') |
|
62 | - ); |
|
63 | - } |
|
34 | + /** |
|
35 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
36 | + * |
|
37 | + * @access public |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + public static function set_hooks_admin() |
|
41 | + { |
|
42 | + self::setDefinitions(); |
|
43 | + add_action( |
|
44 | + 'AHEE__template_settings__template__before_settings_form', |
|
45 | + array('EED_Events_Archive_Caff', 'template_settings_form'), |
|
46 | + 10 |
|
47 | + ); |
|
48 | + add_filter( |
|
49 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
50 | + array('EED_Events_Archive_Caff', 'update_template_settings'), |
|
51 | + 10, |
|
52 | + 2 |
|
53 | + ); |
|
54 | + // AJAX |
|
55 | + add_action( |
|
56 | + 'wp_ajax_espresso_update_event_archive_order', |
|
57 | + array('EED_Events_Archive_Caff', 'update_event_archive_order') |
|
58 | + ); |
|
59 | + add_action( |
|
60 | + 'wp_ajax_nopriv_espresso_update_event_archive_order', |
|
61 | + array('EED_Events_Archive_Caff', 'update_event_archive_order') |
|
62 | + ); |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * run - initial module setup |
|
68 | - * |
|
69 | - * @param WP $WP |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - public function run($WP) |
|
73 | - { |
|
74 | - } |
|
66 | + /** |
|
67 | + * run - initial module setup |
|
68 | + * |
|
69 | + * @param WP $WP |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + public function run($WP) |
|
73 | + { |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * Conditionally set constants if they haven't been defined yet. |
|
79 | - */ |
|
80 | - public static function setDefinitions() |
|
81 | - { |
|
82 | - if (! defined('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH')) { |
|
83 | - define( |
|
84 | - 'EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', |
|
85 | - str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates/' |
|
86 | - ); |
|
87 | - define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
88 | - } |
|
89 | - } |
|
77 | + /** |
|
78 | + * Conditionally set constants if they haven't been defined yet. |
|
79 | + */ |
|
80 | + public static function setDefinitions() |
|
81 | + { |
|
82 | + if (! defined('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH')) { |
|
83 | + define( |
|
84 | + 'EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', |
|
85 | + str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates/' |
|
86 | + ); |
|
87 | + define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * @return void |
|
94 | - * @throws DomainException |
|
95 | - * @throws InvalidArgumentException |
|
96 | - * @throws InvalidDataTypeException |
|
97 | - * @throws InvalidInterfaceException |
|
98 | - */ |
|
99 | - public static function template_settings_form() |
|
100 | - { |
|
101 | - // grab general settings admin page and remove the existing hook callback |
|
102 | - $gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object('general_settings'); |
|
103 | - if ($gen_set_admin instanceof General_Settings_Admin_Page) { |
|
104 | - remove_action( |
|
105 | - 'AHEE__template_settings__template__before_settings_form', |
|
106 | - array($gen_set_admin, 'template_settings_caff_features'), |
|
107 | - 100 |
|
108 | - ); |
|
109 | - } |
|
110 | - // first just grab the template settings |
|
111 | - $config = EE_Registry::instance()->CFG->template_settings; |
|
112 | - // then if the Event Archive config is valid, use that, else create a new one |
|
113 | - $config = $config instanceof EE_Template_Config |
|
114 | - && $config->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
115 | - ? $config->EED_Events_Archive |
|
116 | - : new EE_Events_Archive_Config(); |
|
117 | - $config = apply_filters( |
|
118 | - 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', |
|
119 | - $config |
|
120 | - ); |
|
121 | - $config->display_status_banner = isset($config->display_status_banner) |
|
122 | - ? $config->display_status_banner |
|
123 | - : 0; |
|
124 | - $config->display_description = isset($config->display_description) |
|
125 | - ? $config->display_description |
|
126 | - : 1; |
|
127 | - $config->display_ticket_selector = isset($config->display_ticket_selector) |
|
128 | - ? $config->display_ticket_selector |
|
129 | - : 0; |
|
130 | - $config->display_datetimes = isset($config->display_datetimes) |
|
131 | - ? $config->display_datetimes |
|
132 | - : 1; |
|
133 | - $config->display_venue = isset($config->display_venue) |
|
134 | - ? $config->display_venue |
|
135 | - : 0; |
|
136 | - $config->display_expired_events = isset($config->display_expired_events) |
|
137 | - ? $config->display_expired_events |
|
138 | - : 0; |
|
139 | - // display order options |
|
140 | - $config->use_sortable_display_order = isset($config->use_sortable_display_order) |
|
141 | - ? $config->use_sortable_display_order |
|
142 | - : false; |
|
143 | - $config->display_order_tickets = isset($config->display_order_tickets) |
|
144 | - ? $config->display_order_tickets |
|
145 | - : 120; |
|
146 | - $config->display_order_datetimes = isset($config->display_order_datetimes) |
|
147 | - ? $config->display_order_datetimes |
|
148 | - : 110; |
|
149 | - $config->display_order_event = isset($config->display_order_event) |
|
150 | - ? $config->display_order_event |
|
151 | - : 100; |
|
152 | - $config->display_order_venue = isset($config->display_order_venue) |
|
153 | - ? $config->display_order_venue |
|
154 | - : 130; |
|
155 | - // get template parts |
|
156 | - $template_parts = EED_Events_Archive::instance()->initialize_template_parts($config); |
|
157 | - // convert to array so that we can add more properties |
|
158 | - $config = get_object_vars($config); |
|
159 | - $config['event_archive_display_order'] = $template_parts->generate_sortable_list_of_template_parts( |
|
160 | - 'event-archive-sortable-js', |
|
161 | - '', |
|
162 | - 'archive-sortable-li archive-sortable-js' |
|
163 | - ); |
|
164 | - EEH_Template::display_template( |
|
165 | - EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
166 | - $config |
|
167 | - ); |
|
168 | - } |
|
92 | + /** |
|
93 | + * @return void |
|
94 | + * @throws DomainException |
|
95 | + * @throws InvalidArgumentException |
|
96 | + * @throws InvalidDataTypeException |
|
97 | + * @throws InvalidInterfaceException |
|
98 | + */ |
|
99 | + public static function template_settings_form() |
|
100 | + { |
|
101 | + // grab general settings admin page and remove the existing hook callback |
|
102 | + $gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object('general_settings'); |
|
103 | + if ($gen_set_admin instanceof General_Settings_Admin_Page) { |
|
104 | + remove_action( |
|
105 | + 'AHEE__template_settings__template__before_settings_form', |
|
106 | + array($gen_set_admin, 'template_settings_caff_features'), |
|
107 | + 100 |
|
108 | + ); |
|
109 | + } |
|
110 | + // first just grab the template settings |
|
111 | + $config = EE_Registry::instance()->CFG->template_settings; |
|
112 | + // then if the Event Archive config is valid, use that, else create a new one |
|
113 | + $config = $config instanceof EE_Template_Config |
|
114 | + && $config->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
115 | + ? $config->EED_Events_Archive |
|
116 | + : new EE_Events_Archive_Config(); |
|
117 | + $config = apply_filters( |
|
118 | + 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', |
|
119 | + $config |
|
120 | + ); |
|
121 | + $config->display_status_banner = isset($config->display_status_banner) |
|
122 | + ? $config->display_status_banner |
|
123 | + : 0; |
|
124 | + $config->display_description = isset($config->display_description) |
|
125 | + ? $config->display_description |
|
126 | + : 1; |
|
127 | + $config->display_ticket_selector = isset($config->display_ticket_selector) |
|
128 | + ? $config->display_ticket_selector |
|
129 | + : 0; |
|
130 | + $config->display_datetimes = isset($config->display_datetimes) |
|
131 | + ? $config->display_datetimes |
|
132 | + : 1; |
|
133 | + $config->display_venue = isset($config->display_venue) |
|
134 | + ? $config->display_venue |
|
135 | + : 0; |
|
136 | + $config->display_expired_events = isset($config->display_expired_events) |
|
137 | + ? $config->display_expired_events |
|
138 | + : 0; |
|
139 | + // display order options |
|
140 | + $config->use_sortable_display_order = isset($config->use_sortable_display_order) |
|
141 | + ? $config->use_sortable_display_order |
|
142 | + : false; |
|
143 | + $config->display_order_tickets = isset($config->display_order_tickets) |
|
144 | + ? $config->display_order_tickets |
|
145 | + : 120; |
|
146 | + $config->display_order_datetimes = isset($config->display_order_datetimes) |
|
147 | + ? $config->display_order_datetimes |
|
148 | + : 110; |
|
149 | + $config->display_order_event = isset($config->display_order_event) |
|
150 | + ? $config->display_order_event |
|
151 | + : 100; |
|
152 | + $config->display_order_venue = isset($config->display_order_venue) |
|
153 | + ? $config->display_order_venue |
|
154 | + : 130; |
|
155 | + // get template parts |
|
156 | + $template_parts = EED_Events_Archive::instance()->initialize_template_parts($config); |
|
157 | + // convert to array so that we can add more properties |
|
158 | + $config = get_object_vars($config); |
|
159 | + $config['event_archive_display_order'] = $template_parts->generate_sortable_list_of_template_parts( |
|
160 | + 'event-archive-sortable-js', |
|
161 | + '', |
|
162 | + 'archive-sortable-li archive-sortable-js' |
|
163 | + ); |
|
164 | + EEH_Template::display_template( |
|
165 | + EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
166 | + $config |
|
167 | + ); |
|
168 | + } |
|
169 | 169 | |
170 | 170 | |
171 | - /** |
|
172 | - * @param EE_Template_Config $CFG |
|
173 | - * @param array $REQ |
|
174 | - * @return EE_Template_Config |
|
175 | - */ |
|
176 | - public static function update_template_settings($CFG, $REQ) |
|
177 | - { |
|
178 | - /** @var EE_Events_Archive_Config $config */ |
|
179 | - $config = $CFG->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
180 | - ? $CFG->EED_Events_Archive |
|
181 | - : new EE_Events_Archive_Config(); |
|
182 | - // unless we are resetting the config... |
|
183 | - if (! isset($REQ['EED_Events_Archive_reset_event_list_settings']) |
|
184 | - || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1 |
|
185 | - ) { |
|
186 | - $config->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) |
|
187 | - ? absint($REQ['EED_Events_Archive_display_status_banner']) |
|
188 | - : 0; |
|
189 | - $config->display_description = isset($REQ['EED_Events_Archive_display_description']) |
|
190 | - ? absint($REQ['EED_Events_Archive_display_description']) |
|
191 | - : 1; |
|
192 | - $config->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) |
|
193 | - ? absint($REQ['EED_Events_Archive_display_ticket_selector']) |
|
194 | - : 0; |
|
195 | - $config->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) |
|
196 | - ? absint($REQ['EED_Events_Archive_display_datetimes']) |
|
197 | - : 1; |
|
198 | - $config->display_venue = isset($REQ['EED_Events_Archive_display_venue']) |
|
199 | - ? absint($REQ['EED_Events_Archive_display_venue']) |
|
200 | - : 0; |
|
201 | - $config->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) |
|
202 | - ? absint($REQ['EED_Events_Archive_display_expired_events']) |
|
203 | - : 0; |
|
204 | - $config->use_sortable_display_order = isset($REQ['EED_Events_Archive_use_sortable_display_order']) |
|
205 | - ? absint($REQ['EED_Events_Archive_use_sortable_display_order']) |
|
206 | - : 0; |
|
207 | - $config->display_order_event = $config->display_order_event !== null |
|
208 | - && $config->use_sortable_display_order |
|
209 | - ? $config->display_order_event |
|
210 | - : EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
211 | - $config->display_order_datetimes = $config->display_order_datetimes !== null |
|
212 | - && $config->use_sortable_display_order |
|
213 | - ? $config->display_order_datetimes |
|
214 | - : EED_Events_Archive::EVENT_DATETIMES_PRIORITY; |
|
215 | - $config->display_order_tickets = $config->display_order_tickets !== null |
|
216 | - && $config->use_sortable_display_order |
|
217 | - ? $config->display_order_tickets |
|
218 | - : EED_Events_Archive::EVENT_TICKETS_PRIORITY; |
|
219 | - $config->display_order_venue = $config->display_order_venue !== null |
|
220 | - && $config->use_sortable_display_order |
|
221 | - ? $config->display_order_venue |
|
222 | - : EED_Events_Archive::EVENT_VENUES_PRIORITY; |
|
223 | - } |
|
224 | - $CFG->EED_Events_Archive = $config; |
|
225 | - do_action('AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ); |
|
226 | - return $CFG; |
|
227 | - } |
|
171 | + /** |
|
172 | + * @param EE_Template_Config $CFG |
|
173 | + * @param array $REQ |
|
174 | + * @return EE_Template_Config |
|
175 | + */ |
|
176 | + public static function update_template_settings($CFG, $REQ) |
|
177 | + { |
|
178 | + /** @var EE_Events_Archive_Config $config */ |
|
179 | + $config = $CFG->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
180 | + ? $CFG->EED_Events_Archive |
|
181 | + : new EE_Events_Archive_Config(); |
|
182 | + // unless we are resetting the config... |
|
183 | + if (! isset($REQ['EED_Events_Archive_reset_event_list_settings']) |
|
184 | + || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1 |
|
185 | + ) { |
|
186 | + $config->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) |
|
187 | + ? absint($REQ['EED_Events_Archive_display_status_banner']) |
|
188 | + : 0; |
|
189 | + $config->display_description = isset($REQ['EED_Events_Archive_display_description']) |
|
190 | + ? absint($REQ['EED_Events_Archive_display_description']) |
|
191 | + : 1; |
|
192 | + $config->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) |
|
193 | + ? absint($REQ['EED_Events_Archive_display_ticket_selector']) |
|
194 | + : 0; |
|
195 | + $config->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) |
|
196 | + ? absint($REQ['EED_Events_Archive_display_datetimes']) |
|
197 | + : 1; |
|
198 | + $config->display_venue = isset($REQ['EED_Events_Archive_display_venue']) |
|
199 | + ? absint($REQ['EED_Events_Archive_display_venue']) |
|
200 | + : 0; |
|
201 | + $config->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) |
|
202 | + ? absint($REQ['EED_Events_Archive_display_expired_events']) |
|
203 | + : 0; |
|
204 | + $config->use_sortable_display_order = isset($REQ['EED_Events_Archive_use_sortable_display_order']) |
|
205 | + ? absint($REQ['EED_Events_Archive_use_sortable_display_order']) |
|
206 | + : 0; |
|
207 | + $config->display_order_event = $config->display_order_event !== null |
|
208 | + && $config->use_sortable_display_order |
|
209 | + ? $config->display_order_event |
|
210 | + : EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
211 | + $config->display_order_datetimes = $config->display_order_datetimes !== null |
|
212 | + && $config->use_sortable_display_order |
|
213 | + ? $config->display_order_datetimes |
|
214 | + : EED_Events_Archive::EVENT_DATETIMES_PRIORITY; |
|
215 | + $config->display_order_tickets = $config->display_order_tickets !== null |
|
216 | + && $config->use_sortable_display_order |
|
217 | + ? $config->display_order_tickets |
|
218 | + : EED_Events_Archive::EVENT_TICKETS_PRIORITY; |
|
219 | + $config->display_order_venue = $config->display_order_venue !== null |
|
220 | + && $config->use_sortable_display_order |
|
221 | + ? $config->display_order_venue |
|
222 | + : EED_Events_Archive::EVENT_VENUES_PRIORITY; |
|
223 | + } |
|
224 | + $CFG->EED_Events_Archive = $config; |
|
225 | + do_action('AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ); |
|
226 | + return $CFG; |
|
227 | + } |
|
228 | 228 | |
229 | 229 | |
230 | - /** |
|
231 | - * @return void |
|
232 | - * @throws InvalidArgumentException |
|
233 | - * @throws InvalidDataTypeException |
|
234 | - * @throws InvalidInterfaceException |
|
235 | - */ |
|
236 | - public static function update_event_archive_order() |
|
237 | - { |
|
238 | - /** @var EE_Config $config */ |
|
239 | - $config = EE_Registry::instance()->CFG; |
|
240 | - $config_saved = false; |
|
241 | - $template_parts = sanitize_text_field($_POST['elements']); |
|
242 | - if (! empty($template_parts)) { |
|
243 | - $template_parts = explode(',', trim($template_parts, ',')); |
|
244 | - foreach ($template_parts as $key => $template_part) { |
|
245 | - $template_part = "display_order_$template_part"; |
|
246 | - $priority = ($key * 10) + EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
247 | - if ($config->template_settings->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
248 | - && property_exists( |
|
249 | - $config->template_settings->EED_Events_Archive, |
|
250 | - $template_part |
|
251 | - ) |
|
252 | - ) { |
|
253 | - $config->template_settings->EED_Events_Archive->{$template_part} = $priority; |
|
254 | - } |
|
255 | - do_action("AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority); |
|
256 | - } |
|
257 | - $config_saved = $config->update_espresso_config(false, false); |
|
258 | - } |
|
259 | - if ($config_saved) { |
|
260 | - EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso')); |
|
261 | - } else { |
|
262 | - EE_Error::add_error( |
|
263 | - __('Display Order was not updated.', 'event_espresso'), |
|
264 | - __FILE__, |
|
265 | - __FUNCTION__, |
|
266 | - __LINE__ |
|
267 | - ); |
|
268 | - } |
|
269 | - echo wp_json_encode(EE_Error::get_notices(false)); |
|
270 | - exit(); |
|
271 | - } |
|
230 | + /** |
|
231 | + * @return void |
|
232 | + * @throws InvalidArgumentException |
|
233 | + * @throws InvalidDataTypeException |
|
234 | + * @throws InvalidInterfaceException |
|
235 | + */ |
|
236 | + public static function update_event_archive_order() |
|
237 | + { |
|
238 | + /** @var EE_Config $config */ |
|
239 | + $config = EE_Registry::instance()->CFG; |
|
240 | + $config_saved = false; |
|
241 | + $template_parts = sanitize_text_field($_POST['elements']); |
|
242 | + if (! empty($template_parts)) { |
|
243 | + $template_parts = explode(',', trim($template_parts, ',')); |
|
244 | + foreach ($template_parts as $key => $template_part) { |
|
245 | + $template_part = "display_order_$template_part"; |
|
246 | + $priority = ($key * 10) + EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
247 | + if ($config->template_settings->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
248 | + && property_exists( |
|
249 | + $config->template_settings->EED_Events_Archive, |
|
250 | + $template_part |
|
251 | + ) |
|
252 | + ) { |
|
253 | + $config->template_settings->EED_Events_Archive->{$template_part} = $priority; |
|
254 | + } |
|
255 | + do_action("AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority); |
|
256 | + } |
|
257 | + $config_saved = $config->update_espresso_config(false, false); |
|
258 | + } |
|
259 | + if ($config_saved) { |
|
260 | + EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso')); |
|
261 | + } else { |
|
262 | + EE_Error::add_error( |
|
263 | + __('Display Order was not updated.', 'event_espresso'), |
|
264 | + __FILE__, |
|
265 | + __FUNCTION__, |
|
266 | + __LINE__ |
|
267 | + ); |
|
268 | + } |
|
269 | + echo wp_json_encode(EE_Error::get_notices(false)); |
|
270 | + exit(); |
|
271 | + } |
|
272 | 272 | } |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public static function setDefinitions() |
81 | 81 | { |
82 | - if (! defined('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH')) { |
|
82 | + if ( ! defined('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH')) { |
|
83 | 83 | define( |
84 | 84 | 'EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', |
85 | - str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates/' |
|
85 | + str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates/' |
|
86 | 86 | ); |
87 | - define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
87 | + define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets/'); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | 'archive-sortable-li archive-sortable-js' |
163 | 163 | ); |
164 | 164 | EEH_Template::display_template( |
165 | - EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
165 | + EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH.'admin-event-list-settings.template.php', |
|
166 | 166 | $config |
167 | 167 | ); |
168 | 168 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | ? $CFG->EED_Events_Archive |
181 | 181 | : new EE_Events_Archive_Config(); |
182 | 182 | // unless we are resetting the config... |
183 | - if (! isset($REQ['EED_Events_Archive_reset_event_list_settings']) |
|
183 | + if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) |
|
184 | 184 | || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1 |
185 | 185 | ) { |
186 | 186 | $config->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $config = EE_Registry::instance()->CFG; |
240 | 240 | $config_saved = false; |
241 | 241 | $template_parts = sanitize_text_field($_POST['elements']); |
242 | - if (! empty($template_parts)) { |
|
242 | + if ( ! empty($template_parts)) { |
|
243 | 243 | $template_parts = explode(',', trim($template_parts, ',')); |
244 | 244 | foreach ($template_parts as $key => $template_part) { |
245 | 245 | $template_part = "display_order_$template_part"; |
@@ -15,249 +15,249 @@ |
||
15 | 15 | */ |
16 | 16 | class EED_Mijireh_Slurper extends EED_Module |
17 | 17 | { |
18 | - const slurp_started_transient_name = 'ee_mijireh_slurp_started'; |
|
19 | - const mijireh_slurper_shortcode = '{{mj-checkout-form}}'; |
|
18 | + const slurp_started_transient_name = 'ee_mijireh_slurp_started'; |
|
19 | + const mijireh_slurper_shortcode = '{{mj-checkout-form}}'; |
|
20 | 20 | |
21 | - /** |
|
22 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
23 | - * |
|
24 | - * @access public |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public static function set_hooks() |
|
28 | - { |
|
29 | - } |
|
21 | + /** |
|
22 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
23 | + * |
|
24 | + * @access public |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public static function set_hooks() |
|
28 | + { |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
33 | - * MIjireh Slurper module mostly just detects a special request on the EE payment methods page |
|
34 | - * to perform a redirect to a slurping page; detects a special request on the post.php editing page to |
|
35 | - * initiate slurping into mijireh; and adds a metabox to the post.php editing page when mijireh's special |
|
36 | - * shortcode is present |
|
37 | - * |
|
38 | - * @access public |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - public static function set_hooks_admin() |
|
42 | - { |
|
43 | - define('EED_MIJIREH_SLURPER_PATH', EE_CAFF_PATH . 'modules/' . 'mijireh_slurper/'); |
|
44 | - add_action('load-post.php', array('EED_Mijireh_Slurper', 'set_edit_post_page_hooks')); |
|
45 | - add_action('load-admin.php', array('EED_Mijireh_Slurper', 'check_for_edit_slurp_page')); |
|
46 | - add_action('AHEE__EE_Mijireh__settings_end', array('EED_Mijireh_Slurper', 'add_slurp_link_to_gateway')); |
|
47 | - } |
|
31 | + /** |
|
32 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
33 | + * MIjireh Slurper module mostly just detects a special request on the EE payment methods page |
|
34 | + * to perform a redirect to a slurping page; detects a special request on the post.php editing page to |
|
35 | + * initiate slurping into mijireh; and adds a metabox to the post.php editing page when mijireh's special |
|
36 | + * shortcode is present |
|
37 | + * |
|
38 | + * @access public |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + public static function set_hooks_admin() |
|
42 | + { |
|
43 | + define('EED_MIJIREH_SLURPER_PATH', EE_CAFF_PATH . 'modules/' . 'mijireh_slurper/'); |
|
44 | + add_action('load-post.php', array('EED_Mijireh_Slurper', 'set_edit_post_page_hooks')); |
|
45 | + add_action('load-admin.php', array('EED_Mijireh_Slurper', 'check_for_edit_slurp_page')); |
|
46 | + add_action('AHEE__EE_Mijireh__settings_end', array('EED_Mijireh_Slurper', 'add_slurp_link_to_gateway')); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Merely used to avoid even bothering to add these hooks on pages besides admin's post.php |
|
51 | - */ |
|
52 | - public static function set_edit_post_page_hooks() |
|
53 | - { |
|
54 | - add_action('add_meta_boxes', array('EED_Mijireh_Slurper', 'add_slurp_page_metabox')); |
|
55 | - add_action('posts_selection', array('EED_Mijireh_Slurper', 'slurp_or_not')); |
|
56 | - if (get_transient(EED_Mijireh_Slurper::slurp_started_transient_name)) { |
|
57 | - add_action('admin_notices', array('EED_Mijireh_Slurper', 'slurping_in_progress_notice')); |
|
58 | - delete_transient(EED_Mijireh_Slurper::slurp_started_transient_name); |
|
59 | - } |
|
60 | - } |
|
49 | + /** |
|
50 | + * Merely used to avoid even bothering to add these hooks on pages besides admin's post.php |
|
51 | + */ |
|
52 | + public static function set_edit_post_page_hooks() |
|
53 | + { |
|
54 | + add_action('add_meta_boxes', array('EED_Mijireh_Slurper', 'add_slurp_page_metabox')); |
|
55 | + add_action('posts_selection', array('EED_Mijireh_Slurper', 'slurp_or_not')); |
|
56 | + if (get_transient(EED_Mijireh_Slurper::slurp_started_transient_name)) { |
|
57 | + add_action('admin_notices', array('EED_Mijireh_Slurper', 'slurping_in_progress_notice')); |
|
58 | + delete_transient(EED_Mijireh_Slurper::slurp_started_transient_name); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Adds the slurping content to the gateway's settings page, because I thought this was best suited to remain in |
|
64 | - * the module's code (because the gateway works fine independent of this module) |
|
65 | - */ |
|
66 | - public static function add_slurp_link_to_gateway($existing_content) |
|
67 | - { |
|
68 | - echo EEH_Template::display_template( |
|
69 | - EED_MIJIREH_SLURPER_PATH . 'templates/additional_content_on_gateway.template.php', |
|
70 | - array(), |
|
71 | - true |
|
72 | - ) . $existing_content; |
|
73 | - } |
|
62 | + /** |
|
63 | + * Adds the slurping content to the gateway's settings page, because I thought this was best suited to remain in |
|
64 | + * the module's code (because the gateway works fine independent of this module) |
|
65 | + */ |
|
66 | + public static function add_slurp_link_to_gateway($existing_content) |
|
67 | + { |
|
68 | + echo EEH_Template::display_template( |
|
69 | + EED_MIJIREH_SLURPER_PATH . 'templates/additional_content_on_gateway.template.php', |
|
70 | + array(), |
|
71 | + true |
|
72 | + ) . $existing_content; |
|
73 | + } |
|
74 | 74 | |
75 | - public static function slurping_in_progress_notice() |
|
76 | - { |
|
77 | - EEH_Template::display_template( |
|
78 | - EED_MIJIREH_SLURPER_PATH . 'templates/slurping_in_progress_notice.template.php', |
|
79 | - array() |
|
80 | - ); |
|
81 | - } |
|
75 | + public static function slurping_in_progress_notice() |
|
76 | + { |
|
77 | + EEH_Template::display_template( |
|
78 | + EED_MIJIREH_SLURPER_PATH . 'templates/slurping_in_progress_notice.template.php', |
|
79 | + array() |
|
80 | + ); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Inspects the request's querystring for a special arg indicating to forward the user onto the mijireh slurp page |
|
85 | - * (we do it this way, instead of just directly putting a link to the page in the anchor tag, because the page |
|
86 | - * might not exist yet, in whcih case we need to first make it). If the special arg is present, redirects the user |
|
87 | - * to the slurp page's edit page |
|
88 | - * |
|
89 | - * @return void |
|
90 | - */ |
|
91 | - public static function check_for_edit_slurp_page() |
|
92 | - { |
|
93 | - if (isset($_GET['mijireh_edit_slurp_page']) && $_GET['mijireh_edit_slurp_page'] == 'true') { |
|
94 | - // check if we already have a slurping page |
|
95 | - if (! $slurp_page_id = self::find_slurp_page()) { |
|
96 | - // if no slurp page yet, make one |
|
97 | - $slurp_page_id = wp_insert_post( |
|
98 | - array( |
|
99 | - 'post_title' => __("Mijireh Slurping Page", 'event_espresso'), |
|
100 | - 'post_content' => EED_Mijireh_Slurper::mijireh_slurper_shortcode, |
|
101 | - 'post_type' => 'page', |
|
102 | - ) |
|
103 | - ); |
|
104 | - } |
|
105 | - wp_redirect(add_query_arg(array('post' => $slurp_page_id, 'action' => 'edit'), admin_url('post.php'))); |
|
106 | - } |
|
107 | - } |
|
83 | + /** |
|
84 | + * Inspects the request's querystring for a special arg indicating to forward the user onto the mijireh slurp page |
|
85 | + * (we do it this way, instead of just directly putting a link to the page in the anchor tag, because the page |
|
86 | + * might not exist yet, in whcih case we need to first make it). If the special arg is present, redirects the user |
|
87 | + * to the slurp page's edit page |
|
88 | + * |
|
89 | + * @return void |
|
90 | + */ |
|
91 | + public static function check_for_edit_slurp_page() |
|
92 | + { |
|
93 | + if (isset($_GET['mijireh_edit_slurp_page']) && $_GET['mijireh_edit_slurp_page'] == 'true') { |
|
94 | + // check if we already have a slurping page |
|
95 | + if (! $slurp_page_id = self::find_slurp_page()) { |
|
96 | + // if no slurp page yet, make one |
|
97 | + $slurp_page_id = wp_insert_post( |
|
98 | + array( |
|
99 | + 'post_title' => __("Mijireh Slurping Page", 'event_espresso'), |
|
100 | + 'post_content' => EED_Mijireh_Slurper::mijireh_slurper_shortcode, |
|
101 | + 'post_type' => 'page', |
|
102 | + ) |
|
103 | + ); |
|
104 | + } |
|
105 | + wp_redirect(add_query_arg(array('post' => $slurp_page_id, 'action' => 'edit'), admin_url('post.php'))); |
|
106 | + } |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Gets the post id which has the {{mj-checkout-form}} "shortcode" in it, otherwise null |
|
111 | - * |
|
112 | - * @return int |
|
113 | - */ |
|
114 | - public static function find_slurp_page() |
|
115 | - { |
|
116 | - global $wpdb; |
|
117 | - return $wpdb->get_var( |
|
118 | - "SELECT id FROM {$wpdb->posts} WHERE post_content LIKE '%" . EED_Mijireh_Slurper::mijireh_slurper_shortcode . "%'" |
|
119 | - ); |
|
120 | - } |
|
109 | + /** |
|
110 | + * Gets the post id which has the {{mj-checkout-form}} "shortcode" in it, otherwise null |
|
111 | + * |
|
112 | + * @return int |
|
113 | + */ |
|
114 | + public static function find_slurp_page() |
|
115 | + { |
|
116 | + global $wpdb; |
|
117 | + return $wpdb->get_var( |
|
118 | + "SELECT id FROM {$wpdb->posts} WHERE post_content LIKE '%" . EED_Mijireh_Slurper::mijireh_slurper_shortcode . "%'" |
|
119 | + ); |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Return true if the current page is the mijireh checkout page, otherwise return false. |
|
124 | - * |
|
125 | - * @return boolean |
|
126 | - */ |
|
127 | - public static function is_slurp_page() |
|
128 | - { |
|
129 | - global $post; |
|
130 | - $isSlurp = false; |
|
131 | - if (isset($post) && is_object($post)) { |
|
132 | - $content = $post->post_content; |
|
133 | - if (strpos($content, EED_Mijireh_Slurper::mijireh_slurper_shortcode) !== false) { |
|
134 | - $isSlurp = true; |
|
135 | - } |
|
136 | - } else { |
|
137 | - // echo '[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Check Slurp Page Failed: " . print_r($post, 1); |
|
138 | - } |
|
139 | - return $isSlurp; |
|
140 | - } |
|
122 | + /** |
|
123 | + * Return true if the current page is the mijireh checkout page, otherwise return false. |
|
124 | + * |
|
125 | + * @return boolean |
|
126 | + */ |
|
127 | + public static function is_slurp_page() |
|
128 | + { |
|
129 | + global $post; |
|
130 | + $isSlurp = false; |
|
131 | + if (isset($post) && is_object($post)) { |
|
132 | + $content = $post->post_content; |
|
133 | + if (strpos($content, EED_Mijireh_Slurper::mijireh_slurper_shortcode) !== false) { |
|
134 | + $isSlurp = true; |
|
135 | + } |
|
136 | + } else { |
|
137 | + // echo '[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Check Slurp Page Failed: " . print_r($post, 1); |
|
138 | + } |
|
139 | + return $isSlurp; |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * adds the callback to adding the slurp page metabox, which shoudl only appear on a page with the |
|
144 | - * {{mj-checkout-form}} "shortcode" |
|
145 | - * |
|
146 | - * @return void |
|
147 | - */ |
|
148 | - public static function add_slurp_page_metabox() |
|
149 | - { |
|
150 | - if (self::is_slurp_page() |
|
151 | - && EEM_Payment_Method::instance()->get_one_active( |
|
152 | - EEM_Payment_Method::scope_cart, |
|
153 | - array(array('PMD_type' => 'Mijireh')) |
|
154 | - )) { |
|
155 | - add_meta_box( |
|
156 | - 'slurp_meta_box', // $id |
|
157 | - 'Mijireh Page Slurp', // $title |
|
158 | - array('EED_Mijireh_Slurper', 'slurp_page_metabox'), // $callback |
|
159 | - 'page', // $page |
|
160 | - 'normal', // $context |
|
161 | - 'high' |
|
162 | - ); // $priority |
|
163 | - } |
|
164 | - } |
|
142 | + /** |
|
143 | + * adds the callback to adding the slurp page metabox, which shoudl only appear on a page with the |
|
144 | + * {{mj-checkout-form}} "shortcode" |
|
145 | + * |
|
146 | + * @return void |
|
147 | + */ |
|
148 | + public static function add_slurp_page_metabox() |
|
149 | + { |
|
150 | + if (self::is_slurp_page() |
|
151 | + && EEM_Payment_Method::instance()->get_one_active( |
|
152 | + EEM_Payment_Method::scope_cart, |
|
153 | + array(array('PMD_type' => 'Mijireh')) |
|
154 | + )) { |
|
155 | + add_meta_box( |
|
156 | + 'slurp_meta_box', // $id |
|
157 | + 'Mijireh Page Slurp', // $title |
|
158 | + array('EED_Mijireh_Slurper', 'slurp_page_metabox'), // $callback |
|
159 | + 'page', // $page |
|
160 | + 'normal', // $context |
|
161 | + 'high' |
|
162 | + ); // $priority |
|
163 | + } |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * outputs HTML for displaying the slurping metabox |
|
168 | - * |
|
169 | - * @param WP_Post $post |
|
170 | - * @return void echoes out html |
|
171 | - */ |
|
172 | - public static function slurp_page_metabox($post) |
|
173 | - { |
|
174 | - global $wp; |
|
175 | - $mijireh_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Mijireh'); |
|
176 | - if ($mijireh_payment_method) { |
|
177 | - $access_key = $mijireh_payment_method->get_extra_meta('access_key', true); |
|
178 | - EEH_Template::display_template( |
|
179 | - EED_MIJIREH_SLURPER_PATH . 'templates/mijireh_slurp_page_metabox.template.php', |
|
180 | - array( |
|
181 | - 'mijireh_image_url' => $mijireh_payment_method->button_url(), |
|
182 | - 'access_key' => $access_key, |
|
183 | - 'slurp_action_link' => esc_url_raw( |
|
184 | - add_query_arg( |
|
185 | - 'mijireh_slurp_now', |
|
186 | - 'true', |
|
187 | - add_query_arg($wp->query_string, '', '?' . $_SERVER['QUERY_STRING']) |
|
188 | - ) |
|
189 | - ), |
|
190 | - ) |
|
191 | - ); |
|
192 | - } |
|
193 | - } |
|
166 | + /** |
|
167 | + * outputs HTML for displaying the slurping metabox |
|
168 | + * |
|
169 | + * @param WP_Post $post |
|
170 | + * @return void echoes out html |
|
171 | + */ |
|
172 | + public static function slurp_page_metabox($post) |
|
173 | + { |
|
174 | + global $wp; |
|
175 | + $mijireh_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Mijireh'); |
|
176 | + if ($mijireh_payment_method) { |
|
177 | + $access_key = $mijireh_payment_method->get_extra_meta('access_key', true); |
|
178 | + EEH_Template::display_template( |
|
179 | + EED_MIJIREH_SLURPER_PATH . 'templates/mijireh_slurp_page_metabox.template.php', |
|
180 | + array( |
|
181 | + 'mijireh_image_url' => $mijireh_payment_method->button_url(), |
|
182 | + 'access_key' => $access_key, |
|
183 | + 'slurp_action_link' => esc_url_raw( |
|
184 | + add_query_arg( |
|
185 | + 'mijireh_slurp_now', |
|
186 | + 'true', |
|
187 | + add_query_arg($wp->query_string, '', '?' . $_SERVER['QUERY_STRING']) |
|
188 | + ) |
|
189 | + ), |
|
190 | + ) |
|
191 | + ); |
|
192 | + } |
|
193 | + } |
|
194 | 194 | |
195 | - /** |
|
196 | - * decides whether to slurp the post indicated by the $post global or not, based entirely |
|
197 | - * on a special arg being in the querystring |
|
198 | - * |
|
199 | - * @return void |
|
200 | - */ |
|
201 | - public static function slurp_or_not() |
|
202 | - { |
|
203 | - // check if this page has the right mijire 'shortcode' and if they've specified to slurp it |
|
204 | - if (isset($_GET['mijireh_slurp_now']) |
|
205 | - && $_GET['mijireh_slurp_now'] == 'true' |
|
206 | - && EED_Mijireh_Slurper::is_slurp_page() |
|
207 | - ) { |
|
208 | - EED_Mijireh_Slurper::slurp_now(); |
|
209 | - } |
|
210 | - } |
|
195 | + /** |
|
196 | + * decides whether to slurp the post indicated by the $post global or not, based entirely |
|
197 | + * on a special arg being in the querystring |
|
198 | + * |
|
199 | + * @return void |
|
200 | + */ |
|
201 | + public static function slurp_or_not() |
|
202 | + { |
|
203 | + // check if this page has the right mijire 'shortcode' and if they've specified to slurp it |
|
204 | + if (isset($_GET['mijireh_slurp_now']) |
|
205 | + && $_GET['mijireh_slurp_now'] == 'true' |
|
206 | + && EED_Mijireh_Slurper::is_slurp_page() |
|
207 | + ) { |
|
208 | + EED_Mijireh_Slurper::slurp_now(); |
|
209 | + } |
|
210 | + } |
|
211 | 211 | |
212 | - /** |
|
213 | - * Sends a request to mijireh to slurp the current $post, and then redirects the user back to the current page |
|
214 | - * without the special querystring arg indicating to slurp. Also, should temporarily make the current post |
|
215 | - * published, then revert it to its previous status |
|
216 | - */ |
|
217 | - public static function slurp_now() |
|
218 | - { |
|
219 | - global $post; |
|
220 | - if ($post->post_status != 'publish') { |
|
221 | - // make sure the post is published at least while slurping |
|
222 | - $post->post_status = 'publish'; |
|
223 | - wp_update_post($post); |
|
224 | - } |
|
225 | - $mijireh_gateway = EEM_Payment_Method::instance()->get_one_of_type('Mijireh'); |
|
226 | - $access_key = $mijireh_gateway->get_extra_meta('access_key', true); |
|
227 | - // 'slurp_url'=>get_permalink($post), |
|
228 | - // 'page_id'=>$post->ID, |
|
229 | - // 'return_url'=>$return_url |
|
230 | - $url = 'https://secure.mijireh.com/api/1/slurps'; |
|
231 | - $args = array( |
|
232 | - 'headers' => array( |
|
233 | - 'Authorization' => 'Basic ' . base64_encode($access_key . ':'), |
|
234 | - 'Accept' => 'application/json', |
|
235 | - ), |
|
236 | - 'body' => wp_json_encode( |
|
237 | - array( |
|
238 | - 'url' => get_permalink($post->ID), |
|
239 | - 'page_id' => $post->ID, |
|
240 | - 'return_url' => '', |
|
241 | - ) |
|
242 | - ), |
|
243 | - ); |
|
244 | - $response = wp_remote_post($url, $args); |
|
245 | - // now redirect the user back to the same page |
|
246 | - $redirect_args = $_GET; |
|
247 | - unset($redirect_args['mijireh_slurp_now']); |
|
248 | - $url = add_query_arg($redirect_args, admin_url('post.php')); |
|
249 | - set_transient(EED_Mijireh_Slurper::slurp_started_transient_name, true); |
|
250 | - // echo "redirect to $url"; |
|
251 | - wp_redirect($url); |
|
252 | - } |
|
212 | + /** |
|
213 | + * Sends a request to mijireh to slurp the current $post, and then redirects the user back to the current page |
|
214 | + * without the special querystring arg indicating to slurp. Also, should temporarily make the current post |
|
215 | + * published, then revert it to its previous status |
|
216 | + */ |
|
217 | + public static function slurp_now() |
|
218 | + { |
|
219 | + global $post; |
|
220 | + if ($post->post_status != 'publish') { |
|
221 | + // make sure the post is published at least while slurping |
|
222 | + $post->post_status = 'publish'; |
|
223 | + wp_update_post($post); |
|
224 | + } |
|
225 | + $mijireh_gateway = EEM_Payment_Method::instance()->get_one_of_type('Mijireh'); |
|
226 | + $access_key = $mijireh_gateway->get_extra_meta('access_key', true); |
|
227 | + // 'slurp_url'=>get_permalink($post), |
|
228 | + // 'page_id'=>$post->ID, |
|
229 | + // 'return_url'=>$return_url |
|
230 | + $url = 'https://secure.mijireh.com/api/1/slurps'; |
|
231 | + $args = array( |
|
232 | + 'headers' => array( |
|
233 | + 'Authorization' => 'Basic ' . base64_encode($access_key . ':'), |
|
234 | + 'Accept' => 'application/json', |
|
235 | + ), |
|
236 | + 'body' => wp_json_encode( |
|
237 | + array( |
|
238 | + 'url' => get_permalink($post->ID), |
|
239 | + 'page_id' => $post->ID, |
|
240 | + 'return_url' => '', |
|
241 | + ) |
|
242 | + ), |
|
243 | + ); |
|
244 | + $response = wp_remote_post($url, $args); |
|
245 | + // now redirect the user back to the same page |
|
246 | + $redirect_args = $_GET; |
|
247 | + unset($redirect_args['mijireh_slurp_now']); |
|
248 | + $url = add_query_arg($redirect_args, admin_url('post.php')); |
|
249 | + set_transient(EED_Mijireh_Slurper::slurp_started_transient_name, true); |
|
250 | + // echo "redirect to $url"; |
|
251 | + wp_redirect($url); |
|
252 | + } |
|
253 | 253 | |
254 | - /** |
|
255 | - * run - initial module setup |
|
256 | - * |
|
257 | - * @access public |
|
258 | - * @return void |
|
259 | - */ |
|
260 | - public function run($WP) |
|
261 | - { |
|
262 | - } |
|
254 | + /** |
|
255 | + * run - initial module setup |
|
256 | + * |
|
257 | + * @access public |
|
258 | + * @return void |
|
259 | + */ |
|
260 | + public function run($WP) |
|
261 | + { |
|
262 | + } |
|
263 | 263 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public static function set_hooks_admin() |
42 | 42 | { |
43 | - define('EED_MIJIREH_SLURPER_PATH', EE_CAFF_PATH . 'modules/' . 'mijireh_slurper/'); |
|
43 | + define('EED_MIJIREH_SLURPER_PATH', EE_CAFF_PATH.'modules/'.'mijireh_slurper/'); |
|
44 | 44 | add_action('load-post.php', array('EED_Mijireh_Slurper', 'set_edit_post_page_hooks')); |
45 | 45 | add_action('load-admin.php', array('EED_Mijireh_Slurper', 'check_for_edit_slurp_page')); |
46 | 46 | add_action('AHEE__EE_Mijireh__settings_end', array('EED_Mijireh_Slurper', 'add_slurp_link_to_gateway')); |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | public static function add_slurp_link_to_gateway($existing_content) |
67 | 67 | { |
68 | 68 | echo EEH_Template::display_template( |
69 | - EED_MIJIREH_SLURPER_PATH . 'templates/additional_content_on_gateway.template.php', |
|
69 | + EED_MIJIREH_SLURPER_PATH.'templates/additional_content_on_gateway.template.php', |
|
70 | 70 | array(), |
71 | 71 | true |
72 | - ) . $existing_content; |
|
72 | + ).$existing_content; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | public static function slurping_in_progress_notice() |
76 | 76 | { |
77 | 77 | EEH_Template::display_template( |
78 | - EED_MIJIREH_SLURPER_PATH . 'templates/slurping_in_progress_notice.template.php', |
|
78 | + EED_MIJIREH_SLURPER_PATH.'templates/slurping_in_progress_notice.template.php', |
|
79 | 79 | array() |
80 | 80 | ); |
81 | 81 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | if (isset($_GET['mijireh_edit_slurp_page']) && $_GET['mijireh_edit_slurp_page'] == 'true') { |
94 | 94 | // check if we already have a slurping page |
95 | - if (! $slurp_page_id = self::find_slurp_page()) { |
|
95 | + if ( ! $slurp_page_id = self::find_slurp_page()) { |
|
96 | 96 | // if no slurp page yet, make one |
97 | 97 | $slurp_page_id = wp_insert_post( |
98 | 98 | array( |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | { |
116 | 116 | global $wpdb; |
117 | 117 | return $wpdb->get_var( |
118 | - "SELECT id FROM {$wpdb->posts} WHERE post_content LIKE '%" . EED_Mijireh_Slurper::mijireh_slurper_shortcode . "%'" |
|
118 | + "SELECT id FROM {$wpdb->posts} WHERE post_content LIKE '%".EED_Mijireh_Slurper::mijireh_slurper_shortcode."%'" |
|
119 | 119 | ); |
120 | 120 | } |
121 | 121 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | if ($mijireh_payment_method) { |
177 | 177 | $access_key = $mijireh_payment_method->get_extra_meta('access_key', true); |
178 | 178 | EEH_Template::display_template( |
179 | - EED_MIJIREH_SLURPER_PATH . 'templates/mijireh_slurp_page_metabox.template.php', |
|
179 | + EED_MIJIREH_SLURPER_PATH.'templates/mijireh_slurp_page_metabox.template.php', |
|
180 | 180 | array( |
181 | 181 | 'mijireh_image_url' => $mijireh_payment_method->button_url(), |
182 | 182 | 'access_key' => $access_key, |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | add_query_arg( |
185 | 185 | 'mijireh_slurp_now', |
186 | 186 | 'true', |
187 | - add_query_arg($wp->query_string, '', '?' . $_SERVER['QUERY_STRING']) |
|
187 | + add_query_arg($wp->query_string, '', '?'.$_SERVER['QUERY_STRING']) |
|
188 | 188 | ) |
189 | 189 | ), |
190 | 190 | ) |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $url = 'https://secure.mijireh.com/api/1/slurps'; |
231 | 231 | $args = array( |
232 | 232 | 'headers' => array( |
233 | - 'Authorization' => 'Basic ' . base64_encode($access_key . ':'), |
|
233 | + 'Authorization' => 'Basic '.base64_encode($access_key.':'), |
|
234 | 234 | 'Accept' => 'application/json', |
235 | 235 | ), |
236 | 236 | 'body' => wp_json_encode( |
@@ -27,322 +27,322 @@ |
||
27 | 27 | class EE_Brewing_Regular extends EE_BASE implements InterminableInterface |
28 | 28 | { |
29 | 29 | |
30 | - /** |
|
31 | - * @var TableAnalysis $table_analysis |
|
32 | - */ |
|
33 | - protected $_table_analysis; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * EE_Brewing_Regular constructor. |
|
38 | - * |
|
39 | - * @param TableAnalysis $table_analysis |
|
40 | - */ |
|
41 | - public function __construct(TableAnalysis $table_analysis) |
|
42 | - { |
|
43 | - $this->_table_analysis = $table_analysis; |
|
44 | - if (defined('EE_CAFF_PATH')) { |
|
45 | - $this->setInitializationHooks(); |
|
46 | - $this->setApiRegistrationHooks(); |
|
47 | - $this->setSwitchHooks(); |
|
48 | - $this->setDefaultFilterHooks(); |
|
49 | - // caffeinated constructed |
|
50 | - do_action('AHEE__EE_Brewing_Regular__construct__complete'); |
|
51 | - } |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * Various hooks used for extending features via registration of modules or extensions. |
|
57 | - */ |
|
58 | - private function setApiRegistrationHooks() |
|
59 | - { |
|
60 | - add_filter( |
|
61 | - 'FHEE__EE_Config__register_modules__modules_to_register', |
|
62 | - array($this, 'caffeinated_modules_to_register') |
|
63 | - ); |
|
64 | - add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10); |
|
65 | - add_filter( |
|
66 | - 'AHEE__EE_System__load_core_configuration__complete', |
|
67 | - function () { |
|
68 | - EE_Register_Payment_Method::register( |
|
69 | - 'caffeinated_payment_methods', |
|
70 | - array( |
|
71 | - 'payment_method_paths' => glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR), |
|
72 | - ) |
|
73 | - ); |
|
74 | - } |
|
75 | - ); |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * Various hooks used for modifying initialization or activation processes. |
|
81 | - */ |
|
82 | - private function setInitializationHooks() |
|
83 | - { |
|
84 | - // activation |
|
85 | - add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content')); |
|
86 | - // load caff init |
|
87 | - add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init')); |
|
88 | - // load caff scripts |
|
89 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Various hooks used for switch (on/off) type filters. |
|
95 | - */ |
|
96 | - private function setSwitchHooks() |
|
97 | - { |
|
98 | - // remove the "powered by" credit link from receipts and invoices |
|
99 | - add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false'); |
|
100 | - // seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer |
|
101 | - add_filter('FHEE__ee_show_affiliate_links', '__return_false'); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * Various filters for affecting default configuration values in the caffeinated |
|
107 | - * context. |
|
108 | - */ |
|
109 | - private function setDefaultFilterHooks() |
|
110 | - { |
|
111 | - add_filter( |
|
112 | - 'FHEE__EE_Admin_Config__show_reg_footer__default', |
|
113 | - '__return_true' |
|
114 | - ); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * callback for the FHEE__EE_Registry__load_helper__helper_paths filter to add the caffeinated paths |
|
120 | - * |
|
121 | - * @param array $paths original helper paths array |
|
122 | - * @return array new array of paths |
|
123 | - */ |
|
124 | - public function caf_helper_paths($paths) |
|
125 | - { |
|
126 | - $paths[] = EE_CAF_CORE . 'helpers/'; |
|
127 | - return $paths; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * Upon brand-new activation, if this is a new activation of CAF, we want to add |
|
133 | - * some global prices that will show off EE4's capabilities. However, if they're upgrading |
|
134 | - * from 3.1, or simply EE4.x decaf, we assume they don't want us to suddenly introduce these extra prices. |
|
135 | - * This action should only be called when EE 4.x.0.P is initially activated. |
|
136 | - * Right now the only CAF content are these global prices. If there's more in the future, then |
|
137 | - * we should probably create a caf file to contain it all instead just a function like this. |
|
138 | - * Right now, we ASSUME the only price types in the system are default ones |
|
139 | - * |
|
140 | - * @global wpdb $wpdb |
|
141 | - */ |
|
142 | - public function initialize_caf_db_content() |
|
143 | - { |
|
144 | - global $wpdb; |
|
145 | - // use same method of getting creator id as the version introducing the change |
|
146 | - $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id()); |
|
147 | - $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
148 | - $price_table = $wpdb->prefix . "esp_price"; |
|
149 | - if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
150 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';// include trashed price types |
|
151 | - $tax_price_type_count = $wpdb->get_var($SQL); |
|
152 | - if ($tax_price_type_count <= 1) { |
|
153 | - $wpdb->insert( |
|
154 | - $price_type_table, |
|
155 | - array( |
|
156 | - 'PRT_name' => __("Regional Tax", "event_espresso"), |
|
157 | - 'PBT_ID' => 4, |
|
158 | - 'PRT_is_percent' => true, |
|
159 | - 'PRT_order' => 60, |
|
160 | - 'PRT_deleted' => false, |
|
161 | - 'PRT_wp_user' => $default_creator_id, |
|
162 | - ), |
|
163 | - array( |
|
164 | - '%s',// PRT_name |
|
165 | - '%d',// PBT_id |
|
166 | - '%d',// PRT_is_percent |
|
167 | - '%d',// PRT_order |
|
168 | - '%d',// PRT_deleted |
|
169 | - '%d', // PRT_wp_user |
|
170 | - ) |
|
171 | - ); |
|
172 | - // federal tax |
|
173 | - $result = $wpdb->insert( |
|
174 | - $price_type_table, |
|
175 | - array( |
|
176 | - 'PRT_name' => __("Federal Tax", "event_espresso"), |
|
177 | - 'PBT_ID' => 4, |
|
178 | - 'PRT_is_percent' => true, |
|
179 | - 'PRT_order' => 70, |
|
180 | - 'PRT_deleted' => false, |
|
181 | - 'PRT_wp_user' => $default_creator_id, |
|
182 | - ), |
|
183 | - array( |
|
184 | - '%s',// PRT_name |
|
185 | - '%d',// PBT_id |
|
186 | - '%d',// PRT_is_percent |
|
187 | - '%d',// PRT_order |
|
188 | - '%d',// PRT_deleted |
|
189 | - '%d' // PRT_wp_user |
|
190 | - ) |
|
191 | - ); |
|
192 | - if ($result) { |
|
193 | - $wpdb->insert( |
|
194 | - $price_table, |
|
195 | - array( |
|
196 | - 'PRT_ID' => $wpdb->insert_id, |
|
197 | - 'PRC_amount' => 15.00, |
|
198 | - 'PRC_name' => __("Sales Tax", "event_espresso"), |
|
199 | - 'PRC_desc' => '', |
|
200 | - 'PRC_is_default' => true, |
|
201 | - 'PRC_overrides' => null, |
|
202 | - 'PRC_deleted' => false, |
|
203 | - 'PRC_order' => 50, |
|
204 | - 'PRC_parent' => null, |
|
205 | - 'PRC_wp_user' => $default_creator_id, |
|
206 | - ), |
|
207 | - array( |
|
208 | - '%d',// PRT_id |
|
209 | - '%f',// PRC_amount |
|
210 | - '%s',// PRC_name |
|
211 | - '%s',// PRC_desc |
|
212 | - '%d',// PRC_is_default |
|
213 | - '%d',// PRC_overrides |
|
214 | - '%d',// PRC_deleted |
|
215 | - '%d',// PRC_order |
|
216 | - '%d',// PRC_parent |
|
217 | - '%d' // PRC_wp_user |
|
218 | - ) |
|
219 | - ); |
|
220 | - } |
|
221 | - } |
|
222 | - } |
|
223 | - } |
|
224 | - |
|
225 | - |
|
226 | - /** |
|
227 | - * caffeinated_modules_to_register |
|
228 | - * |
|
229 | - * @access public |
|
230 | - * @param array $modules_to_register |
|
231 | - * @return array |
|
232 | - */ |
|
233 | - public function caffeinated_modules_to_register($modules_to_register = array()) |
|
234 | - { |
|
235 | - if (is_readable(EE_CAFF_PATH . 'modules')) { |
|
236 | - $caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules/*', GLOB_ONLYDIR); |
|
237 | - if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) { |
|
238 | - $modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register); |
|
239 | - } |
|
240 | - } |
|
241 | - return $modules_to_register; |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * @throws EE_Error |
|
247 | - * @throws InvalidArgumentException |
|
248 | - * @throws ReflectionException |
|
249 | - * @throws InvalidDataTypeException |
|
250 | - * @throws InvalidInterfaceException |
|
251 | - */ |
|
252 | - public function caffeinated_init() |
|
253 | - { |
|
254 | - // Custom Post Type hooks |
|
255 | - add_filter( |
|
256 | - 'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies', |
|
257 | - array($this, 'filter_taxonomies') |
|
258 | - ); |
|
259 | - add_filter( |
|
260 | - 'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes', |
|
261 | - array($this, 'filter_cpts') |
|
262 | - ); |
|
263 | - add_filter( |
|
264 | - 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', |
|
265 | - array($this, 'nav_metabox_items') |
|
266 | - ); |
|
267 | - EE_Registry::instance()->load_file( |
|
268 | - EE_CAFF_PATH, |
|
269 | - 'EE_Caf_Messages', |
|
270 | - 'class', |
|
271 | - array(), |
|
272 | - false |
|
273 | - ); |
|
274 | - // caffeinated_init__complete hook |
|
275 | - do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete'); |
|
276 | - } |
|
277 | - |
|
278 | - |
|
279 | - public function enqueue_caffeinated_scripts() |
|
280 | - { |
|
281 | - // sound of crickets... |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - /** |
|
286 | - * callbacks below here |
|
287 | - * |
|
288 | - * @param array $taxonomy_array |
|
289 | - * @return array |
|
290 | - */ |
|
291 | - public function filter_taxonomies(array $taxonomy_array) |
|
292 | - { |
|
293 | - $taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true; |
|
294 | - return $taxonomy_array; |
|
295 | - } |
|
296 | - |
|
297 | - |
|
298 | - /** |
|
299 | - * @param array $cpt_array |
|
300 | - * @return mixed |
|
301 | - */ |
|
302 | - public function filter_cpts(array $cpt_array) |
|
303 | - { |
|
304 | - $cpt_array['espresso_venues']['args']['show_in_nav_menus'] = true; |
|
305 | - return $cpt_array; |
|
306 | - } |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * @param array $menuitems |
|
311 | - * @return array |
|
312 | - */ |
|
313 | - public function nav_metabox_items(array $menuitems) |
|
314 | - { |
|
315 | - $menuitems[] = array( |
|
316 | - 'title' => __('Venue List', 'event_espresso'), |
|
317 | - 'url' => get_post_type_archive_link('espresso_venues'), |
|
318 | - 'description' => __('Archive page for all venues.', 'event_espresso'), |
|
319 | - ); |
|
320 | - return $menuitems; |
|
321 | - } |
|
322 | - |
|
323 | - |
|
324 | - /** |
|
325 | - * Gets the injected table analyzer, or throws an exception |
|
326 | - * |
|
327 | - * @return TableAnalysis |
|
328 | - * @throws \EE_Error |
|
329 | - */ |
|
330 | - protected function _get_table_analysis() |
|
331 | - { |
|
332 | - if ($this->_table_analysis instanceof TableAnalysis) { |
|
333 | - return $this->_table_analysis; |
|
334 | - } else { |
|
335 | - throw new \EE_Error( |
|
336 | - sprintf( |
|
337 | - __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
338 | - get_class($this) |
|
339 | - ) |
|
340 | - ); |
|
341 | - } |
|
342 | - } |
|
30 | + /** |
|
31 | + * @var TableAnalysis $table_analysis |
|
32 | + */ |
|
33 | + protected $_table_analysis; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * EE_Brewing_Regular constructor. |
|
38 | + * |
|
39 | + * @param TableAnalysis $table_analysis |
|
40 | + */ |
|
41 | + public function __construct(TableAnalysis $table_analysis) |
|
42 | + { |
|
43 | + $this->_table_analysis = $table_analysis; |
|
44 | + if (defined('EE_CAFF_PATH')) { |
|
45 | + $this->setInitializationHooks(); |
|
46 | + $this->setApiRegistrationHooks(); |
|
47 | + $this->setSwitchHooks(); |
|
48 | + $this->setDefaultFilterHooks(); |
|
49 | + // caffeinated constructed |
|
50 | + do_action('AHEE__EE_Brewing_Regular__construct__complete'); |
|
51 | + } |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * Various hooks used for extending features via registration of modules or extensions. |
|
57 | + */ |
|
58 | + private function setApiRegistrationHooks() |
|
59 | + { |
|
60 | + add_filter( |
|
61 | + 'FHEE__EE_Config__register_modules__modules_to_register', |
|
62 | + array($this, 'caffeinated_modules_to_register') |
|
63 | + ); |
|
64 | + add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10); |
|
65 | + add_filter( |
|
66 | + 'AHEE__EE_System__load_core_configuration__complete', |
|
67 | + function () { |
|
68 | + EE_Register_Payment_Method::register( |
|
69 | + 'caffeinated_payment_methods', |
|
70 | + array( |
|
71 | + 'payment_method_paths' => glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR), |
|
72 | + ) |
|
73 | + ); |
|
74 | + } |
|
75 | + ); |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * Various hooks used for modifying initialization or activation processes. |
|
81 | + */ |
|
82 | + private function setInitializationHooks() |
|
83 | + { |
|
84 | + // activation |
|
85 | + add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content')); |
|
86 | + // load caff init |
|
87 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init')); |
|
88 | + // load caff scripts |
|
89 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * Various hooks used for switch (on/off) type filters. |
|
95 | + */ |
|
96 | + private function setSwitchHooks() |
|
97 | + { |
|
98 | + // remove the "powered by" credit link from receipts and invoices |
|
99 | + add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false'); |
|
100 | + // seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer |
|
101 | + add_filter('FHEE__ee_show_affiliate_links', '__return_false'); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * Various filters for affecting default configuration values in the caffeinated |
|
107 | + * context. |
|
108 | + */ |
|
109 | + private function setDefaultFilterHooks() |
|
110 | + { |
|
111 | + add_filter( |
|
112 | + 'FHEE__EE_Admin_Config__show_reg_footer__default', |
|
113 | + '__return_true' |
|
114 | + ); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * callback for the FHEE__EE_Registry__load_helper__helper_paths filter to add the caffeinated paths |
|
120 | + * |
|
121 | + * @param array $paths original helper paths array |
|
122 | + * @return array new array of paths |
|
123 | + */ |
|
124 | + public function caf_helper_paths($paths) |
|
125 | + { |
|
126 | + $paths[] = EE_CAF_CORE . 'helpers/'; |
|
127 | + return $paths; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * Upon brand-new activation, if this is a new activation of CAF, we want to add |
|
133 | + * some global prices that will show off EE4's capabilities. However, if they're upgrading |
|
134 | + * from 3.1, or simply EE4.x decaf, we assume they don't want us to suddenly introduce these extra prices. |
|
135 | + * This action should only be called when EE 4.x.0.P is initially activated. |
|
136 | + * Right now the only CAF content are these global prices. If there's more in the future, then |
|
137 | + * we should probably create a caf file to contain it all instead just a function like this. |
|
138 | + * Right now, we ASSUME the only price types in the system are default ones |
|
139 | + * |
|
140 | + * @global wpdb $wpdb |
|
141 | + */ |
|
142 | + public function initialize_caf_db_content() |
|
143 | + { |
|
144 | + global $wpdb; |
|
145 | + // use same method of getting creator id as the version introducing the change |
|
146 | + $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id()); |
|
147 | + $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
148 | + $price_table = $wpdb->prefix . "esp_price"; |
|
149 | + if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
150 | + $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';// include trashed price types |
|
151 | + $tax_price_type_count = $wpdb->get_var($SQL); |
|
152 | + if ($tax_price_type_count <= 1) { |
|
153 | + $wpdb->insert( |
|
154 | + $price_type_table, |
|
155 | + array( |
|
156 | + 'PRT_name' => __("Regional Tax", "event_espresso"), |
|
157 | + 'PBT_ID' => 4, |
|
158 | + 'PRT_is_percent' => true, |
|
159 | + 'PRT_order' => 60, |
|
160 | + 'PRT_deleted' => false, |
|
161 | + 'PRT_wp_user' => $default_creator_id, |
|
162 | + ), |
|
163 | + array( |
|
164 | + '%s',// PRT_name |
|
165 | + '%d',// PBT_id |
|
166 | + '%d',// PRT_is_percent |
|
167 | + '%d',// PRT_order |
|
168 | + '%d',// PRT_deleted |
|
169 | + '%d', // PRT_wp_user |
|
170 | + ) |
|
171 | + ); |
|
172 | + // federal tax |
|
173 | + $result = $wpdb->insert( |
|
174 | + $price_type_table, |
|
175 | + array( |
|
176 | + 'PRT_name' => __("Federal Tax", "event_espresso"), |
|
177 | + 'PBT_ID' => 4, |
|
178 | + 'PRT_is_percent' => true, |
|
179 | + 'PRT_order' => 70, |
|
180 | + 'PRT_deleted' => false, |
|
181 | + 'PRT_wp_user' => $default_creator_id, |
|
182 | + ), |
|
183 | + array( |
|
184 | + '%s',// PRT_name |
|
185 | + '%d',// PBT_id |
|
186 | + '%d',// PRT_is_percent |
|
187 | + '%d',// PRT_order |
|
188 | + '%d',// PRT_deleted |
|
189 | + '%d' // PRT_wp_user |
|
190 | + ) |
|
191 | + ); |
|
192 | + if ($result) { |
|
193 | + $wpdb->insert( |
|
194 | + $price_table, |
|
195 | + array( |
|
196 | + 'PRT_ID' => $wpdb->insert_id, |
|
197 | + 'PRC_amount' => 15.00, |
|
198 | + 'PRC_name' => __("Sales Tax", "event_espresso"), |
|
199 | + 'PRC_desc' => '', |
|
200 | + 'PRC_is_default' => true, |
|
201 | + 'PRC_overrides' => null, |
|
202 | + 'PRC_deleted' => false, |
|
203 | + 'PRC_order' => 50, |
|
204 | + 'PRC_parent' => null, |
|
205 | + 'PRC_wp_user' => $default_creator_id, |
|
206 | + ), |
|
207 | + array( |
|
208 | + '%d',// PRT_id |
|
209 | + '%f',// PRC_amount |
|
210 | + '%s',// PRC_name |
|
211 | + '%s',// PRC_desc |
|
212 | + '%d',// PRC_is_default |
|
213 | + '%d',// PRC_overrides |
|
214 | + '%d',// PRC_deleted |
|
215 | + '%d',// PRC_order |
|
216 | + '%d',// PRC_parent |
|
217 | + '%d' // PRC_wp_user |
|
218 | + ) |
|
219 | + ); |
|
220 | + } |
|
221 | + } |
|
222 | + } |
|
223 | + } |
|
224 | + |
|
225 | + |
|
226 | + /** |
|
227 | + * caffeinated_modules_to_register |
|
228 | + * |
|
229 | + * @access public |
|
230 | + * @param array $modules_to_register |
|
231 | + * @return array |
|
232 | + */ |
|
233 | + public function caffeinated_modules_to_register($modules_to_register = array()) |
|
234 | + { |
|
235 | + if (is_readable(EE_CAFF_PATH . 'modules')) { |
|
236 | + $caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules/*', GLOB_ONLYDIR); |
|
237 | + if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) { |
|
238 | + $modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register); |
|
239 | + } |
|
240 | + } |
|
241 | + return $modules_to_register; |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * @throws EE_Error |
|
247 | + * @throws InvalidArgumentException |
|
248 | + * @throws ReflectionException |
|
249 | + * @throws InvalidDataTypeException |
|
250 | + * @throws InvalidInterfaceException |
|
251 | + */ |
|
252 | + public function caffeinated_init() |
|
253 | + { |
|
254 | + // Custom Post Type hooks |
|
255 | + add_filter( |
|
256 | + 'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies', |
|
257 | + array($this, 'filter_taxonomies') |
|
258 | + ); |
|
259 | + add_filter( |
|
260 | + 'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes', |
|
261 | + array($this, 'filter_cpts') |
|
262 | + ); |
|
263 | + add_filter( |
|
264 | + 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', |
|
265 | + array($this, 'nav_metabox_items') |
|
266 | + ); |
|
267 | + EE_Registry::instance()->load_file( |
|
268 | + EE_CAFF_PATH, |
|
269 | + 'EE_Caf_Messages', |
|
270 | + 'class', |
|
271 | + array(), |
|
272 | + false |
|
273 | + ); |
|
274 | + // caffeinated_init__complete hook |
|
275 | + do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete'); |
|
276 | + } |
|
277 | + |
|
278 | + |
|
279 | + public function enqueue_caffeinated_scripts() |
|
280 | + { |
|
281 | + // sound of crickets... |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + /** |
|
286 | + * callbacks below here |
|
287 | + * |
|
288 | + * @param array $taxonomy_array |
|
289 | + * @return array |
|
290 | + */ |
|
291 | + public function filter_taxonomies(array $taxonomy_array) |
|
292 | + { |
|
293 | + $taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true; |
|
294 | + return $taxonomy_array; |
|
295 | + } |
|
296 | + |
|
297 | + |
|
298 | + /** |
|
299 | + * @param array $cpt_array |
|
300 | + * @return mixed |
|
301 | + */ |
|
302 | + public function filter_cpts(array $cpt_array) |
|
303 | + { |
|
304 | + $cpt_array['espresso_venues']['args']['show_in_nav_menus'] = true; |
|
305 | + return $cpt_array; |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * @param array $menuitems |
|
311 | + * @return array |
|
312 | + */ |
|
313 | + public function nav_metabox_items(array $menuitems) |
|
314 | + { |
|
315 | + $menuitems[] = array( |
|
316 | + 'title' => __('Venue List', 'event_espresso'), |
|
317 | + 'url' => get_post_type_archive_link('espresso_venues'), |
|
318 | + 'description' => __('Archive page for all venues.', 'event_espresso'), |
|
319 | + ); |
|
320 | + return $menuitems; |
|
321 | + } |
|
322 | + |
|
323 | + |
|
324 | + /** |
|
325 | + * Gets the injected table analyzer, or throws an exception |
|
326 | + * |
|
327 | + * @return TableAnalysis |
|
328 | + * @throws \EE_Error |
|
329 | + */ |
|
330 | + protected function _get_table_analysis() |
|
331 | + { |
|
332 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
333 | + return $this->_table_analysis; |
|
334 | + } else { |
|
335 | + throw new \EE_Error( |
|
336 | + sprintf( |
|
337 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
338 | + get_class($this) |
|
339 | + ) |
|
340 | + ); |
|
341 | + } |
|
342 | + } |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | |
346 | 346 | $brewing = new EE_Brewing_Regular( |
347 | - EE_Registry::instance()->create('TableAnalysis', array(), true) |
|
347 | + EE_Registry::instance()->create('TableAnalysis', array(), true) |
|
348 | 348 | ); |
@@ -11,10 +11,10 @@ discard block |
||
11 | 11 | * define and use the hook in a specific caffeinated/whatever class or file. |
12 | 12 | */ |
13 | 13 | // defined some new constants related to caffeinated folder |
14 | -define('EE_CAF_URL', EE_PLUGIN_DIR_URL . 'caffeinated/'); |
|
15 | -define('EE_CAF_CORE', EE_CAFF_PATH . 'core/'); |
|
16 | -define('EE_CAF_LIBRARIES', EE_CAF_CORE . 'libraries/'); |
|
17 | -define('EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH . 'payment_methods/'); |
|
14 | +define('EE_CAF_URL', EE_PLUGIN_DIR_URL.'caffeinated/'); |
|
15 | +define('EE_CAF_CORE', EE_CAFF_PATH.'core/'); |
|
16 | +define('EE_CAF_LIBRARIES', EE_CAF_CORE.'libraries/'); |
|
17 | +define('EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH.'payment_methods/'); |
|
18 | 18 | |
19 | 19 | |
20 | 20 | /** |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10); |
65 | 65 | add_filter( |
66 | 66 | 'AHEE__EE_System__load_core_configuration__complete', |
67 | - function () { |
|
67 | + function() { |
|
68 | 68 | EE_Register_Payment_Method::register( |
69 | 69 | 'caffeinated_payment_methods', |
70 | 70 | array( |
71 | - 'payment_method_paths' => glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR), |
|
71 | + 'payment_method_paths' => glob(EE_CAF_PAYMENT_METHODS.'*', GLOB_ONLYDIR), |
|
72 | 72 | ) |
73 | 73 | ); |
74 | 74 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function caf_helper_paths($paths) |
125 | 125 | { |
126 | - $paths[] = EE_CAF_CORE . 'helpers/'; |
|
126 | + $paths[] = EE_CAF_CORE.'helpers/'; |
|
127 | 127 | return $paths; |
128 | 128 | } |
129 | 129 | |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | global $wpdb; |
145 | 145 | // use same method of getting creator id as the version introducing the change |
146 | 146 | $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id()); |
147 | - $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
148 | - $price_table = $wpdb->prefix . "esp_price"; |
|
147 | + $price_type_table = $wpdb->prefix."esp_price_type"; |
|
148 | + $price_table = $wpdb->prefix."esp_price"; |
|
149 | 149 | if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
150 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';// include trashed price types |
|
150 | + $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table.' WHERE PBT_ID=4'; // include trashed price types |
|
151 | 151 | $tax_price_type_count = $wpdb->get_var($SQL); |
152 | 152 | if ($tax_price_type_count <= 1) { |
153 | 153 | $wpdb->insert( |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | 'PRT_wp_user' => $default_creator_id, |
162 | 162 | ), |
163 | 163 | array( |
164 | - '%s',// PRT_name |
|
165 | - '%d',// PBT_id |
|
166 | - '%d',// PRT_is_percent |
|
167 | - '%d',// PRT_order |
|
168 | - '%d',// PRT_deleted |
|
164 | + '%s', // PRT_name |
|
165 | + '%d', // PBT_id |
|
166 | + '%d', // PRT_is_percent |
|
167 | + '%d', // PRT_order |
|
168 | + '%d', // PRT_deleted |
|
169 | 169 | '%d', // PRT_wp_user |
170 | 170 | ) |
171 | 171 | ); |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | 'PRT_wp_user' => $default_creator_id, |
182 | 182 | ), |
183 | 183 | array( |
184 | - '%s',// PRT_name |
|
185 | - '%d',// PBT_id |
|
186 | - '%d',// PRT_is_percent |
|
187 | - '%d',// PRT_order |
|
188 | - '%d',// PRT_deleted |
|
184 | + '%s', // PRT_name |
|
185 | + '%d', // PBT_id |
|
186 | + '%d', // PRT_is_percent |
|
187 | + '%d', // PRT_order |
|
188 | + '%d', // PRT_deleted |
|
189 | 189 | '%d' // PRT_wp_user |
190 | 190 | ) |
191 | 191 | ); |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | 'PRC_wp_user' => $default_creator_id, |
206 | 206 | ), |
207 | 207 | array( |
208 | - '%d',// PRT_id |
|
209 | - '%f',// PRC_amount |
|
210 | - '%s',// PRC_name |
|
211 | - '%s',// PRC_desc |
|
212 | - '%d',// PRC_is_default |
|
213 | - '%d',// PRC_overrides |
|
214 | - '%d',// PRC_deleted |
|
215 | - '%d',// PRC_order |
|
216 | - '%d',// PRC_parent |
|
208 | + '%d', // PRT_id |
|
209 | + '%f', // PRC_amount |
|
210 | + '%s', // PRC_name |
|
211 | + '%s', // PRC_desc |
|
212 | + '%d', // PRC_is_default |
|
213 | + '%d', // PRC_overrides |
|
214 | + '%d', // PRC_deleted |
|
215 | + '%d', // PRC_order |
|
216 | + '%d', // PRC_parent |
|
217 | 217 | '%d' // PRC_wp_user |
218 | 218 | ) |
219 | 219 | ); |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function caffeinated_modules_to_register($modules_to_register = array()) |
234 | 234 | { |
235 | - if (is_readable(EE_CAFF_PATH . 'modules')) { |
|
236 | - $caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules/*', GLOB_ONLYDIR); |
|
235 | + if (is_readable(EE_CAFF_PATH.'modules')) { |
|
236 | + $caffeinated_modules_to_register = glob(EE_CAFF_PATH.'modules/*', GLOB_ONLYDIR); |
|
237 | 237 | if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) { |
238 | 238 | $modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register); |
239 | 239 | } |
@@ -14,52 +14,52 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - /** |
|
18 | - * constructor |
|
19 | - * |
|
20 | - * @Constructor |
|
21 | - * @access public |
|
22 | - * @return Pricing_Admin_Page_Init |
|
23 | - */ |
|
24 | - public function __construct() |
|
25 | - { |
|
17 | + /** |
|
18 | + * constructor |
|
19 | + * |
|
20 | + * @Constructor |
|
21 | + * @access public |
|
22 | + * @return Pricing_Admin_Page_Init |
|
23 | + */ |
|
24 | + public function __construct() |
|
25 | + { |
|
26 | 26 | |
27 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
27 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
28 | 28 | |
29 | - define('PRICING_PG_SLUG', 'pricing'); |
|
30 | - define('PRICING_LABEL', __('Pricing', 'event_espresso')); |
|
31 | - define('PRICING_PG_NAME', ucwords(str_replace('_', '', PRICING_PG_SLUG))); |
|
32 | - define('PRICING_ADMIN', EE_CORE_CAF_ADMIN . 'new/' . PRICING_PG_SLUG . '/'); |
|
33 | - define('PRICING_ADMIN_URL', admin_url('admin.php?page=' . PRICING_PG_SLUG)); |
|
34 | - define('PRICING_ASSETS_PATH', PRICING_ADMIN . 'assets/'); |
|
35 | - define('PRICING_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/assets/'); |
|
36 | - define('PRICING_TEMPLATE_PATH', PRICING_ADMIN . 'templates/'); |
|
37 | - define('PRICING_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/templates/'); |
|
29 | + define('PRICING_PG_SLUG', 'pricing'); |
|
30 | + define('PRICING_LABEL', __('Pricing', 'event_espresso')); |
|
31 | + define('PRICING_PG_NAME', ucwords(str_replace('_', '', PRICING_PG_SLUG))); |
|
32 | + define('PRICING_ADMIN', EE_CORE_CAF_ADMIN . 'new/' . PRICING_PG_SLUG . '/'); |
|
33 | + define('PRICING_ADMIN_URL', admin_url('admin.php?page=' . PRICING_PG_SLUG)); |
|
34 | + define('PRICING_ASSETS_PATH', PRICING_ADMIN . 'assets/'); |
|
35 | + define('PRICING_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/assets/'); |
|
36 | + define('PRICING_TEMPLATE_PATH', PRICING_ADMIN . 'templates/'); |
|
37 | + define('PRICING_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/templates/'); |
|
38 | 38 | |
39 | - parent::__construct(); |
|
40 | - $this->_folder_path = EE_CORE_CAF_ADMIN . 'new/' . $this->_folder_name . '/'; |
|
41 | - } |
|
39 | + parent::__construct(); |
|
40 | + $this->_folder_path = EE_CORE_CAF_ADMIN . 'new/' . $this->_folder_name . '/'; |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - protected function _set_init_properties() |
|
45 | - { |
|
46 | - $this->label = PRICING_LABEL; |
|
47 | - } |
|
44 | + protected function _set_init_properties() |
|
45 | + { |
|
46 | + $this->label = PRICING_LABEL; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - protected function _set_menu_map() |
|
51 | - { |
|
52 | - $this->_menu_map = new EE_Admin_Page_Sub_Menu( |
|
53 | - array( |
|
54 | - 'menu_group' => 'management', |
|
55 | - 'menu_order' => 20, |
|
56 | - 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
|
57 | - 'parent_slug' => 'espresso_events', |
|
58 | - 'menu_slug' => PRICING_PG_SLUG, |
|
59 | - 'menu_label' => PRICING_LABEL, |
|
60 | - 'capability' => 'ee_read_default_prices', |
|
61 | - 'admin_init_page' => $this, |
|
62 | - ) |
|
63 | - ); |
|
64 | - } |
|
50 | + protected function _set_menu_map() |
|
51 | + { |
|
52 | + $this->_menu_map = new EE_Admin_Page_Sub_Menu( |
|
53 | + array( |
|
54 | + 'menu_group' => 'management', |
|
55 | + 'menu_order' => 20, |
|
56 | + 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
|
57 | + 'parent_slug' => 'espresso_events', |
|
58 | + 'menu_slug' => PRICING_PG_SLUG, |
|
59 | + 'menu_label' => PRICING_LABEL, |
|
60 | + 'capability' => 'ee_read_default_prices', |
|
61 | + 'admin_init_page' => $this, |
|
62 | + ) |
|
63 | + ); |
|
64 | + } |
|
65 | 65 | } |
@@ -29,15 +29,15 @@ |
||
29 | 29 | define('PRICING_PG_SLUG', 'pricing'); |
30 | 30 | define('PRICING_LABEL', __('Pricing', 'event_espresso')); |
31 | 31 | define('PRICING_PG_NAME', ucwords(str_replace('_', '', PRICING_PG_SLUG))); |
32 | - define('PRICING_ADMIN', EE_CORE_CAF_ADMIN . 'new/' . PRICING_PG_SLUG . '/'); |
|
33 | - define('PRICING_ADMIN_URL', admin_url('admin.php?page=' . PRICING_PG_SLUG)); |
|
34 | - define('PRICING_ASSETS_PATH', PRICING_ADMIN . 'assets/'); |
|
35 | - define('PRICING_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/assets/'); |
|
36 | - define('PRICING_TEMPLATE_PATH', PRICING_ADMIN . 'templates/'); |
|
37 | - define('PRICING_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/templates/'); |
|
32 | + define('PRICING_ADMIN', EE_CORE_CAF_ADMIN.'new/'.PRICING_PG_SLUG.'/'); |
|
33 | + define('PRICING_ADMIN_URL', admin_url('admin.php?page='.PRICING_PG_SLUG)); |
|
34 | + define('PRICING_ASSETS_PATH', PRICING_ADMIN.'assets/'); |
|
35 | + define('PRICING_ASSETS_URL', EE_CORE_CAF_ADMIN_URL.'new/'.PRICING_PG_SLUG.'/assets/'); |
|
36 | + define('PRICING_TEMPLATE_PATH', PRICING_ADMIN.'templates/'); |
|
37 | + define('PRICING_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL.'new/'.PRICING_PG_SLUG.'/templates/'); |
|
38 | 38 | |
39 | 39 | parent::__construct(); |
40 | - $this->_folder_path = EE_CORE_CAF_ADMIN . 'new/' . $this->_folder_name . '/'; |
|
40 | + $this->_folder_path = EE_CORE_CAF_ADMIN.'new/'.$this->_folder_name.'/'; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 |