@@ -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' |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\admin; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -28,31 +28,31 @@ discard block |
||
28 | 28 | public static function set_hooks_admin() { |
29 | 29 | add_action( |
30 | 30 | 'save_post', |
31 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save' ), |
|
31 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save'), |
|
32 | 32 | 100, |
33 | 33 | 2 |
34 | 34 | ); |
35 | 35 | add_action( |
36 | 36 | 'delete_post', |
37 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete' ), |
|
37 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete'), |
|
38 | 38 | 100, |
39 | 39 | 1 |
40 | 40 | ); |
41 | 41 | add_action( |
42 | 42 | 'add_option_page_for_posts', |
43 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set' ), |
|
43 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set'), |
|
44 | 44 | 100, |
45 | 45 | 2 |
46 | 46 | ); |
47 | 47 | add_action( |
48 | 48 | 'update_option', |
49 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change' ), |
|
49 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change'), |
|
50 | 50 | 100, |
51 | 51 | 3 |
52 | 52 | ); |
53 | 53 | add_action( |
54 | 54 | 'delete_option', |
55 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete' ), |
|
55 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete'), |
|
56 | 56 | 100, |
57 | 57 | 1 |
58 | 58 | ); |
@@ -72,61 +72,61 @@ discard block |
||
72 | 72 | * @param \WP_Post $post |
73 | 73 | * @return void |
74 | 74 | */ |
75 | - public static function parse_post_content_on_save( $post_ID, $post ) { |
|
75 | + public static function parse_post_content_on_save($post_ID, $post) { |
|
76 | 76 | // if the post is trashed, then let's remove our post shortcode tracking |
77 | - if ( $post instanceof \WP_Post && $post->post_status === 'trash' ) { |
|
78 | - PostShortcodeTracking::unset_post_shortcodes_on_delete( $post_ID ); |
|
77 | + if ($post instanceof \WP_Post && $post->post_status === 'trash') { |
|
78 | + PostShortcodeTracking::unset_post_shortcodes_on_delete($post_ID); |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | // default post types |
82 | - $post_types = array( 'post' => 0, 'page' => 1 ); |
|
82 | + $post_types = array('post' => 0, 'page' => 1); |
|
83 | 83 | // add CPTs |
84 | 84 | $CPTs = \EE_Register_CPTs::get_CPTs(); |
85 | - $post_types = array_merge( $post_types, $CPTs ); |
|
85 | + $post_types = array_merge($post_types, $CPTs); |
|
86 | 86 | // for default or CPT posts... |
87 | - if ( isset( $post_types[ $post->post_type ] ) ) { |
|
87 | + if (isset($post_types[$post->post_type])) { |
|
88 | 88 | // post on frontpage ? |
89 | 89 | $page_for_posts = \EE_Config::get_page_for_posts(); |
90 | - if ( $post->post_name === $page_for_posts ) { |
|
91 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $page_for_posts ); |
|
90 | + if ($post->post_name === $page_for_posts) { |
|
91 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page($page_for_posts); |
|
92 | 92 | return; |
93 | 93 | } |
94 | 94 | // array of shortcodes indexed by post name |
95 | - \EE_Registry::CFG()->core->post_shortcodes = isset( \EE_Registry::CFG()->core->post_shortcodes ) |
|
95 | + \EE_Registry::CFG()->core->post_shortcodes = isset(\EE_Registry::CFG()->core->post_shortcodes) |
|
96 | 96 | ? \EE_Registry::CFG()->core->post_shortcodes |
97 | 97 | : array(); |
98 | 98 | // whether to proceed with update |
99 | 99 | $update_post_shortcodes = false; |
100 | 100 | // empty both arrays |
101 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ] = array(); |
|
101 | + \EE_Registry::CFG()->core->post_shortcodes[$post->post_name] = array(); |
|
102 | 102 | // check that posts page is already being tracked |
103 | - if ( ! isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
103 | + if ( ! isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts])) { |
|
104 | 104 | // if not, then ensure that it is properly added |
105 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
105 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array(); |
|
106 | 106 | } |
107 | 107 | // loop thru shortcodes |
108 | - foreach ( \EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) { |
|
108 | + foreach (\EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir) { |
|
109 | 109 | // convert to UPPERCASE to get actual shortcode |
110 | - $EES_Shortcode = strtoupper( $EES_Shortcode ); |
|
110 | + $EES_Shortcode = strtoupper($EES_Shortcode); |
|
111 | 111 | // is the shortcode in the post_content ? |
112 | - if ( strpos( $post->post_content, $EES_Shortcode ) !== false ) { |
|
112 | + if (strpos($post->post_content, $EES_Shortcode) !== false) { |
|
113 | 113 | // map shortcode to post names and post IDs |
114 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID; |
|
114 | + \EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode] = $post_ID; |
|
115 | 115 | // and add this shortcode to the tracking for the blog page |
116 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
116 | + PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID); |
|
117 | 117 | $update_post_shortcodes = true; |
118 | 118 | } else { |
119 | 119 | // shortcode is not present in post content, so check if we were tracking it previously |
120 | 120 | // stop tracking if shortcode is not used in this specific post |
121 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ) ) { |
|
122 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ); |
|
121 | + if (isset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode])) { |
|
122 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode]); |
|
123 | 123 | $update_post_shortcodes = true; |
124 | 124 | } |
125 | 125 | // make sure that something is set for the shortcode posts (even though we may remove this) |
126 | 126 | $shortcode_posts = isset( |
127 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
127 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] |
|
128 | 128 | ) |
129 | - ? \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
129 | + ? \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] |
|
130 | 130 | : array(); |
131 | 131 | // and stop tracking for this shortcode on the blog page if it is not used |
132 | 132 | $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | : $update_post_shortcodes; |
141 | 141 | } |
142 | 142 | } |
143 | - if ( $update_post_shortcodes ) { |
|
144 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
143 | + if ($update_post_shortcodes) { |
|
144 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
@@ -158,15 +158,15 @@ discard block |
||
158 | 158 | * @param string $page_for_posts |
159 | 159 | * @return void |
160 | 160 | */ |
161 | - protected static function set_post_shortcodes_for_posts_page( $page_for_posts ) { |
|
162 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
161 | + protected static function set_post_shortcodes_for_posts_page($page_for_posts) { |
|
162 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array(); |
|
163 | 163 | // loop thru shortcodes |
164 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
165 | - foreach ( $post_shortcodes as $EES_Shortcode => $post_ID ) { |
|
166 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
164 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
165 | + foreach ($post_shortcodes as $EES_Shortcode => $post_ID) { |
|
166 | + PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID); |
|
167 | 167 | } |
168 | 168 | } |
169 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
169 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
@@ -181,24 +181,24 @@ discard block |
||
181 | 181 | * @param $EES_Shortcode |
182 | 182 | * @param $post_ID |
183 | 183 | */ |
184 | - protected static function set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ) { |
|
184 | + protected static function set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID) { |
|
185 | 185 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
186 | 186 | $critical_shortcodes = \EE_Registry::CFG()->core->get_critical_pages_shortcodes_array(); |
187 | 187 | // if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE |
188 | - if ( in_array( $EES_Shortcode, $critical_shortcodes ) ) { |
|
188 | + if (in_array($EES_Shortcode, $critical_shortcodes)) { |
|
189 | 189 | return; |
190 | 190 | } |
191 | 191 | // add shortcode to "Posts page" tracking |
192 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
192 | + if (isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) { |
|
193 | 193 | // make sure tracking is in form of an array |
194 | - if ( ! is_array( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
195 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( |
|
196 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] => true |
|
194 | + if ( ! is_array(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) { |
|
195 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array( |
|
196 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] => true |
|
197 | 197 | ); |
198 | 198 | } |
199 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] += array( $post_ID => true ); |
|
199 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] += array($post_ID => true); |
|
200 | 200 | } else { |
201 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( $post_ID => true ); |
|
201 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array($post_ID => true); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
@@ -211,16 +211,16 @@ discard block |
||
211 | 211 | * @param int $ID |
212 | 212 | * @return void |
213 | 213 | */ |
214 | - public static function unset_post_shortcodes_on_delete( $ID ) { |
|
214 | + public static function unset_post_shortcodes_on_delete($ID) { |
|
215 | 215 | $update_post_shortcodes = false; |
216 | 216 | // post on frontpage ? |
217 | 217 | $page_for_posts = \EE_Config::get_page_for_posts(); |
218 | 218 | // looking for any references to this post |
219 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
219 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
220 | 220 | // is this the "Posts Page" (blog) ? |
221 | - if ( $post_name === $page_for_posts ) { |
|
221 | + if ($post_name === $page_for_posts) { |
|
222 | 222 | // loop thru shortcodes registered for the posts page |
223 | - foreach ( $post_shortcodes as $shortcode_class => $shortcode_posts ) { |
|
223 | + foreach ($post_shortcodes as $shortcode_class => $shortcode_posts) { |
|
224 | 224 | $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
225 | 225 | $ID, |
226 | 226 | $shortcode_class, |
@@ -233,17 +233,17 @@ discard block |
||
233 | 233 | } |
234 | 234 | } else { |
235 | 235 | // loop thru shortcodes registered for each page |
236 | - foreach ( $post_shortcodes as $shortcode_class => $post_ID ) { |
|
236 | + foreach ($post_shortcodes as $shortcode_class => $post_ID) { |
|
237 | 237 | // if this is page is being deleted, then don't track any post shortcodes for it |
238 | - if ( $post_ID === $ID ) { |
|
239 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post_name ] ); |
|
238 | + if ($post_ID === $ID) { |
|
239 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$post_name]); |
|
240 | 240 | $update_post_shortcodes = true; |
241 | 241 | } |
242 | 242 | } |
243 | 243 | } |
244 | 244 | } |
245 | - if ( $update_post_shortcodes ) { |
|
246 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
245 | + if ($update_post_shortcodes) { |
|
246 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
@@ -268,20 +268,20 @@ discard block |
||
268 | 268 | $update_post_shortcodes = false |
269 | 269 | ) { |
270 | 270 | // make sure that an array of post IDs is being tracked for each shortcode |
271 | - if ( ! is_array( $shortcode_posts ) ) { |
|
272 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] = array( |
|
271 | + if ( ! is_array($shortcode_posts)) { |
|
272 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class] = array( |
|
273 | 273 | $shortcode_posts => true |
274 | 274 | ); |
275 | 275 | $update_post_shortcodes = true; |
276 | 276 | } |
277 | 277 | // now if the ID of the post being deleted is in the $shortcode_posts array |
278 | - if ( is_array( $shortcode_posts ) && isset( $shortcode_posts[ $ID ] ) ) { |
|
279 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ][ $ID ] ); |
|
278 | + if (is_array($shortcode_posts) && isset($shortcode_posts[$ID])) { |
|
279 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class][$ID]); |
|
280 | 280 | $update_post_shortcodes = true; |
281 | 281 | } |
282 | 282 | // if nothing is registered for that shortcode anymore, then delete the shortcode altogether |
283 | - if ( empty( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) ) { |
|
284 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ); |
|
283 | + if (empty(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class])) { |
|
284 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class]); |
|
285 | 285 | $update_post_shortcodes = true; |
286 | 286 | } |
287 | 287 | return $update_post_shortcodes; |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | * @param $page_for_posts |
297 | 297 | * @return void |
298 | 298 | */ |
299 | - public static function update_post_shortcodes( $page_for_posts = '' ) { |
|
299 | + public static function update_post_shortcodes($page_for_posts = '') { |
|
300 | 300 | // make sure page_for_posts is set |
301 | - $page_for_posts = ! empty( $page_for_posts ) |
|
301 | + $page_for_posts = ! empty($page_for_posts) |
|
302 | 302 | ? $page_for_posts |
303 | 303 | : \EE_Config::get_page_for_posts(); |
304 | 304 | // allow others to mess stuff up :D |
@@ -314,45 +314,45 @@ discard block |
||
314 | 314 | $page_for_posts |
315 | 315 | ); |
316 | 316 | // verify that post_shortcodes is set |
317 | - \EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes ) |
|
318 | - && is_array( \EE_Config::instance()->core->post_shortcodes ) |
|
317 | + \EE_Config::instance()->core->post_shortcodes = isset(\EE_Config::instance()->core->post_shortcodes) |
|
318 | + && is_array(\EE_Config::instance()->core->post_shortcodes) |
|
319 | 319 | ? \EE_Config::instance()->core->post_shortcodes |
320 | 320 | : array(); |
321 | 321 | // cycle thru post_shortcodes |
322 | - foreach ( \EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes ) { |
|
322 | + foreach (\EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes) { |
|
323 | 323 | // are there any shortcodes to track ? |
324 | - if ( ! empty( $shortcodes ) ) { |
|
324 | + if ( ! empty($shortcodes)) { |
|
325 | 325 | // loop thru list of tracked shortcodes |
326 | - foreach ( $shortcodes as $shortcode => $post_id ) { |
|
326 | + foreach ($shortcodes as $shortcode => $post_id) { |
|
327 | 327 | // if shortcode is for a critical page, |
328 | 328 | // BUT this is NOT the corresponding critical page for that shortcode |
329 | - if ( $post_name === $page_for_posts ) { |
|
329 | + if ($post_name === $page_for_posts) { |
|
330 | 330 | continue; |
331 | 331 | } |
332 | 332 | // skip the posts page, because we want all shortcodes registered for it |
333 | - if ( $post_name === $page_for_posts ) { |
|
333 | + if ($post_name === $page_for_posts) { |
|
334 | 334 | continue; |
335 | 335 | } |
336 | 336 | // make sure post still exists |
337 | - $post = get_post( $post_id ); |
|
337 | + $post = get_post($post_id); |
|
338 | 338 | // check that the post name matches what we have saved |
339 | - if ( $post && $post->post_name === $post_name ) { |
|
339 | + if ($post && $post->post_name === $post_name) { |
|
340 | 340 | // if so, then break before hitting the unset below |
341 | 341 | continue; |
342 | 342 | } |
343 | 343 | // we don't like missing posts around here >:( |
344 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
344 | + unset(\EE_Config::instance()->core->post_shortcodes[$post_name]); |
|
345 | 345 | } |
346 | 346 | } else { |
347 | 347 | // you got no shortcodes to keep track of ! |
348 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
348 | + unset(\EE_Config::instance()->core->post_shortcodes[$post_name]); |
|
349 | 349 | } |
350 | 350 | } |
351 | 351 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
352 | 352 | $critical_shortcodes = \EE_Config::instance()->core->get_critical_pages_shortcodes_array(); |
353 | - $critical_shortcodes = array_flip( $critical_shortcodes ); |
|
354 | - foreach ( $critical_shortcodes as $critical_shortcode ) { |
|
355 | - unset( \EE_Config::instance()->core->post_shortcodes[ $page_for_posts ][ $critical_shortcode ] ); |
|
353 | + $critical_shortcodes = array_flip($critical_shortcodes); |
|
354 | + foreach ($critical_shortcodes as $critical_shortcode) { |
|
355 | + unset(\EE_Config::instance()->core->post_shortcodes[$page_for_posts][$critical_shortcode]); |
|
356 | 356 | } |
357 | 357 | //only show errors |
358 | 358 | \EE_Config::instance()->update_espresso_config(); |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | * @param string $value |
373 | 373 | * @return void |
374 | 374 | */ |
375 | - public static function reset_page_for_posts_on_initial_set( $option, $value ) { |
|
376 | - PostShortcodeTracking::reset_page_for_posts_on_change( $option, '', $value ); |
|
375 | + public static function reset_page_for_posts_on_initial_set($option, $value) { |
|
376 | + PostShortcodeTracking::reset_page_for_posts_on_change($option, '', $value); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -390,13 +390,13 @@ discard block |
||
390 | 390 | * @param string $value |
391 | 391 | * @return void |
392 | 392 | */ |
393 | - public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' ) { |
|
394 | - if ( $option === 'page_for_posts' ) { |
|
393 | + public static function reset_page_for_posts_on_change($option, $old_value = '', $value = '') { |
|
394 | + if ($option === 'page_for_posts') { |
|
395 | 395 | global $wpdb; |
396 | 396 | $table = $wpdb->posts; |
397 | 397 | $SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
398 | - $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts'; |
|
399 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts ); |
|
398 | + $new_page_for_posts = $value ? $wpdb->get_var($wpdb->prepare($SQL, $value)) : 'posts'; |
|
399 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page($new_page_for_posts); |
|
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | * @param string $option |
413 | 413 | * @return void |
414 | 414 | */ |
415 | - public static function reset_page_for_posts_on_delete( $option ) { |
|
416 | - if ( $option === 'page_for_posts' ) { |
|
417 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( 'posts' ); |
|
415 | + public static function reset_page_for_posts_on_delete($option) { |
|
416 | + if ($option === 'page_for_posts') { |
|
417 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page('posts'); |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | |
79 | 79 | |
80 | 80 | /** |
81 | - * @var EE_CPT_Base |
|
82 | - */ |
|
81 | + * @var EE_CPT_Base |
|
82 | + */ |
|
83 | 83 | protected $_cpt_model_obj = FALSE; |
84 | 84 | |
85 | 85 | |
@@ -866,10 +866,10 @@ discard block |
||
866 | 866 | |
867 | 867 | //if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit. |
868 | 868 | if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base |
869 | - || ( |
|
870 | - $update |
|
871 | - && $this->_cpt_model_obj->ID() !== $post_id |
|
872 | - ) |
|
869 | + || ( |
|
870 | + $update |
|
871 | + && $this->_cpt_model_obj->ID() !== $post_id |
|
872 | + ) |
|
873 | 873 | ) { |
874 | 874 | return; |
875 | 875 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param object $post The post object of the cpt that was saved. |
114 | 114 | * @return void |
115 | 115 | */ |
116 | - abstract protected function _insert_update_cpt_item( $post_id, $post ); |
|
116 | + abstract protected function _insert_update_cpt_item($post_id, $post); |
|
117 | 117 | |
118 | 118 | |
119 | 119 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string $post_id The ID of the cpt that was trashed |
127 | 127 | * @return void |
128 | 128 | */ |
129 | - abstract public function trash_cpt_item( $post_id ); |
|
129 | + abstract public function trash_cpt_item($post_id); |
|
130 | 130 | |
131 | 131 | |
132 | 132 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param string $post_id theID of the cpt that was untrashed |
138 | 138 | * @return void |
139 | 139 | */ |
140 | - abstract public function restore_cpt_item( $post_id ); |
|
140 | + abstract public function restore_cpt_item($post_id); |
|
141 | 141 | |
142 | 142 | |
143 | 143 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param string $post_id the ID of the cpt that was deleted |
149 | 149 | * @return void |
150 | 150 | */ |
151 | - abstract public function delete_cpt_item( $post_id ); |
|
151 | + abstract public function delete_cpt_item($post_id); |
|
152 | 152 | |
153 | 153 | |
154 | 154 | |
@@ -161,32 +161,32 @@ discard block |
||
161 | 161 | */ |
162 | 162 | protected function _before_page_setup() { |
163 | 163 | |
164 | - $page = isset( $this->_req_data['page'] ) ? $this->_req_data['page'] : $this->page_slug; |
|
164 | + $page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug; |
|
165 | 165 | |
166 | - $this->_cpt_routes = array_merge(array('create_new'=>$this->page_slug, 'edit' => $this->page_slug, 'trash' => $this->page_slug), $this->_cpt_routes ); |
|
166 | + $this->_cpt_routes = array_merge(array('create_new'=>$this->page_slug, 'edit' => $this->page_slug, 'trash' => $this->page_slug), $this->_cpt_routes); |
|
167 | 167 | |
168 | 168 | //let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page |
169 | - $this->_cpt_object = isset($this->_req_data['action']) && isset( $this->_cpt_routes[$this->_req_data['action']] ) ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']]) : get_post_type_object( $page ); |
|
169 | + $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[$this->_req_data['action']]) ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']]) : get_post_type_object($page); |
|
170 | 170 | |
171 | 171 | //tweak pagenow for page loading. |
172 | - if( ! $this->_pagenow_map ) { |
|
172 | + if ( ! $this->_pagenow_map) { |
|
173 | 173 | $this->_pagenow_map = array( |
174 | 174 | 'create_new' => 'post-new.php', |
175 | 175 | 'edit' => 'post.php', |
176 | 176 | 'trash' => 'post.php' |
177 | 177 | ); |
178 | 178 | } |
179 | - add_action( 'current_screen', array( $this, 'modify_pagenow') ); |
|
179 | + add_action('current_screen', array($this, 'modify_pagenow')); |
|
180 | 180 | |
181 | 181 | |
182 | 182 | //TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param. |
183 | 183 | //get current page from autosave |
184 | - $current_page = isset( $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] ) ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] : NULL; |
|
185 | - $this->_current_page = isset( $this->_req_data['current_page'] ) ? $this->_req_data['current_page'] : $current_page; |
|
184 | + $current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']) ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] : NULL; |
|
185 | + $this->_current_page = isset($this->_req_data['current_page']) ? $this->_req_data['current_page'] : $current_page; |
|
186 | 186 | |
187 | 187 | |
188 | 188 | //autosave... make sure its only for the correct page |
189 | - if ( !empty($this->_current_page ) && $this->_current_page == $this->page_slug ) { |
|
189 | + if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) { |
|
190 | 190 | //setup autosave ajax hook |
191 | 191 | //add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented |
192 | 192 | } |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return void |
204 | 204 | */ |
205 | - public function modify_pagenow( $current_screen ) { |
|
205 | + public function modify_pagenow($current_screen) { |
|
206 | 206 | global $pagenow; |
207 | 207 | //possibly reset pagenow. |
208 | - if ( ! empty( $this->_req_data['page'] ) && $this->_req_data['page'] == $this->page_slug && !empty( $this->_req_data['action'] ) && isset( $this->_pagenow_map[$this->_req_data['action'] ] ) ) { |
|
208 | + if ( ! empty($this->_req_data['page']) && $this->_req_data['page'] == $this->page_slug && ! empty($this->_req_data['action']) && isset($this->_pagenow_map[$this->_req_data['action']])) { |
|
209 | 209 | $pagenow = $this->_pagenow_map[$this->_req_data['action']]; |
210 | 210 | } |
211 | 211 | } |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | * @param array $ids an array of ids for containers that hold form inputs we want autosave to pickup. Typically you would send along the id of a metabox container. |
221 | 221 | * @return void |
222 | 222 | */ |
223 | - protected function _register_autosave_containers( $ids ) { |
|
224 | - $this->_autosave_containers = array_merge( $this->_autosave_fields, (array) $ids ); |
|
223 | + protected function _register_autosave_containers($ids) { |
|
224 | + $this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -236,22 +236,22 @@ discard block |
||
236 | 236 | |
237 | 237 | $containers = array(); |
238 | 238 | |
239 | - if ( empty( $wp_meta_boxes ) ) |
|
239 | + if (empty($wp_meta_boxes)) |
|
240 | 240 | return; |
241 | 241 | |
242 | - $current_metaboxes = isset( $wp_meta_boxes[$this->page_slug] ) ? $wp_meta_boxes[$this->page_slug] : array(); |
|
242 | + $current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array(); |
|
243 | 243 | |
244 | - foreach ( $current_metaboxes as $box_context ) { |
|
245 | - foreach ( $box_context as $box_details ) { |
|
246 | - foreach ( $box_details as $box ) { |
|
247 | - if ( is_array( $box['callback'] ) && ( $box['callback'][0] instanceof EE_Admin_Page || $box['callback'][0] instanceof EE_Admin_Hooks ) ){ |
|
244 | + foreach ($current_metaboxes as $box_context) { |
|
245 | + foreach ($box_context as $box_details) { |
|
246 | + foreach ($box_details as $box) { |
|
247 | + if (is_array($box['callback']) && ($box['callback'][0] instanceof EE_Admin_Page || $box['callback'][0] instanceof EE_Admin_Hooks)) { |
|
248 | 248 | $containers[] = $box['id']; |
249 | 249 | } |
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | - $this->_autosave_containers = array_merge( $this->_autosave_containers, $containers ); |
|
254 | + $this->_autosave_containers = array_merge($this->_autosave_containers, $containers); |
|
255 | 255 | |
256 | 256 | //add hidden inputs container |
257 | 257 | $this->_autosave_containers[] = 'ee-cpt-hidden-inputs'; |
@@ -268,13 +268,13 @@ discard block |
||
268 | 268 | wp_enqueue_script('cpt-autosave');/**/ //todo re-enable when we start doing autosave again in 4.2 |
269 | 269 | |
270 | 270 | //filter _autosave_containers |
271 | - $containers = apply_filters( 'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers', $this->_autosave_containers, $this ); |
|
272 | - $containers = apply_filters( 'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers', $containers, $this ); |
|
271 | + $containers = apply_filters('FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers', $this->_autosave_containers, $this); |
|
272 | + $containers = apply_filters('FHEE__EE_Admin_Page_CPT__'.get_class($this).'___load_autosave_scripts_styles__containers', $containers, $this); |
|
273 | 273 | |
274 | - wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS', $containers ); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave" |
|
274 | + wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS', $containers); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave" |
|
275 | 275 | |
276 | 276 | $unsaved_data_msg = array( |
277 | - 'eventmsg' => sprintf( __("The changes you made to this %s will be lost if you navigate away from this page.", 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
277 | + 'eventmsg' => sprintf(__("The changes you made to this %s will be lost if you navigate away from this page.", 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
278 | 278 | 'inputChanged' => 0 |
279 | 279 | ); |
280 | 280 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | public function load_page_dependencies() { |
287 | 287 | try { |
288 | 288 | $this->_load_page_dependencies(); |
289 | - } catch ( EE_Error $e ) { |
|
289 | + } catch (EE_Error $e) { |
|
290 | 290 | $e->get_error(); |
291 | 291 | } |
292 | 292 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | protected function _load_page_dependencies() { |
303 | 303 | |
304 | 304 | //we only add stuff if this is a cpt_route! |
305 | - if ( !$this->_cpt_route ) { |
|
305 | + if ( ! $this->_cpt_route) { |
|
306 | 306 | parent::_load_page_dependencies(); |
307 | 307 | return; |
308 | 308 | } |
@@ -312,72 +312,72 @@ discard block |
||
312 | 312 | |
313 | 313 | //the following filters are for setting all the redirects on DEFAULT WP custom post type actions |
314 | 314 | //let's add a hidden input to the post-edit form so we know when we have to trigger our custom redirects! Otherwise the redirects will happen on ALL post saves which wouldn't be good of course! |
315 | - add_action('edit_form_after_title', array( $this, 'cpt_post_form_hidden_input') ); |
|
315 | + add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input')); |
|
316 | 316 | |
317 | 317 | //inject our Admin page nav tabs... |
318 | 318 | //let's make sure the nav tabs are set if they aren't already |
319 | 319 | //if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs(); |
320 | - add_action('post_edit_form_tag', array( $this, 'inject_nav_tabs' ) ); |
|
320 | + add_action('post_edit_form_tag', array($this, 'inject_nav_tabs')); |
|
321 | 321 | |
322 | 322 | //modify the post_updated messages array |
323 | - add_action('post_updated_messages', array( $this, 'post_update_messages' ), 10 ); |
|
323 | + add_action('post_updated_messages', array($this, 'post_update_messages'), 10); |
|
324 | 324 | |
325 | 325 | //add shortlink button to cpt edit screens. We can do this as a universal thing BECAUSE, cpts use the same format for shortlinks as posts! |
326 | - add_filter( 'pre_get_shortlink', array( $this, 'add_shortlink_button_to_editor' ), 10, 4 ); |
|
326 | + add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4); |
|
327 | 327 | |
328 | 328 | //This basically allows us to change the title of the "publish" metabox area on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class. |
329 | - if ( !empty($this->_labels['publishbox'] ) ) { |
|
329 | + if ( ! empty($this->_labels['publishbox'])) { |
|
330 | 330 | |
331 | - $box_label = is_array( $this->_labels['publishbox'] ) && isset( $this->_labels['publishbox'][$this->_req_action]) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
331 | + $box_label = is_array($this->_labels['publishbox']) && isset($this->_labels['publishbox'][$this->_req_action]) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
332 | 332 | |
333 | - remove_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
|
334 | - add_meta_box( 'submitdiv', $box_label, 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
|
333 | + remove_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
334 | + add_meta_box('submitdiv', $box_label, 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | //let's add page_templates metabox if this cpt added support for it. |
338 | - if ( $this->_supports_page_templates($this->_cpt_object->name) ) { |
|
339 | - add_meta_box( 'page_templates', __('Page Template', 'event_espresso' ), array( $this, 'page_template_meta_box' ), $this->_cpt_routes[$this->_req_action], 'side', 'default' ); |
|
338 | + if ($this->_supports_page_templates($this->_cpt_object->name)) { |
|
339 | + add_meta_box('page_templates', __('Page Template', 'event_espresso'), array($this, 'page_template_meta_box'), $this->_cpt_routes[$this->_req_action], 'side', 'default'); |
|
340 | 340 | }/**/ |
341 | 341 | |
342 | 342 | |
343 | 343 | //this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form |
344 | - if ( method_exists( $this, 'extra_permalink_field_buttons' ) ) |
|
345 | - add_filter('get_sample_permalink_html', array( $this, 'extra_permalink_field_buttons' ), 10, 4 ); |
|
344 | + if (method_exists($this, 'extra_permalink_field_buttons')) |
|
345 | + add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4); |
|
346 | 346 | |
347 | 347 | //add preview button |
348 | - add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4 ); |
|
348 | + add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4); |
|
349 | 349 | |
350 | 350 | |
351 | 351 | //insert our own post_stati dropdown |
352 | - add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown' ), 10 ); |
|
352 | + add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10); |
|
353 | 353 | |
354 | 354 | //This allows adding additional information to the publish post submitbox on the wp post edit form |
355 | - if ( method_exists( $this, 'extra_misc_actions_publish_box' ) ) |
|
356 | - add_action('post_submitbox_misc_actions', array( $this, 'extra_misc_actions_publish_box' ), 10 ); |
|
355 | + if (method_exists($this, 'extra_misc_actions_publish_box')) |
|
356 | + add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10); |
|
357 | 357 | |
358 | 358 | //This allows for adding additional stuff after the title field on the wp post edit form. This is also before the wp_editor for post description field. |
359 | - if ( method_exists( $this, 'edit_form_after_title' ) ) |
|
360 | - add_action('edit_form_after_title', array( $this, 'edit_form_after_title' ), 10 ); |
|
359 | + if (method_exists($this, 'edit_form_after_title')) |
|
360 | + add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10); |
|
361 | 361 | |
362 | 362 | |
363 | 363 | /** |
364 | 364 | * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route. |
365 | 365 | */ |
366 | - add_filter( 'clean_url', array( $this, 'switch_core_wp_urls_with_ours' ), 10, 3 ); |
|
366 | + add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3); |
|
367 | 367 | |
368 | 368 | |
369 | 369 | parent::_load_page_dependencies(); |
370 | 370 | |
371 | 371 | //notice we are ALSO going to load the pagenow hook set for this route (see _before_page_setup for the reset of the pagenow global ). This is for any plugins that are doing things properly and hooking into the load page hook for core wp cpt routes. |
372 | 372 | global $pagenow; |
373 | - do_action( 'load-' . $pagenow ); |
|
373 | + do_action('load-'.$pagenow); |
|
374 | 374 | |
375 | 375 | $this->modify_current_screen(); |
376 | - add_action( 'admin_enqueue_scripts', array( $this, 'setup_autosave_hooks'), 30 ); |
|
376 | + add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30); |
|
377 | 377 | //we route REALLY early. |
378 | 378 | try { |
379 | 379 | $this->_route_admin_request(); |
380 | - } catch ( EE_Error $e ) { |
|
380 | + } catch (EE_Error $e) { |
|
381 | 381 | $e->get_error(); |
382 | 382 | } |
383 | 383 | } |
@@ -396,21 +396,21 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @return string possibly a new url for our route. |
398 | 398 | */ |
399 | - public function switch_core_wp_urls_with_ours( $good_protocol_url, $original_url, $_context ) { |
|
399 | + public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context) { |
|
400 | 400 | $routes_to_match = array( |
401 | 401 | 0 => array( |
402 | 402 | 'edit.php?post_type=espresso_attendees', |
403 | 403 | 'admin.php?page=espresso_registrations&action=contact_list' |
404 | 404 | ), |
405 | 405 | 1 => array( |
406 | - 'edit.php?post_type=' . $this->_cpt_object->name, |
|
407 | - 'admin.php?page=' . $this->_cpt_object->name |
|
406 | + 'edit.php?post_type='.$this->_cpt_object->name, |
|
407 | + 'admin.php?page='.$this->_cpt_object->name |
|
408 | 408 | ) |
409 | 409 | ); |
410 | 410 | |
411 | - foreach( $routes_to_match as $route_matches ) { |
|
412 | - if ( strpos( $good_protocol_url, $route_matches[0] ) !== false ) { |
|
413 | - return str_replace( $route_matches[0], $route_matches[1], $good_protocol_url ); |
|
411 | + foreach ($routes_to_match as $route_matches) { |
|
412 | + if (strpos($good_protocol_url, $route_matches[0]) !== false) { |
|
413 | + return str_replace($route_matches[0], $route_matches[1], $good_protocol_url); |
|
414 | 414 | |
415 | 415 | } |
416 | 416 | } |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | * @param string $cpt_name The cpt slug we're checking on. |
427 | 427 | * @return bool True supported, false not. |
428 | 428 | */ |
429 | - private function _supports_page_templates( $cpt_name ) { |
|
429 | + private function _supports_page_templates($cpt_name) { |
|
430 | 430 | $cpt_args = EE_Register_CPTs::get_CPTs(); |
431 | - $cpt_args = isset( $cpt_args[$cpt_name] ) ? $cpt_args[$cpt_name]['args'] : array(); |
|
432 | - return ! empty( $cpt_args['page_templates'] ) ? TRUE : FALSE; |
|
431 | + $cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array(); |
|
432 | + return ! empty($cpt_args['page_templates']) ? TRUE : FALSE; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -444,9 +444,9 @@ discard block |
||
444 | 444 | public function page_template_meta_box() { |
445 | 445 | global $post; |
446 | 446 | $template = ''; |
447 | - if ( count( get_page_templates( $post ) ) != 0 ) { |
|
448 | - $page_template = get_post_meta( $post->ID, '_wp_page_template', TRUE ); |
|
449 | - $template = !empty( $page_template ) ? $page_template : ''; |
|
447 | + if (count(get_page_templates($post)) != 0) { |
|
448 | + $page_template = get_post_meta($post->ID, '_wp_page_template', TRUE); |
|
449 | + $template = ! empty($page_template) ? $page_template : ''; |
|
450 | 450 | } |
451 | 451 | ?> |
452 | 452 | <p><strong><?php _e('Template') ?></strong></p> |
@@ -470,10 +470,10 @@ discard block |
||
470 | 470 | * @param string $new_slug what the slug is |
471 | 471 | * @return string The new html string for the permalink area |
472 | 472 | */ |
473 | - public function preview_button_html( $return, $id, $new_title, $new_slug ) { |
|
474 | - $post = get_post( $id ); |
|
475 | - if ( 'publish' != get_post_status( $post ) ) { |
|
476 | - $return .= '<span_id="view-post-btn"><a href="' . wp_get_shortlink($id, 'post') . '" class="button button-small">' . __('Preview', 'event_espresso') . '</a></span>' . "\n"; |
|
473 | + public function preview_button_html($return, $id, $new_title, $new_slug) { |
|
474 | + $post = get_post($id); |
|
475 | + if ('publish' != get_post_status($post)) { |
|
476 | + $return .= '<span_id="view-post-btn"><a href="'.wp_get_shortlink($id, 'post').'" class="button button-small">'.__('Preview', 'event_espresso').'</a></span>'."\n"; |
|
477 | 477 | } |
478 | 478 | return $return; |
479 | 479 | } |
@@ -493,18 +493,18 @@ discard block |
||
493 | 493 | 'cur_status' => $this->_cpt_model_obj->status(), |
494 | 494 | 'statuses' => $statuses, |
495 | 495 | 'cur_status_label' => $cur_status_label, |
496 | - 'localized_status_save' => sprintf( __('Save %s', 'event_espresso'), $cur_status_label ) |
|
496 | + 'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label) |
|
497 | 497 | ); |
498 | 498 | |
499 | 499 | //we'll add a trash post status (WP doesn't add one for some reason) |
500 | - if ( $this->_cpt_model_obj->status() == 'trash' ) { |
|
500 | + if ($this->_cpt_model_obj->status() == 'trash') { |
|
501 | 501 | $template_args['cur_status_label'] = __('Trashed', 'event_espresso'); |
502 | 502 | $statuses['trash'] = __('Trashed', 'event_espresso'); |
503 | 503 | $template_args['statuses'] = $statuses; |
504 | 504 | } |
505 | 505 | |
506 | - $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php'; |
|
507 | - EEH_Template::display_template( $template, $template_args ); |
|
506 | + $template = EE_ADMIN_TEMPLATE.'status_dropdown.template.php'; |
|
507 | + EEH_Template::display_template($template, $template_args); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | |
@@ -543,22 +543,22 @@ discard block |
||
543 | 543 | public function do_extra_autosave_stuff() { |
544 | 544 | |
545 | 545 | //next let's check for the autosave nonce (we'll use _verify_nonce ) |
546 | - $nonce = isset( $this->_req_data['autosavenonce'] ) ? $this->_req_data['autosavenonce'] : NULL; |
|
547 | - $this->_verify_nonce( $nonce, 'autosave' ); |
|
546 | + $nonce = isset($this->_req_data['autosavenonce']) ? $this->_req_data['autosavenonce'] : NULL; |
|
547 | + $this->_verify_nonce($nonce, 'autosave'); |
|
548 | 548 | |
549 | 549 | |
550 | 550 | //make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it) |
551 | - if ( !defined('DOING_AUTOSAVE') ) define('DOING_AUTOSAVE', true); |
|
551 | + if ( ! defined('DOING_AUTOSAVE')) define('DOING_AUTOSAVE', true); |
|
552 | 552 | |
553 | 553 | //if we made it here then the nonce checked out. Let's run our methods and actions |
554 | - if ( method_exists( $this, '_ee_autosave_' . $this->_current_view ) ) { |
|
555 | - call_user_func( array( $this, '_ee_autosave_' . $this->_current_view ) ); |
|
554 | + if (method_exists($this, '_ee_autosave_'.$this->_current_view)) { |
|
555 | + call_user_func(array($this, '_ee_autosave_'.$this->_current_view)); |
|
556 | 556 | } else { |
557 | 557 | $this->_template_args['success'] = TRUE; |
558 | 558 | } |
559 | 559 | |
560 | - do_action( 'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this ); |
|
561 | - do_action( 'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class( $this ), $this ); |
|
560 | + do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this); |
|
561 | + do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_'.get_class($this), $this); |
|
562 | 562 | |
563 | 563 | //now let's return json |
564 | 564 | $this->_return_json(); |
@@ -578,18 +578,18 @@ discard block |
||
578 | 578 | protected function _extend_page_config_for_cpt() { |
579 | 579 | |
580 | 580 | //before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug |
581 | - if ( ( isset( $this->_req_data['page'] ) && $this->_req_data['page'] != $this->page_slug ) ) |
|
581 | + if ((isset($this->_req_data['page']) && $this->_req_data['page'] != $this->page_slug)) |
|
582 | 582 | return; |
583 | 583 | |
584 | 584 | //set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes |
585 | - if ( !empty( $this->_cpt_object ) ) { |
|
586 | - $this->_page_routes = array_merge( array( |
|
585 | + if ( ! empty($this->_cpt_object)) { |
|
586 | + $this->_page_routes = array_merge(array( |
|
587 | 587 | 'create_new' => '_create_new_cpt_item', |
588 | 588 | 'edit' => '_edit_cpt_item' |
589 | - ), $this->_page_routes ); |
|
589 | + ), $this->_page_routes); |
|
590 | 590 | |
591 | 591 | |
592 | - $this->_page_config = array_merge( array( |
|
592 | + $this->_page_config = array_merge(array( |
|
593 | 593 | 'create_new' => array( |
594 | 594 | 'nav' => array( |
595 | 595 | 'label' => $this->_cpt_object->labels->add_new_item, |
@@ -611,23 +611,23 @@ discard block |
||
611 | 611 | } |
612 | 612 | |
613 | 613 | //load the next section only if this is a matching cpt route as set in the cpt routes array. |
614 | - if ( !isset( $this->_cpt_routes[$this->_req_action] ) ) |
|
614 | + if ( ! isset($this->_cpt_routes[$this->_req_action])) |
|
615 | 615 | return; |
616 | 616 | |
617 | 617 | |
618 | - $this->_cpt_route = isset( $this->_cpt_routes[$this->_req_action] ) ? TRUE : FALSE; |
|
618 | + $this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? TRUE : FALSE; |
|
619 | 619 | //add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') ); |
620 | 620 | |
621 | 621 | |
622 | - if ( empty( $this->_cpt_object ) ) { |
|
623 | - $msg = sprintf( __('This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this: 1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).'), $this->page_slug, $this->_req_action, get_class($this) ); |
|
624 | - throw new EE_Error( $msg ); |
|
622 | + if (empty($this->_cpt_object)) { |
|
623 | + $msg = sprintf(__('This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this: 1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).'), $this->page_slug, $this->_req_action, get_class($this)); |
|
624 | + throw new EE_Error($msg); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | |
628 | - if ( $this->_cpt_route ) { |
|
629 | - $id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
|
630 | - $this->_set_model_object( $id ); |
|
628 | + if ($this->_cpt_route) { |
|
629 | + $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
630 | + $this->_set_model_object($id); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | } |
@@ -643,17 +643,17 @@ discard block |
||
643 | 643 | * @param int $id The id to retrieve the model object for. If empty we set a default object. |
644 | 644 | * @return void |
645 | 645 | */ |
646 | - protected function _set_model_object( $id = NULL ) { |
|
646 | + protected function _set_model_object($id = NULL) { |
|
647 | 647 | |
648 | - if ( empty( $this->_cpt_model_names ) || ! isset( $this->_cpt_routes[ $this->_req_action ] ) || ( is_object( $this->_cpt_model_obj ) && $this->_cpt_model_obj->ID() == $id )) { |
|
648 | + if (empty($this->_cpt_model_names) || ! isset($this->_cpt_routes[$this->_req_action]) || (is_object($this->_cpt_model_obj) && $this->_cpt_model_obj->ID() == $id)) { |
|
649 | 649 | //get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent. |
650 | 650 | return; |
651 | 651 | } |
652 | 652 | // load CPT object model |
653 | - $model = EE_Registry::instance()->load_model( $this->_cpt_model_names[$this->_req_action] ); |
|
654 | - $this->_cpt_model_obj = ! empty( $id ) ? $model->get_one_by_ID( $id ) : $model->create_default_object(); |
|
653 | + $model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]); |
|
654 | + $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object(); |
|
655 | 655 | //d( $this->_cpt_model_obj ); |
656 | - do_action( 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object' ); |
|
656 | + do_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object'); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | |
@@ -667,47 +667,47 @@ discard block |
||
667 | 667 | */ |
668 | 668 | public function admin_init_global() { |
669 | 669 | |
670 | - $post = isset( $this->_req_data['post'] ) ? get_post( $this->_req_data['post'] ) : NULL; |
|
670 | + $post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : NULL; |
|
671 | 671 | |
672 | 672 | //its possible this is a new save so let's catch that instead |
673 | - $post = isset( $this->_req_data['post_ID'] ) ? get_post( $this->_req_data['post_ID'] ) : $post; |
|
673 | + $post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post; |
|
674 | 674 | $post_type = $post ? $post->post_type : false; |
675 | 675 | |
676 | 676 | $current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork'; |
677 | 677 | |
678 | - $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : ''; |
|
678 | + $route_to_check = $post_type && isset($this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : ''; |
|
679 | 679 | |
680 | - add_filter( 'get_delete_post_link', array( $this, 'modify_delete_post_link'), 10, 3 ); |
|
681 | - add_filter( 'get_edit_post_link', array( $this, 'modify_edit_post_link'), 10, 3 ); |
|
680 | + add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3); |
|
681 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3); |
|
682 | 682 | |
683 | 683 | |
684 | - if ( $post_type === $route_to_check ) { |
|
685 | - add_filter('redirect_post_location', array( $this, 'cpt_post_location_redirect'), 10, 2 ); |
|
684 | + if ($post_type === $route_to_check) { |
|
685 | + add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2); |
|
686 | 686 | //catch trashed wp redirect |
687 | - add_filter('wp_redirect', array( $this, 'cpt_trash_post_location_redirect' ), 10, 2 ); |
|
687 | + add_filter('wp_redirect', array($this, 'cpt_trash_post_location_redirect'), 10, 2); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | //now let's filter redirect if we're on a revision page and the revision is for an event CPT. |
691 | - $revision = isset( $this->_req_data['revision'] ) ? $this->_req_data['revision'] : NULL; |
|
691 | + $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : NULL; |
|
692 | 692 | |
693 | 693 | /**var_dump($this->_req_data); |
694 | 694 | exit();/**/ |
695 | 695 | |
696 | - if ( !empty( $revision ) ) { |
|
697 | - $action = isset( $this->_req_data['action'] ) ? $this->_req_data['action'] : NULL; |
|
696 | + if ( ! empty($revision)) { |
|
697 | + $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : NULL; |
|
698 | 698 | |
699 | 699 | //doing a restore? |
700 | - if ( !empty( $action ) && $action == 'restore' ) { |
|
700 | + if ( ! empty($action) && $action == 'restore') { |
|
701 | 701 | |
702 | 702 | //get post for revision |
703 | - $rev_post = get_post( $revision ); |
|
704 | - $rev_parent = get_post( $rev_post->post_parent ); |
|
703 | + $rev_post = get_post($revision); |
|
704 | + $rev_parent = get_post($rev_post->post_parent); |
|
705 | 705 | |
706 | 706 | //only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts. |
707 | - if ( $rev_parent && $rev_parent->post_type == $this->page_slug ) { |
|
708 | - add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2 ); |
|
707 | + if ($rev_parent && $rev_parent->post_type == $this->page_slug) { |
|
708 | + add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2); |
|
709 | 709 | //restores of revisions |
710 | - add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2 ); |
|
710 | + add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2); |
|
711 | 711 | } |
712 | 712 | } |
713 | 713 | |
@@ -716,15 +716,15 @@ discard block |
||
716 | 716 | //NOTE we ONLY want to run these hooks if we're on the right class for the given post type. Otherwise we could see some really freaky things happen! |
717 | 717 | |
718 | 718 | |
719 | - if ( $post_type && $post_type === $route_to_check ) { |
|
719 | + if ($post_type && $post_type === $route_to_check) { |
|
720 | 720 | //$post_id, $post |
721 | - add_action('save_post', array( $this, 'insert_update'), 10, 3 ); |
|
721 | + add_action('save_post', array($this, 'insert_update'), 10, 3); |
|
722 | 722 | |
723 | 723 | //$post_id |
724 | - add_action('trashed_post', array( $this, 'before_trash_cpt_item' ), 10 ); |
|
725 | - add_action('trashed_post', array( $this, 'dont_permanently_delete_ee_cpts'), 10 ); |
|
726 | - add_action('untrashed_post', array( $this, 'before_restore_cpt_item'), 10 ); |
|
727 | - add_action('after_delete_post', array( $this, 'before_delete_cpt_item'), 10 ); |
|
724 | + add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10); |
|
725 | + add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10); |
|
726 | + add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10); |
|
727 | + add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | } |
@@ -738,12 +738,12 @@ discard block |
||
738 | 738 | * |
739 | 739 | * @param int $post_id |
740 | 740 | */ |
741 | - public function before_trash_cpt_item( $post_id ) { |
|
741 | + public function before_trash_cpt_item($post_id) { |
|
742 | 742 | //if our cpt object isn't existent then get out immediately. |
743 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id ) { |
|
743 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
|
744 | 744 | return; |
745 | 745 | } |
746 | - $this->trash_cpt_item( $post_id ); |
|
746 | + $this->trash_cpt_item($post_id); |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | |
@@ -753,12 +753,12 @@ discard block |
||
753 | 753 | * |
754 | 754 | * @param $post_id |
755 | 755 | */ |
756 | - public function before_restore_cpt_item( $post_id ) { |
|
756 | + public function before_restore_cpt_item($post_id) { |
|
757 | 757 | //if our cpt object isn't existent then get out immediately. |
758 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id ) { |
|
758 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
|
759 | 759 | return; |
760 | 760 | } |
761 | - $this->restore_cpt_item( $post_id ); |
|
761 | + $this->restore_cpt_item($post_id); |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | |
@@ -767,12 +767,12 @@ discard block |
||
767 | 767 | * Execute some basic checks before calling the delete_cpt_item method in the child class. |
768 | 768 | * @param $post_id |
769 | 769 | */ |
770 | - public function before_delete_cpt_item( $post_id ) { |
|
770 | + public function before_delete_cpt_item($post_id) { |
|
771 | 771 | //if our cpt object isn't existent then get out immediately. |
772 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id ) { |
|
772 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
|
773 | 773 | return; |
774 | 774 | } |
775 | - $this->delete_cpt_item( $post_id ); |
|
775 | + $this->delete_cpt_item($post_id); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | |
@@ -784,15 +784,15 @@ discard block |
||
784 | 784 | * @return void |
785 | 785 | */ |
786 | 786 | public function verify_cpt_object() { |
787 | - $label = !empty( $this->_cpt_object ) ? $this->_cpt_object->labels->singular_name : $this->page_label; |
|
787 | + $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label; |
|
788 | 788 | // verify event object |
789 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base ) { |
|
790 | - throw new EE_Error( sprintf( __('Something has gone wrong with the page load because we are unable to set up the object for the %1$s. This usually happens when the given id for the page route is NOT for the correct custom post type for this page', 'event_espresso' ), $label ) ); |
|
789 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
790 | + throw new EE_Error(sprintf(__('Something has gone wrong with the page load because we are unable to set up the object for the %1$s. This usually happens when the given id for the page route is NOT for the correct custom post type for this page', 'event_espresso'), $label)); |
|
791 | 791 | } |
792 | 792 | //if auto-draft then throw an error |
793 | - if ( $this->_cpt_model_obj->get('status') == 'auto-draft' ) { |
|
793 | + if ($this->_cpt_model_obj->get('status') == 'auto-draft') { |
|
794 | 794 | EE_Error::overwrite_errors(); |
795 | - EE_Error::add_error( sprintf( __('This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly. All autodrafts will show up in the "draft" view of your event list table. You can delete them from there. Please click the "Add %1$s" button to refresh and restart.'), $label ), __FILE__, __FUNCTION__, __LINE__ ); |
|
795 | + EE_Error::add_error(sprintf(__('This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly. All autodrafts will show up in the "draft" view of your event list table. You can delete them from there. Please click the "Add %1$s" button to refresh and restart.'), $label), __FILE__, __FUNCTION__, __LINE__); |
|
796 | 796 | } |
797 | 797 | } |
798 | 798 | |
@@ -821,22 +821,22 @@ discard block |
||
821 | 821 | public function load_global_scripts_styles() { |
822 | 822 | parent::load_global_scripts_styles(); |
823 | 823 | |
824 | - if ( $this->_cpt_model_obj instanceof EE_CPT_Base ) { |
|
824 | + if ($this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
825 | 825 | //setup custom post status object for localize script but only if we've got a cpt object |
826 | 826 | $statuses = $this->_cpt_model_obj->get_custom_post_statuses(); |
827 | 827 | |
828 | - if ( !empty($statuses) ) { |
|
828 | + if ( ! empty($statuses)) { |
|
829 | 829 | //get ALL statuses! |
830 | 830 | $statuses = $this->_cpt_model_obj->get_all_post_statuses(); |
831 | 831 | //setup object |
832 | 832 | $ee_cpt_statuses = array(); |
833 | - foreach ( $statuses as $status => $label ) { |
|
833 | + foreach ($statuses as $status => $label) { |
|
834 | 834 | $ee_cpt_statuses[$status] = array( |
835 | 835 | 'label' => $label, |
836 | - 'save_label' => sprintf( __('Save as %s', 'event_espresso'), $label ) |
|
836 | + 'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label) |
|
837 | 837 | ); |
838 | 838 | } |
839 | - wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses ); |
|
839 | + wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses); |
|
840 | 840 | } |
841 | 841 | } |
842 | 842 | } |
@@ -851,11 +851,11 @@ discard block |
||
851 | 851 | * @param bool $update Whether this is an update or a new save. |
852 | 852 | * @return void |
853 | 853 | */ |
854 | - public function insert_update( $post_id, $post, $update ) { |
|
854 | + public function insert_update($post_id, $post, $update) { |
|
855 | 855 | |
856 | 856 | //make sure that if this is a revision OR trash action that we don't do any updates! |
857 | 857 | if ( |
858 | - isset( $this->_req_data['action'] ) |
|
858 | + isset($this->_req_data['action']) |
|
859 | 859 | && ( |
860 | 860 | $this->_req_data['action'] == 'restore' |
861 | 861 | || $this->_req_data['action'] == 'trash' |
@@ -886,19 +886,19 @@ discard block |
||
886 | 886 | }/**/ //TODO reactivate after autosave is implemented in 4.2 |
887 | 887 | |
888 | 888 | //take care of updating any selected page_template IF this cpt supports it. |
889 | - if ( $this->_supports_page_templates($post->post_type ) && !empty( $this->_req_data['page_template'] ) ) { |
|
889 | + if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) { |
|
890 | 890 | $post->page_template = $this->_req_data['page_template']; |
891 | - $page_templates = wp_get_theme()->get_page_templates( $post ); |
|
892 | - if ( 'default' != $this->_req_data['page_template'] && ! isset( $page_templates[ $this->_req_data['page_template'] ] ) ) { |
|
893 | - EE_Error::add_error( __('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
891 | + $page_templates = wp_get_theme()->get_page_templates($post); |
|
892 | + if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) { |
|
893 | + EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
894 | 894 | } else { |
895 | - update_post_meta( $post_id, '_wp_page_template', $this->_req_data['page_template'] ); |
|
895 | + update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']); |
|
896 | 896 | } |
897 | 897 | } |
898 | 898 | |
899 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) |
|
899 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) |
|
900 | 900 | return; //TODO we'll remove this after reimplementing autosave in 4.2 |
901 | - $this->_insert_update_cpt_item( $post_id, $post ); |
|
901 | + $this->_insert_update_cpt_item($post_id, $post); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | |
@@ -911,15 +911,15 @@ discard block |
||
911 | 911 | * @param int $post_id ID of the post |
912 | 912 | * @return void |
913 | 913 | */ |
914 | - public function dont_permanently_delete_ee_cpts( $post_id ) { |
|
914 | + public function dont_permanently_delete_ee_cpts($post_id) { |
|
915 | 915 | //only do this if we're actually processing one of our CPTs |
916 | 916 | //if our cpt object isn't existent then get out immediately. |
917 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base ) { |
|
917 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
918 | 918 | return; |
919 | 919 | } |
920 | 920 | |
921 | - delete_post_meta( $post_id, '_wp_trash_meta_status' ); |
|
922 | - delete_post_meta( $post_id, '_wp_trash_meta_time'); |
|
921 | + delete_post_meta($post_id, '_wp_trash_meta_status'); |
|
922 | + delete_post_meta($post_id, '_wp_trash_meta_time'); |
|
923 | 923 | |
924 | 924 | //our cpts may have comments so let's take care of that too |
925 | 925 | delete_post_meta($post_id, '_wp_trash_meta_comments_status'); |
@@ -937,14 +937,14 @@ discard block |
||
937 | 937 | * @param int $revision_id ID of revision being restored |
938 | 938 | * @return void |
939 | 939 | */ |
940 | - public function restore_revision( $post_id, $revision_id ) { |
|
941 | - $this->_restore_cpt_item( $post_id, $revision_id ); |
|
940 | + public function restore_revision($post_id, $revision_id) { |
|
941 | + $this->_restore_cpt_item($post_id, $revision_id); |
|
942 | 942 | |
943 | 943 | //global action |
944 | - do_action( 'AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id); |
|
944 | + do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id); |
|
945 | 945 | |
946 | 946 | //class specific action so you can limit hooking into a specific page. |
947 | - do_action( 'AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id ); |
|
947 | + do_action('AHEE_EE_Admin_Page_CPT_'.get_class($this).'__restore_revision', $post_id, $revision_id); |
|
948 | 948 | } |
949 | 949 | |
950 | 950 | |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | * @param int $revision_id ID of revision for item |
956 | 956 | * @return void |
957 | 957 | */ |
958 | - abstract protected function _restore_cpt_item( $post_id, $revision_id ); |
|
958 | + abstract protected function _restore_cpt_item($post_id, $revision_id); |
|
959 | 959 | |
960 | 960 | |
961 | 961 | |
@@ -974,9 +974,9 @@ discard block |
||
974 | 974 | */ |
975 | 975 | public function modify_current_screen() { |
976 | 976 | //ONLY do this if the current page_route IS a cpt route |
977 | - if ( !$this->_cpt_route ) return; |
|
977 | + if ( ! $this->_cpt_route) return; |
|
978 | 978 | //routing things REALLY early b/c this is a cpt admin page |
979 | - set_current_screen( $this->_cpt_routes[$this->_req_action]); |
|
979 | + set_current_screen($this->_cpt_routes[$this->_req_action]); |
|
980 | 980 | $this->_current_screen = get_current_screen(); |
981 | 981 | $this->_current_screen->base = 'event-espresso'; |
982 | 982 | $this->_add_help_tabs(); //we make sure we add any help tabs back in! |
@@ -997,8 +997,8 @@ discard block |
||
997 | 997 | * @param string $title The new title (or existing if there is no editor_title defined) |
998 | 998 | * @return string |
999 | 999 | */ |
1000 | - public function add_custom_editor_default_title( $title ) { |
|
1001 | - return isset( $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] ) ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] : $title; |
|
1000 | + public function add_custom_editor_default_title($title) { |
|
1001 | + return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]) ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] : $title; |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | |
@@ -1011,11 +1011,11 @@ discard block |
||
1011 | 1011 | * @param bool $allow_slugs Whether to allow post slugs in the shortlink. |
1012 | 1012 | * @return string |
1013 | 1013 | */ |
1014 | - public function add_shortlink_button_to_editor( $shortlink, $id, $context, $allow_slugs ) { |
|
1015 | - if ( !empty( $id ) && '' != get_option('permalink_structure') ) { |
|
1016 | - $post = get_post( $id ); |
|
1017 | - if ( isset($post->post_type) && $this->page_slug == $post->post_type ) |
|
1018 | - $shortlink = home_url('?p=' . $post->ID); |
|
1014 | + public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs) { |
|
1015 | + if ( ! empty($id) && '' != get_option('permalink_structure')) { |
|
1016 | + $post = get_post($id); |
|
1017 | + if (isset($post->post_type) && $this->page_slug == $post->post_type) |
|
1018 | + $shortlink = home_url('?p='.$post->ID); |
|
1019 | 1019 | } |
1020 | 1020 | return $shortlink; |
1021 | 1021 | } |
@@ -1028,10 +1028,10 @@ discard block |
||
1028 | 1028 | * @return void |
1029 | 1029 | */ |
1030 | 1030 | public function route_admin_request() { |
1031 | - if ( $this->_cpt_route ) return; |
|
1031 | + if ($this->_cpt_route) return; |
|
1032 | 1032 | try { |
1033 | 1033 | $this->_route_admin_request(); |
1034 | - } catch ( EE_Error $e ) { |
|
1034 | + } catch (EE_Error $e) { |
|
1035 | 1035 | $e->get_error(); |
1036 | 1036 | } |
1037 | 1037 | } |
@@ -1044,12 +1044,12 @@ discard block |
||
1044 | 1044 | * @return string html |
1045 | 1045 | */ |
1046 | 1046 | public function cpt_post_form_hidden_input() { |
1047 | - echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />'; |
|
1047 | + echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="'.$this->_admin_base_url.'" />'; |
|
1048 | 1048 | |
1049 | 1049 | //we're also going to add the route value and the current page so we can direct autosave parsing correctly |
1050 | 1050 | echo '<div id="ee-cpt-hidden-inputs">'; |
1051 | - echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />'; |
|
1052 | - echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />'; |
|
1051 | + echo '<input type="hidden" id="current_route" name="current_route" value="'.$this->_current_view.'" />'; |
|
1052 | + echo '<input type="hidden" id="current_page" name="current_page" value="'.$this->page_slug.'" />'; |
|
1053 | 1053 | echo '</div>'; |
1054 | 1054 | } |
1055 | 1055 | |
@@ -1062,12 +1062,12 @@ discard block |
||
1062 | 1062 | * @param int $status Status for http header |
1063 | 1063 | * @return string new (or original) url to redirect to. |
1064 | 1064 | */ |
1065 | - public function revision_redirect( $location, $status ) { |
|
1065 | + public function revision_redirect($location, $status) { |
|
1066 | 1066 | //get revision |
1067 | 1067 | $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : NULL; |
1068 | 1068 | |
1069 | 1069 | //can't do anything without revision so let's get out if not present |
1070 | - if ( empty( $rev_id ) ) |
|
1070 | + if (empty($rev_id)) |
|
1071 | 1071 | return $location; |
1072 | 1072 | |
1073 | 1073 | //get rev_post_data |
@@ -1081,8 +1081,8 @@ discard block |
||
1081 | 1081 | 'message' => 5 |
1082 | 1082 | ); |
1083 | 1083 | |
1084 | - $this->_process_notices( $query_args, TRUE ); |
|
1085 | - return self::add_query_args_and_nonce( $query_args, $admin_url ); |
|
1084 | + $this->_process_notices($query_args, TRUE); |
|
1085 | + return self::add_query_args_and_nonce($query_args, $admin_url); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | |
@@ -1095,16 +1095,16 @@ discard block |
||
1095 | 1095 | * @param string $context optional, defaults to display. How to write the '&' |
1096 | 1096 | * @return string the link |
1097 | 1097 | */ |
1098 | - public function modify_edit_post_link( $link, $id, $context ) { |
|
1099 | - $post = get_post( $id ); |
|
1100 | - if ( !isset( $this->_req_data['action'] ) || !isset( $this->_cpt_routes[$this->_req_data['action']] ) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) |
|
1098 | + public function modify_edit_post_link($link, $id, $context) { |
|
1099 | + $post = get_post($id); |
|
1100 | + if ( ! isset($this->_req_data['action']) || ! isset($this->_cpt_routes[$this->_req_data['action']]) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]) |
|
1101 | 1101 | return $link; |
1102 | 1102 | $query_args = array( |
1103 | 1103 | 'action' => isset($this->_cpt_edit_routes[$post->post_type]) ? $this->_cpt_edit_routes[$post->post_type] : 'edit', |
1104 | 1104 | 'post' => $id |
1105 | 1105 | ); |
1106 | 1106 | |
1107 | - return self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1107 | + return self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | |
@@ -1116,12 +1116,12 @@ discard block |
||
1116 | 1116 | * @param bool $force_delete whether this is forcing a hard delete instead of trash |
1117 | 1117 | * @return string new delete link |
1118 | 1118 | */ |
1119 | - public function modify_delete_post_link( $delete_link, $post_id, $force_delete ) { |
|
1119 | + public function modify_delete_post_link($delete_link, $post_id, $force_delete) { |
|
1120 | 1120 | $post = get_post($post_id); |
1121 | - if ( !isset( $this->_req_data['action'] ) || ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) ) |
|
1121 | + if ( ! isset($this->_req_data['action']) || (isset($this->_cpt_routes[$this->_req_data['action']]) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']])) |
|
1122 | 1122 | return $delete_link; |
1123 | 1123 | |
1124 | - return add_query_arg( array('current_route' => 'trash' ), $delete_link ); |
|
1124 | + return add_query_arg(array('current_route' => 'trash'), $delete_link); |
|
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | |
@@ -1132,16 +1132,16 @@ discard block |
||
1132 | 1132 | * @param string $status status |
1133 | 1133 | * @return string url to redirect to |
1134 | 1134 | */ |
1135 | - public function cpt_trash_post_location_redirect( $location, $status ) { |
|
1136 | - if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] !== 'trash' && empty( $this->_req_data['post'] ) ) |
|
1135 | + public function cpt_trash_post_location_redirect($location, $status) { |
|
1136 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] !== 'trash' && empty($this->_req_data['post'])) |
|
1137 | 1137 | return $location; |
1138 | 1138 | |
1139 | - $post = get_post( $this->_req_data['post'] ); |
|
1140 | - $query_args = array( 'action' => 'default' ); |
|
1139 | + $post = get_post($this->_req_data['post']); |
|
1140 | + $query_args = array('action' => 'default'); |
|
1141 | 1141 | $this->_cpt_object = get_post_type_object($post->post_type); |
1142 | - EE_Error::add_success( sprintf( __('%s trashed.', 'event_espresso'), $this->_cpt_object->labels->singular_name) ); |
|
1143 | - $this->_process_notices( $query_args, TRUE ); |
|
1144 | - return self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1142 | + EE_Error::add_success(sprintf(__('%s trashed.', 'event_espresso'), $this->_cpt_object->labels->singular_name)); |
|
1143 | + $this->_process_notices($query_args, TRUE); |
|
1144 | + return self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | * @param string $post_id This is the 'ID' value of the wp_posts table |
1157 | 1157 | * @return string the new location to redirect to |
1158 | 1158 | */ |
1159 | - public function cpt_post_location_redirect( $location, $post_id ) { |
|
1159 | + public function cpt_post_location_redirect($location, $post_id) { |
|
1160 | 1160 | //we DO have a match so let's setup the url |
1161 | 1161 | |
1162 | 1162 | //we have to get the post to determine our route |
@@ -1164,14 +1164,14 @@ discard block |
||
1164 | 1164 | $edit_route = $this->_cpt_edit_routes[$post->post_type]; |
1165 | 1165 | |
1166 | 1166 | //shared query_args |
1167 | - $query_args = array( 'action' => $edit_route, 'post' => $post_id ); |
|
1167 | + $query_args = array('action' => $edit_route, 'post' => $post_id); |
|
1168 | 1168 | $admin_url = $this->_admin_base_url; |
1169 | 1169 | // $append = ''; |
1170 | 1170 | |
1171 | - if ( isset( $this->_req_data['save'] ) || isset( $this->_req_data['publish'] ) ) { |
|
1172 | - $status = get_post_status( $post_id ); |
|
1173 | - if ( isset( $this->_req_data['publish'] ) ) { |
|
1174 | - switch ( $status ) { |
|
1171 | + if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) { |
|
1172 | + $status = get_post_status($post_id); |
|
1173 | + if (isset($this->_req_data['publish'])) { |
|
1174 | + switch ($status) { |
|
1175 | 1175 | case 'pending': |
1176 | 1176 | $message = 8; |
1177 | 1177 | break; |
@@ -1184,13 +1184,13 @@ discard block |
||
1184 | 1184 | } else { |
1185 | 1185 | $message = 'draft' == $status ? 10 : 1; |
1186 | 1186 | } |
1187 | - } else if ( isset( $this->_req_data['addmeta']) && $this->_req_data['addmeta'] ) { |
|
1187 | + } else if (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) { |
|
1188 | 1188 | $message = 2; |
1189 | 1189 | // $append = '#postcustom'; |
1190 | - } else if ( isset( $this->_req_data['deletemeta']) && $this->_req_data['deletemeta'] ) { |
|
1190 | + } else if (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) { |
|
1191 | 1191 | $message = 3; |
1192 | 1192 | // $append = '#postcustom'; |
1193 | - } elseif ( $this->_req_data['action'] == 'post-quickpress-save-cont' ) { |
|
1193 | + } elseif ($this->_req_data['action'] == 'post-quickpress-save-cont') { |
|
1194 | 1194 | $message = 7; |
1195 | 1195 | } else { |
1196 | 1196 | $message = 4; |
@@ -1198,12 +1198,12 @@ discard block |
||
1198 | 1198 | |
1199 | 1199 | //change the message if the post type is not viewable on the frontend |
1200 | 1200 | $this->_cpt_object = get_post_type_object($post->post_type); |
1201 | - $message = $message === 1 && !$this->_cpt_object->publicly_queryable ? 4 : $message; |
|
1201 | + $message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message; |
|
1202 | 1202 | |
1203 | - $query_args = array_merge( array( 'message' => $message ), $query_args ); |
|
1203 | + $query_args = array_merge(array('message' => $message), $query_args); |
|
1204 | 1204 | |
1205 | - $this->_process_notices( $query_args, TRUE ); |
|
1206 | - return self::add_query_args_and_nonce( $query_args, $admin_url ); |
|
1205 | + $this->_process_notices($query_args, TRUE); |
|
1206 | + return self::add_query_args_and_nonce($query_args, $admin_url); |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | |
@@ -1235,10 +1235,10 @@ discard block |
||
1235 | 1235 | * @param array $messages the original messages array |
1236 | 1236 | * @return array the new messages array |
1237 | 1237 | */ |
1238 | - public function post_update_messages( $messages ) { |
|
1238 | + public function post_update_messages($messages) { |
|
1239 | 1239 | global $post; |
1240 | - $id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
|
1241 | - $id = empty( $id ) && is_object( $post ) ? $post->ID : NULL; |
|
1240 | + $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
1241 | + $id = empty($id) && is_object($post) ? $post->ID : NULL; |
|
1242 | 1242 | |
1243 | 1243 | // $post_type = $post ? $post->post_type : false; |
1244 | 1244 | |
@@ -1251,9 +1251,9 @@ discard block |
||
1251 | 1251 | 0 => '', //Unused. Messages start at index 1. |
1252 | 1252 | |
1253 | 1253 | 1 => sprintf( |
1254 | - __( '%1$s updated. %2$sView %1$s%3$s', 'event_espresso'), |
|
1254 | + __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'), |
|
1255 | 1255 | $this->_cpt_object->labels->singular_name, |
1256 | - '<a href="' . esc_url( get_permalink( $id )) . '">', |
|
1256 | + '<a href="'.esc_url(get_permalink($id)).'">', |
|
1257 | 1257 | '</a>' |
1258 | 1258 | ), |
1259 | 1259 | |
@@ -1261,38 +1261,38 @@ discard block |
||
1261 | 1261 | |
1262 | 1262 | 3 => __('Custom field deleted.'), |
1263 | 1263 | |
1264 | - 4 => sprintf( __( '%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name ), |
|
1264 | + 4 => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
1265 | 1265 | |
1266 | - 5 => isset( $_GET['revision'] ) ? sprintf( __('%s restored to revision from %s', 'event_espresso'), $this->_cpt_object->labels->singular_name, wp_post_revision_title( (int) $_GET['revision'], FALSE ) ) : FALSE, |
|
1266 | + 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'event_espresso'), $this->_cpt_object->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], FALSE)) : FALSE, |
|
1267 | 1267 | |
1268 | 1268 | 6 => sprintf( |
1269 | - __( '%1$s published. %2$sView %1$s%3$s', 'event_espresso'), |
|
1269 | + __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'), |
|
1270 | 1270 | $this->_cpt_object->labels->singular_name, |
1271 | - '<a href="' . esc_url( get_permalink( $id )) . '">', |
|
1271 | + '<a href="'.esc_url(get_permalink($id)).'">', |
|
1272 | 1272 | '</a>' |
1273 | 1273 | ), |
1274 | 1274 | |
1275 | - 7 => sprintf( __( '%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name ), |
|
1275 | + 7 => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
1276 | 1276 | |
1277 | 1277 | 8 => sprintf( |
1278 | 1278 | __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'), |
1279 | 1279 | $this->_cpt_object->labels->singular_name, |
1280 | - '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $id ))) . '">', |
|
1280 | + '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))).'">', |
|
1281 | 1281 | '</a>' |
1282 | 1282 | ), |
1283 | 1283 | |
1284 | 1284 | 9 => sprintf( |
1285 | - __( '%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'), |
|
1285 | + __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'), |
|
1286 | 1286 | $this->_cpt_object->labels->singular_name, |
1287 | - '<strong>' . date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date )) . '</strong>', |
|
1288 | - '<a target="_blank" href="' . esc_url( get_permalink( $id )), |
|
1287 | + '<strong>'.date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)).'</strong>', |
|
1288 | + '<a target="_blank" href="'.esc_url(get_permalink($id)), |
|
1289 | 1289 | '</a>' |
1290 | 1290 | ), |
1291 | 1291 | |
1292 | 1292 | 10 => sprintf( |
1293 | 1293 | __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'), |
1294 | 1294 | $this->_cpt_object->labels->singular_name, |
1295 | - '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $id ))) , |
|
1295 | + '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))), |
|
1296 | 1296 | '</a>' |
1297 | 1297 | ) |
1298 | 1298 | ); |
@@ -1319,24 +1319,24 @@ discard block |
||
1319 | 1319 | $post_type_object = $this->_cpt_object; |
1320 | 1320 | $title = $post_type_object->labels->add_new_item; |
1321 | 1321 | $editing = TRUE; |
1322 | - wp_enqueue_script( 'autosave' ); |
|
1323 | - $post = $post = get_default_post_to_edit( $this->_cpt_routes[$this->_req_action], TRUE ); |
|
1322 | + wp_enqueue_script('autosave'); |
|
1323 | + $post = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], TRUE); |
|
1324 | 1324 | $post_ID = $post->ID; |
1325 | 1325 | $is_IE = $is_IE; |
1326 | 1326 | |
1327 | - add_action( 'admin_print_styles', array( $this, 'add_new_admin_page_global' ) ); |
|
1327 | + add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
|
1328 | 1328 | |
1329 | 1329 | //modify the default editor title field with default title. |
1330 | - add_filter('enter_title_here', array( $this, 'add_custom_editor_default_title' ), 10 ); |
|
1330 | + add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
|
1331 | 1331 | |
1332 | - include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
1332 | + include_once WP_ADMIN_PATH.'edit-form-advanced.php'; |
|
1333 | 1333 | } |
1334 | 1334 | |
1335 | 1335 | |
1336 | 1336 | |
1337 | 1337 | |
1338 | 1338 | public function add_new_admin_page_global() { |
1339 | - $admin_page = !empty( $this->_req_data['post'] ) ? 'post-php' : 'post-new-php'; |
|
1339 | + $admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php'; |
|
1340 | 1340 | ?> |
1341 | 1341 | <script type="text/javascript"> |
1342 | 1342 | adminpage = '<?php echo $admin_page; ?>'; |
@@ -1358,16 +1358,16 @@ discard block |
||
1358 | 1358 | */ |
1359 | 1359 | protected function _edit_cpt_item() { |
1360 | 1360 | global $post, $title, $is_IE, $post_type, $post_type_object; |
1361 | - $post_id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
|
1362 | - $post = !empty( $post_id ) ? get_post( $post_id, OBJECT, 'edit' ) : NULL; |
|
1361 | + $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
1362 | + $post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : NULL; |
|
1363 | 1363 | |
1364 | - if ( empty ( $post ) ) { |
|
1365 | - wp_die( __('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?') ); |
|
1364 | + if (empty ($post)) { |
|
1365 | + wp_die(__('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?')); |
|
1366 | 1366 | } |
1367 | 1367 | |
1368 | - if ( ! empty( $_GET['get-post-lock'] ) ) { |
|
1369 | - wp_set_post_lock( $post_id ); |
|
1370 | - wp_redirect( get_edit_post_link( $post_id, 'url' ) ); |
|
1368 | + if ( ! empty($_GET['get-post-lock'])) { |
|
1369 | + wp_set_post_lock($post_id); |
|
1370 | + wp_redirect(get_edit_post_link($post_id, 'url')); |
|
1371 | 1371 | exit(); |
1372 | 1372 | } |
1373 | 1373 | |
@@ -1379,32 +1379,32 @@ discard block |
||
1379 | 1379 | $post_type_object = $this->_cpt_object; |
1380 | 1380 | $is_IE = $is_IE; |
1381 | 1381 | |
1382 | - if ( ! wp_check_post_lock( $post->ID ) ) { |
|
1383 | - $active_post_lock = wp_set_post_lock( $post->ID ); |
|
1382 | + if ( ! wp_check_post_lock($post->ID)) { |
|
1383 | + $active_post_lock = wp_set_post_lock($post->ID); |
|
1384 | 1384 | //wp_enqueue_script('autosave'); |
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | $title = $this->_cpt_object->labels->edit_item; |
1388 | 1388 | |
1389 | - add_action('admin_footer', '_admin_notice_post_locked' ); |
|
1389 | + add_action('admin_footer', '_admin_notice_post_locked'); |
|
1390 | 1390 | |
1391 | - if ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && !isset( $this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']] ) ) { |
|
1392 | - $create_new_action = apply_filters( 'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action', 'create_new', $this ); |
|
1391 | + if (isset($this->_cpt_routes[$this->_req_data['action']]) && ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])) { |
|
1392 | + $create_new_action = apply_filters('FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action', 'create_new', $this); |
|
1393 | 1393 | |
1394 | - $post_new_file = EE_Admin_Page::add_query_args_and_nonce( array('action' => $create_new_action, 'page' => $this->page_slug), 'admin.php' ); |
|
1394 | + $post_new_file = EE_Admin_Page::add_query_args_and_nonce(array('action' => $create_new_action, 'page' => $this->page_slug), 'admin.php'); |
|
1395 | 1395 | } |
1396 | 1396 | |
1397 | - if ( post_type_supports($this->_cpt_routes[$this->_req_action], 'comments') ) { |
|
1397 | + if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) { |
|
1398 | 1398 | wp_enqueue_script('admin-comments'); |
1399 | 1399 | enqueue_comment_hotkeys_js(); |
1400 | 1400 | } |
1401 | 1401 | |
1402 | - add_action( 'admin_print_styles', array( $this, 'add_new_admin_page_global' ) ); |
|
1402 | + add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
|
1403 | 1403 | |
1404 | 1404 | //modify the default editor title field with default title. |
1405 | - add_filter('enter_title_here', array( $this, 'add_custom_editor_default_title' ), 10 ); |
|
1405 | + add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
|
1406 | 1406 | |
1407 | - include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
1407 | + include_once WP_ADMIN_PATH.'edit-form-advanced.php'; |
|
1408 | 1408 | |
1409 | 1409 | } |
1410 | 1410 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * EE_Admin_Page_CPT class |
4 | 6 | * |
@@ -236,8 +238,9 @@ discard block |
||
236 | 238 | |
237 | 239 | $containers = array(); |
238 | 240 | |
239 | - if ( empty( $wp_meta_boxes ) ) |
|
240 | - return; |
|
241 | + if ( empty( $wp_meta_boxes ) ) { |
|
242 | + return; |
|
243 | + } |
|
241 | 244 | |
242 | 245 | $current_metaboxes = isset( $wp_meta_boxes[$this->page_slug] ) ? $wp_meta_boxes[$this->page_slug] : array(); |
243 | 246 | |
@@ -341,8 +344,9 @@ discard block |
||
341 | 344 | |
342 | 345 | |
343 | 346 | //this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form |
344 | - if ( method_exists( $this, 'extra_permalink_field_buttons' ) ) |
|
345 | - add_filter('get_sample_permalink_html', array( $this, 'extra_permalink_field_buttons' ), 10, 4 ); |
|
347 | + if ( method_exists( $this, 'extra_permalink_field_buttons' ) ) { |
|
348 | + add_filter('get_sample_permalink_html', array( $this, 'extra_permalink_field_buttons' ), 10, 4 ); |
|
349 | + } |
|
346 | 350 | |
347 | 351 | //add preview button |
348 | 352 | add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4 ); |
@@ -352,12 +356,14 @@ discard block |
||
352 | 356 | add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown' ), 10 ); |
353 | 357 | |
354 | 358 | //This allows adding additional information to the publish post submitbox on the wp post edit form |
355 | - if ( method_exists( $this, 'extra_misc_actions_publish_box' ) ) |
|
356 | - add_action('post_submitbox_misc_actions', array( $this, 'extra_misc_actions_publish_box' ), 10 ); |
|
359 | + if ( method_exists( $this, 'extra_misc_actions_publish_box' ) ) { |
|
360 | + add_action('post_submitbox_misc_actions', array( $this, 'extra_misc_actions_publish_box' ), 10 ); |
|
361 | + } |
|
357 | 362 | |
358 | 363 | //This allows for adding additional stuff after the title field on the wp post edit form. This is also before the wp_editor for post description field. |
359 | - if ( method_exists( $this, 'edit_form_after_title' ) ) |
|
360 | - add_action('edit_form_after_title', array( $this, 'edit_form_after_title' ), 10 ); |
|
364 | + if ( method_exists( $this, 'edit_form_after_title' ) ) { |
|
365 | + add_action('edit_form_after_title', array( $this, 'edit_form_after_title' ), 10 ); |
|
366 | + } |
|
361 | 367 | |
362 | 368 | |
363 | 369 | /** |
@@ -548,7 +554,9 @@ discard block |
||
548 | 554 | |
549 | 555 | |
550 | 556 | //make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it) |
551 | - if ( !defined('DOING_AUTOSAVE') ) define('DOING_AUTOSAVE', true); |
|
557 | + if ( !defined('DOING_AUTOSAVE') ) { |
|
558 | + define('DOING_AUTOSAVE', true); |
|
559 | + } |
|
552 | 560 | |
553 | 561 | //if we made it here then the nonce checked out. Let's run our methods and actions |
554 | 562 | if ( method_exists( $this, '_ee_autosave_' . $this->_current_view ) ) { |
@@ -578,8 +586,9 @@ discard block |
||
578 | 586 | protected function _extend_page_config_for_cpt() { |
579 | 587 | |
580 | 588 | //before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug |
581 | - if ( ( isset( $this->_req_data['page'] ) && $this->_req_data['page'] != $this->page_slug ) ) |
|
582 | - return; |
|
589 | + if ( ( isset( $this->_req_data['page'] ) && $this->_req_data['page'] != $this->page_slug ) ) { |
|
590 | + return; |
|
591 | + } |
|
583 | 592 | |
584 | 593 | //set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes |
585 | 594 | if ( !empty( $this->_cpt_object ) ) { |
@@ -611,8 +620,9 @@ discard block |
||
611 | 620 | } |
612 | 621 | |
613 | 622 | //load the next section only if this is a matching cpt route as set in the cpt routes array. |
614 | - if ( !isset( $this->_cpt_routes[$this->_req_action] ) ) |
|
615 | - return; |
|
623 | + if ( !isset( $this->_cpt_routes[$this->_req_action] ) ) { |
|
624 | + return; |
|
625 | + } |
|
616 | 626 | |
617 | 627 | |
618 | 628 | $this->_cpt_route = isset( $this->_cpt_routes[$this->_req_action] ) ? TRUE : FALSE; |
@@ -896,8 +906,10 @@ discard block |
||
896 | 906 | } |
897 | 907 | } |
898 | 908 | |
899 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) |
|
900 | - return; //TODO we'll remove this after reimplementing autosave in 4.2 |
|
909 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
910 | + return; |
|
911 | + } |
|
912 | + //TODO we'll remove this after reimplementing autosave in 4.2 |
|
901 | 913 | $this->_insert_update_cpt_item( $post_id, $post ); |
902 | 914 | } |
903 | 915 | |
@@ -974,7 +986,9 @@ discard block |
||
974 | 986 | */ |
975 | 987 | public function modify_current_screen() { |
976 | 988 | //ONLY do this if the current page_route IS a cpt route |
977 | - if ( !$this->_cpt_route ) return; |
|
989 | + if ( !$this->_cpt_route ) { |
|
990 | + return; |
|
991 | + } |
|
978 | 992 | //routing things REALLY early b/c this is a cpt admin page |
979 | 993 | set_current_screen( $this->_cpt_routes[$this->_req_action]); |
980 | 994 | $this->_current_screen = get_current_screen(); |
@@ -1014,8 +1028,9 @@ discard block |
||
1014 | 1028 | public function add_shortlink_button_to_editor( $shortlink, $id, $context, $allow_slugs ) { |
1015 | 1029 | if ( !empty( $id ) && '' != get_option('permalink_structure') ) { |
1016 | 1030 | $post = get_post( $id ); |
1017 | - if ( isset($post->post_type) && $this->page_slug == $post->post_type ) |
|
1018 | - $shortlink = home_url('?p=' . $post->ID); |
|
1031 | + if ( isset($post->post_type) && $this->page_slug == $post->post_type ) { |
|
1032 | + $shortlink = home_url('?p=' . $post->ID); |
|
1033 | + } |
|
1019 | 1034 | } |
1020 | 1035 | return $shortlink; |
1021 | 1036 | } |
@@ -1028,7 +1043,9 @@ discard block |
||
1028 | 1043 | * @return void |
1029 | 1044 | */ |
1030 | 1045 | public function route_admin_request() { |
1031 | - if ( $this->_cpt_route ) return; |
|
1046 | + if ( $this->_cpt_route ) { |
|
1047 | + return; |
|
1048 | + } |
|
1032 | 1049 | try { |
1033 | 1050 | $this->_route_admin_request(); |
1034 | 1051 | } catch ( EE_Error $e ) { |
@@ -1067,8 +1084,9 @@ discard block |
||
1067 | 1084 | $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : NULL; |
1068 | 1085 | |
1069 | 1086 | //can't do anything without revision so let's get out if not present |
1070 | - if ( empty( $rev_id ) ) |
|
1071 | - return $location; |
|
1087 | + if ( empty( $rev_id ) ) { |
|
1088 | + return $location; |
|
1089 | + } |
|
1072 | 1090 | |
1073 | 1091 | //get rev_post_data |
1074 | 1092 | $rev = get_post($rev_id); |
@@ -1097,8 +1115,9 @@ discard block |
||
1097 | 1115 | */ |
1098 | 1116 | public function modify_edit_post_link( $link, $id, $context ) { |
1099 | 1117 | $post = get_post( $id ); |
1100 | - if ( !isset( $this->_req_data['action'] ) || !isset( $this->_cpt_routes[$this->_req_data['action']] ) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) |
|
1101 | - return $link; |
|
1118 | + if ( !isset( $this->_req_data['action'] ) || !isset( $this->_cpt_routes[$this->_req_data['action']] ) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) { |
|
1119 | + return $link; |
|
1120 | + } |
|
1102 | 1121 | $query_args = array( |
1103 | 1122 | 'action' => isset($this->_cpt_edit_routes[$post->post_type]) ? $this->_cpt_edit_routes[$post->post_type] : 'edit', |
1104 | 1123 | 'post' => $id |
@@ -1118,8 +1137,9 @@ discard block |
||
1118 | 1137 | */ |
1119 | 1138 | public function modify_delete_post_link( $delete_link, $post_id, $force_delete ) { |
1120 | 1139 | $post = get_post($post_id); |
1121 | - if ( !isset( $this->_req_data['action'] ) || ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) ) |
|
1122 | - return $delete_link; |
|
1140 | + if ( !isset( $this->_req_data['action'] ) || ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) ) { |
|
1141 | + return $delete_link; |
|
1142 | + } |
|
1123 | 1143 | |
1124 | 1144 | return add_query_arg( array('current_route' => 'trash' ), $delete_link ); |
1125 | 1145 | } |
@@ -1133,8 +1153,9 @@ discard block |
||
1133 | 1153 | * @return string url to redirect to |
1134 | 1154 | */ |
1135 | 1155 | public function cpt_trash_post_location_redirect( $location, $status ) { |
1136 | - if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] !== 'trash' && empty( $this->_req_data['post'] ) ) |
|
1137 | - return $location; |
|
1156 | + if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] !== 'trash' && empty( $this->_req_data['post'] ) ) { |
|
1157 | + return $location; |
|
1158 | + } |
|
1138 | 1159 | |
1139 | 1160 | $post = get_post( $this->_req_data['post'] ); |
1140 | 1161 | $query_args = array( 'action' => 'default' ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | 'espresso_events' => 'edit' |
68 | 68 | ); |
69 | 69 | |
70 | - add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) ); |
|
70 | + add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | protected function _ajax_hooks() { |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | 'edit' => __('Update Event', 'event_espresso'), |
94 | 94 | 'add_category' => __('Save New Category', 'event_espresso'), |
95 | 95 | 'edit_category' => __('Update Category', 'event_espresso'), |
96 | - 'template_settings' => __( 'Update Settings', 'event_espresso' ) |
|
96 | + 'template_settings' => __('Update Settings', 'event_espresso') |
|
97 | 97 | ) |
98 | 98 | ); |
99 | 99 | } |
100 | 100 | |
101 | 101 | protected function _set_page_routes() { |
102 | 102 | //load formatter helper |
103 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
103 | + EE_Registry::instance()->load_helper('Formatter'); |
|
104 | 104 | //load field generator helper |
105 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
105 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
106 | 106 | |
107 | 107 | //is there a evt_id in the request? |
108 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0; |
|
109 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
108 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0; |
|
109 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
110 | 110 | |
111 | 111 | |
112 | 112 | $this->_page_routes = array( |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | 'help_tour' => array( |
321 | 321 | 'Event_Editor_Help_Tour' |
322 | 322 | ), |
323 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
323 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
324 | 324 | 'require_nonce' => FALSE |
325 | 325 | ), |
326 | 326 | 'edit' => array( |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | /*'help_tour' => array( |
377 | 377 | 'Event_Edit_Help_Tour' |
378 | 378 | ),*/ |
379 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
379 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
380 | 380 | 'require_nonce' => FALSE |
381 | 381 | ), |
382 | 382 | 'default_event_settings' => array( |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | 'filename' => 'events_default_settings_status' |
399 | 399 | ) |
400 | 400 | ), |
401 | - 'help_tour' => array( 'Event_Default_Settings_Help_Tour'), |
|
401 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
402 | 402 | 'require_nonce' => FALSE |
403 | 403 | ), |
404 | 404 | //template settings |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | 'filename' => 'general_settings_templates' |
415 | 415 | ) |
416 | 416 | ), |
417 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
417 | + 'help_tour' => array('Templates_Help_Tour'), |
|
418 | 418 | 'require_nonce' => FALSE |
419 | 419 | ), |
420 | 420 | //event category stuff |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | 'label' => __('Edit Category', 'event_espresso'), |
439 | 439 | 'order' => 15, |
440 | 440 | 'persistent' => FALSE, |
441 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
441 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url |
|
442 | 442 | ), |
443 | 443 | 'help_tabs' => array( |
444 | 444 | 'edit_category_help_tab' => array( |
@@ -508,14 +508,14 @@ discard block |
||
508 | 508 | |
509 | 509 | public function load_scripts_styles() { |
510 | 510 | |
511 | - wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
512 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
511 | + wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
512 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
513 | 513 | wp_enqueue_style('events-admin-css'); |
514 | 514 | wp_enqueue_style('ee-cat-admin'); |
515 | 515 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
516 | 516 | //registers for all views |
517 | 517 | //scripts |
518 | - wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
518 | + wp_register_script('event_editor_js', EVENTS_ASSETS_URL.'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -533,11 +533,11 @@ discard block |
||
533 | 533 | public function load_scripts_styles_edit() { |
534 | 534 | //styles |
535 | 535 | wp_enqueue_style('espresso-ui-theme'); |
536 | - wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
536 | + wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
537 | 537 | wp_enqueue_style('event-editor-css'); |
538 | 538 | |
539 | 539 | //scripts |
540 | - wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION ); |
|
540 | + wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION); |
|
541 | 541 | wp_enqueue_script('event-datetime-metabox'); |
542 | 542 | |
543 | 543 | } |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | |
574 | 574 | public function admin_init() { |
575 | - EE_Registry::$i18n_js_strings[ 'image_confirm' ] = __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' ); |
|
575 | + EE_Registry::$i18n_js_strings['image_confirm'] = __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso'); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | |
@@ -593,45 +593,45 @@ discard block |
||
593 | 593 | */ |
594 | 594 | public function verify_event_edit($event = NULL) { |
595 | 595 | // no event? |
596 | - if ( empty( $event )) { |
|
596 | + if (empty($event)) { |
|
597 | 597 | // set event |
598 | 598 | $event = $this->_cpt_model_obj; |
599 | 599 | } |
600 | 600 | // STILL no event? |
601 | - if ( empty ( $event )) { |
|
601 | + if (empty ($event)) { |
|
602 | 602 | return; |
603 | 603 | } |
604 | 604 | // first check if event is active. |
605 | - if ( $event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed ) { |
|
605 | + if ($event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed) { |
|
606 | 606 | return; |
607 | 607 | } |
608 | 608 | $orig_status = $event->status(); |
609 | 609 | //made it here so it IS active... next check that any of the tickets are sold. |
610 | - if ( $event->is_sold_out( true ) ) { |
|
611 | - if ( $event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out ) { |
|
610 | + if ($event->is_sold_out(true)) { |
|
611 | + if ($event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out) { |
|
612 | 612 | EE_Error::add_attention( |
613 | 613 | sprintf( |
614 | - __( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso' ), |
|
615 | - EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' ) |
|
614 | + __('Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso'), |
|
615 | + EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence') |
|
616 | 616 | ) |
617 | 617 | ); |
618 | 618 | } |
619 | 619 | return; |
620 | - } else if ( $orig_status === EEM_Event::sold_out ) { |
|
620 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
621 | 621 | EE_Error::add_attention( |
622 | 622 | sprintf( |
623 | - __( 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
624 | - 'event_espresso' ), |
|
625 | - EEH_Template::pretty_status( $event->status(), false, 'sentence' ) |
|
623 | + __('Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
624 | + 'event_espresso'), |
|
625 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
626 | 626 | ) |
627 | 627 | ); |
628 | 628 | } |
629 | 629 | //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
630 | - if ( ! $event->tickets_on_sale() ) { |
|
630 | + if ( ! $event->tickets_on_sale()) { |
|
631 | 631 | return; |
632 | 632 | } |
633 | 633 | //made it here so show warning |
634 | - EE_Error::add_attention( $this->_edit_event_warning() ); |
|
634 | + EE_Error::add_attention($this->_edit_event_warning()); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | ), |
672 | 672 | ); |
673 | 673 | |
674 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
674 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
675 | 675 | $this->_views['trash'] = array( |
676 | 676 | 'slug' => 'trash', |
677 | 677 | 'label' => __('Trash', 'event_espresso'), |
@@ -701,39 +701,39 @@ discard block |
||
701 | 701 | 'desc' => __('View Registrations for Event', 'event_espresso') |
702 | 702 | ) |
703 | 703 | ); |
704 | - $items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items ); |
|
704 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
705 | 705 | $statuses = array( |
706 | 706 | 'sold_out_status' => array( |
707 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
708 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' ) |
|
707 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
708 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence') |
|
709 | 709 | ), |
710 | 710 | 'active_status' => array( |
711 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
712 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' ) |
|
711 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
712 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence') |
|
713 | 713 | ), |
714 | 714 | 'upcoming_status' => array( |
715 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
716 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' ) |
|
715 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
716 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence') |
|
717 | 717 | ), |
718 | 718 | 'postponed_status' => array( |
719 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
720 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' ) |
|
719 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
720 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence') |
|
721 | 721 | ), |
722 | 722 | 'cancelled_status' => array( |
723 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
724 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' ) |
|
723 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
724 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence') |
|
725 | 725 | ), |
726 | 726 | 'expired_status' => array( |
727 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
728 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' ) |
|
727 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
728 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence') |
|
729 | 729 | ), |
730 | 730 | 'inactive_status' => array( |
731 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
732 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' ) |
|
731 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
732 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence') |
|
733 | 733 | ) |
734 | 734 | ); |
735 | - $statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses ); |
|
736 | - return array_merge( $items, $statuses ); |
|
735 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
736 | + return array_merge($items, $statuses); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | |
@@ -745,8 +745,8 @@ discard block |
||
745 | 745 | * @return EEM_Event |
746 | 746 | */ |
747 | 747 | private function _event_model() { |
748 | - if ( ! $this->_event_model instanceof EEM_Event ) { |
|
749 | - $this->_event_model = EE_Registry::instance()->load_model( 'Event' ); |
|
748 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
749 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
750 | 750 | } |
751 | 751 | return $this->_event_model; |
752 | 752 | } |
@@ -765,12 +765,12 @@ discard block |
||
765 | 765 | * @param string $new_slug what the slug is |
766 | 766 | * @return string The new html string for the permalink area |
767 | 767 | */ |
768 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
768 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
769 | 769 | //make sure this is only when editing |
770 | - if ( !empty( $id ) ) { |
|
771 | - $post = get_post( $id ); |
|
772 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> '; |
|
773 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' . $post->ID . ']">'; |
|
770 | + if ( ! empty($id)) { |
|
771 | + $post = get_post($id); |
|
772 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">'.__('Shortcode', 'event_espresso').'</a> '; |
|
773 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='.$post->ID.']">'; |
|
774 | 774 | } |
775 | 775 | return $return; |
776 | 776 | } |
@@ -786,8 +786,8 @@ discard block |
||
786 | 786 | * @return string html for generated table |
787 | 787 | */ |
788 | 788 | protected function _events_overview_list_table() { |
789 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
790 | - $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) . |
|
789 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
790 | + $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button'). |
|
791 | 791 | $this->_display_legend($this->_event_legend_items()); |
792 | 792 | $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
793 | 793 | $this->display_admin_list_table_page_with_no_sidebar(); |
@@ -805,51 +805,51 @@ discard block |
||
805 | 805 | |
806 | 806 | |
807 | 807 | |
808 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
808 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
809 | 809 | |
810 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) { |
|
810 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
811 | 811 | //getout we're not processing an event save. |
812 | 812 | return; |
813 | 813 | } |
814 | 814 | |
815 | 815 | $event_values = array( |
816 | - 'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0, |
|
817 | - 'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0, |
|
816 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
817 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
818 | 818 | 'EVT_additional_limit' => min( |
819 | - apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ), |
|
820 | - !empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ), |
|
821 | - 'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
822 | - 'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0, |
|
823 | - 'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0, |
|
824 | - 'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL, |
|
825 | - 'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL, |
|
826 | - 'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL |
|
819 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
820 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ), |
|
821 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
822 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
823 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
824 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL, |
|
825 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL, |
|
826 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL |
|
827 | 827 | ); |
828 | 828 | |
829 | 829 | //update event |
830 | - $success = $this->_event_model()->update_by_ID( $event_values, $post_id ); |
|
830 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
831 | 831 | |
832 | 832 | |
833 | 833 | //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
834 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
835 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
834 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
835 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
836 | 836 | |
837 | 837 | |
838 | 838 | //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
839 | - $event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) ); |
|
839 | + $event_update_callbacks = apply_filters('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))); |
|
840 | 840 | |
841 | 841 | $att_success = TRUE; |
842 | 842 | |
843 | - foreach ( $event_update_callbacks as $e_callback ) { |
|
844 | - $_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) ); |
|
845 | - $att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
843 | + foreach ($event_update_callbacks as $e_callback) { |
|
844 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
845 | + $att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | //any errors? |
849 | - if ( $success && FALSE === $att_success ) { |
|
850 | - EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
851 | - } else if ( $success === FALSE ) { |
|
852 | - EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
849 | + if ($success && FALSE === $att_success) { |
|
850 | + EE_Error::add_error(__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
851 | + } else if ($success === FALSE) { |
|
852 | + EE_Error::add_error(__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
853 | 853 | } |
854 | 854 | } |
855 | 855 | |
@@ -859,14 +859,14 @@ discard block |
||
859 | 859 | /** |
860 | 860 | * @see parent::restore_item() |
861 | 861 | */ |
862 | - protected function _restore_cpt_item( $post_id, $revision_id ) { |
|
862 | + protected function _restore_cpt_item($post_id, $revision_id) { |
|
863 | 863 | //copy existing event meta to new post |
864 | 864 | $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
865 | - if ( $post_evt instanceof EE_Event ) { |
|
865 | + if ($post_evt instanceof EE_Event) { |
|
866 | 866 | //meta revision restore |
867 | - $post_evt->restore_revision( $revision_id ); |
|
867 | + $post_evt->restore_revision($revision_id); |
|
868 | 868 | //related objs restore |
869 | - $post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) ); |
|
869 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
870 | 870 | } |
871 | 871 | } |
872 | 872 | |
@@ -879,52 +879,52 @@ discard block |
||
879 | 879 | * @param array $data The request data from the form |
880 | 880 | * @return bool Success or fail. |
881 | 881 | */ |
882 | - protected function _default_venue_update( $evtobj, $data ) { |
|
883 | - require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
882 | + protected function _default_venue_update($evtobj, $data) { |
|
883 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
884 | 884 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
885 | 885 | $rows_affected = NULL; |
886 | - $venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL; |
|
886 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL; |
|
887 | 887 | |
888 | 888 | // very important. If we don't have a venue name... |
889 | 889 | // then we'll get out because not necessary to create empty venue |
890 | - if ( empty( $data['venue_title'] ) ) { |
|
890 | + if (empty($data['venue_title'])) { |
|
891 | 891 | return false; |
892 | 892 | } |
893 | 893 | |
894 | 894 | $venue_array = array( |
895 | 895 | 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
896 | - 'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL, |
|
897 | - 'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL, |
|
898 | - 'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL, |
|
899 | - 'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL, |
|
900 | - 'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL, |
|
901 | - 'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL, |
|
902 | - 'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL, |
|
903 | - 'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL, |
|
904 | - 'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL, |
|
905 | - 'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL, |
|
906 | - 'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL, |
|
907 | - 'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL, |
|
908 | - 'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL, |
|
909 | - 'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
910 | - 'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL, |
|
911 | - 'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0, |
|
896 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL, |
|
897 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL, |
|
898 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL, |
|
899 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL, |
|
900 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL, |
|
901 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL, |
|
902 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL, |
|
903 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL, |
|
904 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL, |
|
905 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL, |
|
906 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL, |
|
907 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL, |
|
908 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL, |
|
909 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
910 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL, |
|
911 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
912 | 912 | 'status' => 'publish' |
913 | 913 | ); |
914 | 914 | |
915 | 915 | |
916 | 916 | //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
917 | - if ( !empty( $venue_id ) ) { |
|
918 | - $update_where = array( $venue_model->primary_key_name() => $venue_id ); |
|
919 | - $rows_affected = $venue_model->update( $venue_array, array( $update_where ) ); |
|
917 | + if ( ! empty($venue_id)) { |
|
918 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
919 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
920 | 920 | //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
921 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
921 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
922 | 922 | return $rows_affected > 0 ? TRUE : FALSE; |
923 | 923 | } else { |
924 | 924 | //we insert the venue |
925 | - $venue_id = $venue_model->insert( $venue_array ); |
|
926 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
927 | - return !empty( $venue_id ) ? TRUE : FALSE; |
|
925 | + $venue_id = $venue_model->insert($venue_array); |
|
926 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
927 | + return ! empty($venue_id) ? TRUE : FALSE; |
|
928 | 928 | } |
929 | 929 | //when we have the ancestor come in it's already been handled by the revision save. |
930 | 930 | } |
@@ -938,55 +938,55 @@ discard block |
||
938 | 938 | * @param array $data The request data from the form |
939 | 939 | * @return bool success or fail |
940 | 940 | */ |
941 | - protected function _default_tickets_update( EE_Event $evtobj, $data ) { |
|
941 | + protected function _default_tickets_update(EE_Event $evtobj, $data) { |
|
942 | 942 | $success = true; |
943 | 943 | $saved_dtt = null; |
944 | 944 | $saved_tickets = array(); |
945 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
945 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
946 | 946 | |
947 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
947 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
948 | 948 | //trim all values to ensure any excess whitespace is removed. |
949 | - $dtt = array_map( 'trim', $dtt ); |
|
950 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
949 | + $dtt = array_map('trim', $dtt); |
|
950 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
951 | 951 | $datetime_values = array( |
952 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
952 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
953 | 953 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
954 | 954 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
955 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'], |
|
955 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
956 | 956 | 'DTT_order' => $row, |
957 | 957 | ); |
958 | 958 | |
959 | 959 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
960 | 960 | |
961 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
962 | - $DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
963 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
964 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
965 | - foreach ( $datetime_values as $field => $value ) { |
|
966 | - $DTM->set( $field, $value ); |
|
961 | + if ( ! empty($dtt['DTT_ID'])) { |
|
962 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']); |
|
963 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
964 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
965 | + foreach ($datetime_values as $field => $value) { |
|
966 | + $DTM->set($field, $value); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
970 | 970 | $saved_dtts[$DTM->ID()] = $DTM; |
971 | 971 | } else { |
972 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE ); |
|
973 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
974 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
975 | - $DTM->set_timezone( $evtobj->get_timezone() ); |
|
976 | - foreach ( $datetime_values as $field => $value ) { |
|
977 | - $DTM->set( $field, $value ); |
|
972 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE); |
|
973 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
974 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
975 | + $DTM->set_timezone($evtobj->get_timezone()); |
|
976 | + foreach ($datetime_values as $field => $value) { |
|
977 | + $DTM->set($field, $value); |
|
978 | 978 | } |
979 | 979 | } |
980 | 980 | $DTM->save(); |
981 | 981 | |
982 | - $DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' ); |
|
982 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
983 | 983 | |
984 | 984 | //load DTT helper |
985 | 985 | EE_Registry::instance()->load_helper('DTT_Helper'); |
986 | 986 | |
987 | 987 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
988 | - if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) { |
|
989 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') ); |
|
988 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
989 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
990 | 990 | $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
991 | 991 | $DTT->save(); |
992 | 992 | } |
@@ -994,45 +994,45 @@ discard block |
||
994 | 994 | //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
995 | 995 | $saved_dtt = $DTT; |
996 | 996 | |
997 | - $success = !$success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
997 | + $success = ! $success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | //no dtts get deleted so we don't do any of that logic here. |
1001 | 1001 | //update tickets next |
1002 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
1003 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
1004 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1002 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1003 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1004 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1005 | 1005 | $update_prices = false; |
1006 | - $ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1006 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1007 | 1007 | |
1008 | 1008 | // trim inputs to ensure any excess whitespace is removed. |
1009 | - $tkt = array_map( 'trim', $tkt ); |
|
1009 | + $tkt = array_map('trim', $tkt); |
|
1010 | 1010 | |
1011 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
1011 | + if (empty($tkt['TKT_start_date'])) { |
|
1012 | 1012 | //let's use now in the set timezone. |
1013 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
1014 | - $tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] ); |
|
1013 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1014 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
1017 | + if (empty($tkt['TKT_end_date'])) { |
|
1018 | 1018 | //use the start date of the first datetime |
1019 | 1019 | $dtt = $evtobj->first_datetime(); |
1020 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] ); |
|
1020 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | $TKT_values = array( |
1024 | - 'TKT_ID' => !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
1025 | - 'TTM_ID' => !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
1026 | - 'TKT_name' => !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
1027 | - 'TKT_description' => !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '', |
|
1024 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
1025 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1026 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1027 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1028 | 1028 | 'TKT_start_date' => $tkt['TKT_start_date'], |
1029 | 1029 | 'TKT_end_date' => $tkt['TKT_end_date'], |
1030 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1031 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ], |
|
1032 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
1033 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
1030 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1031 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1032 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1033 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1034 | 1034 | 'TKT_row' => $row, |
1035 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row, |
|
1035 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1036 | 1036 | 'TKT_price' => $ticket_price |
1037 | 1037 | ); |
1038 | 1038 | |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | |
1041 | 1041 | |
1042 | 1042 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
1043 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
1043 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1044 | 1044 | $TKT_values['TKT_ID'] = 0; |
1045 | 1045 | $TKT_values['TKT_is_default'] = 0; |
1046 | 1046 | $TKT_values['TKT_price'] = $ticket_price; |
@@ -1051,58 +1051,58 @@ discard block |
||
1051 | 1051 | //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
1052 | 1052 | //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
1053 | 1053 | |
1054 | - if ( !empty( $tkt['TKT_ID'] ) ) { |
|
1055 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
1056 | - if ( $TKT instanceof EE_Ticket ) { |
|
1057 | - $ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false; |
|
1054 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1055 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']); |
|
1056 | + if ($TKT instanceof EE_Ticket) { |
|
1057 | + $ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false; |
|
1058 | 1058 | //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
1059 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false; |
|
1060 | - $TKT->set_date_format( $incoming_date_formats[ 0 ] ); |
|
1061 | - $TKT->set_time_format( $incoming_date_formats[ 1 ] ); |
|
1059 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false; |
|
1060 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1061 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1062 | 1062 | //set new values |
1063 | - foreach ( $TKT_values as $field => $value ) { |
|
1064 | - if ( $field == 'TKT_qty' ) { |
|
1065 | - $TKT->set_qty( $value ); |
|
1063 | + foreach ($TKT_values as $field => $value) { |
|
1064 | + if ($field == 'TKT_qty') { |
|
1065 | + $TKT->set_qty($value); |
|
1066 | 1066 | } else { |
1067 | - $TKT->set( $field, $value ); |
|
1067 | + $TKT->set($field, $value); |
|
1068 | 1068 | } |
1069 | 1069 | } |
1070 | 1070 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
1071 | - if ( $create_new_TKT ) { |
|
1071 | + if ($create_new_TKT) { |
|
1072 | 1072 | //archive the old ticket first |
1073 | - $TKT->set( 'TKT_deleted', 1 ); |
|
1073 | + $TKT->set('TKT_deleted', 1); |
|
1074 | 1074 | $TKT->save(); |
1075 | 1075 | //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
1076 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1076 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1077 | 1077 | //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
1078 | 1078 | $TKT = clone $TKT; |
1079 | - $TKT->set( 'TKT_ID', 0 ); |
|
1080 | - $TKT->set( 'TKT_deleted', 0 ); |
|
1081 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1082 | - $TKT->set( 'TKT_sold', 0 ); |
|
1079 | + $TKT->set('TKT_ID', 0); |
|
1080 | + $TKT->set('TKT_deleted', 0); |
|
1081 | + $TKT->set('TKT_price', $ticket_price); |
|
1082 | + $TKT->set('TKT_sold', 0); |
|
1083 | 1083 | //now we need to make sure that $new prices are created as well and attached to new ticket. |
1084 | 1084 | $update_prices = true; |
1085 | 1085 | } |
1086 | 1086 | //make sure price is set if it hasn't been already |
1087 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1087 | + $TKT->set('TKT_price', $ticket_price); |
|
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | } else { |
1091 | 1091 | //no TKT_id so a new TKT |
1092 | 1092 | $TKT_values['TKT_price'] = $ticket_price; |
1093 | - $TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE ); |
|
1094 | - if ( $TKT instanceof EE_Ticket ) { |
|
1093 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE); |
|
1094 | + if ($TKT instanceof EE_Ticket) { |
|
1095 | 1095 | //need to reset values to properly account for the date formats |
1096 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1097 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1098 | - $TKT->set_timezone( $evtobj->get_timezone() ); |
|
1096 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1097 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1098 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1099 | 1099 | |
1100 | 1100 | //set new values |
1101 | - foreach ( $TKT_values as $field => $value ) { |
|
1102 | - if ( $field == 'TKT_qty' ) { |
|
1103 | - $TKT->set_qty( $value ); |
|
1101 | + foreach ($TKT_values as $field => $value) { |
|
1102 | + if ($field == 'TKT_qty') { |
|
1103 | + $TKT->set_qty($value); |
|
1104 | 1104 | } else { |
1105 | - $TKT->set( $field, $value ); |
|
1105 | + $TKT->set($field, $value); |
|
1106 | 1106 | } |
1107 | 1107 | } |
1108 | 1108 | |
@@ -1110,32 +1110,32 @@ discard block |
||
1110 | 1110 | } |
1111 | 1111 | } |
1112 | 1112 | // cap ticket qty by datetime reg limits |
1113 | - $TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) ); |
|
1113 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1114 | 1114 | //update ticket. |
1115 | 1115 | $TKT->save(); |
1116 | 1116 | |
1117 | 1117 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
1118 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
1119 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
1118 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1119 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1120 | 1120 | EE_Registry::instance()->load_helper('DTT_Helper'); |
1121 | 1121 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
1122 | 1122 | $TKT->save(); |
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | //initially let's add the ticket to the dtt |
1126 | - $saved_dtt->_add_relation_to( $TKT, 'Ticket' ); |
|
1126 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1127 | 1127 | |
1128 | 1128 | $saved_tickets[$TKT->ID()] = $TKT; |
1129 | 1129 | |
1130 | 1130 | //add prices to ticket |
1131 | - $this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices ); |
|
1131 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1132 | 1132 | } |
1133 | 1133 | //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
1134 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1135 | - $tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) ); |
|
1134 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1135 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1136 | 1136 | |
1137 | - foreach ( $tickets_removed as $id ) { |
|
1138 | - $id = absint( $id ); |
|
1137 | + foreach ($tickets_removed as $id) { |
|
1138 | + $id = absint($id); |
|
1139 | 1139 | |
1140 | 1140 | //get the ticket for this id |
1141 | 1141 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
1144 | 1144 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
1145 | 1145 | |
1146 | - foreach( $dtts as $dtt ) { |
|
1146 | + foreach ($dtts as $dtt) { |
|
1147 | 1147 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
1148 | 1148 | } |
1149 | 1149 | |
@@ -1154,7 +1154,7 @@ discard block |
||
1154 | 1154 | //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
1155 | 1155 | $tkt_to_remove->delete_permanently(); |
1156 | 1156 | } |
1157 | - return array( $saved_dtt, $saved_tickets ); |
|
1157 | + return array($saved_dtt, $saved_tickets); |
|
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | |
@@ -1169,31 +1169,31 @@ discard block |
||
1169 | 1169 | * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
1170 | 1170 | * @return void |
1171 | 1171 | */ |
1172 | - private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) { |
|
1173 | - foreach ( $prices as $row => $prc ) { |
|
1172 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) { |
|
1173 | + foreach ($prices as $row => $prc) { |
|
1174 | 1174 | $PRC_values = array( |
1175 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
1176 | - 'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL, |
|
1177 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
1178 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
1179 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
1175 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
1176 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL, |
|
1177 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1178 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1179 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1180 | 1180 | 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
1181 | 1181 | 'PRC_order' => $row |
1182 | 1182 | ); |
1183 | 1183 | |
1184 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
1184 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1185 | 1185 | $PRC_values['PRC_ID'] = 0; |
1186 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
1186 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
1187 | 1187 | } else { |
1188 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
1188 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1189 | 1189 | //update this price with new values |
1190 | - foreach ( $PRC_values as $field => $newprc ) { |
|
1191 | - $PRC->set( $field, $newprc ); |
|
1190 | + foreach ($PRC_values as $field => $newprc) { |
|
1191 | + $PRC->set($field, $newprc); |
|
1192 | 1192 | } |
1193 | 1193 | $PRC->save(); |
1194 | 1194 | } |
1195 | 1195 | |
1196 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
1196 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1197 | 1197 | } |
1198 | 1198 | } |
1199 | 1199 | |
@@ -1216,33 +1216,33 @@ discard block |
||
1216 | 1216 | |
1217 | 1217 | return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
1218 | 1218 | |
1219 | - $postid = isset( $this->_req_data['post_ID'] ) ? $this->_req_data['post_ID'] : NULL; |
|
1219 | + $postid = isset($this->_req_data['post_ID']) ? $this->_req_data['post_ID'] : NULL; |
|
1220 | 1220 | |
1221 | 1221 | |
1222 | 1222 | //if no postid then get out cause we need it for stuff in here |
1223 | - if ( empty( $postid ) ) return; |
|
1223 | + if (empty($postid)) return; |
|
1224 | 1224 | |
1225 | 1225 | |
1226 | 1226 | //handle datetime saves |
1227 | 1227 | $items = array(); |
1228 | 1228 | |
1229 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $postid ); |
|
1230 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
1229 | + $get_one_where = array($this->_event_model()->primary_key_name() => $postid); |
|
1230 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
1231 | 1231 | |
1232 | 1232 | //now let's get the attached datetimes from the most recent autosave |
1233 | 1233 | $dtts = $event->get_many_related('Datetime'); |
1234 | 1234 | |
1235 | 1235 | $dtt_ids = array(); |
1236 | - foreach( $dtts as $dtt ) { |
|
1236 | + foreach ($dtts as $dtt) { |
|
1237 | 1237 | $dtt_ids[] = $dtt->ID(); |
1238 | 1238 | $order = $dtt->order(); |
1239 | 1239 | $this->_template_args['data']['items']['ID-'.$order] = $dtt->ID(); |
1240 | 1240 | } |
1241 | - $this->_template_args['data']['items']['datetime_IDS'] = serialize( $dtt_ids ); |
|
1241 | + $this->_template_args['data']['items']['datetime_IDS'] = serialize($dtt_ids); |
|
1242 | 1242 | |
1243 | 1243 | //handle DECAF venues |
1244 | 1244 | //we need to make sure that the venue_id gets updated in the form so that future autosaves will properly conntect that venue to the event. |
1245 | - if ( $do_venue_autosaves = apply_filters( 'FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE ) ) { |
|
1245 | + if ($do_venue_autosaves = apply_filters('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE)) { |
|
1246 | 1246 | $venue = $event->get_first_related('Venue'); |
1247 | 1247 | $this->_template_args['data']['items']['venue-id'] = $venue->ID(); |
1248 | 1248 | } |
@@ -1253,23 +1253,23 @@ discard block |
||
1253 | 1253 | |
1254 | 1254 | $ticket_ids = array(); |
1255 | 1255 | $price_ids = array(); |
1256 | - foreach ( $tickets as $ticket ) { |
|
1256 | + foreach ($tickets as $ticket) { |
|
1257 | 1257 | $ticket_ids[] = $price->ID(); |
1258 | 1258 | $ticket_order = $price->get('TKT_order'); |
1259 | - $this->_template_args['data']['items']['edit-ticket-id-' . $ticket_order] = $ticket->ID(); |
|
1260 | - $this->_template_args['data']['items']['edit-ticket-event-id-' . $order] = $event->ID(); |
|
1259 | + $this->_template_args['data']['items']['edit-ticket-id-'.$ticket_order] = $ticket->ID(); |
|
1260 | + $this->_template_args['data']['items']['edit-ticket-event-id-'.$order] = $event->ID(); |
|
1261 | 1261 | |
1262 | 1262 | //now we have to make sure the prices are updated appropriately |
1263 | 1263 | $prices = $ticket->get_many_related('Prices'); |
1264 | 1264 | |
1265 | - foreach ( $prices as $price ) { |
|
1265 | + foreach ($prices as $price) { |
|
1266 | 1266 | $price_ids[] = $price->ID(); |
1267 | 1267 | $price_order = $price->get('PRC_order'); |
1268 | - $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-' . $ticket_order . '-' . $price_order] = $price->ID(); |
|
1269 | - $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-' . $ticket_row . '-' . $price_row] = $price->ID(); |
|
1270 | - $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-' . $ticket_row . '-' . $price_row] = $price->get('PRC_is_default'); |
|
1268 | + $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-'.$ticket_order.'-'.$price_order] = $price->ID(); |
|
1269 | + $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-'.$ticket_row.'-'.$price_row] = $price->ID(); |
|
1270 | + $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-'.$ticket_row.'-'.$price_row] = $price->get('PRC_is_default'); |
|
1271 | 1271 | } |
1272 | - $this->_template_args['data']['items']['price-IDs-ticketrow-' . $ticket_row] = implode(',', $price_ids); |
|
1272 | + $this->_template_args['data']['items']['price-IDs-ticketrow-'.$ticket_row] = implode(',', $price_ids); |
|
1273 | 1273 | } |
1274 | 1274 | $this->_template_args['data']['items']['ticket-IDs'] = implode(',', $ticket_ids); |
1275 | 1275 | } |
@@ -1287,12 +1287,12 @@ discard block |
||
1287 | 1287 | private function _generate_publish_box_extra_content() { |
1288 | 1288 | |
1289 | 1289 | //load formatter helper |
1290 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
1290 | + EE_Registry::instance()->load_helper('Formatter'); |
|
1291 | 1291 | |
1292 | 1292 | //args for getting related registrations |
1293 | - $approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) ); |
|
1294 | - $not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) ); |
|
1295 | - $pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) ); |
|
1293 | + $approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved)); |
|
1294 | + $not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved)); |
|
1295 | + $pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment)); |
|
1296 | 1296 | |
1297 | 1297 | |
1298 | 1298 | // publish box |
@@ -1321,9 +1321,9 @@ discard block |
||
1321 | 1321 | ), |
1322 | 1322 | REG_ADMIN_URL |
1323 | 1323 | ), |
1324 | - 'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ), |
|
1325 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ), |
|
1326 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ), |
|
1324 | + 'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args), |
|
1325 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args), |
|
1326 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args), |
|
1327 | 1327 | 'misc_pub_section_class' => apply_filters( |
1328 | 1328 | 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
1329 | 1329 | 'misc-pub-section' |
@@ -1342,9 +1342,9 @@ discard block |
||
1342 | 1342 | 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
1343 | 1343 | $this->_cpt_model_obj |
1344 | 1344 | ); |
1345 | - $publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean(); |
|
1345 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1346 | 1346 | // load template |
1347 | - EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args ); |
|
1347 | + EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args); |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | |
@@ -1376,16 +1376,16 @@ discard block |
||
1376 | 1376 | $this->verify_cpt_object(); |
1377 | 1377 | add_meta_box( |
1378 | 1378 | 'espresso_event_editor_tickets', |
1379 | - __( 'Event Datetime & Ticket', 'event_espresso' ), |
|
1380 | - array( $this, 'ticket_metabox' ), |
|
1379 | + __('Event Datetime & Ticket', 'event_espresso'), |
|
1380 | + array($this, 'ticket_metabox'), |
|
1381 | 1381 | $this->page_slug, |
1382 | 1382 | 'normal', |
1383 | 1383 | 'high' |
1384 | 1384 | ); |
1385 | 1385 | add_meta_box( |
1386 | 1386 | 'espresso_event_editor_event_options', |
1387 | - __( 'Event Registration Options', 'event_espresso' ), |
|
1388 | - array( $this, 'registration_options_meta_box' ), |
|
1387 | + __('Event Registration Options', 'event_espresso'), |
|
1388 | + array($this, 'registration_options_meta_box'), |
|
1389 | 1389 | $this->page_slug, |
1390 | 1390 | 'side', |
1391 | 1391 | 'default' |
@@ -1415,37 +1415,37 @@ discard block |
||
1415 | 1415 | 'disabled' => '' |
1416 | 1416 | ); |
1417 | 1417 | |
1418 | - $event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL; |
|
1418 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL; |
|
1419 | 1419 | |
1420 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1420 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1421 | 1421 | |
1422 | 1422 | /** |
1423 | 1423 | * 1. Start with retrieving Datetimes |
1424 | 1424 | * 2. Fore each datetime get related tickets |
1425 | 1425 | * 3. For each ticket get related prices |
1426 | 1426 | */ |
1427 | - $times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id ); |
|
1428 | - EE_Registry::instance()->load_helper('DTT_Helper' ); |
|
1427 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1428 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
1429 | 1429 | /** @type EE_Datetime $first_datetime */ |
1430 | - $first_datetime = reset( $times ); |
|
1430 | + $first_datetime = reset($times); |
|
1431 | 1431 | //do we get related tickets? |
1432 | - if ( $first_datetime instanceof EE_Datetime |
|
1433 | - && $first_datetime->ID() !== 0 ) { |
|
1432 | + if ($first_datetime instanceof EE_Datetime |
|
1433 | + && $first_datetime->ID() !== 0) { |
|
1434 | 1434 | $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
1435 | 1435 | $template_args['time'] = $first_datetime; |
1436 | 1436 | $related_tickets = $first_datetime->tickets( |
1437 | 1437 | array( |
1438 | - array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), |
|
1438 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1439 | 1439 | 'default_where_conditions' => 'none' |
1440 | 1440 | ) |
1441 | 1441 | ); |
1442 | 1442 | |
1443 | - if ( !empty($related_tickets) ) { |
|
1443 | + if ( ! empty($related_tickets)) { |
|
1444 | 1444 | $template_args['total_ticket_rows'] = count($related_tickets); |
1445 | 1445 | $row = 0; |
1446 | - foreach ( $related_tickets as $ticket ) { |
|
1446 | + foreach ($related_tickets as $ticket) { |
|
1447 | 1447 | $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
1448 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row ); |
|
1448 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row); |
|
1449 | 1449 | |
1450 | 1450 | $row++; |
1451 | 1451 | } |
@@ -1453,13 +1453,13 @@ discard block |
||
1453 | 1453 | $template_args['total_ticket_rows'] = 1; |
1454 | 1454 | /** @type EE_Ticket $ticket */ |
1455 | 1455 | $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
1456 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket ); |
|
1456 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1457 | 1457 | } |
1458 | 1458 | } else { |
1459 | 1459 | $template_args['time'] = $times[0]; |
1460 | 1460 | /** @type EE_Ticket $ticket */ |
1461 | 1461 | $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
1462 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] ); |
|
1462 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1463 | 1463 | // NOTE: we're just sending the first default row |
1464 | 1464 | // (decaf can't manage default tickets so this should be sufficient); |
1465 | 1465 | } |
@@ -1468,8 +1468,8 @@ discard block |
||
1468 | 1468 | $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
1469 | 1469 | $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
1470 | 1470 | $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
1471 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE ); |
|
1472 | - $template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' ); |
|
1471 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE); |
|
1472 | + $template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'); |
|
1473 | 1473 | EEH_Template::display_template($template, $template_args); |
1474 | 1474 | } |
1475 | 1475 | |
@@ -1484,21 +1484,21 @@ discard block |
||
1484 | 1484 | * @param int $row |
1485 | 1485 | * @return string generated html for the ticket row. |
1486 | 1486 | */ |
1487 | - private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) { |
|
1487 | + private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) { |
|
1488 | 1488 | $template_args = array( |
1489 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1490 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '', |
|
1489 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1490 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '', |
|
1491 | 1491 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
1492 | 1492 | 'TKT_ID' => $ticket->get('TKT_ID'), |
1493 | 1493 | 'TKT_name' => $ticket->get('TKT_name'), |
1494 | 1494 | 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
1495 | 1495 | 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
1496 | 1496 | 'TKT_is_default' => $ticket->get('TKT_is_default'), |
1497 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty','input'), |
|
1497 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1498 | 1498 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
1499 | 1499 | 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
1500 | - 'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1501 | - 'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled' |
|
1500 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1501 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled' |
|
1502 | 1502 | ); |
1503 | 1503 | |
1504 | 1504 | $price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object(); |
@@ -1514,23 +1514,23 @@ discard block |
||
1514 | 1514 | |
1515 | 1515 | //make sure we have default start and end dates if skeleton |
1516 | 1516 | //handle rows that should NOT be empty |
1517 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1517 | + if (empty($template_args['TKT_start_date'])) { |
|
1518 | 1518 | //if empty then the start date will be now. |
1519 | 1519 | $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
1520 | 1520 | } |
1521 | 1521 | |
1522 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1522 | + if (empty($template_args['TKT_end_date'])) { |
|
1523 | 1523 | //get the earliest datetime (if present); |
1524 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1524 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1525 | 1525 | |
1526 | - if ( !empty( $earliest_dtt ) ) |
|
1526 | + if ( ! empty($earliest_dtt)) |
|
1527 | 1527 | $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
1528 | 1528 | else |
1529 | - $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
|
1529 | + $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))); |
|
1530 | 1530 | } |
1531 | 1531 | |
1532 | - $template_args = array_merge( $template_args, $price_args ); |
|
1533 | - $template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1532 | + $template_args = array_merge($template_args, $price_args); |
|
1533 | + $template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1534 | 1534 | return EEH_Template::display_template($template, $template_args, TRUE); |
1535 | 1535 | } |
1536 | 1536 | |
@@ -1559,8 +1559,8 @@ discard block |
||
1559 | 1559 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
1560 | 1560 | $template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description()); |
1561 | 1561 | $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false); |
1562 | - $template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values ); |
|
1563 | - $templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php'; |
|
1562 | + $template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values); |
|
1563 | + $templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php'; |
|
1564 | 1564 | EEH_Template::display_template($templatepath, $template_args); |
1565 | 1565 | } |
1566 | 1566 | |
@@ -1588,21 +1588,21 @@ discard block |
||
1588 | 1588 | $EEME = $this->_event_model(); |
1589 | 1589 | |
1590 | 1590 | $offset = ($current_page - 1) * $per_page; |
1591 | - $limit = $count ? NULL : $offset . ',' . $per_page; |
|
1591 | + $limit = $count ? NULL : $offset.','.$per_page; |
|
1592 | 1592 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
1593 | 1593 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
1594 | 1594 | |
1595 | 1595 | if (isset($this->_req_data['month_range'])) { |
1596 | 1596 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
1597 | - $month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1598 | - $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
|
1597 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1598 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1599 | 1599 | } |
1600 | 1600 | |
1601 | 1601 | $where = array(); |
1602 | 1602 | |
1603 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
1603 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
1604 | 1604 | //determine what post_status our condition will have for the query. |
1605 | - switch ( $status ) { |
|
1605 | + switch ($status) { |
|
1606 | 1606 | case 'month' : |
1607 | 1607 | case 'today' : |
1608 | 1608 | case NULL : |
@@ -1610,7 +1610,7 @@ discard block |
||
1610 | 1610 | break; |
1611 | 1611 | |
1612 | 1612 | case 'draft' : |
1613 | - $where['status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1613 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1614 | 1614 | break; |
1615 | 1615 | |
1616 | 1616 | default : |
@@ -1618,43 +1618,43 @@ discard block |
||
1618 | 1618 | } |
1619 | 1619 | |
1620 | 1620 | //categories? |
1621 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1621 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1622 | 1622 | |
1623 | - if ( !empty ( $category ) ) { |
|
1623 | + if ( ! empty ($category)) { |
|
1624 | 1624 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1625 | 1625 | $where['Term_Taxonomy.term_id'] = $category; |
1626 | 1626 | } |
1627 | 1627 | |
1628 | 1628 | //date where conditions |
1629 | - $start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' ); |
|
1629 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1630 | 1630 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
1631 | - $DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) ); |
|
1632 | - $start = $DateTime->format( implode( ' ', $start_formats ) ); |
|
1633 | - $end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) ); |
|
1634 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) ); |
|
1631 | + $DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone())); |
|
1632 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1633 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1634 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1635 | 1635 | } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
1636 | - $DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1637 | - $start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) ); |
|
1638 | - $end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1639 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1640 | - } else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) { |
|
1641 | - $now = date( 'Y-m-01' ); |
|
1642 | - $DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1643 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1644 | - $end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1645 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1636 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1637 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1638 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1639 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1640 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1641 | + $now = date('Y-m-01'); |
|
1642 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1643 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1644 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1645 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | |
1649 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1650 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1649 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1650 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1651 | 1651 | } else { |
1652 | - if ( ! isset( $where['status'] ) ) { |
|
1653 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
1652 | + if ( ! isset($where['status'])) { |
|
1653 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1654 | 1654 | $where['OR'] = array( |
1655 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1655 | + 'status*restrict_private' => array('!=', 'private'), |
|
1656 | 1656 | 'AND' => array( |
1657 | - 'status*inclusive' => array( '=', 'private' ), |
|
1657 | + 'status*inclusive' => array('=', 'private'), |
|
1658 | 1658 | 'EVT_wp_user' => get_current_user_id() |
1659 | 1659 | ) |
1660 | 1660 | ); |
@@ -1662,16 +1662,16 @@ discard block |
||
1662 | 1662 | } |
1663 | 1663 | } |
1664 | 1664 | |
1665 | - if ( isset( $this->_req_data['EVT_wp_user'] ) ) { |
|
1666 | - if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1665 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1666 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1667 | 1667 | $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
1668 | 1668 | } |
1669 | 1669 | } |
1670 | 1670 | |
1671 | 1671 | |
1672 | 1672 | //search query handling |
1673 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1674 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1673 | + if (isset($this->_req_data['s'])) { |
|
1674 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1675 | 1675 | $where['OR'] = array( |
1676 | 1676 | 'EVT_name' => array('LIKE', $search_string), |
1677 | 1677 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1680,32 +1680,32 @@ discard block |
||
1680 | 1680 | } |
1681 | 1681 | |
1682 | 1682 | |
1683 | - $where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data ); |
|
1684 | - $query_params = apply_filters( 'FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID' ), $this->_req_data ); |
|
1683 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1684 | + $query_params = apply_filters('FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID'), $this->_req_data); |
|
1685 | 1685 | |
1686 | 1686 | |
1687 | 1687 | //let's first check if we have special requests coming in. |
1688 | - if ( isset( $this->_req_data['active_status'] ) ) { |
|
1689 | - switch ( $this->_req_data['active_status'] ) { |
|
1688 | + if (isset($this->_req_data['active_status'])) { |
|
1689 | + switch ($this->_req_data['active_status']) { |
|
1690 | 1690 | case 'upcoming' : |
1691 | - return $EEME->get_upcoming_events( $query_params, $count ); |
|
1691 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1692 | 1692 | break; |
1693 | 1693 | |
1694 | 1694 | case 'expired' : |
1695 | - return $EEME->get_expired_events( $query_params, $count ); |
|
1695 | + return $EEME->get_expired_events($query_params, $count); |
|
1696 | 1696 | break; |
1697 | 1697 | |
1698 | 1698 | case 'active' : |
1699 | - return $EEME->get_active_events( $query_params, $count ); |
|
1699 | + return $EEME->get_active_events($query_params, $count); |
|
1700 | 1700 | break; |
1701 | 1701 | |
1702 | 1702 | case 'inactive' : |
1703 | - return $EEME->get_inactive_events( $query_params, $count ); |
|
1703 | + return $EEME->get_inactive_events($query_params, $count); |
|
1704 | 1704 | break; |
1705 | 1705 | } |
1706 | 1706 | } |
1707 | 1707 | |
1708 | - $events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params ); |
|
1708 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1709 | 1709 | |
1710 | 1710 | return $events; |
1711 | 1711 | } |
@@ -1714,23 +1714,23 @@ discard block |
||
1714 | 1714 | |
1715 | 1715 | |
1716 | 1716 | //handling for WordPress CPT actions (trash, restore, delete) |
1717 | - public function trash_cpt_item( $post_id ) { |
|
1717 | + public function trash_cpt_item($post_id) { |
|
1718 | 1718 | $this->_req_data['EVT_ID'] = $post_id; |
1719 | - $this->_trash_or_restore_event( 'trash', FALSE ); |
|
1719 | + $this->_trash_or_restore_event('trash', FALSE); |
|
1720 | 1720 | } |
1721 | 1721 | |
1722 | 1722 | |
1723 | 1723 | |
1724 | 1724 | |
1725 | - public function restore_cpt_item( $post_id ) { |
|
1725 | + public function restore_cpt_item($post_id) { |
|
1726 | 1726 | $this->_req_data['EVT_ID'] = $post_id; |
1727 | - $this->_trash_or_restore_event( 'draft', FALSE ); |
|
1727 | + $this->_trash_or_restore_event('draft', FALSE); |
|
1728 | 1728 | } |
1729 | 1729 | |
1730 | 1730 | |
1731 | - public function delete_cpt_item( $post_id ) { |
|
1731 | + public function delete_cpt_item($post_id) { |
|
1732 | 1732 | $this->_req_data['EVT_ID'] = $post_id; |
1733 | - $this->_delete_event( FALSE ); |
|
1733 | + $this->_delete_event(FALSE); |
|
1734 | 1734 | } |
1735 | 1735 | |
1736 | 1736 | |
@@ -1742,7 +1742,7 @@ discard block |
||
1742 | 1742 | * @param string $event_status |
1743 | 1743 | * @return void |
1744 | 1744 | */ |
1745 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) { |
|
1745 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) { |
|
1746 | 1746 | //determine the event id and set to array. |
1747 | 1747 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE; |
1748 | 1748 | // loop thru events |
@@ -1750,7 +1750,7 @@ discard block |
||
1750 | 1750 | // clean status |
1751 | 1751 | $event_status = sanitize_key($event_status); |
1752 | 1752 | // grab status |
1753 | - if (!empty($event_status)) { |
|
1753 | + if ( ! empty($event_status)) { |
|
1754 | 1754 | $success = $this->_change_event_status($EVT_ID, $event_status); |
1755 | 1755 | } else { |
1756 | 1756 | $success = FALSE; |
@@ -1764,7 +1764,7 @@ discard block |
||
1764 | 1764 | } |
1765 | 1765 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1766 | 1766 | |
1767 | - if ( $redirect_after ) |
|
1767 | + if ($redirect_after) |
|
1768 | 1768 | $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
1769 | 1769 | } |
1770 | 1770 | |
@@ -1779,7 +1779,7 @@ discard block |
||
1779 | 1779 | // clean status |
1780 | 1780 | $event_status = sanitize_key($event_status); |
1781 | 1781 | // grab status |
1782 | - if (!empty($event_status)) { |
|
1782 | + if ( ! empty($event_status)) { |
|
1783 | 1783 | $success = TRUE; |
1784 | 1784 | //determine the event id and set to array. |
1785 | 1785 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
@@ -1814,15 +1814,15 @@ discard block |
||
1814 | 1814 | * @param string $event_status |
1815 | 1815 | * @return bool |
1816 | 1816 | */ |
1817 | - private function _change_event_status( $EVT_ID = 0, $event_status = '') { |
|
1817 | + private function _change_event_status($EVT_ID = 0, $event_status = '') { |
|
1818 | 1818 | // grab event id |
1819 | - if (!$EVT_ID) { |
|
1819 | + if ( ! $EVT_ID) { |
|
1820 | 1820 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1821 | 1821 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1822 | 1822 | return FALSE; |
1823 | 1823 | } |
1824 | 1824 | |
1825 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1825 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1826 | 1826 | |
1827 | 1827 | // clean status |
1828 | 1828 | $event_status = sanitize_key($event_status); |
@@ -1848,7 +1848,7 @@ discard block |
||
1848 | 1848 | $hook = FALSE; |
1849 | 1849 | } |
1850 | 1850 | //use class to change status |
1851 | - $this->_cpt_model_obj->set_status( $event_status ); |
|
1851 | + $this->_cpt_model_obj->set_status($event_status); |
|
1852 | 1852 | $success = $this->_cpt_model_obj->save(); |
1853 | 1853 | |
1854 | 1854 | if ($success === FALSE) { |
@@ -1870,15 +1870,15 @@ discard block |
||
1870 | 1870 | * @access protected |
1871 | 1871 | * @param bool $redirect_after |
1872 | 1872 | */ |
1873 | - protected function _delete_event( $redirect_after = TRUE ) { |
|
1873 | + protected function _delete_event($redirect_after = TRUE) { |
|
1874 | 1874 | //determine the event id and set to array. |
1875 | 1875 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL; |
1876 | - $EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID; |
|
1876 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
1877 | 1877 | |
1878 | 1878 | |
1879 | 1879 | // loop thru events |
1880 | 1880 | if ($EVT_ID) { |
1881 | - $success = $this->_permanently_delete_event( $EVT_ID ); |
|
1881 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
1882 | 1882 | // get list of events with no prices |
1883 | 1883 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
1884 | 1884 | // remove this event from the list of events with no prices |
@@ -1892,7 +1892,7 @@ discard block |
||
1892 | 1892 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1893 | 1893 | } |
1894 | 1894 | |
1895 | - if ( $redirect_after ) |
|
1895 | + if ($redirect_after) |
|
1896 | 1896 | $this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash')); |
1897 | 1897 | } |
1898 | 1898 | |
@@ -1910,12 +1910,12 @@ discard block |
||
1910 | 1910 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
1911 | 1911 | // loop thru events |
1912 | 1912 | foreach ($EVT_IDs as $EVT_ID) { |
1913 | - $EVT_ID = absint( $EVT_ID ); |
|
1914 | - if ( $EVT_ID ) { |
|
1915 | - $results = $this->_permanently_delete_event( $EVT_ID ); |
|
1913 | + $EVT_ID = absint($EVT_ID); |
|
1914 | + if ($EVT_ID) { |
|
1915 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
1916 | 1916 | $success = $results !== FALSE ? $success : FALSE; |
1917 | 1917 | // remove this event from the list of events with no prices |
1918 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
1918 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
1919 | 1919 | } else { |
1920 | 1920 | $success = FALSE; |
1921 | 1921 | $msg = __('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso'); |
@@ -1935,9 +1935,9 @@ discard block |
||
1935 | 1935 | * @param int $EVT_ID |
1936 | 1936 | * @return bool |
1937 | 1937 | */ |
1938 | - private function _permanently_delete_event( $EVT_ID = 0 ) { |
|
1938 | + private function _permanently_delete_event($EVT_ID = 0) { |
|
1939 | 1939 | // grab event id |
1940 | - if ( ! $EVT_ID ) { |
|
1940 | + if ( ! $EVT_ID) { |
|
1941 | 1941 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1942 | 1942 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1943 | 1943 | return FALSE; |
@@ -1946,19 +1946,19 @@ discard block |
||
1946 | 1946 | ! $this->_cpt_model_obj instanceof EE_Event |
1947 | 1947 | || $this->_cpt_model_obj->ID() !== $EVT_ID |
1948 | 1948 | ) { |
1949 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1949 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1950 | 1950 | } |
1951 | 1951 | |
1952 | - if ( ! $this->_cpt_model instanceof EE_Event ) { |
|
1952 | + if ( ! $this->_cpt_model instanceof EE_Event) { |
|
1953 | 1953 | return false; |
1954 | 1954 | } |
1955 | 1955 | |
1956 | 1956 | //need to delete related tickets and prices first. |
1957 | 1957 | $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
1958 | - foreach ( $datetimes as $datetime ) { |
|
1958 | + foreach ($datetimes as $datetime) { |
|
1959 | 1959 | $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
1960 | 1960 | $tickets = $datetime->get_many_related('Ticket'); |
1961 | - foreach ( $tickets as $ticket ) { |
|
1961 | + foreach ($tickets as $ticket) { |
|
1962 | 1962 | $ticket->_remove_relation_to($datetime, 'Datetime'); |
1963 | 1963 | $ticket->delete_related_permanently('Price'); |
1964 | 1964 | $ticket->delete_permanently(); |
@@ -1968,14 +1968,14 @@ discard block |
||
1968 | 1968 | |
1969 | 1969 | //what about related venues or terms? |
1970 | 1970 | $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
1971 | - foreach ( $venues as $venue ) { |
|
1971 | + foreach ($venues as $venue) { |
|
1972 | 1972 | $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
1973 | 1973 | } |
1974 | 1974 | |
1975 | 1975 | //any attached question groups? |
1976 | 1976 | $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
1977 | - if ( !empty( $question_groups ) ) { |
|
1978 | - foreach ( $question_groups as $question_group ) { |
|
1977 | + if ( ! empty($question_groups)) { |
|
1978 | + foreach ($question_groups as $question_group) { |
|
1979 | 1979 | $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
1980 | 1980 | } |
1981 | 1981 | } |
@@ -1984,12 +1984,12 @@ discard block |
||
1984 | 1984 | |
1985 | 1985 | |
1986 | 1986 | //Message Template Groups |
1987 | - $this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' ); |
|
1987 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
1988 | 1988 | |
1989 | 1989 | /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
1990 | 1990 | $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
1991 | 1991 | |
1992 | - foreach ( $term_taxonomies as $term_taxonomy ) { |
|
1992 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
1993 | 1993 | $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
1994 | 1994 | } |
1995 | 1995 | |
@@ -2003,7 +2003,7 @@ discard block |
||
2003 | 2003 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
2004 | 2004 | return FALSE; |
2005 | 2005 | } |
2006 | - do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID ); |
|
2006 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2007 | 2007 | return TRUE; |
2008 | 2008 | } |
2009 | 2009 | |
@@ -2020,7 +2020,7 @@ discard block |
||
2020 | 2020 | */ |
2021 | 2021 | public function total_events() { |
2022 | 2022 | |
2023 | - $count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2023 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2024 | 2024 | return $count; |
2025 | 2025 | } |
2026 | 2026 | |
@@ -2035,10 +2035,10 @@ discard block |
||
2035 | 2035 | */ |
2036 | 2036 | public function total_events_draft() { |
2037 | 2037 | $where = array( |
2038 | - 'status' => array( 'IN', array('draft', 'auto-draft' ) ) |
|
2038 | + 'status' => array('IN', array('draft', 'auto-draft')) |
|
2039 | 2039 | ); |
2040 | 2040 | |
2041 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2041 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2042 | 2042 | return $count; |
2043 | 2043 | } |
2044 | 2044 | |
@@ -2057,7 +2057,7 @@ discard block |
||
2057 | 2057 | 'status' => 'trash' |
2058 | 2058 | ); |
2059 | 2059 | |
2060 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2060 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2061 | 2061 | return $count; |
2062 | 2062 | } |
2063 | 2063 | |
@@ -2085,11 +2085,11 @@ discard block |
||
2085 | 2085 | // translated |
2086 | 2086 | TRUE |
2087 | 2087 | ); |
2088 | - $this->_template_args['default_reg_status'] = isset( EE_Registry::instance()->CFG->registration->default_STS_ID ) ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) : EEM_Registration::status_id_pending_payment; |
|
2088 | + $this->_template_args['default_reg_status'] = isset(EE_Registry::instance()->CFG->registration->default_STS_ID) ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) : EEM_Registration::status_id_pending_payment; |
|
2089 | 2089 | |
2090 | 2090 | $this->_set_add_edit_form_tags('update_default_event_settings'); |
2091 | 2091 | $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
2092 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE); |
|
2092 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE); |
|
2093 | 2093 | $this->display_admin_page_with_sidebar(); |
2094 | 2094 | } |
2095 | 2095 | |
@@ -2115,9 +2115,9 @@ discard block |
||
2115 | 2115 | |
2116 | 2116 | protected function _template_settings() { |
2117 | 2117 | $this->_admin_page_title = __('Template Settings (Preview)', 'event_espresso'); |
2118 | - $this->_template_args['preview_img'] = '<img src="' . EVENTS_ASSETS_URL . DS . 'images' . DS . 'caffeinated_template_features.jpg" alt="' . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) . '" />'; |
|
2119 | - $this->_template_args['preview_text'] = '<strong>'.__( 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso' ).'</strong>'; |
|
2120 | - $this->display_admin_caf_preview_page( 'template_settings_tab' ); |
|
2118 | + $this->_template_args['preview_img'] = '<img src="'.EVENTS_ASSETS_URL.DS.'images'.DS.'caffeinated_template_features.jpg" alt="'.esc_attr__('Template Settings Preview screenshot', 'event_espresso').'" />'; |
|
2119 | + $this->_template_args['preview_text'] = '<strong>'.__('Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso').'</strong>'; |
|
2120 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2121 | 2121 | } |
2122 | 2122 | |
2123 | 2123 | |
@@ -2130,22 +2130,22 @@ discard block |
||
2130 | 2130 | * @return void |
2131 | 2131 | */ |
2132 | 2132 | private function _set_category_object() { |
2133 | - if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
2133 | + if (isset($this->_category->id) && ! empty($this->_category->id)) |
|
2134 | 2134 | return; //already have the category object so get out. |
2135 | 2135 | |
2136 | 2136 | //set default category object |
2137 | 2137 | $this->_set_empty_category_object(); |
2138 | 2138 | |
2139 | 2139 | //only set if we've got an id |
2140 | - if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) { |
|
2140 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2141 | 2141 | return; |
2142 | 2142 | } |
2143 | 2143 | |
2144 | 2144 | $category_id = absint($this->_req_data['EVT_CAT_ID']); |
2145 | 2145 | |
2146 | - $term = get_term( $category_id, 'espresso_event_categories' ); |
|
2146 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2147 | 2147 | |
2148 | - if ( !empty( $term ) ) { |
|
2148 | + if ( ! empty($term)) { |
|
2149 | 2149 | $this->_category->category_name = $term->name; |
2150 | 2150 | $this->_category->category_identifier = $term->slug; |
2151 | 2151 | $this->_category->category_desc = $term->description; |
@@ -2159,13 +2159,13 @@ discard block |
||
2159 | 2159 | |
2160 | 2160 | private function _set_empty_category_object() { |
2161 | 2161 | $this->_category = new stdClass(); |
2162 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2162 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2163 | 2163 | $this->_category->id = $this->_category->parent = 0; |
2164 | 2164 | } |
2165 | 2165 | |
2166 | 2166 | |
2167 | 2167 | protected function _category_list_table() { |
2168 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2168 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2169 | 2169 | $this->_search_btn_label = __('Categories', 'event_espresso'); |
2170 | 2170 | $this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2'); |
2171 | 2171 | $this->display_admin_list_table_page_with_sidebar(); |
@@ -2175,22 +2175,22 @@ discard block |
||
2175 | 2175 | protected function _category_details($view) { |
2176 | 2176 | |
2177 | 2177 | //load formatter helper |
2178 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
2178 | + EE_Registry::instance()->load_helper('Formatter'); |
|
2179 | 2179 | //load field generator helper |
2180 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
2180 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
2181 | 2181 | |
2182 | 2182 | $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
2183 | 2183 | $this->_set_add_edit_form_tags($route); |
2184 | 2184 | |
2185 | 2185 | $this->_set_category_object(); |
2186 | - $id = !empty($this->_category->id) ? $this->_category->id : ''; |
|
2186 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2187 | 2187 | |
2188 | 2188 | $delete_action = 'delete_category'; |
2189 | 2189 | |
2190 | 2190 | //custom redirect |
2191 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url ); |
|
2191 | + $redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url); |
|
2192 | 2192 | |
2193 | - $this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect ); |
|
2193 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2194 | 2194 | |
2195 | 2195 | //take care of contents |
2196 | 2196 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
@@ -2204,25 +2204,25 @@ discard block |
||
2204 | 2204 | 'type' => 'wp_editor', |
2205 | 2205 | 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
2206 | 2206 | 'class' => 'my_editor_custom', |
2207 | - 'wpeditor_args' => array('media_buttons' => FALSE ) |
|
2207 | + 'wpeditor_args' => array('media_buttons' => FALSE) |
|
2208 | 2208 | ); |
2209 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
2209 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2210 | 2210 | |
2211 | - $all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) ); |
|
2211 | + $all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id))); |
|
2212 | 2212 | |
2213 | 2213 | //setup category select for term parents. |
2214 | 2214 | $category_select_values[] = array( |
2215 | 2215 | 'text' => __('No Parent', 'event_espresso'), |
2216 | 2216 | 'id' => 0 |
2217 | 2217 | ); |
2218 | - foreach ( $all_terms as $term ) { |
|
2218 | + foreach ($all_terms as $term) { |
|
2219 | 2219 | $category_select_values[] = array( |
2220 | 2220 | 'text' => $term->name, |
2221 | 2221 | 'id' => $term->term_id |
2222 | 2222 | ); |
2223 | 2223 | } |
2224 | 2224 | |
2225 | - $category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent ); |
|
2225 | + $category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent); |
|
2226 | 2226 | |
2227 | 2227 | $template_args = array( |
2228 | 2228 | 'category' => $this->_category, |
@@ -2232,15 +2232,15 @@ discard block |
||
2232 | 2232 | 'disable' => '', |
2233 | 2233 | 'disabled_message' => FALSE |
2234 | 2234 | ); |
2235 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2236 | - return EEH_Template::display_template($template, $template_args, TRUE ); |
|
2235 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2236 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
2237 | 2237 | } |
2238 | 2238 | |
2239 | 2239 | |
2240 | 2240 | protected function _delete_categories() { |
2241 | - $cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2241 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2242 | 2242 | |
2243 | - foreach ( $cat_ids as $cat_id ) { |
|
2243 | + foreach ($cat_ids as $cat_id) { |
|
2244 | 2244 | $this->_delete_category($cat_id); |
2245 | 2245 | } |
2246 | 2246 | |
@@ -2248,7 +2248,7 @@ discard block |
||
2248 | 2248 | $query_args = array( |
2249 | 2249 | 'action' => 'category_list' |
2250 | 2250 | ); |
2251 | - $this->_redirect_after_action(0,'','',$query_args); |
|
2251 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2252 | 2252 | |
2253 | 2253 | } |
2254 | 2254 | |
@@ -2258,61 +2258,61 @@ discard block |
||
2258 | 2258 | |
2259 | 2259 | protected function _delete_category($cat_id) { |
2260 | 2260 | global $wpdb; |
2261 | - $cat_id = absint( $cat_id ); |
|
2262 | - wp_delete_term( $cat_id, 'espresso_event_categories' ); |
|
2261 | + $cat_id = absint($cat_id); |
|
2262 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2263 | 2263 | } |
2264 | 2264 | |
2265 | 2265 | |
2266 | 2266 | |
2267 | 2267 | protected function _insert_or_update_category($new_category) { |
2268 | 2268 | |
2269 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE ); |
|
2269 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE); |
|
2270 | 2270 | $success = 0; //we already have a success message so lets not send another. |
2271 | 2271 | |
2272 | - if ( $cat_id ) { |
|
2272 | + if ($cat_id) { |
|
2273 | 2273 | $query_args = array( |
2274 | 2274 | 'action' => 'edit_category', |
2275 | 2275 | 'EVT_CAT_ID' => $cat_id |
2276 | 2276 | ); |
2277 | 2277 | } else { |
2278 | - $query_args = array( 'action' => 'add_category' ); |
|
2278 | + $query_args = array('action' => 'add_category'); |
|
2279 | 2279 | } |
2280 | - $this->_redirect_after_action( $success, '','', $query_args, TRUE ); |
|
2280 | + $this->_redirect_after_action($success, '', '', $query_args, TRUE); |
|
2281 | 2281 | |
2282 | 2282 | } |
2283 | 2283 | |
2284 | 2284 | |
2285 | 2285 | |
2286 | - private function _insert_category( $update = FALSE ) { |
|
2286 | + private function _insert_category($update = FALSE) { |
|
2287 | 2287 | $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
2288 | - $category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
2289 | - $category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
2290 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
2288 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2289 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2290 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2291 | 2291 | |
2292 | - if ( empty( $category_name ) ) { |
|
2293 | - $msg = __( 'You must add a name for the category.', 'event_espresso' ); |
|
2294 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2292 | + if (empty($category_name)) { |
|
2293 | + $msg = __('You must add a name for the category.', 'event_espresso'); |
|
2294 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2295 | 2295 | return false; |
2296 | 2296 | } |
2297 | 2297 | |
2298 | - $term_args=array( |
|
2298 | + $term_args = array( |
|
2299 | 2299 | 'name'=>$category_name, |
2300 | 2300 | 'description'=>$category_desc, |
2301 | 2301 | 'parent'=>$category_parent |
2302 | 2302 | ); |
2303 | 2303 | //was the category_identifier input disabled? |
2304 | - if(isset($this->_req_data['category_identifier'])){ |
|
2304 | + if (isset($this->_req_data['category_identifier'])) { |
|
2305 | 2305 | $term_args['slug'] = $this->_req_data['category_identifier']; |
2306 | 2306 | } |
2307 | - $insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args ); |
|
2307 | + $insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2308 | 2308 | |
2309 | - if ( !is_array( $insert_ids ) ) { |
|
2310 | - $msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' ); |
|
2311 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2309 | + if ( ! is_array($insert_ids)) { |
|
2310 | + $msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso'); |
|
2311 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2312 | 2312 | } else { |
2313 | 2313 | $cat_id = $insert_ids['term_id']; |
2314 | - $msg = sprintf ( __('The category %s was successfuly saved', 'event_espresso'), $category_name ); |
|
2315 | - EE_Error::add_success( $msg ); |
|
2314 | + $msg = sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name); |
|
2315 | + EE_Error::add_success($msg); |
|
2316 | 2316 | } |
2317 | 2317 | |
2318 | 2318 | return $cat_id; |
@@ -2321,32 +2321,32 @@ discard block |
||
2321 | 2321 | |
2322 | 2322 | |
2323 | 2323 | |
2324 | - public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) { |
|
2324 | + public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) { |
|
2325 | 2325 | global $wpdb; |
2326 | 2326 | |
2327 | 2327 | //testing term stuff |
2328 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2329 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
2330 | - $limit = ($current_page-1)*$per_page; |
|
2328 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2329 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2330 | + $limit = ($current_page - 1) * $per_page; |
|
2331 | 2331 | |
2332 | - $where = array( 'taxonomy' => 'espresso_event_categories' ); |
|
2332 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2333 | 2333 | |
2334 | - if ( isset( $this->_req_data['s'] ) ) { |
|
2335 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2334 | + if (isset($this->_req_data['s'])) { |
|
2335 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2336 | 2336 | $where['OR'] = array( |
2337 | - 'Term.name' => array( 'LIKE', $sstr), |
|
2338 | - 'description' => array( 'LIKE', $sstr ) |
|
2337 | + 'Term.name' => array('LIKE', $sstr), |
|
2338 | + 'description' => array('LIKE', $sstr) |
|
2339 | 2339 | ); |
2340 | 2340 | } |
2341 | 2341 | |
2342 | 2342 | $query_params = array( |
2343 | - $where , |
|
2344 | - 'order_by' => array( $orderby => $order ), |
|
2345 | - 'limit' => $limit . ',' . $per_page, |
|
2343 | + $where, |
|
2344 | + 'order_by' => array($orderby => $order), |
|
2345 | + 'limit' => $limit.','.$per_page, |
|
2346 | 2346 | 'force_join' => array('Term') |
2347 | 2347 | ); |
2348 | 2348 | |
2349 | - $categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
2349 | + $categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2350 | 2350 | |
2351 | 2351 | return $categories; |
2352 | 2352 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @param EE_Checkout $checkout |
21 | 21 | * @return \EE_SPCO_Reg_Step_Finalize_Registration |
22 | 22 | */ |
23 | - public function __construct( EE_Checkout $checkout ) { |
|
23 | + public function __construct(EE_Checkout $checkout) { |
|
24 | 24 | $this->_slug = 'finalize_registration'; |
25 | 25 | $this->_name = __('Finalize Registration', 'event_espresso'); |
26 | 26 | $this->_submit_button_text = $this->_name; |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function initialize_reg_step() { |
48 | 48 | // there's actually no reg form to process if this is the final step |
49 | - if ( $this->is_current_step() ) { |
|
49 | + if ($this->is_current_step()) { |
|
50 | 50 | $this->checkout->step = $_REQUEST['step'] = $this->slug(); |
51 | - $this->checkout->action = $_REQUEST[ 'action' ] = 'process_reg_step'; |
|
51 | + $this->checkout->action = $_REQUEST['action'] = 'process_reg_step'; |
|
52 | 52 | $this->checkout->generate_reg_form = false; |
53 | 53 | } |
54 | 54 | return true; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function process_reg_step() { |
73 | 73 | // ensure all data gets refreshed from the db |
74 | - $this->checkout->refresh_all_entities( true ); |
|
74 | + $this->checkout->refresh_all_entities(true); |
|
75 | 75 | // ensures that all details and statuses for transaction, registration, and payments are updated |
76 | 76 | $txn_update_params = $this->_finalize_transaction(); |
77 | 77 | // DEBUG LOG |
@@ -85,16 +85,16 @@ discard block |
||
85 | 85 | // ) |
86 | 86 | //); |
87 | 87 | // set a hook point |
88 | - do_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', $this->checkout, $txn_update_params ); |
|
88 | + do_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', $this->checkout, $txn_update_params); |
|
89 | 89 | // check if transaction has a primary registrant and that it has a related Attendee object |
90 | - if ( $this->checkout->transaction_has_primary_registrant() ) { |
|
90 | + if ($this->checkout->transaction_has_primary_registrant()) { |
|
91 | 91 | // setup URL for redirect |
92 | 92 | $this->checkout->redirect_url = add_query_arg( |
93 | - array( 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link() ), |
|
93 | + array('e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link()), |
|
94 | 94 | $this->checkout->thank_you_page_url |
95 | 95 | ); |
96 | 96 | } else { |
97 | - EE_Error::add_error( __( 'A valid Primary Registration for this Transaction could not be found.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
97 | + EE_Error::add_error(__('A valid Primary Registration for this Transaction could not be found.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
98 | 98 | $this->checkout->redirect = false; |
99 | 99 | $this->checkout->continue_reg = false; |
100 | 100 | return false; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | // you don't have to go home but you can't stay here ! |
103 | 103 | $this->checkout->redirect = true; |
104 | 104 | $this->checkout->continue_reg = true; |
105 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
106 | - if ( ! ( $this->checkout->payment_method instanceof EE_Payment_Method && $this->checkout->payment_method->is_off_site() ) ) { |
|
105 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
106 | + if ( ! ($this->checkout->payment_method instanceof EE_Payment_Method && $this->checkout->payment_method->is_off_site())) { |
|
107 | 107 | // mark this reg step as completed |
108 | 108 | $this->set_completed(); |
109 | 109 | } |
@@ -120,24 +120,24 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected function _finalize_transaction() { |
122 | 122 | /** @type EE_Transaction_Processor $transaction_processor */ |
123 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
123 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
124 | 124 | //set revisit flag in txn processor |
125 | - $transaction_processor->set_revisit( $this->checkout->revisit ); |
|
125 | + $transaction_processor->set_revisit($this->checkout->revisit); |
|
126 | 126 | // at this point we'll consider a TXN to not have been abandoned |
127 | - $transaction_processor->toggle_abandoned_transaction_status( $this->checkout->transaction ); |
|
128 | - if ( $this->checkout->cart instanceof EE_Cart ) { |
|
127 | + $transaction_processor->toggle_abandoned_transaction_status($this->checkout->transaction); |
|
128 | + if ($this->checkout->cart instanceof EE_Cart) { |
|
129 | 129 | // save TXN data to the cart |
130 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $this->checkout->transaction->ID() ); |
|
130 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($this->checkout->transaction->ID()); |
|
131 | 131 | } |
132 | 132 | /** @type EE_Transaction_Payments $transaction_payments */ |
133 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
133 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
134 | 134 | // maybe update status, but don't save transaction just yet |
135 | - $transaction_payments->update_transaction_status_based_on_total_paid( $this->checkout->transaction, false ); |
|
135 | + $transaction_payments->update_transaction_status_based_on_total_paid($this->checkout->transaction, false); |
|
136 | 136 | // If the selected method of payment used an off-site gateway... |
137 | - if ( $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
138 | - $is_revisit = filter_var( $this->checkout->revisit, FILTER_VALIDATE_BOOLEAN ); |
|
139 | - if ( $this->checkout->payment_method->is_off_site() ) { |
|
140 | - $gateway= $this->checkout->payment_method->type_obj()->get_gateway(); |
|
137 | + if ($this->checkout->payment_method instanceof EE_Payment_Method) { |
|
138 | + $is_revisit = filter_var($this->checkout->revisit, FILTER_VALIDATE_BOOLEAN); |
|
139 | + if ($this->checkout->payment_method->is_off_site()) { |
|
140 | + $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
|
141 | 141 | if ( |
142 | 142 | ! $is_revisit |
143 | 143 | && $gateway instanceof EE_Offsite_Gateway |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | ) |
148 | 148 | ) { |
149 | 149 | // first time through SPCO and we are processing the payment notification NOW |
150 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
150 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
151 | 151 | } else { |
152 | 152 | // do NOT trigger notifications because this is a revisit, OR it was already done during the IPN |
153 | - remove_all_filters( 'FHEE__EED_Messages___maybe_registration__deliver_notifications' ); |
|
153 | + remove_all_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications'); |
|
154 | 154 | add_filter( |
155 | 155 | 'FHEE__EED_Messages___maybe_registration__deliver_notifications', |
156 | 156 | '__return_false', |
@@ -159,16 +159,16 @@ discard block |
||
159 | 159 | } |
160 | 160 | } else if ( |
161 | 161 | // if SPCO revisit and TXN status has changed due to a payment |
162 | - $is_revisit && ( $this->checkout->txn_status_updated || $this->checkout->any_reg_status_updated() ) |
|
162 | + $is_revisit && ($this->checkout->txn_status_updated || $this->checkout->any_reg_status_updated()) |
|
163 | 163 | ) { |
164 | 164 | // send out notifications |
165 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
166 | - } else if ( ! $is_revisit ) { |
|
167 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
165 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
166 | + } else if ( ! $is_revisit) { |
|
167 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | // this will result in the base session properties getting saved to the TXN_Session_data field |
171 | - $this->checkout->transaction->set_txn_session_data( EE_Registry::instance()->SSN->get_session_data( null, true )); |
|
171 | + $this->checkout->transaction->set_txn_session_data(EE_Registry::instance()->SSN->get_session_data(null, true)); |
|
172 | 172 | |
173 | 173 | // update the TXN if payment conditions have changed |
174 | 174 | return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @return boolean |
186 | 186 | */ |
187 | 187 | public function update_reg_step() { |
188 | - EE_Error::doing_it_wrong( __CLASS__ . '::' . __FILE__, __( 'Can not call update_reg_step() on the Finalize Registration reg step.', 'event_espresso'), '4.6.0' ); |
|
188 | + EE_Error::doing_it_wrong(__CLASS__.'::'.__FILE__, __('Can not call update_reg_step() on the Finalize Registration reg step.', 'event_espresso'), '4.6.0'); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 |