@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Paypal Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group' ); |
|
27 | + protected $supports = array('subscription', 'sandbox', 'single_subscription_group'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Payment method order. |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @var array |
61 | 61 | */ |
62 | - public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ); |
|
62 | + public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR'); |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * URL to view a transaction. |
@@ -80,17 +80,17 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function __construct() { |
82 | 82 | |
83 | - $this->title = __( 'PayPal Standard', 'invoicing' ); |
|
84 | - $this->method_title = __( 'PayPal Standard', 'invoicing' ); |
|
85 | - $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' ); |
|
86 | - $this->notify_url = wpinv_get_ipn_url( $this->id ); |
|
87 | - |
|
88 | - add_filter( 'wpinv_subscription_cancel_url', array( $this, 'filter_cancel_subscription_url' ), 10, 2 ); |
|
89 | - add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 ); |
|
90 | - add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
|
91 | - add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 ); |
|
92 | - add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) ); |
|
93 | - add_action( 'wpinv_paypal_connect', array( $this, 'display_connect_buttons' ) ); |
|
83 | + $this->title = __('PayPal Standard', 'invoicing'); |
|
84 | + $this->method_title = __('PayPal Standard', 'invoicing'); |
|
85 | + $this->checkout_button_text = __('Proceed to PayPal', 'invoicing'); |
|
86 | + $this->notify_url = wpinv_get_ipn_url($this->id); |
|
87 | + |
|
88 | + add_filter('wpinv_subscription_cancel_url', array($this, 'filter_cancel_subscription_url'), 10, 2); |
|
89 | + add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2); |
|
90 | + add_filter('getpaid_paypal_sandbox_notice', array($this, 'sandbox_notice')); |
|
91 | + add_filter('getpaid_get_paypal_connect_url', array($this, 'maybe_get_connect_url'), 10, 2); |
|
92 | + add_action('getpaid_authenticated_admin_action_connect_paypal', array($this, 'connect_paypal')); |
|
93 | + add_action('wpinv_paypal_connect', array($this, 'display_connect_buttons')); |
|
94 | 94 | parent::__construct(); |
95 | 95 | } |
96 | 96 | |
@@ -103,16 +103,16 @@ discard block |
||
103 | 103 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
104 | 104 | * @return array |
105 | 105 | */ |
106 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
106 | + public function process_payment($invoice, $submission_data, $submission) { |
|
107 | 107 | |
108 | 108 | // Get redirect url. |
109 | - $paypal_redirect = $this->get_request_url( $invoice ); |
|
109 | + $paypal_redirect = $this->get_request_url($invoice); |
|
110 | 110 | |
111 | 111 | // Add a note about the request url. |
112 | 112 | $invoice->add_note( |
113 | 113 | sprintf( |
114 | - __( 'Redirecting to PayPal: %s', 'invoicing' ), |
|
115 | - esc_url( $paypal_redirect ) |
|
114 | + __('Redirecting to PayPal: %s', 'invoicing'), |
|
115 | + esc_url($paypal_redirect) |
|
116 | 116 | ), |
117 | 117 | false, |
118 | 118 | false, |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | ); |
121 | 121 | |
122 | 122 | // Redirect to PayPal |
123 | - wp_redirect( $paypal_redirect ); |
|
123 | + wp_redirect($paypal_redirect); |
|
124 | 124 | exit; |
125 | 125 | |
126 | 126 | } |
@@ -131,21 +131,21 @@ discard block |
||
131 | 131 | * @param WPInv_Invoice $invoice Invoice object. |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - public function get_request_url( $invoice ) { |
|
134 | + public function get_request_url($invoice) { |
|
135 | 135 | |
136 | 136 | // Endpoint for this request |
137 | - $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
137 | + $this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
138 | 138 | |
139 | 139 | // Retrieve paypal args. |
140 | - $paypal_args = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' ); |
|
140 | + $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode'); |
|
141 | 141 | |
142 | - if ( $invoice->is_recurring() ) { |
|
142 | + if ($invoice->is_recurring()) { |
|
143 | 143 | $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US'; |
144 | 144 | } else { |
145 | 145 | $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US'; |
146 | 146 | } |
147 | 147 | |
148 | - return add_query_arg( $paypal_args, $this->endpoint ); |
|
148 | + return add_query_arg($paypal_args, $this->endpoint); |
|
149 | 149 | |
150 | 150 | } |
151 | 151 | |
@@ -155,25 +155,25 @@ discard block |
||
155 | 155 | * @param WPInv_Invoice $invoice Invoice object. |
156 | 156 | * @return array |
157 | 157 | */ |
158 | - protected function get_paypal_args( $invoice ) { |
|
158 | + protected function get_paypal_args($invoice) { |
|
159 | 159 | |
160 | 160 | // Whether or not to send the line items as one item. |
161 | - $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice ); |
|
161 | + $force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', true, $invoice); |
|
162 | 162 | |
163 | - if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) { |
|
163 | + if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) { |
|
164 | 164 | $force_one_line_item = true; |
165 | 165 | } |
166 | 166 | |
167 | 167 | $paypal_args = apply_filters( |
168 | 168 | 'getpaid_paypal_args', |
169 | 169 | array_merge( |
170 | - $this->get_transaction_args( $invoice ), |
|
171 | - $this->get_line_item_args( $invoice, $force_one_line_item ) |
|
170 | + $this->get_transaction_args($invoice), |
|
171 | + $this->get_line_item_args($invoice, $force_one_line_item) |
|
172 | 172 | ), |
173 | 173 | $invoice |
174 | 174 | ); |
175 | 175 | |
176 | - return $this->fix_request_length( $invoice, $paypal_args ); |
|
176 | + return $this->fix_request_length($invoice, $paypal_args); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | * @param WPInv_Invoice $invoice Invoice object. |
183 | 183 | * @return array |
184 | 184 | */ |
185 | - protected function get_transaction_args( $invoice ) { |
|
185 | + protected function get_transaction_args($invoice) { |
|
186 | 186 | |
187 | - $email = $this->is_sandbox( $invoice ) ? wpinv_get_option( 'paypal_sandbox_email', wpinv_get_option( 'paypal_email', '' ) ) : wpinv_get_option( 'paypal_email', '' ); |
|
187 | + $email = $this->is_sandbox($invoice) ? wpinv_get_option('paypal_sandbox_email', wpinv_get_option('paypal_email', '')) : wpinv_get_option('paypal_email', ''); |
|
188 | 188 | return array( |
189 | 189 | 'cmd' => '_cart', |
190 | 190 | 'business' => $email, |
@@ -195,16 +195,16 @@ discard block |
||
195 | 195 | 'rm' => is_ssl() ? 2 : 1, |
196 | 196 | 'upload' => 1, |
197 | 197 | 'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal |
198 | - 'return' => esc_url_raw( $this->get_return_url( $invoice ) ), |
|
199 | - 'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ), |
|
200 | - 'notify_url' => getpaid_limit_length( $this->notify_url, 255 ), |
|
201 | - 'invoice' => getpaid_limit_length( $invoice->get_number(), 127 ), |
|
198 | + 'return' => esc_url_raw($this->get_return_url($invoice)), |
|
199 | + 'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()), |
|
200 | + 'notify_url' => getpaid_limit_length($this->notify_url, 255), |
|
201 | + 'invoice' => getpaid_limit_length($invoice->get_number(), 127), |
|
202 | 202 | 'custom' => $invoice->get_id(), |
203 | - 'first_name' => getpaid_limit_length( $invoice->get_first_name(), 32 ), |
|
204 | - 'last_name' => getpaid_limit_length( $invoice->get_last_name(), 64 ), |
|
205 | - 'country' => getpaid_limit_length( $invoice->get_country(), 2 ), |
|
206 | - 'email' => getpaid_limit_length( $invoice->get_email(), 127 ), |
|
207 | - 'cbt' => get_bloginfo( 'name' ), |
|
203 | + 'first_name' => getpaid_limit_length($invoice->get_first_name(), 32), |
|
204 | + 'last_name' => getpaid_limit_length($invoice->get_last_name(), 64), |
|
205 | + 'country' => getpaid_limit_length($invoice->get_country(), 2), |
|
206 | + 'email' => getpaid_limit_length($invoice->get_email(), 127), |
|
207 | + 'cbt' => get_bloginfo('name'), |
|
208 | 208 | ); |
209 | 209 | |
210 | 210 | } |
@@ -216,30 +216,30 @@ discard block |
||
216 | 216 | * @param bool $force_one_line_item Create only one item for this invoice. |
217 | 217 | * @return array |
218 | 218 | */ |
219 | - protected function get_line_item_args( $invoice, $force_one_line_item = false ) { |
|
219 | + protected function get_line_item_args($invoice, $force_one_line_item = false) { |
|
220 | 220 | |
221 | 221 | // Maybe send invoice as a single item. |
222 | - if ( $force_one_line_item ) { |
|
223 | - return $this->get_line_item_args_single_item( $invoice ); |
|
222 | + if ($force_one_line_item) { |
|
223 | + return $this->get_line_item_args_single_item($invoice); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | // Send each line item individually. |
227 | 227 | $line_item_args = array(); |
228 | 228 | |
229 | 229 | // Prepare line items. |
230 | - $this->prepare_line_items( $invoice ); |
|
230 | + $this->prepare_line_items($invoice); |
|
231 | 231 | |
232 | 232 | // Add taxes to the cart |
233 | - if ( wpinv_use_taxes() && $invoice->is_taxable() ) { |
|
234 | - $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 ); |
|
233 | + if (wpinv_use_taxes() && $invoice->is_taxable()) { |
|
234 | + $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | // Add discount. |
238 | - if ( $invoice->get_total_discount() > 0 ) { |
|
239 | - $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 ); |
|
238 | + if ($invoice->get_total_discount() > 0) { |
|
239 | + $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2); |
|
240 | 240 | } |
241 | 241 | |
242 | - return array_merge( $line_item_args, $this->get_line_items() ); |
|
242 | + return array_merge($line_item_args, $this->get_line_items()); |
|
243 | 243 | |
244 | 244 | } |
245 | 245 | |
@@ -249,11 +249,11 @@ discard block |
||
249 | 249 | * @param WPInv_Invoice $invoice Invoice object. |
250 | 250 | * @return array |
251 | 251 | */ |
252 | - protected function get_line_item_args_single_item( $invoice ) { |
|
252 | + protected function get_line_item_args_single_item($invoice) { |
|
253 | 253 | $this->delete_line_items(); |
254 | 254 | |
255 | - $item_name = wp_sprintf( __( 'Invoice %s', 'invoicing' ), $invoice->get_number() ); |
|
256 | - $this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() ); |
|
255 | + $item_name = wp_sprintf(__('Invoice %s', 'invoicing'), $invoice->get_number()); |
|
256 | + $this->add_line_item($item_name, 1, wpinv_round_amount((float) $invoice->get_total(), 2, true), $invoice->get_id()); |
|
257 | 257 | |
258 | 258 | return $this->get_line_items(); |
259 | 259 | } |
@@ -277,19 +277,19 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @param WPInv_Invoice $invoice Invoice object. |
279 | 279 | */ |
280 | - protected function prepare_line_items( $invoice ) { |
|
280 | + protected function prepare_line_items($invoice) { |
|
281 | 281 | $this->delete_line_items(); |
282 | 282 | |
283 | 283 | // Items. |
284 | - foreach ( $invoice->get_items() as $item ) { |
|
284 | + foreach ($invoice->get_items() as $item) { |
|
285 | 285 | $amount = $item->get_price(); |
286 | 286 | $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(); |
287 | - $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() ); |
|
287 | + $this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id()); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | // Fees. |
291 | - foreach ( $invoice->get_fees() as $fee => $data ) { |
|
292 | - $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) ); |
|
291 | + foreach ($invoice->get_fees() as $fee => $data) { |
|
292 | + $this->add_line_item($fee, 1, wpinv_sanitize_amount($data['initial_fee'])); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | } |
@@ -302,20 +302,20 @@ discard block |
||
302 | 302 | * @param float $amount Amount. |
303 | 303 | * @param string $item_number Item number. |
304 | 304 | */ |
305 | - protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { |
|
306 | - $index = ( count( $this->line_items ) / 4 ) + 1; |
|
305 | + protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') { |
|
306 | + $index = (count($this->line_items) / 4) + 1; |
|
307 | 307 | |
308 | 308 | /** |
309 | 309 | * Prevent error "Things don't appear to be working at the moment. (https://www.sandbox.paypal.com/webapps/hermes/error)" |
310 | 310 | */ |
311 | - $item_name = str_replace( "#", "", $item_name ); |
|
311 | + $item_name = str_replace("#", "", $item_name); |
|
312 | 312 | |
313 | 313 | $item = apply_filters( |
314 | 314 | 'getpaid_paypal_line_item', |
315 | 315 | array( |
316 | - 'item_name' => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), |
|
316 | + 'item_name' => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'), |
|
317 | 317 | 'quantity' => (float) $quantity, |
318 | - 'amount' => wpinv_sanitize_amount( (float) $amount, 2 ), |
|
318 | + 'amount' => wpinv_sanitize_amount((float) $amount, 2), |
|
319 | 319 | 'item_number' => $item_number, |
320 | 320 | ), |
321 | 321 | $item_name, |
@@ -324,12 +324,12 @@ discard block |
||
324 | 324 | $item_number |
325 | 325 | ); |
326 | 326 | |
327 | - $this->line_items[ 'item_name_' . $index ] = getpaid_limit_length( $item['item_name'], 127 ); |
|
328 | - $this->line_items[ 'quantity_' . $index ] = $item['quantity']; |
|
327 | + $this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127); |
|
328 | + $this->line_items['quantity_' . $index] = $item['quantity']; |
|
329 | 329 | |
330 | 330 | // The price or amount of the product, service, or contribution, not including shipping, handling, or tax. |
331 | - $this->line_items[ 'amount_' . $index ] = $item['amount'] * $item['quantity']; |
|
332 | - $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 ); |
|
331 | + $this->line_items['amount_' . $index] = $item['amount'] * $item['quantity']; |
|
332 | + $this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
@@ -341,19 +341,19 @@ discard block |
||
341 | 341 | * @param array $paypal_args Arguments sent to Paypal in the request. |
342 | 342 | * @return array |
343 | 343 | */ |
344 | - protected function fix_request_length( $invoice, $paypal_args ) { |
|
344 | + protected function fix_request_length($invoice, $paypal_args) { |
|
345 | 345 | $max_paypal_length = 2083; |
346 | - $query_candidate = http_build_query( $paypal_args, '', '&' ); |
|
346 | + $query_candidate = http_build_query($paypal_args, '', '&'); |
|
347 | 347 | |
348 | - if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { |
|
348 | + if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) { |
|
349 | 349 | return $paypal_args; |
350 | 350 | } |
351 | 351 | |
352 | 352 | return apply_filters( |
353 | 353 | 'getpaid_paypal_args', |
354 | 354 | array_merge( |
355 | - $this->get_transaction_args( $invoice ), |
|
356 | - $this->get_line_item_args( $invoice, true ) |
|
355 | + $this->get_transaction_args($invoice), |
|
356 | + $this->get_line_item_args($invoice, true) |
|
357 | 357 | ), |
358 | 358 | $invoice |
359 | 359 | ); |
@@ -366,10 +366,10 @@ discard block |
||
366 | 366 | * @param array $paypal_args PayPal args. |
367 | 367 | * @param WPInv_Invoice $invoice Invoice object. |
368 | 368 | */ |
369 | - public function process_subscription( $paypal_args, $invoice ) { |
|
369 | + public function process_subscription($paypal_args, $invoice) { |
|
370 | 370 | |
371 | 371 | // Make sure this is a subscription. |
372 | - if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) { |
|
372 | + if (!$invoice->is_recurring() || !$subscription = getpaid_get_invoice_subscription($invoice)) { |
|
373 | 373 | return $paypal_args; |
374 | 374 | } |
375 | 375 | |
@@ -377,23 +377,23 @@ discard block |
||
377 | 377 | $paypal_args['cmd'] = '_xclick-subscriptions'; |
378 | 378 | |
379 | 379 | // Subscription name. |
380 | - $paypal_args['item_name'] = wp_sprintf( __( 'Invoice %s', 'invoicing' ), $invoice->get_number() ); |
|
380 | + $paypal_args['item_name'] = wp_sprintf(__('Invoice %s', 'invoicing'), $invoice->get_number()); |
|
381 | 381 | |
382 | 382 | // Get subscription args. |
383 | - $period = strtoupper( substr( $subscription->get_period(), 0, 1 ) ); |
|
383 | + $period = strtoupper(substr($subscription->get_period(), 0, 1)); |
|
384 | 384 | $interval = (int) $subscription->get_frequency(); |
385 | 385 | $bill_times = (int) $subscription->get_bill_times(); |
386 | - $initial_amount = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 ); |
|
387 | - $recurring_amount = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 ); |
|
388 | - $subscription_item = $invoice->get_recurring( true ); |
|
386 | + $initial_amount = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2); |
|
387 | + $recurring_amount = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2); |
|
388 | + $subscription_item = $invoice->get_recurring(true); |
|
389 | 389 | |
390 | 390 | // Convert 365 days to 1 year. |
391 | - if ( 'D' == $period && 365 == $interval ) { |
|
391 | + if ('D' == $period && 365 == $interval) { |
|
392 | 392 | $period = 'Y'; |
393 | 393 | $interval = 1; |
394 | 394 | } |
395 | 395 | |
396 | - if ( $subscription_item->has_free_trial() ) { |
|
396 | + if ($subscription_item->has_free_trial()) { |
|
397 | 397 | |
398 | 398 | $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount; |
399 | 399 | |
@@ -403,28 +403,28 @@ discard block |
||
403 | 403 | // Trial period. |
404 | 404 | $paypal_args['t1'] = $subscription_item->get_trial_period(); |
405 | 405 | |
406 | - } elseif ( $initial_amount != $recurring_amount ) { |
|
406 | + } elseif ($initial_amount != $recurring_amount) { |
|
407 | 407 | |
408 | 408 | // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period. |
409 | 409 | |
410 | - if ( 1 == $bill_times ) { |
|
410 | + if (1 == $bill_times) { |
|
411 | 411 | $param_number = 3; |
412 | 412 | } else { |
413 | 413 | $param_number = 1; |
414 | 414 | } |
415 | 415 | |
416 | - $paypal_args[ 'a' . $param_number ] = $initial_amount ? $initial_amount : 0; |
|
416 | + $paypal_args['a' . $param_number] = $initial_amount ? $initial_amount : 0; |
|
417 | 417 | |
418 | 418 | // Sign Up interval |
419 | - $paypal_args[ 'p' . $param_number ] = $interval; |
|
419 | + $paypal_args['p' . $param_number] = $interval; |
|
420 | 420 | |
421 | 421 | // Sign Up unit of duration |
422 | - $paypal_args[ 't' . $param_number ] = $period; |
|
422 | + $paypal_args['t' . $param_number] = $period; |
|
423 | 423 | |
424 | 424 | } |
425 | 425 | |
426 | 426 | // We have a recurring payment |
427 | - if ( ! isset( $param_number ) || 1 == $param_number ) { |
|
427 | + if (!isset($param_number) || 1 == $param_number) { |
|
428 | 428 | |
429 | 429 | // Subscription price |
430 | 430 | $paypal_args['a3'] = $recurring_amount; |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | } |
439 | 439 | |
440 | 440 | // Recurring payments |
441 | - if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) { |
|
441 | + if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) { |
|
442 | 442 | |
443 | 443 | // Non-recurring payments |
444 | 444 | $paypal_args['src'] = 0; |
@@ -447,15 +447,15 @@ discard block |
||
447 | 447 | |
448 | 448 | $paypal_args['src'] = 1; |
449 | 449 | |
450 | - if ( $bill_times > 0 ) { |
|
450 | + if ($bill_times > 0) { |
|
451 | 451 | |
452 | 452 | // An initial period is being used to charge a sign-up fee |
453 | - if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) { |
|
453 | + if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) { |
|
454 | 454 | $bill_times--; |
455 | 455 | } |
456 | 456 | |
457 | 457 | // Make sure it's not over the max of 52 |
458 | - $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 ); |
|
458 | + $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52); |
|
459 | 459 | |
460 | 460 | } |
461 | 461 | } |
@@ -464,10 +464,10 @@ discard block |
||
464 | 464 | $paypal_args['rm'] = 2; |
465 | 465 | |
466 | 466 | // Get rid of redudant items. |
467 | - foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) { |
|
467 | + foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) { |
|
468 | 468 | |
469 | - if ( isset( $paypal_args[ $arg ] ) ) { |
|
470 | - unset( $paypal_args[ $arg ] ); |
|
469 | + if (isset($paypal_args[$arg])) { |
|
470 | + unset($paypal_args[$arg]); |
|
471 | 471 | } |
472 | 472 | } |
473 | 473 | |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | * @return void |
486 | 486 | */ |
487 | 487 | public function verify_ipn() { |
488 | - new GetPaid_Paypal_Gateway_IPN_Handler( $this ); |
|
488 | + new GetPaid_Paypal_Gateway_IPN_Handler($this); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | public function sandbox_notice() { |
495 | 495 | |
496 | 496 | return sprintf( |
497 | - __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %1$sPayPal Sandbox Testing Guide%2$s for more details.', 'invoicing' ), |
|
497 | + __('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %1$sPayPal Sandbox Testing Guide%2$s for more details.', 'invoicing'), |
|
498 | 498 | '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">', |
499 | 499 | '</a>' |
500 | 500 | ); |
@@ -506,41 +506,41 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @param array $admin_settings |
508 | 508 | */ |
509 | - public function admin_settings( $admin_settings ) { |
|
509 | + public function admin_settings($admin_settings) { |
|
510 | 510 | |
511 | 511 | $currencies = sprintf( |
512 | - __( 'Supported Currencies: %s', 'invoicing' ), |
|
513 | - implode( ', ', $this->currencies ) |
|
512 | + __('Supported Currencies: %s', 'invoicing'), |
|
513 | + implode(', ', $this->currencies) |
|
514 | 514 | ); |
515 | 515 | |
516 | 516 | $admin_settings['paypal_active']['desc'] .= " ($currencies)"; |
517 | - $admin_settings['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' ); |
|
517 | + $admin_settings['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing'); |
|
518 | 518 | |
519 | 519 | // Access tokens. |
520 | - $live_email = wpinv_get_option( 'paypal_email' ); |
|
521 | - $sandbox_email = wpinv_get_option( 'paypal_sandbox_email' ); |
|
520 | + $live_email = wpinv_get_option('paypal_email'); |
|
521 | + $sandbox_email = wpinv_get_option('paypal_sandbox_email'); |
|
522 | 522 | |
523 | 523 | $admin_settings['paypal_connect'] = array( |
524 | 524 | 'type' => 'hook', |
525 | 525 | 'id' => 'paypal_connect', |
526 | - 'name' => __( 'Connect to PayPal', 'invoicing' ), |
|
526 | + 'name' => __('Connect to PayPal', 'invoicing'), |
|
527 | 527 | ); |
528 | 528 | |
529 | 529 | $admin_settings['paypal_email'] = array( |
530 | 530 | 'type' => 'text', |
531 | 531 | 'class' => 'live-auth-data', |
532 | 532 | 'id' => 'paypal_email', |
533 | - 'name' => __( 'Live Email Address', 'invoicing' ), |
|
534 | - 'desc' => __( 'The email address of your PayPal account.', 'invoicing' ), |
|
533 | + 'name' => __('Live Email Address', 'invoicing'), |
|
534 | + 'desc' => __('The email address of your PayPal account.', 'invoicing'), |
|
535 | 535 | ); |
536 | 536 | |
537 | 537 | $admin_settings['paypal_sandbox_email'] = array( |
538 | 538 | 'type' => 'text', |
539 | 539 | 'class' => 'sandbox-auth-data', |
540 | 540 | 'id' => 'paypal_sandbox_email', |
541 | - 'name' => __( 'Sandbox Email Address', 'invoicing' ), |
|
542 | - 'desc' => __( 'The email address of your sandbox PayPal account.', 'invoicing' ), |
|
543 | - 'std' => wpinv_get_option( 'paypal_email', '' ), |
|
541 | + 'name' => __('Sandbox Email Address', 'invoicing'), |
|
542 | + 'desc' => __('The email address of your sandbox PayPal account.', 'invoicing'), |
|
543 | + 'std' => wpinv_get_option('paypal_email', ''), |
|
544 | 544 | ); |
545 | 545 | |
546 | 546 | // Client ID and secret. |
@@ -548,41 +548,41 @@ discard block |
||
548 | 548 | 'type' => 'text', |
549 | 549 | 'class' => 'live-auth-data', |
550 | 550 | 'id' => 'paypal_client_id', |
551 | - 'name' => __( 'Live Client ID', 'invoicing' ), |
|
552 | - 'desc' => __( 'The client ID of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ), |
|
551 | + 'name' => __('Live Client ID', 'invoicing'), |
|
552 | + 'desc' => __('The client ID of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'), |
|
553 | 553 | ); |
554 | 554 | |
555 | 555 | $admin_settings['paypal_sandbox_client_id'] = array( |
556 | 556 | 'type' => 'text', |
557 | 557 | 'class' => 'sandbox-auth-data', |
558 | 558 | 'id' => 'paypal_sandbox_client_id', |
559 | - 'name' => __( 'Sandbox Client ID', 'invoicing' ), |
|
560 | - 'desc' => __( 'The client ID of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ), |
|
561 | - 'std' => wpinv_get_option( 'paypal_client_id', '' ), |
|
559 | + 'name' => __('Sandbox Client ID', 'invoicing'), |
|
560 | + 'desc' => __('The client ID of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'), |
|
561 | + 'std' => wpinv_get_option('paypal_client_id', ''), |
|
562 | 562 | ); |
563 | 563 | |
564 | 564 | $admin_settings['paypal_secret'] = array( |
565 | 565 | 'type' => 'text', |
566 | 566 | 'class' => 'live-auth-data', |
567 | 567 | 'id' => 'paypal_secret', |
568 | - 'name' => __( 'Live Secret', 'invoicing' ), |
|
569 | - 'desc' => __( 'The secret of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ), |
|
568 | + 'name' => __('Live Secret', 'invoicing'), |
|
569 | + 'desc' => __('The secret of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'), |
|
570 | 570 | ); |
571 | 571 | |
572 | 572 | $admin_settings['paypal_sandbox_secret'] = array( |
573 | 573 | 'type' => 'text', |
574 | 574 | 'class' => 'sandbox-auth-data', |
575 | 575 | 'id' => 'paypal_sandbox_secret', |
576 | - 'name' => __( 'Sandbox Secret', 'invoicing' ), |
|
577 | - 'desc' => __( 'The secret of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ), |
|
576 | + 'name' => __('Sandbox Secret', 'invoicing'), |
|
577 | + 'desc' => __('The secret of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'), |
|
578 | 578 | ); |
579 | 579 | |
580 | 580 | $admin_settings['paypal_ipn_url'] = array( |
581 | 581 | 'type' => 'ipn_url', |
582 | 582 | 'id' => 'paypal_ipn_url', |
583 | - 'name' => __( 'IPN Url', 'invoicing' ), |
|
583 | + 'name' => __('IPN Url', 'invoicing'), |
|
584 | 584 | 'std' => $this->notify_url, |
585 | - 'desc' => __( "If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing' ) . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
585 | + 'desc' => __("If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing') . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
586 | 586 | 'readonly' => true, |
587 | 587 | ); |
588 | 588 | |
@@ -595,9 +595,9 @@ discard block |
||
595 | 595 | * @param string $url |
596 | 596 | * @param WPInv_Subscription $subscription |
597 | 597 | */ |
598 | - public function filter_cancel_subscription_url( $url, $subscription ) { |
|
598 | + public function filter_cancel_subscription_url($url, $subscription) { |
|
599 | 599 | |
600 | - if ( $this->id !== $subscription->get_gateway() ) { |
|
600 | + if ($this->id !== $subscription->get_gateway()) { |
|
601 | 601 | return $url; |
602 | 602 | } |
603 | 603 | |
@@ -605,16 +605,16 @@ discard block |
||
605 | 605 | $profile_id = $subscription->get_profile_id(); |
606 | 606 | |
607 | 607 | // Bail if no profile ID. |
608 | - if ( empty( $profile_id ) ) { |
|
608 | + if (empty($profile_id)) { |
|
609 | 609 | return $url; |
610 | 610 | } |
611 | 611 | |
612 | 612 | $cancel_url = 'https://www.paypal.com/myaccount/autopay/connect/%s/cancel'; |
613 | - if ( $this->is_sandbox( $subscription->get_parent_payment() ) ) { |
|
613 | + if ($this->is_sandbox($subscription->get_parent_payment())) { |
|
614 | 614 | $cancel_url = 'https://www.sandbox.paypal.com/myaccount/autopay/connect/%s/cancel'; |
615 | 615 | } |
616 | 616 | |
617 | - return sprintf( $cancel_url, $profile_id ); |
|
617 | + return sprintf($cancel_url, $profile_id); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | /** |
@@ -624,8 +624,8 @@ discard block |
||
624 | 624 | * @param array $data |
625 | 625 | * @return string |
626 | 626 | */ |
627 | - public static function maybe_get_connect_url( $url = '', $data = array() ) { |
|
628 | - return self::get_connect_url( false, urldecode( $data['redirect'] ) ); |
|
627 | + public static function maybe_get_connect_url($url = '', $data = array()) { |
|
628 | + return self::get_connect_url(false, urldecode($data['redirect'])); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
@@ -636,25 +636,25 @@ discard block |
||
636 | 636 | * @param string $redirect |
637 | 637 | * @return string |
638 | 638 | */ |
639 | - public static function get_connect_url( $is_sandbox, $redirect = '' ) { |
|
639 | + public static function get_connect_url($is_sandbox, $redirect = '') { |
|
640 | 640 | |
641 | 641 | $redirect_url = add_query_arg( |
642 | 642 | array( |
643 | 643 | 'getpaid-admin-action' => 'connect_paypal', |
644 | 644 | 'page' => 'wpinv-settings', |
645 | - 'live_mode' => (int) empty( $is_sandbox ), |
|
645 | + 'live_mode' => (int) empty($is_sandbox), |
|
646 | 646 | 'tab' => 'gateways', |
647 | 647 | 'section' => 'paypal', |
648 | - 'getpaid-nonce' => wp_create_nonce( 'getpaid-nonce' ), |
|
649 | - 'redirect' => urlencode( $redirect ), |
|
648 | + 'getpaid-nonce' => wp_create_nonce('getpaid-nonce'), |
|
649 | + 'redirect' => urlencode($redirect), |
|
650 | 650 | ), |
651 | - admin_url( 'admin.php' ) |
|
651 | + admin_url('admin.php') |
|
652 | 652 | ); |
653 | 653 | |
654 | 654 | return add_query_arg( |
655 | 655 | array( |
656 | - 'live_mode' => (int) empty( $is_sandbox ), |
|
657 | - 'redirect_url' => urlencode( str_replace( '&', '&', $redirect_url ) ), |
|
656 | + 'live_mode' => (int) empty($is_sandbox), |
|
657 | + 'redirect_url' => urlencode(str_replace('&', '&', $redirect_url)), |
|
658 | 658 | ), |
659 | 659 | 'https://ayecode.io/oauth/paypal' |
660 | 660 | ); |
@@ -670,10 +670,10 @@ discard block |
||
670 | 670 | |
671 | 671 | ?> |
672 | 672 | <div class="wpinv-paypal-connect-live"> |
673 | - <a class="button button-primary" href="<?php echo esc_url( self::get_connect_url( false ) ); ?>"><?php esc_html_e( 'Connect to PayPal', 'invoicing' ); ?></a> |
|
673 | + <a class="button button-primary" href="<?php echo esc_url(self::get_connect_url(false)); ?>"><?php esc_html_e('Connect to PayPal', 'invoicing'); ?></a> |
|
674 | 674 | </div> |
675 | 675 | <div class="wpinv-paypal-connect-sandbox"> |
676 | - <a class="button button-primary" href="<?php echo esc_url( self::get_connect_url( true ) ); ?>"><?php esc_html_e( 'Connect to PayPal Sandbox', 'invoicing' ); ?></a> |
|
676 | + <a class="button button-primary" href="<?php echo esc_url(self::get_connect_url(true)); ?>"><?php esc_html_e('Connect to PayPal Sandbox', 'invoicing'); ?></a> |
|
677 | 677 | </div> |
678 | 678 | |
679 | 679 | <script> |
@@ -714,26 +714,26 @@ discard block |
||
714 | 714 | * @param array $data Connection data. |
715 | 715 | * @return void |
716 | 716 | */ |
717 | - public function connect_paypal( $data ) { |
|
717 | + public function connect_paypal($data) { |
|
718 | 718 | |
719 | 719 | $sandbox = $this->is_sandbox(); |
720 | - $data = wp_unslash( $data ); |
|
721 | - $access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] ); |
|
720 | + $data = wp_unslash($data); |
|
721 | + $access_token = empty($data['access_token']) ? '' : sanitize_text_field($data['access_token']); |
|
722 | 722 | |
723 | - if ( isset( $data['live_mode'] ) ) { |
|
724 | - $sandbox = empty( $data['live_mode'] ); |
|
723 | + if (isset($data['live_mode'])) { |
|
724 | + $sandbox = empty($data['live_mode']); |
|
725 | 725 | } |
726 | 726 | |
727 | - wpinv_update_option( 'paypal_sandbox', (int) $sandbox ); |
|
728 | - wpinv_update_option( 'paypal_active', 1 ); |
|
727 | + wpinv_update_option('paypal_sandbox', (int) $sandbox); |
|
728 | + wpinv_update_option('paypal_active', 1); |
|
729 | 729 | |
730 | - if ( ! empty( $data['error_description'] ) ) { |
|
731 | - getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) ); |
|
730 | + if (!empty($data['error_description'])) { |
|
731 | + getpaid_admin()->show_error(wp_kses_post(urldecode($data['error_description']))); |
|
732 | 732 | } else { |
733 | 733 | |
734 | 734 | // Retrieve the user info. |
735 | 735 | $user_info = wp_remote_get( |
736 | - ! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1', |
|
736 | + !$sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1', |
|
737 | 737 | array( |
738 | 738 | |
739 | 739 | 'headers' => array( |
@@ -744,33 +744,33 @@ discard block |
||
744 | 744 | ) |
745 | 745 | ); |
746 | 746 | |
747 | - if ( is_wp_error( $user_info ) ) { |
|
748 | - getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) ); |
|
747 | + if (is_wp_error($user_info)) { |
|
748 | + getpaid_admin()->show_error(wp_kses_post($user_info->get_error_message())); |
|
749 | 749 | } else { |
750 | 750 | |
751 | 751 | // Create application. |
752 | - $user_info = json_decode( wp_remote_retrieve_body( $user_info ) ); |
|
752 | + $user_info = json_decode(wp_remote_retrieve_body($user_info)); |
|
753 | 753 | |
754 | - if ( $sandbox ) { |
|
755 | - wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) ); |
|
756 | - wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) ); |
|
757 | - set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] ); |
|
758 | - getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) ); |
|
754 | + if ($sandbox) { |
|
755 | + wpinv_update_option('paypal_sandbox_email', sanitize_email($user_info->emails[0]->value)); |
|
756 | + wpinv_update_option('paypal_sandbox_refresh_token', sanitize_text_field(urldecode($data['refresh_token']))); |
|
757 | + set_transient('getpaid_paypal_sandbox_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']); |
|
758 | + getpaid_admin()->show_success(__('Successfully connected your PayPal sandbox account', 'invoicing')); |
|
759 | 759 | } else { |
760 | - wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) ); |
|
761 | - wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) ); |
|
762 | - set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] ); |
|
763 | - getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) ); |
|
760 | + wpinv_update_option('paypal_email', sanitize_email($user_info->emails[0]->value)); |
|
761 | + wpinv_update_option('paypal_refresh_token', sanitize_text_field(urldecode($data['refresh_token']))); |
|
762 | + set_transient('getpaid_paypal_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']); |
|
763 | + getpaid_admin()->show_success(__('Successfully connected your PayPal account', 'invoicing')); |
|
764 | 764 | } |
765 | 765 | } |
766 | 766 | } |
767 | 767 | |
768 | - $redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways§ion=paypal' ) : urldecode( $data['redirect'] ); |
|
768 | + $redirect = empty($data['redirect']) ? admin_url('admin.php?page=wpinv-settings&tab=gateways§ion=paypal') : urldecode($data['redirect']); |
|
769 | 769 | |
770 | - if ( isset( $data['step'] ) ) { |
|
771 | - $redirect = add_query_arg( 'step', $data['step'], $redirect ); |
|
770 | + if (isset($data['step'])) { |
|
771 | + $redirect = add_query_arg('step', $data['step'], $redirect); |
|
772 | 772 | } |
773 | - wp_redirect( $redirect ); |
|
773 | + wp_redirect($redirect); |
|
774 | 774 | exit; |
775 | 775 | } |
776 | 776 |
@@ -3,27 +3,27 @@ discard block |
||
3 | 3 | * Admin View: Page - Addons |
4 | 4 | * |
5 | 5 | */ |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | add_ThickBox(); |
10 | 10 | ?> |
11 | 11 | <div class="wrap wpi_addons_wrap"> |
12 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
12 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
13 | 13 | |
14 | - <?php if ( $tabs ) { ?> |
|
14 | + <?php if ($tabs) { ?> |
|
15 | 15 | <nav class="nav-tab-wrapper wpi-nav-tab-wrapper"> |
16 | 16 | <?php |
17 | - foreach ( $tabs as $name => $label ) { |
|
18 | - echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
|
17 | + foreach ($tabs as $name => $label) { |
|
18 | + echo '<a href="' . esc_url(admin_url('admin.php?page=wpi-addons&tab=' . $name)) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . esc_html($label) . '</a>'; |
|
19 | 19 | } |
20 | - do_action( 'wpi_addons_tabs' ); |
|
20 | + do_action('wpi_addons_tabs'); |
|
21 | 21 | ?> |
22 | 22 | </nav> |
23 | 23 | |
24 | 24 | <?php |
25 | 25 | |
26 | - if ( $current_tab == 'membership' ) { |
|
26 | + if ($current_tab == 'membership') { |
|
27 | 27 | |
28 | 28 | ?> |
29 | 29 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | <!-- |
33 | 33 | <h2>With our WPInvoicing Membership you get access to all our products!</h2> |
34 | 34 | <p><a class="button button-primary" href="https://wpinvoicing.com/downloads/membership/">View Memberships</a></p>--> |
35 | - <?php if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { ?> |
|
36 | - <h2><?php esc_html_e( 'Have a membership key?', 'invoicing' ); ?></h2> |
|
35 | + <?php if (defined('WP_EASY_UPDATES_ACTIVE')) { ?> |
|
36 | + <h2><?php esc_html_e('Have a membership key?', 'invoicing'); ?></h2> |
|
37 | 37 | <p> |
38 | 38 | <?php |
39 | - $wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' ); |
|
40 | - echo $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ); |
|
39 | + $wpeu_admin = new External_Updates_Admin('wpinvoicing.com', '1'); |
|
40 | + echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership', array(95, 106, 108, 12351)); |
|
41 | 41 | ?> |
42 | 42 | </p> |
43 | 43 | <?php } ?> |
44 | 44 | |
45 | 45 | <div class="membership-cta-contet"> |
46 | 46 | <div class="main-cta"> |
47 | - <h2><?php esc_html_e( 'Membership benefits Include:', 'invoicing' ); ?></h2> |
|
47 | + <h2><?php esc_html_e('Membership benefits Include:', 'invoicing'); ?></h2> |
|
48 | 48 | <div class="feature-list"> |
49 | 49 | <ul> |
50 | 50 | <?php |
51 | 51 | $addon_obj = new WPInv_Admin_Addons(); |
52 | - if ( $addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | - foreach ( $addons as $addon ) { |
|
54 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
52 | + if ($addons = $addon_obj->get_section_data('addons')) { |
|
53 | + foreach ($addons as $addon) { |
|
54 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | ?> |
58 | 58 | </ul> |
59 | 59 | |
60 | 60 | <div class="feature-cta"> |
61 | - <h3><?php esc_html_e( 'Membership Starts from', 'invoicing' ); ?></h3> |
|
61 | + <h3><?php esc_html_e('Membership Starts from', 'invoicing'); ?></h3> |
|
62 | 62 | <h4>$99</h4> |
63 | - <a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_attr_e( 'Buy Membership', 'invoicing' ); ?></a> |
|
63 | + <a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_attr_e('Buy Membership', 'invoicing'); ?></a> |
|
64 | 64 | </div> |
65 | - <h3><?php esc_html_e( 'Included Gateways:', 'invoicing' ); ?></h3> |
|
65 | + <h3><?php esc_html_e('Included Gateways:', 'invoicing'); ?></h3> |
|
66 | 66 | <ul> |
67 | 67 | <?php |
68 | - if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | - foreach ( $addons as $addon ) { |
|
70 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
68 | + if ($addons = $addon_obj->get_section_data('gateways')) { |
|
69 | + foreach ($addons as $addon) { |
|
70 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | ?> |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | <div class="testimonial-content"> |
82 | 82 | <div class="t-image"> |
83 | 83 | <?php |
84 | - echo '<img src="' . esc_url( plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) ) . '" > '; |
|
84 | + echo '<img src="' . esc_url(plugins_url('images/t-image2.png', dirname(__FILE__))) . '" > '; |
|
85 | 85 | ?> |
86 | 86 | </div> |
87 | 87 | <div class="t-content"> |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | <div class="testimonial-content"> |
102 | 102 | <div class="t-image"> |
103 | 103 | <?php |
104 | - echo '<img src="' . esc_url( plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) ) . '" > '; |
|
104 | + echo '<img src="' . esc_url(plugins_url('images/t-image1.png', dirname(__FILE__))) . '" > '; |
|
105 | 105 | ?> |
106 | 106 | </div> |
107 | 107 | <div class="t-content"> |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | </div> |
118 | 118 | </div> |
119 | 119 | <div class="member-footer"> |
120 | - <a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_html_e( 'Buy Membership', 'invoicing' ); ?></a> |
|
121 | - <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php esc_html_e( 'Create Invoice', 'invoicing' ); ?></a> |
|
120 | + <a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_html_e('Buy Membership', 'invoicing'); ?></a> |
|
121 | + <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php esc_html_e('Create Invoice', 'invoicing'); ?></a> |
|
122 | 122 | </div> |
123 | 123 | </div> |
124 | 124 | |
@@ -129,63 +129,63 @@ discard block |
||
129 | 129 | } else { |
130 | 130 | $installed_plugins = get_plugins(); |
131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
132 | - if ( $addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
132 | + if ($addons = $addon_obj->get_section_data($current_tab)) : |
|
133 | 133 | //print_r($addons); |
134 | 134 | ?> |
135 | 135 | <ul class="wpi-products"> |
136 | 136 | <?php |
137 | - foreach ( $addons as $addon ) : |
|
138 | - if ( 965 == $addon->info->id ) { |
|
139 | -continue;}// don't show quote add on |
|
137 | + foreach ($addons as $addon) : |
|
138 | + if (965 == $addon->info->id) { |
|
139 | +continue; }// don't show quote add on |
|
140 | 140 | ?> |
141 | 141 | <li class="wpi-product"> |
142 | 142 | <div class="wpi-product-title"> |
143 | 143 | <h3> |
144 | 144 | <?php |
145 | - if ( ! empty( $addon->info->excerpt ) ) { |
|
146 | - wpi_help_tip( $addon->info->excerpt, false, false, true ); |
|
145 | + if (!empty($addon->info->excerpt)) { |
|
146 | + wpi_help_tip($addon->info->excerpt, false, false, true); |
|
147 | 147 | } |
148 | - echo esc_html( $addon->info->title ); |
|
148 | + echo esc_html($addon->info->title); |
|
149 | 149 | ?> |
150 | 150 | </h3> |
151 | 151 | </div> |
152 | 152 | |
153 | 153 | <span class="wpi-product-image"> |
154 | - <?php if ( ! empty( $addon->info->thumbnail ) ) : ?> |
|
155 | - <img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/> |
|
154 | + <?php if (!empty($addon->info->thumbnail)) : ?> |
|
155 | + <img src="<?php echo esc_attr($addon->info->thumbnail); ?>"/> |
|
156 | 156 | <?php |
157 | 157 | endif; |
158 | 158 | |
159 | - if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
159 | + if ('stripe-payment-gateway' == $addon->info->slug) { |
|
160 | 160 | $addon->info->slug = 'getpaid-stripe-payments'; |
161 | 161 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
162 | 162 | } |
163 | - elseif( 'wallet' == $addon->info->slug ){ |
|
163 | + elseif ('wallet' == $addon->info->slug) { |
|
164 | 164 | $addon->info->slug = 'getpaid-wallet'; |
165 | 165 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-wallet/'; |
166 | 166 | } |
167 | - elseif( 'item-inventory' == $addon->info->slug ){ |
|
167 | + elseif ('item-inventory' == $addon->info->slug) { |
|
168 | 168 | $addon->info->slug = 'getpaid-item-inventory'; |
169 | 169 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-item-inventory/'; |
170 | 170 | } |
171 | 171 | |
172 | - if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) { |
|
173 | - echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
174 | - echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>'; |
|
172 | + if (isset($addon->info->link) && substr($addon->info->link, 0, 21) === 'https://wordpress.org') { |
|
173 | + echo '<a href="' . esc_url(admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug)) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
174 | + echo '<span class="wpi-product-info">' . esc_html__('More info', 'invoicing') . '</span>'; |
|
175 | 175 | echo '</a>'; |
176 | - } elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) { |
|
177 | - if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
178 | - $url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' ); |
|
176 | + } elseif (isset($addon->info->link) && (substr($addon->info->link, 0, 23) === 'https://wpinvoicing.com' || substr($addon->info->link, 0, 21) === 'https://wpgetpaid.com')) { |
|
177 | + if (defined('WP_EASY_UPDATES_ACTIVE')) { |
|
178 | + $url = admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true'); |
|
179 | 179 | } else { |
180 | 180 | // if installed show activation link |
181 | - if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) { |
|
181 | + if (isset($installed_plugins['wp-easy-updates/external-updates.php'])) { |
|
182 | 182 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
183 | 183 | } else { |
184 | 184 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
185 | 185 | } |
186 | 186 | } |
187 | - echo '<a href="' . esc_url( $url ) . '" class="thickbox">'; |
|
188 | - echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>'; |
|
187 | + echo '<a href="' . esc_url($url) . '" class="thickbox">'; |
|
188 | + echo '<span class="wpi-product-info">' . esc_html__('More info', 'invoicing') . '</span>'; |
|
189 | 189 | echo '</a>'; |
190 | 190 | } |
191 | 191 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | <span class="wpi-product-button"> |
198 | 198 | <?php |
199 | - $addon_obj->output_button( $addon ); |
|
199 | + $addon_obj->output_button($addon); |
|
200 | 200 | ?> |
201 | 201 | </span> |
202 | 202 | |
@@ -210,21 +210,21 @@ discard block |
||
210 | 210 | |
211 | 211 | <div class="clearfix" ></div> |
212 | 212 | |
213 | - <?php if ( $current_tab == 'addons' ) { ?> |
|
214 | - <p><?php printf( esc_attr__( 'All of our Addons can be found on wpGetPaid.com here: %sInvoicing Addons%s', 'invoicing' ), '<a href="https://wpinvoicing.com/downloads/category/addons/">','</a>' ); ?></p> |
|
215 | - <?php } if ( $current_tab == 'gateways' ) { ?> |
|
216 | - <p><?php printf( esc_attr__( 'All of our Payment Gateways can be found on wpGetPaid.com here: %sGetPaid Payment Gateways %s', 'invoicing' ), '<a href="https://wpinvoicing.com/downloads/category/gateways/">','</a>' ); ?></p> |
|
213 | + <?php if ($current_tab == 'addons') { ?> |
|
214 | + <p><?php printf(esc_attr__('All of our Addons can be found on wpGetPaid.com here: %sInvoicing Addons%s', 'invoicing'), '<a href="https://wpinvoicing.com/downloads/category/addons/">', '</a>'); ?></p> |
|
215 | + <?php } if ($current_tab == 'gateways') { ?> |
|
216 | + <p><?php printf(esc_attr__('All of our Payment Gateways can be found on wpGetPaid.com here: %sGetPaid Payment Gateways %s', 'invoicing'), '<a href="https://wpinvoicing.com/downloads/category/gateways/">', '</a>'); ?></p> |
|
217 | 217 | <?php } ?> |
218 | 218 | |
219 | - <div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post( sprintf( __( "The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing' ), wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php' ), 'activate-plugin_wp-easy-updates/external-updates.php' ) ) ); ?></span></div> |
|
220 | - <div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post( sprintf( __( "The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing' ), admin_url( 'plugin-install.php?tab=upload&wpeu-install=true' ) ) ); ?></span></div> |
|
219 | + <div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post(sprintf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing'), wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php'))); ?></span></div> |
|
220 | + <div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post(sprintf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing'), admin_url('plugin-install.php?tab=upload&wpeu-install=true'))); ?></span></div> |
|
221 | 221 | <div id="wpeu-licence-popup" style="display:none;"> |
222 | 222 | <span class="wpi-notification noti-white"> |
223 | - <h3 class="wpeu-licence-title"><?php esc_html_e( 'Licence key', 'invoicing' ); ?></h3> |
|
224 | - <input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e( 'Enter your licence key', 'invoicing' ); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e( 'Install', 'invoicing' ); ?></button> |
|
223 | + <h3 class="wpeu-licence-title"><?php esc_html_e('Licence key', 'invoicing'); ?></h3> |
|
224 | + <input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e('Enter your licence key', 'invoicing'); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e('Install', 'invoicing'); ?></button> |
|
225 | 225 | <br> |
226 | 226 | <?php |
227 | - printf( esc_html__( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' ); |
|
227 | + printf(esc_html__('%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>'); |
|
228 | 228 | ?> |
229 | 229 | </span> |
230 | 230 | </div> |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * All Invoicing extensions screen related functions can be found here. |
6 | 6 | * |
7 | 7 | */ |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if (!defined('ABSPATH')) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | 11 | |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function get_tabs() { |
24 | 24 | $tabs = array( |
25 | - 'addons' => __( 'Addons', 'invoicing' ), |
|
26 | - 'gateways' => __( 'Payment Gateways', 'invoicing' ), |
|
27 | - 'recommended_plugins' => __( 'Recommended plugins', 'invoicing' ), |
|
28 | - 'membership' => __( 'Membership', 'invoicing' ), |
|
25 | + 'addons' => __('Addons', 'invoicing'), |
|
26 | + 'gateways' => __('Payment Gateways', 'invoicing'), |
|
27 | + 'recommended_plugins' => __('Recommended plugins', 'invoicing'), |
|
28 | + 'membership' => __('Membership', 'invoicing'), |
|
29 | 29 | ); |
30 | 30 | |
31 | 31 | return $tabs; |
@@ -38,57 +38,57 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return array |
40 | 40 | */ |
41 | - public function get_section_data( $section_id ) { |
|
42 | - $section = self::get_tab( $section_id ); |
|
41 | + public function get_section_data($section_id) { |
|
42 | + $section = self::get_tab($section_id); |
|
43 | 43 | $api_url = 'https://wpinvoicing.com/edd-api/v2/products/'; |
44 | 44 | $section_data = new stdClass(); |
45 | 45 | |
46 | - if ( $section_id == 'recommended_plugins' ) { |
|
46 | + if ($section_id == 'recommended_plugins') { |
|
47 | 47 | $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
48 | - } elseif ( ! empty( $section ) ) { |
|
49 | - if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
48 | + } elseif (!empty($section)) { |
|
49 | + if (false === ($section_data = get_transient('wpi_addons_section_' . $section_id))) { //@todo restore after testing |
|
50 | 50 | //if ( 1==1) { |
51 | 51 | |
52 | 52 | $query_args = array( |
53 | 53 | 'category' => $section_id, |
54 | 54 | 'number' => 100, |
55 | 55 | ); |
56 | - $query_args = apply_filters( 'wpeu_edd_api_query_args', $query_args, $api_url, $section_id ); |
|
56 | + $query_args = apply_filters('wpeu_edd_api_query_args', $query_args, $api_url, $section_id); |
|
57 | 57 | |
58 | 58 | $raw_section = wp_safe_remote_get( |
59 | - esc_url_raw( add_query_arg( $query_args, $api_url ) ), |
|
59 | + esc_url_raw(add_query_arg($query_args, $api_url)), |
|
60 | 60 | array( |
61 | 61 | 'user-agent' => 'Invoicing Addons Page', |
62 | 62 | 'timeout' => 15, |
63 | 63 | ) |
64 | 64 | ); |
65 | 65 | |
66 | - if ( ! is_wp_error( $raw_section ) ) { |
|
67 | - $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
66 | + if (!is_wp_error($raw_section)) { |
|
67 | + $section_data = json_decode(wp_remote_retrieve_body($raw_section)); |
|
68 | 68 | |
69 | - if ( ! empty( $section_data->products ) ) { |
|
70 | - set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
69 | + if (!empty($section_data->products)) { |
|
70 | + set_transient('wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - $products = isset( $section_data->products ) ? $section_data->products : array(); |
|
77 | - if ( 'addons' == $section_id ) { |
|
76 | + $products = isset($section_data->products) ? $section_data->products : array(); |
|
77 | + if ('addons' == $section_id) { |
|
78 | 78 | |
79 | 79 | $quotes = new stdClass(); |
80 | 80 | $quotes->info = new stdClass(); |
81 | 81 | $quotes->info->id = ''; |
82 | 82 | $quotes->info->slug = 'invoicing-quotes'; |
83 | - $quotes->info->title = __( 'Quotes', 'invoicing' ); |
|
84 | - $quotes->info->excerpt = __( 'Create quotes and estimates', 'invoicing' ); |
|
83 | + $quotes->info->title = __('Quotes', 'invoicing'); |
|
84 | + $quotes->info->excerpt = __('Create quotes and estimates', 'invoicing'); |
|
85 | 85 | $quotes->info->link = 'https://wordpress.org/plugins/invoicing-quotes/'; |
86 | 86 | $quotes->info->thumbnail = WPINV_PLUGIN_URL . 'assets/images/Quotes-1-768x384.png'; |
87 | 87 | |
88 | 88 | $products[] = $quotes; |
89 | 89 | } |
90 | 90 | |
91 | - return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
91 | + return apply_filters('wpi_addons_section_data', $products, $section_id); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | * @param string $theme |
100 | 100 | * @param string $plugin |
101 | 101 | */ |
102 | - public function output_button( $addon ) { |
|
102 | + public function output_button($addon) { |
|
103 | 103 | |
104 | 104 | // print_r($addon); |
105 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
105 | + $current_tab = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']); |
|
106 | 106 | // $button_text = __('Free','invoicing'); |
107 | 107 | // $licensing = false; |
108 | 108 | // $installed = false; |
@@ -114,30 +114,30 @@ discard block |
||
114 | 114 | // $install_status = 'get'; |
115 | 115 | // $onclick = ''; |
116 | 116 | |
117 | - $wp_org_themes = array( 'supreme-directory', 'directory-starter' ); |
|
117 | + $wp_org_themes = array('supreme-directory', 'directory-starter'); |
|
118 | 118 | |
119 | 119 | $button_args = array( |
120 | 120 | 'type' => ($current_tab == 'addons' || $current_tab == 'gateways') ? 'addons' : $current_tab, |
121 | - 'id' => isset( $addon->info->id ) ? absint( $addon->info->id ) : '', |
|
122 | - 'title' => isset( $addon->info->title ) ? $addon->info->title : '', |
|
123 | - 'button_text' => __( 'Free', 'invoicing' ), |
|
124 | - 'price_text' => __( 'Free', 'invoicing' ), |
|
125 | - 'link' => isset( $addon->info->link ) ? $addon->info->link : '', // link to product |
|
126 | - 'url' => isset( $addon->info->link ) ? $addon->info->link : '', // button url |
|
121 | + 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
|
122 | + 'title' => isset($addon->info->title) ? $addon->info->title : '', |
|
123 | + 'button_text' => __('Free', 'invoicing'), |
|
124 | + 'price_text' => __('Free', 'invoicing'), |
|
125 | + 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
|
126 | + 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
|
127 | 127 | 'class' => 'button-primary', |
128 | 128 | 'install_status' => 'get', |
129 | 129 | 'installed' => false, |
130 | 130 | 'price' => '', |
131 | - 'licensing' => isset( $addon->licensing->enabled ) && $addon->licensing->enabled ? true : false, |
|
132 | - 'license' => isset( $addon->licensing->license ) && $addon->licensing->license ? $addon->licensing->license : '', |
|
131 | + 'licensing' => isset($addon->licensing->enabled) && $addon->licensing->enabled ? true : false, |
|
132 | + 'license' => isset($addon->licensing->license) && $addon->licensing->license ? $addon->licensing->license : '', |
|
133 | 133 | 'onclick' => '', |
134 | - 'slug' => isset( $addon->info->slug ) ? $addon->info->slug : '', |
|
134 | + 'slug' => isset($addon->info->slug) ? $addon->info->slug : '', |
|
135 | 135 | 'active' => false, |
136 | 136 | 'file' => '', |
137 | 137 | 'update_url' => '', |
138 | 138 | ); |
139 | 139 | |
140 | - if ( 'invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset( $addon->info->slug ) && $addon->info->slug ) ) { |
|
140 | + if ('invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug)) { |
|
141 | 141 | include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
142 | 142 | $status = install_plugin_install_status( |
143 | 143 | array( |
@@ -145,81 +145,81 @@ discard block |
||
145 | 145 | 'version' => '', |
146 | 146 | ) |
147 | 147 | ); |
148 | - $button_args['install_status'] = isset( $status['status'] ) ? $status['status'] : 'install'; |
|
149 | - $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
150 | - } elseif ( ($current_tab == 'addons' || $current_tab == 'gateways') && isset( $addon->info->id ) && $addon->info->id ) { |
|
148 | + $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
|
149 | + $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
150 | + } elseif (($current_tab == 'addons' || $current_tab == 'gateways') && isset($addon->info->id) && $addon->info->id) { |
|
151 | 151 | include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
152 | - if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
153 | -$button_args['slug'] = $addon->licensing->edd_slug;} |
|
154 | - $status = self::install_plugin_install_status( $addon ); |
|
155 | - $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
156 | - if ( isset( $status['status'] ) ) { |
|
157 | -$button_args['install_status'] = $status['status'];} |
|
152 | + if (!empty($addon->licensing->edd_slug)) { |
|
153 | +$button_args['slug'] = $addon->licensing->edd_slug; } |
|
154 | + $status = self::install_plugin_install_status($addon); |
|
155 | + $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
156 | + if (isset($status['status'])) { |
|
157 | +$button_args['install_status'] = $status['status']; } |
|
158 | 158 | $button_args['update_url'] = 'https://wpinvoicing.com'; |
159 | - } elseif ( $current_tab == 'themes' && isset( $addon->info->id ) && $addon->info->id ) { |
|
160 | - if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
161 | -$button_args['slug'] = $addon->licensing->edd_slug;} |
|
162 | - $button_args['installed'] = self::is_theme_installed( $addon ); |
|
163 | - if ( ! in_array( $button_args['slug'], $wp_org_themes ) ) { |
|
159 | + } elseif ($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
160 | + if (!empty($addon->licensing->edd_slug)) { |
|
161 | +$button_args['slug'] = $addon->licensing->edd_slug; } |
|
162 | + $button_args['installed'] = self::is_theme_installed($addon); |
|
163 | + if (!in_array($button_args['slug'], $wp_org_themes)) { |
|
164 | 164 | $button_args['update_url'] = 'https://wpinvoicing.com'; |
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | // set price |
169 | - if ( isset( $addon->pricing ) && ! empty( $addon->pricing ) ) { |
|
170 | - if ( is_object( $addon->pricing ) ) { |
|
171 | - $prices = (array)$addon->pricing; |
|
172 | - $button_args['price'] = reset( $prices ); |
|
173 | - } elseif ( isset( $addon->pricing ) ) { |
|
169 | + if (isset($addon->pricing) && !empty($addon->pricing)) { |
|
170 | + if (is_object($addon->pricing)) { |
|
171 | + $prices = (array) $addon->pricing; |
|
172 | + $button_args['price'] = reset($prices); |
|
173 | + } elseif (isset($addon->pricing)) { |
|
174 | 174 | $button_args['price'] = $addon->pricing; |
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | 178 | // set price text |
179 | - if ( $button_args['price'] && $button_args['price'] != '0.00' ) { |
|
180 | - $button_args['price_text'] = sprintf( __( 'From: $%d', 'invoicing' ), $button_args['price'] ); |
|
179 | + if ($button_args['price'] && $button_args['price'] != '0.00') { |
|
180 | + $button_args['price_text'] = sprintf(__('From: $%d', 'invoicing'), $button_args['price']); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | // set if installed |
184 | - if ( in_array( $button_args['install_status'], array( 'installed', 'latest_installed', 'update_available', 'newer_installed' ) ) ) { |
|
184 | + if (in_array($button_args['install_status'], array('installed', 'latest_installed', 'update_available', 'newer_installed'))) { |
|
185 | 185 | $button_args['installed'] = true; |
186 | 186 | } |
187 | 187 | |
188 | 188 | // print_r($button_args); |
189 | 189 | // set if active |
190 | - if ( $button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes') ) { |
|
191 | - if ( $button_args['type'] != 'themes' ) { |
|
192 | - $button_args['active'] = is_plugin_active( $button_args['file'] ); |
|
190 | + if ($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')) { |
|
191 | + if ($button_args['type'] != 'themes') { |
|
192 | + $button_args['active'] = is_plugin_active($button_args['file']); |
|
193 | 193 | } else { |
194 | - $button_args['active'] = self::is_theme_active( $addon ); |
|
194 | + $button_args['active'] = self::is_theme_active($addon); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | 198 | // set button text and class |
199 | - if ( $button_args['active'] ) { |
|
200 | - $button_args['button_text'] = __( 'Active', 'invoicing' ); |
|
199 | + if ($button_args['active']) { |
|
200 | + $button_args['button_text'] = __('Active', 'invoicing'); |
|
201 | 201 | $button_args['class'] = ' button-secondary disabled '; |
202 | - } elseif ( $button_args['installed'] ) { |
|
203 | - $button_args['button_text'] = __( 'Activate', 'invoicing' ); |
|
202 | + } elseif ($button_args['installed']) { |
|
203 | + $button_args['button_text'] = __('Activate', 'invoicing'); |
|
204 | 204 | |
205 | - if ( $button_args['type'] != 'themes' ) { |
|
206 | - if ( current_user_can( 'manage_options' ) ) { |
|
207 | - $button_args['url'] = wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $button_args['file'] ), 'activate-plugin_' . $button_args['file'] ); |
|
205 | + if ($button_args['type'] != 'themes') { |
|
206 | + if (current_user_can('manage_options')) { |
|
207 | + $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . $button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
208 | 208 | } else { |
209 | 209 | $button_args['url'] = '#'; |
210 | 210 | } |
211 | 211 | } else { |
212 | - if ( current_user_can( 'switch_themes' ) ) { |
|
213 | - $button_args['url'] = self::get_theme_activation_url( $addon ); |
|
212 | + if (current_user_can('switch_themes')) { |
|
213 | + $button_args['url'] = self::get_theme_activation_url($addon); |
|
214 | 214 | } else { |
215 | 215 | $button_args['url'] = '#'; |
216 | 216 | } |
217 | 217 | } |
218 | 218 | } else { |
219 | - if ( $button_args['type'] == 'recommended_plugins' ) { |
|
220 | - $button_args['button_text'] = __( 'Install', 'invoicing' ); |
|
219 | + if ($button_args['type'] == 'recommended_plugins') { |
|
220 | + $button_args['button_text'] = __('Install', 'invoicing'); |
|
221 | 221 | } else { |
222 | - $button_args['button_text'] = __( 'Get it', 'invoicing' ); |
|
222 | + $button_args['button_text'] = __('Get it', 'invoicing'); |
|
223 | 223 | |
224 | 224 | /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
225 | 225 | $button_args['button_text'] = __('Install','invoicing'); |
@@ -231,41 +231,41 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | // filter the button arguments |
234 | - $button_args = apply_filters( 'edd_api_button_args', $button_args ); |
|
234 | + $button_args = apply_filters('edd_api_button_args', $button_args); |
|
235 | 235 | // print_r($button_args); |
236 | 236 | // set price text |
237 | - if ( isset( $button_args['price_text'] ) ) { |
|
237 | + if (isset($button_args['price_text'])) { |
|
238 | 238 | ?> |
239 | 239 | <a |
240 | 240 | target="_blank" |
241 | 241 | class="addons-price-text" |
242 | - href="<?php echo esc_url( $button_args['link'] ); ?>"> |
|
243 | - <?php echo esc_html( $button_args['price_text'] ); ?> |
|
242 | + href="<?php echo esc_url($button_args['link']); ?>"> |
|
243 | + <?php echo esc_html($button_args['price_text']); ?> |
|
244 | 244 | </a> |
245 | 245 | <?php |
246 | 246 | } |
247 | 247 | |
248 | 248 | ?> |
249 | 249 | <a |
250 | - data-licence="<?php echo esc_attr( $button_args['license'] ); ?>" |
|
250 | + data-licence="<?php echo esc_attr($button_args['license']); ?>" |
|
251 | 251 | data-licensing="<?php echo $button_args['licensing'] ? 1 : 0; ?>" |
252 | - data-title="<?php echo esc_attr( $button_args['title'] ); ?>" |
|
253 | - data-type="<?php echo esc_attr( $button_args['type'] ); ?>" |
|
254 | - data-text-error-message="<?php esc_attr_e( 'Something went wrong!', 'invoicing' ); ?>" |
|
255 | - data-text-activate="<?php esc_attr_e( 'Activate', 'invoicing' ); ?>" |
|
256 | - data-text-activating="<?php esc_attr_e( 'Activating', 'invoicing' ); ?>" |
|
257 | - data-text-deactivate="<?php esc_attr_e( 'Deactivate', 'invoicing' ); ?>" |
|
258 | - data-text-installed="<?php esc_attr_e( 'Installed', 'invoicing' ); ?>" |
|
259 | - data-text-install="<?php esc_attr_e( 'Install', 'invoicing' ); ?>" |
|
260 | - data-text-installing="<?php esc_attr_e( 'Installing', 'invoicing' ); ?>" |
|
261 | - data-text-error="<?php esc_attr_e( 'Error', 'invoicing' ); ?>" |
|
252 | + data-title="<?php echo esc_attr($button_args['title']); ?>" |
|
253 | + data-type="<?php echo esc_attr($button_args['type']); ?>" |
|
254 | + data-text-error-message="<?php esc_attr_e('Something went wrong!', 'invoicing'); ?>" |
|
255 | + data-text-activate="<?php esc_attr_e('Activate', 'invoicing'); ?>" |
|
256 | + data-text-activating="<?php esc_attr_e('Activating', 'invoicing'); ?>" |
|
257 | + data-text-deactivate="<?php esc_attr_e('Deactivate', 'invoicing'); ?>" |
|
258 | + data-text-installed="<?php esc_attr_e('Installed', 'invoicing'); ?>" |
|
259 | + data-text-install="<?php esc_attr_e('Install', 'invoicing'); ?>" |
|
260 | + data-text-installing="<?php esc_attr_e('Installing', 'invoicing'); ?>" |
|
261 | + data-text-error="<?php esc_attr_e('Error', 'invoicing'); ?>" |
|
262 | 262 | <?php |
263 | - if ( ! empty( $button_args['onclick'] ) ) { |
|
264 | -echo " onclick='" . esc_attr( $button_args['onclick'] ) . "' ";} |
|
263 | + if (!empty($button_args['onclick'])) { |
|
264 | +echo " onclick='" . esc_attr($button_args['onclick']) . "' "; } |
|
265 | 265 | ?> |
266 | - class="addons-button <?php echo esc_attr( $button_args['class'] ); ?>" |
|
267 | - href="<?php echo esc_url( $button_args['url'] ); ?>"> |
|
268 | - <?php echo esc_html( $button_args['button_text'] ); ?> |
|
266 | + class="addons-button <?php echo esc_attr($button_args['class']); ?>" |
|
267 | + href="<?php echo esc_url($button_args['url']); ?>"> |
|
268 | + <?php echo esc_html($button_args['button_text']); ?> |
|
269 | 269 | </a> |
270 | 270 | <?php |
271 | 271 | |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | $tabs = self::get_tabs(); |
280 | 280 | $sections = self::get_sections(); |
281 | 281 | $theme = wp_get_theme(); |
282 | - $section_keys = array_keys( $sections ); |
|
283 | - $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
284 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
282 | + $section_keys = array_keys($sections); |
|
283 | + $current_section = isset($_GET['section']) ? sanitize_text_field($_GET['section']) : current($section_keys); |
|
284 | + $current_tab = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']); |
|
285 | 285 | include_once WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php'; |
286 | 286 | } |
287 | 287 | |
@@ -296,19 +296,19 @@ discard block |
||
296 | 296 | 'slug' => 'invoicing-quotes', |
297 | 297 | 'name' => 'Quotes', |
298 | 298 | 'thumbnail' => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png', |
299 | - 'desc' => __( 'Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.', 'invoicing' ), |
|
299 | + 'desc' => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.', 'invoicing'), |
|
300 | 300 | ), |
301 | 301 | 'geodirectory' => array( |
302 | 302 | 'url' => 'https://wordpress.org/plugins/geodirectory/', |
303 | 303 | 'slug' => 'geodirectory', |
304 | 304 | 'name' => 'GeoDirectory', |
305 | - 'desc' => __( 'Turn any WordPress theme into a global business directory portal.', 'invoicing' ), |
|
305 | + 'desc' => __('Turn any WordPress theme into a global business directory portal.', 'invoicing'), |
|
306 | 306 | ), |
307 | 307 | 'userswp' => array( |
308 | 308 | 'url' => 'https://wordpress.org/plugins/userswp/', |
309 | 309 | 'slug' => 'userswp', |
310 | 310 | 'name' => 'UsersWP', |
311 | - 'desc' => __( 'Allow frontend user login and registration as well as have slick profile pages.', 'invoicing' ), |
|
311 | + 'desc' => __('Allow frontend user login and registration as well as have slick profile pages.', 'invoicing'), |
|
312 | 312 | ), |
313 | 313 | ); |
314 | 314 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; // Exit if accessed directly |
5 | 5 | } |
6 | 6 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @return AUI|null |
36 | 36 | */ |
37 | 37 | public static function instance() { |
38 | - if ( self::$instance == null ) { |
|
38 | + if (self::$instance == null) { |
|
39 | 39 | self::$instance = new AUI(); |
40 | 40 | } |
41 | 41 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * @since 1.0.0 |
49 | 49 | */ |
50 | 50 | private function __construct() { |
51 | - if ( function_exists( "__autoload" ) ) { |
|
52 | - spl_autoload_register( "__autoload" ); |
|
51 | + if (function_exists("__autoload")) { |
|
52 | + spl_autoload_register("__autoload"); |
|
53 | 53 | } |
54 | - spl_autoload_register( array( $this, 'autoload' ) ); |
|
54 | + spl_autoload_register(array($this, 'autoload')); |
|
55 | 55 | |
56 | 56 | // load options |
57 | 57 | self::$options = get_option('aui_options'); |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @param $classname |
66 | 66 | */ |
67 | - private function autoload( $classname ) { |
|
68 | - $class = str_replace( '_', '-', strtolower( $classname ) ); |
|
69 | - $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php'; |
|
70 | - if ( $file_path && is_readable( $file_path ) ) { |
|
71 | - include_once( $file_path ); |
|
67 | + private function autoload($classname) { |
|
68 | + $class = str_replace('_', '-', strtolower($classname)); |
|
69 | + $file_path = trailingslashit(dirname(__FILE__)) . "components/class-" . $class . '.php'; |
|
70 | + if ($file_path && is_readable($file_path)) { |
|
71 | + include_once($file_path); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -79,34 +79,34 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return string|void |
81 | 81 | */ |
82 | - public function get_option( $option ){ |
|
82 | + public function get_option($option) { |
|
83 | 83 | $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : ''; |
84 | 84 | |
85 | - if ( ! $result && $option) { |
|
86 | - if( $option == 'color_primary' ){ |
|
85 | + if (!$result && $option) { |
|
86 | + if ($option == 'color_primary') { |
|
87 | 87 | $result = AUI_PRIMARY_COLOR; |
88 | - }elseif( $option == 'color_secondary' ){ |
|
88 | + }elseif ($option == 'color_secondary') { |
|
89 | 89 | $result = AUI_SECONDARY_COLOR; |
90 | 90 | } |
91 | 91 | } |
92 | 92 | return $result; |
93 | 93 | } |
94 | 94 | |
95 | - public function render( $items = array(), $echo = false ) { |
|
95 | + public function render($items = array(), $echo = false) { |
|
96 | 96 | $output = ''; |
97 | 97 | |
98 | - if ( ! empty( $items ) ) { |
|
99 | - foreach ( $items as $args ) { |
|
100 | - $render = isset( $args['render'] ) ? $args['render'] : ''; |
|
101 | - if ( $render && method_exists( __CLASS__, $render ) ) { |
|
102 | - $output .= $this->$render( $args ); |
|
98 | + if (!empty($items)) { |
|
99 | + foreach ($items as $args) { |
|
100 | + $render = isset($args['render']) ? $args['render'] : ''; |
|
101 | + if ($render && method_exists(__CLASS__, $render)) { |
|
102 | + $output .= $this->$render($args); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - if ( $echo ) { |
|
107 | + if ($echo) { |
|
108 | 108 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
109 | - }else{ |
|
109 | + } else { |
|
110 | 110 | return $output; |
111 | 111 | } |
112 | 112 | |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return string The rendered component. |
124 | 124 | */ |
125 | - public function alert( $args = array(), $echo = false ) { |
|
126 | - $output = AUI_Component_Alert::get( $args ); |
|
125 | + public function alert($args = array(), $echo = false) { |
|
126 | + $output = AUI_Component_Alert::get($args); |
|
127 | 127 | |
128 | - if ( $echo ) { |
|
128 | + if ($echo) { |
|
129 | 129 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
130 | - }else{ |
|
130 | + } else { |
|
131 | 131 | return $output; |
132 | 132 | } |
133 | 133 | } |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return string The rendered component. |
144 | 144 | */ |
145 | - public function input( $args = array(), $echo = false ) { |
|
146 | - $output = AUI_Component_Input::input( $args ); |
|
145 | + public function input($args = array(), $echo = false) { |
|
146 | + $output = AUI_Component_Input::input($args); |
|
147 | 147 | |
148 | - if ( $echo ) { |
|
148 | + if ($echo) { |
|
149 | 149 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
150 | - }else{ |
|
150 | + } else { |
|
151 | 151 | return $output; |
152 | 152 | } |
153 | 153 | } |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return string The rendered component. |
164 | 164 | */ |
165 | - public function textarea( $args = array(), $echo = false ) { |
|
166 | - $output = AUI_Component_Input::textarea( $args ); |
|
165 | + public function textarea($args = array(), $echo = false) { |
|
166 | + $output = AUI_Component_Input::textarea($args); |
|
167 | 167 | |
168 | - if ( $echo ) { |
|
168 | + if ($echo) { |
|
169 | 169 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
170 | - }else{ |
|
170 | + } else { |
|
171 | 171 | return $output; |
172 | 172 | } |
173 | 173 | } |
@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return string The rendered component. |
184 | 184 | */ |
185 | - public function button( $args = array(), $echo = false ) { |
|
186 | - $output = AUI_Component_Button::get( $args ); |
|
185 | + public function button($args = array(), $echo = false) { |
|
186 | + $output = AUI_Component_Button::get($args); |
|
187 | 187 | |
188 | - if ( $echo ) { |
|
188 | + if ($echo) { |
|
189 | 189 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
190 | - }else{ |
|
190 | + } else { |
|
191 | 191 | return $output; |
192 | 192 | } |
193 | 193 | } |
@@ -202,26 +202,26 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return string The rendered component. |
204 | 204 | */ |
205 | - public function badge( $args = array(), $echo = false ) { |
|
205 | + public function badge($args = array(), $echo = false) { |
|
206 | 206 | $defaults = array( |
207 | 207 | 'class' => 'badge badge-primary align-middle', |
208 | 208 | ); |
209 | 209 | |
210 | 210 | // maybe set type. |
211 | - if ( empty( $args['href'] ) ) { |
|
211 | + if (empty($args['href'])) { |
|
212 | 212 | $defaults['type'] = 'badge'; |
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
216 | 216 | * Parse incoming $args into an array and merge it with $defaults |
217 | 217 | */ |
218 | - $args = wp_parse_args( $args, $defaults ); |
|
218 | + $args = wp_parse_args($args, $defaults); |
|
219 | 219 | |
220 | - $output = AUI_Component_Button::get( $args ); |
|
220 | + $output = AUI_Component_Button::get($args); |
|
221 | 221 | |
222 | - if ( $echo ) { |
|
222 | + if ($echo) { |
|
223 | 223 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
224 | - }else{ |
|
224 | + } else { |
|
225 | 225 | return $output; |
226 | 226 | } |
227 | 227 | } |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return string The rendered component. |
238 | 238 | */ |
239 | - public function dropdown( $args = array(), $echo = false ) { |
|
240 | - $output = AUI_Component_Dropdown::get( $args ); |
|
239 | + public function dropdown($args = array(), $echo = false) { |
|
240 | + $output = AUI_Component_Dropdown::get($args); |
|
241 | 241 | |
242 | - if ( $echo ) { |
|
242 | + if ($echo) { |
|
243 | 243 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
244 | - }else{ |
|
244 | + } else { |
|
245 | 245 | return $output; |
246 | 246 | } |
247 | 247 | } |
@@ -256,12 +256,12 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return string The rendered component. |
258 | 258 | */ |
259 | - public function select( $args = array(), $echo = false ) { |
|
260 | - $output = AUI_Component_Input::select( $args ); |
|
259 | + public function select($args = array(), $echo = false) { |
|
260 | + $output = AUI_Component_Input::select($args); |
|
261 | 261 | |
262 | - if ( $echo ) { |
|
262 | + if ($echo) { |
|
263 | 263 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
264 | - }else{ |
|
264 | + } else { |
|
265 | 265 | return $output; |
266 | 266 | } |
267 | 267 | } |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return string The rendered component. |
278 | 278 | */ |
279 | - public function radio( $args = array(), $echo = false ) { |
|
280 | - $output = AUI_Component_Input::radio( $args ); |
|
279 | + public function radio($args = array(), $echo = false) { |
|
280 | + $output = AUI_Component_Input::radio($args); |
|
281 | 281 | |
282 | - if ( $echo ) { |
|
282 | + if ($echo) { |
|
283 | 283 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
284 | - }else{ |
|
284 | + } else { |
|
285 | 285 | return $output; |
286 | 286 | } |
287 | 287 | } |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return string The rendered component. |
298 | 298 | */ |
299 | - public function pagination( $args = array(), $echo = false ) { |
|
300 | - $output = AUI_Component_Pagination::get( $args ); |
|
299 | + public function pagination($args = array(), $echo = false) { |
|
300 | + $output = AUI_Component_Pagination::get($args); |
|
301 | 301 | |
302 | - if ( $echo ) { |
|
302 | + if ($echo) { |
|
303 | 303 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
304 | - }else{ |
|
304 | + } else { |
|
305 | 305 | return $output; |
306 | 306 | } |
307 | 307 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | function aui_init_flatpickr(){ |
253 | 253 | if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) { |
254 | 254 | $aui_doing_init_flatpickr = true; |
255 | - <?php if ( ! empty( $flatpickr_locale ) ) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
255 | + <?php if (!empty($flatpickr_locale)) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
256 | 256 | jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr(); |
257 | 257 | } |
258 | 258 | $aui_doing_init_flatpickr = false; |
@@ -1013,7 +1013,7 @@ discard block |
||
1013 | 1013 | |
1014 | 1014 | <?php |
1015 | 1015 | // FSE tweaks. |
1016 | - if(!empty($_REQUEST['postType'])){ ?> |
|
1016 | + if (!empty($_REQUEST['postType'])) { ?> |
|
1017 | 1017 | function aui_fse_set_data_scroll() { |
1018 | 1018 | console.log('init scroll'); |
1019 | 1019 | let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas"); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | function aui_init_flatpickr(){ |
243 | 243 | if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) { |
244 | 244 | $aui_doing_init_flatpickr = true; |
245 | - <?php if ( ! empty( $flatpickr_locale ) ) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
245 | + <?php if (!empty($flatpickr_locale)) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
246 | 246 | jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr(); |
247 | 247 | } |
248 | 248 | $aui_doing_init_flatpickr = false; |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | |
972 | 972 | <?php |
973 | 973 | // FSE tweaks. |
974 | - if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'){ ?> |
|
974 | + if (!empty($_REQUEST['postType']) && $_REQUEST['postType'] == 'wp_template') { ?> |
|
975 | 975 | function aui_fse_set_data_scroll() { |
976 | 976 | console.log('init scroll'); |
977 | 977 | let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas"); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package GetPaid |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Queries the customers database. |
@@ -17,26 +17,26 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @return int|array|GetPaid_Customer[]|GetPaid_Customers_Query |
19 | 19 | */ |
20 | -function getpaid_get_customers( $args = array(), $return = 'results' ) { |
|
20 | +function getpaid_get_customers($args = array(), $return = 'results') { |
|
21 | 21 | |
22 | 22 | // Do not retrieve all fields if we just want the count. |
23 | - if ( 'count' === $return ) { |
|
23 | + if ('count' === $return) { |
|
24 | 24 | $args['fields'] = 'id'; |
25 | 25 | $args['number'] = 1; |
26 | 26 | } |
27 | 27 | |
28 | 28 | // Do not count all matches if we just want the results. |
29 | - if ( 'results' === $return ) { |
|
29 | + if ('results' === $return) { |
|
30 | 30 | $args['count_total'] = false; |
31 | 31 | } |
32 | 32 | |
33 | - $query = new GetPaid_Customers_Query( $args ); |
|
33 | + $query = new GetPaid_Customers_Query($args); |
|
34 | 34 | |
35 | - if ( 'results' === $return ) { |
|
35 | + if ('results' === $return) { |
|
36 | 36 | return $query->get_results(); |
37 | 37 | } |
38 | 38 | |
39 | - if ( 'count' === $return ) { |
|
39 | + if ('count' === $return) { |
|
40 | 40 | return $query->get_total(); |
41 | 41 | } |
42 | 42 | |
@@ -49,19 +49,19 @@ discard block |
||
49 | 49 | * @param int|string|object|GetPaid_Customer $customer customer id, email or object. |
50 | 50 | * @return GetPaid_Customer|null |
51 | 51 | */ |
52 | -function getpaid_get_customer( $customer ) { |
|
52 | +function getpaid_get_customer($customer) { |
|
53 | 53 | |
54 | - if ( empty( $customer ) ) { |
|
54 | + if (empty($customer)) { |
|
55 | 55 | return null; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Retrieve the customer. |
59 | - if ( ! is_a( $customer, 'GetPaid_Customer' ) ) { |
|
60 | - $customer = new GetPaid_Customer( $customer ); |
|
59 | + if (!is_a($customer, 'GetPaid_Customer')) { |
|
60 | + $customer = new GetPaid_Customer($customer); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // Check if it exists. |
64 | - if ( $customer->exists() ) { |
|
64 | + if ($customer->exists()) { |
|
65 | 65 | return $customer; |
66 | 66 | } |
67 | 67 | |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @return GetPaid_Customer|null |
75 | 75 | * @since 1.0.0 |
76 | 76 | */ |
77 | -function getpaid_get_customer_by_user_id( $user_id ) { |
|
77 | +function getpaid_get_customer_by_user_id($user_id) { |
|
78 | 78 | return getpaid_get_customer( |
79 | - GetPaid_Customer::get_customer_id_by( $user_id, 'user_id' ) |
|
79 | + GetPaid_Customer::get_customer_id_by($user_id, 'user_id') |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | * @param array $args |
89 | 89 | * @see wp_dropdown_users |
90 | 90 | */ |
91 | -function wpinv_dropdown_users( $args = '' ) { |
|
91 | +function wpinv_dropdown_users($args = '') { |
|
92 | 92 | |
93 | - if ( is_array( $args ) && ! empty( $args['show'] ) && 'display_name_with_email' == $args['show'] ) { |
|
93 | + if (is_array($args) && !empty($args['show']) && 'display_name_with_email' == $args['show']) { |
|
94 | 94 | $args['show'] = 'display_name_with_login'; |
95 | 95 | } |
96 | 96 | |
97 | - return wp_dropdown_users( $args ); |
|
97 | + return wp_dropdown_users($args); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | * @return string capability to check against |
105 | 105 | * @param string $capalibilty Optional. The alternative capability to check against. |
106 | 106 | */ |
107 | -function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
|
107 | +function wpinv_get_capability($capalibilty = 'manage_invoicing') { |
|
108 | 108 | |
109 | - if ( current_user_can( 'manage_options' ) ) { |
|
109 | + if (current_user_can('manage_options')) { |
|
110 | 110 | return 'manage_options'; |
111 | 111 | }; |
112 | 112 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @return bool |
121 | 121 | */ |
122 | 122 | function wpinv_current_user_can_manage_invoicing() { |
123 | - return current_user_can( wpinv_get_capability() ); |
|
123 | + return current_user_can(wpinv_get_capability()); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | * @param mixed $args Optional further parameters, typically starting with an object. |
133 | 133 | * @return bool Whether the current user has the given capability. |
134 | 134 | */ |
135 | -function wpinv_current_user_can( $capability, $args = array() ) { |
|
135 | +function wpinv_current_user_can($capability, $args = array()) { |
|
136 | 136 | $can = wpinv_current_user_can_manage_invoicing(); |
137 | 137 | |
138 | - return apply_filters( 'getpaid_current_user_can', $can, $capability, $args ); |
|
138 | + return apply_filters('getpaid_current_user_can', $can, $capability, $args); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,19 +144,19 @@ discard block |
||
144 | 144 | * @since 1.0.19 |
145 | 145 | * @return int|WP_Error |
146 | 146 | */ |
147 | -function wpinv_create_user( $email, $prefix = '' ) { |
|
147 | +function wpinv_create_user($email, $prefix = '') { |
|
148 | 148 | |
149 | 149 | // Prepare user values. |
150 | - $prefix = preg_replace( '/\s+/', '', $prefix ); |
|
151 | - $prefix = empty( $prefix ) ? $email : $prefix; |
|
152 | - $args = array( |
|
153 | - 'user_login' => wpinv_generate_user_name( $prefix ), |
|
150 | + $prefix = preg_replace('/\s+/', '', $prefix); |
|
151 | + $prefix = empty($prefix) ? $email : $prefix; |
|
152 | + $args = array( |
|
153 | + 'user_login' => wpinv_generate_user_name($prefix), |
|
154 | 154 | 'user_pass' => wp_generate_password(), |
155 | 155 | 'user_email' => $email, |
156 | 156 | 'role' => 'subscriber', |
157 | 157 | ); |
158 | 158 | |
159 | - return wp_insert_user( $args ); |
|
159 | + return wp_insert_user($args); |
|
160 | 160 | |
161 | 161 | } |
162 | 162 | |
@@ -166,26 +166,26 @@ discard block |
||
166 | 166 | * @since 1.0.19 |
167 | 167 | * @return bool|WP_User |
168 | 168 | */ |
169 | -function wpinv_generate_user_name( $prefix = '' ) { |
|
169 | +function wpinv_generate_user_name($prefix = '') { |
|
170 | 170 | |
171 | 171 | // If prefix is an email, retrieve the part before the email. |
172 | - $prefix = strtok( $prefix, '@' ); |
|
173 | - $prefix = trim( $prefix, '.' ); |
|
172 | + $prefix = strtok($prefix, '@'); |
|
173 | + $prefix = trim($prefix, '.'); |
|
174 | 174 | |
175 | 175 | // Sanitize the username. |
176 | - $prefix = sanitize_user( $prefix, true ); |
|
176 | + $prefix = sanitize_user($prefix, true); |
|
177 | 177 | |
178 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
179 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
180 | - $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
178 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
179 | + if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) { |
|
180 | + $prefix = 'gtp_' . zeroise(wp_rand(0, 9999), 4); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | $username = $prefix; |
184 | 184 | $postfix = 2; |
185 | 185 | |
186 | - while ( username_exists( $username ) ) { |
|
186 | + while (username_exists($username)) { |
|
187 | 187 | $username = "{$prefix}{$postfix}"; |
188 | - $postfix ++; |
|
188 | + $postfix++; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | return $username; |
@@ -202,31 +202,31 @@ discard block |
||
202 | 202 | $tabs = array( |
203 | 203 | |
204 | 204 | 'gp-invoices' => array( |
205 | - 'label' => __( 'Invoices', 'invoicing' ), // Name of the tab. |
|
205 | + 'label' => __('Invoices', 'invoicing'), // Name of the tab. |
|
206 | 206 | 'content' => '[wpinv_history]', // Content of the tab. Or specify "callback" to provide a callback instead. |
207 | 207 | 'icon' => 'fas fa-file-invoice', // Shown on some profile plugins. |
208 | 208 | ), |
209 | 209 | |
210 | 210 | 'gp-subscriptions' => array( |
211 | - 'label' => __( 'Subscriptions', 'invoicing' ), |
|
211 | + 'label' => __('Subscriptions', 'invoicing'), |
|
212 | 212 | 'content' => '[wpinv_subscriptions]', |
213 | 213 | 'icon' => 'fas fa-redo', |
214 | 214 | ), |
215 | 215 | |
216 | 216 | 'gp-edit-address' => array( |
217 | - 'label' => __( 'Billing Address', 'invoicing' ), |
|
217 | + 'label' => __('Billing Address', 'invoicing'), |
|
218 | 218 | 'callback' => 'getpaid_display_address_edit_tab', |
219 | 219 | 'icon' => 'fas fa-credit-card', |
220 | 220 | ), |
221 | 221 | |
222 | 222 | ); |
223 | 223 | |
224 | - $tabs = apply_filters( 'getpaid_user_content_tabs', $tabs ); |
|
224 | + $tabs = apply_filters('getpaid_user_content_tabs', $tabs); |
|
225 | 225 | |
226 | 226 | // Make sure address editing is last on the list. |
227 | - if ( isset( $tabs['gp-edit-address'] ) ) { |
|
227 | + if (isset($tabs['gp-edit-address'])) { |
|
228 | 228 | $address = $tabs['gp-edit-address']; |
229 | - unset( $tabs['gp-edit-address'] ); |
|
229 | + unset($tabs['gp-edit-address']); |
|
230 | 230 | $tabs['gp-edit-address'] = $address; |
231 | 231 | } |
232 | 232 | |
@@ -240,19 +240,19 @@ discard block |
||
240 | 240 | * @param array $tab |
241 | 241 | * @return array |
242 | 242 | */ |
243 | -function getpaid_prepare_user_content_tab( $tab ) { |
|
243 | +function getpaid_prepare_user_content_tab($tab) { |
|
244 | 244 | |
245 | - if ( ! empty( $tab['callback'] ) ) { |
|
246 | - return call_user_func( $tab['callback'] ); |
|
245 | + if (!empty($tab['callback'])) { |
|
246 | + return call_user_func($tab['callback']); |
|
247 | 247 | } |
248 | 248 | |
249 | - if ( ! empty( $tab['content'] ) ) { |
|
250 | - return convert_smilies( capital_P_dangit( wp_filter_content_tags( do_shortcode( shortcode_unautop( wpautop( wptexturize( do_blocks( $tab['content'] ) ) ) ) ) ) ) ); |
|
249 | + if (!empty($tab['content'])) { |
|
250 | + return convert_smilies(capital_P_dangit(wp_filter_content_tags(do_shortcode(shortcode_unautop(wpautop(wptexturize(do_blocks($tab['content'])))))))); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | $notice = aui()->alert( |
254 | 254 | array( |
255 | - 'content' => __( 'This tab has no content or content callback.', 'invoicing' ), |
|
255 | + 'content' => __('This tab has no content or content callback.', 'invoicing'), |
|
256 | 256 | 'type' => 'error', |
257 | 257 | ) |
258 | 258 | ); |
@@ -268,14 +268,14 @@ discard block |
||
268 | 268 | * @param string $default |
269 | 269 | * @return array |
270 | 270 | */ |
271 | -function getpaid_get_tab_url( $tab, $default ) { |
|
271 | +function getpaid_get_tab_url($tab, $default) { |
|
272 | 272 | global $getpaid_tab_url; |
273 | 273 | |
274 | - if ( empty( $getpaid_tab_url ) ) { |
|
274 | + if (empty($getpaid_tab_url)) { |
|
275 | 275 | return $default; |
276 | 276 | } |
277 | 277 | |
278 | - return sprintf( $getpaid_tab_url, $tab ); |
|
278 | + return sprintf($getpaid_tab_url, $tab); |
|
279 | 279 | |
280 | 280 | } |
281 | 281 | |
@@ -287,21 +287,21 @@ discard block |
||
287 | 287 | */ |
288 | 288 | function getpaid_display_address_edit_tab() { |
289 | 289 | |
290 | - if ( 0 === get_current_user_id() ) { |
|
290 | + if (0 === get_current_user_id()) { |
|
291 | 291 | return '<div class="bsui">' . aui()->alert( |
292 | 292 | array( |
293 | 293 | 'type' => 'error', |
294 | - 'content' => __( 'Your must be logged in to view this section', 'invoicing' ), |
|
294 | + 'content' => __('Your must be logged in to view this section', 'invoicing'), |
|
295 | 295 | 'dismissible' => false, |
296 | 296 | ) |
297 | 297 | ) . '</div>'; |
298 | 298 | } |
299 | 299 | |
300 | - $customer = getpaid_get_customer_by_user_id( get_current_user_id() ); |
|
300 | + $customer = getpaid_get_customer_by_user_id(get_current_user_id()); |
|
301 | 301 | |
302 | - if ( empty( $customer ) ) { |
|
303 | - $customer = new GetPaid_Customer( 0 ); |
|
304 | - $customer->clone_user( get_current_user_id() ); |
|
302 | + if (empty($customer)) { |
|
303 | + $customer = new GetPaid_Customer(0); |
|
304 | + $customer->clone_user(get_current_user_id()); |
|
305 | 305 | $customer->save(); |
306 | 306 | } |
307 | 307 | |
@@ -313,21 +313,21 @@ discard block |
||
313 | 313 | |
314 | 314 | <?php |
315 | 315 | |
316 | - foreach ( getpaid_user_address_fields() as $key => $label ) { |
|
316 | + foreach (getpaid_user_address_fields() as $key => $label) { |
|
317 | 317 | |
318 | - $value = $customer->get( $key ); |
|
318 | + $value = $customer->get($key); |
|
319 | 319 | |
320 | 320 | // Display the country. |
321 | - if ( 'country' == $key ) { |
|
321 | + if ('country' == $key) { |
|
322 | 322 | |
323 | 323 | aui()->select( |
324 | 324 | array( |
325 | 325 | 'options' => wpinv_get_country_list(), |
326 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
327 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
328 | - 'value' => sanitize_text_field( $value ), |
|
326 | + 'name' => 'getpaid_address[' . esc_attr($key) . ']', |
|
327 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
328 | + 'value' => sanitize_text_field($value), |
|
329 | 329 | 'placeholder' => $label, |
330 | - 'label' => wp_kses_post( $label ), |
|
330 | + 'label' => wp_kses_post($label), |
|
331 | 331 | 'label_type' => 'vertical', |
332 | 332 | 'class' => 'getpaid-address-field', |
333 | 333 | ), |
@@ -337,17 +337,17 @@ discard block |
||
337 | 337 | } |
338 | 338 | |
339 | 339 | // Display the state. |
340 | - elseif ( 'state' == $key ) { |
|
340 | + elseif ('state' == $key) { |
|
341 | 341 | |
342 | 342 | getpaid_get_states_select_markup( |
343 | - $customer->get( 'country' ), |
|
343 | + $customer->get('country'), |
|
344 | 344 | $value, |
345 | 345 | $label, |
346 | 346 | $label, |
347 | 347 | '', |
348 | 348 | false, |
349 | 349 | '', |
350 | - 'getpaid_address[' . esc_attr( $key ) . ']', |
|
350 | + 'getpaid_address[' . esc_attr($key) . ']', |
|
351 | 351 | true |
352 | 352 | ); |
353 | 353 | |
@@ -355,13 +355,13 @@ discard block |
||
355 | 355 | |
356 | 356 | aui()->input( |
357 | 357 | array( |
358 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
359 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
358 | + 'name' => 'getpaid_address[' . esc_attr($key) . ']', |
|
359 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
360 | 360 | 'placeholder' => $label, |
361 | - 'label' => wp_kses_post( $label ), |
|
361 | + 'label' => wp_kses_post($label), |
|
362 | 362 | 'label_type' => 'vertical', |
363 | 363 | 'type' => 'text', |
364 | - 'value' => sanitize_text_field( $value ), |
|
364 | + 'value' => sanitize_text_field($value), |
|
365 | 365 | 'class' => 'getpaid-address-field', |
366 | 366 | ), |
367 | 367 | true |
@@ -375,32 +375,32 @@ discard block |
||
375 | 375 | 'name' => 'getpaid_address[email_cc]', |
376 | 376 | 'id' => 'wpinv-email_cc', |
377 | 377 | 'placeholder' => '[email protected], [email protected]', |
378 | - 'label' => __( 'Other email addresses', 'invoicing' ), |
|
378 | + 'label' => __('Other email addresses', 'invoicing'), |
|
379 | 379 | 'label_type' => 'vertical', |
380 | 380 | 'type' => 'text', |
381 | - 'value' => sanitize_text_field( $customer->get( 'email_cc' ) ), |
|
381 | + 'value' => sanitize_text_field($customer->get('email_cc')), |
|
382 | 382 | 'class' => 'getpaid-address-field', |
383 | - 'help_text' => __( 'Optionally provide other email addresses where we should send payment notifications', 'invoicing' ), |
|
383 | + 'help_text' => __('Optionally provide other email addresses where we should send payment notifications', 'invoicing'), |
|
384 | 384 | ), |
385 | 385 | true |
386 | 386 | ); |
387 | 387 | |
388 | - do_action( 'getpaid_display_address_edit_tab' ); |
|
388 | + do_action('getpaid_display_address_edit_tab'); |
|
389 | 389 | |
390 | 390 | aui()->input( |
391 | 391 | array( |
392 | 392 | 'name' => 'getpaid_profile_edit_submit_button', |
393 | 393 | 'id' => 'getpaid_profile_edit_submit_button', |
394 | - 'value' => __( 'Save Address', 'invoicing' ), |
|
395 | - 'help_text' => __( 'New invoices will use this address as the billing address.', 'invoicing' ), |
|
394 | + 'value' => __('Save Address', 'invoicing'), |
|
395 | + 'help_text' => __('New invoices will use this address as the billing address.', 'invoicing'), |
|
396 | 396 | 'type' => 'submit', |
397 | 397 | 'class' => 'btn btn-primary btn-block submit-button', |
398 | 398 | ), |
399 | 399 | true |
400 | 400 | ); |
401 | 401 | |
402 | - wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); |
|
403 | - getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' ); |
|
402 | + wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); |
|
403 | + getpaid_hidden_field('getpaid-action', 'edit_billing_details'); |
|
404 | 404 | ?> |
405 | 405 | |
406 | 406 | </form> |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | |
411 | 411 | return ob_get_clean(); |
412 | 412 | } |
413 | -add_shortcode( 'getpaid_edit_address', 'getpaid_display_address_edit_tab' ); |
|
413 | +add_shortcode('getpaid_edit_address', 'getpaid_display_address_edit_tab'); |
|
414 | 414 | |
415 | 415 | /** |
416 | 416 | * Saves the billing address edit tab. |
@@ -418,35 +418,35 @@ discard block |
||
418 | 418 | * @since 2.1.4 |
419 | 419 | * @param array $data |
420 | 420 | */ |
421 | -function getpaid_save_address_edit_tab( $data ) { |
|
421 | +function getpaid_save_address_edit_tab($data) { |
|
422 | 422 | |
423 | - if ( empty( $data['getpaid_address'] ) || ! is_array( $data['getpaid_address'] ) ) { |
|
423 | + if (empty($data['getpaid_address']) || !is_array($data['getpaid_address'])) { |
|
424 | 424 | return; |
425 | 425 | } |
426 | 426 | |
427 | 427 | $data = $data['getpaid_address']; |
428 | - $customer = getpaid_get_customer_by_user_id( get_current_user_id() ); |
|
428 | + $customer = getpaid_get_customer_by_user_id(get_current_user_id()); |
|
429 | 429 | |
430 | - if ( empty( $customer ) ) { |
|
431 | - $customer = new GetPaid_Customer( 0 ); |
|
432 | - $customer->clone_user( get_current_user_id() ); |
|
430 | + if (empty($customer)) { |
|
431 | + $customer = new GetPaid_Customer(0); |
|
432 | + $customer->clone_user(get_current_user_id()); |
|
433 | 433 | } |
434 | 434 | |
435 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
435 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
436 | 436 | |
437 | - if ( isset( $data[ $field ] ) ) { |
|
438 | - $customer->set( $field, sanitize_text_field( $data[ $field ] ) ); |
|
437 | + if (isset($data[$field])) { |
|
438 | + $customer->set($field, sanitize_text_field($data[$field])); |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | |
442 | - if ( isset( $data['email_cc'] ) ) { |
|
443 | - $customer->set( 'email_cc', sanitize_text_field( $data['email_cc'] ) ); |
|
442 | + if (isset($data['email_cc'])) { |
|
443 | + $customer->set('email_cc', sanitize_text_field($data['email_cc'])); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | $customer->save(); |
447 | - wpinv_set_error( 'address_updated' ); |
|
447 | + wpinv_set_error('address_updated'); |
|
448 | 448 | } |
449 | -add_action( 'getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab' ); |
|
449 | +add_action('getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab'); |
|
450 | 450 | |
451 | 451 | |
452 | 452 | /* |
@@ -464,27 +464,27 @@ discard block |
||
464 | 464 | * @param array $tabs |
465 | 465 | * @return array |
466 | 466 | */ |
467 | -function getpaid_filter_userswp_account_tabs( $tabs ) { |
|
467 | +function getpaid_filter_userswp_account_tabs($tabs) { |
|
468 | 468 | |
469 | 469 | // Abort if the integration is inactive. |
470 | - if ( ! getpaid_is_userswp_integration_active() ) { |
|
470 | + if (!getpaid_is_userswp_integration_active()) { |
|
471 | 471 | return $tabs; |
472 | 472 | } |
473 | 473 | |
474 | - $new_tabs = array(); |
|
474 | + $new_tabs = array(); |
|
475 | 475 | |
476 | - foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) { |
|
476 | + foreach (getpaid_get_user_content_tabs() as $slug => $tab) { |
|
477 | 477 | |
478 | - $new_tabs[ $slug ] = array( |
|
478 | + $new_tabs[$slug] = array( |
|
479 | 479 | 'title' => $tab['label'], |
480 | 480 | 'icon' => $tab['icon'], |
481 | 481 | ); |
482 | 482 | |
483 | 483 | } |
484 | 484 | |
485 | - return array_merge( $tabs, $new_tabs ); |
|
485 | + return array_merge($tabs, $new_tabs); |
|
486 | 486 | } |
487 | -add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' ); |
|
487 | +add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs'); |
|
488 | 488 | |
489 | 489 | /** |
490 | 490 | * Display our UsersWP account tabs. |
@@ -493,21 +493,21 @@ discard block |
||
493 | 493 | * @param array $tabs |
494 | 494 | * @return array |
495 | 495 | */ |
496 | -function getpaid_display_userswp_account_tabs( $tab ) { |
|
496 | +function getpaid_display_userswp_account_tabs($tab) { |
|
497 | 497 | global $getpaid_tab_url; |
498 | 498 | |
499 | 499 | $our_tabs = getpaid_get_user_content_tabs(); |
500 | 500 | |
501 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
502 | - $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() ); |
|
503 | - echo wp_kses( getpaid_prepare_user_content_tab( $our_tabs[ $tab ] ), getpaid_allowed_html() ); |
|
501 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
502 | + $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url()); |
|
503 | + echo wp_kses(getpaid_prepare_user_content_tab($our_tabs[$tab]), getpaid_allowed_html()); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | } |
507 | -add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' ); |
|
507 | +add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs'); |
|
508 | 508 | |
509 | 509 | function getpaid_allowed_html() { |
510 | - $allowed_html = wp_kses_allowed_html( 'post' ); |
|
510 | + $allowed_html = wp_kses_allowed_html('post'); |
|
511 | 511 | |
512 | 512 | // form fields |
513 | 513 | $allowed_html['form'] = array( |
@@ -578,17 +578,17 @@ discard block |
||
578 | 578 | * @param string $tab Current tab. |
579 | 579 | * @return string Title. |
580 | 580 | */ |
581 | -function getpaid_filter_userswp_account_title( $title, $tab ) { |
|
581 | +function getpaid_filter_userswp_account_title($title, $tab) { |
|
582 | 582 | |
583 | - $our_tabs = getpaid_get_user_content_tabs(); |
|
583 | + $our_tabs = getpaid_get_user_content_tabs(); |
|
584 | 584 | |
585 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
586 | - return $our_tabs[ $tab ]['label']; |
|
585 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
586 | + return $our_tabs[$tab]['label']; |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | return $title; |
590 | 590 | } |
591 | -add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 ); |
|
591 | +add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2); |
|
592 | 592 | |
593 | 593 | /** |
594 | 594 | * Registers the UsersWP integration settings. |
@@ -597,26 +597,26 @@ discard block |
||
597 | 597 | * @param array $settings An array of integration settings. |
598 | 598 | * @return array |
599 | 599 | */ |
600 | -function getpaid_register_userswp_settings( $settings ) { |
|
600 | +function getpaid_register_userswp_settings($settings) { |
|
601 | 601 | |
602 | - if ( defined( 'USERSWP_PLUGIN_FILE' ) ) { |
|
602 | + if (defined('USERSWP_PLUGIN_FILE')) { |
|
603 | 603 | |
604 | 604 | $settings[] = array( |
605 | 605 | |
606 | 606 | 'id' => 'userswp', |
607 | - 'label' => __( 'UsersWP', 'invoicing' ), |
|
607 | + 'label' => __('UsersWP', 'invoicing'), |
|
608 | 608 | 'settings' => array( |
609 | 609 | |
610 | 610 | 'userswp_settings' => array( |
611 | 611 | 'id' => 'userswp_settings', |
612 | - 'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>', |
|
612 | + 'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>', |
|
613 | 613 | 'type' => 'header', |
614 | 614 | ), |
615 | 615 | |
616 | 616 | 'enable_userswp' => array( |
617 | 617 | 'id' => 'enable_userswp', |
618 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
619 | - 'desc' => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ), |
|
618 | + 'name' => __('Enable Integration', 'invoicing'), |
|
619 | + 'desc' => __('Display GetPaid items on UsersWP account page.', 'invoicing'), |
|
620 | 620 | 'type' => 'checkbox', |
621 | 621 | 'std' => 1, |
622 | 622 | ), |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | |
630 | 630 | return $settings; |
631 | 631 | } |
632 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' ); |
|
632 | +add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings'); |
|
633 | 633 | |
634 | 634 | /** |
635 | 635 | * Ovewrites the invoices history page to UsersWP. |
@@ -637,18 +637,18 @@ discard block |
||
637 | 637 | * @since 2.3.1 |
638 | 638 | * @return bool |
639 | 639 | */ |
640 | -function getpaid_userswp_overwrite_invoice_history_page( $url, $post_type ) { |
|
640 | +function getpaid_userswp_overwrite_invoice_history_page($url, $post_type) { |
|
641 | 641 | |
642 | 642 | $our_tabs = getpaid_get_user_content_tabs(); |
643 | 643 | $tab = "gp-{$post_type}s"; |
644 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
645 | - return add_query_arg( 'type', $tab, uwp_get_account_page_url() ); |
|
644 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
645 | + return add_query_arg('type', $tab, uwp_get_account_page_url()); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | return $url; |
649 | 649 | |
650 | 650 | } |
651 | -add_filter( 'wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2 ); |
|
651 | +add_filter('wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2); |
|
652 | 652 | |
653 | 653 | /** |
654 | 654 | * Checks if the integration is enabled. |
@@ -657,8 +657,8 @@ discard block |
||
657 | 657 | * @return bool |
658 | 658 | */ |
659 | 659 | function getpaid_is_userswp_integration_active() { |
660 | - $enabled = wpinv_get_option( 'enable_userswp', 1 ); |
|
661 | - return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled ); |
|
660 | + $enabled = wpinv_get_option('enable_userswp', 1); |
|
661 | + return defined('USERSWP_PLUGIN_FILE') && !empty($enabled); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | /* |
@@ -676,26 +676,26 @@ discard block |
||
676 | 676 | * @param array $settings An array of integration settings. |
677 | 677 | * @return array |
678 | 678 | */ |
679 | -function getpaid_register_buddypress_settings( $settings ) { |
|
679 | +function getpaid_register_buddypress_settings($settings) { |
|
680 | 680 | |
681 | - if ( class_exists( 'BuddyPress' ) ) { |
|
681 | + if (class_exists('BuddyPress')) { |
|
682 | 682 | |
683 | 683 | $settings[] = array( |
684 | 684 | |
685 | 685 | 'id' => 'buddypress', |
686 | - 'label' => __( 'BuddyPress', 'invoicing' ), |
|
686 | + 'label' => __('BuddyPress', 'invoicing'), |
|
687 | 687 | 'settings' => array( |
688 | 688 | |
689 | 689 | 'buddypress_settings' => array( |
690 | 690 | 'id' => 'buddypress_settings', |
691 | - 'name' => '<h3>' . __( 'BuddyPress', 'invoicing' ) . '</h3>', |
|
691 | + 'name' => '<h3>' . __('BuddyPress', 'invoicing') . '</h3>', |
|
692 | 692 | 'type' => 'header', |
693 | 693 | ), |
694 | 694 | |
695 | 695 | 'enable_buddypress' => array( |
696 | 696 | 'id' => 'enable_buddypress', |
697 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
698 | - 'desc' => __( 'Display GetPaid items on BuddyPress account pages.', 'invoicing' ), |
|
697 | + 'name' => __('Enable Integration', 'invoicing'), |
|
698 | + 'desc' => __('Display GetPaid items on BuddyPress account pages.', 'invoicing'), |
|
699 | 699 | 'type' => 'checkbox', |
700 | 700 | 'std' => 1, |
701 | 701 | ), |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | return $settings; |
710 | 710 | } |
711 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_buddypress_settings' ); |
|
711 | +add_filter('getpaid_integration_settings', 'getpaid_register_buddypress_settings'); |
|
712 | 712 | |
713 | 713 | /** |
714 | 714 | * Checks if the integration is enabled. |
@@ -717,8 +717,8 @@ discard block |
||
717 | 717 | * @return bool |
718 | 718 | */ |
719 | 719 | function getpaid_is_buddypress_integration_active() { |
720 | - $enabled = wpinv_get_option( 'enable_buddypress', 1 ); |
|
721 | - return class_exists( 'BuddyPress' ) && ! empty( $enabled ); |
|
720 | + $enabled = wpinv_get_option('enable_buddypress', 1); |
|
721 | + return class_exists('BuddyPress') && !empty($enabled); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | /** |
@@ -729,13 +729,13 @@ discard block |
||
729 | 729 | */ |
730 | 730 | function getpaid_setup_buddypress_integration() { |
731 | 731 | |
732 | - if ( getpaid_is_buddypress_integration_active() ) { |
|
732 | + if (getpaid_is_buddypress_integration_active()) { |
|
733 | 733 | require_once WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php'; |
734 | 734 | buddypress()->getpaid = new BP_GetPaid_Component(); |
735 | 735 | } |
736 | 736 | |
737 | 737 | } |
738 | -add_action( 'bp_setup_components', 'getpaid_setup_buddypress_integration' ); |
|
738 | +add_action('bp_setup_components', 'getpaid_setup_buddypress_integration'); |
|
739 | 739 | |
740 | 740 | /** |
741 | 741 | * Checks if a given user has purchased a given item. |
@@ -744,10 +744,10 @@ discard block |
||
744 | 744 | * @param int $item_id The item id. |
745 | 745 | * @return int The IDs of users who purchased the item. |
746 | 746 | */ |
747 | -function getpaid_user_ids_who_purchased_item( $item_id ) { |
|
747 | +function getpaid_user_ids_who_purchased_item($item_id) { |
|
748 | 748 | global $wpdb; |
749 | 749 | |
750 | - if ( empty( $item_id ) ) { |
|
750 | + if (empty($item_id)) { |
|
751 | 751 | return false; |
752 | 752 | } |
753 | 753 | |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | ) |
761 | 761 | ); |
762 | 762 | |
763 | - return wp_parse_id_list( $ids ); |
|
763 | + return wp_parse_id_list($ids); |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | /** |
@@ -769,10 +769,10 @@ discard block |
||
769 | 769 | * @since 2.6.17 |
770 | 770 | * @param int $user_id The user id. |
771 | 771 | */ |
772 | -function getpaid_has_user_purchased_item( $user_id, $item_id ) { |
|
772 | +function getpaid_has_user_purchased_item($user_id, $item_id) { |
|
773 | 773 | global $wpdb; |
774 | 774 | |
775 | - if ( empty( $user_id ) ) { |
|
775 | + if (empty($user_id)) { |
|
776 | 776 | return false; |
777 | 777 | } |
778 | 778 | |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | ) |
788 | 788 | ); |
789 | 789 | |
790 | - return ! empty( $count ); |
|
790 | + return !empty($count); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | /** |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | * @since 2.6.17 |
797 | 797 | * @param int $user_id The user id. |
798 | 798 | */ |
799 | -function getpaid_get_user_total_spend( $user_id ) { |
|
799 | +function getpaid_get_user_total_spend($user_id) { |
|
800 | 800 | $args = array( |
801 | 801 | 'data' => array( |
802 | 802 | |
@@ -811,17 +811,17 @@ discard block |
||
811 | 811 | |
812 | 812 | 'author' => array( |
813 | 813 | 'type' => 'post_data', |
814 | - 'value' => absint( $user_id ), |
|
814 | + 'value' => absint($user_id), |
|
815 | 815 | 'key' => 'posts.post_author', |
816 | 816 | 'operator' => '=', |
817 | 817 | ), |
818 | 818 | |
819 | 819 | ), |
820 | 820 | 'query_type' => 'get_var', |
821 | - 'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ), |
|
821 | + 'invoice_status' => array('wpi-renewal', 'wpi-processing', 'publish'), |
|
822 | 822 | ); |
823 | 823 | |
824 | - return wpinv_round_amount( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
824 | + return wpinv_round_amount(GetPaid_Reports_Helper::get_invoice_report_data($args)); |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | /** |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | * @since 2.6.17 |
831 | 831 | * @param int $user_id The user id. |
832 | 832 | */ |
833 | -function getpaid_count_user_invoices( $user_id ) { |
|
833 | +function getpaid_count_user_invoices($user_id) { |
|
834 | 834 | $args = array( |
835 | 835 | 'data' => array( |
836 | 836 | |
@@ -846,17 +846,17 @@ discard block |
||
846 | 846 | |
847 | 847 | 'author' => array( |
848 | 848 | 'type' => 'post_data', |
849 | - 'value' => absint( $user_id ), |
|
849 | + 'value' => absint($user_id), |
|
850 | 850 | 'key' => 'posts.post_author', |
851 | 851 | 'operator' => '=', |
852 | 852 | ), |
853 | 853 | |
854 | 854 | ), |
855 | 855 | 'query_type' => 'get_var', |
856 | - 'invoice_status' => array_keys( wpinv_get_invoice_statuses() ), |
|
856 | + 'invoice_status' => array_keys(wpinv_get_invoice_statuses()), |
|
857 | 857 | ); |
858 | 858 | |
859 | - return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
859 | + return absint(GetPaid_Reports_Helper::get_invoice_report_data($args)); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | /** |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | * Default null, for no reassignment. |
870 | 870 | * @param WP_User $user WP_User object of the user to delete. |
871 | 871 | */ |
872 | -function getpaid_delete_user_data( $user_id, $reassign, $user ) { |
|
872 | +function getpaid_delete_user_data($user_id, $reassign, $user) { |
|
873 | 873 | global $wpdb; |
874 | 874 | |
875 | 875 | // Delete customer data. |
@@ -880,4 +880,4 @@ discard block |
||
880 | 880 | ) |
881 | 881 | ); |
882 | 882 | } |
883 | -add_action( 'delete_user', 'getpaid_delete_user_data', 10, 3 ); |
|
884 | 883 | \ No newline at end of file |
884 | +add_action('delete_user', 'getpaid_delete_user_data', 10, 3); |
|
885 | 885 | \ No newline at end of file |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -16,62 +16,62 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class GetPaid_Meta_Box_Invoice_Items { |
18 | 18 | |
19 | - public static function get_columns( $invoice ) { |
|
19 | + public static function get_columns($invoice) { |
|
20 | 20 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
21 | 21 | $columns = array( |
22 | - 'id' => __( 'ID', 'invoicing' ), |
|
23 | - 'title' => __( 'Item', 'invoicing' ), |
|
22 | + 'id' => __('ID', 'invoicing'), |
|
23 | + 'title' => __('Item', 'invoicing'), |
|
24 | 24 | 'price' => sprintf( |
25 | 25 | '<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span> |
26 | 26 | <span class="getpaid-hide-if-hours hide-if-amount">%s</span> |
27 | 27 | <span class="getpaid-hide-if-quantity hide-if-amount">%s</span>', |
28 | - __( 'Amount', 'invoicing' ), |
|
29 | - __( 'Price', 'invoicing' ), |
|
30 | - __( 'Rate', 'invoicing' ) |
|
28 | + __('Amount', 'invoicing'), |
|
29 | + __('Price', 'invoicing'), |
|
30 | + __('Rate', 'invoicing') |
|
31 | 31 | ), |
32 | 32 | 'qty' => sprintf( |
33 | 33 | '<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>', |
34 | - __( 'Quantity', 'invoicing' ), |
|
35 | - __( 'Hours', 'invoicing' ) |
|
34 | + __('Quantity', 'invoicing'), |
|
35 | + __('Hours', 'invoicing') |
|
36 | 36 | ), |
37 | - 'total' => __( 'Total', 'invoicing' ), |
|
37 | + 'total' => __('Total', 'invoicing'), |
|
38 | 38 | 'tax' => $invoice->get_item_tax_name(), |
39 | 39 | 'action' => '', |
40 | 40 | ); |
41 | 41 | |
42 | - if ( ! $use_taxes ) { |
|
43 | - unset( $columns['tax'] ); |
|
42 | + if (!$use_taxes) { |
|
43 | + unset($columns['tax']); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | return $columns; |
47 | 47 | } |
48 | 48 | |
49 | - public static function output( $post, $invoice = false ) { |
|
49 | + public static function output($post, $invoice = false) { |
|
50 | 50 | |
51 | - if ( apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) { |
|
52 | - return self::output2( $post ); |
|
51 | + if (apply_filters('getpaid_use_new_invoice_items_metabox', false)) { |
|
52 | + return self::output2($post); |
|
53 | 53 | } |
54 | 54 | |
55 | - $post_id = ! empty( $post->ID ) ? $post->ID : 0; |
|
56 | - $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id ); |
|
55 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
56 | + $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id); |
|
57 | 57 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
58 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
59 | - $columns = self::get_columns( $invoice ); |
|
60 | - $cols = count( $columns ); |
|
58 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
59 | + $columns = self::get_columns($invoice); |
|
60 | + $cols = count($columns); |
|
61 | 61 | $class = ''; |
62 | 62 | |
63 | - unset( $item_types['adv'] ); |
|
64 | - unset( $item_types['package'] ); |
|
63 | + unset($item_types['adv']); |
|
64 | + unset($item_types['package']); |
|
65 | 65 | |
66 | - if ( $invoice->is_paid() ) { |
|
66 | + if ($invoice->is_paid()) { |
|
67 | 67 | $class .= ' wpinv-paid'; |
68 | 68 | } |
69 | 69 | |
70 | - if ( $invoice->is_refunded() ) { |
|
70 | + if ($invoice->is_refunded()) { |
|
71 | 71 | $class .= ' wpinv-refunded'; |
72 | 72 | } |
73 | 73 | |
74 | - if ( $invoice->is_recurring() ) { |
|
74 | + if ($invoice->is_recurring()) { |
|
75 | 75 | $class .= ' wpi-recurring'; |
76 | 76 | } |
77 | 77 | |
@@ -87,26 +87,26 @@ discard block |
||
87 | 87 | ); |
88 | 88 | ?> |
89 | 89 | |
90 | - <div class="wpinv-items-wrap<?php echo esc_attr( $class ); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>"> |
|
90 | + <div class="wpinv-items-wrap<?php echo esc_attr($class); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>"> |
|
91 | 91 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
92 | 92 | |
93 | 93 | <thead> |
94 | 94 | <tr> |
95 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
95 | + <?php foreach ($columns as $key => $label) : ?> |
|
96 | 96 | <th class=" |
97 | 97 | <?php |
98 | - echo esc_attr( $key ); |
|
98 | + echo esc_attr($key); |
|
99 | 99 | echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : ''; |
100 | 100 | ?> |
101 | - "><?php echo wp_kses_post( $label ); ?></th> |
|
101 | + "><?php echo wp_kses_post($label); ?></th> |
|
102 | 102 | <?php endforeach; ?> |
103 | 103 | </tr> |
104 | 104 | </thead> |
105 | 105 | |
106 | 106 | <tbody class="wpinv-line-items"> |
107 | 107 | <?php |
108 | - foreach ( $invoice->get_items() as $int => $item ) { |
|
109 | - self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' ); |
|
108 | + foreach ($invoice->get_items() as $int => $item) { |
|
109 | + self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd'); |
|
110 | 110 | } |
111 | 111 | ?> |
112 | 112 | </tbody> |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | <div class="wp-clearfix"> |
124 | 124 | <label class="wpi-item-name"> |
125 | 125 | <span class="input-text-wrap"> |
126 | - <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
126 | + <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
127 | 127 | </span> |
128 | 128 | </label> |
129 | 129 | </div> |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | <div class="wp-clearfix"> |
132 | 132 | <label class="wpi-item-price"> |
133 | 133 | <span class="input-text-wrap"> |
134 | - <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' ); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
135 | - × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' ); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
134 | + <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
135 | + × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
136 | 136 | </span> |
137 | 137 | </label> |
138 | 138 | </div> |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | <div class="wp-clearfix"> |
141 | 141 | <label class="wpi-item-name"> |
142 | 142 | <span class="input-text-wrap"> |
143 | - <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' ); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
143 | + <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
144 | 144 | </span> |
145 | 145 | </label> |
146 | 146 | </div> |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | </label> |
166 | 166 | </div> |
167 | 167 | |
168 | - <?php if ( $use_taxes ) : ?> |
|
168 | + <?php if ($use_taxes) : ?> |
|
169 | 169 | <div class="wp-clearfix"> |
170 | 170 | <label class="wpi-vat-rule"> |
171 | 171 | <span class="input-text-wrap"> |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | wpinv_html_select( |
174 | 174 | array( |
175 | 175 | 'options' => array_merge( |
176 | - array( '' => __( 'Select VAT Rule', 'invoicing' ) ), |
|
176 | + array('' => __('Select VAT Rule', 'invoicing')), |
|
177 | 177 | getpaid_get_tax_rules() |
178 | 178 | ), |
179 | 179 | 'name' => '_wpinv_quick[vat_rule]', |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | wpinv_html_select( |
196 | 196 | array( |
197 | 197 | 'options' => array_merge( |
198 | - array( '' => __( 'Select VAT Class', 'invoicing' ) ), |
|
198 | + array('' => __('Select VAT Class', 'invoicing')), |
|
199 | 199 | getpaid_get_tax_classes() |
200 | 200 | ), |
201 | 201 | 'name' => '_wpinv_quick[vat_class]', |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | 'type' => 'checkbox', |
220 | 220 | 'name' => '_wpinv_quick[one-time]', |
221 | 221 | 'id' => '_wpinv_quick-one-time', |
222 | - 'label' => __( "One time item (won't be saved to regular items list)", 'invoicing' ), |
|
222 | + 'label' => __("One time item (won't be saved to regular items list)", 'invoicing'), |
|
223 | 223 | 'value' => 1, |
224 | 224 | 'no_wrap' => true, |
225 | 225 | 'checked' => false, |
@@ -243,39 +243,39 @@ discard block |
||
243 | 243 | </td> |
244 | 244 | </tr> |
245 | 245 | <tr class="totals"> |
246 | - <td colspan="<?php echo ( (int) $cols - 4 ); ?>"></td> |
|
246 | + <td colspan="<?php echo ((int) $cols - 4); ?>"></td> |
|
247 | 247 | <td colspan="4"> |
248 | 248 | <table cellspacing="0" cellpadding="0"> |
249 | 249 | <tr class="subtotal"> |
250 | - <td class="name"><?php esc_html_e( 'Sub Total:', 'invoicing' ); ?></td> |
|
251 | - <td class="total"><?php wpinv_the_price( $invoice->get_subtotal(), $invoice->get_currency() ); ?></td> |
|
250 | + <td class="name"><?php esc_html_e('Sub Total:', 'invoicing'); ?></td> |
|
251 | + <td class="total"><?php wpinv_the_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td> |
|
252 | 252 | <td class="action"></td> |
253 | 253 | </tr> |
254 | 254 | <tr class="discount"> |
255 | - <td class="name"><?php esc_html_e( 'Discount:', 'invoicing' ); ?></td> |
|
256 | - <td class="total"><?php wpinv_the_price( $invoice->get_total_discount(), $invoice->get_currency() ); ?></td> |
|
255 | + <td class="name"><?php esc_html_e('Discount:', 'invoicing'); ?></td> |
|
256 | + <td class="total"><?php wpinv_the_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td> |
|
257 | 257 | <td class="action"></td> |
258 | 258 | </tr> |
259 | - <?php if ( $use_taxes ) : ?> |
|
260 | - <?php if ( is_array( $taxes = $invoice->get_taxes() ) && wpinv_display_individual_tax_rates() ) { ?> |
|
261 | - <?php foreach ( $taxes as $tax_key => $tax_item ) { ?> |
|
259 | + <?php if ($use_taxes) : ?> |
|
260 | + <?php if (is_array($taxes = $invoice->get_taxes()) && wpinv_display_individual_tax_rates()) { ?> |
|
261 | + <?php foreach ($taxes as $tax_key => $tax_item) { ?> |
|
262 | 262 | <tr class="tax"> |
263 | - <td class="name"><?php echo esc_html( $invoice->get_tax_item_name( $tax_key, $tax_item, ':' ) ); ?></td> |
|
264 | - <td class="total"><?php wpinv_the_price( $invoice->get_tax_item_amount( $tax_key, $tax_item ), $invoice->get_currency() ); ?></td> |
|
263 | + <td class="name"><?php echo esc_html($invoice->get_tax_item_name($tax_key, $tax_item, ':')); ?></td> |
|
264 | + <td class="total"><?php wpinv_the_price($invoice->get_tax_item_amount($tax_key, $tax_item), $invoice->get_currency()); ?></td> |
|
265 | 265 | <td class="action"></td> |
266 | 266 | </tr> |
267 | 267 | <?php } ?> |
268 | 268 | <?php } else { ?> |
269 | 269 | <tr class="tax"> |
270 | - <td class="name"><?php esc_html_e( 'Tax:', 'invoicing' ); ?></td> |
|
271 | - <td class="total"><?php wpinv_the_price( $invoice->get_total_tax(), $invoice->get_currency() ); ?></td> |
|
270 | + <td class="name"><?php esc_html_e('Tax:', 'invoicing'); ?></td> |
|
271 | + <td class="total"><?php wpinv_the_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td> |
|
272 | 272 | <td class="action"></td> |
273 | 273 | </tr> |
274 | 274 | <?php } ?> |
275 | 275 | <?php endif; ?> |
276 | 276 | <tr class="total"> |
277 | - <td class="name"><?php esc_html_e( 'Total:', 'invoicing' ); ?></td> |
|
278 | - <td class="total"><?php wpinv_the_price( $invoice->get_total(), $invoice->get_currency() ); ?></td> |
|
277 | + <td class="name"><?php esc_html_e('Total:', 'invoicing'); ?></td> |
|
278 | + <td class="total"><?php wpinv_the_price($invoice->get_total(), $invoice->get_currency()); ?></td> |
|
279 | 279 | <td class="action"></td> |
280 | 280 | </tr> |
281 | 281 | </table> |
@@ -291,18 +291,18 @@ discard block |
||
291 | 291 | <div class="modal-dialog modal-dialog-centered" role="document"> |
292 | 292 | <div class="modal-content"> |
293 | 293 | <div class="modal-header"> |
294 | - <h5 class="modal-title" id="getpaid-refund-invoice-modal-label"><?php esc_html_e( 'Refund Payment', 'invoicing' ); ?></h5> |
|
295 | - <button type="button" class="close btn-close" data-bs-dismiss="modal" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>"> |
|
296 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
294 | + <h5 class="modal-title" id="getpaid-refund-invoice-modal-label"><?php esc_html_e('Refund Payment', 'invoicing'); ?></h5> |
|
295 | + <button type="button" class="close btn-close" data-bs-dismiss="modal" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>"> |
|
296 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
297 | 297 | <span aria-hidden="true">×</span> |
298 | 298 | <?php endif; ?> |
299 | 299 | </button> |
300 | 300 | </div> |
301 | 301 | <div class="modal-body"> |
302 | 302 | <p> |
303 | - <?php esc_html_e( 'Are you sure you want to refund this payment?', 'invoicing' ); ?> |
|
303 | + <?php esc_html_e('Are you sure you want to refund this payment?', 'invoicing'); ?> |
|
304 | 304 | </p> |
305 | - <?php if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) ) : ?> |
|
305 | + <?php if (getpaid_payment_gateway_supports($invoice->get_gateway(), 'refunds')) : ?> |
|
306 | 306 | <?php |
307 | 307 | aui()->input( |
308 | 308 | array( |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | 'id' => 'getpaid_refund_remote', |
312 | 312 | 'label' => sprintf( |
313 | 313 | 'Refund payment in %s', |
314 | - wpinv_get_gateway_admin_label( $invoice->get_gateway() ) |
|
314 | + wpinv_get_gateway_admin_label($invoice->get_gateway()) |
|
315 | 315 | ), |
316 | 316 | 'value' => 1, |
317 | 317 | 'class' => 'getpaid-refund-field', |
@@ -321,14 +321,14 @@ discard block |
||
321 | 321 | ?> |
322 | 322 | <?php endif; ?> |
323 | 323 | |
324 | - <?php if ( getpaid_get_invoice_subscriptions( $invoice ) ) : ?> |
|
324 | + <?php if (getpaid_get_invoice_subscriptions($invoice)) : ?> |
|
325 | 325 | <?php |
326 | 326 | aui()->input( |
327 | 327 | array( |
328 | 328 | 'type' => 'checkbox', |
329 | 329 | 'name' => 'getpaid_cancel_subscription', |
330 | 330 | 'id' => 'getpaid_cancel_subscription', |
331 | - 'label' => __( 'Cancel subscription', 'invoicing' ), |
|
331 | + 'label' => __('Cancel subscription', 'invoicing'), |
|
332 | 332 | 'value' => 1, |
333 | 333 | 'class' => 'getpaid-refund-field', |
334 | 334 | ), |
@@ -338,12 +338,12 @@ discard block |
||
338 | 338 | <?php endif; ?> |
339 | 339 | </div> |
340 | 340 | <div class="modal-footer"> |
341 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-bs-dismiss="modal" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
341 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-bs-dismiss="modal" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
342 | 342 | <a |
343 | - href="<?php echo esc_url_raw( $refund_url ); ?>" |
|
344 | - data-href="<?php echo esc_url_raw( $refund_url ); ?>" |
|
343 | + href="<?php echo esc_url_raw($refund_url); ?>" |
|
344 | + data-href="<?php echo esc_url_raw($refund_url); ?>" |
|
345 | 345 | class="btn btn-primary getpaid-refund-payment-button" |
346 | - ><?php esc_html_e( 'Refund', 'invoicing' ); ?></a> |
|
346 | + ><?php esc_html_e('Refund', 'invoicing'); ?></a> |
|
347 | 347 | <script> |
348 | 348 | // Update the refund URL when the user changes the refund options. |
349 | 349 | jQuery( function( $ ) { |
@@ -369,13 +369,13 @@ discard block |
||
369 | 369 | |
370 | 370 | <div class="wpinv-actions"> |
371 | 371 | <?php |
372 | - if ( $invoice->is_paid() ) { |
|
372 | + if ($invoice->is_paid()) { |
|
373 | 373 | |
374 | 374 | printf( |
375 | 375 | '<span class="bsui"><button type="button" class="button button-primary" data-toggle="modal" data-bs-toggle="modal" data-bs-target="#getpaid-refund-invoice-modal" data-target="#getpaid-refund-invoice-modal">%s</button></span>', |
376 | - esc_html__( 'Refund', 'invoicing' ) |
|
376 | + esc_html__('Refund', 'invoicing') |
|
377 | 377 | ); |
378 | - } elseif ( ! $invoice->is_refunded() ) { |
|
378 | + } elseif (!$invoice->is_refunded()) { |
|
379 | 379 | wpinv_item_dropdown( |
380 | 380 | array( |
381 | 381 | 'name' => 'wpinv_invoice_item', |
@@ -385,66 +385,66 @@ discard block |
||
385 | 385 | ) |
386 | 386 | ); |
387 | 387 | |
388 | - echo ' ' . '<button type="button" class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), esc_html( $invoice->get_label() ) ) . '</button>'; |
|
389 | - echo ' ' . '<button type="button" class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>'; |
|
390 | - echo ' ' . '<button type="button" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>'; |
|
388 | + echo ' ' . '<button type="button" class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), esc_html($invoice->get_label())) . '</button>'; |
|
389 | + echo ' ' . '<button type="button" class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>'; |
|
390 | + echo ' ' . '<button type="button" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>'; |
|
391 | 391 | |
392 | 392 | } |
393 | 393 | ?> |
394 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
394 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
395 | 395 | </div> |
396 | 396 | </div> |
397 | 397 | <?php |
398 | 398 | } |
399 | 399 | |
400 | - public static function output_row( $columns, $item, $invoice, $class = 'even' ) { |
|
400 | + public static function output_row($columns, $item, $invoice, $class = 'even') { |
|
401 | 401 | |
402 | 402 | ?> |
403 | - <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>"> |
|
404 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
403 | + <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>"> |
|
404 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
405 | 405 | <td class=" |
406 | 406 | <?php |
407 | - echo esc_attr( $column ); |
|
407 | + echo esc_attr($column); |
|
408 | 408 | echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : ''; |
409 | 409 | ?> |
410 | 410 | "> |
411 | 411 | <?php |
412 | - switch ( $column ) { |
|
412 | + switch ($column) { |
|
413 | 413 | case 'id': |
414 | 414 | echo (int) $item->get_id(); |
415 | 415 | break; |
416 | 416 | case 'title': |
417 | 417 | printf( |
418 | 418 | '<a href="%s" target="_blank">%s</a>', |
419 | - esc_url( get_edit_post_link( $item->get_id() ) ), |
|
420 | - esc_html( $item->get_raw_name() ) |
|
419 | + esc_url(get_edit_post_link($item->get_id())), |
|
420 | + esc_html($item->get_raw_name()) |
|
421 | 421 | ); |
422 | 422 | |
423 | - $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
424 | - if ( $summary !== '' ) { |
|
423 | + $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice); |
|
424 | + if ($summary !== '') { |
|
425 | 425 | printf( |
426 | 426 | '<span class="meta">%s</span>', |
427 | - wp_kses_post( wpautop( $summary ) ) |
|
427 | + wp_kses_post(wpautop($summary)) |
|
428 | 428 | ); |
429 | 429 | } |
430 | 430 | |
431 | 431 | printf( |
432 | 432 | '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />', |
433 | - esc_attr( $item->get_raw_name() ), |
|
433 | + esc_attr($item->get_raw_name()), |
|
434 | 434 | (int) $item->get_id() |
435 | 435 | ); |
436 | 436 | |
437 | 437 | printf( |
438 | 438 | '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>', |
439 | 439 | (int) $item->get_id(), |
440 | - esc_attr( $item->get_description() ) |
|
440 | + esc_attr($item->get_description()) |
|
441 | 441 | ); |
442 | 442 | |
443 | 443 | break; |
444 | 444 | case 'price': |
445 | 445 | printf( |
446 | 446 | '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />', |
447 | - esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ), |
|
447 | + esc_attr(getpaid_unstandardize_amount($item->get_price())), |
|
448 | 448 | (int) $item->get_id() |
449 | 449 | ); |
450 | 450 | |
@@ -452,26 +452,26 @@ discard block |
||
452 | 452 | case 'qty': |
453 | 453 | printf( |
454 | 454 | '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />', |
455 | - floatval( $item->get_quantity() ), |
|
455 | + floatval($item->get_quantity()), |
|
456 | 456 | (int) $item->get_id() |
457 | 457 | ); |
458 | 458 | |
459 | 459 | break; |
460 | 460 | case 'total': |
461 | - wpinv_the_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
461 | + wpinv_the_price($item->get_sub_total(), $invoice->get_currency()); |
|
462 | 462 | |
463 | 463 | break; |
464 | 464 | case 'tax': |
465 | - echo floatval( wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
465 | + echo floatval(wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2)) . '%'; |
|
466 | 466 | |
467 | 467 | break; |
468 | 468 | case 'action': |
469 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
469 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
470 | 470 | echo '<i class="fa fa-trash wpinv-item-remove"></i>'; |
471 | 471 | } |
472 | 472 | break; |
473 | 473 | } |
474 | - do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice ); |
|
474 | + do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice); |
|
475 | 475 | ?> |
476 | 476 | </td> |
477 | 477 | <?php endforeach; ?> |
@@ -484,10 +484,10 @@ discard block |
||
484 | 484 | * |
485 | 485 | * @param WP_Post $post |
486 | 486 | */ |
487 | - public static function output2( $post ) { |
|
487 | + public static function output2($post) { |
|
488 | 488 | |
489 | 489 | // Prepare the invoice. |
490 | - $invoice = new WPInv_Invoice( $post ); |
|
490 | + $invoice = new WPInv_Invoice($post); |
|
491 | 491 | |
492 | 492 | // Invoice items. |
493 | 493 | $items = $invoice->get_items(); |
@@ -495,28 +495,28 @@ discard block |
||
495 | 495 | $totals = array( |
496 | 496 | |
497 | 497 | 'subtotal' => array( |
498 | - 'label' => __( 'Items Subtotal', 'invoicing' ), |
|
499 | - 'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
498 | + 'label' => __('Items Subtotal', 'invoicing'), |
|
499 | + 'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
500 | 500 | ), |
501 | 501 | |
502 | 502 | 'discount' => array( |
503 | - 'label' => __( 'Total Discount', 'invoicing' ), |
|
504 | - 'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
503 | + 'label' => __('Total Discount', 'invoicing'), |
|
504 | + 'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
505 | 505 | ), |
506 | 506 | |
507 | 507 | 'tax' => array( |
508 | - 'label' => __( 'Total Tax', 'invoicing' ), |
|
509 | - 'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
508 | + 'label' => __('Total Tax', 'invoicing'), |
|
509 | + 'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
510 | 510 | ), |
511 | 511 | |
512 | 512 | 'total' => array( |
513 | - 'label' => __( 'Invoice Total', 'invoicing' ), |
|
514 | - 'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
|
513 | + 'label' => __('Invoice Total', 'invoicing'), |
|
514 | + 'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()), |
|
515 | 515 | ), |
516 | 516 | ); |
517 | 517 | |
518 | - if ( ! wpinv_use_taxes() ) { |
|
519 | - unset( $totals['tax'] ); |
|
518 | + if (!wpinv_use_taxes()) { |
|
519 | + unset($totals['tax']); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | $item_args = array( |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | 'orderby' => 'title', |
525 | 525 | 'order' => 'ASC', |
526 | 526 | 'posts_per_page' => -1, |
527 | - 'post_status' => array( 'publish' ), |
|
527 | + 'post_status' => array('publish'), |
|
528 | 528 | 'meta_query' => array( |
529 | 529 | array( |
530 | 530 | 'key' => '_wpinv_type', |
@@ -552,10 +552,10 @@ discard block |
||
552 | 552 | } |
553 | 553 | </style> |
554 | 554 | |
555 | - <div class="bsui getpaid-invoice-items-inner <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
|
555 | + <div class="bsui getpaid-invoice-items-inner <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
|
556 | 556 | |
557 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
558 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
557 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
558 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
559 | 559 | |
560 | 560 | <div class="row"> |
561 | 561 | <div class="col-12 col-sm-6"> |
@@ -564,15 +564,15 @@ discard block |
||
564 | 564 | array( |
565 | 565 | 'id' => 'wpinv_template', |
566 | 566 | 'name' => 'wpinv_template', |
567 | - 'label' => __( 'Template', 'invoicing' ), |
|
567 | + 'label' => __('Template', 'invoicing'), |
|
568 | 568 | 'label_type' => 'vertical', |
569 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
569 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
570 | 570 | 'class' => 'form-control-sm', |
571 | - 'value' => $invoice->get_template( 'edit' ), |
|
571 | + 'value' => $invoice->get_template('edit'), |
|
572 | 572 | 'options' => array( |
573 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
574 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
575 | - 'amount' => __( 'Amount Only', 'invoicing' ), |
|
573 | + 'quantity' => __('Quantity', 'invoicing'), |
|
574 | + 'hours' => __('Hours', 'invoicing'), |
|
575 | + 'amount' => __('Amount Only', 'invoicing'), |
|
576 | 576 | ), |
577 | 577 | 'data-allow-clear' => 'false', |
578 | 578 | 'select2' => true, |
@@ -589,11 +589,11 @@ discard block |
||
589 | 589 | array( |
590 | 590 | 'id' => 'wpinv_currency', |
591 | 591 | 'name' => 'wpinv_currency', |
592 | - 'label' => __( 'Currency', 'invoicing' ), |
|
592 | + 'label' => __('Currency', 'invoicing'), |
|
593 | 593 | 'label_type' => 'vertical', |
594 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
594 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
595 | 595 | 'class' => 'form-control-sm', |
596 | - 'value' => $invoice->get_currency( 'edit' ), |
|
596 | + 'value' => $invoice->get_currency('edit'), |
|
597 | 597 | 'required' => false, |
598 | 598 | 'data-allow-clear' => 'false', |
599 | 599 | 'select2' => true, |
@@ -606,24 +606,24 @@ discard block |
||
606 | 606 | </div> |
607 | 607 | </div> |
608 | 608 | |
609 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
609 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
610 | 610 | <?php endif; ?> |
611 | 611 | |
612 | 612 | <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items"> |
613 | 613 | <thead> |
614 | 614 | <tr> |
615 | - <th class="getpaid-item" colspan="2"><?php esc_html_e( 'Item', 'invoicing' ); ?></th> |
|
615 | + <th class="getpaid-item" colspan="2"><?php esc_html_e('Item', 'invoicing'); ?></th> |
|
616 | 616 | <th class="getpaid-quantity hide-if-amount text-right"> |
617 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
618 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ); ?></span> |
|
617 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
618 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing'); ?></span> |
|
619 | 619 | </th> |
620 | 620 | <th class="getpaid-price hide-if-amount text-right"> |
621 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
622 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Rate', 'invoicing' ); ?></span> |
|
621 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
622 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Rate', 'invoicing'); ?></span> |
|
623 | 623 | </th> |
624 | 624 | <th class="getpaid-item-subtotal text-right"> |
625 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
626 | - <span class="hide-if-amount"><?php esc_html_e( 'Total', 'invoicing' ); ?></span> |
|
625 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
626 | + <span class="hide-if-amount"><?php esc_html_e('Total', 'invoicing'); ?></span> |
|
627 | 627 | </th> |
628 | 628 | <th class="getpaid-item-actions hide-if-not-editable" width="70px"> </th> |
629 | 629 | </tr> |
@@ -631,8 +631,8 @@ discard block |
||
631 | 631 | <tbody class="getpaid_invoice_line_items"> |
632 | 632 | <tr class="hide-if-has-items hide-if-not-editable"> |
633 | 633 | <td colspan="2" class="pt-4 pb-4"> |
634 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Items', 'invoicing' ); ?></button> |
|
635 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ); ?></button> |
|
634 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Items', 'invoicing'); ?></button> |
|
635 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing'); ?></button> |
|
636 | 636 | </td> |
637 | 637 | <td class="hide-if-amount"> </th> |
638 | 638 | <td class="hide-if-amount"> </th> |
@@ -664,11 +664,11 @@ discard block |
||
664 | 664 | <div class="col-12 col-sm-6 offset-sm-6"> |
665 | 665 | <table class="getpaid-invoice-totals text-right w-100"> |
666 | 666 | <tbody> |
667 | - <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?> |
|
668 | - <tr class="getpaid-totals-<?php echo esc_attr( $key ); ?>"> |
|
669 | - <td class="label"><?php echo esc_html( $data['label'] ); ?>:</td> |
|
667 | + <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?> |
|
668 | + <tr class="getpaid-totals-<?php echo esc_attr($key); ?>"> |
|
669 | + <td class="label"><?php echo esc_html($data['label']); ?>:</td> |
|
670 | 670 | <td width="1%"></td> |
671 | - <td class="value"><?php echo wp_kses_post( $data['value'] ); ?></td> |
|
671 | + <td class="value"><?php echo wp_kses_post($data['value']); ?></td> |
|
672 | 672 | </tr> |
673 | 673 | <?php endforeach; ?> |
674 | 674 | </tbody> |
@@ -681,18 +681,18 @@ discard block |
||
681 | 681 | <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable"> |
682 | 682 | <div class="row"> |
683 | 683 | <div class="text-left col-12 col-sm-8"> |
684 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Item', 'invoicing' ); ?></button> |
|
685 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ); ?></button> |
|
686 | - <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?> |
|
684 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Item', 'invoicing'); ?></button> |
|
685 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing'); ?></button> |
|
686 | + <?php do_action('getpaid-invoice-items-actions', $invoice); ?> |
|
687 | 687 | </div> |
688 | 688 | <div class="text-right col-12 col-sm-4"> |
689 | - <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e( 'Recalculate Totals', 'invoicing' ); ?></button> |
|
689 | + <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e('Recalculate Totals', 'invoicing'); ?></button> |
|
690 | 690 | </div> |
691 | 691 | </div> |
692 | 692 | </div> |
693 | 693 | |
694 | 694 | <div class="getpaid-invoice-item-actions hide-if-editable"> |
695 | - <p class="description m-2 text-right text-muted"><?php esc_html_e( 'This invoice is no longer editable', 'invoicing' ); ?></p> |
|
695 | + <p class="description m-2 text-right text-muted"><?php esc_html_e('This invoice is no longer editable', 'invoicing'); ?></p> |
|
696 | 696 | </div> |
697 | 697 | |
698 | 698 | <!-- Add items to an invoice --> |
@@ -700,9 +700,9 @@ discard block |
||
700 | 700 | <div class="modal-dialog modal-dialog-centered" role="document"> |
701 | 701 | <div class="modal-content"> |
702 | 702 | <div class="modal-header"> |
703 | - <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e( 'Add Item(s)', 'invoicing' ); ?></h5> |
|
704 | - <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>"> |
|
705 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
703 | + <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e('Add Item(s)', 'invoicing'); ?></h5> |
|
704 | + <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>"> |
|
705 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
706 | 706 | <span aria-hidden="true">×</span> |
707 | 707 | <?php endif; ?> |
708 | 708 | </button> |
@@ -711,10 +711,10 @@ discard block |
||
711 | 711 | <table class="widefat"> |
712 | 712 | <thead> |
713 | 713 | <tr> |
714 | - <th class="pl-0 text-left"><?php esc_html_e( 'Item', 'invoicing' ); ?></th> |
|
714 | + <th class="pl-0 text-left"><?php esc_html_e('Item', 'invoicing'); ?></th> |
|
715 | 715 | <th class="pr-0 text-right hide-if-amount"> |
716 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
717 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ); ?></span> |
|
716 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
717 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing'); ?></span> |
|
718 | 718 | </th> |
719 | 719 | </tr> |
720 | 720 | </thead> |
@@ -722,9 +722,9 @@ discard block |
||
722 | 722 | <tr> |
723 | 723 | <td class="pl-0 text-left"> |
724 | 724 | <select class="regular-text getpaid-add-invoice-item-select"> |
725 | - <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option> |
|
726 | - <?php foreach ( get_posts( $item_args ) as $item ) : ?> |
|
727 | - <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html( $item->post_title ); ?></option> |
|
725 | + <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option> |
|
726 | + <?php foreach (get_posts($item_args) as $item) : ?> |
|
727 | + <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html($item->post_title); ?></option> |
|
728 | 728 | <?php endforeach; ?> |
729 | 729 | </select> |
730 | 730 | </td> |
@@ -736,8 +736,8 @@ discard block |
||
736 | 736 | </table> |
737 | 737 | </div> |
738 | 738 | <div class="modal-footer"> |
739 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
740 | - <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e( 'Add', 'invoicing' ); ?></button> |
|
739 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
740 | + <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e('Add', 'invoicing'); ?></button> |
|
741 | 741 | </div> |
742 | 742 | </div> |
743 | 743 | </div> |
@@ -748,9 +748,9 @@ discard block |
||
748 | 748 | <div class="modal-dialog modal-dialog-centered" role="document"> |
749 | 749 | <div class="modal-content"> |
750 | 750 | <div class="modal-header"> |
751 | - <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e( 'Create Item', 'invoicing' ); ?></h5> |
|
752 | - <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>"> |
|
753 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
751 | + <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e('Create Item', 'invoicing'); ?></h5> |
|
752 | + <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>"> |
|
753 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
754 | 754 | <span aria-hidden="true">×</span> |
755 | 755 | <?php endif; ?> |
756 | 756 | </button> |
@@ -759,27 +759,27 @@ discard block |
||
759 | 759 | <div class="getpaid-create-item-div"> |
760 | 760 | <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id"> |
761 | 761 | <label class="form-group mb-3 w-100"> |
762 | - <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span> |
|
763 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
762 | + <span><?php esc_html_e('Name', 'invoicing'); ?></span> |
|
763 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
764 | 764 | </label> |
765 | 765 | <label class="form-group mb-3 w-100"> |
766 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
767 | - <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
768 | - <input type="text" name="price" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control form-control-sm item-price"> |
|
766 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
767 | + <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
768 | + <input type="text" name="price" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control form-control-sm item-price"> |
|
769 | 769 | </label> |
770 | 770 | <label class="form-group mb-3 w-100 hide-if-amount"> |
771 | - <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
771 | + <span><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
772 | 772 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
773 | 773 | </label> |
774 | 774 | <label class="form-group mb-3 w-100"> |
775 | - <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span> |
|
776 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
775 | + <span><?php esc_html_e('Item Description', 'invoicing'); ?></span> |
|
776 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
777 | 777 | </label> |
778 | 778 | </div> |
779 | 779 | </div> |
780 | 780 | <div class="modal-footer"> |
781 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
782 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Create', 'invoicing' ); ?></button> |
|
781 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
782 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Create', 'invoicing'); ?></button> |
|
783 | 783 | </div> |
784 | 784 | </div> |
785 | 785 | </div> |
@@ -790,9 +790,9 @@ discard block |
||
790 | 790 | <div class="modal-dialog modal-dialog-centered" role="document"> |
791 | 791 | <div class="modal-content"> |
792 | 792 | <div class="modal-header"> |
793 | - <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e( 'Edit Item', 'invoicing' ); ?></h5> |
|
794 | - <button type="button" class="close close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>"> |
|
795 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
793 | + <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e('Edit Item', 'invoicing'); ?></h5> |
|
794 | + <button type="button" class="close close" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>"> |
|
795 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
796 | 796 | <span aria-hidden="true">×</span> |
797 | 797 | <?php endif; ?> |
798 | 798 | </button> |
@@ -801,27 +801,27 @@ discard block |
||
801 | 801 | <div class="getpaid-edit-item-div"> |
802 | 802 | <input type="hidden" name="id" class="form-control form-control-sm item-id"> |
803 | 803 | <label class="form-group mb-3 w-100"> |
804 | - <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span> |
|
805 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
804 | + <span><?php esc_html_e('Name', 'invoicing'); ?></span> |
|
805 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
806 | 806 | </label> |
807 | 807 | <label class="form-group mb-3 w-100"> |
808 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
809 | - <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
810 | - <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price"> |
|
808 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
809 | + <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
810 | + <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price"> |
|
811 | 811 | </label> |
812 | 812 | <label class="form-group mb-3 w-100 hide-if-amount"> |
813 | - <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
813 | + <span><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
814 | 814 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
815 | 815 | </label> |
816 | 816 | <label class="form-group mb-3 w-100"> |
817 | - <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span> |
|
818 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
817 | + <span><?php esc_html_e('Item Description', 'invoicing'); ?></span> |
|
818 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
819 | 819 | </label> |
820 | 820 | </div> |
821 | 821 | </div> |
822 | 822 | <div class="modal-footer"> |
823 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
824 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Save', 'invoicing' ); ?></button> |
|
823 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
824 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Save', 'invoicing'); ?></button> |
|
825 | 825 | </div> |
826 | 826 | </div> |
827 | 827 | </div> |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Payment form submission taxes class |
@@ -29,24 +29,24 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @param GetPaid_Payment_Form_Submission $submission |
31 | 31 | */ |
32 | - public function __construct( $submission ) { |
|
32 | + public function __construct($submission) { |
|
33 | 33 | // Validate VAT number. |
34 | - $this->validate_vat( $submission ); |
|
34 | + $this->validate_vat($submission); |
|
35 | 35 | |
36 | - if ( $this->skip_taxes ) { |
|
36 | + if ($this->skip_taxes) { |
|
37 | 37 | return; |
38 | 38 | } |
39 | 39 | |
40 | - foreach ( $submission->get_items() as $item ) { |
|
41 | - $this->process_item_tax( $item, $submission ); |
|
40 | + foreach ($submission->get_items() as $item) { |
|
41 | + $this->process_item_tax($item, $submission); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // Process any existing invoice taxes. |
45 | - if ( $submission->has_invoice() ) { |
|
45 | + if ($submission->has_invoice()) { |
|
46 | 46 | $invoice = $submission->get_invoice(); |
47 | - $invoice = $this->refresh_totals( $invoice, $submission ); |
|
47 | + $invoice = $this->refresh_totals($invoice, $submission); |
|
48 | 48 | |
49 | - $this->taxes = array_replace( $invoice->get_taxes(), $this->taxes ); |
|
49 | + $this->taxes = array_replace($invoice->get_taxes(), $this->taxes); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
@@ -57,26 +57,26 @@ discard block |
||
57 | 57 | * @param GetPaid_Form_Item $item |
58 | 58 | * @param GetPaid_Payment_Form_Submission $submission |
59 | 59 | */ |
60 | - public function process_item_tax( $item, $submission ) { |
|
60 | + public function process_item_tax($item, $submission) { |
|
61 | 61 | |
62 | - $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
63 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
64 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
65 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
62 | + $rates = getpaid_get_item_tax_rates($item, $submission->country, $submission->state); |
|
63 | + $rates = getpaid_filter_item_tax_rates($item, $rates); |
|
64 | + $taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates); |
|
65 | + $r_taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates); |
|
66 | 66 | |
67 | - foreach ( $taxes as $name => $amount ) { |
|
68 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
69 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
67 | + foreach ($taxes as $name => $amount) { |
|
68 | + $recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0; |
|
69 | + $tax = getpaid_prepare_item_tax($item, $name, $amount, $recurring); |
|
70 | 70 | |
71 | - $item->item_tax += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
71 | + $item->item_tax += wpinv_sanitize_amount($tax['initial_tax']); |
|
72 | 72 | |
73 | - if ( ! isset( $this->taxes[ $name ] ) ) { |
|
74 | - $this->taxes[ $name ] = $tax; |
|
73 | + if (!isset($this->taxes[$name])) { |
|
74 | + $this->taxes[$name] = $tax; |
|
75 | 75 | continue; |
76 | 76 | } |
77 | 77 | |
78 | - $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
79 | - $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
78 | + $this->taxes[$name]['initial_tax'] += $tax['initial_tax']; |
|
79 | + $this->taxes[$name]['recurring_tax'] += $tax['recurring_tax']; |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | * @since 1.0.19 |
90 | 90 | * @return bool |
91 | 91 | */ |
92 | - public function has_digital_item( $submission ) { |
|
92 | + public function has_digital_item($submission) { |
|
93 | 93 | |
94 | - foreach ( $submission->get_items() as $item ) { |
|
94 | + foreach ($submission->get_items() as $item) { |
|
95 | 95 | |
96 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
96 | + if ('digital' == $item->get_vat_rule()) { |
|
97 | 97 | return true; |
98 | 98 | } |
99 | 99 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @return bool |
109 | 109 | */ |
110 | 110 | public static function is_eu_store() { |
111 | - return self::is_eu_country( wpinv_get_default_country() ); |
|
111 | + return self::is_eu_country(wpinv_get_default_country()); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * @since 1.0.19 |
119 | 119 | * @return bool |
120 | 120 | */ |
121 | - public static function is_eu_country( $country ) { |
|
122 | - return getpaid_is_eu_state( $country ); |
|
121 | + public static function is_eu_country($country) { |
|
122 | + return getpaid_is_eu_state($country); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * @since 1.0.19 |
130 | 130 | * @return bool |
131 | 131 | */ |
132 | - public static function is_eu_transaction( $customer_country ) { |
|
133 | - return self::is_eu_country( $customer_country ) && self::is_eu_store(); |
|
132 | + public static function is_eu_transaction($customer_country) { |
|
133 | + return self::is_eu_country($customer_country) && self::is_eu_store(); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | * @since 1.0.19 |
141 | 141 | * @return string |
142 | 142 | */ |
143 | - public function get_vat_number( $submission ) { |
|
143 | + public function get_vat_number($submission) { |
|
144 | 144 | |
145 | 145 | // Retrieve from the posted number. |
146 | - $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
147 | - if ( ! is_null( $vat_number ) ) { |
|
148 | - return wpinv_clean( $vat_number ); |
|
146 | + $vat_number = $submission->get_field('wpinv_vat_number', 'billing'); |
|
147 | + if (!is_null($vat_number)) { |
|
148 | + return wpinv_clean($vat_number); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : ''; |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | * @since 1.0.19 |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - public function get_company( $submission ) { |
|
161 | + public function get_company($submission) { |
|
162 | 162 | |
163 | 163 | // Retrieve from the posted data. |
164 | - $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
165 | - if ( ! empty( $company ) ) { |
|
166 | - return wpinv_clean( $company ); |
|
164 | + $company = $submission->get_field('wpinv_company', 'billing'); |
|
165 | + if (!empty($company)) { |
|
166 | + return wpinv_clean($company); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | // Retrieve from the invoice. |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | * @since 1.0.19 |
179 | 179 | * @return string |
180 | 180 | */ |
181 | - public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
181 | + public function requires_vat($ip_in_eu, $country_in_eu) { |
|
182 | 182 | |
183 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
184 | - $prevent_b2c = ! empty( $prevent_b2c ); |
|
183 | + $prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase'); |
|
184 | + $prevent_b2c = !empty($prevent_b2c); |
|
185 | 185 | $is_eu = $ip_in_eu || $country_in_eu; |
186 | 186 | |
187 | 187 | return $prevent_b2c && $is_eu; |
@@ -193,43 +193,43 @@ discard block |
||
193 | 193 | * @param GetPaid_Payment_Form_Submission $submission |
194 | 194 | * @since 1.0.19 |
195 | 195 | */ |
196 | - public function validate_vat( $submission ) { |
|
196 | + public function validate_vat($submission) { |
|
197 | 197 | |
198 | - $in_eu = $this->is_eu_transaction( $submission->country ); |
|
198 | + $in_eu = $this->is_eu_transaction($submission->country); |
|
199 | 199 | |
200 | 200 | // Abort if we are not validating vat numbers. |
201 | - if ( ! $in_eu ) { |
|
201 | + if (!$in_eu) { |
|
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
205 | 205 | // Prepare variables. |
206 | - $vat_number = $this->get_vat_number( $submission ); |
|
206 | + $vat_number = $this->get_vat_number($submission); |
|
207 | 207 | $ip_country = getpaid_get_ip_country(); |
208 | - $is_eu = $this->is_eu_country( $submission->country ); |
|
209 | - $is_ip_eu = $this->is_eu_country( $ip_country ); |
|
208 | + $is_eu = $this->is_eu_country($submission->country); |
|
209 | + $is_ip_eu = $this->is_eu_country($ip_country); |
|
210 | 210 | |
211 | 211 | // Maybe abort early for initial fetches. |
212 | - if ( $submission->is_initial_fetch() && empty( $vat_number ) ) { |
|
212 | + if ($submission->is_initial_fetch() && empty($vat_number)) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | 216 | // If we're preventing business to consumer purchases, |
217 | - if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
217 | + if ($this->requires_vat($is_ip_eu, $is_eu) && empty($vat_number)) { |
|
218 | 218 | |
219 | 219 | // Ensure that a vat number has been specified. |
220 | - throw new GetPaid_Payment_Exception( '.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) ); |
|
220 | + throw new GetPaid_Payment_Exception('.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __('Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing')); |
|
221 | 221 | |
222 | 222 | } |
223 | 223 | |
224 | - if ( empty( $vat_number ) ) { |
|
224 | + if (empty($vat_number)) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
228 | - if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
229 | - throw new GetPaid_Payment_Exception( '.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
228 | + if (wpinv_should_validate_vat_number() && !wpinv_validate_vat_number($vat_number, $submission->country)) { |
|
229 | + throw new GetPaid_Payment_Exception('.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __('Your VAT number is invalid', 'invoicing')); |
|
230 | 230 | } |
231 | 231 | |
232 | - if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
232 | + if (wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) { |
|
233 | 233 | return; |
234 | 234 | } |
235 | 235 | |
@@ -245,19 +245,19 @@ discard block |
||
245 | 245 | * @param GetPaid_Payment_Form_Submission $submission Payment form submission object. |
246 | 246 | * @return object Invoice object. |
247 | 247 | */ |
248 | - public function refresh_totals( $invoice, $submission ) { |
|
249 | - if ( ! ( ! empty( $_POST['action'] ) && ( $_POST['action'] == 'wpinv_payment_form_refresh_prices' || $_POST['action'] == 'wpinv_payment_form' ) && isset( $_POST['billing']['wpinv_country'] ) ) ) { |
|
248 | + public function refresh_totals($invoice, $submission) { |
|
249 | + if (!(!empty($_POST['action']) && ($_POST['action'] == 'wpinv_payment_form_refresh_prices' || $_POST['action'] == 'wpinv_payment_form') && isset($_POST['billing']['wpinv_country']))) { |
|
250 | 250 | return $invoice; |
251 | 251 | } |
252 | 252 | |
253 | - if ( ! ( ! $invoice->is_paid() && ! $invoice->is_refunded() && ! $invoice->is_held() ) ) { |
|
253 | + if (!(!$invoice->is_paid() && !$invoice->is_refunded() && !$invoice->is_held())) { |
|
254 | 254 | return $invoice; |
255 | 255 | } |
256 | 256 | |
257 | 257 | // Maybe check the country, state. |
258 | - if ( $submission->country != $invoice->get_country() || $submission->state != $invoice->get_state() ) { |
|
259 | - $invoice->set_country( sanitize_text_field( $submission->country ) ); |
|
260 | - $invoice->set_state( sanitize_text_field( $submission->state ) ); |
|
258 | + if ($submission->country != $invoice->get_country() || $submission->state != $invoice->get_state()) { |
|
259 | + $invoice->set_country(sanitize_text_field($submission->country)); |
|
260 | + $invoice->set_state(sanitize_text_field($submission->state)); |
|
261 | 261 | |
262 | 262 | // Recalculate totals. |
263 | 263 | $invoice->recalculate_total(); |