@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php printf( |
2 | - esc_html__( |
|
3 | - 'PayPal Pro (Website Payments Pro) is an on-site payment method for accepting credit and debit cards and is available to event organizers in the United States, United Kingdom, and Canada. An account with PayPal is required to accept payments. Need a PayPal Pro account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', |
|
4 | - 'event_espresso' |
|
5 | - ), |
|
6 | - '<a href="https://eventespresso.com/go/paypalpro/" target="_blank">', |
|
7 | - '</a>' |
|
2 | + esc_html__( |
|
3 | + 'PayPal Pro (Website Payments Pro) is an on-site payment method for accepting credit and debit cards and is available to event organizers in the United States, United Kingdom, and Canada. An account with PayPal is required to accept payments. Need a PayPal Pro account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', |
|
4 | + 'event_espresso' |
|
5 | + ), |
|
6 | + '<a href="https://eventespresso.com/go/paypalpro/" target="_blank">', |
|
7 | + '</a>' |
|
8 | 8 | ); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $billing_form->get_input('cvv')->set_default('123'); |
129 | 129 | } |
130 | 130 | $billing_form->add_subsections( |
131 | - array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ), |
|
131 | + array('fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html()), |
|
132 | 132 | 'credit_card' |
133 | 133 | ); |
134 | 134 | $billing_form->add_subsections( |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | 'html_label_text' => sprintf(__("Required Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()), |
190 | 190 | 'default' => array_diff( |
191 | 191 | array_keys($billing_input_names), |
192 | - array( 'address2', 'phone', 'company', 'fax' ) |
|
192 | + array('address2', 'phone', 'company', 'fax') |
|
193 | 193 | ), |
194 | 194 | 'html_help_text' => __('Note: if fields are excluded they cannot be required.', 'event_espresso') |
195 | 195 | ) |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | { |
250 | 250 | $all_billing_values_empty = array(); |
251 | 251 | foreach (array_keys($this->billing_input_names()) as $input_name) { |
252 | - $all_billing_values_empty[ $input_name ] = ''; |
|
252 | + $all_billing_values_empty[$input_name] = ''; |
|
253 | 253 | } |
254 | 254 | return array_merge( |
255 | 255 | $all_billing_values_empty, |
@@ -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 | } |
@@ -17,9 +17,9 @@ |
||
17 | 17 | |
18 | 18 | <p> |
19 | 19 | <?php _e( |
20 | - 'Test Mode allows you to submit test transactions to the payment gateway. Transactions that are submitted while Test Mode is ON are NOT actually processed. The result of a transaction depends on the card number submitted, and the invoice amount. If you want a transaction to be approved, use one of the following card numbers.', |
|
21 | - 'event_espresso' |
|
22 | - ); ?> |
|
20 | + 'Test Mode allows you to submit test transactions to the payment gateway. Transactions that are submitted while Test Mode is ON are NOT actually processed. The result of a transaction depends on the card number submitted, and the invoice amount. If you want a transaction to be approved, use one of the following card numbers.', |
|
21 | + 'event_espresso' |
|
22 | + ); ?> |
|
23 | 23 | </p> |
24 | 24 | |
25 | 25 | <p> |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php printf( |
2 | - esc_html__( |
|
3 | - 'Authorize.Net AIM is an on-site payment method for accepting credit and debit card payments and is available to event organizers in the United States, Canada, United Kingdom, and Australia. An account with Authorize.Net is required to accept payments. Need an Authorize.Net account? %1$sClick here to sign up for a merchant account%2$s.', |
|
4 | - 'event_espresso' |
|
5 | - ), |
|
6 | - '<a href="https://eventespresso.com/go/authorizenetaim/" target="_blank">', |
|
7 | - '</a>' |
|
2 | + esc_html__( |
|
3 | + 'Authorize.Net AIM is an on-site payment method for accepting credit and debit card payments and is available to event organizers in the United States, Canada, United Kingdom, and Australia. An account with Authorize.Net is required to accept payments. Need an Authorize.Net account? %1$sClick here to sign up for a merchant account%2$s.', |
|
4 | + 'event_espresso' |
|
5 | + ), |
|
6 | + '<a href="https://eventespresso.com/go/authorizenetaim/" target="_blank">', |
|
7 | + '</a>' |
|
8 | 8 | ); |
@@ -181,7 +181,6 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @access public |
183 | 183 | * @uses _initialize_admin_page() |
184 | - * @param string $dir_name directory name for specific admin_page being loaded. |
|
185 | 184 | * @return void |
186 | 185 | */ |
187 | 186 | public function initialize_admin_page() |
@@ -196,6 +195,9 @@ discard block |
||
196 | 195 | } |
197 | 196 | |
198 | 197 | |
198 | + /** |
|
199 | + * @param string $wp_page_slug |
|
200 | + */ |
|
199 | 201 | public function set_page_dependencies($wp_page_slug) |
200 | 202 | { |
201 | 203 | if (! $this->_load_page) { |
@@ -13,424 +13,424 @@ |
||
13 | 13 | abstract class EE_Admin_Page_Init extends EE_Base |
14 | 14 | { |
15 | 15 | |
16 | - // identity properties (set in _set_defaults and _set_init_properties) |
|
17 | - public $label; |
|
18 | - |
|
19 | - /** |
|
20 | - * Menu map has a capability. However, this allows admin pages to have separate capability requirements for menus |
|
21 | - * and accessing pages. If capability is NOT set, then it defaults to the menu_map capability. |
|
22 | - * |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - public $capability; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * This holds the menu map object for this admin page. |
|
30 | - * |
|
31 | - * @var EE_Admin_Page_Menu_Map |
|
32 | - */ |
|
33 | - protected $_menu_map; |
|
34 | - |
|
35 | - /** |
|
36 | - * deprecated |
|
37 | - */ |
|
38 | - public $menu_label; |
|
39 | - public $menu_slug; |
|
40 | - |
|
41 | - |
|
42 | - // set in _set_defaults |
|
43 | - protected $_folder_name; |
|
44 | - protected $_folder_path; |
|
45 | - protected $_file_name; |
|
46 | - public $hook_file; |
|
47 | - protected $_wp_page_slug; |
|
48 | - protected $_routing; |
|
49 | - |
|
50 | - |
|
51 | - // will hold page object. |
|
52 | - protected $_loaded_page_object; |
|
53 | - |
|
54 | - |
|
55 | - // for caf |
|
56 | - protected $_files_hooked; |
|
57 | - protected $_hook_paths; |
|
58 | - |
|
59 | - // load_page? |
|
60 | - private $_load_page; |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * @Constructor |
|
65 | - * @access public |
|
66 | - * @return void |
|
67 | - */ |
|
68 | - public function __construct() |
|
69 | - { |
|
70 | - // set global defaults |
|
71 | - $this->_set_defaults(); |
|
72 | - // set properties that are always available with objects. |
|
73 | - $this->_set_init_properties(); |
|
74 | - // global styles/scripts across all wp admin pages |
|
75 | - add_action('admin_enqueue_scripts', array($this, 'load_wp_global_scripts_styles'), 5); |
|
76 | - // load initial stuff. |
|
77 | - $this->_set_file_and_folder_name(); |
|
78 | - $this->_set_menu_map(); |
|
79 | - if (empty($this->_menu_map) || is_array($this->_menu_map)) { |
|
80 | - EE_Error::doing_it_wrong( |
|
81 | - get_class($this) . '::$_menu_map', |
|
82 | - sprintf( |
|
83 | - __( |
|
84 | - 'The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core. Please see Admin_Page_Init class examples in core for the new way of setting this property up.', |
|
85 | - 'event_espresso' |
|
86 | - ), |
|
87 | - get_class($this) |
|
88 | - ), |
|
89 | - '4.4.0' |
|
90 | - ); |
|
91 | - return; |
|
92 | - } |
|
93 | - // set default capability |
|
94 | - $this->_set_capability(); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * _set_init_properties |
|
100 | - * Child classes use to set the following properties: |
|
101 | - * $label |
|
102 | - * |
|
103 | - * @abstract |
|
104 | - * @access protected |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - abstract protected function _set_init_properties(); |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * _set_menu_map is a function that child classes use to set the menu_map property (which should be an instance of |
|
112 | - * EE_Admin_Page_Menu_Map. Their menu can either be EE_Admin_Page_Main_Menu or EE_Admin_Page_Sub_Menu. |
|
113 | - * |
|
114 | - * @since 4.4.0 |
|
115 | - * @ return void. |
|
116 | - */ |
|
117 | - protected function _set_menu_map() |
|
118 | - { |
|
119 | - return array(); |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * returns the menu map for this admin page |
|
125 | - * |
|
126 | - * @since 4.4.0 |
|
127 | - * @return EE_Admin_Page_Menu_Map |
|
128 | - */ |
|
129 | - public function get_menu_map() |
|
130 | - { |
|
131 | - return $this->_menu_map; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * This loads scripts and styles for the EE_Admin system |
|
137 | - * that must be available on ALL WP admin pages (i.e. EE_menu items) |
|
138 | - * |
|
139 | - * @return void |
|
140 | - */ |
|
141 | - public function load_wp_global_scripts_styles() |
|
142 | - { |
|
143 | - wp_register_style( |
|
144 | - 'espresso_menu', |
|
145 | - EE_ADMIN_URL . 'assets/admin-menu-styles.css', |
|
146 | - array('dashicons'), |
|
147 | - EVENT_ESPRESSO_VERSION |
|
148 | - ); |
|
149 | - wp_enqueue_style('espresso_menu'); |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * this sets default properties (might be overridden in _set_init_properties); |
|
155 | - * |
|
156 | - * @access private |
|
157 | - * @return void |
|
158 | - */ |
|
159 | - private function _set_defaults() |
|
160 | - { |
|
161 | - $this->_file_name = $this->_folder_name = $this->_wp_page_slug = $this->capability = null; |
|
162 | - $this->_routing = true; |
|
163 | - $this->_load_page = false; |
|
164 | - $this->_files_hooked = $this->_hook_paths = array(); |
|
165 | - // menu_map |
|
166 | - $this->_menu_map = $this->get_menu_map(); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - protected function _set_capability() |
|
171 | - { |
|
172 | - $capability = empty($this->capability) ? $this->_menu_map->capability : $this->capability; |
|
173 | - $this->capability = apply_filters('FHEE_' . $this->_menu_map->menu_slug . '_capability', $capability); |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * initialize_admin_page |
|
179 | - * This method is what executes the loading of the specific page class for the given dir_name as called by the |
|
180 | - * EE_Admin_Init class. |
|
181 | - * |
|
182 | - * @access public |
|
183 | - * @uses _initialize_admin_page() |
|
184 | - * @param string $dir_name directory name for specific admin_page being loaded. |
|
185 | - * @return void |
|
186 | - */ |
|
187 | - public function initialize_admin_page() |
|
188 | - { |
|
189 | - // let's check user access first |
|
190 | - $this->_check_user_access(); |
|
191 | - if (! is_object($this->_loaded_page_object)) { |
|
192 | - return; |
|
193 | - } |
|
194 | - $this->_loaded_page_object->route_admin_request(); |
|
195 | - return; |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - public function set_page_dependencies($wp_page_slug) |
|
200 | - { |
|
201 | - if (! $this->_load_page) { |
|
202 | - return; |
|
203 | - } |
|
204 | - if (! is_object($this->_loaded_page_object)) { |
|
205 | - $msg[] = __( |
|
206 | - 'We can\'t load the page because we\'re missing a valid page object that tells us what to load', |
|
207 | - 'event_espresso' |
|
208 | - ); |
|
209 | - $msg[] = $msg[0] . "\r\n" |
|
210 | - . sprintf( |
|
211 | - __( |
|
212 | - 'The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory', |
|
213 | - 'event_espresso' |
|
214 | - ), |
|
215 | - $this->_file_name, |
|
216 | - $this->_file_name, |
|
217 | - $this->_folder_path . $this->_file_name, |
|
218 | - $this->_menu_map->menu_slug |
|
219 | - ); |
|
220 | - throw new EE_Error(implode('||', $msg)); |
|
221 | - } |
|
222 | - $this->_loaded_page_object->set_wp_page_slug($wp_page_slug); |
|
223 | - $page_hook = 'load-' . $wp_page_slug; |
|
224 | - // hook into page load hook so all page specific stuff get's loaded. |
|
225 | - if (! empty($wp_page_slug)) { |
|
226 | - add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies')); |
|
227 | - } |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * This executes the intial page loads for EE_Admin pages to take care of any ajax or other code needing to run |
|
233 | - * before the load-page... hook. Note, the page loads are happening around the wp_init hook. |
|
234 | - * |
|
235 | - * @return void |
|
236 | - */ |
|
237 | - public function do_initial_loads() |
|
238 | - { |
|
239 | - // no loading or initializing if menu map is setup incorrectly. |
|
240 | - if (empty($this->_menu_map) || is_array($this->_menu_map)) { |
|
241 | - return; |
|
242 | - } |
|
243 | - $this->_initialize_admin_page(); |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * all we're doing here is setting the $_file_name property for later use. |
|
249 | - * |
|
250 | - * @access private |
|
251 | - * @return void |
|
252 | - */ |
|
253 | - private function _set_file_and_folder_name() |
|
254 | - { |
|
255 | - $bt = debug_backtrace(); |
|
256 | - // for more reliable determination of folder name |
|
257 | - // we're using this to get the actual folder name of the CALLING class (i.e. the child class that extends this). Why? Because $this->menu_slug may be different than the folder name (to avoid conflicts with other plugins) |
|
258 | - $class = get_class($this); |
|
259 | - foreach ($bt as $index => $values) { |
|
260 | - if (isset($values['class']) && $values['class'] == $class) { |
|
261 | - $file_index = $index - 1; |
|
262 | - $this->_folder_name = basename(dirname($bt[ $file_index ]['file'])); |
|
263 | - if (! empty($this->_folder_name)) { |
|
264 | - break; |
|
265 | - } |
|
266 | - } |
|
267 | - } |
|
268 | - $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/'; |
|
269 | - $this->_file_name = preg_replace('/^ee/', 'EE', $this->_folder_name); |
|
270 | - $this->_file_name = ucwords(str_replace('_', ' ', $this->_file_name)); |
|
271 | - $this->_file_name = str_replace(' ', '_', $this->_file_name); |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * This automatically checks if we have a hook class in the loaded child directory. If we DO then we will register |
|
277 | - * it with the appropriate pages. That way all we have to do is make sure the file is named correctly and |
|
278 | - * "dropped" in. Example: if we wanted to set this up for Messages hooking into Events then we would do: |
|
279 | - * events_Messages_Hooks.class.php |
|
280 | - * |
|
281 | - * @param bool $extend This indicates whether we're checking the extend directory for any register_hooks |
|
282 | - * files/classes |
|
283 | - * @return array |
|
284 | - */ |
|
285 | - public function register_hooks($extend = false) |
|
286 | - { |
|
287 | - |
|
288 | - // get a list of files in the directory that have the "Hook" in their name an |
|
289 | - // if this is an extended check (i.e. caf is active) then we will scan the caffeinated/extend directory first and any hook files that are found will be have their reference added to the $_files_hook array property. Then, we make sure that when we loop through the core decaf directories to find hook files that we skip over any hooks files that have already been set by caf. |
|
290 | - if ($extend) { |
|
291 | - $hook_files_glob_path = apply_filters( |
|
292 | - 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path__extend', |
|
293 | - EE_CORE_CAF_ADMIN_EXTEND |
|
294 | - . $this->_folder_name |
|
295 | - . '/*' |
|
296 | - . $this->_file_name |
|
297 | - . '_Hooks_Extend.class.php' |
|
298 | - ); |
|
299 | - $this->_hook_paths = $this->_register_hook_files($hook_files_glob_path, $extend); |
|
300 | - } |
|
301 | - // loop through decaf folders |
|
302 | - $hook_files_glob_path = apply_filters( |
|
303 | - 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path', |
|
304 | - $this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php' |
|
305 | - ); |
|
306 | - $this->_hook_paths = array_merge( |
|
307 | - $this->_register_hook_files($hook_files_glob_path), |
|
308 | - $this->_hook_paths |
|
309 | - ); // making sure any extended hook paths are later in the array than the core hook paths! |
|
310 | - return $this->_hook_paths; |
|
311 | - } |
|
312 | - |
|
313 | - |
|
314 | - protected function _register_hook_files($hook_files_glob_path, $extend = false) |
|
315 | - { |
|
316 | - $hook_paths = array(); |
|
317 | - if ($hook_files = glob($hook_files_glob_path)) { |
|
318 | - if (empty($hook_files)) { |
|
319 | - return array(); |
|
320 | - } |
|
321 | - foreach ($hook_files as $file) { |
|
322 | - // lets get the linked admin. |
|
323 | - $hook_file = $extend ? str_replace(EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . '/', '', $file) |
|
324 | - : str_replace($this->_folder_path, '', $file); |
|
325 | - $replace = $extend |
|
326 | - ? '_' . $this->_file_name . '_Hooks_Extend.class.php' |
|
327 | - : '_' |
|
328 | - . $this->_file_name |
|
329 | - . '_Hooks.class.php'; |
|
330 | - $rel_admin = str_replace($replace, '', $hook_file); |
|
331 | - $rel_admin = strtolower($rel_admin); |
|
332 | - $hook_paths[] = $file; |
|
333 | - // make sure we haven't already got a hook setup for this page path |
|
334 | - if (in_array($rel_admin, $this->_files_hooked)) { |
|
335 | - continue; |
|
336 | - } |
|
337 | - $this->hook_file = $hook_file; |
|
338 | - $rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin; |
|
339 | - $filter = add_filter($rel_admin_hook, array($this, 'load_admin_hook')); |
|
340 | - $this->_files_hooked[] = $rel_admin; |
|
341 | - } |
|
342 | - } |
|
343 | - return $hook_paths; |
|
344 | - } |
|
345 | - |
|
346 | - |
|
347 | - public function load_admin_hook($registered_pages) |
|
348 | - { |
|
349 | - $this->hook_file; |
|
350 | - $hook_file = (array) $this->hook_file; |
|
351 | - return array_merge($hook_file, $registered_pages); |
|
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - /** |
|
356 | - * _initialize_admin_page |
|
357 | - * |
|
358 | - * @see initialize_admin_page() for info |
|
359 | - */ |
|
360 | - protected function _initialize_admin_page() |
|
361 | - { |
|
362 | - |
|
363 | - // JUST CHECK WE'RE ON RIGHT PAGE. |
|
364 | - if ((! isset($_REQUEST['page']) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing) { |
|
365 | - return; |
|
366 | - } //not on the right page so let's get out. |
|
367 | - $this->_load_page = true; |
|
368 | - |
|
369 | - // we don't need to do a page_request check here because it's only called via WP menu system. |
|
370 | - $admin_page = $this->_file_name . '_Admin_Page'; |
|
371 | - $hook_suffix = $this->_menu_map->menu_slug . '_' . $admin_page; |
|
372 | - $admin_page = apply_filters( |
|
373 | - "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$hook_suffix}", |
|
374 | - $admin_page |
|
375 | - ); |
|
376 | - // define requested admin page class name then load the file and instantiate |
|
377 | - $path_to_file = str_replace(array('\\', '/'), '/', $this->_folder_path . $admin_page . '.core.php'); |
|
378 | - $path_to_file = apply_filters( |
|
379 | - "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}", |
|
380 | - $path_to_file |
|
381 | - );// so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page |
|
382 | - if (is_readable($path_to_file)) { |
|
383 | - // This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place |
|
384 | - do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization'); |
|
385 | - do_action( |
|
386 | - 'AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_' . $this->_menu_map->menu_slug |
|
387 | - ); |
|
388 | - require_once($path_to_file); |
|
389 | - $a = new ReflectionClass($admin_page); |
|
390 | - $this->_loaded_page_object = $a->newInstance($this->_routing); |
|
391 | - } |
|
392 | - do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization'); |
|
393 | - do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_' . $this->_menu_map->menu_slug); |
|
394 | - } |
|
395 | - |
|
396 | - |
|
397 | - public function get_admin_page_name() |
|
398 | - { |
|
399 | - return $this->_file_name . '_Admin_Page'; |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * @return mixed |
|
405 | - */ |
|
406 | - public function loaded_page_object() |
|
407 | - { |
|
408 | - return $this->_loaded_page_object; |
|
409 | - } |
|
410 | - |
|
411 | - |
|
412 | - // public function set_autoloaders($className) |
|
413 | - // { |
|
414 | - // $dir_ref = array( |
|
415 | - // $this->_folder_path => array('core', 'class'), |
|
416 | - // ); |
|
417 | - // EEH_Autoloader::try_autoload($dir_ref, $className); |
|
418 | - // } |
|
419 | - /** |
|
420 | - * _check_user_access |
|
421 | - * verifies user access for this admin page. If no user access is available then let's gracefully exit with a |
|
422 | - * WordPress die message. |
|
423 | - * |
|
424 | - * @return bool|die true if pass (or admin) wp_die if fail |
|
425 | - */ |
|
426 | - private function _check_user_access() |
|
427 | - { |
|
428 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
429 | - $this->_menu_map->capability, |
|
430 | - $this->_menu_map->menu_slug |
|
431 | - )) { |
|
432 | - wp_die(__('You don\'t have access to this page.', 'event_espresso'), '', array('back_link' => true)); |
|
433 | - } |
|
434 | - return true; |
|
435 | - } |
|
16 | + // identity properties (set in _set_defaults and _set_init_properties) |
|
17 | + public $label; |
|
18 | + |
|
19 | + /** |
|
20 | + * Menu map has a capability. However, this allows admin pages to have separate capability requirements for menus |
|
21 | + * and accessing pages. If capability is NOT set, then it defaults to the menu_map capability. |
|
22 | + * |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + public $capability; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * This holds the menu map object for this admin page. |
|
30 | + * |
|
31 | + * @var EE_Admin_Page_Menu_Map |
|
32 | + */ |
|
33 | + protected $_menu_map; |
|
34 | + |
|
35 | + /** |
|
36 | + * deprecated |
|
37 | + */ |
|
38 | + public $menu_label; |
|
39 | + public $menu_slug; |
|
40 | + |
|
41 | + |
|
42 | + // set in _set_defaults |
|
43 | + protected $_folder_name; |
|
44 | + protected $_folder_path; |
|
45 | + protected $_file_name; |
|
46 | + public $hook_file; |
|
47 | + protected $_wp_page_slug; |
|
48 | + protected $_routing; |
|
49 | + |
|
50 | + |
|
51 | + // will hold page object. |
|
52 | + protected $_loaded_page_object; |
|
53 | + |
|
54 | + |
|
55 | + // for caf |
|
56 | + protected $_files_hooked; |
|
57 | + protected $_hook_paths; |
|
58 | + |
|
59 | + // load_page? |
|
60 | + private $_load_page; |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * @Constructor |
|
65 | + * @access public |
|
66 | + * @return void |
|
67 | + */ |
|
68 | + public function __construct() |
|
69 | + { |
|
70 | + // set global defaults |
|
71 | + $this->_set_defaults(); |
|
72 | + // set properties that are always available with objects. |
|
73 | + $this->_set_init_properties(); |
|
74 | + // global styles/scripts across all wp admin pages |
|
75 | + add_action('admin_enqueue_scripts', array($this, 'load_wp_global_scripts_styles'), 5); |
|
76 | + // load initial stuff. |
|
77 | + $this->_set_file_and_folder_name(); |
|
78 | + $this->_set_menu_map(); |
|
79 | + if (empty($this->_menu_map) || is_array($this->_menu_map)) { |
|
80 | + EE_Error::doing_it_wrong( |
|
81 | + get_class($this) . '::$_menu_map', |
|
82 | + sprintf( |
|
83 | + __( |
|
84 | + 'The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core. Please see Admin_Page_Init class examples in core for the new way of setting this property up.', |
|
85 | + 'event_espresso' |
|
86 | + ), |
|
87 | + get_class($this) |
|
88 | + ), |
|
89 | + '4.4.0' |
|
90 | + ); |
|
91 | + return; |
|
92 | + } |
|
93 | + // set default capability |
|
94 | + $this->_set_capability(); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * _set_init_properties |
|
100 | + * Child classes use to set the following properties: |
|
101 | + * $label |
|
102 | + * |
|
103 | + * @abstract |
|
104 | + * @access protected |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + abstract protected function _set_init_properties(); |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * _set_menu_map is a function that child classes use to set the menu_map property (which should be an instance of |
|
112 | + * EE_Admin_Page_Menu_Map. Their menu can either be EE_Admin_Page_Main_Menu or EE_Admin_Page_Sub_Menu. |
|
113 | + * |
|
114 | + * @since 4.4.0 |
|
115 | + * @ return void. |
|
116 | + */ |
|
117 | + protected function _set_menu_map() |
|
118 | + { |
|
119 | + return array(); |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * returns the menu map for this admin page |
|
125 | + * |
|
126 | + * @since 4.4.0 |
|
127 | + * @return EE_Admin_Page_Menu_Map |
|
128 | + */ |
|
129 | + public function get_menu_map() |
|
130 | + { |
|
131 | + return $this->_menu_map; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * This loads scripts and styles for the EE_Admin system |
|
137 | + * that must be available on ALL WP admin pages (i.e. EE_menu items) |
|
138 | + * |
|
139 | + * @return void |
|
140 | + */ |
|
141 | + public function load_wp_global_scripts_styles() |
|
142 | + { |
|
143 | + wp_register_style( |
|
144 | + 'espresso_menu', |
|
145 | + EE_ADMIN_URL . 'assets/admin-menu-styles.css', |
|
146 | + array('dashicons'), |
|
147 | + EVENT_ESPRESSO_VERSION |
|
148 | + ); |
|
149 | + wp_enqueue_style('espresso_menu'); |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * this sets default properties (might be overridden in _set_init_properties); |
|
155 | + * |
|
156 | + * @access private |
|
157 | + * @return void |
|
158 | + */ |
|
159 | + private function _set_defaults() |
|
160 | + { |
|
161 | + $this->_file_name = $this->_folder_name = $this->_wp_page_slug = $this->capability = null; |
|
162 | + $this->_routing = true; |
|
163 | + $this->_load_page = false; |
|
164 | + $this->_files_hooked = $this->_hook_paths = array(); |
|
165 | + // menu_map |
|
166 | + $this->_menu_map = $this->get_menu_map(); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + protected function _set_capability() |
|
171 | + { |
|
172 | + $capability = empty($this->capability) ? $this->_menu_map->capability : $this->capability; |
|
173 | + $this->capability = apply_filters('FHEE_' . $this->_menu_map->menu_slug . '_capability', $capability); |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * initialize_admin_page |
|
179 | + * This method is what executes the loading of the specific page class for the given dir_name as called by the |
|
180 | + * EE_Admin_Init class. |
|
181 | + * |
|
182 | + * @access public |
|
183 | + * @uses _initialize_admin_page() |
|
184 | + * @param string $dir_name directory name for specific admin_page being loaded. |
|
185 | + * @return void |
|
186 | + */ |
|
187 | + public function initialize_admin_page() |
|
188 | + { |
|
189 | + // let's check user access first |
|
190 | + $this->_check_user_access(); |
|
191 | + if (! is_object($this->_loaded_page_object)) { |
|
192 | + return; |
|
193 | + } |
|
194 | + $this->_loaded_page_object->route_admin_request(); |
|
195 | + return; |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + public function set_page_dependencies($wp_page_slug) |
|
200 | + { |
|
201 | + if (! $this->_load_page) { |
|
202 | + return; |
|
203 | + } |
|
204 | + if (! is_object($this->_loaded_page_object)) { |
|
205 | + $msg[] = __( |
|
206 | + 'We can\'t load the page because we\'re missing a valid page object that tells us what to load', |
|
207 | + 'event_espresso' |
|
208 | + ); |
|
209 | + $msg[] = $msg[0] . "\r\n" |
|
210 | + . sprintf( |
|
211 | + __( |
|
212 | + 'The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory', |
|
213 | + 'event_espresso' |
|
214 | + ), |
|
215 | + $this->_file_name, |
|
216 | + $this->_file_name, |
|
217 | + $this->_folder_path . $this->_file_name, |
|
218 | + $this->_menu_map->menu_slug |
|
219 | + ); |
|
220 | + throw new EE_Error(implode('||', $msg)); |
|
221 | + } |
|
222 | + $this->_loaded_page_object->set_wp_page_slug($wp_page_slug); |
|
223 | + $page_hook = 'load-' . $wp_page_slug; |
|
224 | + // hook into page load hook so all page specific stuff get's loaded. |
|
225 | + if (! empty($wp_page_slug)) { |
|
226 | + add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies')); |
|
227 | + } |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * This executes the intial page loads for EE_Admin pages to take care of any ajax or other code needing to run |
|
233 | + * before the load-page... hook. Note, the page loads are happening around the wp_init hook. |
|
234 | + * |
|
235 | + * @return void |
|
236 | + */ |
|
237 | + public function do_initial_loads() |
|
238 | + { |
|
239 | + // no loading or initializing if menu map is setup incorrectly. |
|
240 | + if (empty($this->_menu_map) || is_array($this->_menu_map)) { |
|
241 | + return; |
|
242 | + } |
|
243 | + $this->_initialize_admin_page(); |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * all we're doing here is setting the $_file_name property for later use. |
|
249 | + * |
|
250 | + * @access private |
|
251 | + * @return void |
|
252 | + */ |
|
253 | + private function _set_file_and_folder_name() |
|
254 | + { |
|
255 | + $bt = debug_backtrace(); |
|
256 | + // for more reliable determination of folder name |
|
257 | + // we're using this to get the actual folder name of the CALLING class (i.e. the child class that extends this). Why? Because $this->menu_slug may be different than the folder name (to avoid conflicts with other plugins) |
|
258 | + $class = get_class($this); |
|
259 | + foreach ($bt as $index => $values) { |
|
260 | + if (isset($values['class']) && $values['class'] == $class) { |
|
261 | + $file_index = $index - 1; |
|
262 | + $this->_folder_name = basename(dirname($bt[ $file_index ]['file'])); |
|
263 | + if (! empty($this->_folder_name)) { |
|
264 | + break; |
|
265 | + } |
|
266 | + } |
|
267 | + } |
|
268 | + $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/'; |
|
269 | + $this->_file_name = preg_replace('/^ee/', 'EE', $this->_folder_name); |
|
270 | + $this->_file_name = ucwords(str_replace('_', ' ', $this->_file_name)); |
|
271 | + $this->_file_name = str_replace(' ', '_', $this->_file_name); |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * This automatically checks if we have a hook class in the loaded child directory. If we DO then we will register |
|
277 | + * it with the appropriate pages. That way all we have to do is make sure the file is named correctly and |
|
278 | + * "dropped" in. Example: if we wanted to set this up for Messages hooking into Events then we would do: |
|
279 | + * events_Messages_Hooks.class.php |
|
280 | + * |
|
281 | + * @param bool $extend This indicates whether we're checking the extend directory for any register_hooks |
|
282 | + * files/classes |
|
283 | + * @return array |
|
284 | + */ |
|
285 | + public function register_hooks($extend = false) |
|
286 | + { |
|
287 | + |
|
288 | + // get a list of files in the directory that have the "Hook" in their name an |
|
289 | + // if this is an extended check (i.e. caf is active) then we will scan the caffeinated/extend directory first and any hook files that are found will be have their reference added to the $_files_hook array property. Then, we make sure that when we loop through the core decaf directories to find hook files that we skip over any hooks files that have already been set by caf. |
|
290 | + if ($extend) { |
|
291 | + $hook_files_glob_path = apply_filters( |
|
292 | + 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path__extend', |
|
293 | + EE_CORE_CAF_ADMIN_EXTEND |
|
294 | + . $this->_folder_name |
|
295 | + . '/*' |
|
296 | + . $this->_file_name |
|
297 | + . '_Hooks_Extend.class.php' |
|
298 | + ); |
|
299 | + $this->_hook_paths = $this->_register_hook_files($hook_files_glob_path, $extend); |
|
300 | + } |
|
301 | + // loop through decaf folders |
|
302 | + $hook_files_glob_path = apply_filters( |
|
303 | + 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path', |
|
304 | + $this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php' |
|
305 | + ); |
|
306 | + $this->_hook_paths = array_merge( |
|
307 | + $this->_register_hook_files($hook_files_glob_path), |
|
308 | + $this->_hook_paths |
|
309 | + ); // making sure any extended hook paths are later in the array than the core hook paths! |
|
310 | + return $this->_hook_paths; |
|
311 | + } |
|
312 | + |
|
313 | + |
|
314 | + protected function _register_hook_files($hook_files_glob_path, $extend = false) |
|
315 | + { |
|
316 | + $hook_paths = array(); |
|
317 | + if ($hook_files = glob($hook_files_glob_path)) { |
|
318 | + if (empty($hook_files)) { |
|
319 | + return array(); |
|
320 | + } |
|
321 | + foreach ($hook_files as $file) { |
|
322 | + // lets get the linked admin. |
|
323 | + $hook_file = $extend ? str_replace(EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . '/', '', $file) |
|
324 | + : str_replace($this->_folder_path, '', $file); |
|
325 | + $replace = $extend |
|
326 | + ? '_' . $this->_file_name . '_Hooks_Extend.class.php' |
|
327 | + : '_' |
|
328 | + . $this->_file_name |
|
329 | + . '_Hooks.class.php'; |
|
330 | + $rel_admin = str_replace($replace, '', $hook_file); |
|
331 | + $rel_admin = strtolower($rel_admin); |
|
332 | + $hook_paths[] = $file; |
|
333 | + // make sure we haven't already got a hook setup for this page path |
|
334 | + if (in_array($rel_admin, $this->_files_hooked)) { |
|
335 | + continue; |
|
336 | + } |
|
337 | + $this->hook_file = $hook_file; |
|
338 | + $rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin; |
|
339 | + $filter = add_filter($rel_admin_hook, array($this, 'load_admin_hook')); |
|
340 | + $this->_files_hooked[] = $rel_admin; |
|
341 | + } |
|
342 | + } |
|
343 | + return $hook_paths; |
|
344 | + } |
|
345 | + |
|
346 | + |
|
347 | + public function load_admin_hook($registered_pages) |
|
348 | + { |
|
349 | + $this->hook_file; |
|
350 | + $hook_file = (array) $this->hook_file; |
|
351 | + return array_merge($hook_file, $registered_pages); |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + /** |
|
356 | + * _initialize_admin_page |
|
357 | + * |
|
358 | + * @see initialize_admin_page() for info |
|
359 | + */ |
|
360 | + protected function _initialize_admin_page() |
|
361 | + { |
|
362 | + |
|
363 | + // JUST CHECK WE'RE ON RIGHT PAGE. |
|
364 | + if ((! isset($_REQUEST['page']) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing) { |
|
365 | + return; |
|
366 | + } //not on the right page so let's get out. |
|
367 | + $this->_load_page = true; |
|
368 | + |
|
369 | + // we don't need to do a page_request check here because it's only called via WP menu system. |
|
370 | + $admin_page = $this->_file_name . '_Admin_Page'; |
|
371 | + $hook_suffix = $this->_menu_map->menu_slug . '_' . $admin_page; |
|
372 | + $admin_page = apply_filters( |
|
373 | + "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$hook_suffix}", |
|
374 | + $admin_page |
|
375 | + ); |
|
376 | + // define requested admin page class name then load the file and instantiate |
|
377 | + $path_to_file = str_replace(array('\\', '/'), '/', $this->_folder_path . $admin_page . '.core.php'); |
|
378 | + $path_to_file = apply_filters( |
|
379 | + "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}", |
|
380 | + $path_to_file |
|
381 | + );// so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page |
|
382 | + if (is_readable($path_to_file)) { |
|
383 | + // This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place |
|
384 | + do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization'); |
|
385 | + do_action( |
|
386 | + 'AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_' . $this->_menu_map->menu_slug |
|
387 | + ); |
|
388 | + require_once($path_to_file); |
|
389 | + $a = new ReflectionClass($admin_page); |
|
390 | + $this->_loaded_page_object = $a->newInstance($this->_routing); |
|
391 | + } |
|
392 | + do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization'); |
|
393 | + do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_' . $this->_menu_map->menu_slug); |
|
394 | + } |
|
395 | + |
|
396 | + |
|
397 | + public function get_admin_page_name() |
|
398 | + { |
|
399 | + return $this->_file_name . '_Admin_Page'; |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * @return mixed |
|
405 | + */ |
|
406 | + public function loaded_page_object() |
|
407 | + { |
|
408 | + return $this->_loaded_page_object; |
|
409 | + } |
|
410 | + |
|
411 | + |
|
412 | + // public function set_autoloaders($className) |
|
413 | + // { |
|
414 | + // $dir_ref = array( |
|
415 | + // $this->_folder_path => array('core', 'class'), |
|
416 | + // ); |
|
417 | + // EEH_Autoloader::try_autoload($dir_ref, $className); |
|
418 | + // } |
|
419 | + /** |
|
420 | + * _check_user_access |
|
421 | + * verifies user access for this admin page. If no user access is available then let's gracefully exit with a |
|
422 | + * WordPress die message. |
|
423 | + * |
|
424 | + * @return bool|die true if pass (or admin) wp_die if fail |
|
425 | + */ |
|
426 | + private function _check_user_access() |
|
427 | + { |
|
428 | + if (! EE_Registry::instance()->CAP->current_user_can( |
|
429 | + $this->_menu_map->capability, |
|
430 | + $this->_menu_map->menu_slug |
|
431 | + )) { |
|
432 | + wp_die(__('You don\'t have access to this page.', 'event_espresso'), '', array('back_link' => true)); |
|
433 | + } |
|
434 | + return true; |
|
435 | + } |
|
436 | 436 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $this->_set_menu_map(); |
79 | 79 | if (empty($this->_menu_map) || is_array($this->_menu_map)) { |
80 | 80 | EE_Error::doing_it_wrong( |
81 | - get_class($this) . '::$_menu_map', |
|
81 | + get_class($this).'::$_menu_map', |
|
82 | 82 | sprintf( |
83 | 83 | __( |
84 | 84 | 'The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core. Please see Admin_Page_Init class examples in core for the new way of setting this property up.', |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | { |
143 | 143 | wp_register_style( |
144 | 144 | 'espresso_menu', |
145 | - EE_ADMIN_URL . 'assets/admin-menu-styles.css', |
|
145 | + EE_ADMIN_URL.'assets/admin-menu-styles.css', |
|
146 | 146 | array('dashicons'), |
147 | 147 | EVENT_ESPRESSO_VERSION |
148 | 148 | ); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | protected function _set_capability() |
171 | 171 | { |
172 | 172 | $capability = empty($this->capability) ? $this->_menu_map->capability : $this->capability; |
173 | - $this->capability = apply_filters('FHEE_' . $this->_menu_map->menu_slug . '_capability', $capability); |
|
173 | + $this->capability = apply_filters('FHEE_'.$this->_menu_map->menu_slug.'_capability', $capability); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | { |
189 | 189 | // let's check user access first |
190 | 190 | $this->_check_user_access(); |
191 | - if (! is_object($this->_loaded_page_object)) { |
|
191 | + if ( ! is_object($this->_loaded_page_object)) { |
|
192 | 192 | return; |
193 | 193 | } |
194 | 194 | $this->_loaded_page_object->route_admin_request(); |
@@ -198,15 +198,15 @@ discard block |
||
198 | 198 | |
199 | 199 | public function set_page_dependencies($wp_page_slug) |
200 | 200 | { |
201 | - if (! $this->_load_page) { |
|
201 | + if ( ! $this->_load_page) { |
|
202 | 202 | return; |
203 | 203 | } |
204 | - if (! is_object($this->_loaded_page_object)) { |
|
204 | + if ( ! is_object($this->_loaded_page_object)) { |
|
205 | 205 | $msg[] = __( |
206 | 206 | 'We can\'t load the page because we\'re missing a valid page object that tells us what to load', |
207 | 207 | 'event_espresso' |
208 | 208 | ); |
209 | - $msg[] = $msg[0] . "\r\n" |
|
209 | + $msg[] = $msg[0]."\r\n" |
|
210 | 210 | . sprintf( |
211 | 211 | __( |
212 | 212 | 'The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory', |
@@ -214,15 +214,15 @@ discard block |
||
214 | 214 | ), |
215 | 215 | $this->_file_name, |
216 | 216 | $this->_file_name, |
217 | - $this->_folder_path . $this->_file_name, |
|
217 | + $this->_folder_path.$this->_file_name, |
|
218 | 218 | $this->_menu_map->menu_slug |
219 | 219 | ); |
220 | 220 | throw new EE_Error(implode('||', $msg)); |
221 | 221 | } |
222 | 222 | $this->_loaded_page_object->set_wp_page_slug($wp_page_slug); |
223 | - $page_hook = 'load-' . $wp_page_slug; |
|
223 | + $page_hook = 'load-'.$wp_page_slug; |
|
224 | 224 | // hook into page load hook so all page specific stuff get's loaded. |
225 | - if (! empty($wp_page_slug)) { |
|
225 | + if ( ! empty($wp_page_slug)) { |
|
226 | 226 | add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies')); |
227 | 227 | } |
228 | 228 | } |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | foreach ($bt as $index => $values) { |
260 | 260 | if (isset($values['class']) && $values['class'] == $class) { |
261 | 261 | $file_index = $index - 1; |
262 | - $this->_folder_name = basename(dirname($bt[ $file_index ]['file'])); |
|
263 | - if (! empty($this->_folder_name)) { |
|
262 | + $this->_folder_name = basename(dirname($bt[$file_index]['file'])); |
|
263 | + if ( ! empty($this->_folder_name)) { |
|
264 | 264 | break; |
265 | 265 | } |
266 | 266 | } |
267 | 267 | } |
268 | - $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/'; |
|
268 | + $this->_folder_path = EE_ADMIN_PAGES.$this->_folder_name.'/'; |
|
269 | 269 | $this->_file_name = preg_replace('/^ee/', 'EE', $this->_folder_name); |
270 | 270 | $this->_file_name = ucwords(str_replace('_', ' ', $this->_file_name)); |
271 | 271 | $this->_file_name = str_replace(' ', '_', $this->_file_name); |
@@ -301,12 +301,12 @@ discard block |
||
301 | 301 | // loop through decaf folders |
302 | 302 | $hook_files_glob_path = apply_filters( |
303 | 303 | 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path', |
304 | - $this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php' |
|
304 | + $this->_folder_path.'*'.$this->_file_name.'_Hooks.class.php' |
|
305 | 305 | ); |
306 | 306 | $this->_hook_paths = array_merge( |
307 | 307 | $this->_register_hook_files($hook_files_glob_path), |
308 | 308 | $this->_hook_paths |
309 | - ); // making sure any extended hook paths are later in the array than the core hook paths! |
|
309 | + ); // making sure any extended hook paths are later in the array than the core hook paths! |
|
310 | 310 | return $this->_hook_paths; |
311 | 311 | } |
312 | 312 | |
@@ -320,10 +320,10 @@ discard block |
||
320 | 320 | } |
321 | 321 | foreach ($hook_files as $file) { |
322 | 322 | // lets get the linked admin. |
323 | - $hook_file = $extend ? str_replace(EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . '/', '', $file) |
|
323 | + $hook_file = $extend ? str_replace(EE_CORE_CAF_ADMIN_EXTEND.$this->_folder_name.'/', '', $file) |
|
324 | 324 | : str_replace($this->_folder_path, '', $file); |
325 | 325 | $replace = $extend |
326 | - ? '_' . $this->_file_name . '_Hooks_Extend.class.php' |
|
326 | + ? '_'.$this->_file_name.'_Hooks_Extend.class.php' |
|
327 | 327 | : '_' |
328 | 328 | . $this->_file_name |
329 | 329 | . '_Hooks.class.php'; |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | continue; |
336 | 336 | } |
337 | 337 | $this->hook_file = $hook_file; |
338 | - $rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin; |
|
338 | + $rel_admin_hook = 'FHEE_do_other_page_hooks_'.$rel_admin; |
|
339 | 339 | $filter = add_filter($rel_admin_hook, array($this, 'load_admin_hook')); |
340 | 340 | $this->_files_hooked[] = $rel_admin; |
341 | 341 | } |
@@ -361,42 +361,42 @@ discard block |
||
361 | 361 | { |
362 | 362 | |
363 | 363 | // JUST CHECK WE'RE ON RIGHT PAGE. |
364 | - if ((! isset($_REQUEST['page']) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing) { |
|
364 | + if (( ! isset($_REQUEST['page']) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing) { |
|
365 | 365 | return; |
366 | 366 | } //not on the right page so let's get out. |
367 | 367 | $this->_load_page = true; |
368 | 368 | |
369 | 369 | // we don't need to do a page_request check here because it's only called via WP menu system. |
370 | - $admin_page = $this->_file_name . '_Admin_Page'; |
|
371 | - $hook_suffix = $this->_menu_map->menu_slug . '_' . $admin_page; |
|
370 | + $admin_page = $this->_file_name.'_Admin_Page'; |
|
371 | + $hook_suffix = $this->_menu_map->menu_slug.'_'.$admin_page; |
|
372 | 372 | $admin_page = apply_filters( |
373 | 373 | "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$hook_suffix}", |
374 | 374 | $admin_page |
375 | 375 | ); |
376 | 376 | // define requested admin page class name then load the file and instantiate |
377 | - $path_to_file = str_replace(array('\\', '/'), '/', $this->_folder_path . $admin_page . '.core.php'); |
|
377 | + $path_to_file = str_replace(array('\\', '/'), '/', $this->_folder_path.$admin_page.'.core.php'); |
|
378 | 378 | $path_to_file = apply_filters( |
379 | 379 | "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}", |
380 | 380 | $path_to_file |
381 | - );// so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page |
|
381 | + ); // so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page |
|
382 | 382 | if (is_readable($path_to_file)) { |
383 | 383 | // This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place |
384 | 384 | do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization'); |
385 | 385 | do_action( |
386 | - 'AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_' . $this->_menu_map->menu_slug |
|
386 | + 'AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_'.$this->_menu_map->menu_slug |
|
387 | 387 | ); |
388 | 388 | require_once($path_to_file); |
389 | 389 | $a = new ReflectionClass($admin_page); |
390 | 390 | $this->_loaded_page_object = $a->newInstance($this->_routing); |
391 | 391 | } |
392 | 392 | do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization'); |
393 | - do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_' . $this->_menu_map->menu_slug); |
|
393 | + do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_'.$this->_menu_map->menu_slug); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | |
397 | 397 | public function get_admin_page_name() |
398 | 398 | { |
399 | - return $this->_file_name . '_Admin_Page'; |
|
399 | + return $this->_file_name.'_Admin_Page'; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | */ |
426 | 426 | private function _check_user_access() |
427 | 427 | { |
428 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
428 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
429 | 429 | $this->_menu_map->capability, |
430 | 430 | $this->_menu_map->menu_slug |
431 | 431 | )) { |
@@ -6,7 +6,7 @@ |
||
6 | 6 | <tr class="item"> |
7 | 7 | <td>[LINE_ITEM_NAME][LINE_ITEM_TAXABLE_*]</td> |
8 | 8 | <td colspan="2">[LINE_ITEM_DESCRIPTION] |
9 | - <p class="ticket-note"><?php echo sprintf(__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema=' . __('any', 'event_espresso') . ']'); ?></p> |
|
9 | + <p class="ticket-note"><?php echo sprintf(__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema='.__('any', 'event_espresso').']'); ?></p> |
|
10 | 10 | </td> |
11 | 11 | <td class="item_c">[LINE_ITEM_QUANTITY]</td> |
12 | 12 | <td class="item_c">[LINE_ITEM_AMOUNT]</td> |
@@ -16,159 +16,159 @@ |
||
16 | 16 | interface CollectionInterface extends Countable, Iterator, Serializable, ArrayAccess |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * add |
|
21 | - * attaches an object to the Collection |
|
22 | - * and sets any supplied data associated with the current iterator entry |
|
23 | - * by calling EE_Object_Collection::set_identifier() |
|
24 | - * |
|
25 | - * @access public |
|
26 | - * @param $object |
|
27 | - * @param mixed $identifier |
|
28 | - * @return bool |
|
29 | - */ |
|
30 | - public function add($object, $identifier = null); |
|
31 | - |
|
32 | - /** |
|
33 | - * setIdentifier |
|
34 | - * Sets the data associated with an object in the Collection |
|
35 | - * if no $identifier is supplied, then the spl_object_hash() is used |
|
36 | - * |
|
37 | - * @access public |
|
38 | - * @param $object |
|
39 | - * @param mixed $identifier |
|
40 | - * @return bool |
|
41 | - */ |
|
42 | - public function setIdentifier($object, $identifier = null); |
|
43 | - |
|
44 | - /** |
|
45 | - * get |
|
46 | - * finds and returns an object in the Collection based on the identifier that was set using addObject() |
|
47 | - * PLZ NOTE: the pointer is reset to the beginning of the collection before returning |
|
48 | - * |
|
49 | - * @access public |
|
50 | - * @param mixed $identifier |
|
51 | - * @return mixed |
|
52 | - */ |
|
53 | - public function get($identifier); |
|
54 | - |
|
55 | - /** |
|
56 | - * has |
|
57 | - * returns TRUE or FALSE |
|
58 | - * depending on whether the object is within the Collection |
|
59 | - * based on the supplied $identifier |
|
60 | - * |
|
61 | - * @access public |
|
62 | - * @param mixed $identifier |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - public function has($identifier); |
|
66 | - |
|
67 | - /** |
|
68 | - * hasObject |
|
69 | - * returns TRUE or FALSE depending on whether the supplied object is within the Collection |
|
70 | - * |
|
71 | - * @access public |
|
72 | - * @param $object |
|
73 | - * @return bool |
|
74 | - */ |
|
75 | - public function hasObject($object); |
|
76 | - |
|
77 | - /** |
|
78 | - * remove |
|
79 | - * detaches an object from the Collection |
|
80 | - * |
|
81 | - * @access public |
|
82 | - * @param $object |
|
83 | - * @return bool |
|
84 | - */ |
|
85 | - public function remove($object); |
|
86 | - |
|
87 | - /** |
|
88 | - * setCurrent |
|
89 | - * advances pointer to the object whose identifier matches that which was provided |
|
90 | - * |
|
91 | - * @access public |
|
92 | - * @param mixed $identifier |
|
93 | - * @return boolean |
|
94 | - */ |
|
95 | - public function setCurrent($identifier); |
|
96 | - |
|
97 | - /** |
|
98 | - * setCurrentUsingObject |
|
99 | - * advances pointer to the provided object |
|
100 | - * |
|
101 | - * @access public |
|
102 | - * @param $object |
|
103 | - * @return boolean |
|
104 | - */ |
|
105 | - public function setCurrentUsingObject($object); |
|
106 | - |
|
107 | - /** |
|
108 | - * Returns the object occupying the index before the current object, |
|
109 | - * unless this is already the first object, in which case it just returns the first object |
|
110 | - * |
|
111 | - * @return mixed |
|
112 | - */ |
|
113 | - public function previous(); |
|
114 | - |
|
115 | - /** |
|
116 | - * Returns the index of a given object, or false if not found |
|
117 | - * |
|
118 | - * @see http://stackoverflow.com/a/8736013 |
|
119 | - * @param $object |
|
120 | - * @return boolean|int|string |
|
121 | - */ |
|
122 | - public function indexOf($object); |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * Returns the object at the given index |
|
127 | - * |
|
128 | - * @see http://stackoverflow.com/a/8736013 |
|
129 | - * @param $index |
|
130 | - * @return mixed |
|
131 | - */ |
|
132 | - public function objectAtIndex($index); |
|
133 | - |
|
134 | - /** |
|
135 | - * Returns the sequence of objects as specified by the offset and length |
|
136 | - * |
|
137 | - * @see http://stackoverflow.com/a/8736013 |
|
138 | - * @param int $offset |
|
139 | - * @param int $length |
|
140 | - * @return array |
|
141 | - */ |
|
142 | - public function slice($offset, $length); |
|
143 | - |
|
144 | - /** |
|
145 | - * Inserts an object (or an array of objects) at a certain point |
|
146 | - * |
|
147 | - * @see http://stackoverflow.com/a/8736013 |
|
148 | - * @param mixed $objects A single object or an array of objects |
|
149 | - * @param integer $index |
|
150 | - */ |
|
151 | - public function insertAt($objects, $index); |
|
152 | - |
|
153 | - /** |
|
154 | - * Removes the object at the given index |
|
155 | - * |
|
156 | - * @see http://stackoverflow.com/a/8736013 |
|
157 | - * @param integer $index |
|
158 | - */ |
|
159 | - public function removeAt($index); |
|
160 | - |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * detaches ALL objects from the Collection |
|
165 | - */ |
|
166 | - public function detachAll(); |
|
167 | - |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * unsets and detaches ALL objects from the Collection |
|
172 | - */ |
|
173 | - public function trashAndDetachAll(); |
|
19 | + /** |
|
20 | + * add |
|
21 | + * attaches an object to the Collection |
|
22 | + * and sets any supplied data associated with the current iterator entry |
|
23 | + * by calling EE_Object_Collection::set_identifier() |
|
24 | + * |
|
25 | + * @access public |
|
26 | + * @param $object |
|
27 | + * @param mixed $identifier |
|
28 | + * @return bool |
|
29 | + */ |
|
30 | + public function add($object, $identifier = null); |
|
31 | + |
|
32 | + /** |
|
33 | + * setIdentifier |
|
34 | + * Sets the data associated with an object in the Collection |
|
35 | + * if no $identifier is supplied, then the spl_object_hash() is used |
|
36 | + * |
|
37 | + * @access public |
|
38 | + * @param $object |
|
39 | + * @param mixed $identifier |
|
40 | + * @return bool |
|
41 | + */ |
|
42 | + public function setIdentifier($object, $identifier = null); |
|
43 | + |
|
44 | + /** |
|
45 | + * get |
|
46 | + * finds and returns an object in the Collection based on the identifier that was set using addObject() |
|
47 | + * PLZ NOTE: the pointer is reset to the beginning of the collection before returning |
|
48 | + * |
|
49 | + * @access public |
|
50 | + * @param mixed $identifier |
|
51 | + * @return mixed |
|
52 | + */ |
|
53 | + public function get($identifier); |
|
54 | + |
|
55 | + /** |
|
56 | + * has |
|
57 | + * returns TRUE or FALSE |
|
58 | + * depending on whether the object is within the Collection |
|
59 | + * based on the supplied $identifier |
|
60 | + * |
|
61 | + * @access public |
|
62 | + * @param mixed $identifier |
|
63 | + * @return bool |
|
64 | + */ |
|
65 | + public function has($identifier); |
|
66 | + |
|
67 | + /** |
|
68 | + * hasObject |
|
69 | + * returns TRUE or FALSE depending on whether the supplied object is within the Collection |
|
70 | + * |
|
71 | + * @access public |
|
72 | + * @param $object |
|
73 | + * @return bool |
|
74 | + */ |
|
75 | + public function hasObject($object); |
|
76 | + |
|
77 | + /** |
|
78 | + * remove |
|
79 | + * detaches an object from the Collection |
|
80 | + * |
|
81 | + * @access public |
|
82 | + * @param $object |
|
83 | + * @return bool |
|
84 | + */ |
|
85 | + public function remove($object); |
|
86 | + |
|
87 | + /** |
|
88 | + * setCurrent |
|
89 | + * advances pointer to the object whose identifier matches that which was provided |
|
90 | + * |
|
91 | + * @access public |
|
92 | + * @param mixed $identifier |
|
93 | + * @return boolean |
|
94 | + */ |
|
95 | + public function setCurrent($identifier); |
|
96 | + |
|
97 | + /** |
|
98 | + * setCurrentUsingObject |
|
99 | + * advances pointer to the provided object |
|
100 | + * |
|
101 | + * @access public |
|
102 | + * @param $object |
|
103 | + * @return boolean |
|
104 | + */ |
|
105 | + public function setCurrentUsingObject($object); |
|
106 | + |
|
107 | + /** |
|
108 | + * Returns the object occupying the index before the current object, |
|
109 | + * unless this is already the first object, in which case it just returns the first object |
|
110 | + * |
|
111 | + * @return mixed |
|
112 | + */ |
|
113 | + public function previous(); |
|
114 | + |
|
115 | + /** |
|
116 | + * Returns the index of a given object, or false if not found |
|
117 | + * |
|
118 | + * @see http://stackoverflow.com/a/8736013 |
|
119 | + * @param $object |
|
120 | + * @return boolean|int|string |
|
121 | + */ |
|
122 | + public function indexOf($object); |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * Returns the object at the given index |
|
127 | + * |
|
128 | + * @see http://stackoverflow.com/a/8736013 |
|
129 | + * @param $index |
|
130 | + * @return mixed |
|
131 | + */ |
|
132 | + public function objectAtIndex($index); |
|
133 | + |
|
134 | + /** |
|
135 | + * Returns the sequence of objects as specified by the offset and length |
|
136 | + * |
|
137 | + * @see http://stackoverflow.com/a/8736013 |
|
138 | + * @param int $offset |
|
139 | + * @param int $length |
|
140 | + * @return array |
|
141 | + */ |
|
142 | + public function slice($offset, $length); |
|
143 | + |
|
144 | + /** |
|
145 | + * Inserts an object (or an array of objects) at a certain point |
|
146 | + * |
|
147 | + * @see http://stackoverflow.com/a/8736013 |
|
148 | + * @param mixed $objects A single object or an array of objects |
|
149 | + * @param integer $index |
|
150 | + */ |
|
151 | + public function insertAt($objects, $index); |
|
152 | + |
|
153 | + /** |
|
154 | + * Removes the object at the given index |
|
155 | + * |
|
156 | + * @see http://stackoverflow.com/a/8736013 |
|
157 | + * @param integer $index |
|
158 | + */ |
|
159 | + public function removeAt($index); |
|
160 | + |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * detaches ALL objects from the Collection |
|
165 | + */ |
|
166 | + public function detachAll(); |
|
167 | + |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * unsets and detaches ALL objects from the Collection |
|
172 | + */ |
|
173 | + public function trashAndDetachAll(); |
|
174 | 174 | } |
@@ -73,7 +73,7 @@ |
||
73 | 73 | } |
74 | 74 | $session_lifespan_in_hours = round($this->session_lifespan->inSeconds() / HOUR_IN_SECONDS); |
75 | 75 | return (string) EEH_Template::display_template( |
76 | - __DIR__ . '/privacy_policy.template.php', |
|
76 | + __DIR__.'/privacy_policy.template.php', |
|
77 | 77 | array( |
78 | 78 | 'active_onsite_payment_methods' => $active_onsite_pms, |
79 | 79 | 'active_offsite_payment_methods' => $active_offsite_pms, |
@@ -20,80 +20,80 @@ |
||
20 | 20 | class PrivacyPolicy implements PrivacyPolicyInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var EEM_Payment_Method |
|
25 | - */ |
|
26 | - protected $payment_method_model; |
|
23 | + /** |
|
24 | + * @var EEM_Payment_Method |
|
25 | + */ |
|
26 | + protected $payment_method_model; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var SessionLifespan |
|
30 | - */ |
|
31 | - protected $session_lifespan; |
|
28 | + /** |
|
29 | + * @var SessionLifespan |
|
30 | + */ |
|
31 | + protected $session_lifespan; |
|
32 | 32 | |
33 | - /** |
|
34 | - * PrivacyPolicy constructor. |
|
35 | - * |
|
36 | - * @param EEM_Payment_Method $payment_method_model |
|
37 | - * @param SessionLifespan $session_lifespan |
|
38 | - */ |
|
39 | - public function __construct(EEM_Payment_Method $payment_method_model, SessionLifespan $session_lifespan) |
|
40 | - { |
|
41 | - $this->payment_method_model = $payment_method_model; |
|
42 | - $this->session_lifespan = $session_lifespan; |
|
43 | - } |
|
33 | + /** |
|
34 | + * PrivacyPolicy constructor. |
|
35 | + * |
|
36 | + * @param EEM_Payment_Method $payment_method_model |
|
37 | + * @param SessionLifespan $session_lifespan |
|
38 | + */ |
|
39 | + public function __construct(EEM_Payment_Method $payment_method_model, SessionLifespan $session_lifespan) |
|
40 | + { |
|
41 | + $this->payment_method_model = $payment_method_model; |
|
42 | + $this->session_lifespan = $session_lifespan; |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * Returns the name of the plugin and will be shown in the privacy policy's postbox header |
|
48 | - * |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function getName() |
|
52 | - { |
|
53 | - return esc_html__('Event Espresso', 'event_espresso'); |
|
54 | - } |
|
46 | + /** |
|
47 | + * Returns the name of the plugin and will be shown in the privacy policy's postbox header |
|
48 | + * |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function getName() |
|
52 | + { |
|
53 | + return esc_html__('Event Espresso', 'event_espresso'); |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * Gets the HTML for the privacy policy. May be dynamic |
|
59 | - * |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function getContent() |
|
63 | - { |
|
64 | - // do they have any offsite payment methods? or onsite payment methods? |
|
65 | - $active_payment_methods = $this->payment_method_model->get_all_active(EEM_Payment_Method::scope_cart); |
|
66 | - $active_onsite_pms = array(); |
|
67 | - $active_offsite_pms = array(); |
|
68 | - foreach ($active_payment_methods as $payment_method) { |
|
69 | - if ($payment_method->type_obj() instanceof \EE_PMT_Base) { |
|
70 | - if ($payment_method->type_obj()->get_gateway() instanceof EE_Onsite_Gateway) { |
|
71 | - $active_onsite_pms[] = $payment_method->name(); |
|
72 | - } elseif ($payment_method->type_obj()->get_gateway() instanceof EE_Offsite_Gateway) { |
|
73 | - $active_offsite_pms[] = $payment_method->name(); |
|
74 | - } |
|
75 | - } |
|
76 | - } |
|
77 | - $session_lifespan_in_hours = round($this->session_lifespan->inSeconds() / HOUR_IN_SECONDS); |
|
78 | - return (string) EEH_Template::display_template( |
|
79 | - __DIR__ . '/privacy_policy.template.php', |
|
80 | - array( |
|
81 | - 'active_onsite_payment_methods' => $active_onsite_pms, |
|
82 | - 'active_offsite_payment_methods' => $active_offsite_pms, |
|
83 | - 'session_lifespan' => sprintf( |
|
84 | - _nx( |
|
85 | - '%1$s hour', |
|
86 | - '%1$s hours', |
|
87 | - $session_lifespan_in_hours, |
|
88 | - '2 hours', |
|
89 | - 'event_espresso' |
|
90 | - ), |
|
91 | - $session_lifespan_in_hours |
|
92 | - ) |
|
93 | - ), |
|
94 | - true |
|
95 | - ); |
|
96 | - } |
|
57 | + /** |
|
58 | + * Gets the HTML for the privacy policy. May be dynamic |
|
59 | + * |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function getContent() |
|
63 | + { |
|
64 | + // do they have any offsite payment methods? or onsite payment methods? |
|
65 | + $active_payment_methods = $this->payment_method_model->get_all_active(EEM_Payment_Method::scope_cart); |
|
66 | + $active_onsite_pms = array(); |
|
67 | + $active_offsite_pms = array(); |
|
68 | + foreach ($active_payment_methods as $payment_method) { |
|
69 | + if ($payment_method->type_obj() instanceof \EE_PMT_Base) { |
|
70 | + if ($payment_method->type_obj()->get_gateway() instanceof EE_Onsite_Gateway) { |
|
71 | + $active_onsite_pms[] = $payment_method->name(); |
|
72 | + } elseif ($payment_method->type_obj()->get_gateway() instanceof EE_Offsite_Gateway) { |
|
73 | + $active_offsite_pms[] = $payment_method->name(); |
|
74 | + } |
|
75 | + } |
|
76 | + } |
|
77 | + $session_lifespan_in_hours = round($this->session_lifespan->inSeconds() / HOUR_IN_SECONDS); |
|
78 | + return (string) EEH_Template::display_template( |
|
79 | + __DIR__ . '/privacy_policy.template.php', |
|
80 | + array( |
|
81 | + 'active_onsite_payment_methods' => $active_onsite_pms, |
|
82 | + 'active_offsite_payment_methods' => $active_offsite_pms, |
|
83 | + 'session_lifespan' => sprintf( |
|
84 | + _nx( |
|
85 | + '%1$s hour', |
|
86 | + '%1$s hours', |
|
87 | + $session_lifespan_in_hours, |
|
88 | + '2 hours', |
|
89 | + 'event_espresso' |
|
90 | + ), |
|
91 | + $session_lifespan_in_hours |
|
92 | + ) |
|
93 | + ), |
|
94 | + true |
|
95 | + ); |
|
96 | + } |
|
97 | 97 | } |
98 | 98 | // End of file PrivacyPolicy.php |
99 | 99 | // Location: EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy.php |
@@ -16,41 +16,41 @@ |
||
16 | 16 | class BlockAssetManagerCollection extends Collection |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * Collection constructor |
|
21 | - * |
|
22 | - * @throws InvalidInterfaceException |
|
23 | - */ |
|
24 | - public function __construct() |
|
25 | - { |
|
26 | - parent::__construct('EventEspresso\core\services\assets\BlockAssetManager'); |
|
27 | - } |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public function addAssets() |
|
34 | - { |
|
35 | - $this->rewind(); |
|
36 | - while ($this->valid()) { |
|
37 | - $this->current()->addAssets(); |
|
38 | - $this->next(); |
|
39 | - } |
|
40 | - $this->rewind(); |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * @return void |
|
46 | - */ |
|
47 | - public function enqueueAssets() |
|
48 | - { |
|
49 | - $this->rewind(); |
|
50 | - while ($this->valid()) { |
|
51 | - $this->current()->enqueueAssets(); |
|
52 | - $this->next(); |
|
53 | - } |
|
54 | - $this->rewind(); |
|
55 | - } |
|
19 | + /** |
|
20 | + * Collection constructor |
|
21 | + * |
|
22 | + * @throws InvalidInterfaceException |
|
23 | + */ |
|
24 | + public function __construct() |
|
25 | + { |
|
26 | + parent::__construct('EventEspresso\core\services\assets\BlockAssetManager'); |
|
27 | + } |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public function addAssets() |
|
34 | + { |
|
35 | + $this->rewind(); |
|
36 | + while ($this->valid()) { |
|
37 | + $this->current()->addAssets(); |
|
38 | + $this->next(); |
|
39 | + } |
|
40 | + $this->rewind(); |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * @return void |
|
46 | + */ |
|
47 | + public function enqueueAssets() |
|
48 | + { |
|
49 | + $this->rewind(); |
|
50 | + while ($this->valid()) { |
|
51 | + $this->current()->enqueueAssets(); |
|
52 | + $this->next(); |
|
53 | + } |
|
54 | + $this->rewind(); |
|
55 | + } |
|
56 | 56 | } |