@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EEG_Aim extends EE_Onsite_Gateway{ |
|
28 | +class EEG_Aim extends EE_Onsite_Gateway { |
|
29 | 29 | protected $_login_id; |
30 | 30 | protected $_transaction_key; |
31 | 31 | protected $_currencies_supported = array( |
@@ -98,17 +98,17 @@ discard block |
||
98 | 98 | $primary_registrant = $transaction->primary_registration(); |
99 | 99 | //if we're are charging for the full amount, show the normal line items |
100 | 100 | //and the itemized total adds up properly |
101 | - if( $this->_can_easily_itemize_transaction_for( $payment ) ){ |
|
101 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
102 | 102 | $total_line_item = $transaction->total_line_item(); |
103 | 103 | foreach ($total_line_item->get_items() as $line_item) { |
104 | 104 | $this->addLineItem($item_num++, $line_item->name(), $line_item->desc(), $line_item->quantity(), $line_item->unit_price(), 'N'); |
105 | 105 | $order_description .= $line_item->desc().', '; |
106 | 106 | } |
107 | - foreach($total_line_item->tax_descendants() as $tax_line_item){ |
|
107 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
108 | 108 | $this->addLineItem($item_num++, $tax_line_item->name(), $tax_line_item->desc(), 1, $tax_line_item->total(), 'N'); |
109 | 109 | } |
110 | - }else{//partial payment |
|
111 | - $order_description = sprintf(__("Payment of %s for %s", "event_espresso"),$payment->amount(),$primary_registrant->reg_code()); |
|
110 | + } else {//partial payment |
|
111 | + $order_description = sprintf(__("Payment of %s for %s", "event_espresso"), $payment->amount(), $primary_registrant->reg_code()); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
@@ -117,18 +117,18 @@ discard block |
||
117 | 117 | //start transaction |
118 | 118 | //if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id |
119 | 119 | $partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363'; |
120 | - $this->setField( 'solution_id', $partner_id ); |
|
120 | + $this->setField('solution_id', $partner_id); |
|
121 | 121 | $this->setField('amount', $this->format_currency($payment->amount())); |
122 | - $this->setField('description',substr(rtrim($order_description, ', '), 0, 255)); |
|
123 | - $this->_set_sensitive_billing_data( $billing_info ); |
|
122 | + $this->setField('description', substr(rtrim($order_description, ', '), 0, 255)); |
|
123 | + $this->_set_sensitive_billing_data($billing_info); |
|
124 | 124 | $this->setField('first_name', $billing_info['first_name']); |
125 | 125 | $this->setField('last_name', $billing_info['last_name']); |
126 | 126 | $this->setField('email', $billing_info['email']); |
127 | 127 | $this->setField('company', $billing_info['company']); |
128 | 128 | $this->setField('address', $billing_info['address'].' '.$billing_info['address2']); |
129 | 129 | $this->setField('city', $billing_info['city']); |
130 | - $this->setField('state', $billing_info['state'] ); |
|
131 | - $this->setField('country', $billing_info['country'] ); |
|
130 | + $this->setField('state', $billing_info['state']); |
|
131 | + $this->setField('country', $billing_info['country']); |
|
132 | 132 | $this->setField('zip', $billing_info['zip']); |
133 | 133 | $this->setField('fax', $billing_info['fax']); |
134 | 134 | $this->setField('cust_id', $primary_registrant->ID()); |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | //invoice_num would be nice to have itbe unique per SPCO page-load, taht way if users |
137 | 137 | //press back, they don't submit a duplicate. However, we may be keepin gthe user on teh same spco page |
138 | 138 | //in which case, we need to generate teh invoice num per request right here... |
139 | - $this->setField('invoice_num', wp_generate_password(12,false));//$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
139 | + $this->setField('invoice_num', wp_generate_password(12, false)); //$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
140 | 140 | //tell AIM that any duplicates sent in the next 5 minutes are to be ignored |
141 | - $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS ); |
|
141 | + $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS); |
|
142 | 142 | |
143 | 143 | |
144 | 144 | if ($this->_test_transactions) { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | //Capture response |
149 | 149 | $this->type = "AUTH_CAPTURE"; |
150 | 150 | $response = $this->_sendRequest($payment); |
151 | - if (!empty($response)){ |
|
151 | + if ( ! empty($response)) { |
|
152 | 152 | if ($this->_debug_mode) { |
153 | 153 | $txn_id = $response->invoice_number; |
154 | 154 | } else { |
@@ -157,15 +157,15 @@ discard block |
||
157 | 157 | $payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status(); |
158 | 158 | $payment->set_status($payment_status); |
159 | 159 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand seperators) |
160 | - $payment->set_amount( floatval( $response->amount ) ); |
|
161 | - $payment->set_gateway_response(sprintf("%s (code: %s)",$response->response_reason_text,$response->response_reason_code)); |
|
162 | - $payment->set_txn_id_chq_nmbr( $txn_id ); |
|
160 | + $payment->set_amount(floatval($response->amount)); |
|
161 | + $payment->set_gateway_response(sprintf("%s (code: %s)", $response->response_reason_text, $response->response_reason_code)); |
|
162 | + $payment->set_txn_id_chq_nmbr($txn_id); |
|
163 | 163 | $payment->set_extra_accntng($primary_registrant->reg_code()); |
164 | - $payment->set_details(print_r($response,true)); |
|
164 | + $payment->set_details(print_r($response, true)); |
|
165 | 165 | } else { |
166 | 166 | $payment->set_status($this->_pay_model->failed_status()); |
167 | 167 | $payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso')); |
168 | - $payment->set_details(print_r($response,true)); |
|
168 | + $payment->set_details(print_r($response, true)); |
|
169 | 169 | } |
170 | 170 | return $payment; |
171 | 171 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * what billing data gets sent |
177 | 177 | * @param array $billing_info |
178 | 178 | */ |
179 | - protected function _set_sensitive_billing_data( $billing_info ) { |
|
179 | + protected function _set_sensitive_billing_data($billing_info) { |
|
180 | 180 | $this->setField('card_num', $billing_info['credit_card']); |
181 | 181 | $this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']); |
182 | 182 | $this->setField('card_code', $billing_info['cvv']); |
@@ -228,22 +228,22 @@ discard block |
||
228 | 228 | $this->_x_post_fields['tran_key'] = $this->_transaction_key; |
229 | 229 | $x_keys = array(); |
230 | 230 | foreach ($this->_x_post_fields as $key => $value) { |
231 | - $x_keys[] = "x_$key=" . urlencode($value); |
|
231 | + $x_keys[] = "x_$key=".urlencode($value); |
|
232 | 232 | } |
233 | 233 | // Add line items |
234 | 234 | foreach ($this->_additional_line_items as $key => $value) { |
235 | - $x_keys[] = "x_line_item=" . urlencode($value); |
|
235 | + $x_keys[] = "x_line_item=".urlencode($value); |
|
236 | 236 | } |
237 | 237 | $this->_log_clean_request($x_keys, $payment); |
238 | 238 | $post_url = ($this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL); |
239 | 239 | $curl_request = curl_init($post_url); |
240 | - curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&",$x_keys)); |
|
240 | + curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&", $x_keys)); |
|
241 | 241 | curl_setopt($curl_request, CURLOPT_HEADER, 0); |
242 | 242 | curl_setopt($curl_request, CURLOPT_TIMEOUT, 45); |
243 | 243 | curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); |
244 | 244 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); |
245 | 245 | if ($this->VERIFY_PEER) { |
246 | - curl_setopt($curl_request, CURLOPT_CAINFO, dirname(dirname(__FILE__)) . '/ssl/cert.pem'); |
|
246 | + curl_setopt($curl_request, CURLOPT_CAINFO, dirname(dirname(__FILE__)).'/ssl/cert.pem'); |
|
247 | 247 | } else { |
248 | 248 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); |
249 | 249 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $response = curl_exec($curl_request); |
256 | 256 | |
257 | 257 | curl_close($curl_request); |
258 | - $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
258 | + $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
259 | 259 | |
260 | 260 | return $this->_log_and_clean_response($response_obj, $payment); |
261 | 261 | } |
@@ -264,18 +264,18 @@ discard block |
||
264 | 264 | * @param array $request_array |
265 | 265 | * @param EEI_Payment $payment |
266 | 266 | */ |
267 | - protected function _log_clean_request($request_array,$payment){ |
|
268 | - $keys_to_filter_out = array( 'x_card_num', 'x_card_code', 'x_exp_date' ); |
|
269 | - foreach($request_array as $index => $keyvaltogether ) { |
|
270 | - foreach( $keys_to_filter_out as $key ) { |
|
271 | - if( strpos( $keyvaltogether, $key ) === 0 ){ |
|
267 | + protected function _log_clean_request($request_array, $payment) { |
|
268 | + $keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date'); |
|
269 | + foreach ($request_array as $index => $keyvaltogether) { |
|
270 | + foreach ($keys_to_filter_out as $key) { |
|
271 | + if (strpos($keyvaltogether, $key) === 0) { |
|
272 | 272 | //found it at the first character |
273 | 273 | //so its one of them |
274 | - unset( $request_array[ $index ] ); |
|
274 | + unset($request_array[$index]); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | } |
278 | - $this->log(array('AIM Request sent:'=>$request_array),$payment); |
|
278 | + $this->log(array('AIM Request sent:'=>$request_array), $payment); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -283,9 +283,9 @@ discard block |
||
283 | 283 | * @param EE_AuthorizeNetAIM_Response $response_obj |
284 | 284 | * @param EE_Payment $payment |
285 | 285 | */ |
286 | - private function _log_and_clean_response($response_obj,$payment){ |
|
286 | + private function _log_and_clean_response($response_obj, $payment) { |
|
287 | 287 | $response_obj->account_number = ''; |
288 | - $this->log(array('AIM Response received:'=>$response_obj),$payment); |
|
288 | + $this->log(array('AIM Response received:'=>$response_obj), $payment); |
|
289 | 289 | return $response_obj; |
290 | 290 | } |
291 | 291 | |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | // Split Array |
382 | 382 | $this->response = $response; |
383 | 383 | if ($encap_char) { |
384 | - $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1)); |
|
384 | + $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1)); |
|
385 | 385 | } else { |
386 | 386 | $this->_response_array = explode($delimiter, $response); |
387 | 387 | } |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | $this->held = ($this->response_code == self::HELD); |
452 | 452 | |
453 | 453 | if ($this->error || $this->declined || $this->held) { |
454 | - $this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />' . $this->response_reason_text . '<br /><span class="response_code">Response Code: ' . $this->response_code . '<br /></span><span class="response_subcode">Response Subcode: ' . $this->response_subcode . '</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> '; |
|
454 | + $this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />'.$this->response_reason_text.'<br /><span class="response_code">Response Code: '.$this->response_code.'<br /></span><span class="response_subcode">Response Subcode: '.$this->response_subcode.'</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> '; |
|
455 | 455 | |
456 | 456 | |
457 | 457 | /* $this->error_message = "AuthorizeNet Error: |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EE_PMT_Aim extends EE_PMT_Base{ |
|
28 | +class EE_PMT_Aim extends EE_PMT_Base { |
|
29 | 29 | |
30 | 30 | |
31 | 31 | /** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | require_once($this->file_folder().'EEG_Aim.gateway.php'); |
49 | 49 | $this->_gateway = new EEG_AIM(); |
50 | 50 | $this->_pretty_name = __("Authorize.net AIM", 'event_espresso'); |
51 | - $this->_default_description = __( 'Please provide the following billing information.', 'event_espresso' ); |
|
51 | + $this->_default_description = __('Please provide the following billing information.', 'event_espresso'); |
|
52 | 52 | $this->_requires_https = true; |
53 | 53 | } |
54 | 54 | |
@@ -57,60 +57,60 @@ discard block |
||
57 | 57 | * @param \EE_Transaction $transaction |
58 | 58 | * @return EE_Billing_Info_Form |
59 | 59 | */ |
60 | - public function generate_new_billing_form( EE_Transaction $transaction = NULL ) { |
|
61 | - $billing_form = new EE_Billing_Attendee_Info_Form($this->_pm_instance,array( |
|
60 | + public function generate_new_billing_form(EE_Transaction $transaction = NULL) { |
|
61 | + $billing_form = new EE_Billing_Attendee_Info_Form($this->_pm_instance, array( |
|
62 | 62 | 'name'=>'AIM_Form', |
63 | 63 | 'subsections'=>array( |
64 | 64 | 'credit_card'=>new EE_Credit_Card_Input(array( |
65 | 65 | 'required'=>true, |
66 | - 'html_label_text' => __( 'Card Number', 'event_espresso' ) |
|
66 | + 'html_label_text' => __('Card Number', 'event_espresso') |
|
67 | 67 | )), |
68 | 68 | 'exp_month'=>new EE_Credit_Card_Month_Input(true, array( |
69 | 69 | 'required'=>true, |
70 | - 'html_label_text' => __( 'Expiry Month', 'event_espresso' ) |
|
70 | + 'html_label_text' => __('Expiry Month', 'event_espresso') |
|
71 | 71 | )), |
72 | - 'exp_year'=>new EE_Credit_Card_Year_Input( array( |
|
72 | + 'exp_year'=>new EE_Credit_Card_Year_Input(array( |
|
73 | 73 | 'required'=>true, |
74 | - 'html_label_text' => __( 'Expiry Year', 'event_espresso' ) |
|
74 | + 'html_label_text' => __('Expiry Year', 'event_espresso') |
|
75 | 75 | )), |
76 | - 'cvv'=>new EE_CVV_Input( array( |
|
76 | + 'cvv'=>new EE_CVV_Input(array( |
|
77 | 77 | 'required'=>true, |
78 | - 'html_label_text' => __( 'CVV', 'event_espresso' ) ) ), |
|
78 | + 'html_label_text' => __('CVV', 'event_espresso') )), |
|
79 | 79 | ) |
80 | 80 | )); |
81 | - $billing_form->add_subsections( array( |
|
82 | - 'company' => new EE_Text_Input( array( |
|
81 | + $billing_form->add_subsections(array( |
|
82 | + 'company' => new EE_Text_Input(array( |
|
83 | 83 | 'html_label_text' => __('Company', 'event_espresso') |
84 | 84 | )) |
85 | - ), 'email', false ); |
|
85 | + ), 'email', false); |
|
86 | 86 | $billing_form->add_subsections( |
87 | 87 | array( |
88 | - 'fax' => new EE_Text_Input( array( |
|
88 | + 'fax' => new EE_Text_Input(array( |
|
89 | 89 | 'html_label_text' => __('Fax', 'event_espresso') |
90 | 90 | )) |
91 | 91 | ), |
92 | 92 | 'phone', |
93 | 93 | false ); |
94 | 94 | $settings_form = $this->settings_form(); |
95 | - if( $settings_form->get_input( 'excluded_billing_inputs' ) instanceof EE_Checkbox_Multi_Input ) { |
|
96 | - $billing_form->exclude( $settings_form->get_input( 'excluded_billing_inputs' )->normalized_value() ); |
|
95 | + if ($settings_form->get_input('excluded_billing_inputs') instanceof EE_Checkbox_Multi_Input) { |
|
96 | + $billing_form->exclude($settings_form->get_input('excluded_billing_inputs')->normalized_value()); |
|
97 | 97 | } |
98 | - if( $settings_form->get_input( 'required_billing_inputs' ) instanceof EE_Checkbox_Multi_Input ) { |
|
99 | - $required_inputs = $settings_form->get_input( 'required_billing_inputs' )->normalized_value(); |
|
98 | + if ($settings_form->get_input('required_billing_inputs') instanceof EE_Checkbox_Multi_Input) { |
|
99 | + $required_inputs = $settings_form->get_input('required_billing_inputs')->normalized_value(); |
|
100 | 100 | //only change the requirement of inputs which are allowed to be changed |
101 | 101 | $inputs_to_evaluate = array_intersect_key( |
102 | 102 | $billing_form->inputs(), |
103 | 103 | $this->billing_input_names() |
104 | 104 | ); |
105 | - foreach( $inputs_to_evaluate as $input_name => $input ) { |
|
106 | - if( in_array( $input_name, $required_inputs ) ) { |
|
107 | - $input->set_required( true ); |
|
105 | + foreach ($inputs_to_evaluate as $input_name => $input) { |
|
106 | + if (in_array($input_name, $required_inputs)) { |
|
107 | + $input->set_required(true); |
|
108 | 108 | } else { |
109 | - $input->set_required( false ); |
|
109 | + $input->set_required(false); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
113 | - return $this->apply_billing_form_debug_settings( $billing_form ); |
|
113 | + return $this->apply_billing_form_debug_settings($billing_form); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
@@ -122,19 +122,19 @@ discard block |
||
122 | 122 | * @param \EE_Billing_Info_Form $billing_form |
123 | 123 | * @return \EE_Billing_Info_Form |
124 | 124 | */ |
125 | - public function apply_billing_form_debug_settings( EE_Billing_Info_Form $billing_form ) { |
|
126 | - if ( $this->_pm_instance->debug_mode() || $this->_pm_instance->get_extra_meta( 'test_transactions', TRUE, FALSE )) { |
|
127 | - $billing_form->get_input( 'credit_card' )->set_default( '4007000000027' ); |
|
128 | - $billing_form->get_input( 'exp_year' )->set_default( '2020' ); |
|
129 | - if( $billing_form->get_subsection( 'cvv' ) instanceof EE_Form_Input_Base ) { |
|
130 | - $billing_form->get_input( 'cvv' )->set_default(( '123' )); |
|
125 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) { |
|
126 | + if ($this->_pm_instance->debug_mode() || $this->_pm_instance->get_extra_meta('test_transactions', TRUE, FALSE)) { |
|
127 | + $billing_form->get_input('credit_card')->set_default('4007000000027'); |
|
128 | + $billing_form->get_input('exp_year')->set_default('2020'); |
|
129 | + if ($billing_form->get_subsection('cvv') instanceof EE_Form_Input_Base) { |
|
130 | + $billing_form->get_input('cvv')->set_default(('123')); |
|
131 | 131 | } |
132 | 132 | $billing_form->add_subsections( |
133 | - array( 'fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html() ), |
|
133 | + array('fyi_about_autofill' => $billing_form->payment_fields_autofilled_notice_html()), |
|
134 | 134 | 'credit_card' |
135 | 135 | ); |
136 | 136 | $billing_form->add_subsections( |
137 | - array( 'debug_content' => new EE_Form_Section_HTML_From_Template( dirname(__FILE__).DS.'templates'.DS.'authorize_net_aim_debug_info.template.php' )), |
|
137 | + array('debug_content' => new EE_Form_Section_HTML_From_Template(dirname(__FILE__).DS.'templates'.DS.'authorize_net_aim_debug_info.template.php')), |
|
138 | 138 | 'first_name' |
139 | 139 | ); |
140 | 140 | } |
@@ -154,17 +154,17 @@ discard block |
||
154 | 154 | 'extra_meta_inputs'=>array( |
155 | 155 | 'login_id'=>new EE_Text_Input( |
156 | 156 | array( |
157 | - 'html_label_text'=> sprintf( __("Authorize.net API Login ID %s", "event_espresso"), $this->get_help_tab_link() ), |
|
157 | + 'html_label_text'=> sprintf(__("Authorize.net API Login ID %s", "event_espresso"), $this->get_help_tab_link()), |
|
158 | 158 | 'required' => true ) |
159 | 159 | ), |
160 | 160 | 'transaction_key'=>new EE_Text_Input( |
161 | 161 | array( |
162 | - 'html_label_text'=> sprintf( __("Authorize.net Transaction Key %s", "event_espresso"), $this->get_help_tab_link() ), |
|
162 | + 'html_label_text'=> sprintf(__("Authorize.net Transaction Key %s", "event_espresso"), $this->get_help_tab_link()), |
|
163 | 163 | 'required' => true ) |
164 | 164 | ), |
165 | 165 | 'test_transactions'=>new EE_Yes_No_Input( |
166 | 166 | array( |
167 | - 'html_label_text'=> sprintf( __("Send test transactions? %s", 'event_espresso'), $this->get_help_tab_link() ), |
|
167 | + 'html_label_text'=> sprintf(__("Send test transactions? %s", 'event_espresso'), $this->get_help_tab_link()), |
|
168 | 168 | 'html_help_text'=> __("Send test transactions, even to live server", 'event_espresso'), |
169 | 169 | 'default' => false, |
170 | 170 | 'required' => true |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | 'excluded_billing_inputs' => new EE_Checkbox_Multi_Input( |
174 | 174 | $billing_input_names, |
175 | 175 | array( |
176 | - 'html_label_text' => sprintf( __("Excluded Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link() ), |
|
176 | + 'html_label_text' => sprintf(__("Excluded Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()), |
|
177 | 177 | 'default' => array( |
178 | 178 | 'company', |
179 | 179 | 'fax', |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | 'required_billing_inputs' => new EE_Checkbox_Multi_Input( |
183 | 183 | $billing_input_names, |
184 | 184 | array( |
185 | - 'html_label_text' => sprintf( __("Required Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link() ), |
|
185 | + 'html_label_text' => sprintf(__("Required Payment Form Fields %s", 'event_espresso'), $this->get_help_tab_link()), |
|
186 | 186 | 'default' => array_diff( |
187 | - array_keys( $billing_input_names ), |
|
188 | - array( 'address2', 'phone', 'company', 'fax' ) |
|
187 | + array_keys($billing_input_names), |
|
188 | + array('address2', 'phone', 'company', 'fax') |
|
189 | 189 | ), |
190 | 190 | 'html_help_text' => __('Note: if fields are excluded they cannot be required.', 'event_espresso') |
191 | 191 | )), |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function billing_input_names() { |
203 | 203 | return array( |
204 | - 'first_name' => __( 'First Name', 'event_espresso' ), |
|
204 | + 'first_name' => __('First Name', 'event_espresso'), |
|
205 | 205 | 'last_name' => __('Last Name', 'event_espresso'), |
206 | - 'email' => __( 'Email', 'event_espresso' ), |
|
207 | - 'company' => __( 'Company', 'event_espresso' ), |
|
206 | + 'email' => __('Email', 'event_espresso'), |
|
207 | + 'company' => __('Company', 'event_espresso'), |
|
208 | 208 | 'address' => __('Address', 'event_espresso'), |
209 | 209 | 'address2' => __('Address2', 'event_espresso'), |
210 | 210 | 'city' => __('City', 'event_espresso'), |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | 'country' => __('Country', 'event_espresso'), |
213 | 213 | 'zip' => __('Zip', 'event_espresso'), |
214 | 214 | 'phone' => __('Phone', 'event_espresso'), |
215 | - 'fax' => __( 'Fax', 'event_espresso' ), |
|
215 | + 'fax' => __('Fax', 'event_espresso'), |
|
216 | 216 | 'cvv' => __('CVV', 'event_espresso') |
217 | 217 | ); |
218 | 218 | } |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * @param type $billing_form |
224 | 224 | * @return array |
225 | 225 | */ |
226 | - protected function _get_billing_values_from_form( $billing_form ){ |
|
226 | + protected function _get_billing_values_from_form($billing_form) { |
|
227 | 227 | $all_billing_values_empty = array(); |
228 | - foreach( array_keys( $this->billing_input_names() ) as $input_name ) { |
|
229 | - $all_billing_values_empty[ $input_name ] = ''; |
|
228 | + foreach (array_keys($this->billing_input_names()) as $input_name) { |
|
229 | + $all_billing_values_empty[$input_name] = ''; |
|
230 | 230 | } |
231 | 231 | return array_merge( |
232 | 232 | $all_billing_values_empty, |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @see EE_PMT_Base::help_tabs_config() |
242 | 242 | * @return array |
243 | 243 | */ |
244 | - public function help_tabs_config(){ |
|
244 | + public function help_tabs_config() { |
|
245 | 245 | return array( |
246 | 246 | $this->get_help_tab_name() => array( |
247 | 247 | 'title' => __('Authorize.net AIM Settings', 'event_espresso'), |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @since $VID:$ |
15 | 15 | * |
16 | 16 | */ |
17 | -abstract class EE_PMT_Base{ |
|
17 | +abstract class EE_PMT_Base { |
|
18 | 18 | |
19 | 19 | const onsite = 'on-site'; |
20 | 20 | const offsite = 'off-site'; |
@@ -95,34 +95,34 @@ discard block |
||
95 | 95 | * @return EE_PMT_Base |
96 | 96 | */ |
97 | 97 | function __construct($pm_instance = NULL) { |
98 | - if ( $pm_instance instanceof EE_Payment_Method ){ |
|
98 | + if ($pm_instance instanceof EE_Payment_Method) { |
|
99 | 99 | $this->set_instance($pm_instance); |
100 | 100 | } |
101 | - if($this->_gateway){ |
|
102 | - $this->_gateway->set_payment_model( EEM_Payment::instance() ); |
|
103 | - $this->_gateway->set_payment_log( EEM_Change_Log::instance() ); |
|
104 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
105 | - $this->_gateway->set_template_helper( new EEH_Template() ); |
|
106 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
107 | - $this->_gateway->set_line_item_helper( new EEH_Line_Item() ); |
|
108 | - EE_Registry::instance()->load_helper( 'Money' ); |
|
109 | - $this->_gateway->set_money_helper( new EEH_Money() ); |
|
101 | + if ($this->_gateway) { |
|
102 | + $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
103 | + $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
104 | + EE_Registry::instance()->load_helper('Template'); |
|
105 | + $this->_gateway->set_template_helper(new EEH_Template()); |
|
106 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
107 | + $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
108 | + EE_Registry::instance()->load_helper('Money'); |
|
109 | + $this->_gateway->set_money_helper(new EEH_Money()); |
|
110 | 110 | } |
111 | - if ( ! isset( $this->_has_billing_form ) ) { |
|
111 | + if ( ! isset($this->_has_billing_form)) { |
|
112 | 112 | // by default, On Site gateways have a billing form |
113 | - if ( $this->payment_occurs() == EE_PMT_Base::onsite ) { |
|
114 | - $this->set_has_billing_form( true ); |
|
113 | + if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
114 | + $this->set_has_billing_form(true); |
|
115 | 115 | } else { |
116 | - $this->set_has_billing_form( false ); |
|
116 | + $this->set_has_billing_form(false); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - if( ! $this->_pretty_name){ |
|
120 | + if ( ! $this->_pretty_name) { |
|
121 | 121 | throw new EE_Error(sprintf(__("You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", "event_espresso"))); |
122 | 122 | } |
123 | 123 | //if the child didn't specify a default button, use the credit card one |
124 | - if( $this->_default_button_url === NULL){ |
|
125 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png'; |
|
124 | + if ($this->_default_button_url === NULL) { |
|
125 | + $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods'.DS.'pay-by-credit-card.png'; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | /** |
132 | 132 | * @param boolean $has_billing_form |
133 | 133 | */ |
134 | - public function set_has_billing_form( $has_billing_form ) { |
|
135 | - $this->_has_billing_form = filter_var( $has_billing_form, FILTER_VALIDATE_BOOLEAN ); |
|
134 | + public function set_has_billing_form($has_billing_form) { |
|
135 | + $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | /** |
141 | 141 | * sets the file_folder property |
142 | 142 | */ |
143 | - protected function _set_file_folder(){ |
|
143 | + protected function _set_file_folder() { |
|
144 | 144 | $reflector = new ReflectionClass(get_class($this)); |
145 | 145 | $fn = $reflector->getFileName(); |
146 | - $this->_file_folder = dirname($fn).DS; |
|
146 | + $this->_file_folder = dirname($fn).DS; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | /** |
152 | 152 | * sets the file URL with a trailing slash for this PMT |
153 | 153 | */ |
154 | - protected function _set_file_url(){ |
|
155 | - $plugins_dir_fixed = str_replace('\\',DS,WP_PLUGIN_DIR); |
|
156 | - $file_folder_fixed = str_replace('\\',DS,$this->file_folder()); |
|
157 | - $file_path = str_replace($plugins_dir_fixed,WP_PLUGIN_URL,$file_folder_fixed); |
|
154 | + protected function _set_file_url() { |
|
155 | + $plugins_dir_fixed = str_replace('\\', DS, WP_PLUGIN_DIR); |
|
156 | + $file_folder_fixed = str_replace('\\', DS, $this->file_folder()); |
|
157 | + $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
158 | 158 | $this->_file_url = $file_path; |
159 | 159 | } |
160 | 160 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * Gets the default description on all payment methods of this type |
163 | 163 | * @return string |
164 | 164 | */ |
165 | - public function default_description(){ |
|
165 | + public function default_description() { |
|
166 | 166 | return $this->_default_description; |
167 | 167 | } |
168 | 168 | |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | * Returns the folder containing the PMT child class, with a trailing slash |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - public function file_folder(){ |
|
176 | - if( ! $this->_file_folder ) { |
|
175 | + public function file_folder() { |
|
176 | + if ( ! $this->_file_folder) { |
|
177 | 177 | $this->_set_file_folder(); |
178 | 178 | } |
179 | 179 | return $this->_file_folder; |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | /** |
185 | 185 | * @return string |
186 | 186 | */ |
187 | - public function file_url(){ |
|
188 | - if( ! $this->_file_url ) { |
|
187 | + public function file_url() { |
|
188 | + if ( ! $this->_file_url) { |
|
189 | 189 | $this->_set_file_url(); |
190 | 190 | } |
191 | 191 | return $this->_file_url; |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | * Its important teh payment method instance is set before |
199 | 199 | * @param EE_Payment_Method $payment_method_instance |
200 | 200 | */ |
201 | - function set_instance($payment_method_instance){ |
|
201 | + function set_instance($payment_method_instance) { |
|
202 | 202 | $this->_pm_instance = $payment_method_instance; |
203 | 203 | //if they have already requested the settings form, make sure its |
204 | 204 | //data matches this model object |
205 | - if($this->_settings_form){ |
|
205 | + if ($this->_settings_form) { |
|
206 | 206 | $this->settings_form()->populate_model_obj($payment_method_instance); |
207 | 207 | } |
208 | - if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
|
208 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
209 | 209 | $this->_gateway->set_settings($payment_method_instance->settings_array()); |
210 | 210 | } |
211 | 211 | } |
@@ -216,14 +216,14 @@ discard block |
||
216 | 216 | * Gets teh form for displaying to admins where they setup the payment method |
217 | 217 | * @return EE_Payment_Method_Form |
218 | 218 | */ |
219 | - function settings_form(){ |
|
220 | - if( ! $this->_settings_form){ |
|
219 | + function settings_form() { |
|
220 | + if ( ! $this->_settings_form) { |
|
221 | 221 | $this->_settings_form = $this->generate_new_settings_form(); |
222 | - $this->_settings_form->set_payment_method_type( $this ); |
|
223 | - $this->_settings_form->_construct_finalize(NULL, NULL ); |
|
222 | + $this->_settings_form->set_payment_method_type($this); |
|
223 | + $this->_settings_form->_construct_finalize(NULL, NULL); |
|
224 | 224 | //if we have already assigned a model object to this pmt, make |
225 | 225 | //sure its reflected in teh form we just generated |
226 | - if($this->_pm_instance){ |
|
226 | + if ($this->_pm_instance) { |
|
227 | 227 | $this->_settings_form->populate_model_obj($this->_pm_instance); |
228 | 228 | } |
229 | 229 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * this payment method type's settings form later in the request |
250 | 250 | * @param EE_Payment_Method_Form $form |
251 | 251 | */ |
252 | - public function set_settings_form($form){ |
|
252 | + public function set_settings_form($form) { |
|
253 | 253 | $this->_settings_form = $form; |
254 | 254 | } |
255 | 255 | |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | * @param array $extra_args |
273 | 273 | * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
274 | 274 | */ |
275 | - public function billing_form( EE_Transaction $transaction = NULL, $extra_args = array() ){ |
|
275 | + public function billing_form(EE_Transaction $transaction = NULL, $extra_args = array()) { |
|
276 | 276 | // has billing form already been regenerated ? or overwrite cache? |
277 | - if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form ){ |
|
278 | - $this->_billing_form = $this->generate_new_billing_form( $transaction, $extra_args ); |
|
277 | + if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
278 | + $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
279 | 279 | } |
280 | 280 | //if we know who the attendee is, and this is a billing form |
281 | 281 | //that uses attendee info, populate it |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | $transaction instanceof EE_Transaction && |
285 | 285 | $transaction->primary_registration() instanceof EE_Registration && |
286 | 286 | $transaction->primary_registration()->attendee() instanceof EE_Attendee |
287 | - ){ |
|
288 | - $this->_billing_form->populate_from_attendee( $transaction->primary_registration()->attendee() ); |
|
287 | + ) { |
|
288 | + $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
289 | 289 | } |
290 | 290 | return $this->_billing_form; |
291 | 291 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * @param \EE_Transaction $transaction |
297 | 297 | * @return \EE_Billing_Info_Form |
298 | 298 | */ |
299 | - abstract function generate_new_billing_form( EE_Transaction $transaction = NULL ); |
|
299 | + abstract function generate_new_billing_form(EE_Transaction $transaction = NULL); |
|
300 | 300 | |
301 | 301 | |
302 | 302 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @param \EE_Billing_Info_Form $billing_form |
308 | 308 | * @return \EE_Billing_Info_Form |
309 | 309 | */ |
310 | - public function apply_billing_form_debug_settings( EE_Billing_Info_Form $billing_form ) { |
|
310 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) { |
|
311 | 311 | return $billing_form; |
312 | 312 | } |
313 | 313 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * if you have form |
319 | 319 | * @param EE_Payment_Method $form |
320 | 320 | */ |
321 | - public function set_billing_form($form){ |
|
321 | + public function set_billing_form($form) { |
|
322 | 322 | $this->_billing_form = $form; |
323 | 323 | } |
324 | 324 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * Returns whether or not this payment method requires HTTPS to be used |
329 | 329 | * @return boolean |
330 | 330 | */ |
331 | - function requires_https(){ |
|
331 | + function requires_https() { |
|
332 | 332 | return $this->_requires_https; |
333 | 333 | } |
334 | 334 | |
@@ -346,9 +346,9 @@ discard block |
||
346 | 346 | * @return EE_Payment |
347 | 347 | * @throws EE_Error |
348 | 348 | */ |
349 | - function process_payment( EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null,$fail_url = '', $method = 'CART', $by_admin = false ){ |
|
349 | + function process_payment(EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null, $fail_url = '', $method = 'CART', $by_admin = false) { |
|
350 | 350 | // @todo: add surcharge for the payment method, if any |
351 | - if ( $this->_gateway ) { |
|
351 | + if ($this->_gateway) { |
|
352 | 352 | //there is a gateway, so we're going to make a payment object |
353 | 353 | //but wait! do they already have a payment in progress that we thought was failed? |
354 | 354 | $duplicate_properties = array( |
@@ -359,10 +359,10 @@ discard block |
||
359 | 359 | 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
360 | 360 | 'PAY_gateway_response' => null, |
361 | 361 | ); |
362 | - $payment = EEM_Payment::instance()->get_one( array( $duplicate_properties )); |
|
362 | + $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
363 | 363 | //if we didn't already have a payment in progress for the same thing, |
364 | 364 | //then we actually want to make a new payment |
365 | - if ( ! $payment instanceof EE_Payment ){ |
|
365 | + if ( ! $payment instanceof EE_Payment) { |
|
366 | 366 | $payment = EE_Payment::new_instance( |
367 | 367 | array_merge( |
368 | 368 | $duplicate_properties, |
@@ -378,10 +378,10 @@ discard block |
||
378 | 378 | } |
379 | 379 | //make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
380 | 380 | $payment->save(); |
381 | - $billing_values = $this->_get_billing_values_from_form( $billing_info ); |
|
381 | + $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
382 | 382 | |
383 | 383 | // Offsite Gateway |
384 | - if( $this->_gateway instanceof EE_Offsite_Gateway ){ |
|
384 | + if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
385 | 385 | |
386 | 386 | $payment = $this->_gateway->set_redirection_info( |
387 | 387 | $payment, |
@@ -397,17 +397,17 @@ discard block |
||
397 | 397 | ); |
398 | 398 | $payment->save(); |
399 | 399 | // Onsite Gateway |
400 | - } elseif ( $this->_gateway instanceof EE_Onsite_Gateway ) { |
|
400 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
401 | 401 | |
402 | - $payment = $this->_gateway->do_direct_payment($payment,$billing_values); |
|
402 | + $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
403 | 403 | $payment->save(); |
404 | 404 | |
405 | 405 | } else { |
406 | 406 | throw new EE_Error( |
407 | 407 | sprintf( |
408 | - __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso' ), |
|
408 | + __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso'), |
|
409 | 409 | get_class($this), |
410 | - gettype( $this->_gateway ) |
|
410 | + gettype($this->_gateway) |
|
411 | 411 | ) |
412 | 412 | ); |
413 | 413 | } |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | } |
430 | 430 | |
431 | 431 | // if there is billing info, clean it and save it now |
432 | - if( $billing_info instanceof EE_Billing_Attendee_Info_Form ){ |
|
433 | - $this->_save_billing_info_to_attendee( $billing_info, $transaction ); |
|
432 | + if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
433 | + $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | return $payment; |
@@ -443,10 +443,10 @@ discard block |
||
443 | 443 | * @param EE_Billing_Info_Form $billing_form |
444 | 444 | * @return array |
445 | 445 | */ |
446 | - protected function _get_billing_values_from_form( $billing_form ){ |
|
447 | - if($billing_form instanceof EE_Form_Section_Proper ){ |
|
448 | - return $billing_form->input_pretty_values( true ); |
|
449 | - }else{ |
|
446 | + protected function _get_billing_values_from_form($billing_form) { |
|
447 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
448 | + return $billing_form->input_pretty_values(true); |
|
449 | + } else { |
|
450 | 450 | return NULL; |
451 | 451 | } |
452 | 452 | } |
@@ -460,13 +460,13 @@ discard block |
||
460 | 460 | * @return EE_Payment |
461 | 461 | * @throws EE_Error |
462 | 462 | */ |
463 | - public function handle_ipn($req_data,$transaction){ |
|
463 | + public function handle_ipn($req_data, $transaction) { |
|
464 | 464 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
465 | - if( ! $this->_gateway instanceof EE_Offsite_Gateway){ |
|
466 | - throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r( $this->_gateway, TRUE ))); |
|
465 | + if ( ! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
466 | + throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r($this->_gateway, TRUE))); |
|
467 | 467 | |
468 | 468 | } |
469 | - $payment = $this->_gateway->handle_payment_update( $req_data, $transaction ); |
|
469 | + $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
470 | 470 | return $payment; |
471 | 471 | } |
472 | 472 | |
@@ -479,22 +479,22 @@ discard block |
||
479 | 479 | * @param EE_Transaction $transaction |
480 | 480 | * @return boolean success |
481 | 481 | */ |
482 | - protected function _save_billing_info_to_attendee($billing_form, $transaction){ |
|
483 | - if( ! $transaction || ! $transaction instanceof EE_Transaction){ |
|
482 | + protected function _save_billing_info_to_attendee($billing_form, $transaction) { |
|
483 | + if ( ! $transaction || ! $transaction instanceof EE_Transaction) { |
|
484 | 484 | EE_Error::add_error(__("Cannot save billing info because no transaction was specified", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
485 | 485 | return false; |
486 | 486 | } |
487 | 487 | $primary_reg = $transaction->primary_registration(); |
488 | - if( ! $primary_reg ){ |
|
488 | + if ( ! $primary_reg) { |
|
489 | 489 | EE_Error::add_error(__("Cannot save billing info because the transaction has no primary registration", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
490 | 490 | return false; |
491 | 491 | } |
492 | 492 | $attendee = $primary_reg->attendee(); |
493 | - if( ! $attendee ){ |
|
493 | + if ( ! $attendee) { |
|
494 | 494 | EE_Error::add_error(__("Cannot save billing info because the transaction's primary registration has no attendee!", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
495 | 495 | return false; |
496 | 496 | } |
497 | - return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method() ); |
|
497 | + return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
498 | 498 | |
499 | 499 | } |
500 | 500 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * @param array $req_data |
508 | 508 | * @return EE_Payment |
509 | 509 | */ |
510 | - protected function find_payment_for_ipn( EE_Transaction $transaction, $req_data = array() ){ |
|
510 | + protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) { |
|
511 | 511 | return $transaction->last_payment(); |
512 | 512 | } |
513 | 513 | |
@@ -524,8 +524,8 @@ discard block |
||
524 | 524 | * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
525 | 525 | * @throws EE_Error |
526 | 526 | */ |
527 | - public function handle_unclaimed_ipn( $req_data = array() ){ |
|
528 | - throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this) )); |
|
527 | + public function handle_unclaimed_ipn($req_data = array()) { |
|
528 | + throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | * @param EE_Transaction $transaction |
542 | 542 | * @return EE_Payment |
543 | 543 | */ |
544 | - public function finalize_payment_for($transaction){ |
|
544 | + public function finalize_payment_for($transaction) { |
|
545 | 545 | return $transaction->last_payment(); |
546 | 546 | } |
547 | 547 | |
@@ -551,10 +551,10 @@ discard block |
||
551 | 551 | * Whether or not this payment method's gateway supports sending refund requests |
552 | 552 | * @return boolean |
553 | 553 | */ |
554 | - public function supports_sending_refunds(){ |
|
555 | - if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
|
554 | + public function supports_sending_refunds() { |
|
555 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
556 | 556 | return $this->_gateway->supports_sending_refunds(); |
557 | - }else{ |
|
557 | + } else { |
|
558 | 558 | return false; |
559 | 559 | } |
560 | 560 | } |
@@ -568,14 +568,14 @@ discard block |
||
568 | 568 | * @throws EE_Error |
569 | 569 | * @return EE_Payment |
570 | 570 | */ |
571 | - public function process_refund( EE_Payment $payment, $refund_info = array()){ |
|
572 | - if ( $this->_gateway && $this->_gateway instanceof EE_Gateway ) { |
|
573 | - return $this->_gateway->do_direct_refund( $payment, $refund_info ); |
|
571 | + public function process_refund(EE_Payment $payment, $refund_info = array()) { |
|
572 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
573 | + return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
574 | 574 | } else { |
575 | 575 | throw new EE_Error( |
576 | 576 | sprintf( |
577 | - __( 'Payment Method Type "%s" does not support sending refund requests', 'event_espresso' ), |
|
578 | - get_class( $this ) |
|
577 | + __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
578 | + get_class($this) |
|
579 | 579 | ) |
580 | 580 | ); |
581 | 581 | } |
@@ -589,15 +589,15 @@ discard block |
||
589 | 589 | * @return string |
590 | 590 | * @throws EE_Error |
591 | 591 | */ |
592 | - public function payment_occurs(){ |
|
593 | - if( ! $this->_gateway){ |
|
592 | + public function payment_occurs() { |
|
593 | + if ( ! $this->_gateway) { |
|
594 | 594 | return EE_PMT_Base::offline; |
595 | - }elseif($this->_gateway instanceof EE_Onsite_Gateway){ |
|
595 | + }elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
596 | 596 | return EE_PMT_Base::onsite; |
597 | - }elseif($this->_gateway instanceof EE_Offsite_Gateway){ |
|
597 | + }elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
598 | 598 | return EE_PMT_Base::offsite; |
599 | - }else{ |
|
600 | - throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"),get_class($this))); |
|
599 | + } else { |
|
600 | + throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"), get_class($this))); |
|
601 | 601 | } |
602 | 602 | } |
603 | 603 | |
@@ -610,9 +610,9 @@ discard block |
||
610 | 610 | * @param EE_Payment $payment |
611 | 611 | * @return string |
612 | 612 | */ |
613 | - public function payment_overview_content(EE_Payment $payment){ |
|
613 | + public function payment_overview_content(EE_Payment $payment) { |
|
614 | 614 | EE_Registry::instance()->load_helper('Template'); |
615 | - return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method'=>$this->_pm_instance,'payment'=>$payment) , true); |
|
615 | + return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method'=>$this->_pm_instance, 'payment'=>$payment), true); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | * @type array $template_args any arguments you want passed to the template file while rendering. |
626 | 626 | * Keys will be variable names and values with be their values. |
627 | 627 | */ |
628 | - public function help_tabs_config(){ |
|
628 | + public function help_tabs_config() { |
|
629 | 629 | return array(); |
630 | 630 | } |
631 | 631 | |
@@ -636,9 +636,9 @@ discard block |
||
636 | 636 | * the payment method's table's PMT_type column) |
637 | 637 | * @return string |
638 | 638 | */ |
639 | - public function system_name(){ |
|
639 | + public function system_name() { |
|
640 | 640 | $classname = get_class($this); |
641 | - return str_replace("EE_PMT_",'',$classname); |
|
641 | + return str_replace("EE_PMT_", '', $classname); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | * A pretty i18n version of the PMT name |
648 | 648 | * @return string |
649 | 649 | */ |
650 | - public function pretty_name(){ |
|
650 | + public function pretty_name() { |
|
651 | 651 | return $this->_pretty_name; |
652 | 652 | } |
653 | 653 | |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | * Gets the default absolute URL to the payment method type's button |
658 | 658 | * @return string |
659 | 659 | */ |
660 | - public function default_button_url(){ |
|
660 | + public function default_button_url() { |
|
661 | 661 | return $this->_default_button_url; |
662 | 662 | } |
663 | 663 | |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | * Gets the gateway used by this payment method (if any) |
668 | 668 | * @return EE_Gateway |
669 | 669 | */ |
670 | - public function get_gateway(){ |
|
670 | + public function get_gateway() { |
|
671 | 671 | return $this->_gateway; |
672 | 672 | } |
673 | 673 | |
@@ -676,9 +676,9 @@ discard block |
||
676 | 676 | /** |
677 | 677 | * @return string html for the link to a help tab |
678 | 678 | */ |
679 | - public function get_help_tab_link(){ |
|
680 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
681 | - return EEH_Template::get_help_tab_link( $this->get_help_tab_name() ); |
|
679 | + public function get_help_tab_link() { |
|
680 | + EE_Registry::instance()->load_helper('Template'); |
|
681 | + return EEH_Template::get_help_tab_link($this->get_help_tab_name()); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | |
@@ -687,8 +687,8 @@ discard block |
||
687 | 687 | * Returns the name of the help tab for this PMT |
688 | 688 | * @return string |
689 | 689 | */ |
690 | - public function get_help_tab_name(){ |
|
691 | - return 'ee_' . strtolower( $this->system_name() ) . '_help_tab'; |
|
690 | + public function get_help_tab_name() { |
|
691 | + return 'ee_'.strtolower($this->system_name()).'_help_tab'; |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
@@ -696,8 +696,8 @@ discard block |
||
696 | 696 | * this PMT by an admin |
697 | 697 | * @return string |
698 | 698 | */ |
699 | - public function cap_name(){ |
|
700 | - return 'ee_payment_method_' . strtolower( $this->system_name() ); |
|
699 | + public function cap_name() { |
|
700 | + return 'ee_payment_method_'.strtolower($this->system_name()); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
@@ -709,9 +709,9 @@ discard block |
||
709 | 709 | * @param EE_Payment $payment |
710 | 710 | * @return void |
711 | 711 | */ |
712 | - public function update_txn_based_on_payment( $payment ){ |
|
713 | - if( $this->_gateway instanceof EE_Gateway ){ |
|
714 | - $this->_gateway->update_txn_based_on_payment( $payment ); |
|
712 | + public function update_txn_based_on_payment($payment) { |
|
713 | + if ($this->_gateway instanceof EE_Gateway) { |
|
714 | + $this->_gateway->update_txn_based_on_payment($payment); |
|
715 | 715 | } |
716 | 716 | } |
717 | 717 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * Class EE_Payment_Method_Manager |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | // check if class object is instantiated, and instantiated properly |
38 | - if ( ! self::$_instance instanceof EE_Payment_Method_Manager ) { |
|
38 | + if ( ! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
39 | 39 | self::$_instance = new self(); |
40 | 40 | } |
41 | 41 | EE_Registry::instance()->load_lib('PMT_Base'); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * Resets the instance and returns a new one |
47 | 47 | * @return EE_Payment_Method_Manager |
48 | 48 | */ |
49 | - public static function reset(){ |
|
49 | + public static function reset() { |
|
50 | 50 | self::$_instance = NULL; |
51 | 51 | return self::instance(); |
52 | 52 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * or just re-use the PMTs we found last time we checked during this request (if |
58 | 58 | * we have not yet checked during this request, then we need to check anyways) |
59 | 59 | */ |
60 | - public function maybe_register_payment_methods( $force_recheck = FALSE ){ |
|
61 | - if( ! $this->_payment_method_types || $force_recheck ){ |
|
60 | + public function maybe_register_payment_methods($force_recheck = FALSE) { |
|
61 | + if ( ! $this->_payment_method_types || $force_recheck) { |
|
62 | 62 | $this->_register_payment_methods(); |
63 | 63 | //if in admin lets ensure caps are set. |
64 | - if ( is_admin() ) { |
|
65 | - add_filter( 'FHEE__EE_Capabilities__init_caps_map__caps', array( $this, 'add_payment_method_caps' ) ); |
|
64 | + if (is_admin()) { |
|
65 | + add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps')); |
|
66 | 66 | EE_Registry::instance()->CAP->init_caps(); |
67 | 67 | } |
68 | 68 | } |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | */ |
76 | 76 | protected function _register_payment_methods() { |
77 | 77 | // grab list of installed modules |
78 | - $pm_to_register = glob( EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR ); |
|
78 | + $pm_to_register = glob(EE_PAYMENT_METHODS.'*', GLOB_ONLYDIR); |
|
79 | 79 | // filter list of modules to register |
80 | - $pm_to_register = apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register ); |
|
80 | + $pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register); |
|
81 | 81 | |
82 | 82 | // loop through folders |
83 | - foreach ( $pm_to_register as $pm_path ) { |
|
84 | - $this->register_payment_method( $pm_path ); |
|
83 | + foreach ($pm_to_register as $pm_path) { |
|
84 | + $this->register_payment_method($pm_path); |
|
85 | 85 | } |
86 | - do_action( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods' ); |
|
86 | + do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods'); |
|
87 | 87 | // filter list of installed modules |
88 | 88 | //keep them organized alphabetically by the payment method type's name |
89 | - ksort( $this->_payment_method_types ); |
|
90 | - return apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types ); |
|
89 | + ksort($this->_payment_method_types); |
|
90 | + return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -99,35 +99,35 @@ discard block |
||
99 | 99 | * @param string $payment_method_path - full path up to and including payment method folder |
100 | 100 | * @return boolean |
101 | 101 | */ |
102 | - public function register_payment_method( $payment_method_path = '' ) { |
|
103 | - do_action( 'AHEE__EE_Payment_Method_Manager__register_payment_method__begin',$payment_method_path ); |
|
102 | + public function register_payment_method($payment_method_path = '') { |
|
103 | + do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path); |
|
104 | 104 | $module_ext = '.pm.php'; |
105 | 105 | // make all separators match |
106 | - $payment_method_path = rtrim( str_replace( '/\\', DS, $payment_method_path ), DS ); |
|
106 | + $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS); |
|
107 | 107 | // grab and sanitize module name |
108 | - $module_dir = basename( $payment_method_path ); |
|
108 | + $module_dir = basename($payment_method_path); |
|
109 | 109 | // create classname from module directory name |
110 | - $module = str_replace( ' ', '_', str_replace( '_', ' ', $module_dir )); |
|
110 | + $module = str_replace(' ', '_', str_replace('_', ' ', $module_dir)); |
|
111 | 111 | // add class prefix |
112 | - $module_class = 'EE_PMT_' . $module; |
|
112 | + $module_class = 'EE_PMT_'.$module; |
|
113 | 113 | // does the module exist ? |
114 | - if ( ! is_readable( $payment_method_path . DS . $module_class . $module_ext )) { |
|
115 | - $msg = sprintf( __( 'The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module ); |
|
116 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
114 | + if ( ! is_readable($payment_method_path.DS.$module_class.$module_ext)) { |
|
115 | + $msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso'), $module); |
|
116 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
117 | 117 | return FALSE; |
118 | 118 | } |
119 | - if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->start_timer(); } |
|
119 | + if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->start_timer(); } |
|
120 | 120 | // load the module class file |
121 | - require_once( $payment_method_path . DS . $module_class . $module_ext ); |
|
122 | - if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); } |
|
121 | + require_once($payment_method_path.DS.$module_class.$module_ext); |
|
122 | + if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); } |
|
123 | 123 | // verify that class exists |
124 | - if ( ! class_exists( $module_class )) { |
|
125 | - $msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
|
126 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
124 | + if ( ! class_exists($module_class)) { |
|
125 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
126 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
127 | 127 | return FALSE; |
128 | 128 | } |
129 | 129 | // add to array of registered modules |
130 | - $this->_payment_method_types[ $module ] = $payment_method_path . DS . $module_class . $module_ext; |
|
130 | + $this->_payment_method_types[$module] = $payment_method_path.DS.$module_class.$module_ext; |
|
131 | 131 | return TRUE; |
132 | 132 | } |
133 | 133 | /** |
@@ -136,18 +136,18 @@ discard block |
||
136 | 136 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
137 | 137 | * @return boolean |
138 | 138 | */ |
139 | - public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE){ |
|
139 | + public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE) { |
|
140 | 140 | if ( |
141 | 141 | $force_recheck |
142 | - || ! is_array( $this->_payment_method_types ) |
|
143 | - || ! isset( $this->_payment_method_types[$payment_method_name] ) |
|
142 | + || ! is_array($this->_payment_method_types) |
|
143 | + || ! isset($this->_payment_method_types[$payment_method_name]) |
|
144 | 144 | ) { |
145 | 145 | $this->maybe_register_payment_methods($force_recheck); |
146 | 146 | } |
147 | - if(isset($this->_payment_method_types[$payment_method_name])){ |
|
147 | + if (isset($this->_payment_method_types[$payment_method_name])) { |
|
148 | 148 | require_once($this->_payment_method_types[$payment_method_name]); |
149 | 149 | return true; |
150 | - }else{ |
|
150 | + } else { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | } |
@@ -158,16 +158,16 @@ discard block |
||
158 | 158 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
159 | 159 | * @return array |
160 | 160 | */ |
161 | - public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE ){ |
|
161 | + public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE) { |
|
162 | 162 | $this->maybe_register_payment_methods($force_recheck); |
163 | - if($with_prefixes){ |
|
163 | + if ($with_prefixes) { |
|
164 | 164 | $classnames = array_keys($this->_payment_method_types); |
165 | 165 | $payment_methods = array(); |
166 | - foreach($classnames as $classname){ |
|
166 | + foreach ($classnames as $classname) { |
|
167 | 167 | $payment_methods[] = $this->payment_method_class_from_type($classname); |
168 | 168 | } |
169 | 169 | return $payment_methods; |
170 | - }else{ |
|
170 | + } else { |
|
171 | 171 | return array_keys($this->_payment_method_types); |
172 | 172 | } |
173 | 173 | } |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
178 | 178 | * @return EE_PMT_Base[] |
179 | 179 | */ |
180 | - public function payment_method_types( $force_recheck = FALSE ){ |
|
180 | + public function payment_method_types($force_recheck = FALSE) { |
|
181 | 181 | $this->maybe_register_payment_methods($force_recheck); |
182 | 182 | $pmt_objs = array(); |
183 | - foreach($this->payment_method_type_names(true) as $classname){ |
|
183 | + foreach ($this->payment_method_type_names(true) as $classname) { |
|
184 | 184 | $pmt_objs[] = new $classname; |
185 | 185 | } |
186 | 186 | return $pmt_objs; |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | * @param string $classname |
193 | 193 | * @return string |
194 | 194 | */ |
195 | - public function payment_method_type_sans_class_prefix($classname){ |
|
196 | - return str_replace( "EE_PMT_", "", $classname ); |
|
195 | + public function payment_method_type_sans_class_prefix($classname) { |
|
196 | + return str_replace("EE_PMT_", "", $classname); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @param string $type |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - public function payment_method_class_from_type($type){ |
|
204 | + public function payment_method_class_from_type($type) { |
|
205 | 205 | $this->maybe_register_payment_methods(); |
206 | 206 | return "EE_PMT_".$type; |
207 | 207 | } |
@@ -215,38 +215,38 @@ discard block |
||
215 | 215 | * @return \EE_Payment_Method |
216 | 216 | * @throws \EE_Error |
217 | 217 | */ |
218 | - public function activate_a_payment_method_of_type( $payment_method_type ){ |
|
218 | + public function activate_a_payment_method_of_type($payment_method_type) { |
|
219 | 219 | $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
220 | - if( ! $payment_method instanceof EE_Payment_Method ){ |
|
220 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
221 | 221 | $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
222 | - if(class_exists($pm_type_class)){ |
|
222 | + if (class_exists($pm_type_class)) { |
|
223 | 223 | /** @var $pm_type_obj EE_PMT_Base */ |
224 | 224 | $pm_type_obj = new $pm_type_class; |
225 | 225 | $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
226 | - if( ! $payment_method){ |
|
227 | - $payment_method = $this->create_payment_method_of_type( $pm_type_obj ); |
|
226 | + if ( ! $payment_method) { |
|
227 | + $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
|
228 | 228 | } |
229 | - $payment_method->set_type( $payment_method_type ); |
|
230 | - $this->initialize_payment_method( $payment_method ); |
|
229 | + $payment_method->set_type($payment_method_type); |
|
230 | + $this->initialize_payment_method($payment_method); |
|
231 | 231 | } else { |
232 | 232 | throw new EE_Error( |
233 | 233 | sprintf( |
234 | - __( 'There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
234 | + __('There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
235 | 235 | $pm_type_class ) |
236 | 236 | ); |
237 | 237 | } |
238 | 238 | } |
239 | 239 | $payment_method->set_active(); |
240 | 240 | $payment_method->save(); |
241 | - $this->set_usable_currencies_on_payment_method( $payment_method ); |
|
242 | - if( $payment_method->type() === 'Invoice' ){ |
|
243 | - $messages = EE_Registry::instance()->load_lib( 'messages' ); |
|
244 | - $messages->ensure_message_type_is_active( 'invoice', 'html' ); |
|
245 | - $messages->ensure_messenger_is_active( 'pdf' ); |
|
241 | + $this->set_usable_currencies_on_payment_method($payment_method); |
|
242 | + if ($payment_method->type() === 'Invoice') { |
|
243 | + $messages = EE_Registry::instance()->load_lib('messages'); |
|
244 | + $messages->ensure_message_type_is_active('invoice', 'html'); |
|
245 | + $messages->ensure_messenger_is_active('pdf'); |
|
246 | 246 | EE_Error::add_attention( |
247 | 247 | sprintf( |
248 | - __( 'Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso' ), |
|
249 | - '<a href="' . admin_url( 'admin.php?page=espresso_messages') . '">', |
|
248 | + __('Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso'), |
|
249 | + '<a href="'.admin_url('admin.php?page=espresso_messages').'">', |
|
250 | 250 | '</a>' |
251 | 251 | ) |
252 | 252 | ); |
@@ -264,17 +264,17 @@ discard block |
||
264 | 264 | * @return EE_Payment_Method |
265 | 265 | * @throws \EE_Error |
266 | 266 | */ |
267 | - public function create_payment_method_of_type( $pm_type_obj ) { |
|
267 | + public function create_payment_method_of_type($pm_type_obj) { |
|
268 | 268 | global $current_user; |
269 | 269 | $payment_method = EE_Payment_Method::new_instance( |
270 | 270 | array( |
271 | 271 | 'PMD_type' => $pm_type_obj->system_name(), |
272 | 272 | 'PMD_name' => $pm_type_obj->pretty_name(), |
273 | 273 | 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
274 | - 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
274 | + 'PMD_slug' => $pm_type_obj->system_name(), //automatically converted to slug |
|
275 | 275 | 'PMD_wp_user' => $current_user->ID, |
276 | 276 | 'PMD_order' => EEM_Payment_Method::instance()->count( |
277 | - array( array( 'PMD_type' => array( '!=', 'Admin_Only' ))) |
|
277 | + array(array('PMD_type' => array('!=', 'Admin_Only'))) |
|
278 | 278 | ) * 10, |
279 | 279 | ) |
280 | 280 | ); |
@@ -290,21 +290,21 @@ discard block |
||
290 | 290 | * @return EE_Payment_Method |
291 | 291 | * @throws \EE_Error |
292 | 292 | */ |
293 | - public function initialize_payment_method( $payment_method ) { |
|
293 | + public function initialize_payment_method($payment_method) { |
|
294 | 294 | $pm_type_obj = $payment_method->type_obj(); |
295 | - $payment_method->set_description( $pm_type_obj->default_description() ); |
|
296 | - if( ! $payment_method->button_url() ){ |
|
297 | - $payment_method->set_button_url( $pm_type_obj->default_button_url() ); |
|
295 | + $payment_method->set_description($pm_type_obj->default_description()); |
|
296 | + if ( ! $payment_method->button_url()) { |
|
297 | + $payment_method->set_button_url($pm_type_obj->default_button_url()); |
|
298 | 298 | } |
299 | 299 | //now add setup its default extra meta properties |
300 | 300 | $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
301 | - if ( ! empty( $extra_metas ) ) { |
|
301 | + if ( ! empty($extra_metas)) { |
|
302 | 302 | //verify the payment method has an ID before adding extra meta |
303 | - if ( ! $payment_method->ID() ) { |
|
303 | + if ( ! $payment_method->ID()) { |
|
304 | 304 | $payment_method->save(); |
305 | 305 | } |
306 | - foreach ( $extra_metas as $meta_name => $input ) { |
|
307 | - $payment_method->update_extra_meta( $meta_name, $input->raw_value() ); |
|
306 | + foreach ($extra_metas as $meta_name => $input) { |
|
307 | + $payment_method->update_extra_meta($meta_name, $input->raw_value()); |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | return $payment_method; |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | * @return EE_Payment_Method |
320 | 320 | * @throws \EE_Error |
321 | 321 | */ |
322 | - public function set_usable_currencies_on_payment_method( $payment_method ) { |
|
323 | - foreach($payment_method->get_all_usable_currencies() as $currency_obj){ |
|
322 | + public function set_usable_currencies_on_payment_method($payment_method) { |
|
323 | + foreach ($payment_method->get_all_usable_currencies() as $currency_obj) { |
|
324 | 324 | $payment_method->_add_relation_to($currency_obj, 'Currency'); |
325 | 325 | } |
326 | 326 | return $payment_method; |
@@ -338,19 +338,19 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @return int count of rows updated. |
340 | 340 | */ |
341 | - public function deactivate_payment_method( $payment_method_slug ) { |
|
341 | + public function deactivate_payment_method($payment_method_slug) { |
|
342 | 342 | EE_Log::instance()->log( |
343 | 343 | __FILE__, |
344 | 344 | __FUNCTION__, |
345 | 345 | sprintf( |
346 | - __( 'Payment method with slug %1$s is being deactivated by site admin', 'event_espresso' ), |
|
346 | + __('Payment method with slug %1$s is being deactivated by site admin', 'event_espresso'), |
|
347 | 347 | $payment_method_slug |
348 | 348 | ), |
349 | 349 | 'payment_method_change' |
350 | 350 | ); |
351 | 351 | $count_updated = EEM_Payment_Method::instance()->update( |
352 | - array( 'PMD_scope' => array() ), |
|
353 | - array( array( 'PMD_slug' => $payment_method_slug ) ) |
|
352 | + array('PMD_scope' => array()), |
|
353 | + array(array('PMD_slug' => $payment_method_slug)) |
|
354 | 354 | ); |
355 | 355 | return $count_updated; |
356 | 356 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * @param array $caps capabilities being filtered |
365 | 365 | * @return array |
366 | 366 | */ |
367 | - public function add_payment_method_caps( $caps ) { |
|
367 | + public function add_payment_method_caps($caps) { |
|
368 | 368 | /* add dynamic caps from payment methods |
369 | 369 | * at the time of writing, october 20 2014, these are the caps added: |
370 | 370 | * ee_payment_method_admin_only |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | * their related capability automatically added too, so long as they are |
380 | 380 | * registered properly using EE_Register_Payment_Method::register() |
381 | 381 | */ |
382 | - foreach( $this->payment_method_types() as $payment_method_type_obj ){ |
|
382 | + foreach ($this->payment_method_types() as $payment_method_type_obj) { |
|
383 | 383 | $caps['administrator'][] = $payment_method_type_obj->cap_name(); |
384 | 384 | } |
385 | 385 | return $caps; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $validation_error_message = $default_validation_strategy->get_validation_error_message(); |
43 | 43 | } |
44 | 44 | throw new EE_Validation_Error( $validation_error_message, 'float_only' ); |
45 | - }else{ |
|
45 | + } else{ |
|
46 | 46 | return floatval($normalized_value); |
47 | 47 | } |
48 | 48 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | public function unnormalize($normalized_value) { |
56 | 56 | if( empty( $normalized_value ) ){ |
57 | 57 | return '0.00'; |
58 | - }else{ |
|
58 | + } else{ |
|
59 | 59 | return "$normalized_value"; |
60 | 60 | } |
61 | 61 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
2 | -do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | +do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
3 | 3 | /** |
4 | 4 | * Event Espresso |
5 | 5 | * |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * ------------------------------------------------------------------------ |
25 | 25 | */ |
26 | -class EE_Payment_Method extends EE_Base_Class{ |
|
26 | +class EE_Payment_Method extends EE_Base_Class { |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Payment Method type object, which has all the info about this type of payment method, |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | * @return EE_Payment_Method |
40 | 40 | * @throws \EE_Error |
41 | 41 | */ |
42 | - public static function new_instance( $props_n_values = array()) { |
|
43 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
44 | - return $has_object ? $has_object : new self( $props_n_values, FALSE ); |
|
42 | + public static function new_instance($props_n_values = array()) { |
|
43 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
44 | + return $has_object ? $has_object : new self($props_n_values, FALSE); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * @return EE_Payment_Method |
52 | 52 | * @throws \EE_Error |
53 | 53 | */ |
54 | - public static function new_instance_from_db ( $props_n_values = array()) { |
|
55 | - return new self( $props_n_values, TRUE ); |
|
54 | + public static function new_instance_from_db($props_n_values = array()) { |
|
55 | + return new self($props_n_values, TRUE); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @return boolean |
82 | 82 | */ |
83 | 83 | public function active() { |
84 | - return array_intersect(array_keys(EEM_Payment_Method::instance()->scopes()),$this->scope()); |
|
84 | + return array_intersect(array_keys(EEM_Payment_Method::instance()->scopes()), $this->scope()); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @throws \EE_Error |
94 | 94 | */ |
95 | - public function set_active(){ |
|
95 | + public function set_active() { |
|
96 | 96 | $default_scopes = array(EEM_Payment_Method::scope_cart); |
97 | - if($this->type_obj() && |
|
98 | - $this->type_obj()->payment_occurs() === EE_PMT_Base::offline){ |
|
97 | + if ($this->type_obj() && |
|
98 | + $this->type_obj()->payment_occurs() === EE_PMT_Base::offline) { |
|
99 | 99 | $default_scopes[] = EEM_Payment_Method::scope_admin; |
100 | 100 | } |
101 | 101 | $this->set_scope($default_scopes); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | /** |
107 | 107 | * Makes this payment method apply to NO scopes at all. DOES NOT SAVE it. |
108 | 108 | */ |
109 | - public function deactivate(){ |
|
109 | + public function deactivate() { |
|
110 | 110 | $this->set_scope(array()); |
111 | 111 | } |
112 | 112 | |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | * @param mixed $field_value |
298 | 298 | * @param boolean $use_default |
299 | 299 | */ |
300 | - public function set( $field_name, $field_value, $use_default = FALSE ){ |
|
301 | - if( $field_name === 'PMD_type' ){ |
|
300 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
301 | + if ($field_name === 'PMD_type') { |
|
302 | 302 | //the type has probably changed, so forget about its old type object |
303 | 303 | $this->_type_obj = NULL; |
304 | 304 | } |
@@ -372,26 +372,26 @@ discard block |
||
372 | 372 | * @return EE_PMT_Base |
373 | 373 | * @throws EE_Error |
374 | 374 | */ |
375 | - public function type_obj(){ |
|
376 | - if( ! $this->_type_obj ) { |
|
377 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
378 | - if ( EE_Payment_Method_Manager::instance()->payment_method_type_exists( $this->type() )) { |
|
379 | - $class_name = EE_Payment_Method_Manager::instance()->payment_method_class_from_type( $this->type() ); |
|
380 | - if ( ! class_exists( $class_name )) { |
|
375 | + public function type_obj() { |
|
376 | + if ( ! $this->_type_obj) { |
|
377 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
378 | + if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($this->type())) { |
|
379 | + $class_name = EE_Payment_Method_Manager::instance()->payment_method_class_from_type($this->type()); |
|
380 | + if ( ! class_exists($class_name)) { |
|
381 | 381 | throw new EE_Error( |
382 | 382 | sprintf( |
383 | - __( 'An attempt to use the "%1$s" payment method failed, so it was deactivated.%2$sWas the "%1$s" Plugin recently deactivated? It can be reactivated on the %3$sPlugins Admin Page%4$s', 'event_espresso' ), |
|
383 | + __('An attempt to use the "%1$s" payment method failed, so it was deactivated.%2$sWas the "%1$s" Plugin recently deactivated? It can be reactivated on the %3$sPlugins Admin Page%4$s', 'event_espresso'), |
|
384 | 384 | $class_name, |
385 | 385 | '<br />', |
386 | - '<a href="' . admin_url('plugins.php') . '">', |
|
386 | + '<a href="'.admin_url('plugins.php').'">', |
|
387 | 387 | '</a>' |
388 | 388 | ) |
389 | 389 | ); |
390 | 390 | } |
391 | - $r = new ReflectionClass( $class_name ); |
|
392 | - $this->_type_obj = $r->newInstanceArgs( array( $this )); |
|
391 | + $r = new ReflectionClass($class_name); |
|
392 | + $this->_type_obj = $r->newInstanceArgs(array($this)); |
|
393 | 393 | } else { |
394 | - throw new EE_Error( sprintf( __( 'A payment method of type "%1$s" does not exist. Only ones existing are: %2$s', 'event_espresso' ), $this->type(), implode(',', EE_Payment_Method_Manager::instance()->payment_method_type_names() ) ) ); |
|
394 | + throw new EE_Error(sprintf(__('A payment method of type "%1$s" does not exist. Only ones existing are: %2$s', 'event_espresso'), $this->type(), implode(',', EE_Payment_Method_Manager::instance()->payment_method_type_names()))); |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 | return $this->_type_obj; |
@@ -404,18 +404,18 @@ discard block |
||
404 | 404 | * and the extra meta. Mostly used for passing off ot gateways. * |
405 | 405 | * @return array |
406 | 406 | */ |
407 | - public function settings_array(){ |
|
407 | + public function settings_array() { |
|
408 | 408 | $fields = $this->model_field_array(); |
409 | 409 | $extra_meta = $this->all_extra_meta_array(); |
410 | 410 | //remove the model's prefix from the fields |
411 | 411 | $combined_settings_array = array(); |
412 | - foreach($fields as $key => $value){ |
|
413 | - if(strpos($key, 'PMD_')===0){ |
|
412 | + foreach ($fields as $key => $value) { |
|
413 | + if (strpos($key, 'PMD_') === 0) { |
|
414 | 414 | $key_sans_model_prefix = str_replace('PMD_', '', $key); |
415 | 415 | $combined_settings_array [$key_sans_model_prefix] = $value; |
416 | 416 | } |
417 | 417 | } |
418 | - $combined_settings_array = array_merge( $extra_meta,$combined_settings_array ); |
|
418 | + $combined_settings_array = array_merge($extra_meta, $combined_settings_array); |
|
419 | 419 | return $combined_settings_array; |
420 | 420 | } |
421 | 421 | |
@@ -429,12 +429,12 @@ discard block |
||
429 | 429 | * @return string of HTML for displaying the button |
430 | 430 | * @throws \EE_Error |
431 | 431 | */ |
432 | - public function button_html( $url = '', $css_class = '' ){ |
|
432 | + public function button_html($url = '', $css_class = '') { |
|
433 | 433 | $payment_occurs = $this->type_obj()->payment_occurs(); |
434 | 434 | return ' |
435 | - <div id="' . $this->slug() . '-payment-option-dv" class="'. $payment_occurs .'-payment-gateway reg-page-payment-option-dv' . $css_class . '"> |
|
436 | - <a id="payment-gateway-button-' . $this->slug() . '" class="reg-page-payment-option-lnk" rel="' . $this->slug() . '" href="' . $url . '" > |
|
437 | - <img src="' . $this->button_url() . '" alt="' . sprintf( esc_attr__( 'Pay using %s', 'event_espresso' ), $this->get_pretty('PMD_name','form_input') ) . '" /> |
|
435 | + <div id="' . $this->slug().'-payment-option-dv" class="'.$payment_occurs.'-payment-gateway reg-page-payment-option-dv'.$css_class.'"> |
|
436 | + <a id="payment-gateway-button-' . $this->slug().'" class="reg-page-payment-option-lnk" rel="'.$this->slug().'" href="'.$url.'" > |
|
437 | + <img src="' . $this->button_url().'" alt="'.sprintf(esc_attr__('Pay using %s', 'event_espresso'), $this->get_pretty('PMD_name', 'form_input')).'" /> |
|
438 | 438 | </a> |
439 | 439 | </div> |
440 | 440 | '; |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | * @return EE_Currency[] |
450 | 450 | * @throws \EE_Error |
451 | 451 | */ |
452 | - public function get_all_usable_currencies(){ |
|
452 | + public function get_all_usable_currencies() { |
|
453 | 453 | return EEM_Currency::instance()->get_all_currencies_usable_by($this->type_obj()); |
454 | 454 | } |
455 | 455 | |
@@ -462,9 +462,9 @@ discard block |
||
462 | 462 | * @return boolean |
463 | 463 | * @throws \EE_Error |
464 | 464 | */ |
465 | - public function usable_for_currency( $currency_code ) { |
|
466 | - foreach( $this->get_all_usable_currencies() as $currency_obj ) { |
|
467 | - if( $currency_obj->ID() === $currency_code ){ |
|
465 | + public function usable_for_currency($currency_code) { |
|
466 | + foreach ($this->get_all_usable_currencies() as $currency_obj) { |
|
467 | + if ($currency_obj->ID() === $currency_code) { |
|
468 | 468 | return TRUE; |
469 | 469 | } |
470 | 470 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * @return bool |
480 | 480 | * @throws \EE_Error |
481 | 481 | */ |
482 | - public function is_on_site(){ |
|
482 | + public function is_on_site() { |
|
483 | 483 | return $this->type_obj()->payment_occurs() === EE_PMT_Base::onsite; |
484 | 484 | } |
485 | 485 | |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | * @return bool |
492 | 492 | * @throws \EE_Error |
493 | 493 | */ |
494 | - public function is_off_site(){ |
|
494 | + public function is_off_site() { |
|
495 | 495 | return $this->type_obj()->payment_occurs() === EE_PMT_Base::offsite; |
496 | 496 | } |
497 | 497 | |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | * @return bool |
504 | 504 | * @throws \EE_Error |
505 | 505 | */ |
506 | - public function is_off_line(){ |
|
506 | + public function is_off_line() { |
|
507 | 507 | return $this->type_obj()->payment_occurs() === EE_PMT_Base::offline; |
508 | 508 | } |
509 | 509 | |
@@ -513,10 +513,10 @@ discard block |
||
513 | 513 | * to load the required classes, and don't need them at the time of unserialization |
514 | 514 | * @return array |
515 | 515 | */ |
516 | - public function __sleep(){ |
|
517 | - $properties = get_object_vars( $this ); |
|
518 | - unset( $properties[ '_type_obj' ] ); |
|
519 | - return array_keys( $properties ); |
|
516 | + public function __sleep() { |
|
517 | + $properties = get_object_vars($this); |
|
518 | + unset($properties['_type_obj']); |
|
519 | + return array_keys($properties); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | |
@@ -528,17 +528,17 @@ discard block |
||
528 | 528 | * @return int @see EE_Base_Class::save() |
529 | 529 | * @throws \EE_Error |
530 | 530 | */ |
531 | - public function save( $set_cols_n_values = array() ) { |
|
532 | - $results = parent::save( $set_cols_n_values ); |
|
533 | - if( $this->get_original( 'PMD_scope' ) !== $this->get( 'PMD_scope' ) ) { |
|
531 | + public function save($set_cols_n_values = array()) { |
|
532 | + $results = parent::save($set_cols_n_values); |
|
533 | + if ($this->get_original('PMD_scope') !== $this->get('PMD_scope')) { |
|
534 | 534 | EE_Log::instance()->log( |
535 | 535 | __FILE__, |
536 | 536 | __FUNCTION__, |
537 | 537 | sprintf( |
538 | - __( 'Set new scope on payment method %1$s to %2$s from %3$s on URL %4$s', 'event_espresso' ), |
|
538 | + __('Set new scope on payment method %1$s to %2$s from %3$s on URL %4$s', 'event_espresso'), |
|
539 | 539 | $this->name(), |
540 | - serialize( $this->get_original( 'PMD_scope' ) ), |
|
541 | - serialize( $this->get( 'PMD_scope' ) ), |
|
540 | + serialize($this->get_original('PMD_scope')), |
|
541 | + serialize($this->get('PMD_scope')), |
|
542 | 542 | EE_Registry::instance()->REQ->get_current_page_permalink() |
543 | 543 | ), |
544 | 544 | 'payment_method_change' |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public static function instance() { |
49 | 49 | // check if class object is instantiated |
50 | - if ( ! self::$_instance instanceof EE_Admin ) { |
|
50 | + if ( ! self::$_instance instanceof EE_Admin) { |
|
51 | 51 | self::$_instance = new self(); |
52 | 52 | } |
53 | 53 | return self::$_instance; |
@@ -62,30 +62,30 @@ discard block |
||
62 | 62 | // define global EE_Admin constants |
63 | 63 | $this->_define_all_constants(); |
64 | 64 | // set autoloaders for our admin page classes based on included path information |
65 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_ADMIN ); |
|
65 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
66 | 66 | // admin hooks |
67 | - add_filter( 'plugin_action_links', array( $this, 'filter_plugin_actions' ), 10, 2 ); |
|
67 | + add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
68 | 68 | // load EE_Request_Handler early |
69 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'get_request' )); |
|
70 | - add_action( 'AHEE__EE_System__initialize_last', array( $this, 'init' )); |
|
69 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
70 | + add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
71 | 71 | // post shortcode tracking |
72 | 72 | add_action( |
73 | 73 | 'AHEE__EE_System__initialize_last', |
74 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'set_hooks_admin' ) |
|
74 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'set_hooks_admin') |
|
75 | 75 | ); |
76 | - add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'route_admin_request' ), 100, 2 ); |
|
77 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 100 ); |
|
78 | - add_action( 'admin_init', array( $this, 'admin_init' ), 100 ); |
|
79 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ), 20 ); |
|
80 | - add_action( 'admin_notices', array( $this, 'display_admin_notices' ), 10 ); |
|
81 | - add_action( 'network_admin_notices', array( $this, 'display_admin_notices' ), 10 ); |
|
82 | - add_filter( 'pre_update_option', array( $this, 'check_for_invalid_datetime_formats' ), 100, 2 ); |
|
83 | - add_filter('admin_footer_text', array( $this, 'espresso_admin_footer' )); |
|
76 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
77 | + add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
78 | + add_action('admin_init', array($this, 'admin_init'), 100); |
|
79 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
80 | + add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
81 | + add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
82 | + add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
83 | + add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
84 | 84 | |
85 | 85 | //reset Environment config (we only do this on admin page loads); |
86 | 86 | EE_Registry::instance()->CFG->environment->recheck_values(); |
87 | 87 | |
88 | - do_action( 'AHEE__EE_Admin__loaded' ); |
|
88 | + do_action('AHEE__EE_Admin__loaded'); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | * @return void |
101 | 101 | */ |
102 | 102 | private function _define_all_constants() { |
103 | - define( 'EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/' ); |
|
104 | - define( 'EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/' ); |
|
105 | - define( 'EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS ); |
|
106 | - define( 'WP_ADMIN_PATH', ABSPATH . 'wp-admin/' ); |
|
107 | - define( 'WP_AJAX_URL', admin_url( 'admin-ajax.php' )); |
|
103 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/'); |
|
104 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/'); |
|
105 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS); |
|
106 | + define('WP_ADMIN_PATH', ABSPATH.'wp-admin/'); |
|
107 | + define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | |
@@ -117,23 +117,23 @@ discard block |
||
117 | 117 | * @param string $plugin |
118 | 118 | * @return array |
119 | 119 | */ |
120 | - public function filter_plugin_actions( $links, $plugin ) { |
|
120 | + public function filter_plugin_actions($links, $plugin) { |
|
121 | 121 | // set $main_file in stone |
122 | 122 | static $main_file; |
123 | 123 | // if $main_file is not set yet |
124 | - if ( ! $main_file ) { |
|
125 | - $main_file = plugin_basename( EVENT_ESPRESSO_MAIN_FILE ); |
|
124 | + if ( ! $main_file) { |
|
125 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
126 | 126 | } |
127 | - if ( $plugin == $main_file ) { |
|
127 | + if ($plugin == $main_file) { |
|
128 | 128 | // compare current plugin to this one |
129 | - if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
130 | - $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode. Click this link to learn why.">' . __('Maintenance Mode Active', 'event_espresso' ) . '</a>'; |
|
131 | - array_unshift( $links, $maintenance_link ); |
|
129 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
130 | + $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode. Click this link to learn why.">'.__('Maintenance Mode Active', 'event_espresso').'</a>'; |
|
131 | + array_unshift($links, $maintenance_link); |
|
132 | 132 | } else { |
133 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __( 'Settings', 'event_espresso' ) . '</a>'; |
|
134 | - $events_link = '<a href="admin.php?page=espresso_events">' . __( 'Events', 'event_espresso' ) . '</a>'; |
|
133 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'.__('Settings', 'event_espresso').'</a>'; |
|
134 | + $events_link = '<a href="admin.php?page=espresso_events">'.__('Events', 'event_espresso').'</a>'; |
|
135 | 135 | // add before other links |
136 | - array_unshift( $links, $org_settings_link, $events_link ); |
|
136 | + array_unshift($links, $org_settings_link, $events_link); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | return $links; |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | * @return void |
149 | 149 | */ |
150 | 150 | public function get_request() { |
151 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
152 | - EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
151 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
152 | + EE_Registry::instance()->load_core('CPT_Strategy'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | * @param array $admin_page_folder_names |
162 | 162 | * @return array |
163 | 163 | */ |
164 | - public function hide_admin_pages_except_maintenance_mode( $admin_page_folder_names = array() ){ |
|
164 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) { |
|
165 | 165 | return array( |
166 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
167 | - 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
168 | - 'support' => EE_ADMIN_PAGES . 'support' . DS |
|
166 | + 'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS, |
|
167 | + 'about' => EE_ADMIN_PAGES.'about'.DS, |
|
168 | + 'support' => EE_ADMIN_PAGES.'support'.DS |
|
169 | 169 | ); |
170 | 170 | } |
171 | 171 | |
@@ -179,31 +179,31 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function init() { |
181 | 181 | //only enable most of the EE_Admin IF we're not in full maintenance mode |
182 | - if ( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){ |
|
182 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
183 | 183 | //ok so we want to enable the entire admin |
184 | - add_action( 'wp_ajax_dismiss_ee_nag_notice', array( $this, 'dismiss_ee_nag_notice_callback' )); |
|
185 | - add_action( 'admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
186 | - add_action( 'network_admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
184 | + add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback')); |
|
185 | + add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
186 | + add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
187 | 187 | //at a glance dashboard widget |
188 | - add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items' ), 10 ); |
|
188 | + add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
189 | 189 | //filter for get_edit_post_link used on comments for custom post types |
190 | - add_filter( 'get_edit_post_link', array( $this, 'modify_edit_post_link' ), 10, 3 ); |
|
190 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3); |
|
191 | 191 | } |
192 | 192 | // run the admin page factory but ONLY if we are doing an ee admin ajax request |
193 | - if ( !defined('DOING_AJAX') || EE_ADMIN_AJAX ) { |
|
193 | + if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
194 | 194 | try { |
195 | 195 | //this loads the controller for the admin pages which will setup routing etc |
196 | - EE_Registry::instance()->load_core( 'Admin_Page_Loader' ); |
|
197 | - } catch ( EE_Error $e ) { |
|
196 | + EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
197 | + } catch (EE_Error $e) { |
|
198 | 198 | $e->get_error(); |
199 | 199 | } |
200 | 200 | } |
201 | - add_filter( 'content_save_pre', array( $this, 'its_eSpresso' ), 10, 1 ); |
|
201 | + add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
202 | 202 | //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
203 | - add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes' ), 10 ); |
|
204 | - add_action('admin_head', array( $this, 'register_custom_nav_menu_boxes' ), 10 ); |
|
203 | + add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
204 | + add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
205 | 205 | //exclude EE critical pages from all nav menus and wp_list_pages |
206 | - add_filter('nav_menu_meta_box_object', array( $this, 'remove_pages_from_nav_menu'), 10 ); |
|
206 | + add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | * @param object $post_type WP post type object |
217 | 217 | * @return object WP post type object |
218 | 218 | */ |
219 | - public function remove_pages_from_nav_menu( $post_type ) { |
|
219 | + public function remove_pages_from_nav_menu($post_type) { |
|
220 | 220 | //if this isn't the "pages" post type let's get out |
221 | - if ( $post_type->name !== 'page' ) |
|
221 | + if ($post_type->name !== 'page') |
|
222 | 222 | return $post_type; |
223 | 223 | |
224 | 224 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
@@ -238,28 +238,28 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function enable_hidden_ee_nav_menu_metaboxes() { |
240 | 240 | global $wp_meta_boxes, $pagenow; |
241 | - if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php' ) { |
|
241 | + if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
242 | 242 | return; |
243 | 243 | } |
244 | 244 | $user = wp_get_current_user(); |
245 | 245 | //has this been done yet? |
246 | - if ( get_user_option( 'ee_nav_menu_initialized', $user->ID ) ) { |
|
246 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
247 | 247 | return; |
248 | 248 | } |
249 | 249 | |
250 | - $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus', $user->ID ); |
|
251 | - $initial_meta_boxes = apply_filters( 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array( 'nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page' ) ); |
|
250 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
251 | + $initial_meta_boxes = apply_filters('FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array('nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page')); |
|
252 | 252 | |
253 | - if ( is_array( $hidden_meta_boxes ) ) { |
|
254 | - foreach ( $hidden_meta_boxes as $key => $meta_box_id ) { |
|
255 | - if ( in_array( $meta_box_id, $initial_meta_boxes ) ) { |
|
256 | - unset( $hidden_meta_boxes[ $key ] ); |
|
253 | + if (is_array($hidden_meta_boxes)) { |
|
254 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
255 | + if (in_array($meta_box_id, $initial_meta_boxes)) { |
|
256 | + unset($hidden_meta_boxes[$key]); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
262 | - update_user_option( $user->ID, 'ee_nav_menu_initialized', 1, true ); |
|
261 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
262 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @return void |
279 | 279 | */ |
280 | 280 | public function register_custom_nav_menu_boxes() { |
281 | - add_meta_box( 'add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array( $this, 'ee_cpt_archive_pages' ), 'nav-menus', 'side', 'core' ); |
|
281 | + add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core'); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -295,17 +295,17 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @return string the (maybe) modified link |
297 | 297 | */ |
298 | - public function modify_edit_post_link( $link, $id, $context ) { |
|
299 | - if ( ! $post = get_post( $id ) ) |
|
298 | + public function modify_edit_post_link($link, $id, $context) { |
|
299 | + if ( ! $post = get_post($id)) |
|
300 | 300 | return $link; |
301 | 301 | |
302 | - if ( $post->post_type == 'espresso_attendees' ) { |
|
302 | + if ($post->post_type == 'espresso_attendees') { |
|
303 | 303 | $query_args = array( |
304 | 304 | 'action' => 'edit_attendee', |
305 | 305 | 'post' => $id |
306 | 306 | ); |
307 | 307 | EE_Registry::instance()->load_helper('URL'); |
308 | - return EEH_URL::add_query_args_and_nonce( $query_args, admin_url('admin.php?page=espresso_registrations') ); |
|
308 | + return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations')); |
|
309 | 309 | } |
310 | 310 | return $link; |
311 | 311 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | global $nav_menu_selected_id; |
318 | 318 | |
319 | 319 | $db_fields = false; |
320 | - $walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
320 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
321 | 321 | $current_tab = 'event-archives'; |
322 | 322 | |
323 | 323 | /*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | ?> |
337 | 337 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
338 | 338 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
339 | - <li <?php echo ( 'event-archives' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
340 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
341 | - <?php _e( 'Event Archive Pages', 'event_espresso' ); ?> |
|
339 | + <li <?php echo ('event-archives' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
340 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
341 | + <?php _e('Event Archive Pages', 'event_espresso'); ?> |
|
342 | 342 | </a> |
343 | 343 | </li> |
344 | 344 | <?php /* // temporarily removing but leaving skeleton in place in case we ever decide to add more tabs. |
@@ -356,13 +356,13 @@ discard block |
||
356 | 356 | <?php */ ?> |
357 | 357 | |
358 | 358 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php |
359 | - echo ( 'event-archives' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
359 | + echo ('event-archives' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
360 | 360 | ?>"> |
361 | 361 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear"> |
362 | 362 | <?php |
363 | 363 | $pages = $this->_get_extra_nav_menu_pages_items(); |
364 | 364 | $args['walker'] = $walker; |
365 | - echo walk_nav_menu_tree( array_map( array( $this, '_setup_extra_nav_menu_pages_items' ), $pages), 0, (object) $args ); |
|
365 | + echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0, (object) $args); |
|
366 | 366 | ?> |
367 | 367 | </ul> |
368 | 368 | </div><!-- /.tabs-panel --> |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | <p class="button-controls"> |
371 | 371 | <span class="list-controls"> |
372 | 372 | <a href="<?php |
373 | - echo esc_url( add_query_arg( |
|
373 | + echo esc_url(add_query_arg( |
|
374 | 374 | array( |
375 | 375 | 'extra-nav-menu-pages-tab' => 'event-archives', |
376 | 376 | 'selectall' => 1, |
377 | 377 | ), |
378 | - remove_query_arg( $removed_args ) |
|
378 | + remove_query_arg($removed_args) |
|
379 | 379 | )); |
380 | 380 | ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
381 | 381 | </span> |
382 | 382 | |
383 | 383 | <span class="add-to-menu"> |
384 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( __( 'Add to Menu' ) ); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e( 'submit-posttype-extra-nav-menu-pages' ); ?>" /> |
|
384 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e(__('Add to Menu')); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e('submit-posttype-extra-nav-menu-pages'); ?>" /> |
|
385 | 385 | <span class="spinner"></span> |
386 | 386 | </span> |
387 | 387 | </p> |
@@ -402,10 +402,10 @@ discard block |
||
402 | 402 | private function _get_extra_nav_menu_pages_items() { |
403 | 403 | $menuitems[] = array( |
404 | 404 | 'title' => __('Event List', 'event_espresso'), |
405 | - 'url' => get_post_type_archive_link( 'espresso_events' ), |
|
405 | + 'url' => get_post_type_archive_link('espresso_events'), |
|
406 | 406 | 'description' => __('Archive page for all events.', 'event_espresso') |
407 | 407 | ); |
408 | - return apply_filters( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems ); |
|
408 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @param $menu_item_values |
418 | 418 | * @return stdClass |
419 | 419 | */ |
420 | - private function _setup_extra_nav_menu_pages_items( $menu_item_values ) { |
|
420 | + private function _setup_extra_nav_menu_pages_items($menu_item_values) { |
|
421 | 421 | $menu_item = new stdClass(); |
422 | 422 | $keys = array( |
423 | 423 | 'ID' => 0, |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | 'xfn' => '' |
438 | 438 | ); |
439 | 439 | |
440 | - foreach ( $keys as $key => $value) { |
|
441 | - $menu_item->{$key} = isset( $menu_item_values[ $key]) ? $menu_item_values[ $key] : $value; |
|
440 | + foreach ($keys as $key => $value) { |
|
441 | + $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
442 | 442 | } |
443 | 443 | return $menu_item; |
444 | 444 | } |
@@ -477,10 +477,10 @@ discard block |
||
477 | 477 | * - check if doing post processing of one of EE CPTs |
478 | 478 | * - instantiate the corresponding EE CPT model for the post_type being processed. |
479 | 479 | */ |
480 | - if ( isset( $_POST['action'] ) && $_POST['action'] == 'editpost' ) { |
|
481 | - if ( isset( $_POST['post_type'] ) ) { |
|
482 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
483 | - EE_Register_CPTs::instantiate_cpt_models( $_POST['post_type'] ); |
|
480 | + if (isset($_POST['action']) && $_POST['action'] == 'editpost') { |
|
481 | + if (isset($_POST['post_type'])) { |
|
482 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
483 | + EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | * 'options-reading.php' core WordPress admin settings page. This is for user-proofing. |
491 | 491 | */ |
492 | 492 | global $pagenow; |
493 | - if ( $pagenow == 'options-reading.php' ) { |
|
494 | - add_filter( 'wp_dropdown_pages', array( $this, 'modify_dropdown_pages' ) ); |
|
493 | + if ($pagenow == 'options-reading.php') { |
|
494 | + add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | } |
@@ -503,25 +503,25 @@ discard block |
||
503 | 503 | * @param string $output Current output. |
504 | 504 | * @return string |
505 | 505 | */ |
506 | - public function modify_dropdown_pages( $output ) { |
|
506 | + public function modify_dropdown_pages($output) { |
|
507 | 507 | //get critical pages |
508 | 508 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
509 | 509 | |
510 | 510 | //split current output by line break for easier parsing. |
511 | - $split_output = explode( "\n", $output ); |
|
511 | + $split_output = explode("\n", $output); |
|
512 | 512 | |
513 | 513 | //loop through to remove any critical pages from the array. |
514 | - foreach ( $critical_pages as $page_id ) { |
|
515 | - $needle = 'value="' . $page_id . '"'; |
|
516 | - foreach( $split_output as $key => $haystack ) { |
|
517 | - if( strpos( $haystack, $needle ) !== false ) { |
|
518 | - unset( $split_output[$key] ); |
|
514 | + foreach ($critical_pages as $page_id) { |
|
515 | + $needle = 'value="'.$page_id.'"'; |
|
516 | + foreach ($split_output as $key => $haystack) { |
|
517 | + if (strpos($haystack, $needle) !== false) { |
|
518 | + unset($split_output[$key]); |
|
519 | 519 | } |
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
523 | 523 | //replace output with the new contents |
524 | - $output = implode( "\n", $split_output ); |
|
524 | + $output = implode("\n", $split_output); |
|
525 | 525 | |
526 | 526 | return $output; |
527 | 527 | } |
@@ -537,37 +537,37 @@ discard block |
||
537 | 537 | public function enqueue_admin_scripts() { |
538 | 538 | // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
539 | 539 | // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script calls. |
540 | - wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
540 | + wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
541 | 541 | // register cookie script for future dependencies |
542 | - wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE ); |
|
542 | + wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE); |
|
543 | 543 | // jquery_validate loading is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
544 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
544 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
545 | 545 | // register jQuery Validate |
546 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
546 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
547 | 547 | } |
548 | 548 | //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again vai: add_filter('FHEE_load_joyride', '__return_true' ); |
549 | - if ( apply_filters( 'FHEE_load_joyride', FALSE ) ) { |
|
549 | + if (apply_filters('FHEE_load_joyride', FALSE)) { |
|
550 | 550 | //joyride style |
551 | - wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
552 | - wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION ); |
|
553 | - wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1', TRUE ); |
|
551 | + wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1'); |
|
552 | + wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION); |
|
553 | + wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', array(), '2.1', TRUE); |
|
554 | 554 | //joyride JS |
555 | - wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE ); |
|
555 | + wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE); |
|
556 | 556 | // wanna go for a joyride? |
557 | 557 | wp_enqueue_style('ee-joyride-css'); |
558 | 558 | wp_enqueue_script('jquery-joyride'); |
559 | 559 | } |
560 | 560 | //qtip is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtips', '__return_true' ); |
561 | - if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) { |
|
561 | + if (apply_filters('FHEE_load_qtip', FALSE)) { |
|
562 | 562 | EE_Registry::instance()->load_helper('Qtip_Loader'); |
563 | 563 | EEH_Qtip_Loader::instance()->register_and_enqueue(); |
564 | 564 | } |
565 | 565 | //accounting.js library |
566 | 566 | // @link http://josscrowcroft.github.io/accounting.js/ |
567 | - if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) { |
|
568 | - wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
569 | - wp_register_script( 'ee-accounting-core', EE_THIRD_PARTY_URL . 'accounting/accounting.js', array('underscore'), '0.3.2', TRUE ); |
|
570 | - wp_enqueue_script( 'ee-accounting' ); |
|
567 | + if (apply_filters('FHEE_load_accounting_js', FALSE)) { |
|
568 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
569 | + wp_register_script('ee-accounting-core', EE_THIRD_PARTY_URL.'accounting/accounting.js', array('underscore'), '0.3.2', TRUE); |
|
570 | + wp_enqueue_script('ee-accounting'); |
|
571 | 571 | // array of settings to get converted to JSON array via wp_localize_script |
572 | 572 | $currency_config = array( |
573 | 573 | 'currency' => array( |
@@ -614,11 +614,11 @@ discard block |
||
614 | 614 | public function get_persistent_admin_notices() { |
615 | 615 | // http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30 |
616 | 616 | $args = array( |
617 | - 'page' => EE_Registry::instance()->REQ->is_set( 'page' ) ? EE_Registry::instance()->REQ->get( 'page' ) : '', |
|
618 | - 'action' => EE_Registry::instance()->REQ->is_set( 'action' ) ? EE_Registry::instance()->REQ->get( 'action' ) : '', |
|
617 | + 'page' => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '', |
|
618 | + 'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '', |
|
619 | 619 | ); |
620 | - $return_url = EE_Admin_Page::add_query_args_and_nonce( $args, EE_ADMIN_URL ); |
|
621 | - echo EE_Error::get_persistent_admin_notices( $return_url ); |
|
620 | + $return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL); |
|
621 | + echo EE_Error::get_persistent_admin_notices($return_url); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | |
@@ -639,26 +639,26 @@ discard block |
||
639 | 639 | * @param $elements |
640 | 640 | * @return array |
641 | 641 | */ |
642 | - public function dashboard_glance_items( $elements ) { |
|
642 | + public function dashboard_glance_items($elements) { |
|
643 | 643 | $events = EEM_Event::instance()->count(); |
644 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_events'), admin_url('admin.php') ); |
|
645 | - $items['events']['text'] = sprintf( _n( '%s Event', '%s Events', $events ), number_format_i18n( $events ) ); |
|
644 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'), admin_url('admin.php')); |
|
645 | + $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
646 | 646 | $items['events']['title'] = __('Click to view all Events', 'event_espresso'); |
647 | 647 | $registrations = EEM_Registration::instance()->count( |
648 | 648 | array( |
649 | 649 | array( |
650 | - 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) |
|
650 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete) |
|
651 | 651 | ) |
652 | 652 | ) |
653 | 653 | ); |
654 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_registrations' ), admin_url('admin.php') ); |
|
655 | - $items['registrations']['text'] = sprintf( _n( '%s Registration', '%s Registrations', $registrations ), number_format_i18n($registrations) ); |
|
654 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'), admin_url('admin.php')); |
|
655 | + $items['registrations']['text'] = sprintf(_n('%s Registration', '%s Registrations', $registrations), number_format_i18n($registrations)); |
|
656 | 656 | $items['registrations']['title'] = __('Click to view all registrations', 'event_espresso'); |
657 | 657 | |
658 | - $items = apply_filters( 'FHEE__EE_Admin__dashboard_glance_items__items', $items ); |
|
658 | + $items = apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
659 | 659 | |
660 | - foreach ( $items as $type => $item_properties ) { |
|
661 | - $elements[] = sprintf( '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text'] ); |
|
660 | + foreach ($items as $type => $item_properties) { |
|
661 | + $elements[] = sprintf('<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text']); |
|
662 | 662 | } |
663 | 663 | return $elements; |
664 | 664 | } |
@@ -675,32 +675,32 @@ discard block |
||
675 | 675 | * @throws EE_Error |
676 | 676 | * @return string |
677 | 677 | */ |
678 | - public function check_for_invalid_datetime_formats( $value, $option ) { |
|
679 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
678 | + public function check_for_invalid_datetime_formats($value, $option) { |
|
679 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
680 | 680 | // check for date_format or time_format |
681 | - switch ( $option ) { |
|
681 | + switch ($option) { |
|
682 | 682 | case 'date_format' : |
683 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
683 | + $date_time_format = $value.' '.get_option('time_format'); |
|
684 | 684 | break; |
685 | 685 | case 'time_format' : |
686 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
686 | + $date_time_format = get_option('date_format').' '.$value; |
|
687 | 687 | break; |
688 | 688 | default : |
689 | 689 | $date_time_format = FALSE; |
690 | 690 | } |
691 | 691 | // do we have a date_time format to check ? |
692 | - if ( $date_time_format ) { |
|
693 | - $error_msg = EEH_DTT_Helper::validate_format_string( $date_time_format ); |
|
692 | + if ($date_time_format) { |
|
693 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
694 | 694 | |
695 | - if ( is_array( $error_msg ) ) { |
|
696 | - $msg = '<p>' . sprintf( __( 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso' ), date( $date_time_format ) , $date_time_format ) . '</p><p><ul>'; |
|
695 | + if (is_array($error_msg)) { |
|
696 | + $msg = '<p>'.sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso'), date($date_time_format), $date_time_format).'</p><p><ul>'; |
|
697 | 697 | |
698 | 698 | |
699 | - foreach ( $error_msg as $error ) { |
|
700 | - $msg .= '<li>' . $error . '</li>'; |
|
699 | + foreach ($error_msg as $error) { |
|
700 | + $msg .= '<li>'.$error.'</li>'; |
|
701 | 701 | } |
702 | 702 | |
703 | - $msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>'; |
|
703 | + $msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>'; |
|
704 | 704 | |
705 | 705 | // trigger WP settings error |
706 | 706 | add_settings_error( |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | ); |
711 | 711 | |
712 | 712 | // set format to something valid |
713 | - switch ( $option ) { |
|
713 | + switch ($option) { |
|
714 | 714 | case 'date_format' : |
715 | 715 | $value = 'F j, Y'; |
716 | 716 | break; |
@@ -732,8 +732,8 @@ discard block |
||
732 | 732 | * @param $content |
733 | 733 | * @return string |
734 | 734 | */ |
735 | - public function its_eSpresso( $content ) { |
|
736 | - return str_replace( '[EXPRESSO_', '[ESPRESSO_', $content ); |
|
735 | + public function its_eSpresso($content) { |
|
736 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | |
@@ -746,9 +746,9 @@ discard block |
||
746 | 746 | */ |
747 | 747 | public function espresso_admin_footer() { |
748 | 748 | return sprintf( |
749 | - __( 'Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso' ), |
|
749 | + __('Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso'), |
|
750 | 750 | '<a href="https://eventespresso.com/" title="', |
751 | - '">' . EVENT_ESPRESSO_POWERED_BY . '</a>' |
|
751 | + '">'.EVENT_ESPRESSO_POWERED_BY.'</a>' |
|
752 | 752 | ); |
753 | 753 | } |
754 | 754 | |
@@ -768,11 +768,11 @@ discard block |
||
768 | 768 | * @param array $config |
769 | 769 | * @return void |
770 | 770 | */ |
771 | - public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) { |
|
772 | - EE_Error::doing_it_wrong( __METHOD__, sprintf( __('Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3' ); |
|
773 | - if ( class_exists( 'EE_Register_Admin_Page' ) ) |
|
771 | + public static function register_ee_admin_page($page_basename, $page_path, $config = array()) { |
|
772 | + EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3'); |
|
773 | + if (class_exists('EE_Register_Admin_Page')) |
|
774 | 774 | $config['page_path'] = $page_path; |
775 | - EE_Register_Admin_Page::register( $page_basename, $config ); |
|
775 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
3 | -require_once ( EE_CLASSES . 'EE_Registration.class.php' ); |
|
2 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
3 | +require_once (EE_CLASSES.'EE_Registration.class.php'); |
|
4 | 4 | /** |
5 | 5 | * |
6 | 6 | * Registration Model |
@@ -92,31 +92,31 @@ discard block |
||
92 | 92 | * Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
93 | 93 | * @return \EEM_Registration |
94 | 94 | */ |
95 | - protected function __construct( $timezone ) { |
|
96 | - $this->singular_item = __('Registration','event_espresso'); |
|
97 | - $this->plural_item = __('Registrations','event_espresso'); |
|
95 | + protected function __construct($timezone) { |
|
96 | + $this->singular_item = __('Registration', 'event_espresso'); |
|
97 | + $this->plural_item = __('Registrations', 'event_espresso'); |
|
98 | 98 | |
99 | 99 | $this->_tables = array( |
100 | - 'Registration'=>new EE_Primary_Table('esp_registration','REG_ID') |
|
100 | + 'Registration'=>new EE_Primary_Table('esp_registration', 'REG_ID') |
|
101 | 101 | ); |
102 | 102 | $this->_fields = array( |
103 | 103 | 'Registration'=>array( |
104 | - 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID','event_espresso')), |
|
105 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
106 | - 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID','event_espresso'), false, 0, 'Attendee'), |
|
107 | - 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'), |
|
108 | - 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso'), false, 0, 'Ticket'), |
|
109 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
110 | - 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred','event_espresso'), false, time(), $timezone ), |
|
111 | - 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total','event_espresso'), false, 0), |
|
112 | - 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration','event_espresso'), false, 0), |
|
113 | - 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration','event_espresso'), false, ''), |
|
114 | - 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration','event_espresso'), false, ''), |
|
115 | - 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration','event_espresso'), false, ''), |
|
116 | - 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ','event_espresso'), true, 1), |
|
117 | - 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group','event_espresso'), false, 1), |
|
118 | - 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending','event_espresso'), false, false), |
|
119 | - 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false ) |
|
104 | + 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')), |
|
105 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
106 | + 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'), |
|
107 | + 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'), |
|
108 | + 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, 0, 'Ticket'), |
|
109 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
110 | + 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred', 'event_espresso'), false, time(), $timezone), |
|
111 | + 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total', 'event_espresso'), false, 0), |
|
112 | + 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration', 'event_espresso'), false, 0), |
|
113 | + 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration', 'event_espresso'), false, ''), |
|
114 | + 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration', 'event_espresso'), false, ''), |
|
115 | + 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration', 'event_espresso'), false, ''), |
|
116 | + 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ', 'event_espresso'), true, 1), |
|
117 | + 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group', 'event_espresso'), false, 1), |
|
118 | + 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false), |
|
119 | + 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false) |
|
120 | 120 | ) |
121 | 121 | ); |
122 | 122 | $this->_model_relations = array( |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | 'Answer'=>new EE_Has_Many_Relation(), |
129 | 129 | 'Checkin'=>new EE_Has_Many_Relation(), |
130 | 130 | 'Registration_Payment' => new EE_Has_Many_Relation(), |
131 | - 'Payment'=>new EE_HABTM_Relation( 'Registration_Payment' ), |
|
131 | + 'Payment'=>new EE_HABTM_Relation('Registration_Payment'), |
|
132 | 132 | ); |
133 | 133 | $this->_model_chain_to_wp_user = 'Event'; |
134 | 134 | |
135 | - parent::__construct( $timezone ); |
|
135 | + parent::__construct($timezone); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | * @param bool $translated If true will return the values as singular localized strings |
166 | 166 | * @return array |
167 | 167 | */ |
168 | - public static function reg_status_array( $exclude = array(), $translated = FALSE ) { |
|
169 | - EEM_Registration::instance()->_get_registration_status_array( $exclude ); |
|
170 | - return $translated ? EEM_Status::instance()->localized_status( self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
168 | + public static function reg_status_array($exclude = array(), $translated = FALSE) { |
|
169 | + EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
170 | + return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | |
@@ -178,19 +178,19 @@ discard block |
||
178 | 178 | * @param array $exclude |
179 | 179 | * @return array |
180 | 180 | */ |
181 | - private function _get_registration_status_array( $exclude = array() ) { |
|
181 | + private function _get_registration_status_array($exclude = array()) { |
|
182 | 182 | //in the very rare circumstance that we are deleting a model's table's data |
183 | 183 | //and the table hasn't actually been created, this could have an error |
184 | 184 | /** @type WPDB $wpdb */ |
185 | 185 | global $wpdb; |
186 | - EE_Registry::instance()->load_helper( 'Activation' ); |
|
187 | - if( EEH_Activation::table_exists( $wpdb->prefix . 'esp_status' ) ){ |
|
188 | - $SQL = 'SELECT STS_ID, STS_code FROM '. $wpdb->prefix . 'esp_status WHERE STS_type = "registration"'; |
|
189 | - $results = $wpdb->get_results( $SQL ); |
|
186 | + EE_Registry::instance()->load_helper('Activation'); |
|
187 | + if (EEH_Activation::table_exists($wpdb->prefix.'esp_status')) { |
|
188 | + $SQL = 'SELECT STS_ID, STS_code FROM '.$wpdb->prefix.'esp_status WHERE STS_type = "registration"'; |
|
189 | + $results = $wpdb->get_results($SQL); |
|
190 | 190 | self::$_reg_status = array(); |
191 | - foreach ( $results as $status ) { |
|
192 | - if ( ! in_array( $status->STS_ID, $exclude )) { |
|
193 | - self::$_reg_status[ $status->STS_ID ] = $status->STS_code; |
|
191 | + foreach ($results as $status) { |
|
192 | + if ( ! in_array($status->STS_ID, $exclude)) { |
|
193 | + self::$_reg_status[$status->STS_ID] = $status->STS_code; |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | } |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | * @param array $where_params Array of query_params as described in the comments for EEM_Base::get_all() |
206 | 206 | * @return wpdb results array |
207 | 207 | */ |
208 | - public function get_reg_months_and_years( $where_params ) { |
|
208 | + public function get_reg_months_and_years($where_params) { |
|
209 | 209 | $query_params[0] = $where_params; |
210 | 210 | $query_params['group_by'] = array('reg_year', 'reg_month'); |
211 | - $query_params['order_by'] = array( 'REG_date' => 'DESC' ); |
|
211 | + $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
212 | 212 | $columns_to_select = array( |
213 | 213 | 'reg_year' => array('YEAR(REG_date)', '%s'), |
214 | 214 | 'reg_month' => array('MONTHNAME(REG_date)', '%s') |
215 | 215 | ); |
216 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
216 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | * @param int $ATT_ID |
226 | 226 | * @return EE_Registration[] |
227 | 227 | */ |
228 | - public function get_all_registrations_for_attendee( $ATT_ID = 0 ) { |
|
229 | - if ( ! $ATT_ID ) { |
|
228 | + public function get_all_registrations_for_attendee($ATT_ID = 0) { |
|
229 | + if ( ! $ATT_ID) { |
|
230 | 230 | return FALSE; |
231 | 231 | } |
232 | - return $this->get_all( array( array( 'ATT_ID' => $ATT_ID ))); |
|
232 | + return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | * @param string $REG_url_link |
241 | 241 | * @return EE_Registration |
242 | 242 | */ |
243 | - public function get_registration_for_reg_url_link($REG_url_link){ |
|
244 | - if(!$REG_url_link){ |
|
243 | + public function get_registration_for_reg_url_link($REG_url_link) { |
|
244 | + if ( ! $REG_url_link) { |
|
245 | 245 | return false; |
246 | 246 | } |
247 | 247 | return $this->get_one(array(array('REG_url_link'=>$REG_url_link))); |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
260 | 260 | * @return mixed array on success, FALSE on fail |
261 | 261 | */ |
262 | - public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) { |
|
262 | + public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) { |
|
263 | 263 | return $this->get_one(array( |
264 | 264 | array( |
265 | 265 | 'TXN_ID'=>$TXN_ID, |
266 | 266 | 'ATT_ID'=>$ATT_ID |
267 | 267 | ), |
268 | - 'limit'=>array( min( ( $att_nmbr-1 ), 0 ), 1 ) |
|
268 | + 'limit'=>array(min(($att_nmbr - 1), 0), 1) |
|
269 | 269 | )); |
270 | 270 | } |
271 | 271 | |
@@ -277,17 +277,17 @@ discard block |
||
277 | 277 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
278 | 278 | * @return stdClass[] with properties regDate and total |
279 | 279 | */ |
280 | - public function get_registrations_per_day_report( $period = '-1 month' ) { |
|
280 | + public function get_registrations_per_day_report($period = '-1 month') { |
|
281 | 281 | |
282 | - $sql_date = $this->convert_datetime_for_query( 'REG_date', date("Y-m-d H:i:s", strtotime($period) ), 'Y-m-d H:i:s', 'UTC' ); |
|
283 | - $where = array( 'REG_date' => array( '>=', $sql_date ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
282 | + $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
283 | + $where = array('REG_date' => array('>=', $sql_date), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
284 | 284 | |
285 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_day_report' ) ) { |
|
285 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
286 | 286 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
287 | 287 | } |
288 | 288 | |
289 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
290 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'REG_date' ); |
|
289 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
290 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date'); |
|
291 | 291 | |
292 | 292 | $results = $this->_get_all_wpdb_results( |
293 | 293 | array( |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | ), |
298 | 298 | OBJECT, |
299 | 299 | array( |
300 | - 'regDate'=>array( 'DATE(' . $query_interval . ')','%s'), |
|
301 | - 'total'=>array('count(REG_ID)','%d') |
|
300 | + 'regDate'=>array('DATE('.$query_interval.')', '%s'), |
|
301 | + 'total'=>array('count(REG_ID)', '%d') |
|
302 | 302 | )); |
303 | 303 | return $results; |
304 | 304 | } |
@@ -313,23 +313,23 @@ discard block |
||
313 | 313 | * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID |
314 | 314 | * (i.e. RAP) |
315 | 315 | */ |
316 | - public function get_registrations_per_day_and_per_status_report( $period = '-1 month' ) { |
|
316 | + public function get_registrations_per_day_and_per_status_report($period = '-1 month') { |
|
317 | 317 | global $wpdb; |
318 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
318 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
319 | 319 | $event_table = $wpdb->posts; |
320 | - $sql_date = date("Y-m-d H:i:s", strtotime($period) ); |
|
320 | + $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
321 | 321 | |
322 | 322 | //prepare the query interval for displaying offset |
323 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
324 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'dates.REG_date' ); |
|
323 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
324 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date'); |
|
325 | 325 | |
326 | 326 | //inner date query |
327 | 327 | $inner_date_query = "SELECT DISTINCT REG_date from $registration_table "; |
328 | 328 | $inner_where = " WHERE"; |
329 | 329 | //exclude events not authored by user if permissions in effect |
330 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
330 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
331 | 331 | $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
332 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
332 | + $inner_where .= " post_author = ".get_current_user_id()." AND"; |
|
333 | 333 | } |
334 | 334 | $inner_where .= " REG_date >= '$sql_date'"; |
335 | 335 | $inner_date_query .= $inner_where; |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | $select_parts = array(); |
342 | 342 | |
343 | 343 | //loop through registration stati to do parts for each status. |
344 | - foreach ( EEM_Registration::reg_status_array() as $STS_ID => $STS_code ) { |
|
345 | - if ( $STS_ID === EEM_Registration::status_id_incomplete ) { |
|
344 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
345 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
346 | 346 | continue; |
347 | 347 | } |
348 | 348 | $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
@@ -350,14 +350,14 @@ discard block |
||
350 | 350 | } |
351 | 351 | |
352 | 352 | //setup the selects |
353 | - $select .= implode(', ', $select_parts ); |
|
353 | + $select .= implode(', ', $select_parts); |
|
354 | 354 | $select .= " FROM ($inner_date_query) AS dates LEFT JOIN "; |
355 | 355 | |
356 | 356 | //setup the joins |
357 | - $join .= implode( " LEFT JOIN ", $join_parts ); |
|
357 | + $join .= implode(" LEFT JOIN ", $join_parts); |
|
358 | 358 | |
359 | 359 | //now let's put it all together |
360 | - $query = $select . $join . ' GROUP BY Registration_REG_date'; |
|
360 | + $query = $select.$join.' GROUP BY Registration_REG_date'; |
|
361 | 361 | |
362 | 362 | //and execute it |
363 | 363 | $results = $wpdb->get_results( |
@@ -378,23 +378,23 @@ discard block |
||
378 | 378 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
379 | 379 | * @return stdClass[] each with properties event_name, reg_limit, and total |
380 | 380 | */ |
381 | - public function get_registrations_per_event_report( $period = '-1 month' ) { |
|
381 | + public function get_registrations_per_event_report($period = '-1 month') { |
|
382 | 382 | |
383 | - $date_sql = $this->convert_datetime_for_query( 'REG_date', date( "Y-m-d H:i:s", strtotime( $period )), 'Y-m-d H:i:s', 'UTC' ); |
|
384 | - $where = array( 'REG_date' => array( '>=', $date_sql ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
383 | + $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
384 | + $where = array('REG_date' => array('>=', $date_sql), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
385 | 385 | |
386 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
386 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
387 | 387 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
388 | 388 | } |
389 | 389 | $results = $this->_get_all_wpdb_results(array( |
390 | 390 | $where, |
391 | 391 | 'group_by'=>'Event.EVT_name', |
392 | 392 | 'order_by'=>'Event.EVT_name', |
393 | - 'limit'=>array(0,24)), |
|
393 | + 'limit'=>array(0, 24)), |
|
394 | 394 | OBJECT, |
395 | 395 | array( |
396 | - 'event_name'=>array('Event_CPT.post_title','%s'), |
|
397 | - 'total'=>array('COUNT(REG_ID)','%s') |
|
396 | + 'event_name'=>array('Event_CPT.post_title', '%s'), |
|
397 | + 'total'=>array('COUNT(REG_ID)', '%s') |
|
398 | 398 | ) |
399 | 399 | ); |
400 | 400 | |
@@ -412,19 +412,19 @@ discard block |
||
412 | 412 | * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID |
413 | 413 | * (i.e. RAP) |
414 | 414 | */ |
415 | - public function get_registrations_per_event_and_per_status_report( $period = '-1 month' ) { |
|
415 | + public function get_registrations_per_event_and_per_status_report($period = '-1 month') { |
|
416 | 416 | global $wpdb; |
417 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
417 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
418 | 418 | $event_table = $wpdb->posts; |
419 | - $sql_date = date("Y-m-d H:i:s", strtotime($period) ); |
|
419 | + $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
420 | 420 | |
421 | 421 | //inner date query |
422 | 422 | $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table "; |
423 | 423 | $inner_where = " WHERE"; |
424 | 424 | //exclude events not authored by user if permissions in effect |
425 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
425 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
426 | 426 | $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
427 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
427 | + $inner_where .= " post_author = ".get_current_user_id()." AND"; |
|
428 | 428 | } |
429 | 429 | $inner_where .= " REG_date >= '$sql_date'"; |
430 | 430 | $inner_date_query .= $inner_where; |
@@ -436,8 +436,8 @@ discard block |
||
436 | 436 | $select_parts = array(); |
437 | 437 | |
438 | 438 | //loop through registration stati to do parts for each status. |
439 | - foreach ( EEM_Registration::reg_status_array() as $STS_ID => $STS_code ) { |
|
440 | - if ( $STS_ID === EEM_Registration::status_id_incomplete ) { |
|
439 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
440 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
441 | 441 | continue; |
442 | 442 | } |
443 | 443 | $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
@@ -445,14 +445,14 @@ discard block |
||
445 | 445 | } |
446 | 446 | |
447 | 447 | //setup the selects |
448 | - $select .= implode( ', ', $select_parts ); |
|
448 | + $select .= implode(', ', $select_parts); |
|
449 | 449 | $select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN "; |
450 | 450 | |
451 | 451 | //setup remaining joins |
452 | - $join .= implode( " LEFT JOIN ", $join_parts ); |
|
452 | + $join .= implode(" LEFT JOIN ", $join_parts); |
|
453 | 453 | |
454 | 454 | //now put it all together |
455 | - $query = $select . $join . ' GROUP BY Registration_Event'; |
|
455 | + $query = $select.$join.' GROUP BY Registration_Event'; |
|
456 | 456 | |
457 | 457 | //and execute |
458 | 458 | $results = $wpdb->get_results( |
@@ -468,11 +468,11 @@ discard block |
||
468 | 468 | * @param int $TXN_ID |
469 | 469 | * @return EE_Registration |
470 | 470 | */ |
471 | - public function get_primary_registration_for_transaction_ID( $TXN_ID = 0){ |
|
472 | - if( ! $TXN_ID ){ |
|
471 | + public function get_primary_registration_for_transaction_ID($TXN_ID = 0) { |
|
472 | + if ( ! $TXN_ID) { |
|
473 | 473 | return false; |
474 | 474 | } |
475 | - return $this->get_one(array(array('TXN_ID'=>$TXN_ID,'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
475 | + return $this->get_one(array(array('TXN_ID'=>$TXN_ID, 'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -484,11 +484,11 @@ discard block |
||
484 | 484 | * @param boolean $for_incomplete_payments |
485 | 485 | * @return int |
486 | 486 | */ |
487 | - public function get_event_registration_count ( $EVT_ID, $for_incomplete_payments = FALSE ) { |
|
487 | + public function get_event_registration_count($EVT_ID, $for_incomplete_payments = FALSE) { |
|
488 | 488 | // we only count approved registrations towards registration limits |
489 | - $query_params = array( array( 'EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved ) ); |
|
490 | - if( $for_incomplete_payments ){ |
|
491 | - $query_params[0]['Transaction.STS_ID']=array('!=', EEM_Transaction::complete_status_code); |
|
489 | + $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
490 | + if ($for_incomplete_payments) { |
|
491 | + $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | return $this->count($query_params); |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | /** @type WPDB $wpdb */ |
505 | 505 | global $wpdb; |
506 | 506 | return $wpdb->query( |
507 | - 'DELETE r FROM ' . $this->table() . ' r LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
507 | + 'DELETE r FROM '.$this->table().' r LEFT JOIN '.EEM_Transaction::instance()->table().' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -514,17 +514,17 @@ discard block |
||
514 | 514 | * @param boolean $checked_in whether to count registrations checked IN or OUT |
515 | 515 | * @return int |
516 | 516 | */ |
517 | - public function count_registrations_checked_into_datetime( $DTT_ID, $checked_in = true) { |
|
517 | + public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true) { |
|
518 | 518 | global $wpdb; |
519 | 519 | //subquery to get latest checkin |
520 | 520 | $query = $wpdb->prepare( |
521 | 521 | 'SELECT ' |
522 | 522 | . 'COUNT( DISTINCT checkins.REG_ID ) ' |
523 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
523 | + . 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN' |
|
524 | 524 | . '( SELECT ' |
525 | 525 | . 'max( CHK_timestamp ) AS latest_checkin, ' |
526 | 526 | . 'REG_ID AS REG_ID ' |
527 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' ' |
|
527 | + . 'FROM '.EEM_Checkin::instance()->table().' ' |
|
528 | 528 | . 'WHERE DTT_ID=%d ' |
529 | 529 | . 'GROUP BY REG_ID' |
530 | 530 | . ') AS most_recent_checkin_per_reg ' |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | $DTT_ID, |
536 | 536 | $checked_in |
537 | 537 | ); |
538 | - return (int)$wpdb->get_var( $query ); |
|
538 | + return (int) $wpdb->get_var($query); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | /** |
@@ -545,18 +545,18 @@ discard block |
||
545 | 545 | * @param boolean $checked_in whether to count registrations checked IN or OUT |
546 | 546 | * @return int |
547 | 547 | */ |
548 | - public function count_registrations_checked_into_event( $EVT_ID, $checked_in = true ) { |
|
548 | + public function count_registrations_checked_into_event($EVT_ID, $checked_in = true) { |
|
549 | 549 | global $wpdb; |
550 | 550 | //subquery to get latest checkin |
551 | 551 | $query = $wpdb->prepare( |
552 | 552 | 'SELECT ' |
553 | 553 | . 'COUNT( DISTINCT checkins.REG_ID ) ' |
554 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
554 | + . 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN' |
|
555 | 555 | . '( SELECT ' |
556 | 556 | . 'max( CHK_timestamp ) AS latest_checkin, ' |
557 | 557 | . 'REG_ID AS REG_ID ' |
558 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS c ' |
|
559 | - . 'INNER JOIN ' . EEM_Datetime::instance()->table() . ' AS d ' |
|
558 | + . 'FROM '.EEM_Checkin::instance()->table().' AS c ' |
|
559 | + . 'INNER JOIN '.EEM_Datetime::instance()->table().' AS d ' |
|
560 | 560 | . 'ON c.DTT_ID=d.DTT_ID ' |
561 | 561 | . 'WHERE d.EVT_ID=%d ' |
562 | 562 | . 'GROUP BY REG_ID' |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | $EVT_ID, |
569 | 569 | $checked_in |
570 | 570 | ); |
571 | - return (int)$wpdb->get_var( $query ); |
|
571 | + return (int) $wpdb->get_var($query); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | |
@@ -583,15 +583,15 @@ discard block |
||
583 | 583 | * @param array $attendee_ids |
584 | 584 | * @return EE_Registration[] |
585 | 585 | */ |
586 | - public function get_latest_registration_for_each_of_given_contacts( $attendee_ids = array() ) { |
|
586 | + public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array()) { |
|
587 | 587 | //first do a native wp_query to get the latest REG_ID's matching these attendees. |
588 | 588 | global $wpdb; |
589 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
589 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
590 | 590 | $attendee_table = $wpdb->posts; |
591 | - $attendee_ids = is_array( $attendee_ids ) |
|
592 | - ? array_map( 'absint', $attendee_ids ) |
|
593 | - : array( (int) $attendee_ids ); |
|
594 | - $attendee_ids = implode( ',', $attendee_ids ); |
|
591 | + $attendee_ids = is_array($attendee_ids) |
|
592 | + ? array_map('absint', $attendee_ids) |
|
593 | + : array((int) $attendee_ids); |
|
594 | + $attendee_ids = implode(',', $attendee_ids); |
|
595 | 595 | |
596 | 596 | |
597 | 597 | //first we do a query to get the registration ids |
@@ -616,24 +616,24 @@ discard block |
||
616 | 616 | ARRAY_A |
617 | 617 | ); |
618 | 618 | |
619 | - if ( empty( $registration_ids ) ) { |
|
619 | + if (empty($registration_ids)) { |
|
620 | 620 | return array(); |
621 | 621 | } |
622 | 622 | |
623 | 623 | $ids_for_model_query = array(); |
624 | 624 | //let's flatten the ids so they can be used in the model query. |
625 | - foreach ( $registration_ids as $registration_id ) { |
|
626 | - if ( isset( $registration_id['registration_id'] ) ) { |
|
625 | + foreach ($registration_ids as $registration_id) { |
|
626 | + if (isset($registration_id['registration_id'])) { |
|
627 | 627 | $ids_for_model_query[] = $registration_id['registration_id']; |
628 | 628 | } |
629 | 629 | } |
630 | 630 | |
631 | 631 | //construct query |
632 | 632 | $_where = array( |
633 | - 'REG_ID' => array( 'IN', $ids_for_model_query ) |
|
633 | + 'REG_ID' => array('IN', $ids_for_model_query) |
|
634 | 634 | ); |
635 | 635 | |
636 | - return $this->get_all( array( $_where ) ); |
|
636 | + return $this->get_all(array($_where)); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public static function instance() { |
130 | 130 | // check if class object is instantiated, and instantiated properly |
131 | - if ( ! self::$_instance instanceof EE_Config ) { |
|
131 | + if ( ! self::$_instance instanceof EE_Config) { |
|
132 | 132 | self::$_instance = new self(); |
133 | 133 | } |
134 | 134 | return self::$_instance; |
@@ -145,22 +145,22 @@ discard block |
||
145 | 145 | * not be ready to instantiate EE_Config currently (eg if the site was put into maintenance mode) |
146 | 146 | * @return EE_Config |
147 | 147 | */ |
148 | - public static function reset( $hard_reset = FALSE, $reinstantiate = TRUE ){ |
|
149 | - if ( $hard_reset ) { |
|
148 | + public static function reset($hard_reset = FALSE, $reinstantiate = TRUE) { |
|
149 | + if ($hard_reset) { |
|
150 | 150 | self::$_instance->_config_option_names = array(); |
151 | 151 | self::$_instance->_initialize_config(); |
152 | 152 | self::$_instance->update_espresso_config(); |
153 | 153 | } |
154 | - if( self::$_instance instanceof EE_Config ){ |
|
154 | + if (self::$_instance instanceof EE_Config) { |
|
155 | 155 | self::$_instance->shutdown(); |
156 | 156 | } |
157 | 157 | self::$_instance = NULL; |
158 | 158 | //we don't need to reset the static properties imo because those should |
159 | 159 | //only change when a module is added or removed. Currently we don't |
160 | 160 | //support removing a module during a request when it previously existed |
161 | - if( $reinstantiate ){ |
|
161 | + if ($reinstantiate) { |
|
162 | 162 | return self::instance(); |
163 | - }else{ |
|
163 | + } else { |
|
164 | 164 | return NULL; |
165 | 165 | } |
166 | 166 | } |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @return \EE_Config |
175 | 175 | */ |
176 | 176 | private function __construct() { |
177 | - do_action( 'AHEE__EE_Config__construct__begin',$this ); |
|
178 | - $this->_config_option_names = get_option( 'ee_config_option_names', array() ); |
|
177 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
178 | + $this->_config_option_names = get_option('ee_config_option_names', array()); |
|
179 | 179 | // setup empty config classes |
180 | 180 | $this->_initialize_config(); |
181 | 181 | // load existing EE site settings |
@@ -183,15 +183,15 @@ discard block |
||
183 | 183 | // confirm everything loaded correctly and set filtered defaults if not |
184 | 184 | $this->_verify_config(); |
185 | 185 | // register shortcodes and modules |
186 | - add_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_and_modules' ), 999 ); |
|
186 | + add_action('AHEE__EE_System__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_and_modules'), 999); |
|
187 | 187 | // initialize shortcodes and modules |
188 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'initialize_shortcodes_and_modules' )); |
|
188 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
189 | 189 | // register widgets |
190 | - add_action( 'widgets_init', array( $this, 'widgets_init' ), 10 ); |
|
190 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
191 | 191 | // shutdown |
192 | - add_action( 'shutdown', array( $this, 'shutdown' ), 10 ); |
|
192 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
193 | 193 | // construct__end hook |
194 | - do_action( 'AHEE__EE_Config__construct__end',$this ); |
|
194 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
195 | 195 | // hardcoded hack |
196 | 196 | $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
197 | 197 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @return string current theme set. |
205 | 205 | */ |
206 | 206 | public static function get_current_theme() { |
207 | - return isset( self::$_instance->template_settings->current_espresso_theme ) ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
207 | + return isset(self::$_instance->template_settings->current_espresso_theme) ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -238,27 +238,27 @@ discard block |
||
238 | 238 | */ |
239 | 239 | private function _load_core_config() { |
240 | 240 | // load_core_config__start hook |
241 | - do_action( 'AHEE__EE_Config___load_core_config__start', $this ); |
|
241 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
242 | 242 | $espresso_config = $this->get_espresso_config(); |
243 | - foreach ( $espresso_config as $config => $settings ) { |
|
243 | + foreach ($espresso_config as $config => $settings) { |
|
244 | 244 | // load_core_config__start hook |
245 | - $settings = apply_filters( 'FHEE__EE_Config___load_core_config__config_settings', $settings, $config, $this ); |
|
246 | - if ( is_object( $settings ) && property_exists( $this, $config ) ) { |
|
247 | - $this->{$config} = apply_filters( 'FHEE__EE_Config___load_core_config__' . $config, $settings ); |
|
245 | + $settings = apply_filters('FHEE__EE_Config___load_core_config__config_settings', $settings, $config, $this); |
|
246 | + if (is_object($settings) && property_exists($this, $config)) { |
|
247 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings); |
|
248 | 248 | //call configs populate method to ensure any defaults are set for empty values. |
249 | - if ( method_exists( $settings, 'populate' ) ) { |
|
249 | + if (method_exists($settings, 'populate')) { |
|
250 | 250 | $this->{$config}->populate(); |
251 | 251 | } |
252 | - if ( method_exists( $settings, 'do_hooks' ) ) { |
|
252 | + if (method_exists($settings, 'do_hooks')) { |
|
253 | 253 | $this->{$config}->do_hooks(); |
254 | 254 | } |
255 | 255 | } |
256 | 256 | } |
257 | - if ( apply_filters( 'FHEE__EE_Config___load_core_config__update_espresso_config', FALSE ) ) { |
|
257 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', FALSE)) { |
|
258 | 258 | $this->update_espresso_config(); |
259 | 259 | } |
260 | 260 | // load_core_config__end hook |
261 | - do_action( 'AHEE__EE_Config___load_core_config__end', $this ); |
|
261 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -272,40 +272,40 @@ discard block |
||
272 | 272 | protected function _verify_config() { |
273 | 273 | |
274 | 274 | $this->core = $this->core instanceof EE_Core_Config |
275 | - ? $this->core : new EE_Core_Config(); |
|
276 | - $this->core = apply_filters( 'FHEE__EE_Config___initialize_config__core', $this->core ); |
|
275 | + ? $this->core : new EE_Core_Config(); |
|
276 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
277 | 277 | |
278 | 278 | $this->organization = $this->organization instanceof EE_Organization_Config |
279 | - ? $this->organization : new EE_Organization_Config(); |
|
280 | - $this->organization = apply_filters( 'FHEE__EE_Config___initialize_config__organization', $this->organization ); |
|
279 | + ? $this->organization : new EE_Organization_Config(); |
|
280 | + $this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization', $this->organization); |
|
281 | 281 | |
282 | 282 | $this->currency = $this->currency instanceof EE_Currency_Config |
283 | 283 | ? $this->currency : new EE_Currency_Config(); |
284 | - $this->currency = apply_filters( 'FHEE__EE_Config___initialize_config__currency', $this->currency ); |
|
284 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
285 | 285 | |
286 | 286 | $this->registration = $this->registration instanceof EE_Registration_Config |
287 | 287 | ? $this->registration : new EE_Registration_Config(); |
288 | - $this->registration = apply_filters( 'FHEE__EE_Config___initialize_config__registration', $this->registration ); |
|
288 | + $this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration', $this->registration); |
|
289 | 289 | |
290 | 290 | $this->admin = $this->admin instanceof EE_Admin_Config |
291 | 291 | ? $this->admin : new EE_Admin_Config(); |
292 | - $this->admin = apply_filters( 'FHEE__EE_Config___initialize_config__admin', $this->admin ); |
|
292 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
293 | 293 | |
294 | 294 | $this->template_settings = $this->template_settings instanceof EE_Template_Config |
295 | 295 | ? $this->template_settings : new EE_Template_Config(); |
296 | - $this->template_settings = apply_filters( 'FHEE__EE_Config___initialize_config__template_settings', $this->template_settings ); |
|
296 | + $this->template_settings = apply_filters('FHEE__EE_Config___initialize_config__template_settings', $this->template_settings); |
|
297 | 297 | |
298 | 298 | $this->map_settings = $this->map_settings instanceof EE_Map_Config |
299 | 299 | ? $this->map_settings : new EE_Map_Config(); |
300 | - $this->map_settings = apply_filters( 'FHEE__EE_Config___initialize_config__map_settings', $this->map_settings ); |
|
300 | + $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', $this->map_settings); |
|
301 | 301 | |
302 | 302 | $this->environment = $this->environment instanceof EE_Environment_Config |
303 | 303 | ? $this->environment : new EE_Environment_Config(); |
304 | - $this->environment = apply_filters( 'FHEE__EE_Config___initialize_config__environment', $this->environment ); |
|
304 | + $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', $this->environment); |
|
305 | 305 | |
306 | 306 | $this->gateway = $this->gateway instanceof EE_Gateway_Config |
307 | 307 | ? $this->gateway : new EE_Gateway_Config(); |
308 | - $this->gateway = apply_filters( 'FHEE__EE_Config___initialize_config__gateway', $this->gateway ); |
|
308 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
309 | 309 | |
310 | 310 | } |
311 | 311 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function get_espresso_config() { |
321 | 321 | // grab espresso configuration |
322 | - return apply_filters( 'FHEE__EE_Config__get_espresso_config__CFG', get_option( 'ee_config', array() )); |
|
322 | + return apply_filters('FHEE__EE_Config__get_espresso_config__CFG', get_option('ee_config', array())); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -332,12 +332,12 @@ discard block |
||
332 | 332 | * @param $old_value |
333 | 333 | * @param $value |
334 | 334 | */ |
335 | - public function double_check_config_comparison( $option = '', $old_value, $value ) { |
|
335 | + public function double_check_config_comparison($option = '', $old_value, $value) { |
|
336 | 336 | // make sure we're checking the ee config |
337 | - if ( $option == 'ee_config' ) { |
|
337 | + if ($option == 'ee_config') { |
|
338 | 338 | // run a loose comparison of the old value against the new value for type and properties, |
339 | 339 | // but NOT exact instance like WP update_option does |
340 | - if ( $value != $old_value ) { |
|
340 | + if ($value != $old_value) { |
|
341 | 341 | // if they are NOT the same, then remove the hook, |
342 | 342 | // which means the subsequent update results will be based solely on the update query results |
343 | 343 | // the reason we do this is because, as stated above, |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | // the string it sees in the db looks the same as the new one it has been passed!!! |
353 | 353 | // This results in the query returning an "affected rows" value of ZERO, |
354 | 354 | // which gets returned immediately by WP update_option and looks like an error. |
355 | - remove_action( 'update_option', array( $this, 'check_config_updated' )); |
|
355 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
356 | 356 | } |
357 | 357 | } |
358 | 358 | } |
@@ -367,11 +367,11 @@ discard block |
||
367 | 367 | */ |
368 | 368 | protected function _reset_espresso_addon_config() { |
369 | 369 | $this->_config_option_names = array(); |
370 | - foreach( $this->addons as $addon_name => $addon_config_obj ) { |
|
371 | - $addon_config_obj = maybe_unserialize( $addon_config_obj ); |
|
372 | - $config_class = get_class( $addon_config_obj ); |
|
373 | - if ( $addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class ) { |
|
374 | - $this->update_config( 'addons', $addon_name, $addon_config_obj, FALSE ); |
|
370 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
371 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
372 | + $config_class = get_class($addon_config_obj); |
|
373 | + if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) { |
|
374 | + $this->update_config('addons', $addon_name, $addon_config_obj, FALSE); |
|
375 | 375 | } |
376 | 376 | $this->addons->{$addon_name} = NULL; |
377 | 377 | } |
@@ -387,17 +387,17 @@ discard block |
||
387 | 387 | * @param bool $add_error |
388 | 388 | * @return bool |
389 | 389 | */ |
390 | - public function update_espresso_config( $add_success = FALSE, $add_error = TRUE ) { |
|
390 | + public function update_espresso_config($add_success = FALSE, $add_error = TRUE) { |
|
391 | 391 | // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
392 | 392 | //$clone = clone( self::$_instance ); |
393 | 393 | //self::$_instance = NULL; |
394 | - do_action( 'AHEE__EE_Config__update_espresso_config__begin',$this ); |
|
394 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
395 | 395 | $this->_reset_espresso_addon_config(); |
396 | 396 | // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
397 | 397 | // but BEFORE the actual update occurs |
398 | - add_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1, 3 ); |
|
398 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
399 | 399 | // now update "ee_config" |
400 | - $saved = update_option( 'ee_config', $this ); |
|
400 | + $saved = update_option('ee_config', $this); |
|
401 | 401 | // if not saved... check if the hook we just added still exists; |
402 | 402 | // if it does, it means one of two things: |
403 | 403 | // that update_option bailed at the ( $value === $old_value ) conditional, |
@@ -408,25 +408,25 @@ discard block |
||
408 | 408 | // but just means no update occurred, so don't display an error to the user. |
409 | 409 | // BUT... if update_option returns FALSE, AND the hook is missing, |
410 | 410 | // then it means that something truly went wrong |
411 | - $saved = ! $saved ? has_action( 'update_option', array( $this, 'double_check_config_comparison' )) : $saved; |
|
411 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
412 | 412 | // remove our action since we don't want it in the system anymore |
413 | - remove_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1 ); |
|
414 | - do_action( 'AHEE__EE_Config__update_espresso_config__end', $this, $saved ); |
|
413 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
414 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
415 | 415 | //self::$_instance = $clone; |
416 | 416 | //unset( $clone ); |
417 | 417 | // if config remains the same or was updated successfully |
418 | - if ( $saved ) { |
|
419 | - if ( $add_success ) { |
|
418 | + if ($saved) { |
|
419 | + if ($add_success) { |
|
420 | 420 | EE_Error::add_success( |
421 | - __( 'The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso' ), |
|
421 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
422 | 422 | __FILE__, __FUNCTION__, __LINE__ |
423 | 423 | ); |
424 | 424 | } |
425 | 425 | return TRUE; |
426 | 426 | } else { |
427 | - if ( $add_error ) { |
|
427 | + if ($add_error) { |
|
428 | 428 | EE_Error::add_error( |
429 | - __( 'The Event Espresso Configuration Settings were not updated.', 'event_espresso' ), |
|
429 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
430 | 430 | __FILE__, __FUNCTION__, __LINE__ |
431 | 431 | ); |
432 | 432 | } |
@@ -452,20 +452,20 @@ discard block |
||
452 | 452 | $name = '', |
453 | 453 | $config_class = '', |
454 | 454 | $config_obj = NULL, |
455 | - $tests_to_run = array( 1, 2, 3, 4, 5, 6, 7, 8 ), |
|
455 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
456 | 456 | $display_errors = TRUE |
457 | 457 | ) { |
458 | 458 | try { |
459 | - foreach ( $tests_to_run as $test ) { |
|
460 | - switch ( $test ) { |
|
459 | + foreach ($tests_to_run as $test) { |
|
460 | + switch ($test) { |
|
461 | 461 | |
462 | 462 | // TEST #1 : check that section was set |
463 | 463 | case 1 : |
464 | - if ( empty( $section ) ) { |
|
465 | - if ( $display_errors ) { |
|
464 | + if (empty($section)) { |
|
465 | + if ($display_errors) { |
|
466 | 466 | throw new EE_Error( |
467 | 467 | sprintf( |
468 | - __( 'No configuration section has been provided while attempting to save "%s".', 'event_espresso' ), |
|
468 | + __('No configuration section has been provided while attempting to save "%s".', 'event_espresso'), |
|
469 | 469 | $config_class |
470 | 470 | ) |
471 | 471 | ); |
@@ -476,11 +476,11 @@ discard block |
||
476 | 476 | |
477 | 477 | // TEST #2 : check that settings section exists |
478 | 478 | case 2 : |
479 | - if ( ! isset( $this->{$section} ) ) { |
|
480 | - if ( $display_errors ) { |
|
479 | + if ( ! isset($this->{$section} )) { |
|
480 | + if ($display_errors) { |
|
481 | 481 | throw new EE_Error( |
482 | - sprintf( __( 'The "%s" configuration section does not exist.', 'event_espresso' ), |
|
483 | - $section ) |
|
482 | + sprintf(__('The "%s" configuration section does not exist.', 'event_espresso'), |
|
483 | + $section) |
|
484 | 484 | ); |
485 | 485 | } |
486 | 486 | return false; |
@@ -490,12 +490,12 @@ discard block |
||
490 | 490 | // TEST #3 : check that section is the proper format |
491 | 491 | case 3 : |
492 | 492 | if ( |
493 | - ! ( $this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass ) |
|
493 | + ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
494 | 494 | ) { |
495 | - if ( $display_errors ) { |
|
495 | + if ($display_errors) { |
|
496 | 496 | throw new EE_Error( |
497 | 497 | sprintf( |
498 | - __( 'The "%s" configuration settings have not been formatted correctly.', 'event_espresso' ), |
|
498 | + __('The "%s" configuration settings have not been formatted correctly.', 'event_espresso'), |
|
499 | 499 | $section |
500 | 500 | ) |
501 | 501 | ); |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | |
507 | 507 | // TEST #4 : check that config section name has been set |
508 | 508 | case 4 : |
509 | - if ( empty( $name ) ) { |
|
510 | - if ( $display_errors ) { |
|
509 | + if (empty($name)) { |
|
510 | + if ($display_errors) { |
|
511 | 511 | throw new EE_Error( |
512 | - __( 'No name has been provided for the specific configuration section.', 'event_espresso' ) |
|
512 | + __('No name has been provided for the specific configuration section.', 'event_espresso') |
|
513 | 513 | ); |
514 | 514 | } |
515 | 515 | return false; |
@@ -518,10 +518,10 @@ discard block |
||
518 | 518 | |
519 | 519 | // TEST #5 : check that a config class name has been set |
520 | 520 | case 5 : |
521 | - if ( empty( $config_class ) ) { |
|
522 | - if ( $display_errors ) { |
|
521 | + if (empty($config_class)) { |
|
522 | + if ($display_errors) { |
|
523 | 523 | throw new EE_Error( |
524 | - __( 'No class name has been provided for the specific configuration section.', 'event_espresso' ) |
|
524 | + __('No class name has been provided for the specific configuration section.', 'event_espresso') |
|
525 | 525 | ); |
526 | 526 | } |
527 | 527 | return false; |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | |
531 | 531 | // TEST #6 : verify config class is accessible |
532 | 532 | case 6 : |
533 | - if ( ! class_exists( $config_class ) ) { |
|
534 | - if ( $display_errors ) { |
|
533 | + if ( ! class_exists($config_class)) { |
|
534 | + if ($display_errors) { |
|
535 | 535 | throw new EE_Error( |
536 | 536 | sprintf( |
537 | - __( 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', 'event_espresso' ), |
|
537 | + __('The "%s" class does not exist. Please ensure that an autoloader has been set for it.', 'event_espresso'), |
|
538 | 538 | $config_class |
539 | 539 | ) |
540 | 540 | ); |
@@ -545,11 +545,11 @@ discard block |
||
545 | 545 | |
546 | 546 | // TEST #7 : check that config has even been set |
547 | 547 | case 7 : |
548 | - if ( ! isset( $this->{$section}->{$name} ) ) { |
|
549 | - if ( $display_errors ) { |
|
548 | + if ( ! isset($this->{$section}->{$name} )) { |
|
549 | + if ($display_errors) { |
|
550 | 550 | throw new EE_Error( |
551 | 551 | sprintf( |
552 | - __( 'No configuration has been set for "%1$s->%2$s".', 'event_espresso' ), |
|
552 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
553 | 553 | $section, |
554 | 554 | $name |
555 | 555 | ) |
@@ -558,17 +558,17 @@ discard block |
||
558 | 558 | return false; |
559 | 559 | } else { |
560 | 560 | // and make sure it's not serialized |
561 | - $this->{$section}->{$name} = maybe_unserialize( $this->{$section}->{$name} ); |
|
561 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name} ); |
|
562 | 562 | } |
563 | 563 | break; |
564 | 564 | |
565 | 565 | // TEST #8 : check that config is the requested type |
566 | 566 | case 8 : |
567 | - if ( ! $this->{$section}->{$name} instanceof $config_class ) { |
|
568 | - if ( $display_errors ) { |
|
567 | + if ( ! $this->{$section}->{$name} instanceof $config_class) { |
|
568 | + if ($display_errors) { |
|
569 | 569 | throw new EE_Error( |
570 | 570 | sprintf( |
571 | - __( 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', 'event_espresso' ), |
|
571 | + __('The configuration for "%1$s->%2$s" is not of the "%3$s" class.', 'event_espresso'), |
|
572 | 572 | $section, |
573 | 573 | $name, |
574 | 574 | $config_class |
@@ -581,12 +581,12 @@ discard block |
||
581 | 581 | |
582 | 582 | // TEST #9 : verify config object |
583 | 583 | case 9 : |
584 | - if ( ! $config_obj instanceof EE_Config_Base ) { |
|
585 | - if ( $display_errors ) { |
|
584 | + if ( ! $config_obj instanceof EE_Config_Base) { |
|
585 | + if ($display_errors) { |
|
586 | 586 | throw new EE_Error( |
587 | 587 | sprintf( |
588 | - __( 'The "%s" class is not an instance of EE_Config_Base.', 'event_espresso' ), |
|
589 | - print_r( $config_obj, true ) |
|
588 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
589 | + print_r($config_obj, true) |
|
590 | 590 | ) |
591 | 591 | ); |
592 | 592 | } |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | } |
598 | 598 | } |
599 | 599 | |
600 | - } catch( EE_Error $e ) { |
|
600 | + } catch (EE_Error $e) { |
|
601 | 601 | $e->get_error(); |
602 | 602 | } |
603 | 603 | // you have successfully run the gauntlet |
@@ -614,8 +614,8 @@ discard block |
||
614 | 614 | * @param string $name |
615 | 615 | * @return string |
616 | 616 | */ |
617 | - private function _generate_config_option_name( $section = '', $name = '' ) { |
|
618 | - return 'ee_config-' . strtolower( $section . '-' . str_replace( array( 'EE_', 'EED_' ), '', $name ) ); |
|
617 | + private function _generate_config_option_name($section = '', $name = '') { |
|
618 | + return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name)); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | |
@@ -629,10 +629,10 @@ discard block |
||
629 | 629 | * @param string $name |
630 | 630 | * @return string |
631 | 631 | */ |
632 | - private function _set_config_class( $config_class = '', $name = '' ) { |
|
633 | - return ! empty( $config_class ) |
|
632 | + private function _set_config_class($config_class = '', $name = '') { |
|
633 | + return ! empty($config_class) |
|
634 | 634 | ? $config_class |
635 | - : str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $name ) ) ) . '_Config'; |
|
635 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config'; |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | |
@@ -646,34 +646,34 @@ discard block |
||
646 | 646 | * @param EE_Config_Base $config_obj |
647 | 647 | * @return EE_Config_Base |
648 | 648 | */ |
649 | - public function set_config( $section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null ) { |
|
649 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) { |
|
650 | 650 | // ensure config class is set to something |
651 | - $config_class = $this->_set_config_class( $config_class, $name ); |
|
651 | + $config_class = $this->_set_config_class($config_class, $name); |
|
652 | 652 | // run tests 1-4, 6, and 7 to verify all config params are set and valid |
653 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ))) { |
|
653 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
654 | 654 | return null; |
655 | 655 | } |
656 | - $config_option_name = $this->_generate_config_option_name( $section, $name ); |
|
656 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
657 | 657 | // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
658 | - if ( ! isset( $this->_config_option_names[ $config_option_name ] )) { |
|
659 | - $this->_config_option_names[ $config_option_name ] = $config_class; |
|
658 | + if ( ! isset($this->_config_option_names[$config_option_name])) { |
|
659 | + $this->_config_option_names[$config_option_name] = $config_class; |
|
660 | 660 | } |
661 | 661 | // verify the incoming config object but suppress errors |
662 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false )) { |
|
662 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
663 | 663 | $config_obj = new $config_class(); |
664 | 664 | } |
665 | - if ( get_option( $config_option_name ) ) { |
|
666 | - update_option( $config_option_name, $config_obj ); |
|
665 | + if (get_option($config_option_name)) { |
|
666 | + update_option($config_option_name, $config_obj); |
|
667 | 667 | $this->{$section}->{$name} = $config_obj; |
668 | 668 | return $this->{$section}->{$name}; |
669 | 669 | } else { |
670 | 670 | // create a wp-option for this config |
671 | - if ( add_option( $config_option_name, $config_obj, '', 'no' )) { |
|
672 | - $this->{$section}->{$name} = maybe_unserialize( $config_obj ); |
|
671 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
672 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
673 | 673 | return $this->{$section}->{$name}; |
674 | 674 | } else { |
675 | 675 | EE_Error::add_error( |
676 | - sprintf( __( 'The "%s" could not be saved to the database.', 'event_espresso' ), $config_class ), |
|
676 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
677 | 677 | __FILE__, __FUNCTION__, __LINE__ |
678 | 678 | ); |
679 | 679 | return null; |
@@ -694,37 +694,37 @@ discard block |
||
694 | 694 | * @param bool $throw_errors |
695 | 695 | * @return bool |
696 | 696 | */ |
697 | - public function update_config( $section = '', $name = '', $config_obj = '', $throw_errors = true ) { |
|
698 | - $config_obj = maybe_unserialize( $config_obj ); |
|
697 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) { |
|
698 | + $config_obj = maybe_unserialize($config_obj); |
|
699 | 699 | // get class name of the incoming object |
700 | - $config_class = get_class( $config_obj ); |
|
700 | + $config_class = get_class($config_obj); |
|
701 | 701 | // run tests 1-5 and 9 to verify config |
702 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 1, 2, 3, 4, 7, 9 ))) { |
|
702 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(1, 2, 3, 4, 7, 9))) { |
|
703 | 703 | return false; |
704 | 704 | } |
705 | - $config_option_name = $this->_generate_config_option_name( $section, $name ); |
|
705 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
706 | 706 | // check if config object has been added to db by seeing if config option name is in $this->_config_option_names array |
707 | - if ( ! isset( $this->_config_option_names[ $config_option_name ] )) { |
|
707 | + if ( ! isset($this->_config_option_names[$config_option_name])) { |
|
708 | 708 | // save new config to db |
709 | - return $this->set_config( $section, $name, $config_class, $config_obj ); |
|
709 | + return $this->set_config($section, $name, $config_class, $config_obj); |
|
710 | 710 | } else { |
711 | 711 | // first check if the record already exists |
712 | - $existing_config = get_option( $config_option_name ); |
|
713 | - $config_obj = serialize( $config_obj ); |
|
712 | + $existing_config = get_option($config_option_name); |
|
713 | + $config_obj = serialize($config_obj); |
|
714 | 714 | // just return if db record is already up to date |
715 | - if ( $existing_config == $config_obj ) { |
|
715 | + if ($existing_config == $config_obj) { |
|
716 | 716 | $this->{$section}->{$name} = $config_obj; |
717 | 717 | return true; |
718 | - } else if ( update_option( $config_option_name, $config_obj )) { |
|
718 | + } else if (update_option($config_option_name, $config_obj)) { |
|
719 | 719 | // update wp-option for this config class |
720 | 720 | $this->{$section}->{$name} = $config_obj; |
721 | 721 | return true; |
722 | - } elseif ( $throw_errors ) { |
|
722 | + } elseif ($throw_errors) { |
|
723 | 723 | EE_Error::add_error( |
724 | 724 | sprintf( |
725 | - __( 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', 'event_espresso' ), |
|
725 | + __('The "%1$s" object stored at"%2$s" was not successfully updated in the database.', 'event_espresso'), |
|
726 | 726 | $config_class, |
727 | - 'EE_Config->' . $section . '->' . $name |
|
727 | + 'EE_Config->'.$section.'->'.$name |
|
728 | 728 | ), |
729 | 729 | __FILE__, __FUNCTION__, __LINE__ |
730 | 730 | ); |
@@ -744,34 +744,34 @@ discard block |
||
744 | 744 | * @param string $config_class |
745 | 745 | * @return mixed EE_Config_Base | NULL |
746 | 746 | */ |
747 | - public function get_config( $section = '', $name = '', $config_class = '' ) { |
|
747 | + public function get_config($section = '', $name = '', $config_class = '') { |
|
748 | 748 | // ensure config class is set to something |
749 | - $config_class = $this->_set_config_class( $config_class, $name ); |
|
749 | + $config_class = $this->_set_config_class($config_class, $name); |
|
750 | 750 | // run tests 1-4, 6 and 7 to verify that all params have been set |
751 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, NULL, array( 1, 2, 3, 4, 5, 6 ))) { |
|
751 | + if ( ! $this->_verify_config_params($section, $name, $config_class, NULL, array(1, 2, 3, 4, 5, 6))) { |
|
752 | 752 | return NULL; |
753 | 753 | } |
754 | 754 | // now test if the requested config object exists, but suppress errors |
755 | - if ( $this->_verify_config_params( $section, $name, $config_class, NULL, array( 7, 8 ), FALSE )) { |
|
755 | + if ($this->_verify_config_params($section, $name, $config_class, NULL, array(7, 8), FALSE)) { |
|
756 | 756 | // config already exists, so pass it back |
757 | 757 | return $this->{$section}->{$name}; |
758 | 758 | } |
759 | 759 | // load config option from db if it exists |
760 | - $config_obj = $this->get_config_option( $this->_generate_config_option_name( $section, $name )); |
|
760 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
761 | 761 | // verify the newly retrieved config object, but suppress errors |
762 | - if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), FALSE )) { |
|
762 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), FALSE)) { |
|
763 | 763 | // config is good, so set it and pass it back |
764 | 764 | $this->{$section}->{$name} = $config_obj; |
765 | 765 | return $this->{$section}->{$name}; |
766 | 766 | } |
767 | 767 | // oops! $config_obj is not already set and does not exist in the db, so create a new one |
768 | - $config_obj =$this->set_config( $section, $name, $config_class ); |
|
768 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
769 | 769 | // verify the newly created config object |
770 | - if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ))) { |
|
770 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
771 | 771 | return $this->{$section}->{$name}; |
772 | 772 | } else { |
773 | 773 | EE_Error::add_error( |
774 | - sprintf( __( 'The "%s" could not be retrieved from the database.', 'event_espresso' ), $config_class ), |
|
774 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
775 | 775 | __FILE__, __FUNCTION__, __LINE__ |
776 | 776 | ); |
777 | 777 | } |
@@ -786,9 +786,9 @@ discard block |
||
786 | 786 | * @param string $config_option_name |
787 | 787 | * @return mixed EE_Config_Base | FALSE |
788 | 788 | */ |
789 | - public function get_config_option( $config_option_name = '' ) { |
|
789 | + public function get_config_option($config_option_name = '') { |
|
790 | 790 | // retrieve the wp-option for this config class. |
791 | - return maybe_unserialize( get_option( $config_option_name )); |
|
791 | + return maybe_unserialize(get_option($config_option_name)); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | |
@@ -803,14 +803,14 @@ discard block |
||
803 | 803 | * @return string |
804 | 804 | */ |
805 | 805 | public static function get_page_for_posts() { |
806 | - $page_for_posts = get_option( 'page_for_posts' ); |
|
807 | - if ( ! $page_for_posts ) { |
|
806 | + $page_for_posts = get_option('page_for_posts'); |
|
807 | + if ( ! $page_for_posts) { |
|
808 | 808 | return 'posts'; |
809 | 809 | } |
810 | 810 | /** @type WPDB $wpdb */ |
811 | 811 | global $wpdb; |
812 | 812 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
813 | - return $wpdb->get_var( $wpdb->prepare( $SQL, $page_for_posts )); |
|
813 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | */ |
828 | 828 | public function register_shortcodes_and_modules() { |
829 | 829 | // allow shortcodes to register with WP and to set hooks for the rest of the system |
830 | - EE_Registry::instance()->shortcodes =$this->_register_shortcodes(); |
|
830 | + EE_Registry::instance()->shortcodes = $this->_register_shortcodes(); |
|
831 | 831 | // allow modules to set hooks for the rest of the system |
832 | 832 | EE_Registry::instance()->modules = $this->_register_modules(); |
833 | 833 | } |
@@ -859,21 +859,21 @@ discard block |
||
859 | 859 | public function widgets_init() { |
860 | 860 | //only init widgets on admin pages when not in complete maintenance, and |
861 | 861 | //on frontend when not in any maintenance mode |
862 | - if (( is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) || ! EE_Maintenance_Mode::instance()->level() ) { |
|
862 | + if ((is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) || ! EE_Maintenance_Mode::instance()->level()) { |
|
863 | 863 | // grab list of installed widgets |
864 | - $widgets_to_register = glob( EE_WIDGETS . '*', GLOB_ONLYDIR ); |
|
864 | + $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR); |
|
865 | 865 | // filter list of modules to register |
866 | - $widgets_to_register = apply_filters( 'FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register ); |
|
866 | + $widgets_to_register = apply_filters('FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register); |
|
867 | 867 | |
868 | - if ( ! empty( $widgets_to_register ) ) { |
|
868 | + if ( ! empty($widgets_to_register)) { |
|
869 | 869 | // cycle thru widget folders |
870 | - foreach ( $widgets_to_register as $widget_path ) { |
|
870 | + foreach ($widgets_to_register as $widget_path) { |
|
871 | 871 | // add to list of installed widget modules |
872 | - EE_Config::register_ee_widget( $widget_path ); |
|
872 | + EE_Config::register_ee_widget($widget_path); |
|
873 | 873 | } |
874 | 874 | } |
875 | 875 | // filter list of installed modules |
876 | - EE_Registry::instance()->widgets = apply_filters( 'FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets ); |
|
876 | + EE_Registry::instance()->widgets = apply_filters('FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets); |
|
877 | 877 | } |
878 | 878 | } |
879 | 879 | |
@@ -886,54 +886,54 @@ discard block |
||
886 | 886 | * @param string $widget_path - full path up to and including widget folder |
887 | 887 | * @return void |
888 | 888 | */ |
889 | - public static function register_ee_widget( $widget_path = NULL ) { |
|
890 | - do_action( 'AHEE__EE_Config__register_widget__begin', $widget_path ); |
|
889 | + public static function register_ee_widget($widget_path = NULL) { |
|
890 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
891 | 891 | $widget_ext = '.widget.php'; |
892 | 892 | // make all separators match |
893 | - $widget_path = rtrim( str_replace( '/\\', DS, $widget_path ), DS ); |
|
893 | + $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
894 | 894 | // does the file path INCLUDE the actual file name as part of the path ? |
895 | - if ( strpos( $widget_path, $widget_ext ) !== FALSE ) { |
|
895 | + if (strpos($widget_path, $widget_ext) !== FALSE) { |
|
896 | 896 | // grab and shortcode file name from directory name and break apart at dots |
897 | - $file_name = explode( '.', basename( $widget_path )); |
|
897 | + $file_name = explode('.', basename($widget_path)); |
|
898 | 898 | // take first segment from file name pieces and remove class prefix if it exists |
899 | - $widget = strpos( $file_name[0], 'EEW_' ) === 0 ? substr( $file_name[0], 4 ) : $file_name[0]; |
|
899 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
900 | 900 | // sanitize shortcode directory name |
901 | - $widget = sanitize_key( $widget ); |
|
901 | + $widget = sanitize_key($widget); |
|
902 | 902 | // now we need to rebuild the shortcode path |
903 | - $widget_path = explode( DS, $widget_path ); |
|
903 | + $widget_path = explode(DS, $widget_path); |
|
904 | 904 | // remove last segment |
905 | - array_pop( $widget_path ); |
|
905 | + array_pop($widget_path); |
|
906 | 906 | // glue it back together |
907 | - $widget_path = implode( DS, $widget_path ); |
|
907 | + $widget_path = implode(DS, $widget_path); |
|
908 | 908 | } else { |
909 | 909 | // grab and sanitize widget directory name |
910 | - $widget = sanitize_key( basename( $widget_path )); |
|
910 | + $widget = sanitize_key(basename($widget_path)); |
|
911 | 911 | } |
912 | 912 | // create classname from widget directory name |
913 | - $widget = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $widget ))); |
|
913 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
914 | 914 | // add class prefix |
915 | - $widget_class = 'EEW_' . $widget; |
|
915 | + $widget_class = 'EEW_'.$widget; |
|
916 | 916 | // does the widget exist ? |
917 | - if ( ! is_readable( $widget_path . DS . $widget_class . $widget_ext )) { |
|
917 | + if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) { |
|
918 | 918 | $msg = sprintf( |
919 | - __( 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso' ), |
|
919 | + __('The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), |
|
920 | 920 | $widget_class, |
921 | - $widget_path . DS . $widget_class . $widget_ext |
|
921 | + $widget_path.DS.$widget_class.$widget_ext |
|
922 | 922 | ); |
923 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
923 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
924 | 924 | return; |
925 | 925 | } |
926 | 926 | // load the widget class file |
927 | - require_once( $widget_path . DS . $widget_class . $widget_ext ); |
|
927 | + require_once($widget_path.DS.$widget_class.$widget_ext); |
|
928 | 928 | // verify that class exists |
929 | - if ( ! class_exists( $widget_class )) { |
|
930 | - $msg = sprintf( __( 'The requested %s widget class does not exist.', 'event_espresso' ), $widget_class ); |
|
931 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
929 | + if ( ! class_exists($widget_class)) { |
|
930 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
931 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
932 | 932 | return; |
933 | 933 | } |
934 | - register_widget( $widget_class ); |
|
934 | + register_widget($widget_class); |
|
935 | 935 | // add to array of registered widgets |
936 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
936 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext; |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | |
@@ -946,18 +946,18 @@ discard block |
||
946 | 946 | */ |
947 | 947 | private function _register_shortcodes() { |
948 | 948 | // grab list of installed shortcodes |
949 | - $shortcodes_to_register = glob( EE_SHORTCODES . '*', GLOB_ONLYDIR ); |
|
949 | + $shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR); |
|
950 | 950 | // filter list of modules to register |
951 | - $shortcodes_to_register = apply_filters( 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register ); |
|
952 | - if ( ! empty( $shortcodes_to_register ) ) { |
|
951 | + $shortcodes_to_register = apply_filters('FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register); |
|
952 | + if ( ! empty($shortcodes_to_register)) { |
|
953 | 953 | // cycle thru shortcode folders |
954 | - foreach ( $shortcodes_to_register as $shortcode_path ) { |
|
954 | + foreach ($shortcodes_to_register as $shortcode_path) { |
|
955 | 955 | // add to list of installed shortcode modules |
956 | - EE_Config::register_shortcode( $shortcode_path ); |
|
956 | + EE_Config::register_shortcode($shortcode_path); |
|
957 | 957 | } |
958 | 958 | } |
959 | 959 | // filter list of installed modules |
960 | - return apply_filters( 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes ); |
|
960 | + return apply_filters('FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes); |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | |
@@ -969,56 +969,56 @@ discard block |
||
969 | 969 | * @param string $shortcode_path - full path up to and including shortcode folder |
970 | 970 | * @return bool |
971 | 971 | */ |
972 | - public static function register_shortcode( $shortcode_path = NULL ) { |
|
973 | - do_action( 'AHEE__EE_Config__register_shortcode__begin',$shortcode_path ); |
|
972 | + public static function register_shortcode($shortcode_path = NULL) { |
|
973 | + do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
974 | 974 | $shortcode_ext = '.shortcode.php'; |
975 | 975 | // make all separators match |
976 | - $shortcode_path = str_replace( array( '\\', '/' ), DS, $shortcode_path ); |
|
976 | + $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
977 | 977 | // does the file path INCLUDE the actual file name as part of the path ? |
978 | - if ( strpos( $shortcode_path, $shortcode_ext ) !== FALSE ) { |
|
978 | + if (strpos($shortcode_path, $shortcode_ext) !== FALSE) { |
|
979 | 979 | // grab shortcode file name from directory name and break apart at dots |
980 | - $shortcode_file = explode( '.', basename( $shortcode_path )); |
|
980 | + $shortcode_file = explode('.', basename($shortcode_path)); |
|
981 | 981 | // take first segment from file name pieces and remove class prefix if it exists |
982 | - $shortcode = strpos( $shortcode_file[0], 'EES_' ) === 0 ? substr( $shortcode_file[0], 4 ) : $shortcode_file[0]; |
|
982 | + $shortcode = strpos($shortcode_file[0], 'EES_') === 0 ? substr($shortcode_file[0], 4) : $shortcode_file[0]; |
|
983 | 983 | // sanitize shortcode directory name |
984 | - $shortcode = sanitize_key( $shortcode ); |
|
984 | + $shortcode = sanitize_key($shortcode); |
|
985 | 985 | // now we need to rebuild the shortcode path |
986 | - $shortcode_path = explode( DS, $shortcode_path ); |
|
986 | + $shortcode_path = explode(DS, $shortcode_path); |
|
987 | 987 | // remove last segment |
988 | - array_pop( $shortcode_path ); |
|
988 | + array_pop($shortcode_path); |
|
989 | 989 | // glue it back together |
990 | - $shortcode_path = implode( DS, $shortcode_path ) . DS; |
|
990 | + $shortcode_path = implode(DS, $shortcode_path).DS; |
|
991 | 991 | } else { |
992 | 992 | // we need to generate the filename based off of the folder name |
993 | 993 | // grab and sanitize shortcode directory name |
994 | - $shortcode = sanitize_key( basename( $shortcode_path )); |
|
995 | - $shortcode_path = rtrim( $shortcode_path, DS ) . DS; |
|
994 | + $shortcode = sanitize_key(basename($shortcode_path)); |
|
995 | + $shortcode_path = rtrim($shortcode_path, DS).DS; |
|
996 | 996 | } |
997 | 997 | // create classname from shortcode directory or file name |
998 | - $shortcode = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $shortcode ))); |
|
998 | + $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
999 | 999 | // add class prefix |
1000 | - $shortcode_class = 'EES_' . $shortcode; |
|
1000 | + $shortcode_class = 'EES_'.$shortcode; |
|
1001 | 1001 | // does the shortcode exist ? |
1002 | - if ( ! is_readable( $shortcode_path . DS . $shortcode_class . $shortcode_ext )) { |
|
1002 | + if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) { |
|
1003 | 1003 | $msg = sprintf( |
1004 | - __( 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso' ), |
|
1004 | + __('The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso'), |
|
1005 | 1005 | $shortcode_class, |
1006 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
1006 | + $shortcode_path.DS.$shortcode_class.$shortcode_ext |
|
1007 | 1007 | ); |
1008 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1008 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1009 | 1009 | return FALSE; |
1010 | 1010 | } |
1011 | 1011 | // load the shortcode class file |
1012 | - require_once( $shortcode_path . $shortcode_class . $shortcode_ext ); |
|
1012 | + require_once($shortcode_path.$shortcode_class.$shortcode_ext); |
|
1013 | 1013 | // verify that class exists |
1014 | - if ( ! class_exists( $shortcode_class )) { |
|
1015 | - $msg = sprintf( __( 'The requested %s shortcode class does not exist.', 'event_espresso' ), $shortcode_class ); |
|
1016 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1014 | + if ( ! class_exists($shortcode_class)) { |
|
1015 | + $msg = sprintf(__('The requested %s shortcode class does not exist.', 'event_espresso'), $shortcode_class); |
|
1016 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1017 | 1017 | return FALSE; |
1018 | 1018 | } |
1019 | - $shortcode = strtoupper( $shortcode ); |
|
1019 | + $shortcode = strtoupper($shortcode); |
|
1020 | 1020 | // add to array of registered shortcodes |
1021 | - EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
1021 | + EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext; |
|
1022 | 1022 | return TRUE; |
1023 | 1023 | } |
1024 | 1024 | |
@@ -1033,23 +1033,23 @@ discard block |
||
1033 | 1033 | */ |
1034 | 1034 | private function _register_modules() { |
1035 | 1035 | // grab list of installed modules |
1036 | - $modules_to_register = glob( EE_MODULES . '*', GLOB_ONLYDIR ); |
|
1036 | + $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR); |
|
1037 | 1037 | // filter list of modules to register |
1038 | - $modules_to_register = apply_filters( 'FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register ); |
|
1038 | + $modules_to_register = apply_filters('FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register); |
|
1039 | 1039 | |
1040 | 1040 | |
1041 | - if ( ! empty( $modules_to_register ) ) { |
|
1041 | + if ( ! empty($modules_to_register)) { |
|
1042 | 1042 | // loop through folders |
1043 | - foreach ( $modules_to_register as $module_path ) { |
|
1043 | + foreach ($modules_to_register as $module_path) { |
|
1044 | 1044 | /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
1045 | - if ( $module_path != EE_MODULES . 'zzz-copy-this-module-template' && $module_path != EE_MODULES . 'gateways' ) { |
|
1045 | + if ($module_path != EE_MODULES.'zzz-copy-this-module-template' && $module_path != EE_MODULES.'gateways') { |
|
1046 | 1046 | // add to list of installed modules |
1047 | - EE_Config::register_module( $module_path ); |
|
1047 | + EE_Config::register_module($module_path); |
|
1048 | 1048 | } |
1049 | 1049 | } |
1050 | 1050 | } |
1051 | 1051 | // filter list of installed modules |
1052 | - return apply_filters( 'FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules ); |
|
1052 | + return apply_filters('FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | |
@@ -1062,54 +1062,54 @@ discard block |
||
1062 | 1062 | * @param string $module_path - full path up to and including module folder |
1063 | 1063 | * @return bool |
1064 | 1064 | */ |
1065 | - public static function register_module( $module_path = NULL ) { |
|
1066 | - do_action( 'AHEE__EE_Config__register_module__begin', $module_path ); |
|
1065 | + public static function register_module($module_path = NULL) { |
|
1066 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1067 | 1067 | $module_ext = '.module.php'; |
1068 | 1068 | // make all separators match |
1069 | - $module_path = str_replace( array( '\\', '/' ), DS, $module_path ); |
|
1069 | + $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1070 | 1070 | // does the file path INCLUDE the actual file name as part of the path ? |
1071 | - if ( strpos( $module_path, $module_ext ) !== FALSE ) { |
|
1071 | + if (strpos($module_path, $module_ext) !== FALSE) { |
|
1072 | 1072 | // grab and shortcode file name from directory name and break apart at dots |
1073 | - $module_file = explode( '.', basename( $module_path )); |
|
1073 | + $module_file = explode('.', basename($module_path)); |
|
1074 | 1074 | // now we need to rebuild the shortcode path |
1075 | - $module_path = explode( DS, $module_path ); |
|
1075 | + $module_path = explode(DS, $module_path); |
|
1076 | 1076 | // remove last segment |
1077 | - array_pop( $module_path ); |
|
1077 | + array_pop($module_path); |
|
1078 | 1078 | // glue it back together |
1079 | - $module_path = implode( DS, $module_path ) . DS; |
|
1079 | + $module_path = implode(DS, $module_path).DS; |
|
1080 | 1080 | // take first segment from file name pieces and sanitize it |
1081 | - $module = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $module_file[0] ); |
|
1081 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1082 | 1082 | // ensure class prefix is added |
1083 | - $module_class = strpos( $module, 'EED_' ) !== 0 ? 'EED_' . $module : $module; |
|
1083 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module; |
|
1084 | 1084 | } else { |
1085 | 1085 | // we need to generate the filename based off of the folder name |
1086 | 1086 | // grab and sanitize module name |
1087 | - $module = strtolower( basename( $module_path )); |
|
1088 | - $module = preg_replace( '/[^a-z0-9_\-]/', '', $module); |
|
1087 | + $module = strtolower(basename($module_path)); |
|
1088 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1089 | 1089 | // like trailingslashit() |
1090 | - $module_path = rtrim( $module_path, DS ) . DS; |
|
1090 | + $module_path = rtrim($module_path, DS).DS; |
|
1091 | 1091 | // create classname from module directory name |
1092 | - $module = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $module ))); |
|
1092 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1093 | 1093 | // add class prefix |
1094 | - $module_class = 'EED_' . $module; |
|
1094 | + $module_class = 'EED_'.$module; |
|
1095 | 1095 | } |
1096 | 1096 | // does the module exist ? |
1097 | - if ( ! is_readable( $module_path . DS . $module_class . $module_ext )) { |
|
1098 | - $msg = sprintf( __( 'The requested %s module file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module ); |
|
1099 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1097 | + if ( ! is_readable($module_path.DS.$module_class.$module_ext)) { |
|
1098 | + $msg = sprintf(__('The requested %s module file could not be found or is not readable due to file permissions.', 'event_espresso'), $module); |
|
1099 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1100 | 1100 | return FALSE; |
1101 | 1101 | } |
1102 | 1102 | // load the module class file |
1103 | - require_once( $module_path . $module_class . $module_ext ); |
|
1103 | + require_once($module_path.$module_class.$module_ext); |
|
1104 | 1104 | // verify that class exists |
1105 | - if ( ! class_exists( $module_class )) { |
|
1106 | - $msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
|
1107 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1105 | + if ( ! class_exists($module_class)) { |
|
1106 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1107 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1108 | 1108 | return FALSE; |
1109 | 1109 | } |
1110 | 1110 | // add to array of registered modules |
1111 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1112 | - do_action( 'AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->{$module_class} ); |
|
1111 | + EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext; |
|
1112 | + do_action('AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->{$module_class} ); |
|
1113 | 1113 | return TRUE; |
1114 | 1114 | } |
1115 | 1115 | |
@@ -1123,23 +1123,23 @@ discard block |
||
1123 | 1123 | */ |
1124 | 1124 | private function _initialize_shortcodes() { |
1125 | 1125 | // cycle thru shortcode folders |
1126 | - foreach ( EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path ) { |
|
1126 | + foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) { |
|
1127 | 1127 | // add class prefix |
1128 | - $shortcode_class = 'EES_' . $shortcode; |
|
1128 | + $shortcode_class = 'EES_'.$shortcode; |
|
1129 | 1129 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
1130 | 1130 | // which set hooks ? |
1131 | - if ( is_admin() ) { |
|
1131 | + if (is_admin()) { |
|
1132 | 1132 | // fire immediately |
1133 | - call_user_func( array( $shortcode_class, 'set_hooks_admin' )); |
|
1133 | + call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
1134 | 1134 | } else { |
1135 | 1135 | // delay until other systems are online |
1136 | - add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $shortcode_class,'set_hooks' )); |
|
1136 | + add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array($shortcode_class, 'set_hooks')); |
|
1137 | 1137 | // convert classname to UPPERCASE and create WP shortcode. |
1138 | - $shortcode_tag = strtoupper( $shortcode ); |
|
1138 | + $shortcode_tag = strtoupper($shortcode); |
|
1139 | 1139 | // but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor' |
1140 | - if ( ! shortcode_exists( $shortcode_tag )) { |
|
1140 | + if ( ! shortcode_exists($shortcode_tag)) { |
|
1141 | 1141 | // NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes() |
1142 | - add_shortcode( $shortcode_tag, array( $shortcode_class, 'fallback_shortcode_processor' )); |
|
1142 | + add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
1143 | 1143 | } |
1144 | 1144 | } |
1145 | 1145 | } |
@@ -1156,15 +1156,15 @@ discard block |
||
1156 | 1156 | */ |
1157 | 1157 | private function _initialize_modules() { |
1158 | 1158 | // cycle thru shortcode folders |
1159 | - foreach ( EE_Registry::instance()->modules as $module_class => $module_path ) { |
|
1159 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1160 | 1160 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
1161 | 1161 | // which set hooks ? |
1162 | - if ( is_admin() ) { |
|
1162 | + if (is_admin()) { |
|
1163 | 1163 | // fire immediately |
1164 | - call_user_func( array( $module_class, 'set_hooks_admin' )); |
|
1164 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
1165 | 1165 | } else { |
1166 | 1166 | // delay until other systems are online |
1167 | - add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $module_class,'set_hooks' )); |
|
1167 | + add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array($module_class, 'set_hooks')); |
|
1168 | 1168 | } |
1169 | 1169 | } |
1170 | 1170 | } |
@@ -1182,26 +1182,26 @@ discard block |
||
1182 | 1182 | * @param string $key - url param key indicating a route is being called |
1183 | 1183 | * @return bool |
1184 | 1184 | */ |
1185 | - public static function register_route( $route = NULL, $module = NULL, $method_name = NULL, $key = 'ee' ) { |
|
1186 | - do_action( 'AHEE__EE_Config__register_route__begin', $route, $module, $method_name ); |
|
1187 | - $module = str_replace( 'EED_', '', $module ); |
|
1188 | - $module_class = 'EED_' . $module; |
|
1189 | - if ( ! isset( EE_Registry::instance()->modules->{$module_class} )) { |
|
1190 | - $msg = sprintf( __( 'The module %s has not been registered.', 'event_espresso' ), $module ); |
|
1191 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1185 | + public static function register_route($route = NULL, $module = NULL, $method_name = NULL, $key = 'ee') { |
|
1186 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1187 | + $module = str_replace('EED_', '', $module); |
|
1188 | + $module_class = 'EED_'.$module; |
|
1189 | + if ( ! isset(EE_Registry::instance()->modules->{$module_class} )) { |
|
1190 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1191 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1192 | 1192 | return FALSE; |
1193 | 1193 | } |
1194 | - if ( empty( $route )) { |
|
1195 | - $msg = sprintf( __( 'No route has been supplied.', 'event_espresso' ), $route ); |
|
1196 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1194 | + if (empty($route)) { |
|
1195 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1196 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1197 | 1197 | return FALSE; |
1198 | 1198 | } |
1199 | - if ( ! method_exists ( 'EED_' . $module, $method_name )) { |
|
1200 | - $msg = sprintf( __( 'A valid class method for the %s route has not been supplied.', 'event_espresso' ), $route ); |
|
1201 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1199 | + if ( ! method_exists('EED_'.$module, $method_name)) { |
|
1200 | + $msg = sprintf(__('A valid class method for the %s route has not been supplied.', 'event_espresso'), $route); |
|
1201 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1202 | 1202 | return FALSE; |
1203 | 1203 | } |
1204 | - EE_Config::$_module_route_map[ $key ][ $route ] = array( 'EED_' . $module, $method_name ); |
|
1204 | + EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name); |
|
1205 | 1205 | return TRUE; |
1206 | 1206 | } |
1207 | 1207 | |
@@ -1215,11 +1215,11 @@ discard block |
||
1215 | 1215 | * @param string $key - url param key indicating a route is being called |
1216 | 1216 | * @return string |
1217 | 1217 | */ |
1218 | - public static function get_route( $route = NULL, $key = 'ee' ) { |
|
1219 | - do_action( 'AHEE__EE_Config__get_route__begin',$route ); |
|
1220 | - $route = apply_filters( 'FHEE__EE_Config__get_route',$route ); |
|
1221 | - if ( isset( EE_Config::$_module_route_map[ $key ][ $route ] )) { |
|
1222 | - return EE_Config::$_module_route_map[ $key ][ $route ]; |
|
1218 | + public static function get_route($route = NULL, $key = 'ee') { |
|
1219 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1220 | + $route = apply_filters('FHEE__EE_Config__get_route', $route); |
|
1221 | + if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
1222 | + return EE_Config::$_module_route_map[$key][$route]; |
|
1223 | 1223 | } |
1224 | 1224 | return NULL; |
1225 | 1225 | } |
@@ -1248,35 +1248,35 @@ discard block |
||
1248 | 1248 | * @param string $key - url param key indicating a route is being called |
1249 | 1249 | * @return bool |
1250 | 1250 | */ |
1251 | - public static function register_forward( $route = NULL, $status = 0, $forward = NULL, $key = 'ee' ) { |
|
1252 | - do_action( 'AHEE__EE_Config__register_forward',$route,$status,$forward ); |
|
1253 | - if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route )) { |
|
1254 | - $msg = sprintf( __( 'The module route %s for this forward has not been registered.', 'event_espresso' ), $route ); |
|
1255 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1251 | + public static function register_forward($route = NULL, $status = 0, $forward = NULL, $key = 'ee') { |
|
1252 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1253 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1254 | + $msg = sprintf(__('The module route %s for this forward has not been registered.', 'event_espresso'), $route); |
|
1255 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1256 | 1256 | return FALSE; |
1257 | 1257 | } |
1258 | - if ( empty( $forward )) { |
|
1259 | - $msg = sprintf( __( 'No forwarding route has been supplied.', 'event_espresso' ), $route ); |
|
1260 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1258 | + if (empty($forward)) { |
|
1259 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1260 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1261 | 1261 | return FALSE; |
1262 | 1262 | } |
1263 | - if ( is_array( $forward )) { |
|
1264 | - if ( ! isset( $forward[1] )) { |
|
1265 | - $msg = sprintf( __( 'A class method for the %s forwarding route has not been supplied.', 'event_espresso' ), $route ); |
|
1266 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1263 | + if (is_array($forward)) { |
|
1264 | + if ( ! isset($forward[1])) { |
|
1265 | + $msg = sprintf(__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), $route); |
|
1266 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1267 | 1267 | return FALSE; |
1268 | 1268 | } |
1269 | - if ( ! method_exists( $forward[0], $forward[1] )) { |
|
1270 | - $msg = sprintf( __( 'The class method %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward[1], $route ); |
|
1271 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1269 | + if ( ! method_exists($forward[0], $forward[1])) { |
|
1270 | + $msg = sprintf(__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), $forward[1], $route); |
|
1271 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1272 | 1272 | return FALSE; |
1273 | 1273 | } |
1274 | - } else if ( ! function_exists( $forward )) { |
|
1275 | - $msg = sprintf( __( 'The function %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward, $route ); |
|
1276 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1274 | + } else if ( ! function_exists($forward)) { |
|
1275 | + $msg = sprintf(__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), $forward, $route); |
|
1276 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1277 | 1277 | return FALSE; |
1278 | 1278 | } |
1279 | - EE_Config::$_module_forward_map[ $key ][ $route ][ absint( $status ) ] = $forward; |
|
1279 | + EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
1280 | 1280 | return TRUE; |
1281 | 1281 | } |
1282 | 1282 | |
@@ -1291,10 +1291,10 @@ discard block |
||
1291 | 1291 | * @param string $key - url param key indicating a route is being called |
1292 | 1292 | * @return string |
1293 | 1293 | */ |
1294 | - public static function get_forward( $route = NULL, $status = 0, $key = 'ee' ) { |
|
1295 | - do_action( 'AHEE__EE_Config__get_forward__begin',$route,$status ); |
|
1296 | - if ( isset( EE_Config::$_module_forward_map[ $key ][ $route ][ $status ] )) { |
|
1297 | - return apply_filters( 'FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], $route,$status ); |
|
1294 | + public static function get_forward($route = NULL, $status = 0, $key = 'ee') { |
|
1295 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1296 | + if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
1297 | + return apply_filters('FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[$key][$route][$status], $route, $status); |
|
1298 | 1298 | } |
1299 | 1299 | return NULL; |
1300 | 1300 | } |
@@ -1311,19 +1311,19 @@ discard block |
||
1311 | 1311 | * @param string $key - url param key indicating a route is being called |
1312 | 1312 | * @return bool |
1313 | 1313 | */ |
1314 | - public static function register_view( $route = NULL, $status = 0, $view = NULL, $key = 'ee' ) { |
|
1315 | - do_action( 'AHEE__EE_Config__register_view__begin',$route,$status,$view ); |
|
1316 | - if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route )) { |
|
1317 | - $msg = sprintf( __( 'The module route %s for this view has not been registered.', 'event_espresso' ), $route ); |
|
1318 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1314 | + public static function register_view($route = NULL, $status = 0, $view = NULL, $key = 'ee') { |
|
1315 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1316 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1317 | + $msg = sprintf(__('The module route %s for this view has not been registered.', 'event_espresso'), $route); |
|
1318 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1319 | 1319 | return FALSE; |
1320 | 1320 | } |
1321 | - if ( ! is_readable( $view )) { |
|
1322 | - $msg = sprintf( __( 'The %s view file could not be found or is not readable due to file permissions.', 'event_espresso' ), $view ); |
|
1323 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1321 | + if ( ! is_readable($view)) { |
|
1322 | + $msg = sprintf(__('The %s view file could not be found or is not readable due to file permissions.', 'event_espresso'), $view); |
|
1323 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1324 | 1324 | return FALSE; |
1325 | 1325 | } |
1326 | - EE_Config::$_module_view_map[ $key ][ $route ][ absint( $status ) ] = $view; |
|
1326 | + EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
1327 | 1327 | return TRUE; |
1328 | 1328 | } |
1329 | 1329 | |
@@ -1340,10 +1340,10 @@ discard block |
||
1340 | 1340 | * @param string $key - url param key indicating a route is being called |
1341 | 1341 | * @return string |
1342 | 1342 | */ |
1343 | - public static function get_view( $route = NULL, $status = 0, $key = 'ee' ) { |
|
1344 | - do_action( 'AHEE__EE_Config__get_view__begin',$route,$status ); |
|
1345 | - if ( isset( EE_Config::$_module_view_map[ $key ][ $route ][ $status ] )) { |
|
1346 | - return apply_filters( 'FHEE__EE_Config__get_view', EE_Config::$_module_view_map[ $key ][ $route ][ $status ], $route,$status ); |
|
1343 | + public static function get_view($route = NULL, $status = 0, $key = 'ee') { |
|
1344 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1345 | + if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
1346 | + return apply_filters('FHEE__EE_Config__get_view', EE_Config::$_module_view_map[$key][$route][$status], $route, $status); |
|
1347 | 1347 | } |
1348 | 1348 | return NULL; |
1349 | 1349 | } |
@@ -1351,7 +1351,7 @@ discard block |
||
1351 | 1351 | |
1352 | 1352 | |
1353 | 1353 | public function shutdown() { |
1354 | - update_option( 'ee_config_option_names', $this->_config_option_names ); |
|
1354 | + update_option('ee_config_option_names', $this->_config_option_names); |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | |
@@ -1367,7 +1367,7 @@ discard block |
||
1367 | 1367 | * magic functions in use, except we'll allow them to magically set and get stuff... |
1368 | 1368 | * basically, they should just be well-defined stdClasses |
1369 | 1369 | */ |
1370 | -class EE_Config_Base{ |
|
1370 | +class EE_Config_Base { |
|
1371 | 1371 | |
1372 | 1372 | /** |
1373 | 1373 | * Utility function for escaping the value of a property and returning. |
@@ -1376,13 +1376,13 @@ discard block |
||
1376 | 1376 | * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
1377 | 1377 | * @throws \EE_Error |
1378 | 1378 | */ |
1379 | - public function get_pretty( $property ) { |
|
1380 | - if ( ! property_exists( $this, $property ) ) { |
|
1381 | - throw new EE_Error( sprintf( __('%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', 'event_espresso' ), get_class( $this ), $property ) ); |
|
1379 | + public function get_pretty($property) { |
|
1380 | + if ( ! property_exists($this, $property)) { |
|
1381 | + throw new EE_Error(sprintf(__('%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', 'event_espresso'), get_class($this), $property)); |
|
1382 | 1382 | } |
1383 | 1383 | //just handling escaping of strings for now. |
1384 | - if ( is_string( $this->{$property} ) ) { |
|
1385 | - return stripslashes( $this->{$property} ); |
|
1384 | + if (is_string($this->{$property} )) { |
|
1385 | + return stripslashes($this->{$property} ); |
|
1386 | 1386 | } |
1387 | 1387 | return $this->{$property}; |
1388 | 1388 | } |
@@ -1391,19 +1391,19 @@ discard block |
||
1391 | 1391 | |
1392 | 1392 | public function populate() { |
1393 | 1393 | //grab defaults via a new instance of this class. |
1394 | - $class_name = get_class( $this ); |
|
1394 | + $class_name = get_class($this); |
|
1395 | 1395 | $defaults = new $class_name; |
1396 | 1396 | |
1397 | 1397 | //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
1398 | 1398 | //default from our $defaults object. |
1399 | - foreach ( get_object_vars( $defaults ) as $property => $value ) { |
|
1400 | - if ( is_null( $this->{$property} ) ) { |
|
1399 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
1400 | + if (is_null($this->{$property} )) { |
|
1401 | 1401 | $this->{$property} = $value; |
1402 | 1402 | } |
1403 | 1403 | } |
1404 | 1404 | |
1405 | 1405 | //cleanup |
1406 | - unset( $defaults ); |
|
1406 | + unset($defaults); |
|
1407 | 1407 | } |
1408 | 1408 | |
1409 | 1409 | |
@@ -1495,12 +1495,12 @@ discard block |
||
1495 | 1495 | */ |
1496 | 1496 | public function __construct() { |
1497 | 1497 | $current_network_main_site = is_multisite() ? get_current_site() : NULL; |
1498 | - $current_main_site_id = !empty( $current_network_main_site ) ? $current_network_main_site->blog_id : 1; |
|
1498 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1499 | 1499 | // set default organization settings |
1500 | 1500 | $this->current_blog_id = get_current_blog_id(); |
1501 | 1501 | $this->current_blog_id = $this->current_blog_id === NULL ? 1 : $this->current_blog_id; |
1502 | - $this->ee_ueip_optin = is_main_site() ? get_option( 'ee_ueip_optin', TRUE ) : get_blog_option( $current_main_site_id, 'ee_ueip_optin', TRUE ); |
|
1503 | - $this->ee_ueip_has_notified = is_main_site() ? get_option( 'ee_ueip_has_notified', FALSE ) : TRUE; |
|
1502 | + $this->ee_ueip_optin = is_main_site() ? get_option('ee_ueip_optin', TRUE) : get_blog_option($current_main_site_id, 'ee_ueip_optin', TRUE); |
|
1503 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', FALSE) : TRUE; |
|
1504 | 1504 | $this->post_shortcodes = array(); |
1505 | 1505 | $this->module_route_map = array(); |
1506 | 1506 | $this->module_forward_map = array(); |
@@ -1519,7 +1519,7 @@ discard block |
||
1519 | 1519 | $this->event_cpt_slug = __('events', 'event_espresso'); |
1520 | 1520 | |
1521 | 1521 | //ueip constant check |
1522 | - if ( defined( 'EE_DISABLE_UXIP' ) && EE_DISABLE_UXIP ) { |
|
1522 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1523 | 1523 | $this->ee_ueip_optin = FALSE; |
1524 | 1524 | $this->ee_ueip_has_notified = TRUE; |
1525 | 1525 | } |
@@ -1559,8 +1559,8 @@ discard block |
||
1559 | 1559 | * @return string |
1560 | 1560 | */ |
1561 | 1561 | public function reg_page_url() { |
1562 | - if ( ! $this->reg_page_url ) { |
|
1563 | - $this->reg_page_url = get_permalink( $this->reg_page_id ) . '#checkout'; |
|
1562 | + if ( ! $this->reg_page_url) { |
|
1563 | + $this->reg_page_url = get_permalink($this->reg_page_id).'#checkout'; |
|
1564 | 1564 | } |
1565 | 1565 | return $this->reg_page_url; |
1566 | 1566 | } |
@@ -1573,12 +1573,12 @@ discard block |
||
1573 | 1573 | * @return string |
1574 | 1574 | */ |
1575 | 1575 | public function txn_page_url($query_args = array()) { |
1576 | - if ( ! $this->txn_page_url ) { |
|
1577 | - $this->txn_page_url = get_permalink( $this->txn_page_id ); |
|
1576 | + if ( ! $this->txn_page_url) { |
|
1577 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1578 | 1578 | } |
1579 | - if($query_args){ |
|
1580 | - return add_query_arg($query_args,$this->txn_page_url); |
|
1581 | - }else{ |
|
1579 | + if ($query_args) { |
|
1580 | + return add_query_arg($query_args, $this->txn_page_url); |
|
1581 | + } else { |
|
1582 | 1582 | return $this->txn_page_url; |
1583 | 1583 | } |
1584 | 1584 | } |
@@ -1590,12 +1590,12 @@ discard block |
||
1590 | 1590 | * @return string |
1591 | 1591 | */ |
1592 | 1592 | public function thank_you_page_url($query_args = array()) { |
1593 | - if ( ! $this->thank_you_page_url ) { |
|
1594 | - $this->thank_you_page_url = get_permalink( $this->thank_you_page_id ); |
|
1593 | + if ( ! $this->thank_you_page_url) { |
|
1594 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1595 | 1595 | } |
1596 | - if($query_args){ |
|
1597 | - return add_query_arg($query_args,$this->thank_you_page_url); |
|
1598 | - }else{ |
|
1596 | + if ($query_args) { |
|
1597 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
1598 | + } else { |
|
1599 | 1599 | return $this->thank_you_page_url; |
1600 | 1600 | } |
1601 | 1601 | } |
@@ -1606,8 +1606,8 @@ discard block |
||
1606 | 1606 | * @return string |
1607 | 1607 | */ |
1608 | 1608 | public function cancel_page_url() { |
1609 | - if ( ! $this->cancel_page_url ) { |
|
1610 | - $this->cancel_page_url = get_permalink( $this->cancel_page_id ); |
|
1609 | + if ( ! $this->cancel_page_url) { |
|
1610 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1611 | 1611 | } |
1612 | 1612 | return $this->cancel_page_url; |
1613 | 1613 | } |
@@ -1635,7 +1635,7 @@ discard block |
||
1635 | 1635 | //reset all url properties |
1636 | 1636 | $this->_reset_urls(); |
1637 | 1637 | //return what to save to db |
1638 | - return array_keys( get_object_vars( $this ) ); |
|
1638 | + return array_keys(get_object_vars($this)); |
|
1639 | 1639 | } |
1640 | 1640 | |
1641 | 1641 | } |
@@ -1867,39 +1867,39 @@ discard block |
||
1867 | 1867 | * @param null $CNT_ISO |
1868 | 1868 | * @return \EE_Currency_Config |
1869 | 1869 | */ |
1870 | - public function __construct( $CNT_ISO = NULL ) { |
|
1870 | + public function __construct($CNT_ISO = NULL) { |
|
1871 | 1871 | |
1872 | 1872 | // get country code from organization settings or use default |
1873 | - $ORG_CNT = isset( EE_Registry::instance()->CFG->organization ) && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ? EE_Registry::instance()->CFG->organization->CNT_ISO : NULL; |
|
1873 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ? EE_Registry::instance()->CFG->organization->CNT_ISO : NULL; |
|
1874 | 1874 | // but override if requested |
1875 | - $CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : $ORG_CNT; |
|
1876 | - EE_Registry::instance()->load_helper( 'Activation' ); |
|
1875 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
1876 | + EE_Registry::instance()->load_helper('Activation'); |
|
1877 | 1877 | // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
1878 | - if ( ! empty( $CNT_ISO ) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists( EE_Registry::instance()->load_model( 'Country' )->table() ) ) { |
|
1878 | + if ( ! empty($CNT_ISO) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists(EE_Registry::instance()->load_model('Country')->table())) { |
|
1879 | 1879 | // retrieve the country settings from the db, just in case they have been customized |
1880 | - $country = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $CNT_ISO ); |
|
1881 | - if ( $country instanceof EE_Country ) { |
|
1882 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
1883 | - $this->name = $country->currency_name_single(); // Dollar |
|
1884 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
1885 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
1886 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
1887 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
1888 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
1889 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
1880 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
1881 | + if ($country instanceof EE_Country) { |
|
1882 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
1883 | + $this->name = $country->currency_name_single(); // Dollar |
|
1884 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
1885 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
1886 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
1887 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
1888 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
1889 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
1890 | 1890 | } |
1891 | 1891 | } |
1892 | 1892 | // fallback to hardcoded defaults, in case the above failed |
1893 | - if ( empty( $this->code )) { |
|
1893 | + if (empty($this->code)) { |
|
1894 | 1894 | // set default currency settings |
1895 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
1896 | - $this->name = __( 'Dollar', 'event_espresso' ); // Dollar |
|
1897 | - $this->plural = __( 'Dollars', 'event_espresso' ); // Dollars |
|
1898 | - $this->sign = '$'; // currency sign: $ |
|
1899 | - $this->sign_b4 = TRUE; // currency sign before or after: $TRUE or FALSE$ |
|
1900 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
1901 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
1902 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
1895 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
1896 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
1897 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
1898 | + $this->sign = '$'; // currency sign: $ |
|
1899 | + $this->sign_b4 = TRUE; // currency sign before or after: $TRUE or FALSE$ |
|
1900 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
1901 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
1902 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
1903 | 1903 | } |
1904 | 1904 | } |
1905 | 1905 | } |
@@ -2048,7 +2048,7 @@ discard block |
||
2048 | 2048 | * @since 4.8.8.rc.019 |
2049 | 2049 | */ |
2050 | 2050 | public function do_hooks() { |
2051 | - add_action( 'AHEE__EE_Config___load_core_config__end', array( $this, 'set_default_reg_status_on_EEM_Event' )); |
|
2051 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2052 | 2052 | } |
2053 | 2053 | |
2054 | 2054 | |
@@ -2056,7 +2056,7 @@ discard block |
||
2056 | 2056 | * @return void |
2057 | 2057 | */ |
2058 | 2058 | public function set_default_reg_status_on_EEM_Event() { |
2059 | - EEM_Event::set_default_reg_status( $this->default_STS_ID ); |
|
2059 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2060 | 2060 | } |
2061 | 2061 | |
2062 | 2062 | |
@@ -2161,10 +2161,10 @@ discard block |
||
2161 | 2161 | * @param bool $reset |
2162 | 2162 | * @return string |
2163 | 2163 | */ |
2164 | - public function log_file_name( $reset = FALSE ) { |
|
2165 | - if ( empty( $this->log_file_name ) || $reset ) { |
|
2166 | - $this->log_file_name = sanitize_key( 'espresso_log_' . md5( uniqid( '', TRUE ))) . '.txt'; |
|
2167 | - EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
|
2164 | + public function log_file_name($reset = FALSE) { |
|
2165 | + if (empty($this->log_file_name) || $reset) { |
|
2166 | + $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', TRUE))).'.txt'; |
|
2167 | + EE_Config::instance()->update_espresso_config(FALSE, FALSE); |
|
2168 | 2168 | } |
2169 | 2169 | return $this->log_file_name; |
2170 | 2170 | } |
@@ -2176,10 +2176,10 @@ discard block |
||
2176 | 2176 | * @param bool $reset |
2177 | 2177 | * @return string |
2178 | 2178 | */ |
2179 | - public function debug_file_name( $reset = FALSE ) { |
|
2180 | - if ( empty( $this->debug_file_name ) || $reset ) { |
|
2181 | - $this->debug_file_name = sanitize_key( 'espresso_debug_' . md5( uniqid( '', TRUE ))) . '.txt'; |
|
2182 | - EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
|
2179 | + public function debug_file_name($reset = FALSE) { |
|
2180 | + if (empty($this->debug_file_name) || $reset) { |
|
2181 | + $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', TRUE))).'.txt'; |
|
2182 | + EE_Config::instance()->update_espresso_config(FALSE, FALSE); |
|
2183 | 2183 | } |
2184 | 2184 | return $this->debug_file_name; |
2185 | 2185 | } |
@@ -2352,21 +2352,21 @@ discard block |
||
2352 | 2352 | // set default map settings |
2353 | 2353 | $this->use_google_maps = TRUE; |
2354 | 2354 | // for event details pages (reg page) |
2355 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
2356 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
2357 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2358 | - $this->event_details_display_nav = TRUE; // ee_map_nav_display_single |
|
2359 | - $this->event_details_nav_size = FALSE; // ee_map_nav_size_single |
|
2360 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2361 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2355 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
2356 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
2357 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2358 | + $this->event_details_display_nav = TRUE; // ee_map_nav_display_single |
|
2359 | + $this->event_details_nav_size = FALSE; // ee_map_nav_size_single |
|
2360 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2361 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2362 | 2362 | // for event list pages |
2363 | - $this->event_list_map_width = 300; // ee_map_width |
|
2364 | - $this->event_list_map_height = 185; // ee_map_height |
|
2365 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2366 | - $this->event_list_display_nav = FALSE; // ee_map_nav_display |
|
2367 | - $this->event_list_nav_size = TRUE; // ee_map_nav_size |
|
2368 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2369 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
2363 | + $this->event_list_map_width = 300; // ee_map_width |
|
2364 | + $this->event_list_map_height = 185; // ee_map_height |
|
2365 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2366 | + $this->event_list_display_nav = FALSE; // ee_map_nav_display |
|
2367 | + $this->event_list_nav_size = TRUE; // ee_map_nav_size |
|
2368 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2369 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
2370 | 2370 | } |
2371 | 2371 | |
2372 | 2372 | } |
@@ -2377,7 +2377,7 @@ discard block |
||
2377 | 2377 | /** |
2378 | 2378 | * stores Events_Archive settings |
2379 | 2379 | */ |
2380 | -class EE_Events_Archive_Config extends EE_Config_Base{ |
|
2380 | +class EE_Events_Archive_Config extends EE_Config_Base { |
|
2381 | 2381 | |
2382 | 2382 | public $display_status_banner; |
2383 | 2383 | public $display_description; |
@@ -2396,7 +2396,7 @@ discard block |
||
2396 | 2396 | /** |
2397 | 2397 | * class constructor |
2398 | 2398 | */ |
2399 | - public function __construct(){ |
|
2399 | + public function __construct() { |
|
2400 | 2400 | $this->display_status_banner = 0; |
2401 | 2401 | $this->display_description = 1; |
2402 | 2402 | $this->display_ticket_selector = 0; |
@@ -2416,7 +2416,7 @@ discard block |
||
2416 | 2416 | /** |
2417 | 2417 | * Stores Event_Single_Config settings |
2418 | 2418 | */ |
2419 | -class EE_Event_Single_Config extends EE_Config_Base{ |
|
2419 | +class EE_Event_Single_Config extends EE_Config_Base { |
|
2420 | 2420 | |
2421 | 2421 | public $display_status_banner_single; |
2422 | 2422 | public $display_venue; |
@@ -2445,7 +2445,7 @@ discard block |
||
2445 | 2445 | /** |
2446 | 2446 | * Stores Ticket_Selector_Config settings |
2447 | 2447 | */ |
2448 | -class EE_Ticket_Selector_Config extends EE_Config_Base{ |
|
2448 | +class EE_Ticket_Selector_Config extends EE_Config_Base { |
|
2449 | 2449 | public $show_ticket_sale_columns; |
2450 | 2450 | public $show_ticket_details; |
2451 | 2451 | public $show_expired_tickets; |
@@ -2499,7 +2499,7 @@ discard block |
||
2499 | 2499 | * @return void |
2500 | 2500 | */ |
2501 | 2501 | protected function _set_php_values() { |
2502 | - $this->php->max_input_vars = ini_get( 'max_input_vars' ); |
|
2502 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
2503 | 2503 | $this->php->version = phpversion(); |
2504 | 2504 | } |
2505 | 2505 | |
@@ -2518,9 +2518,9 @@ discard block |
||
2518 | 2518 | * @type string $msg Any message to be displayed. |
2519 | 2519 | * } |
2520 | 2520 | */ |
2521 | - public function max_input_vars_limit_check( $input_count = 0 ) { |
|
2522 | - if ( ! empty( $this->php->max_input_vars ) && ( $input_count >= $this->php->max_input_vars ) && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >=9 ) ) { |
|
2523 | - return sprintf( __('The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', 'event_espresso'), '<br>', $input_count, $this->php->max_input_vars); |
|
2521 | + public function max_input_vars_limit_check($input_count = 0) { |
|
2522 | + if ( ! empty($this->php->max_input_vars) && ($input_count >= $this->php->max_input_vars) && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)) { |
|
2523 | + return sprintf(__('The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', 'event_espresso'), '<br>', $input_count, $this->php->max_input_vars); |
|
2524 | 2524 | } else { |
2525 | 2525 | return ''; |
2526 | 2526 | } |
@@ -2555,7 +2555,7 @@ discard block |
||
2555 | 2555 | * stores payment gateway info |
2556 | 2556 | * @deprecated |
2557 | 2557 | */ |
2558 | -class EE_Gateway_Config extends EE_Config_Base{ |
|
2558 | +class EE_Gateway_Config extends EE_Config_Base { |
|
2559 | 2559 | |
2560 | 2560 | /** |
2561 | 2561 | * Array with keys that are payment gateways slugs, and values are arrays |
@@ -2577,9 +2577,9 @@ discard block |
||
2577 | 2577 | * class constructor |
2578 | 2578 | * @deprecated |
2579 | 2579 | */ |
2580 | - public function __construct(){ |
|
2580 | + public function __construct() { |
|
2581 | 2581 | $this->payment_settings = array(); |
2582 | - $this->active_gateways = array( 'Invoice' => FALSE ); |
|
2582 | + $this->active_gateways = array('Invoice' => FALSE); |
|
2583 | 2583 | } |
2584 | 2584 | } |
2585 | 2585 |