@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | 142 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
143 | + return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -175,125 +175,125 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
178 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
179 | 179 | |
180 | - // Setup possible parts |
|
181 | - $templates = array(); |
|
182 | - if ( isset( $name ) ) { |
|
183 | - $templates[] = $slug . '-' . $name . '.php'; |
|
180 | + // Setup possible parts |
|
181 | + $templates = array(); |
|
182 | + if ( isset( $name ) ) { |
|
183 | + $templates[] = $slug . '-' . $name . '.php'; |
|
184 | 184 | } |
185 | - $templates[] = $slug . '.php'; |
|
185 | + $templates[] = $slug . '.php'; |
|
186 | 186 | |
187 | - // Allow template parts to be filtered |
|
188 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
187 | + // Allow template parts to be filtered |
|
188 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
189 | 189 | |
190 | - // Return the part that is found |
|
191 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
190 | + // Return the part that is found |
|
191 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
195 | - // No file found yet |
|
196 | - $located = false; |
|
195 | + // No file found yet |
|
196 | + $located = false; |
|
197 | 197 | |
198 | - // Try to find a template file |
|
199 | - foreach ( (array)$template_names as $template_name ) { |
|
198 | + // Try to find a template file |
|
199 | + foreach ( (array)$template_names as $template_name ) { |
|
200 | 200 | |
201 | - // Continue if template is empty |
|
202 | - if ( empty( $template_name ) ) { |
|
203 | - continue; |
|
201 | + // Continue if template is empty |
|
202 | + if ( empty( $template_name ) ) { |
|
203 | + continue; |
|
204 | 204 | } |
205 | 205 | |
206 | - // Trim off any slashes from the template name |
|
207 | - $template_name = ltrim( $template_name, '/' ); |
|
206 | + // Trim off any slashes from the template name |
|
207 | + $template_name = ltrim( $template_name, '/' ); |
|
208 | 208 | |
209 | - // try locating this template file by looping through the template paths |
|
210 | - foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
209 | + // try locating this template file by looping through the template paths |
|
210 | + foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
211 | 211 | |
212 | - if ( file_exists( $template_path . $template_name ) ) { |
|
213 | - $located = $template_path . $template_name; |
|
214 | - break; |
|
215 | - } |
|
216 | - } |
|
212 | + if ( file_exists( $template_path . $template_name ) ) { |
|
213 | + $located = $template_path . $template_name; |
|
214 | + break; |
|
215 | + } |
|
216 | + } |
|
217 | 217 | |
218 | - if ( ! empty( $located ) ) { |
|
219 | - break; |
|
220 | - } |
|
221 | - } |
|
218 | + if ( ! empty( $located ) ) { |
|
219 | + break; |
|
220 | + } |
|
221 | + } |
|
222 | 222 | |
223 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
224 | - load_template( $located, $require_once ); |
|
223 | + if ( ( true == $load ) && ! empty( $located ) ) { |
|
224 | + load_template( $located, $require_once ); |
|
225 | 225 | } |
226 | 226 | |
227 | - return $located; |
|
227 | + return $located; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | function wpinv_get_theme_template_paths() { |
231 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
231 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
232 | 232 | |
233 | - $file_paths = array( |
|
234 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
235 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
236 | - 100 => wpinv_get_templates_dir(), |
|
237 | - ); |
|
233 | + $file_paths = array( |
|
234 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
235 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
236 | + 100 => wpinv_get_templates_dir(), |
|
237 | + ); |
|
238 | 238 | |
239 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
239 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
240 | 240 | |
241 | - // sort the file paths based on priority |
|
242 | - ksort( $file_paths, SORT_NUMERIC ); |
|
241 | + // sort the file paths based on priority |
|
242 | + ksort( $file_paths, SORT_NUMERIC ); |
|
243 | 243 | |
244 | - return array_map( 'trailingslashit', $file_paths ); |
|
244 | + return array_map( 'trailingslashit', $file_paths ); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | function wpinv_checkout_meta_tags() { |
248 | 248 | |
249 | - $pages = array(); |
|
250 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
251 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
252 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
253 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
249 | + $pages = array(); |
|
250 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
251 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
252 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
253 | + $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
254 | 254 | |
255 | - if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
256 | - return; |
|
257 | - } |
|
255 | + if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
256 | + return; |
|
257 | + } |
|
258 | 258 | |
259 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
259 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
260 | 260 | } |
261 | 261 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
262 | 262 | |
263 | 263 | function wpinv_add_body_classes( $class ) { |
264 | - $classes = (array)$class; |
|
264 | + $classes = (array)$class; |
|
265 | 265 | |
266 | - if ( wpinv_is_checkout() ) { |
|
267 | - $classes[] = 'wpinv-checkout'; |
|
268 | - $classes[] = 'wpinv-page'; |
|
269 | - } |
|
266 | + if ( wpinv_is_checkout() ) { |
|
267 | + $classes[] = 'wpinv-checkout'; |
|
268 | + $classes[] = 'wpinv-page'; |
|
269 | + } |
|
270 | 270 | |
271 | - if ( wpinv_is_success_page() ) { |
|
272 | - $classes[] = 'wpinv-success'; |
|
273 | - $classes[] = 'wpinv-page'; |
|
274 | - } |
|
271 | + if ( wpinv_is_success_page() ) { |
|
272 | + $classes[] = 'wpinv-success'; |
|
273 | + $classes[] = 'wpinv-page'; |
|
274 | + } |
|
275 | 275 | |
276 | - if ( wpinv_is_failed_transaction_page() ) { |
|
277 | - $classes[] = 'wpinv-failed-transaction'; |
|
278 | - $classes[] = 'wpinv-page'; |
|
279 | - } |
|
276 | + if ( wpinv_is_failed_transaction_page() ) { |
|
277 | + $classes[] = 'wpinv-failed-transaction'; |
|
278 | + $classes[] = 'wpinv-page'; |
|
279 | + } |
|
280 | 280 | |
281 | - if ( wpinv_is_invoice_history_page() ) { |
|
282 | - $classes[] = 'wpinv-history'; |
|
283 | - $classes[] = 'wpinv-page'; |
|
284 | - } |
|
281 | + if ( wpinv_is_invoice_history_page() ) { |
|
282 | + $classes[] = 'wpinv-history'; |
|
283 | + $classes[] = 'wpinv-page'; |
|
284 | + } |
|
285 | 285 | |
286 | - if ( wpinv_is_subscriptions_history_page() ) { |
|
287 | - $classes[] = 'wpinv-subscription'; |
|
288 | - $classes[] = 'wpinv-page'; |
|
289 | - } |
|
286 | + if ( wpinv_is_subscriptions_history_page() ) { |
|
287 | + $classes[] = 'wpinv-subscription'; |
|
288 | + $classes[] = 'wpinv-page'; |
|
289 | + } |
|
290 | 290 | |
291 | - if ( wpinv_is_test_mode() ) { |
|
292 | - $classes[] = 'wpinv-test-mode'; |
|
293 | - $classes[] = 'wpinv-page'; |
|
294 | - } |
|
291 | + if ( wpinv_is_test_mode() ) { |
|
292 | + $classes[] = 'wpinv-test-mode'; |
|
293 | + $classes[] = 'wpinv-page'; |
|
294 | + } |
|
295 | 295 | |
296 | - return array_unique( $classes ); |
|
296 | + return array_unique( $classes ); |
|
297 | 297 | } |
298 | 298 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
299 | 299 | |
@@ -458,16 +458,16 @@ discard block |
||
458 | 458 | |
459 | 459 | wpinv_html_select( |
460 | 460 | array( |
461 | - 'name' => $args['name'], |
|
462 | - 'selected' => $args['selected'], |
|
463 | - 'id' => $args['id'], |
|
464 | - 'class' => $args['class'], |
|
465 | - 'options' => $options, |
|
466 | - 'multiple' => $args['multiple'], |
|
467 | - 'placeholder' => $args['placeholder'], |
|
468 | - 'show_option_all' => $args['show_option_all'], |
|
469 | - 'show_option_none' => $args['show_option_none'], |
|
470 | - 'data' => $args['data'], |
|
461 | + 'name' => $args['name'], |
|
462 | + 'selected' => $args['selected'], |
|
463 | + 'id' => $args['id'], |
|
464 | + 'class' => $args['class'], |
|
465 | + 'options' => $options, |
|
466 | + 'multiple' => $args['multiple'], |
|
467 | + 'placeholder' => $args['placeholder'], |
|
468 | + 'show_option_all' => $args['show_option_all'], |
|
469 | + 'show_option_none' => $args['show_option_none'], |
|
470 | + 'data' => $args['data'], |
|
471 | 471 | ) |
472 | 472 | ); |
473 | 473 | |
@@ -767,21 +767,21 @@ discard block |
||
767 | 767 | |
768 | 768 | $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
769 | 769 | |
770 | - // Remove unavailable tags. |
|
770 | + // Remove unavailable tags. |
|
771 | 771 | $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address ); |
772 | 772 | |
773 | 773 | // Clean up white space. |
774 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
774 | + $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
775 | 775 | $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
776 | 776 | |
777 | 777 | // Break newlines apart and remove empty lines/trim commas and white space. |
778 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
778 | + $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
779 | 779 | |
780 | 780 | // Add html breaks. |
781 | - $formatted_address = implode( $separator, $formatted_address ); |
|
781 | + $formatted_address = implode( $separator, $formatted_address ); |
|
782 | 782 | |
783 | - // We're done! |
|
784 | - return $formatted_address; |
|
783 | + // We're done! |
|
784 | + return $formatted_address; |
|
785 | 785 | |
786 | 786 | } |
787 | 787 | |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | function getpaid_display_invoice_subscriptions( $invoice ) { |
828 | 828 | |
829 | 829 | // Subscriptions. |
830 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
830 | + $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
831 | 831 | |
832 | 832 | if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
833 | 833 | return; |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | function wpinv_empty_cart_message() { |
1042 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1042 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | /** |
@@ -1237,9 +1237,9 @@ discard block |
||
1237 | 1237 | |
1238 | 1238 | if ( 0 == count( $form->get_items() ) ) { |
1239 | 1239 | aui()->alert( |
1240 | - array( |
|
1241 | - 'type' => 'warning', |
|
1242 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1240 | + array( |
|
1241 | + 'type' => 'warning', |
|
1242 | + 'content' => __( 'No published items found', 'invoicing' ), |
|
1243 | 1243 | ), |
1244 | 1244 | true |
1245 | 1245 | ); |
@@ -1262,10 +1262,10 @@ discard block |
||
1262 | 1262 | $invoice = wpinv_get_invoice( $invoice_id ); |
1263 | 1263 | |
1264 | 1264 | if ( empty( $invoice ) ) { |
1265 | - aui()->alert( |
|
1266 | - array( |
|
1267 | - 'type' => 'warning', |
|
1268 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1265 | + aui()->alert( |
|
1266 | + array( |
|
1267 | + 'type' => 'warning', |
|
1268 | + 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1269 | 1269 | ), |
1270 | 1270 | true |
1271 | 1271 | ); |
@@ -1273,10 +1273,10 @@ discard block |
||
1273 | 1273 | } |
1274 | 1274 | |
1275 | 1275 | if ( $invoice->is_paid() ) { |
1276 | - aui()->alert( |
|
1277 | - array( |
|
1278 | - 'type' => 'warning', |
|
1279 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1276 | + aui()->alert( |
|
1277 | + array( |
|
1278 | + 'type' => 'warning', |
|
1279 | + 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1280 | 1280 | ), |
1281 | 1281 | true |
1282 | 1282 | ); |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
1341 | 1341 | } |
1342 | 1342 | |
1343 | - if ( ! empty( $items ) ) { |
|
1343 | + if ( ! empty( $items ) ) { |
|
1344 | 1344 | $items = esc_attr( $items ); |
1345 | 1345 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
1346 | 1346 | } |
@@ -1526,21 +1526,21 @@ discard block |
||
1526 | 1526 | |
1527 | 1527 | return aui()->select( |
1528 | 1528 | array( |
1529 | - 'options' => $states, |
|
1530 | - 'name' => esc_attr( $field_name ), |
|
1531 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1532 | - 'value' => sanitize_text_field( $state ), |
|
1533 | - 'placeholder' => $placeholder, |
|
1534 | - 'required' => $required, |
|
1535 | - 'label' => wp_kses_post( $label ), |
|
1536 | - 'label_type' => 'vertical', |
|
1537 | - 'help_text' => $help_text, |
|
1538 | - 'class' => 'getpaid-address-field wpinv_state', |
|
1539 | - 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
|
1540 | - 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
|
1541 | - 'extra_attributes' => array( |
|
1542 | - 'autocomplete' => 'address-level1', |
|
1543 | - ), |
|
1529 | + 'options' => $states, |
|
1530 | + 'name' => esc_attr( $field_name ), |
|
1531 | + 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1532 | + 'value' => sanitize_text_field( $state ), |
|
1533 | + 'placeholder' => $placeholder, |
|
1534 | + 'required' => $required, |
|
1535 | + 'label' => wp_kses_post( $label ), |
|
1536 | + 'label_type' => 'vertical', |
|
1537 | + 'help_text' => $help_text, |
|
1538 | + 'class' => 'getpaid-address-field wpinv_state', |
|
1539 | + 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
|
1540 | + 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
|
1541 | + 'extra_attributes' => array( |
|
1542 | + 'autocomplete' => 'address-level1', |
|
1543 | + ), |
|
1544 | 1544 | ), |
1545 | 1545 | $echo |
1546 | 1546 | ); |
@@ -4,99 +4,99 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Displays an invoice. |
11 | 11 | * |
12 | 12 | * @param WPInv_Invoice $invoice. |
13 | 13 | */ |
14 | -function getpaid_invoice( $invoice ) { |
|
15 | - if ( ! empty( $invoice ) ) { |
|
16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
14 | +function getpaid_invoice($invoice) { |
|
15 | + if (!empty($invoice)) { |
|
16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
17 | 17 | } |
18 | 18 | } |
19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Displays the invoice footer. |
23 | 23 | */ |
24 | -function getpaid_invoice_footer( $invoice ) { |
|
25 | - if ( ! empty( $invoice ) ) { |
|
26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
24 | +function getpaid_invoice_footer($invoice) { |
|
25 | + if (!empty($invoice)) { |
|
26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
27 | 27 | } |
28 | 28 | } |
29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Displays the invoice top bar. |
33 | 33 | */ |
34 | -function getpaid_invoice_header( $invoice ) { |
|
35 | - if ( ! empty( $invoice ) ) { |
|
36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
34 | +function getpaid_invoice_header($invoice) { |
|
35 | + if (!empty($invoice)) { |
|
36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
37 | 37 | } |
38 | 38 | } |
39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Displays actions on the left side of the header. |
43 | 43 | */ |
44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
45 | - if ( ! empty( $invoice ) ) { |
|
46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
45 | + if (!empty($invoice)) { |
|
46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
47 | 47 | } |
48 | 48 | } |
49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Displays actions on the right side of the invoice top bar. |
53 | 53 | */ |
54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
55 | - if ( ! empty( $invoice ) ) { |
|
56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
55 | + if (!empty($invoice)) { |
|
56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
57 | 57 | } |
58 | 58 | } |
59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Displays the invoice title, logo etc. |
63 | 63 | */ |
64 | -function getpaid_invoice_details_top( $invoice ) { |
|
65 | - if ( ! empty( $invoice ) ) { |
|
66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
64 | +function getpaid_invoice_details_top($invoice) { |
|
65 | + if (!empty($invoice)) { |
|
66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
67 | 67 | } |
68 | 68 | } |
69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Displays the company logo. |
73 | 73 | */ |
74 | -function getpaid_invoice_logo( $invoice ) { |
|
75 | - if ( ! empty( $invoice ) ) { |
|
76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
74 | +function getpaid_invoice_logo($invoice) { |
|
75 | + if (!empty($invoice)) { |
|
76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
77 | 77 | } |
78 | 78 | } |
79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Displays the type of invoice. |
83 | 83 | */ |
84 | -function getpaid_invoice_type( $invoice ) { |
|
85 | - if ( ! empty( $invoice ) ) { |
|
86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
84 | +function getpaid_invoice_type($invoice) { |
|
85 | + if (!empty($invoice)) { |
|
86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
87 | 87 | } |
88 | 88 | } |
89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Displays the invoice details. |
93 | 93 | */ |
94 | -function getpaid_invoice_details_main( $invoice ) { |
|
95 | - if ( ! empty( $invoice ) ) { |
|
96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
94 | +function getpaid_invoice_details_main($invoice) { |
|
95 | + if (!empty($invoice)) { |
|
96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
97 | 97 | } |
98 | 98 | } |
99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
127 | 127 | */ |
128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
129 | - getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
129 | + getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return string |
150 | 150 | */ |
151 | 151 | function wpinv_template_path() { |
152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,58 +170,58 @@ discard block |
||
170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
172 | 172 | */ |
173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
175 | 175 | } |
176 | 176 | |
177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
179 | 179 | |
180 | 180 | // Setup possible parts |
181 | 181 | $templates = array(); |
182 | - if ( isset( $name ) ) { |
|
182 | + if (isset($name)) { |
|
183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
184 | 184 | } |
185 | 185 | $templates[] = $slug . '.php'; |
186 | 186 | |
187 | 187 | // Allow template parts to be filtered |
188 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
188 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
189 | 189 | |
190 | 190 | // Return the part that is found |
191 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
191 | + return wpinv_locate_tmpl($templates, $load, false); |
|
192 | 192 | } |
193 | 193 | |
194 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
194 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
195 | 195 | // No file found yet |
196 | 196 | $located = false; |
197 | 197 | |
198 | 198 | // Try to find a template file |
199 | - foreach ( (array)$template_names as $template_name ) { |
|
199 | + foreach ((array) $template_names as $template_name) { |
|
200 | 200 | |
201 | 201 | // Continue if template is empty |
202 | - if ( empty( $template_name ) ) { |
|
202 | + if (empty($template_name)) { |
|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 | |
206 | 206 | // Trim off any slashes from the template name |
207 | - $template_name = ltrim( $template_name, '/' ); |
|
207 | + $template_name = ltrim($template_name, '/'); |
|
208 | 208 | |
209 | 209 | // try locating this template file by looping through the template paths |
210 | - foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
210 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
211 | 211 | |
212 | - if ( file_exists( $template_path . $template_name ) ) { |
|
212 | + if (file_exists($template_path . $template_name)) { |
|
213 | 213 | $located = $template_path . $template_name; |
214 | 214 | break; |
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | - if ( ! empty( $located ) ) { |
|
218 | + if (!empty($located)) { |
|
219 | 219 | break; |
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
224 | - load_template( $located, $require_once ); |
|
223 | + if ((true == $load) && !empty($located)) { |
|
224 | + load_template($located, $require_once); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return $located; |
@@ -231,73 +231,73 @@ discard block |
||
231 | 231 | $template_dir = wpinv_get_theme_template_dir_name(); |
232 | 232 | |
233 | 233 | $file_paths = array( |
234 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
235 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
234 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
235 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
236 | 236 | 100 => wpinv_get_templates_dir(), |
237 | 237 | ); |
238 | 238 | |
239 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
239 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
240 | 240 | |
241 | 241 | // sort the file paths based on priority |
242 | - ksort( $file_paths, SORT_NUMERIC ); |
|
242 | + ksort($file_paths, SORT_NUMERIC); |
|
243 | 243 | |
244 | - return array_map( 'trailingslashit', $file_paths ); |
|
244 | + return array_map('trailingslashit', $file_paths); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | function wpinv_checkout_meta_tags() { |
248 | 248 | |
249 | 249 | $pages = array(); |
250 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
251 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
252 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
253 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
250 | + $pages[] = wpinv_get_option('success_page'); |
|
251 | + $pages[] = wpinv_get_option('failure_page'); |
|
252 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
253 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
254 | 254 | |
255 | - if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
255 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | 258 | |
259 | 259 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
260 | 260 | } |
261 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
261 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
262 | 262 | |
263 | -function wpinv_add_body_classes( $class ) { |
|
264 | - $classes = (array)$class; |
|
263 | +function wpinv_add_body_classes($class) { |
|
264 | + $classes = (array) $class; |
|
265 | 265 | |
266 | - if ( wpinv_is_checkout() ) { |
|
266 | + if (wpinv_is_checkout()) { |
|
267 | 267 | $classes[] = 'wpinv-checkout'; |
268 | 268 | $classes[] = 'wpinv-page'; |
269 | 269 | } |
270 | 270 | |
271 | - if ( wpinv_is_success_page() ) { |
|
271 | + if (wpinv_is_success_page()) { |
|
272 | 272 | $classes[] = 'wpinv-success'; |
273 | 273 | $classes[] = 'wpinv-page'; |
274 | 274 | } |
275 | 275 | |
276 | - if ( wpinv_is_failed_transaction_page() ) { |
|
276 | + if (wpinv_is_failed_transaction_page()) { |
|
277 | 277 | $classes[] = 'wpinv-failed-transaction'; |
278 | 278 | $classes[] = 'wpinv-page'; |
279 | 279 | } |
280 | 280 | |
281 | - if ( wpinv_is_invoice_history_page() ) { |
|
281 | + if (wpinv_is_invoice_history_page()) { |
|
282 | 282 | $classes[] = 'wpinv-history'; |
283 | 283 | $classes[] = 'wpinv-page'; |
284 | 284 | } |
285 | 285 | |
286 | - if ( wpinv_is_subscriptions_history_page() ) { |
|
286 | + if (wpinv_is_subscriptions_history_page()) { |
|
287 | 287 | $classes[] = 'wpinv-subscription'; |
288 | 288 | $classes[] = 'wpinv-page'; |
289 | 289 | } |
290 | 290 | |
291 | - if ( wpinv_is_test_mode() ) { |
|
291 | + if (wpinv_is_test_mode()) { |
|
292 | 292 | $classes[] = 'wpinv-test-mode'; |
293 | 293 | $classes[] = 'wpinv-page'; |
294 | 294 | } |
295 | 295 | |
296 | - return array_unique( $classes ); |
|
296 | + return array_unique($classes); |
|
297 | 297 | } |
298 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
298 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
299 | 299 | |
300 | -function wpinv_html_select( $args = array() ) { |
|
300 | +function wpinv_html_select($args = array()) { |
|
301 | 301 | $defaults = array( |
302 | 302 | 'options' => array(), |
303 | 303 | 'name' => null, |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | 'selected' => 0, |
307 | 307 | 'placeholder' => null, |
308 | 308 | 'multiple' => false, |
309 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
310 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
309 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
310 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
311 | 311 | 'data' => array(), |
312 | 312 | 'onchange' => null, |
313 | 313 | 'required' => false, |
@@ -315,79 +315,79 @@ discard block |
||
315 | 315 | 'readonly' => false, |
316 | 316 | ); |
317 | 317 | |
318 | - $args = wp_parse_args( $args, $defaults ); |
|
318 | + $args = wp_parse_args($args, $defaults); |
|
319 | 319 | |
320 | 320 | $attrs = array( |
321 | 321 | 'name' => $args['name'], |
322 | 322 | 'id' => $args['id'], |
323 | - 'class' => 'wpinv-select ' . implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ), |
|
324 | - 'multiple' => ! empty( $args['multiple'] ), |
|
325 | - 'readonly' => ! empty( $args['readonly'] ), |
|
326 | - 'disabled' => ! empty( $args['disabled'] ), |
|
327 | - 'required' => ! empty( $args['required'] ), |
|
328 | - 'onchange' => ! empty( $args['onchange'] ), |
|
323 | + 'class' => 'wpinv-select ' . implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))), |
|
324 | + 'multiple' => !empty($args['multiple']), |
|
325 | + 'readonly' => !empty($args['readonly']), |
|
326 | + 'disabled' => !empty($args['disabled']), |
|
327 | + 'required' => !empty($args['required']), |
|
328 | + 'onchange' => !empty($args['onchange']), |
|
329 | 329 | ); |
330 | 330 | |
331 | - if ( $args['placeholder'] ) { |
|
331 | + if ($args['placeholder']) { |
|
332 | 332 | $attrs['data-placeholder'] = $args['placeholder']; |
333 | 333 | } |
334 | 334 | |
335 | - if ( $args['onchange'] ) { |
|
335 | + if ($args['onchange']) { |
|
336 | 336 | $attrs['onchange'] = $args['onchange']; |
337 | 337 | } |
338 | 338 | |
339 | - foreach ( $args['data'] as $key => $value ) { |
|
339 | + foreach ($args['data'] as $key => $value) { |
|
340 | 340 | $attrs["data-$key"] = $value; |
341 | 341 | } |
342 | 342 | |
343 | 343 | echo '<select '; |
344 | 344 | |
345 | - foreach ( $attrs as $attr => $value ) { |
|
345 | + foreach ($attrs as $attr => $value) { |
|
346 | 346 | |
347 | - if ( false === $value ) { |
|
347 | + if (false === $value) { |
|
348 | 348 | continue; |
349 | 349 | } |
350 | 350 | |
351 | - if ( true === $value ) { |
|
352 | - echo ' ' . esc_attr( $attr ); |
|
351 | + if (true === $value) { |
|
352 | + echo ' ' . esc_attr($attr); |
|
353 | 353 | } else { |
354 | - echo ' ' . esc_attr( $attr ) . '="' . esc_attr( $value ) . '"'; |
|
354 | + echo ' ' . esc_attr($attr) . '="' . esc_attr($value) . '"'; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | } |
358 | 358 | |
359 | 359 | echo '>'; |
360 | 360 | |
361 | - if ( $args['show_option_all'] ) { |
|
362 | - if ( $args['multiple'] ) { |
|
363 | - $selected = in_array( 0, $args['selected'] ); |
|
361 | + if ($args['show_option_all']) { |
|
362 | + if ($args['multiple']) { |
|
363 | + $selected = in_array(0, $args['selected']); |
|
364 | 364 | } else { |
365 | - $selected = empty( $args['selected'] ); |
|
365 | + $selected = empty($args['selected']); |
|
366 | 366 | } |
367 | - echo '<option value="all"' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
367 | + echo '<option value="all"' . selected($selected, true, false) . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
368 | 368 | } |
369 | 369 | |
370 | - if ( ! empty( $args['options'] ) ) { |
|
370 | + if (!empty($args['options'])) { |
|
371 | 371 | |
372 | - if ( $args['show_option_none'] ) { |
|
373 | - if ( $args['multiple'] ) { |
|
374 | - $selected = in_array( '', $args['selected'] ); |
|
372 | + if ($args['show_option_none']) { |
|
373 | + if ($args['multiple']) { |
|
374 | + $selected = in_array('', $args['selected']); |
|
375 | 375 | } else { |
376 | 376 | $selected = $args['selected'] === ''; |
377 | 377 | } |
378 | 378 | |
379 | - echo '<option value=""' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
379 | + echo '<option value=""' . selected($selected, true, false) . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
380 | 380 | } |
381 | 381 | |
382 | - foreach ( $args['options'] as $key => $option ) { |
|
382 | + foreach ($args['options'] as $key => $option) { |
|
383 | 383 | |
384 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
385 | - $selected = in_array( $key, $args['selected'] ); |
|
384 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
385 | + $selected = in_array($key, $args['selected']); |
|
386 | 386 | } else { |
387 | 387 | $selected = $args['selected'] == $key; |
388 | 388 | } |
389 | 389 | |
390 | - echo '<option value="' . esc_attr( $key ) . '"' . selected( $selected, true, false ) . '>' . esc_html( $option ) . '</option>'; |
|
390 | + echo '<option value="' . esc_attr($key) . '"' . selected($selected, true, false) . '>' . esc_html($option) . '</option>'; |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | |
396 | 396 | } |
397 | 397 | |
398 | -function wpinv_item_dropdown( $args = array() ) { |
|
398 | +function wpinv_item_dropdown($args = array()) { |
|
399 | 399 | $defaults = array( |
400 | 400 | 'name' => 'wpi_item', |
401 | 401 | 'id' => 'wpi_item', |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | 'multiple' => false, |
404 | 404 | 'selected' => 0, |
405 | 405 | 'number' => -1, |
406 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
407 | - 'data' => array( 'search-type' => 'item' ), |
|
406 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
407 | + 'data' => array('search-type' => 'item'), |
|
408 | 408 | 'show_option_all' => false, |
409 | 409 | 'show_option_none' => false, |
410 | 410 | 'show_recurring' => false, |
411 | 411 | ); |
412 | 412 | |
413 | - $args = wp_parse_args( $args, $defaults ); |
|
413 | + $args = wp_parse_args($args, $defaults); |
|
414 | 414 | |
415 | 415 | $item_args = array( |
416 | 416 | 'post_type' => 'wpi_item', |
@@ -419,40 +419,40 @@ discard block |
||
419 | 419 | 'posts_per_page' => $args['number'], |
420 | 420 | ); |
421 | 421 | |
422 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
422 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
423 | 423 | |
424 | - $items = get_posts( $item_args ); |
|
424 | + $items = get_posts($item_args); |
|
425 | 425 | $options = array(); |
426 | - if ( $items ) { |
|
427 | - foreach ( $items as $item ) { |
|
428 | - $title = esc_html( $item->post_title ); |
|
426 | + if ($items) { |
|
427 | + foreach ($items as $item) { |
|
428 | + $title = esc_html($item->post_title); |
|
429 | 429 | |
430 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
431 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
430 | + if (!empty($args['show_recurring'])) { |
|
431 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
432 | 432 | } |
433 | 433 | |
434 | - $options[ absint( $item->ID ) ] = $title; |
|
434 | + $options[absint($item->ID)] = $title; |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | |
438 | 438 | // This ensures that any selected items are included in the drop down |
439 | - if ( is_array( $args['selected'] ) ) { |
|
440 | - foreach ( $args['selected'] as $item ) { |
|
441 | - if ( ! in_array( $item, $options ) ) { |
|
442 | - $title = get_the_title( $item ); |
|
443 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
444 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
439 | + if (is_array($args['selected'])) { |
|
440 | + foreach ($args['selected'] as $item) { |
|
441 | + if (!in_array($item, $options)) { |
|
442 | + $title = get_the_title($item); |
|
443 | + if (!empty($args['show_recurring'])) { |
|
444 | + $title .= wpinv_get_item_suffix($item, false); |
|
445 | 445 | } |
446 | - $options[ $item ] = $title; |
|
446 | + $options[$item] = $title; |
|
447 | 447 | } |
448 | 448 | } |
449 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
450 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
451 | - $title = get_the_title( $args['selected'] ); |
|
452 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
453 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
449 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
450 | + if (!in_array($args['selected'], $options)) { |
|
451 | + $title = get_the_title($args['selected']); |
|
452 | + if (!empty($args['show_recurring'])) { |
|
453 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
454 | 454 | } |
455 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
455 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
@@ -488,16 +488,16 @@ discard block |
||
488 | 488 | ); |
489 | 489 | |
490 | 490 | $options = array(); |
491 | - if ( $items ) { |
|
492 | - foreach ( $items as $item ) { |
|
493 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
491 | + if ($items) { |
|
492 | + foreach ($items as $item) { |
|
493 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | 497 | return $options; |
498 | 498 | } |
499 | 499 | |
500 | -function wpinv_html_checkbox( $args = array() ) { |
|
500 | +function wpinv_html_checkbox($args = array()) { |
|
501 | 501 | $defaults = array( |
502 | 502 | 'name' => null, |
503 | 503 | 'current' => null, |
@@ -508,17 +508,17 @@ discard block |
||
508 | 508 | ), |
509 | 509 | ); |
510 | 510 | |
511 | - $args = wp_parse_args( $args, $defaults ); |
|
511 | + $args = wp_parse_args($args, $defaults); |
|
512 | 512 | |
513 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
513 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
514 | 514 | $attr = ''; |
515 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
515 | + if (!empty($args['options']['disabled'])) { |
|
516 | 516 | $attr .= ' disabled="disabled"'; |
517 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
517 | + } elseif (!empty($args['options']['readonly'])) { |
|
518 | 518 | $attr .= ' readonly'; |
519 | 519 | } |
520 | 520 | |
521 | - $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . esc_attr( $class ) . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
521 | + $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . esc_attr($class) . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
522 | 522 | |
523 | 523 | return $output; |
524 | 524 | } |
@@ -526,34 +526,34 @@ discard block |
||
526 | 526 | /** |
527 | 527 | * Displays a hidden field. |
528 | 528 | */ |
529 | -function getpaid_hidden_field( $name, $value ) { |
|
530 | - echo "<input type='hidden' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' />"; |
|
529 | +function getpaid_hidden_field($name, $value) { |
|
530 | + echo "<input type='hidden' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' />"; |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
534 | 534 | * Displays a submit field. |
535 | 535 | */ |
536 | -function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) { |
|
537 | - echo "<input type='submit' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' class='btn " . esc_attr( $class ) . "' />"; |
|
536 | +function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') { |
|
537 | + echo "<input type='submit' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' class='btn " . esc_attr($class) . "' />"; |
|
538 | 538 | } |
539 | 539 | |
540 | -function wpinv_html_text( $args = array() ) { |
|
540 | +function wpinv_html_text($args = array()) { |
|
541 | 541 | // Backwards compatibility |
542 | - if ( func_num_args() > 1 ) { |
|
542 | + if (func_num_args() > 1) { |
|
543 | 543 | $args = func_get_args(); |
544 | 544 | |
545 | 545 | $name = $args[0]; |
546 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
547 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
548 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
546 | + $value = isset($args[1]) ? $args[1] : ''; |
|
547 | + $label = isset($args[2]) ? $args[2] : ''; |
|
548 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | $defaults = array( |
552 | 552 | 'id' => '', |
553 | - 'name' => isset( $name ) ? $name : 'text', |
|
554 | - 'value' => isset( $value ) ? $value : null, |
|
555 | - 'label' => isset( $label ) ? $label : null, |
|
556 | - 'desc' => isset( $desc ) ? $desc : null, |
|
553 | + 'name' => isset($name) ? $name : 'text', |
|
554 | + 'value' => isset($value) ? $value : null, |
|
555 | + 'label' => isset($label) ? $label : null, |
|
556 | + 'desc' => isset($desc) ? $desc : null, |
|
557 | 557 | 'placeholder' => '', |
558 | 558 | 'class' => 'regular-text', |
559 | 559 | 'disabled' => false, |
@@ -563,41 +563,41 @@ discard block |
||
563 | 563 | 'data' => false, |
564 | 564 | ); |
565 | 565 | |
566 | - $args = wp_parse_args( $args, $defaults ); |
|
566 | + $args = wp_parse_args($args, $defaults); |
|
567 | 567 | |
568 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
568 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
569 | 569 | $options = ''; |
570 | - if ( $args['required'] ) { |
|
570 | + if ($args['required']) { |
|
571 | 571 | $options .= ' required="required"'; |
572 | 572 | } |
573 | - if ( $args['readonly'] ) { |
|
573 | + if ($args['readonly']) { |
|
574 | 574 | $options .= ' readonly'; |
575 | 575 | } |
576 | - if ( $args['readonly'] ) { |
|
576 | + if ($args['readonly']) { |
|
577 | 577 | $options .= ' readonly'; |
578 | 578 | } |
579 | 579 | |
580 | 580 | $data = ''; |
581 | - if ( ! empty( $args['data'] ) ) { |
|
582 | - foreach ( $args['data'] as $key => $value ) { |
|
583 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
581 | + if (!empty($args['data'])) { |
|
582 | + foreach ($args['data'] as $key => $value) { |
|
583 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
588 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
589 | - if ( ! empty( $args['desc'] ) ) { |
|
590 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
587 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
588 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
589 | + if (!empty($args['desc'])) { |
|
590 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
591 | 591 | } |
592 | 592 | |
593 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
593 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
594 | 594 | |
595 | 595 | $output .= '</span>'; |
596 | 596 | |
597 | 597 | return $output; |
598 | 598 | } |
599 | 599 | |
600 | -function wpinv_html_textarea( $args = array() ) { |
|
600 | +function wpinv_html_textarea($args = array()) { |
|
601 | 601 | $defaults = array( |
602 | 602 | 'name' => 'textarea', |
603 | 603 | 'value' => null, |
@@ -608,31 +608,31 @@ discard block |
||
608 | 608 | 'placeholder' => '', |
609 | 609 | ); |
610 | 610 | |
611 | - $args = wp_parse_args( $args, $defaults ); |
|
611 | + $args = wp_parse_args($args, $defaults); |
|
612 | 612 | |
613 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
613 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
614 | 614 | $disabled = ''; |
615 | - if ( $args['disabled'] ) { |
|
615 | + if ($args['disabled']) { |
|
616 | 616 | $disabled = ' disabled="disabled"'; |
617 | 617 | } |
618 | 618 | |
619 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
620 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
621 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
619 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
620 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
621 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
622 | 622 | |
623 | - if ( ! empty( $args['desc'] ) ) { |
|
624 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
623 | + if (!empty($args['desc'])) { |
|
624 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
625 | 625 | } |
626 | 626 | $output .= '</span>'; |
627 | 627 | |
628 | 628 | return $output; |
629 | 629 | } |
630 | 630 | |
631 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
631 | +function wpinv_html_ajax_user_search($args = array()) { |
|
632 | 632 | $defaults = array( |
633 | 633 | 'name' => 'user_id', |
634 | 634 | 'value' => null, |
635 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
635 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
636 | 636 | 'label' => null, |
637 | 637 | 'desc' => null, |
638 | 638 | 'class' => '', |
@@ -641,13 +641,13 @@ discard block |
||
641 | 641 | 'data' => false, |
642 | 642 | ); |
643 | 643 | |
644 | - $args = wp_parse_args( $args, $defaults ); |
|
644 | + $args = wp_parse_args($args, $defaults); |
|
645 | 645 | |
646 | 646 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
647 | 647 | |
648 | 648 | $output = '<span class="wpinv_user_search_wrap">'; |
649 | - $output .= wpinv_html_text( $args ); |
|
650 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
649 | + $output .= wpinv_html_text($args); |
|
650 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
651 | 651 | $output .= '</span>'; |
652 | 652 | |
653 | 653 | return $output; |
@@ -658,44 +658,44 @@ discard block |
||
658 | 658 | * |
659 | 659 | * @param string $template the template that is currently being used. |
660 | 660 | */ |
661 | -function wpinv_template( $template ) { |
|
661 | +function wpinv_template($template) { |
|
662 | 662 | global $post; |
663 | 663 | |
664 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
664 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
665 | 665 | |
666 | 666 | // If the user can view this invoice, display it. |
667 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
667 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
668 | 668 | |
669 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
669 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
670 | 670 | |
671 | 671 | // Else display an error message. |
672 | 672 | } else { |
673 | 673 | |
674 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
674 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
675 | 675 | |
676 | 676 | } |
677 | 677 | } |
678 | 678 | |
679 | 679 | return $template; |
680 | 680 | } |
681 | -add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
681 | +add_filter('template_include', 'wpinv_template', 10, 1); |
|
682 | 682 | |
683 | 683 | function wpinv_get_business_address() { |
684 | 684 | $business_address = wpinv_store_address(); |
685 | - $business_address = ! empty( $business_address ) ? wp_kses_post( wpautop( $business_address ) ) : ''; |
|
685 | + $business_address = !empty($business_address) ? wp_kses_post(wpautop($business_address)) : ''; |
|
686 | 686 | |
687 | 687 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
688 | 688 | |
689 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
689 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
693 | 693 | * Displays the company address. |
694 | 694 | */ |
695 | 695 | function wpinv_display_from_address() { |
696 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
696 | + wpinv_get_template('invoice/company-address.php'); |
|
697 | 697 | } |
698 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
698 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
699 | 699 | |
700 | 700 | /** |
701 | 701 | * Generates a watermark text for an invoice. |
@@ -703,9 +703,9 @@ discard block |
||
703 | 703 | * @param WPInv_Invoice $invoice |
704 | 704 | * @return string |
705 | 705 | */ |
706 | -function wpinv_watermark( $invoice ) { |
|
707 | - $watermark = wpinv_get_watermark( $invoice ); |
|
708 | - return apply_filters( 'wpinv_get_watermark', $watermark, $invoice ); |
|
706 | +function wpinv_watermark($invoice) { |
|
707 | + $watermark = wpinv_get_watermark($invoice); |
|
708 | + return apply_filters('wpinv_get_watermark', $watermark, $invoice); |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | /** |
@@ -714,37 +714,37 @@ discard block |
||
714 | 714 | * @param WPInv_Invoice $invoice |
715 | 715 | * @return string |
716 | 716 | */ |
717 | -function wpinv_get_watermark( $invoice ) { |
|
717 | +function wpinv_get_watermark($invoice) { |
|
718 | 718 | return $invoice->get_status_nicename(); |
719 | 719 | } |
720 | 720 | |
721 | 721 | /** |
722 | 722 | * @deprecated |
723 | 723 | */ |
724 | -function wpinv_display_invoice_details( $invoice ) { |
|
725 | - return getpaid_invoice_meta( $invoice ); |
|
724 | +function wpinv_display_invoice_details($invoice) { |
|
725 | + return getpaid_invoice_meta($invoice); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | /** |
729 | 729 | * Displays invoice meta. |
730 | 730 | */ |
731 | -function getpaid_invoice_meta( $invoice ) { |
|
731 | +function getpaid_invoice_meta($invoice) { |
|
732 | 732 | |
733 | - $invoice = new WPInv_Invoice( $invoice ); |
|
733 | + $invoice = new WPInv_Invoice($invoice); |
|
734 | 734 | |
735 | 735 | // Ensure that we have an invoice. |
736 | - if ( 0 == $invoice->get_id() ) { |
|
736 | + if (0 == $invoice->get_id()) { |
|
737 | 737 | return; |
738 | 738 | } |
739 | 739 | |
740 | 740 | // Get the invoice meta. |
741 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
741 | + $meta = getpaid_get_invoice_meta($invoice); |
|
742 | 742 | |
743 | 743 | // Display the meta. |
744 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
744 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
745 | 745 | |
746 | 746 | } |
747 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
747 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
748 | 748 | |
749 | 749 | /** |
750 | 750 | * Retrieves the address markup to use on Invoices. |
@@ -756,29 +756,29 @@ discard block |
||
756 | 756 | * @param string $separator How to separate address lines. |
757 | 757 | * @return string |
758 | 758 | */ |
759 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
759 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
760 | 760 | |
761 | 761 | // Retrieve the address markup... |
762 | - $country = empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
763 | - $format = wpinv_get_full_address_format( $country ); |
|
762 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
763 | + $format = wpinv_get_full_address_format($country); |
|
764 | 764 | |
765 | 765 | // ... and the replacements. |
766 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
766 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
767 | 767 | |
768 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
768 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
769 | 769 | |
770 | 770 | // Remove unavailable tags. |
771 | - $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address ); |
|
771 | + $formatted_address = preg_replace('/\{\{\w+\}\}/', '', $formatted_address); |
|
772 | 772 | |
773 | 773 | // Clean up white space. |
774 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
775 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
774 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
775 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
776 | 776 | |
777 | 777 | // Break newlines apart and remove empty lines/trim commas and white space. |
778 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
778 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
779 | 779 | |
780 | 780 | // Add html breaks. |
781 | - $formatted_address = implode( $separator, $formatted_address ); |
|
781 | + $formatted_address = implode($separator, $formatted_address); |
|
782 | 782 | |
783 | 783 | // We're done! |
784 | 784 | return $formatted_address; |
@@ -790,118 +790,118 @@ discard block |
||
790 | 790 | * |
791 | 791 | * @param WPInv_Invoice $invoice |
792 | 792 | */ |
793 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
794 | - if ( ! empty( $invoice ) ) { |
|
795 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
793 | +function wpinv_display_to_address($invoice = 0) { |
|
794 | + if (!empty($invoice)) { |
|
795 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
796 | 796 | } |
797 | 797 | } |
798 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
798 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
799 | 799 | |
800 | 800 | |
801 | 801 | /** |
802 | 802 | * Displays invoice line items. |
803 | 803 | */ |
804 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
804 | +function wpinv_display_line_items($invoice_id = 0) { |
|
805 | 805 | |
806 | 806 | // Prepare the invoice. |
807 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
807 | + $invoice = new WPInv_Invoice($invoice_id); |
|
808 | 808 | |
809 | 809 | // Abort if there is no invoice. |
810 | - if ( 0 == $invoice->get_id() ) { |
|
810 | + if (0 == $invoice->get_id()) { |
|
811 | 811 | return; |
812 | 812 | } |
813 | 813 | |
814 | 814 | // Line item columns. |
815 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
816 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
815 | + $columns = getpaid_invoice_item_columns($invoice); |
|
816 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
817 | 817 | |
818 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
818 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
819 | 819 | } |
820 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
820 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
821 | 821 | |
822 | 822 | /** |
823 | 823 | * Displays invoice subscriptions. |
824 | 824 | * |
825 | 825 | * @param WPInv_Invoice $invoice |
826 | 826 | */ |
827 | -function getpaid_display_invoice_subscriptions( $invoice ) { |
|
827 | +function getpaid_display_invoice_subscriptions($invoice) { |
|
828 | 828 | |
829 | 829 | // Subscriptions. |
830 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
830 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
831 | 831 | |
832 | - if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
|
832 | + if (empty($subscriptions) || !$invoice->is_recurring()) { |
|
833 | 833 | return; |
834 | 834 | } |
835 | 835 | |
836 | - $main_subscription = getpaid_get_invoice_subscription( $invoice ); |
|
836 | + $main_subscription = getpaid_get_invoice_subscription($invoice); |
|
837 | 837 | |
838 | 838 | // Display related subscriptions. |
839 | - if ( is_array( $subscriptions ) ) { |
|
840 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) ); |
|
841 | - getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false ); |
|
839 | + if (is_array($subscriptions)) { |
|
840 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing')); |
|
841 | + getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false); |
|
842 | 842 | } |
843 | 843 | |
844 | - if ( $main_subscription->get_total_payments() > 1 ) { |
|
845 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) ); |
|
846 | - getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false ); |
|
844 | + if ($main_subscription->get_total_payments() > 1) { |
|
845 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing')); |
|
846 | + getpaid_admin_subscription_invoice_details_metabox($main_subscription, false); |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | } |
850 | -add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55 ); |
|
851 | -add_action( 'wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11 ); |
|
850 | +add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55); |
|
851 | +add_action('wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11); |
|
852 | 852 | |
853 | 853 | /** |
854 | 854 | * Displays invoice notices on invoices. |
855 | 855 | */ |
856 | 856 | function wpinv_display_invoice_notice() { |
857 | 857 | |
858 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
859 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
858 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
859 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
860 | 860 | |
861 | - if ( empty( $label ) && empty( $notice ) ) { |
|
861 | + if (empty($label) && empty($notice)) { |
|
862 | 862 | return; |
863 | 863 | } |
864 | 864 | |
865 | 865 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
866 | 866 | |
867 | - if ( ! empty( $label ) ) { |
|
868 | - echo "<h5>" . esc_html( $label ) . "</h5>"; |
|
867 | + if (!empty($label)) { |
|
868 | + echo "<h5>" . esc_html($label) . "</h5>"; |
|
869 | 869 | } |
870 | 870 | |
871 | - if ( ! empty( $notice ) ) { |
|
872 | - echo '<small class="form-text text-muted">' . wp_kses_post( wpautop( wptexturize( $notice ) ) ) . '</small>'; |
|
871 | + if (!empty($notice)) { |
|
872 | + echo '<small class="form-text text-muted">' . wp_kses_post(wpautop(wptexturize($notice))) . '</small>'; |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | echo '</div>'; |
876 | 876 | } |
877 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
877 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
878 | 878 | |
879 | 879 | /** |
880 | 880 | * @param WPInv_Invoice $invoice |
881 | 881 | */ |
882 | -function wpinv_display_invoice_notes( $invoice ) { |
|
882 | +function wpinv_display_invoice_notes($invoice) { |
|
883 | 883 | |
884 | 884 | // Retrieve the notes. |
885 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
885 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
886 | 886 | |
887 | 887 | // Abort if we have non. |
888 | - if ( empty( $notes ) ) { |
|
888 | + if (empty($notes)) { |
|
889 | 889 | return; |
890 | 890 | } |
891 | 891 | |
892 | 892 | // Echo the note. |
893 | 893 | echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">'; |
894 | - echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__( 'Notes', 'invoicing' ) . '</h2>'; |
|
894 | + echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__('Notes', 'invoicing') . '</h2>'; |
|
895 | 895 | echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">'; |
896 | 896 | |
897 | - foreach ( $notes as $note ) { |
|
898 | - wpinv_get_invoice_note_line_item( $note ); |
|
897 | + foreach ($notes as $note) { |
|
898 | + wpinv_get_invoice_note_line_item($note); |
|
899 | 899 | } |
900 | 900 | |
901 | 901 | echo '</ul>'; |
902 | 902 | echo '</div>'; |
903 | 903 | } |
904 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
904 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
905 | 905 | |
906 | 906 | /** |
907 | 907 | * Loads scripts on our invoice templates. |
@@ -909,32 +909,32 @@ discard block |
||
909 | 909 | function wpinv_display_style() { |
910 | 910 | |
911 | 911 | // Make sure that all scripts have been loaded. |
912 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
913 | - do_action( 'wp_enqueue_scripts' ); |
|
912 | + if (!did_action('wp_enqueue_scripts')) { |
|
913 | + do_action('wp_enqueue_scripts'); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | // Register the invoices style. |
917 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
917 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
918 | 918 | |
919 | 919 | // Load required styles |
920 | - wp_print_styles( 'wpinv-single-style' ); |
|
921 | - wp_print_styles( 'ayecode-ui' ); |
|
920 | + wp_print_styles('wpinv-single-style'); |
|
921 | + wp_print_styles('ayecode-ui'); |
|
922 | 922 | |
923 | 923 | // Maybe load custom css. |
924 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
924 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
925 | 925 | |
926 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
927 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
928 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
926 | + if (isset($custom_css) && !empty($custom_css)) { |
|
927 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
928 | + $custom_css = str_replace('>', '>', $custom_css); |
|
929 | 929 | echo '<style type="text/css">'; |
930 | - echo wp_kses_post( $custom_css ); |
|
930 | + echo wp_kses_post($custom_css); |
|
931 | 931 | echo '</style>'; |
932 | 932 | } |
933 | 933 | |
934 | 934 | wp_site_icon(); |
935 | 935 | } |
936 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
937 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
936 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
937 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
938 | 938 | |
939 | 939 | |
940 | 940 | /** |
@@ -946,41 +946,41 @@ discard block |
||
946 | 946 | // Retrieve the current invoice. |
947 | 947 | $invoice_id = getpaid_get_current_invoice_id(); |
948 | 948 | |
949 | - if ( empty( $invoice_id ) ) { |
|
949 | + if (empty($invoice_id)) { |
|
950 | 950 | |
951 | 951 | return aui()->alert( |
952 | 952 | array( |
953 | 953 | 'type' => 'warning', |
954 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
954 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
955 | 955 | ) |
956 | 956 | ); |
957 | 957 | |
958 | 958 | } |
959 | 959 | |
960 | 960 | // Can the user view this invoice? |
961 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
961 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
962 | 962 | |
963 | 963 | return aui()->alert( |
964 | 964 | array( |
965 | 965 | 'type' => 'warning', |
966 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
966 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
967 | 967 | ) |
968 | 968 | ); |
969 | 969 | |
970 | 970 | } |
971 | 971 | |
972 | 972 | // Ensure that it is not yet paid for. |
973 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
973 | + $invoice = new WPInv_Invoice($invoice_id); |
|
974 | 974 | |
975 | 975 | // Maybe mark it as viewed. |
976 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
976 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
977 | 977 | |
978 | - if ( $invoice->is_paid() ) { |
|
978 | + if ($invoice->is_paid()) { |
|
979 | 979 | |
980 | 980 | return aui()->alert( |
981 | 981 | array( |
982 | 982 | 'type' => 'success', |
983 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
983 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
984 | 984 | ) |
985 | 985 | ); |
986 | 986 | |
@@ -990,15 +990,15 @@ discard block |
||
990 | 990 | $wpi_checkout_id = $invoice_id; |
991 | 991 | |
992 | 992 | // Retrieve appropriate payment form. |
993 | - $payment_form = new GetPaid_Payment_Form( $invoice->get_meta( 'force_payment_form' ) ); |
|
994 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
993 | + $payment_form = new GetPaid_Payment_Form($invoice->get_meta('force_payment_form')); |
|
994 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
995 | 995 | |
996 | - if ( ! $payment_form->exists() ) { |
|
996 | + if (!$payment_form->exists()) { |
|
997 | 997 | |
998 | 998 | return aui()->alert( |
999 | 999 | array( |
1000 | 1000 | 'type' => 'warning', |
1001 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
1001 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
1002 | 1002 | ) |
1003 | 1003 | ); |
1004 | 1004 | |
@@ -1007,29 +1007,29 @@ discard block |
||
1007 | 1007 | // Set the invoice. |
1008 | 1008 | $payment_form->invoice = $invoice; |
1009 | 1009 | |
1010 | - if ( ! $payment_form->is_default() ) { |
|
1010 | + if (!$payment_form->is_default()) { |
|
1011 | 1011 | |
1012 | 1012 | $items = array(); |
1013 | 1013 | $item_ids = array(); |
1014 | 1014 | |
1015 | - foreach ( $invoice->get_items() as $item ) { |
|
1016 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1015 | + foreach ($invoice->get_items() as $item) { |
|
1016 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1017 | 1017 | $item_ids[] = $item->get_id(); |
1018 | 1018 | $items[] = $item; |
1019 | 1019 | } |
1020 | 1020 | } |
1021 | 1021 | |
1022 | - foreach ( $payment_form->get_items() as $item ) { |
|
1023 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1022 | + foreach ($payment_form->get_items() as $item) { |
|
1023 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1024 | 1024 | $item_ids[] = $item->get_id(); |
1025 | 1025 | $items[] = $item; |
1026 | 1026 | } |
1027 | 1027 | } |
1028 | 1028 | |
1029 | - $payment_form->set_items( $items ); |
|
1029 | + $payment_form->set_items($items); |
|
1030 | 1030 | |
1031 | 1031 | } else { |
1032 | - $payment_form->set_items( $invoice->get_items() ); |
|
1032 | + $payment_form->set_items($invoice->get_items()); |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | // Generate the html. |
@@ -1038,7 +1038,7 @@ discard block |
||
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | function wpinv_empty_cart_message() { |
1041 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1041 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | /** |
@@ -1056,76 +1056,76 @@ discard block |
||
1056 | 1056 | true |
1057 | 1057 | ); |
1058 | 1058 | } |
1059 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1059 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1060 | 1060 | |
1061 | 1061 | /** |
1062 | 1062 | * Filters the receipt page. |
1063 | 1063 | */ |
1064 | -function wpinv_filter_success_page_content( $content ) { |
|
1064 | +function wpinv_filter_success_page_content($content) { |
|
1065 | 1065 | |
1066 | 1066 | // Maybe abort early. |
1067 | - if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) { |
|
1067 | + if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) { |
|
1068 | 1068 | return $content; |
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | // Ensure this is our page. |
1072 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1072 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1073 | 1073 | |
1074 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
1075 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
1074 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
1075 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
1076 | 1076 | |
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | return $content; |
1080 | 1080 | } |
1081 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1081 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1082 | 1082 | |
1083 | -function wpinv_invoice_link( $invoice_id ) { |
|
1084 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1083 | +function wpinv_invoice_link($invoice_id) { |
|
1084 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1085 | 1085 | |
1086 | - if ( empty( $invoice ) ) { |
|
1086 | + if (empty($invoice)) { |
|
1087 | 1087 | return null; |
1088 | 1088 | } |
1089 | 1089 | |
1090 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1090 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1091 | 1091 | |
1092 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1092 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
1096 | - if ( empty( $note ) ) { |
|
1095 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
1096 | + if (empty($note)) { |
|
1097 | 1097 | return null; |
1098 | 1098 | } |
1099 | 1099 | |
1100 | - if ( is_int( $note ) ) { |
|
1101 | - $note = get_comment( $note ); |
|
1100 | + if (is_int($note)) { |
|
1101 | + $note = get_comment($note); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | - if ( ! ( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
1104 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
1105 | 1105 | return null; |
1106 | 1106 | } |
1107 | 1107 | |
1108 | - $note_classes = array( 'note' ); |
|
1109 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
1108 | + $note_classes = array('note'); |
|
1109 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
1110 | 1110 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
1111 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
1112 | - $note_classes = ! empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
1111 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
1112 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
1113 | 1113 | |
1114 | 1114 | ob_start(); |
1115 | 1115 | ?> |
1116 | - <li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2"> |
|
1116 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2"> |
|
1117 | 1117 | <div class="note_content"> |
1118 | 1118 | |
1119 | - <?php echo wp_kses_post( wptexturize( $note->comment_content ) ); ?> |
|
1119 | + <?php echo wp_kses_post(wptexturize($note->comment_content)); ?> |
|
1120 | 1120 | |
1121 | - <?php if ( ! is_admin() ) : ?> |
|
1121 | + <?php if (!is_admin()) : ?> |
|
1122 | 1122 | <em class="small form-text text-muted mt-0"> |
1123 | 1123 | <?php |
1124 | 1124 | printf( |
1125 | - esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1126 | - esc_html( $note->comment_author ), |
|
1127 | - esc_html( getpaid_format_date_value( $note->comment_date ) ), |
|
1128 | - esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ) |
|
1125 | + esc_html__('%1$s - %2$s at %3$s', 'invoicing'), |
|
1126 | + esc_html($note->comment_author), |
|
1127 | + esc_html(getpaid_format_date_value($note->comment_date)), |
|
1128 | + esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date))) |
|
1129 | 1129 | ); |
1130 | 1130 | ?> |
1131 | 1131 | </em> |
@@ -1133,21 +1133,21 @@ discard block |
||
1133 | 1133 | |
1134 | 1134 | </div> |
1135 | 1135 | |
1136 | - <?php if ( is_admin() ) : ?> |
|
1136 | + <?php if (is_admin()) : ?> |
|
1137 | 1137 | |
1138 | 1138 | <p class="meta px-4 py-2"> |
1139 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
1139 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
1140 | 1140 | <?php |
1141 | 1141 | printf( |
1142 | - esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1143 | - esc_html( $note->comment_author ), |
|
1144 | - esc_html( getpaid_format_date_value( $note->comment_date ) ), |
|
1145 | - esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ) |
|
1142 | + esc_html__('%1$s - %2$s at %3$s', 'invoicing'), |
|
1143 | + esc_html($note->comment_author), |
|
1144 | + esc_html(getpaid_format_date_value($note->comment_date)), |
|
1145 | + esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date))) |
|
1146 | 1146 | ); |
1147 | 1147 | ?> |
1148 | 1148 | </abbr> |
1149 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
1150 | - <a href="#" class="delete_note"><?php esc_html_e( 'Delete note', 'invoicing' ); ?></a> |
|
1149 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
1150 | + <a href="#" class="delete_note"><?php esc_html_e('Delete note', 'invoicing'); ?></a> |
|
1151 | 1151 | <?php } ?> |
1152 | 1152 | </p> |
1153 | 1153 | |
@@ -1156,10 +1156,10 @@ discard block |
||
1156 | 1156 | </li> |
1157 | 1157 | <?php |
1158 | 1158 | $note_content = ob_get_clean(); |
1159 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
1159 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
1160 | 1160 | |
1161 | - if ( $echo ) { |
|
1162 | - echo wp_kses_post( $note_content ); |
|
1161 | + if ($echo) { |
|
1162 | + echo wp_kses_post($note_content); |
|
1163 | 1163 | } else { |
1164 | 1164 | return $note_content; |
1165 | 1165 | } |
@@ -1172,43 +1172,43 @@ discard block |
||
1172 | 1172 | * @return string |
1173 | 1173 | */ |
1174 | 1174 | function wpinv_get_policy_text() { |
1175 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
1175 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
1176 | 1176 | |
1177 | - $text = wpinv_get_option( 'invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ) ); |
|
1177 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
1178 | 1178 | |
1179 | - if ( ! $privacy_page_id ) { |
|
1180 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
1179 | + if (!$privacy_page_id) { |
|
1180 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
1181 | 1181 | } |
1182 | 1182 | |
1183 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
1183 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
1184 | 1184 | |
1185 | 1185 | $find_replace = array( |
1186 | 1186 | '[wpinv_privacy_policy]' => $privacy_link, |
1187 | 1187 | ); |
1188 | 1188 | |
1189 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
1189 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
1190 | 1190 | |
1191 | - return wp_kses_post( wpautop( $privacy_text ) ); |
|
1191 | + return wp_kses_post(wpautop($privacy_text)); |
|
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | function wpinv_oxygen_fix_conflict() { |
1195 | 1195 | global $ct_ignore_post_types; |
1196 | 1196 | |
1197 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
1197 | + if (!is_array($ct_ignore_post_types)) { |
|
1198 | 1198 | $ct_ignore_post_types = array(); |
1199 | 1199 | } |
1200 | 1200 | |
1201 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' ); |
|
1201 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form'); |
|
1202 | 1202 | |
1203 | - foreach ( $post_types as $post_type ) { |
|
1203 | + foreach ($post_types as $post_type) { |
|
1204 | 1204 | $ct_ignore_post_types[] = $post_type; |
1205 | 1205 | |
1206 | 1206 | // Ignore post type |
1207 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
1207 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
1208 | 1208 | } |
1209 | 1209 | |
1210 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
1211 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
1210 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
1211 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | /** |
@@ -1216,10 +1216,10 @@ discard block |
||
1216 | 1216 | * |
1217 | 1217 | * @param GetPaid_Payment_Form $form |
1218 | 1218 | */ |
1219 | -function getpaid_display_payment_form( $form ) { |
|
1219 | +function getpaid_display_payment_form($form) { |
|
1220 | 1220 | |
1221 | - if ( is_numeric( $form ) ) { |
|
1222 | - $form = new GetPaid_Payment_Form( $form ); |
|
1221 | + if (is_numeric($form)) { |
|
1222 | + $form = new GetPaid_Payment_Form($form); |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | $form->display(); |
@@ -1229,61 +1229,61 @@ discard block |
||
1229 | 1229 | /** |
1230 | 1230 | * Helper function to display a item payment form on the frontend. |
1231 | 1231 | */ |
1232 | -function getpaid_display_item_payment_form( $items ) { |
|
1232 | +function getpaid_display_item_payment_form($items) { |
|
1233 | 1233 | |
1234 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1235 | - $form->set_items( $items ); |
|
1234 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1235 | + $form->set_items($items); |
|
1236 | 1236 | |
1237 | - if ( 0 == count( $form->get_items() ) ) { |
|
1237 | + if (0 == count($form->get_items())) { |
|
1238 | 1238 | aui()->alert( |
1239 | 1239 | array( |
1240 | 1240 | 'type' => 'warning', |
1241 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1241 | + 'content' => __('No published items found', 'invoicing'), |
|
1242 | 1242 | ), |
1243 | 1243 | true |
1244 | 1244 | ); |
1245 | 1245 | return; |
1246 | 1246 | } |
1247 | 1247 | |
1248 | - $extra_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
1249 | - $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items ); |
|
1248 | + $extra_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
1249 | + $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items); |
|
1250 | 1250 | $extra_items = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />"; |
1251 | 1251 | $extra_items .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />"; |
1252 | 1252 | |
1253 | - $form->display( $extra_items ); |
|
1253 | + $form->display($extra_items); |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | /** |
1257 | 1257 | * Helper function to display an invoice payment form on the frontend. |
1258 | 1258 | */ |
1259 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
1259 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
1260 | 1260 | |
1261 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1261 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1262 | 1262 | |
1263 | - if ( empty( $invoice ) ) { |
|
1263 | + if (empty($invoice)) { |
|
1264 | 1264 | aui()->alert( |
1265 | 1265 | array( |
1266 | 1266 | 'type' => 'warning', |
1267 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1267 | + 'content' => __('Invoice not found', 'invoicing'), |
|
1268 | 1268 | ), |
1269 | 1269 | true |
1270 | 1270 | ); |
1271 | 1271 | return; |
1272 | 1272 | } |
1273 | 1273 | |
1274 | - if ( $invoice->is_paid() ) { |
|
1274 | + if ($invoice->is_paid()) { |
|
1275 | 1275 | aui()->alert( |
1276 | 1276 | array( |
1277 | 1277 | 'type' => 'warning', |
1278 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1278 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
1279 | 1279 | ), |
1280 | 1280 | true |
1281 | 1281 | ); |
1282 | 1282 | return; |
1283 | 1283 | } |
1284 | 1284 | |
1285 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1286 | - $form->set_items( $invoice->get_items() ); |
|
1285 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1286 | + $form->set_items($invoice->get_items()); |
|
1287 | 1287 | |
1288 | 1288 | $form->display(); |
1289 | 1289 | } |
@@ -1291,23 +1291,23 @@ discard block |
||
1291 | 1291 | /** |
1292 | 1292 | * Helper function to convert item string to array. |
1293 | 1293 | */ |
1294 | -function getpaid_convert_items_to_array( $items ) { |
|
1295 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
1294 | +function getpaid_convert_items_to_array($items) { |
|
1295 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
1296 | 1296 | $prepared = array(); |
1297 | 1297 | |
1298 | - foreach ( $items as $item ) { |
|
1299 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
1298 | + foreach ($items as $item) { |
|
1299 | + $data = array_map('trim', explode('|', $item)); |
|
1300 | 1300 | |
1301 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
1301 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
1302 | 1302 | continue; |
1303 | 1303 | } |
1304 | 1304 | |
1305 | 1305 | $quantity = 1; |
1306 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
1306 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
1307 | 1307 | $quantity = (float) $data[1]; |
1308 | 1308 | } |
1309 | 1309 | |
1310 | - $prepared[ $data[0] ] = $quantity; |
|
1310 | + $prepared[$data[0]] = $quantity; |
|
1311 | 1311 | |
1312 | 1312 | } |
1313 | 1313 | |
@@ -1317,13 +1317,13 @@ discard block |
||
1317 | 1317 | /** |
1318 | 1318 | * Helper function to convert item array to string. |
1319 | 1319 | */ |
1320 | -function getpaid_convert_items_to_string( $items ) { |
|
1320 | +function getpaid_convert_items_to_string($items) { |
|
1321 | 1321 | $prepared = array(); |
1322 | 1322 | |
1323 | - foreach ( $items as $item => $quantity ) { |
|
1323 | + foreach ($items as $item => $quantity) { |
|
1324 | 1324 | $prepared[] = "$item|$quantity"; |
1325 | 1325 | } |
1326 | - return implode( ',', $prepared ); |
|
1326 | + return implode(',', $prepared); |
|
1327 | 1327 | } |
1328 | 1328 | |
1329 | 1329 | /** |
@@ -1331,21 +1331,21 @@ discard block |
||
1331 | 1331 | * |
1332 | 1332 | * Provide a label and one of $form, $items or $invoice. |
1333 | 1333 | */ |
1334 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
1335 | - $label = sanitize_text_field( $label ); |
|
1334 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
1335 | + $label = sanitize_text_field($label); |
|
1336 | 1336 | |
1337 | - if ( ! empty( $form ) ) { |
|
1338 | - $form = esc_attr( $form ); |
|
1337 | + if (!empty($form)) { |
|
1338 | + $form = esc_attr($form); |
|
1339 | 1339 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
1340 | 1340 | } |
1341 | 1341 | |
1342 | - if ( ! empty( $items ) ) { |
|
1343 | - $items = esc_attr( $items ); |
|
1342 | + if (!empty($items)) { |
|
1343 | + $items = esc_attr($items); |
|
1344 | 1344 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
1345 | 1345 | } |
1346 | 1346 | |
1347 | - if ( ! empty( $invoice ) ) { |
|
1348 | - $invoice = esc_attr( $invoice ); |
|
1347 | + if (!empty($invoice)) { |
|
1348 | + $invoice = esc_attr($invoice); |
|
1349 | 1349 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
1350 | 1350 | } |
1351 | 1351 | |
@@ -1356,17 +1356,17 @@ discard block |
||
1356 | 1356 | * |
1357 | 1357 | * @param WPInv_Invoice $invoice |
1358 | 1358 | */ |
1359 | -function getpaid_the_invoice_description( $invoice ) { |
|
1359 | +function getpaid_the_invoice_description($invoice) { |
|
1360 | 1360 | $description = $invoice->get_description(); |
1361 | 1361 | |
1362 | - if ( empty( $description ) ) { |
|
1362 | + if (empty($description)) { |
|
1363 | 1363 | return; |
1364 | 1364 | } |
1365 | 1365 | |
1366 | - echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>" . wp_kses_post( wpautop( $description ) ) . "</em></small>"; |
|
1366 | + echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>" . wp_kses_post(wpautop($description)) . "</em></small>"; |
|
1367 | 1367 | } |
1368 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
1369 | -add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 ); |
|
1368 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
1369 | +add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100); |
|
1370 | 1370 | |
1371 | 1371 | /** |
1372 | 1372 | * Render element on a form. |
@@ -1374,79 +1374,79 @@ discard block |
||
1374 | 1374 | * @param array $element |
1375 | 1375 | * @param GetPaid_Payment_Form $form |
1376 | 1376 | */ |
1377 | -function getpaid_payment_form_element( $element, $form ) { |
|
1377 | +function getpaid_payment_form_element($element, $form) { |
|
1378 | 1378 | |
1379 | 1379 | // Set up the args. |
1380 | - $element_type = trim( $element['type'] ); |
|
1380 | + $element_type = trim($element['type']); |
|
1381 | 1381 | $element['form'] = $form; |
1382 | - extract( $element ); |
|
1382 | + extract($element); |
|
1383 | 1383 | |
1384 | 1384 | // Try to locate the appropriate template. |
1385 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
1385 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
1386 | 1386 | |
1387 | 1387 | // Abort if this is not our element. |
1388 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1388 | + if (empty($located) || !file_exists($located)) { |
|
1389 | 1389 | return; |
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | // Generate the class and id of the element. |
1393 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
1394 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
1393 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
1394 | + $id = isset($id) ? $id : uniqid('gp'); |
|
1395 | 1395 | |
1396 | - $element_id = ! empty( $element['label'] ) ? sanitize_title( $element['label'] ) : $id; |
|
1397 | - $query_value = isset( $_GET[ $element_id ] ) ? wpinv_clean( urldecode( $_GET[ $element_id ] ) ) : ''; |
|
1396 | + $element_id = !empty($element['label']) ? sanitize_title($element['label']) : $id; |
|
1397 | + $query_value = isset($_GET[$element_id]) ? wpinv_clean(urldecode($_GET[$element_id])) : ''; |
|
1398 | 1398 | |
1399 | 1399 | $element_id = 'getpaid-' . '-' . $element_id; |
1400 | - if ( ! empty( $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ] ) ) { |
|
1401 | - $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ]; |
|
1400 | + if (!empty($GLOBALS['rendered_getpaid_forms'][$form->get_id()])) { |
|
1401 | + $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][$form->get_id()]; |
|
1402 | 1402 | } |
1403 | 1403 | |
1404 | 1404 | // Echo the opening wrapper. |
1405 | - echo "<div class='getpaid-payment-form-element " . esc_attr( $wrapper_class ) . "'>"; |
|
1405 | + echo "<div class='getpaid-payment-form-element " . esc_attr($wrapper_class) . "'>"; |
|
1406 | 1406 | |
1407 | 1407 | // Fires before displaying a given element type's content. |
1408 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
1408 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
1409 | 1409 | |
1410 | 1410 | // Include the template for the element. |
1411 | 1411 | include $located; |
1412 | 1412 | |
1413 | 1413 | // Fires after displaying a given element type's content. |
1414 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
1414 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
1415 | 1415 | |
1416 | 1416 | // Echo the closing wrapper. |
1417 | 1417 | echo '</div>'; |
1418 | 1418 | } |
1419 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
1419 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
1420 | 1420 | |
1421 | 1421 | /** |
1422 | 1422 | * Render an element's edit page. |
1423 | 1423 | * |
1424 | 1424 | * @param WP_Post $post |
1425 | 1425 | */ |
1426 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
1426 | +function getpaid_payment_form_edit_element_template($post) { |
|
1427 | 1427 | |
1428 | 1428 | // Retrieve all elements. |
1429 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1429 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1430 | 1430 | |
1431 | - foreach ( $all_elements as $element ) { |
|
1431 | + foreach ($all_elements as $element) { |
|
1432 | 1432 | |
1433 | 1433 | // Try to locate the appropriate template. |
1434 | - $element = esc_attr( sanitize_key( $element ) ); |
|
1435 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
1434 | + $element = esc_attr(sanitize_key($element)); |
|
1435 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
1436 | 1436 | |
1437 | 1437 | // Continue if this is not our element. |
1438 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1438 | + if (empty($located) || !file_exists($located)) { |
|
1439 | 1439 | continue; |
1440 | 1440 | } |
1441 | 1441 | |
1442 | 1442 | // Include the template for the element. |
1443 | - echo "<div v-if=\"active_form_element.type=='" . esc_attr( $element ) . "'\">"; |
|
1443 | + echo "<div v-if=\"active_form_element.type=='" . esc_attr($element) . "'\">"; |
|
1444 | 1444 | include $located; |
1445 | 1445 | echo '</div>'; |
1446 | 1446 | } |
1447 | 1447 | |
1448 | 1448 | } |
1449 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
1449 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
1450 | 1450 | |
1451 | 1451 | /** |
1452 | 1452 | * Render an element's preview. |
@@ -1455,27 +1455,27 @@ discard block |
||
1455 | 1455 | function getpaid_payment_form_render_element_preview_template() { |
1456 | 1456 | |
1457 | 1457 | // Retrieve all elements. |
1458 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1458 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1459 | 1459 | |
1460 | - foreach ( $all_elements as $element ) { |
|
1460 | + foreach ($all_elements as $element) { |
|
1461 | 1461 | |
1462 | 1462 | // Try to locate the appropriate template. |
1463 | - $element = sanitize_key( $element ); |
|
1464 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
1463 | + $element = sanitize_key($element); |
|
1464 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
1465 | 1465 | |
1466 | 1466 | // Continue if this is not our element. |
1467 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1467 | + if (empty($located) || !file_exists($located)) { |
|
1468 | 1468 | continue; |
1469 | 1469 | } |
1470 | 1470 | |
1471 | 1471 | // Include the template for the element. |
1472 | - echo "<div v-if=\"form_element.type=='" . esc_html( $element ) . "'\">"; |
|
1472 | + echo "<div v-if=\"form_element.type=='" . esc_html($element) . "'\">"; |
|
1473 | 1473 | include $located; |
1474 | 1474 | echo '</div>'; |
1475 | 1475 | } |
1476 | 1476 | |
1477 | 1477 | } |
1478 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
1478 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
1479 | 1479 | |
1480 | 1480 | /** |
1481 | 1481 | * Shows a list of gateways that support recurring payments. |
@@ -1483,17 +1483,17 @@ discard block |
||
1483 | 1483 | function wpinv_get_recurring_gateways_text() { |
1484 | 1484 | $gateways = array(); |
1485 | 1485 | |
1486 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
1487 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
1488 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
1486 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
1487 | + if (wpinv_gateway_support_subscription($key)) { |
|
1488 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
1489 | 1489 | } |
1490 | 1490 | } |
1491 | 1491 | |
1492 | - if ( empty( $gateways ) ) { |
|
1493 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) . '</span>'; |
|
1492 | + if (empty($gateways)) { |
|
1493 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . '</span>'; |
|
1494 | 1494 | } |
1495 | 1495 | |
1496 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) . '</span>'; |
|
1496 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . '</span>'; |
|
1497 | 1497 | |
1498 | 1498 | } |
1499 | 1499 | |
@@ -1503,7 +1503,7 @@ discard block |
||
1503 | 1503 | * @return GetPaid_Template |
1504 | 1504 | */ |
1505 | 1505 | function getpaid_template() { |
1506 | - return getpaid()->get( 'template' ); |
|
1506 | + return getpaid()->get('template'); |
|
1507 | 1507 | } |
1508 | 1508 | |
1509 | 1509 | /** |
@@ -1512,8 +1512,8 @@ discard block |
||
1512 | 1512 | * @param array args |
1513 | 1513 | * @return string |
1514 | 1514 | */ |
1515 | -function getpaid_paginate_links( $args ) { |
|
1516 | - return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) ); |
|
1515 | +function getpaid_paginate_links($args) { |
|
1516 | + return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args)); |
|
1517 | 1517 | } |
1518 | 1518 | |
1519 | 1519 | /** |
@@ -1523,22 +1523,22 @@ discard block |
||
1523 | 1523 | * @param string state |
1524 | 1524 | * @return string |
1525 | 1525 | */ |
1526 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false ) { |
|
1526 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false) { |
|
1527 | 1527 | |
1528 | - $states = wpinv_get_country_states( $country ); |
|
1529 | - $uniqid = uniqid( '_' ); |
|
1528 | + $states = wpinv_get_country_states($country); |
|
1529 | + $uniqid = uniqid('_'); |
|
1530 | 1530 | |
1531 | - if ( ! empty( $states ) ) { |
|
1531 | + if (!empty($states)) { |
|
1532 | 1532 | |
1533 | 1533 | return aui()->select( |
1534 | 1534 | array( |
1535 | 1535 | 'options' => $states, |
1536 | - 'name' => esc_attr( $field_name ), |
|
1537 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1538 | - 'value' => sanitize_text_field( $state ), |
|
1536 | + 'name' => esc_attr($field_name), |
|
1537 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1538 | + 'value' => sanitize_text_field($state), |
|
1539 | 1539 | 'placeholder' => $placeholder, |
1540 | 1540 | 'required' => $required, |
1541 | - 'label' => wp_kses_post( $label ), |
|
1541 | + 'label' => wp_kses_post($label), |
|
1542 | 1542 | 'label_type' => 'vertical', |
1543 | 1543 | 'help_text' => $help_text, |
1544 | 1544 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1555,14 +1555,14 @@ discard block |
||
1555 | 1555 | |
1556 | 1556 | return aui()->input( |
1557 | 1557 | array( |
1558 | - 'name' => esc_attr( $field_name ), |
|
1559 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1558 | + 'name' => esc_attr($field_name), |
|
1559 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1560 | 1560 | 'placeholder' => $placeholder, |
1561 | 1561 | 'required' => $required, |
1562 | - 'label' => wp_kses_post( $label ), |
|
1562 | + 'label' => wp_kses_post($label), |
|
1563 | 1563 | 'label_type' => 'vertical', |
1564 | 1564 | 'help_text' => $help_text, |
1565 | - 'value' => sanitize_text_field( $state ), |
|
1565 | + 'value' => sanitize_text_field($state), |
|
1566 | 1566 | 'class' => 'getpaid-address-field wpinv_state', |
1567 | 1567 | 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
1568 | 1568 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -1581,16 +1581,16 @@ discard block |
||
1581 | 1581 | * @param array $element |
1582 | 1582 | * @return string |
1583 | 1583 | */ |
1584 | -function getpaid_get_form_element_grid_class( $element ) { |
|
1584 | +function getpaid_get_form_element_grid_class($element) { |
|
1585 | 1585 | |
1586 | 1586 | $class = 'col-12'; |
1587 | - $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width']; |
|
1587 | + $width = empty($element['grid_width']) ? 'full' : $element['grid_width']; |
|
1588 | 1588 | |
1589 | - if ( $width == 'half' ) { |
|
1589 | + if ($width == 'half') { |
|
1590 | 1590 | $class .= ' col-md-6'; |
1591 | 1591 | } |
1592 | 1592 | |
1593 | - if ( $width == 'third' ) { |
|
1593 | + if ($width == 'third') { |
|
1594 | 1594 | $class .= ' col-md-4'; |
1595 | 1595 | } |
1596 | 1596 | |
@@ -1605,15 +1605,15 @@ discard block |
||
1605 | 1605 | * |
1606 | 1606 | * @return string |
1607 | 1607 | */ |
1608 | -function getpaid_embed_url( $payment_form = false, $items = false ) { |
|
1608 | +function getpaid_embed_url($payment_form = false, $items = false) { |
|
1609 | 1609 | |
1610 | 1610 | return add_query_arg( |
1611 | 1611 | array( |
1612 | 1612 | 'getpaid_embed' => 1, |
1613 | - 'form' => $payment_form ? absint( $payment_form ) : false, |
|
1614 | - 'item' => $items ? urlencode( $items ) : false, |
|
1613 | + 'form' => $payment_form ? absint($payment_form) : false, |
|
1614 | + 'item' => $items ? urlencode($items) : false, |
|
1615 | 1615 | ), |
1616 | - home_url( 'index.php' ) |
|
1616 | + home_url('index.php') |
|
1617 | 1617 | ); |
1618 | 1618 | |
1619 | 1619 | } |
@@ -1623,13 +1623,13 @@ discard block |
||
1623 | 1623 | * |
1624 | 1624 | * @return string |
1625 | 1625 | */ |
1626 | -function getpaid_filter_embed_template( $template ) { |
|
1626 | +function getpaid_filter_embed_template($template) { |
|
1627 | 1627 | |
1628 | - if ( isset( $_GET['getpaid_embed'] ) ) { |
|
1629 | - wpinv_get_template( 'payment-forms/embed.php' ); |
|
1628 | + if (isset($_GET['getpaid_embed'])) { |
|
1629 | + wpinv_get_template('payment-forms/embed.php'); |
|
1630 | 1630 | exit; |
1631 | 1631 | } |
1632 | 1632 | |
1633 | 1633 | return $template; |
1634 | 1634 | } |
1635 | -add_filter( 'template_include', 'getpaid_filter_embed_template' ); |
|
1635 | +add_filter('template_include', 'getpaid_filter_embed_template'); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @var array $tax_rate |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | ?> |
12 | 12 | |
@@ -18,13 +18,13 @@ discard block |
||
18 | 18 | aui()->select( |
19 | 19 | array( |
20 | 20 | 'options' => array_merge( |
21 | - array( '' => __( 'All Countries', 'invoicing' ) ), |
|
21 | + array('' => __('All Countries', 'invoicing')), |
|
22 | 22 | wpinv_get_country_list() |
23 | 23 | ), |
24 | 24 | 'name' => "tax_rates[$key][country]", |
25 | - 'id' => uniqid( 'tax_rate_country' ), |
|
26 | - 'value' => esc_html( $tax_rate['country'] ), |
|
27 | - 'label' => __( 'Country', 'invoicing' ), |
|
25 | + 'id' => uniqid('tax_rate_country'), |
|
26 | + 'value' => esc_html($tax_rate['country']), |
|
27 | + 'label' => __('Country', 'invoicing'), |
|
28 | 28 | 'class' => 'wpinv_country', |
29 | 29 | 'no_wrap' => true, |
30 | 30 | ), |
@@ -37,35 +37,35 @@ discard block |
||
37 | 37 | <td class="wpinv_tax_state"> |
38 | 38 | |
39 | 39 | <label class="w-100"> |
40 | - <span class="screen-reader-text"><?php esc_html_e( 'States', 'invoicing' ); ?></span> |
|
41 | - <input type="text" placeholder="<?php esc_attr_e( 'Apply to whole country', 'invoicing' ); ?>" name="tax_rates[<?php echo esc_attr( $key ); ?>][state]" value="<?php echo empty( $tax_rate['global'] ) ? esc_attr( $tax_rate['state'] ) : ''; ?>"/> |
|
40 | + <span class="screen-reader-text"><?php esc_html_e('States', 'invoicing'); ?></span> |
|
41 | + <input type="text" placeholder="<?php esc_attr_e('Apply to whole country', 'invoicing'); ?>" name="tax_rates[<?php echo esc_attr($key); ?>][state]" value="<?php echo empty($tax_rate['global']) ? esc_attr($tax_rate['state']) : ''; ?>"/> |
|
42 | 42 | </label> |
43 | 43 | |
44 | 44 | </td> |
45 | 45 | |
46 | 46 | <td class="wpinv_standard_rate"> |
47 | 47 | <label class="w-100"> |
48 | - <span class="screen-reader-text"><?php esc_html_e( 'Standard Rate', 'invoicing' ); ?></span> |
|
49 | - <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ); ?>][rate]" value="<?php echo esc_attr( $tax_rate['rate'] ); ?>"/> |
|
48 | + <span class="screen-reader-text"><?php esc_html_e('Standard Rate', 'invoicing'); ?></span> |
|
49 | + <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key); ?>][rate]" value="<?php echo esc_attr($tax_rate['rate']); ?>"/> |
|
50 | 50 | </label> |
51 | 51 | </td> |
52 | 52 | |
53 | 53 | <td class="wpinv_reduced_rate"> |
54 | 54 | <label class="w-100"> |
55 | - <span class="screen-reader-text"><?php esc_html_e( 'Reduced Rate', 'invoicing' ); ?></span> |
|
56 | - <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ); ?>][reduced_rate]" value="<?php echo esc_attr( $tax_rate['reduced_rate'] ); ?>"/> |
|
55 | + <span class="screen-reader-text"><?php esc_html_e('Reduced Rate', 'invoicing'); ?></span> |
|
56 | + <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key); ?>][reduced_rate]" value="<?php echo esc_attr($tax_rate['reduced_rate']); ?>"/> |
|
57 | 57 | </label> |
58 | 58 | </td> |
59 | 59 | |
60 | 60 | <td class="wpinv_tax_name"> |
61 | 61 | <label class="w-100"> |
62 | - <span class="screen-reader-text"><?php esc_html_e( 'Tax Name', 'invoicing' ); ?></span> |
|
63 | - <input type="text" name="tax_rates[<?php echo esc_attr( $key ); ?>][name]" value="<?php echo esc_attr( $tax_rate['name'] ); ?>"/> |
|
62 | + <span class="screen-reader-text"><?php esc_html_e('Tax Name', 'invoicing'); ?></span> |
|
63 | + <input type="text" name="tax_rates[<?php echo esc_attr($key); ?>][name]" value="<?php echo esc_attr($tax_rate['name']); ?>"/> |
|
64 | 64 | </label> |
65 | 65 | </td> |
66 | 66 | |
67 | 67 | <td class="wpinv_tax_remove"> |
68 | - <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>" title="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>"> |
|
68 | + <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e('Delete', 'invoicing'); ?>" title="<?php esc_attr_e('Delete', 'invoicing'); ?>"> |
|
69 | 69 | <span aria-hidden="true">×</span> |
70 | 70 | </button> |
71 | 71 | </td> |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | $tax_rates = GetPaid_Tax::get_all_tax_rates(); |
10 | 10 | $dummy_rate = array( |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | 'global' => true, |
14 | 14 | 'rate' => wpinv_get_default_tax_rate(), |
15 | 15 | 'reduced_rate' => 5, |
16 | - 'name' => __( 'VAT', 'invoicing' ), |
|
16 | + 'name' => __('VAT', 'invoicing'), |
|
17 | 17 | ); |
18 | 18 | |
19 | 19 | $reset_url = wp_nonce_url( |
20 | - add_query_arg( 'getpaid-admin-action', 'reset_tax_rates' ), |
|
20 | + add_query_arg('getpaid-admin-action', 'reset_tax_rates'), |
|
21 | 21 | 'getpaid-nonce', |
22 | 22 | 'getpaid-nonce' |
23 | 23 | ); |
@@ -25,34 +25,34 @@ discard block |
||
25 | 25 | ?> |
26 | 26 | <div class="table-responsive"> |
27 | 27 | <table id="wpinv_tax_rates" class="widefat fixed table"> |
28 | - <caption><?php echo esc_html_e( 'Enter tax rates for specific regions.', 'invoicing' ); ?></caption> |
|
28 | + <caption><?php echo esc_html_e('Enter tax rates for specific regions.', 'invoicing'); ?></caption> |
|
29 | 29 | |
30 | 30 | <thead> |
31 | 31 | <tr class="table-light"> |
32 | 32 | |
33 | 33 | <th scope="col" class="border-bottom border-top"> |
34 | - <?php esc_html_e( 'Country', 'invoicing' ); ?> |
|
35 | - <?php getpaid_get_help_tip( __( 'Optionally limit this tax rate to a specific country.', 'invoicing' ), 'position-static', true ); ?> |
|
34 | + <?php esc_html_e('Country', 'invoicing'); ?> |
|
35 | + <?php getpaid_get_help_tip(__('Optionally limit this tax rate to a specific country.', 'invoicing'), 'position-static', true); ?> |
|
36 | 36 | </th> |
37 | 37 | |
38 | 38 | <th scope="col" class="border-bottom border-top"> |
39 | - <?php esc_html_e( 'State', 'invoicing' ); ?> |
|
40 | - <?php getpaid_get_help_tip( __( 'Separate state codes using a comma or leave blank to apply country wide.', 'invoicing' ), 'position-static', true ); ?> |
|
39 | + <?php esc_html_e('State', 'invoicing'); ?> |
|
40 | + <?php getpaid_get_help_tip(__('Separate state codes using a comma or leave blank to apply country wide.', 'invoicing'), 'position-static', true); ?> |
|
41 | 41 | </th> |
42 | 42 | |
43 | 43 | <th scope="col" class="border-bottom border-top"> |
44 | - <?php esc_html_e( 'Standard Rate %', 'invoicing' ); ?> |
|
45 | - <?php getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing' ), 'position-static', true ); ?> |
|
44 | + <?php esc_html_e('Standard Rate %', 'invoicing'); ?> |
|
45 | + <?php getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing'), 'position-static', true); ?> |
|
46 | 46 | </th> |
47 | 47 | |
48 | 48 | <th scope="col" class="border-bottom border-top"> |
49 | - <?php esc_html_e( 'Reduced Rate %', 'invoicing' ); ?> |
|
50 | - <?php getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing' ), 'position-static', true ); ?> |
|
49 | + <?php esc_html_e('Reduced Rate %', 'invoicing'); ?> |
|
50 | + <?php getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing'), 'position-static', true); ?> |
|
51 | 51 | </th> |
52 | 52 | |
53 | 53 | <th scope="col" class="border-bottom border-top"> |
54 | - <?php esc_html_e( 'Tax Name', 'invoicing' ); ?> |
|
55 | - <?php getpaid_get_help_tip( __( 'The name of this tax, e.g VAT.', 'invoicing' ), 'position-static', true ); ?> |
|
54 | + <?php esc_html_e('Tax Name', 'invoicing'); ?> |
|
55 | + <?php getpaid_get_help_tip(__('The name of this tax, e.g VAT.', 'invoicing'), 'position-static', true); ?> |
|
56 | 56 | </th> |
57 | 57 | |
58 | 58 | <th scope="col" class="border-bottom border-top" style="width:32px"> </th> |
@@ -61,19 +61,19 @@ discard block |
||
61 | 61 | </thead> |
62 | 62 | |
63 | 63 | <tbody> |
64 | - <?php array_walk( $tax_rates, 'wpinv_tax_rate_callback' ); ?> |
|
64 | + <?php array_walk($tax_rates, 'wpinv_tax_rate_callback'); ?> |
|
65 | 65 | </tbody> |
66 | 66 | |
67 | 67 | <tfoot> |
68 | 68 | <tr class="table-light"> |
69 | 69 | <td colspan="6" class="border-top"> |
70 | 70 | |
71 | - <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e( 'Add Tax Rate', 'invoicing' ); ?>"> |
|
72 | - <span><?php esc_html_e( 'Add Tax Rate', 'invoicing' ); ?></span> |
|
71 | + <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e('Add Tax Rate', 'invoicing'); ?>"> |
|
72 | + <span><?php esc_html_e('Add Tax Rate', 'invoicing'); ?></span> |
|
73 | 73 | </button> |
74 | 74 | |
75 | - <a href="<?php echo esc_url( $reset_url ); ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e( 'Reset Tax Rates', 'invoicing' ); ?>"> |
|
76 | - <span><?php esc_html_e( 'Reset Tax Rates', 'invoicing' ); ?></span> |
|
75 | + <a href="<?php echo esc_url($reset_url); ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e('Reset Tax Rates', 'invoicing'); ?>"> |
|
76 | + <span><?php esc_html_e('Reset Tax Rates', 'invoicing'); ?></span> |
|
77 | 77 | </a> |
78 | 78 | </td> |
79 | 79 | </tr> |
@@ -82,6 +82,6 @@ discard block |
||
82 | 82 | </div> |
83 | 83 | |
84 | 84 | <script type="text/html" id="tmpl-wpinv-tax-rate-row"> |
85 | - <?php wpinv_tax_rate_callback( $dummy_rate, 0, true ); ?> |
|
85 | + <?php wpinv_tax_rate_callback($dummy_rate, 0, true); ?> |
|
86 | 86 | </script> |
87 | 87 |
@@ -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 | * Generates a users select dropdown. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | * @param array $args |
17 | 17 | * @see wp_dropdown_users |
18 | 18 | */ |
19 | -function wpinv_dropdown_users( $args = '' ) { |
|
19 | +function wpinv_dropdown_users($args = '') { |
|
20 | 20 | |
21 | - if ( is_array( $args ) && ! empty( $args['show'] ) && 'display_name_with_email' == $args['show'] ) { |
|
21 | + if (is_array($args) && !empty($args['show']) && 'display_name_with_email' == $args['show']) { |
|
22 | 22 | $args['show'] = 'display_name_with_login'; |
23 | 23 | } |
24 | 24 | |
25 | - return wp_dropdown_users( $args ); |
|
25 | + return wp_dropdown_users($args); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * @return string capability to check against |
33 | 33 | * @param string $capalibilty Optional. The alternative capability to check against. |
34 | 34 | */ |
35 | -function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
|
35 | +function wpinv_get_capability($capalibilty = 'manage_invoicing') { |
|
36 | 36 | |
37 | - if ( current_user_can( 'manage_options' ) ) { |
|
37 | + if (current_user_can('manage_options')) { |
|
38 | 38 | return 'manage_options'; |
39 | 39 | }; |
40 | 40 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return bool |
49 | 49 | */ |
50 | 50 | function wpinv_current_user_can_manage_invoicing() { |
51 | - return current_user_can( wpinv_get_capability() ); |
|
51 | + return current_user_can(wpinv_get_capability()); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -57,19 +57,19 @@ discard block |
||
57 | 57 | * @since 1.0.19 |
58 | 58 | * @return int|WP_Error |
59 | 59 | */ |
60 | -function wpinv_create_user( $email, $prefix = '' ) { |
|
60 | +function wpinv_create_user($email, $prefix = '') { |
|
61 | 61 | |
62 | 62 | // Prepare user values. |
63 | - $prefix = preg_replace( '/\s+/', '', $prefix ); |
|
64 | - $prefix = empty( $prefix ) ? $email : $prefix; |
|
65 | - $args = array( |
|
66 | - 'user_login' => wpinv_generate_user_name( $prefix ), |
|
63 | + $prefix = preg_replace('/\s+/', '', $prefix); |
|
64 | + $prefix = empty($prefix) ? $email : $prefix; |
|
65 | + $args = array( |
|
66 | + 'user_login' => wpinv_generate_user_name($prefix), |
|
67 | 67 | 'user_pass' => wp_generate_password(), |
68 | 68 | 'user_email' => $email, |
69 | 69 | 'role' => 'subscriber', |
70 | 70 | ); |
71 | 71 | |
72 | - return wp_insert_user( $args ); |
|
72 | + return wp_insert_user($args); |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | |
@@ -79,26 +79,26 @@ discard block |
||
79 | 79 | * @since 1.0.19 |
80 | 80 | * @return bool|WP_User |
81 | 81 | */ |
82 | -function wpinv_generate_user_name( $prefix = '' ) { |
|
82 | +function wpinv_generate_user_name($prefix = '') { |
|
83 | 83 | |
84 | 84 | // If prefix is an email, retrieve the part before the email. |
85 | - $prefix = strtok( $prefix, '@' ); |
|
86 | - $prefix = trim( $prefix, '.' ); |
|
85 | + $prefix = strtok($prefix, '@'); |
|
86 | + $prefix = trim($prefix, '.'); |
|
87 | 87 | |
88 | 88 | // Sanitize the username. |
89 | - $prefix = sanitize_user( $prefix, true ); |
|
89 | + $prefix = sanitize_user($prefix, true); |
|
90 | 90 | |
91 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
92 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
93 | - $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
91 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
92 | + if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) { |
|
93 | + $prefix = 'gtp_' . zeroise(wp_rand(0, 9999), 4); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $username = $prefix; |
97 | 97 | $postfix = 2; |
98 | 98 | |
99 | - while ( username_exists( $username ) ) { |
|
99 | + while (username_exists($username)) { |
|
100 | 100 | $username = $prefix + $postfix; |
101 | - $postfix ++; |
|
101 | + $postfix++; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | return $username; |
@@ -115,31 +115,31 @@ discard block |
||
115 | 115 | $tabs = array( |
116 | 116 | |
117 | 117 | 'gp-invoices' => array( |
118 | - 'label' => __( 'Invoices', 'invoicing' ), // Name of the tab. |
|
118 | + 'label' => __('Invoices', 'invoicing'), // Name of the tab. |
|
119 | 119 | 'content' => '[wpinv_history]', // Content of the tab. Or specify "callback" to provide a callback instead. |
120 | 120 | 'icon' => 'fas fa-file-invoice', // Shown on some profile plugins. |
121 | 121 | ), |
122 | 122 | |
123 | 123 | 'gp-subscriptions' => array( |
124 | - 'label' => __( 'Subscriptions', 'invoicing' ), |
|
124 | + 'label' => __('Subscriptions', 'invoicing'), |
|
125 | 125 | 'content' => '[wpinv_subscriptions]', |
126 | 126 | 'icon' => 'fas fa-redo', |
127 | 127 | ), |
128 | 128 | |
129 | 129 | 'gp-edit-address' => array( |
130 | - 'label' => __( 'Billing Address', 'invoicing' ), |
|
130 | + 'label' => __('Billing Address', 'invoicing'), |
|
131 | 131 | 'callback' => 'getpaid_display_address_edit_tab', |
132 | 132 | 'icon' => 'fas fa-credit-card', |
133 | 133 | ), |
134 | 134 | |
135 | 135 | ); |
136 | 136 | |
137 | - $tabs = apply_filters( 'getpaid_user_content_tabs', $tabs ); |
|
137 | + $tabs = apply_filters('getpaid_user_content_tabs', $tabs); |
|
138 | 138 | |
139 | 139 | // Make sure address editing is last on the list. |
140 | - if ( isset( $tabs['gp-edit-address'] ) ) { |
|
140 | + if (isset($tabs['gp-edit-address'])) { |
|
141 | 141 | $address = $tabs['gp-edit-address']; |
142 | - unset( $tabs['gp-edit-address'] ); |
|
142 | + unset($tabs['gp-edit-address']); |
|
143 | 143 | $tabs['gp-edit-address'] = $address; |
144 | 144 | } |
145 | 145 | |
@@ -153,19 +153,19 @@ discard block |
||
153 | 153 | * @param array $tab |
154 | 154 | * @return array |
155 | 155 | */ |
156 | -function getpaid_prepare_user_content_tab( $tab ) { |
|
156 | +function getpaid_prepare_user_content_tab($tab) { |
|
157 | 157 | |
158 | - if ( ! empty( $tab['callback'] ) ) { |
|
159 | - return call_user_func( $tab['callback'] ); |
|
158 | + if (!empty($tab['callback'])) { |
|
159 | + return call_user_func($tab['callback']); |
|
160 | 160 | } |
161 | 161 | |
162 | - if ( ! empty( $tab['content'] ) ) { |
|
163 | - return convert_smilies( capital_P_dangit( wp_filter_content_tags( do_shortcode( shortcode_unautop( wpautop( wptexturize( do_blocks( $tab['content'] ) ) ) ) ) ) ) ); |
|
162 | + if (!empty($tab['content'])) { |
|
163 | + return convert_smilies(capital_P_dangit(wp_filter_content_tags(do_shortcode(shortcode_unautop(wpautop(wptexturize(do_blocks($tab['content'])))))))); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | $notice = aui()->alert( |
167 | 167 | array( |
168 | - 'content' => __( 'This tab has no content or content callback.', 'invoicing' ), |
|
168 | + 'content' => __('This tab has no content or content callback.', 'invoicing'), |
|
169 | 169 | 'type' => 'error', |
170 | 170 | ) |
171 | 171 | ); |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | * @param string $default |
182 | 182 | * @return array |
183 | 183 | */ |
184 | -function getpaid_get_tab_url( $tab, $default ) { |
|
184 | +function getpaid_get_tab_url($tab, $default) { |
|
185 | 185 | global $getpaid_tab_url; |
186 | 186 | |
187 | - if ( empty( $getpaid_tab_url ) ) { |
|
187 | + if (empty($getpaid_tab_url)) { |
|
188 | 188 | return $default; |
189 | 189 | } |
190 | 190 | |
191 | - return sprintf( $getpaid_tab_url, $tab ); |
|
191 | + return sprintf($getpaid_tab_url, $tab); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | */ |
201 | 201 | function getpaid_display_address_edit_tab() { |
202 | 202 | |
203 | - if ( 0 === get_current_user_id() ) { |
|
203 | + if (0 === get_current_user_id()) { |
|
204 | 204 | return '<div class="bsui">' . aui()->alert( |
205 | 205 | array( |
206 | 206 | 'type' => 'error', |
207 | - 'content' => __( 'Your must be logged in to view this section', 'invoicing' ), |
|
207 | + 'content' => __('Your must be logged in to view this section', 'invoicing'), |
|
208 | 208 | 'dismissible' => false, |
209 | 209 | ) |
210 | 210 | ) . '</div>'; |
@@ -218,19 +218,19 @@ discard block |
||
218 | 218 | |
219 | 219 | <?php |
220 | 220 | |
221 | - foreach ( getpaid_user_address_fields() as $key => $label ) { |
|
221 | + foreach (getpaid_user_address_fields() as $key => $label) { |
|
222 | 222 | |
223 | 223 | // Display the country. |
224 | - if ( 'country' == $key ) { |
|
224 | + if ('country' == $key) { |
|
225 | 225 | |
226 | 226 | aui()->select( |
227 | 227 | array( |
228 | 228 | 'options' => wpinv_get_country_list(), |
229 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
230 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
231 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
229 | + 'name' => 'getpaid_address[' . esc_attr($key) . ']', |
|
230 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
231 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
232 | 232 | 'placeholder' => $label, |
233 | - 'label' => wp_kses_post( $label ), |
|
233 | + 'label' => wp_kses_post($label), |
|
234 | 234 | 'label_type' => 'vertical', |
235 | 235 | 'class' => 'getpaid-address-field', |
236 | 236 | ), |
@@ -240,17 +240,17 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | // Display the state. |
243 | - elseif ( 'state' == $key ) { |
|
243 | + elseif ('state' == $key) { |
|
244 | 244 | |
245 | 245 | getpaid_get_states_select_markup( |
246 | - getpaid_get_user_address_field( get_current_user_id(), 'country' ), |
|
247 | - getpaid_get_user_address_field( get_current_user_id(), 'state' ), |
|
246 | + getpaid_get_user_address_field(get_current_user_id(), 'country'), |
|
247 | + getpaid_get_user_address_field(get_current_user_id(), 'state'), |
|
248 | 248 | $label, |
249 | 249 | $label, |
250 | 250 | '', |
251 | 251 | false, |
252 | 252 | '', |
253 | - 'getpaid_address[' . esc_attr( $key ) . ']', |
|
253 | + 'getpaid_address[' . esc_attr($key) . ']', |
|
254 | 254 | true |
255 | 255 | ); |
256 | 256 | |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | |
259 | 259 | aui()->input( |
260 | 260 | array( |
261 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
262 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
261 | + 'name' => 'getpaid_address[' . esc_attr($key) . ']', |
|
262 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
263 | 263 | 'placeholder' => $label, |
264 | - 'label' => wp_kses_post( $label ), |
|
264 | + 'label' => wp_kses_post($label), |
|
265 | 265 | 'label_type' => 'vertical', |
266 | 266 | 'type' => 'text', |
267 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
267 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
268 | 268 | 'class' => 'getpaid-address-field', |
269 | 269 | ), |
270 | 270 | true |
@@ -278,32 +278,32 @@ discard block |
||
278 | 278 | 'name' => 'getpaid_address[email_cc]', |
279 | 279 | 'id' => 'wpinv-email_cc', |
280 | 280 | 'placeholder' => '[email protected], [email protected]', |
281 | - 'label' => __( 'Other email addresses', 'invoicing' ), |
|
281 | + 'label' => __('Other email addresses', 'invoicing'), |
|
282 | 282 | 'label_type' => 'vertical', |
283 | 283 | 'type' => 'text', |
284 | - 'value' => sanitize_text_field( get_user_meta( get_current_user_id(), '_wpinv_email_cc', true ) ), |
|
284 | + 'value' => sanitize_text_field(get_user_meta(get_current_user_id(), '_wpinv_email_cc', true)), |
|
285 | 285 | 'class' => 'getpaid-address-field', |
286 | - 'help_text' => __( 'Optionally provide other email addresses where we should send payment notifications', 'invoicing' ), |
|
286 | + 'help_text' => __('Optionally provide other email addresses where we should send payment notifications', 'invoicing'), |
|
287 | 287 | ), |
288 | 288 | true |
289 | 289 | ); |
290 | 290 | |
291 | - do_action( 'getpaid_display_address_edit_tab' ); |
|
291 | + do_action('getpaid_display_address_edit_tab'); |
|
292 | 292 | |
293 | 293 | aui()->input( |
294 | 294 | array( |
295 | 295 | 'name' => 'getpaid_profile_edit_submit_button', |
296 | 296 | 'id' => 'getpaid_profile_edit_submit_button', |
297 | - 'value' => __( 'Save Address', 'invoicing' ), |
|
298 | - 'help_text' => __( 'New invoices will use this address as the billing address.', 'invoicing' ), |
|
297 | + 'value' => __('Save Address', 'invoicing'), |
|
298 | + 'help_text' => __('New invoices will use this address as the billing address.', 'invoicing'), |
|
299 | 299 | 'type' => 'submit', |
300 | 300 | 'class' => 'btn btn-primary btn-block submit-button', |
301 | 301 | ), |
302 | 302 | true |
303 | 303 | ); |
304 | 304 | |
305 | - wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); |
|
306 | - getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' ); |
|
305 | + wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); |
|
306 | + getpaid_hidden_field('getpaid-action', 'edit_billing_details'); |
|
307 | 307 | ?> |
308 | 308 | |
309 | 309 | </form> |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | |
314 | 314 | return ob_get_clean(); |
315 | 315 | } |
316 | -add_shortcode( 'getpaid_edit_address', 'getpaid_display_address_edit_tab' ); |
|
316 | +add_shortcode('getpaid_edit_address', 'getpaid_display_address_edit_tab'); |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * Saves the billing address edit tab. |
@@ -321,30 +321,30 @@ discard block |
||
321 | 321 | * @since 2.1.4 |
322 | 322 | * @param array $data |
323 | 323 | */ |
324 | -function getpaid_save_address_edit_tab( $data ) { |
|
324 | +function getpaid_save_address_edit_tab($data) { |
|
325 | 325 | |
326 | - if ( empty( $data['getpaid_address'] ) || ! is_array( $data['getpaid_address'] ) ) { |
|
326 | + if (empty($data['getpaid_address']) || !is_array($data['getpaid_address'])) { |
|
327 | 327 | return; |
328 | 328 | } |
329 | 329 | |
330 | 330 | $data = $data['getpaid_address']; |
331 | 331 | $user_id = get_current_user_id(); |
332 | 332 | |
333 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
333 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
334 | 334 | |
335 | - if ( isset( $data[ $field ] ) ) { |
|
336 | - $value = sanitize_text_field( $data[ $field ] ); |
|
337 | - update_user_meta( $user_id, '_wpinv_' . $field, $value ); |
|
335 | + if (isset($data[$field])) { |
|
336 | + $value = sanitize_text_field($data[$field]); |
|
337 | + update_user_meta($user_id, '_wpinv_' . $field, $value); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
341 | - if ( isset( $data['email_cc'] ) ) { |
|
342 | - update_user_meta( $user_id, '_wpinv_email_cc', sanitize_text_field( $data['email_cc'] ) ); |
|
341 | + if (isset($data['email_cc'])) { |
|
342 | + update_user_meta($user_id, '_wpinv_email_cc', sanitize_text_field($data['email_cc'])); |
|
343 | 343 | } |
344 | 344 | |
345 | - wpinv_set_error( 'address_updated', __( 'Your billing address has been updated', 'invoicing' ), 'success' ); |
|
345 | + wpinv_set_error('address_updated', __('Your billing address has been updated', 'invoicing'), 'success'); |
|
346 | 346 | } |
347 | -add_action( 'getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab' ); |
|
347 | +add_action('getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab'); |
|
348 | 348 | |
349 | 349 | |
350 | 350 | /* |
@@ -362,27 +362,27 @@ discard block |
||
362 | 362 | * @param array $tabs |
363 | 363 | * @return array |
364 | 364 | */ |
365 | -function getpaid_filter_userswp_account_tabs( $tabs ) { |
|
365 | +function getpaid_filter_userswp_account_tabs($tabs) { |
|
366 | 366 | |
367 | 367 | // Abort if the integration is inactive. |
368 | - if ( ! getpaid_is_userswp_integration_active() ) { |
|
368 | + if (!getpaid_is_userswp_integration_active()) { |
|
369 | 369 | return $tabs; |
370 | 370 | } |
371 | 371 | |
372 | - $new_tabs = array(); |
|
372 | + $new_tabs = array(); |
|
373 | 373 | |
374 | - foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) { |
|
374 | + foreach (getpaid_get_user_content_tabs() as $slug => $tab) { |
|
375 | 375 | |
376 | - $new_tabs[ $slug ] = array( |
|
376 | + $new_tabs[$slug] = array( |
|
377 | 377 | 'title' => $tab['label'], |
378 | 378 | 'icon' => $tab['icon'], |
379 | 379 | ); |
380 | 380 | |
381 | 381 | } |
382 | 382 | |
383 | - return array_merge( $tabs, $new_tabs ); |
|
383 | + return array_merge($tabs, $new_tabs); |
|
384 | 384 | } |
385 | -add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' ); |
|
385 | +add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs'); |
|
386 | 386 | |
387 | 387 | /** |
388 | 388 | * Display our UsersWP account tabs. |
@@ -391,21 +391,21 @@ discard block |
||
391 | 391 | * @param array $tabs |
392 | 392 | * @return array |
393 | 393 | */ |
394 | -function getpaid_display_userswp_account_tabs( $tab ) { |
|
394 | +function getpaid_display_userswp_account_tabs($tab) { |
|
395 | 395 | global $getpaid_tab_url; |
396 | 396 | |
397 | 397 | $our_tabs = getpaid_get_user_content_tabs(); |
398 | 398 | |
399 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
400 | - $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() ); |
|
401 | - echo wp_kses( getpaid_prepare_user_content_tab( $our_tabs[ $tab ] ), getpaid_allowed_html() ); |
|
399 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
400 | + $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url()); |
|
401 | + echo wp_kses(getpaid_prepare_user_content_tab($our_tabs[$tab]), getpaid_allowed_html()); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | } |
405 | -add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' ); |
|
405 | +add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs'); |
|
406 | 406 | |
407 | 407 | function getpaid_allowed_html() { |
408 | - $allowed_html = wp_kses_allowed_html( 'post' ); |
|
408 | + $allowed_html = wp_kses_allowed_html('post'); |
|
409 | 409 | |
410 | 410 | // form fields |
411 | 411 | $allowed_html['form'] = array( |
@@ -453,17 +453,17 @@ discard block |
||
453 | 453 | * @param string $tab Current tab. |
454 | 454 | * @return string Title. |
455 | 455 | */ |
456 | -function getpaid_filter_userswp_account_title( $title, $tab ) { |
|
456 | +function getpaid_filter_userswp_account_title($title, $tab) { |
|
457 | 457 | |
458 | - $our_tabs = getpaid_get_user_content_tabs(); |
|
458 | + $our_tabs = getpaid_get_user_content_tabs(); |
|
459 | 459 | |
460 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
461 | - return $our_tabs[ $tab ]['label']; |
|
460 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
461 | + return $our_tabs[$tab]['label']; |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | return $title; |
465 | 465 | } |
466 | -add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 ); |
|
466 | +add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2); |
|
467 | 467 | |
468 | 468 | /** |
469 | 469 | * Registers the UsersWP integration settings. |
@@ -472,26 +472,26 @@ discard block |
||
472 | 472 | * @param array $settings An array of integration settings. |
473 | 473 | * @return array |
474 | 474 | */ |
475 | -function getpaid_register_userswp_settings( $settings ) { |
|
475 | +function getpaid_register_userswp_settings($settings) { |
|
476 | 476 | |
477 | - if ( defined( 'USERSWP_PLUGIN_FILE' ) ) { |
|
477 | + if (defined('USERSWP_PLUGIN_FILE')) { |
|
478 | 478 | |
479 | 479 | $settings[] = array( |
480 | 480 | |
481 | 481 | 'id' => 'userswp', |
482 | - 'label' => __( 'UsersWP', 'invoicing' ), |
|
482 | + 'label' => __('UsersWP', 'invoicing'), |
|
483 | 483 | 'settings' => array( |
484 | 484 | |
485 | 485 | 'userswp_settings' => array( |
486 | 486 | 'id' => 'userswp_settings', |
487 | - 'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>', |
|
487 | + 'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>', |
|
488 | 488 | 'type' => 'header', |
489 | 489 | ), |
490 | 490 | |
491 | 491 | 'enable_userswp' => array( |
492 | 492 | 'id' => 'enable_userswp', |
493 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
494 | - 'desc' => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ), |
|
493 | + 'name' => __('Enable Integration', 'invoicing'), |
|
494 | + 'desc' => __('Display GetPaid items on UsersWP account page.', 'invoicing'), |
|
495 | 495 | 'type' => 'checkbox', |
496 | 496 | 'std' => 1, |
497 | 497 | ), |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | |
505 | 505 | return $settings; |
506 | 506 | } |
507 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' ); |
|
507 | +add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings'); |
|
508 | 508 | |
509 | 509 | /** |
510 | 510 | * Ovewrites the invoices history page to UsersWP. |
@@ -512,18 +512,18 @@ discard block |
||
512 | 512 | * @since 2.3.1 |
513 | 513 | * @return bool |
514 | 514 | */ |
515 | -function getpaid_userswp_overwrite_invoice_history_page( $url, $post_type ) { |
|
515 | +function getpaid_userswp_overwrite_invoice_history_page($url, $post_type) { |
|
516 | 516 | |
517 | 517 | $our_tabs = getpaid_get_user_content_tabs(); |
518 | 518 | $tab = "gp-{$post_type}s"; |
519 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
520 | - return add_query_arg( 'type', $tab, uwp_get_account_page_url() ); |
|
519 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
520 | + return add_query_arg('type', $tab, uwp_get_account_page_url()); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | return $url; |
524 | 524 | |
525 | 525 | } |
526 | -add_filter( 'wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2 ); |
|
526 | +add_filter('wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2); |
|
527 | 527 | |
528 | 528 | /** |
529 | 529 | * Checks if the integration is enabled. |
@@ -532,8 +532,8 @@ discard block |
||
532 | 532 | * @return bool |
533 | 533 | */ |
534 | 534 | function getpaid_is_userswp_integration_active() { |
535 | - $enabled = wpinv_get_option( 'enable_userswp', 1 ); |
|
536 | - return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled ); |
|
535 | + $enabled = wpinv_get_option('enable_userswp', 1); |
|
536 | + return defined('USERSWP_PLUGIN_FILE') && !empty($enabled); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | /* |
@@ -551,26 +551,26 @@ discard block |
||
551 | 551 | * @param array $settings An array of integration settings. |
552 | 552 | * @return array |
553 | 553 | */ |
554 | -function getpaid_register_buddypress_settings( $settings ) { |
|
554 | +function getpaid_register_buddypress_settings($settings) { |
|
555 | 555 | |
556 | - if ( class_exists( 'BuddyPress' ) ) { |
|
556 | + if (class_exists('BuddyPress')) { |
|
557 | 557 | |
558 | 558 | $settings[] = array( |
559 | 559 | |
560 | 560 | 'id' => 'buddypress', |
561 | - 'label' => __( 'BuddyPress', 'invoicing' ), |
|
561 | + 'label' => __('BuddyPress', 'invoicing'), |
|
562 | 562 | 'settings' => array( |
563 | 563 | |
564 | 564 | 'buddypress_settings' => array( |
565 | 565 | 'id' => 'buddypress_settings', |
566 | - 'name' => '<h3>' . __( 'BuddyPress', 'invoicing' ) . '</h3>', |
|
566 | + 'name' => '<h3>' . __('BuddyPress', 'invoicing') . '</h3>', |
|
567 | 567 | 'type' => 'header', |
568 | 568 | ), |
569 | 569 | |
570 | 570 | 'enable_buddypress' => array( |
571 | 571 | 'id' => 'enable_buddypress', |
572 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
573 | - 'desc' => __( 'Display GetPaid items on BuddyPress account pages.', 'invoicing' ), |
|
572 | + 'name' => __('Enable Integration', 'invoicing'), |
|
573 | + 'desc' => __('Display GetPaid items on BuddyPress account pages.', 'invoicing'), |
|
574 | 574 | 'type' => 'checkbox', |
575 | 575 | 'std' => 1, |
576 | 576 | ), |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | |
584 | 584 | return $settings; |
585 | 585 | } |
586 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_buddypress_settings' ); |
|
586 | +add_filter('getpaid_integration_settings', 'getpaid_register_buddypress_settings'); |
|
587 | 587 | |
588 | 588 | /** |
589 | 589 | * Checks if the integration is enabled. |
@@ -592,8 +592,8 @@ discard block |
||
592 | 592 | * @return bool |
593 | 593 | */ |
594 | 594 | function getpaid_is_buddypress_integration_active() { |
595 | - $enabled = wpinv_get_option( 'enable_buddypress', 1 ); |
|
596 | - return class_exists( 'BuddyPress' ) && ! empty( $enabled ); |
|
595 | + $enabled = wpinv_get_option('enable_buddypress', 1); |
|
596 | + return class_exists('BuddyPress') && !empty($enabled); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
@@ -604,10 +604,10 @@ discard block |
||
604 | 604 | */ |
605 | 605 | function getpaid_setup_buddypress_integration() { |
606 | 606 | |
607 | - if ( getpaid_is_buddypress_integration_active() ) { |
|
607 | + if (getpaid_is_buddypress_integration_active()) { |
|
608 | 608 | require_once WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php'; |
609 | 609 | buddypress()->getpaid = new BP_GetPaid_Component(); |
610 | 610 | } |
611 | 611 | |
612 | 612 | } |
613 | -add_action( 'bp_setup_components', 'getpaid_setup_buddypress_integration' ); |
|
613 | +add_action('bp_setup_components', 'getpaid_setup_buddypress_integration'); |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
36 | 36 | |
37 | - if ( current_user_can( 'manage_options' ) ) { |
|
38 | - return 'manage_options'; |
|
39 | - }; |
|
37 | + if ( current_user_can( 'manage_options' ) ) { |
|
38 | + return 'manage_options'; |
|
39 | + }; |
|
40 | 40 | |
41 | - return $capalibilty; |
|
41 | + return $capalibilty; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | // Prepare user values. |
63 | 63 | $prefix = preg_replace( '/\s+/', '', $prefix ); |
64 | 64 | $prefix = empty( $prefix ) ? $email : $prefix; |
65 | - $args = array( |
|
66 | - 'user_login' => wpinv_generate_user_name( $prefix ), |
|
67 | - 'user_pass' => wp_generate_password(), |
|
68 | - 'user_email' => $email, |
|
65 | + $args = array( |
|
66 | + 'user_login' => wpinv_generate_user_name( $prefix ), |
|
67 | + 'user_pass' => wp_generate_password(), |
|
68 | + 'user_email' => $email, |
|
69 | 69 | 'role' => 'subscriber', |
70 | 70 | ); |
71 | 71 | |
@@ -82,16 +82,16 @@ discard block |
||
82 | 82 | function wpinv_generate_user_name( $prefix = '' ) { |
83 | 83 | |
84 | 84 | // If prefix is an email, retrieve the part before the email. |
85 | - $prefix = strtok( $prefix, '@' ); |
|
85 | + $prefix = strtok( $prefix, '@' ); |
|
86 | 86 | $prefix = trim( $prefix, '.' ); |
87 | 87 | |
88 | - // Sanitize the username. |
|
89 | - $prefix = sanitize_user( $prefix, true ); |
|
88 | + // Sanitize the username. |
|
89 | + $prefix = sanitize_user( $prefix, true ); |
|
90 | 90 | |
91 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
92 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
93 | - $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
94 | - } |
|
91 | + $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
92 | + if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
93 | + $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
94 | + } |
|
95 | 95 | |
96 | 96 | $username = $prefix; |
97 | 97 | $postfix = 2; |
@@ -220,43 +220,43 @@ discard block |
||
220 | 220 | |
221 | 221 | foreach ( getpaid_user_address_fields() as $key => $label ) { |
222 | 222 | |
223 | - // Display the country. |
|
224 | - if ( 'country' == $key ) { |
|
225 | - |
|
226 | - aui()->select( |
|
227 | - array( |
|
228 | - 'options' => wpinv_get_country_list(), |
|
229 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
230 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
231 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
232 | - 'placeholder' => $label, |
|
233 | - 'label' => wp_kses_post( $label ), |
|
234 | - 'label_type' => 'vertical', |
|
235 | - 'class' => 'getpaid-address-field', |
|
223 | + // Display the country. |
|
224 | + if ( 'country' == $key ) { |
|
225 | + |
|
226 | + aui()->select( |
|
227 | + array( |
|
228 | + 'options' => wpinv_get_country_list(), |
|
229 | + 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
230 | + 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
231 | + 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
232 | + 'placeholder' => $label, |
|
233 | + 'label' => wp_kses_post( $label ), |
|
234 | + 'label_type' => 'vertical', |
|
235 | + 'class' => 'getpaid-address-field', |
|
236 | 236 | ), |
237 | 237 | true |
238 | - ); |
|
239 | - |
|
240 | - } |
|
241 | - |
|
242 | - // Display the state. |
|
243 | - elseif ( 'state' == $key ) { |
|
244 | - |
|
245 | - getpaid_get_states_select_markup( |
|
246 | - getpaid_get_user_address_field( get_current_user_id(), 'country' ), |
|
247 | - getpaid_get_user_address_field( get_current_user_id(), 'state' ), |
|
248 | - $label, |
|
249 | - $label, |
|
250 | - '', |
|
251 | - false, |
|
252 | - '', |
|
253 | - 'getpaid_address[' . esc_attr( $key ) . ']', |
|
238 | + ); |
|
239 | + |
|
240 | + } |
|
241 | + |
|
242 | + // Display the state. |
|
243 | + elseif ( 'state' == $key ) { |
|
244 | + |
|
245 | + getpaid_get_states_select_markup( |
|
246 | + getpaid_get_user_address_field( get_current_user_id(), 'country' ), |
|
247 | + getpaid_get_user_address_field( get_current_user_id(), 'state' ), |
|
248 | + $label, |
|
249 | + $label, |
|
250 | + '', |
|
251 | + false, |
|
252 | + '', |
|
253 | + 'getpaid_address[' . esc_attr( $key ) . ']', |
|
254 | 254 | true |
255 | - ); |
|
255 | + ); |
|
256 | 256 | |
257 | 257 | } else { |
258 | 258 | |
259 | - aui()->input( |
|
259 | + aui()->input( |
|
260 | 260 | array( |
261 | 261 | 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
262 | 262 | 'id' => 'wpinv-' . sanitize_html_class( $key ), |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | 'class' => 'getpaid-address-field', |
269 | 269 | ), |
270 | 270 | true |
271 | - ); |
|
271 | + ); |
|
272 | 272 | |
273 | 273 | } |
274 | 274 | } |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | function getpaid_allowed_html() { |
408 | 408 | $allowed_html = wp_kses_allowed_html( 'post' ); |
409 | 409 | |
410 | - // form fields |
|
410 | + // form fields |
|
411 | 411 | $allowed_html['form'] = array( |
412 | 412 | 'action' => true, |
413 | 413 | 'accept' => true, |
@@ -419,12 +419,12 @@ discard block |
||
419 | 419 | ); |
420 | 420 | |
421 | 421 | // - input |
422 | - $allowed_html['input'] = array( |
|
423 | - 'class' => array(), |
|
424 | - 'id' => array(), |
|
425 | - 'name' => array(), |
|
426 | - 'value' => array(), |
|
427 | - 'type' => array(), |
|
422 | + $allowed_html['input'] = array( |
|
423 | + 'class' => array(), |
|
424 | + 'id' => array(), |
|
425 | + 'name' => array(), |
|
426 | + 'value' => array(), |
|
427 | + 'type' => array(), |
|
428 | 428 | 'placeholder' => array(), |
429 | 429 | 'autocomplete' => array(), |
430 | 430 | 'autofocus' => array(), |
@@ -438,33 +438,33 @@ discard block |
||
438 | 438 | 'max' => array(), |
439 | 439 | 'step' => array(), |
440 | 440 | 'size' => array(), |
441 | - ); |
|
441 | + ); |
|
442 | 442 | |
443 | 443 | // - input |
444 | - $allowed_html['textarea'] = array( |
|
445 | - 'class' => array(), |
|
446 | - 'id' => array(), |
|
447 | - 'name' => array(), |
|
448 | - 'value' => array(), |
|
449 | - ); |
|
450 | - |
|
451 | - // select |
|
452 | - $allowed_html['select'] = array( |
|
453 | - 'class' => array(), |
|
454 | - 'id' => array(), |
|
455 | - 'name' => array(), |
|
444 | + $allowed_html['textarea'] = array( |
|
445 | + 'class' => array(), |
|
446 | + 'id' => array(), |
|
447 | + 'name' => array(), |
|
448 | + 'value' => array(), |
|
449 | + ); |
|
450 | + |
|
451 | + // select |
|
452 | + $allowed_html['select'] = array( |
|
453 | + 'class' => array(), |
|
454 | + 'id' => array(), |
|
455 | + 'name' => array(), |
|
456 | 456 | 'autocomplete' => array(), |
457 | 457 | 'multiple' => array(), |
458 | - ); |
|
458 | + ); |
|
459 | 459 | |
460 | - // select options |
|
461 | - $allowed_html['option'] = array( |
|
462 | - 'selected' => array(), |
|
460 | + // select options |
|
461 | + $allowed_html['option'] = array( |
|
462 | + 'selected' => array(), |
|
463 | 463 | 'disabled' => array(), |
464 | 464 | 'value' => array(), |
465 | - ); |
|
465 | + ); |
|
466 | 466 | |
467 | - return $allowed_html; |
|
467 | + return $allowed_html; |
|
468 | 468 | |
469 | 469 | } |
470 | 470 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | * Hook in methods. |
15 | 15 | */ |
16 | 16 | public static function init() { |
17 | - add_action( 'init', array( __CLASS__, 'init_hooks' ), 0 ); |
|
18 | - add_action( 'admin_notices', array( __CLASS__, 'notices' ) ); |
|
17 | + add_action('init', array(__CLASS__, 'init_hooks'), 0); |
|
18 | + add_action('admin_notices', array(__CLASS__, 'notices')); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public static function init_hooks() { |
22 | - if ( false === ( $page_uris = get_transient( 'wpinv_cache_excluded_uris' ) ) ) { |
|
23 | - $checkout_page = wpinv_get_option( 'checkout_page', '' ); |
|
24 | - $success_page = wpinv_get_option( 'success_page', '' ); |
|
25 | - $failure_page = wpinv_get_option( 'failure_page', '' ); |
|
26 | - $history_page = wpinv_get_option( 'invoice_history_page', '' ); |
|
27 | - $subscr_page = wpinv_get_option( 'invoice_subscription_page', '' ); |
|
28 | - if ( empty( $checkout_page ) || empty( $success_page ) || empty( $failure_page ) || empty( $history_page ) || empty( $subscr_page ) ) { |
|
22 | + if (false === ($page_uris = get_transient('wpinv_cache_excluded_uris'))) { |
|
23 | + $checkout_page = wpinv_get_option('checkout_page', ''); |
|
24 | + $success_page = wpinv_get_option('success_page', ''); |
|
25 | + $failure_page = wpinv_get_option('failure_page', ''); |
|
26 | + $history_page = wpinv_get_option('invoice_history_page', ''); |
|
27 | + $subscr_page = wpinv_get_option('invoice_subscription_page', ''); |
|
28 | + if (empty($checkout_page) || empty($success_page) || empty($failure_page) || empty($history_page) || empty($subscr_page)) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
@@ -39,34 +39,34 @@ discard block |
||
39 | 39 | $page_uris[] = 'p=' . $subscr_page; |
40 | 40 | |
41 | 41 | // Exclude permalinks |
42 | - $checkout_page = get_post( $checkout_page ); |
|
43 | - $success_page = get_post( $success_page ); |
|
44 | - $failure_page = get_post( $failure_page ); |
|
45 | - $history_page = get_post( $history_page ); |
|
46 | - $subscr_page = get_post( $subscr_page ); |
|
42 | + $checkout_page = get_post($checkout_page); |
|
43 | + $success_page = get_post($success_page); |
|
44 | + $failure_page = get_post($failure_page); |
|
45 | + $history_page = get_post($history_page); |
|
46 | + $subscr_page = get_post($subscr_page); |
|
47 | 47 | |
48 | - if ( ! is_null( $checkout_page ) ) { |
|
48 | + if (!is_null($checkout_page)) { |
|
49 | 49 | $page_uris[] = '/' . $checkout_page->post_name; |
50 | 50 | } |
51 | - if ( ! is_null( $success_page ) ) { |
|
51 | + if (!is_null($success_page)) { |
|
52 | 52 | $page_uris[] = '/' . $success_page->post_name; |
53 | 53 | } |
54 | - if ( ! is_null( $failure_page ) ) { |
|
54 | + if (!is_null($failure_page)) { |
|
55 | 55 | $page_uris[] = '/' . $failure_page->post_name; |
56 | 56 | } |
57 | - if ( ! is_null( $history_page ) ) { |
|
57 | + if (!is_null($history_page)) { |
|
58 | 58 | $page_uris[] = '/' . $history_page->post_name; |
59 | 59 | } |
60 | - if ( ! is_null( $subscr_page ) ) { |
|
60 | + if (!is_null($subscr_page)) { |
|
61 | 61 | $page_uris[] = '/' . $subscr_page->post_name; |
62 | 62 | } |
63 | 63 | |
64 | - set_transient( 'wpinv_cache_excluded_uris', $page_uris ); |
|
64 | + set_transient('wpinv_cache_excluded_uris', $page_uris); |
|
65 | 65 | } |
66 | 66 | |
67 | - if ( is_array( $page_uris ) ) { |
|
68 | - foreach ( $page_uris as $uri ) { |
|
69 | - if ( strstr( $_SERVER['REQUEST_URI'], $uri ) ) { |
|
67 | + if (is_array($page_uris)) { |
|
68 | + foreach ($page_uris as $uri) { |
|
69 | + if (strstr($_SERVER['REQUEST_URI'], $uri)) { |
|
70 | 70 | self::nocache(); |
71 | 71 | break; |
72 | 72 | } |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * @access private |
80 | 80 | */ |
81 | 81 | private static function nocache() { |
82 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
83 | - define( 'DONOTCACHEPAGE', true ); |
|
82 | + if (!defined('DONOTCACHEPAGE')) { |
|
83 | + define('DONOTCACHEPAGE', true); |
|
84 | 84 | } |
85 | - if ( ! defined( 'DONOTCACHEOBJECT' ) ) { |
|
86 | - define( 'DONOTCACHEOBJECT', true ); |
|
85 | + if (!defined('DONOTCACHEOBJECT')) { |
|
86 | + define('DONOTCACHEOBJECT', true); |
|
87 | 87 | } |
88 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
89 | - define( 'DONOTCACHEDB', true ); |
|
88 | + if (!defined('DONOTCACHEDB')) { |
|
89 | + define('DONOTCACHEDB', true); |
|
90 | 90 | } |
91 | 91 | nocache_headers(); |
92 | 92 | } |
@@ -95,18 +95,18 @@ discard block |
||
95 | 95 | * notices function. |
96 | 96 | */ |
97 | 97 | public static function notices() { |
98 | - if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) { |
|
98 | + if (!function_exists('w3tc_pgcache_flush') || !function_exists('w3_instance')) { |
|
99 | 99 | return; |
100 | 100 | } |
101 | 101 | |
102 | - $config = w3_instance( 'W3_Config' ); |
|
103 | - $enabled = $config->get_integer( 'dbcache.enabled' ); |
|
104 | - $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) ); |
|
102 | + $config = w3_instance('W3_Config'); |
|
103 | + $enabled = $config->get_integer('dbcache.enabled'); |
|
104 | + $settings = array_map('trim', $config->get_array('dbcache.reject.sql')); |
|
105 | 105 | |
106 | - if ( $enabled && ! in_array( '_wp_session_', $settings ) ) { |
|
106 | + if ($enabled && !in_array('_wp_session_', $settings)) { |
|
107 | 107 | ?> |
108 | 108 | <div class="error"> |
109 | - <p><?php printf( wp_kses_post( __( 'In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing' ) ), '<code>_wp_session_</code>', esc_url( admin_url( 'admin.php?page=w3tc_dbcache' ) ) ); ?></p> |
|
109 | + <p><?php printf(wp_kses_post(__('In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing')), '<code>_wp_session_</code>', esc_url(admin_url('admin.php?page=w3tc_dbcache'))); ?></p> |
|
110 | 110 | </div> |
111 | 111 | <?php |
112 | 112 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function wpinv_subscriptions_page() { |
16 | 16 | |
17 | - ?> |
|
17 | + ?> |
|
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,28 +22,28 @@ discard block |
||
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | - // Verify user permissions. |
|
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
25 | + // Verify user permissions. |
|
26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
27 | 27 | |
28 | - aui()->alert( |
|
28 | + aui()->alert( |
|
29 | 29 | array( |
30 | - 'type' => 'danger', |
|
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | - ), |
|
33 | - true |
|
30 | + 'type' => 'danger', |
|
31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | + ), |
|
33 | + true |
|
34 | 34 | ); |
35 | 35 | |
36 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
36 | + } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
37 | 37 | |
38 | - // Display a single subscription. |
|
39 | - wpinv_recurring_subscription_details(); |
|
40 | - } else { |
|
38 | + // Display a single subscription. |
|
39 | + wpinv_recurring_subscription_details(); |
|
40 | + } else { |
|
41 | 41 | |
42 | - // Display a list of available subscriptions. |
|
43 | - getpaid_print_subscriptions_list(); |
|
44 | - } |
|
42 | + // Display a list of available subscriptions. |
|
43 | + getpaid_print_subscriptions_list(); |
|
44 | + } |
|
45 | 45 | |
46 | - ?> |
|
46 | + ?> |
|
47 | 47 | |
48 | 48 | </div> |
49 | 49 | </div> |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | */ |
61 | 61 | function getpaid_print_subscriptions_list() { |
62 | 62 | |
63 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
64 | - $subscribers_table->prepare_items(); |
|
63 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
64 | + $subscribers_table->prepare_items(); |
|
65 | 65 | |
66 | - ?> |
|
66 | + ?> |
|
67 | 67 | <?php $subscribers_table->views(); ?> |
68 | 68 | <form id="subscribers-filter" class="bsui" method="get"> |
69 | 69 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
@@ -82,42 +82,42 @@ discard block |
||
82 | 82 | */ |
83 | 83 | function wpinv_recurring_subscription_details() { |
84 | 84 | |
85 | - // Fetch the subscription. |
|
86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
87 | - if ( ! $sub->exists() ) { |
|
85 | + // Fetch the subscription. |
|
86 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
87 | + if ( ! $sub->exists() ) { |
|
88 | 88 | |
89 | - aui()->alert( |
|
90 | - array( |
|
91 | - 'type' => 'danger', |
|
92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
93 | - ), |
|
94 | - true |
|
95 | - ); |
|
89 | + aui()->alert( |
|
90 | + array( |
|
91 | + 'type' => 'danger', |
|
92 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
93 | + ), |
|
94 | + true |
|
95 | + ); |
|
96 | 96 | |
97 | - return; |
|
98 | - } |
|
97 | + return; |
|
98 | + } |
|
99 | 99 | |
100 | - // Use metaboxes to display the subscription details. |
|
101 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
102 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | + // Use metaboxes to display the subscription details. |
|
101 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
102 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
103 | 103 | |
104 | - $subscription_id = $sub->get_id(); |
|
105 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
106 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
104 | + $subscription_id = $sub->get_id(); |
|
105 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
106 | + $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
107 | 107 | |
108 | - if ( 1 < count( $subscription_groups ) ) { |
|
109 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
110 | - } |
|
108 | + if ( 1 < count( $subscription_groups ) ) { |
|
109 | + add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
110 | + } |
|
111 | 111 | |
112 | - if ( ! empty( $subscription_group ) ) { |
|
113 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
114 | - } |
|
112 | + if ( ! empty( $subscription_group ) ) { |
|
113 | + add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
114 | + } |
|
115 | 115 | |
116 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
116 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
117 | 117 | |
118 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
118 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
119 | 119 | |
120 | - ?> |
|
120 | + ?> |
|
121 | 121 | |
122 | 122 | <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
123 | 123 | |
@@ -157,44 +157,44 @@ discard block |
||
157 | 157 | */ |
158 | 158 | function getpaid_admin_subscription_details_metabox( $sub ) { |
159 | 159 | |
160 | - // Subscription items. |
|
161 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
162 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
163 | - |
|
164 | - // Prepare subscription detail columns. |
|
165 | - $fields = apply_filters( |
|
166 | - 'getpaid_subscription_admin_page_fields', |
|
167 | - array( |
|
168 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
169 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
170 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
171 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
172 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
173 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
174 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
177 | - 'status' => __( 'Status', 'invoicing' ), |
|
178 | - ) |
|
179 | - ); |
|
180 | - |
|
181 | - if ( ! $sub->is_active() ) { |
|
182 | - |
|
183 | - if ( isset( $fields['renews_on'] ) ) { |
|
184 | - unset( $fields['renews_on'] ); |
|
185 | - } |
|
186 | - |
|
187 | - if ( isset( $fields['gateway'] ) ) { |
|
188 | - unset( $fields['gateway'] ); |
|
189 | - } |
|
160 | + // Subscription items. |
|
161 | + $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
162 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
163 | + |
|
164 | + // Prepare subscription detail columns. |
|
165 | + $fields = apply_filters( |
|
166 | + 'getpaid_subscription_admin_page_fields', |
|
167 | + array( |
|
168 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
169 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
170 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
171 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
172 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
173 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
174 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
175 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
176 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
177 | + 'status' => __( 'Status', 'invoicing' ), |
|
178 | + ) |
|
179 | + ); |
|
180 | + |
|
181 | + if ( ! $sub->is_active() ) { |
|
182 | + |
|
183 | + if ( isset( $fields['renews_on'] ) ) { |
|
184 | + unset( $fields['renews_on'] ); |
|
185 | + } |
|
186 | + |
|
187 | + if ( isset( $fields['gateway'] ) ) { |
|
188 | + unset( $fields['gateway'] ); |
|
189 | + } |
|
190 | 190 | } |
191 | 191 | |
192 | - $profile_id = $sub->get_profile_id(); |
|
193 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
194 | - unset( $fields['profile_id'] ); |
|
195 | - } |
|
192 | + $profile_id = $sub->get_profile_id(); |
|
193 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
194 | + unset( $fields['profile_id'] ); |
|
195 | + } |
|
196 | 196 | |
197 | - ?> |
|
197 | + ?> |
|
198 | 198 | |
199 | 199 | <table class="table table-borderless" style="font-size: 14px;"> |
200 | 200 | <tbody> |
@@ -228,20 +228,20 @@ discard block |
||
228 | 228 | */ |
229 | 229 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
230 | 230 | |
231 | - $username = __( '(Missing User)', 'invoicing' ); |
|
231 | + $username = __( '(Missing User)', 'invoicing' ); |
|
232 | 232 | |
233 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
234 | - if ( $user ) { |
|
233 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
234 | + if ( $user ) { |
|
235 | 235 | |
236 | - $username = sprintf( |
|
237 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
238 | - absint( $user->ID ), |
|
239 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
240 | - ); |
|
236 | + $username = sprintf( |
|
237 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
238 | + absint( $user->ID ), |
|
239 | + ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
240 | + ); |
|
241 | 241 | |
242 | - } |
|
242 | + } |
|
243 | 243 | |
244 | - echo wp_kses_post( $username ); |
|
244 | + echo wp_kses_post( $username ); |
|
245 | 245 | } |
246 | 246 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
247 | 247 | |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * @param WPInv_Subscription $subscription |
252 | 252 | */ |
253 | 253 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
254 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
255 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
254 | + $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
255 | + echo wp_kses_post( "<span>$amount</span>" ); |
|
256 | 256 | } |
257 | 257 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
258 | 258 | |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | */ |
264 | 264 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
265 | 265 | |
266 | - printf( |
|
267 | - '<a href="%s">#%s</a>', |
|
268 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
269 | - absint( $subscription->get_id() ) |
|
270 | - ); |
|
266 | + printf( |
|
267 | + '<a href="%s">#%s</a>', |
|
268 | + esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
269 | + absint( $subscription->get_id() ) |
|
270 | + ); |
|
271 | 271 | |
272 | 272 | } |
273 | 273 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param WPInv_Subscription $subscription |
279 | 279 | */ |
280 | 280 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
281 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
281 | + echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
282 | 282 | } |
283 | 283 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
284 | 284 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param WPInv_Subscription $subscription |
289 | 289 | */ |
290 | 290 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
291 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
291 | + echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
292 | 292 | } |
293 | 293 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
294 | 294 | |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | * @param WPInv_Subscription $subscription |
299 | 299 | */ |
300 | 300 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
301 | - $max_bills = $subscription->get_bill_times(); |
|
302 | - echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
301 | + $max_bills = $subscription->get_bill_times(); |
|
302 | + echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
303 | 303 | } |
304 | 304 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
305 | 305 | /** |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | */ |
311 | 311 | function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
312 | 312 | |
313 | - if ( empty( $subscription_group ) ) { |
|
314 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
315 | - return; |
|
316 | - } |
|
313 | + if ( empty( $subscription_group ) ) { |
|
314 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
315 | + return; |
|
316 | + } |
|
317 | 317 | |
318 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
319 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
318 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
319 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
320 | 320 | |
321 | 321 | } |
322 | 322 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | */ |
329 | 329 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
330 | 330 | |
331 | - $gateway = $subscription->get_gateway(); |
|
331 | + $gateway = $subscription->get_gateway(); |
|
332 | 332 | |
333 | - if ( ! empty( $gateway ) ) { |
|
334 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
335 | - } else { |
|
336 | - echo '—'; |
|
337 | - } |
|
333 | + if ( ! empty( $gateway ) ) { |
|
334 | + echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
335 | + } else { |
|
336 | + echo '—'; |
|
337 | + } |
|
338 | 338 | |
339 | 339 | } |
340 | 340 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @param WPInv_Subscription $subscription |
346 | 346 | */ |
347 | 347 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
348 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
348 | + echo wp_kses_post( $subscription->get_status_label_html() ); |
|
349 | 349 | } |
350 | 350 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
351 | 351 | |
@@ -356,27 +356,27 @@ discard block |
||
356 | 356 | */ |
357 | 357 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
358 | 358 | |
359 | - $profile_id = $subscription->get_profile_id(); |
|
360 | - |
|
361 | - aui()->input( |
|
362 | - array( |
|
363 | - 'type' => 'text', |
|
364 | - 'id' => 'wpinv_subscription_profile_id', |
|
365 | - 'name' => 'wpinv_subscription_profile_id', |
|
366 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
367 | - 'label_type' => 'hidden', |
|
368 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
369 | - 'value' => esc_attr( $profile_id ), |
|
370 | - 'input_group_right' => '', |
|
371 | - 'no_wrap' => true, |
|
372 | - ), |
|
373 | - true |
|
374 | - ); |
|
375 | - |
|
376 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
377 | - if ( ! empty( $url ) ) { |
|
378 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
379 | - } |
|
359 | + $profile_id = $subscription->get_profile_id(); |
|
360 | + |
|
361 | + aui()->input( |
|
362 | + array( |
|
363 | + 'type' => 'text', |
|
364 | + 'id' => 'wpinv_subscription_profile_id', |
|
365 | + 'name' => 'wpinv_subscription_profile_id', |
|
366 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
367 | + 'label_type' => 'hidden', |
|
368 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
369 | + 'value' => esc_attr( $profile_id ), |
|
370 | + 'input_group_right' => '', |
|
371 | + 'no_wrap' => true, |
|
372 | + ), |
|
373 | + true |
|
374 | + ); |
|
375 | + |
|
376 | + $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
377 | + if ( ! empty( $url ) ) { |
|
378 | + echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
379 | + } |
|
380 | 380 | |
381 | 381 | } |
382 | 382 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -388,40 +388,40 @@ discard block |
||
388 | 388 | */ |
389 | 389 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
390 | 390 | |
391 | - ?> |
|
391 | + ?> |
|
392 | 392 | <div class="mt-3"> |
393 | 393 | |
394 | 394 | <?php |
395 | - aui()->select( |
|
396 | - array( |
|
397 | - 'options' => getpaid_get_subscription_statuses(), |
|
398 | - 'name' => 'subscription_status', |
|
399 | - 'id' => 'subscription_status_update_select', |
|
400 | - 'required' => true, |
|
401 | - 'no_wrap' => false, |
|
402 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
403 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
404 | - 'select2' => true, |
|
405 | - 'value' => $subscription->get_status( 'edit' ), |
|
406 | - ), |
|
407 | - true |
|
408 | - ); |
|
409 | - ?> |
|
395 | + aui()->select( |
|
396 | + array( |
|
397 | + 'options' => getpaid_get_subscription_statuses(), |
|
398 | + 'name' => 'subscription_status', |
|
399 | + 'id' => 'subscription_status_update_select', |
|
400 | + 'required' => true, |
|
401 | + 'no_wrap' => false, |
|
402 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
403 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
404 | + 'select2' => true, |
|
405 | + 'value' => $subscription->get_status( 'edit' ), |
|
406 | + ), |
|
407 | + true |
|
408 | + ); |
|
409 | + ?> |
|
410 | 410 | |
411 | 411 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
412 | 412 | |
413 | 413 | <?php |
414 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
414 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
415 | 415 | |
416 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
417 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
418 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
416 | + $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
417 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
418 | + $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
419 | 419 | |
420 | - if ( $subscription->is_active() ) { |
|
421 | - echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
422 | - } |
|
420 | + if ( $subscription->is_active() ) { |
|
421 | + echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
422 | + } |
|
423 | 423 | |
424 | - echo '</div></div>'; |
|
424 | + echo '</div></div>'; |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
@@ -432,33 +432,33 @@ discard block |
||
432 | 432 | */ |
433 | 433 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
434 | 434 | |
435 | - $columns = apply_filters( |
|
436 | - 'getpaid_subscription_related_invoices_columns', |
|
437 | - array( |
|
438 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
439 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
440 | - 'date' => __( 'Date', 'invoicing' ), |
|
441 | - 'status' => __( 'Status', 'invoicing' ), |
|
442 | - 'total' => __( 'Total', 'invoicing' ), |
|
443 | - ), |
|
444 | - $subscription |
|
445 | - ); |
|
446 | - |
|
447 | - // Prepare the invoices. |
|
448 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
449 | - $parent = $subscription->get_parent_invoice(); |
|
450 | - |
|
451 | - if ( $parent->exists() ) { |
|
452 | - $payments = array_merge( array( $parent ), $payments ); |
|
453 | - } |
|
454 | - |
|
455 | - $table_class = 'w-100 bg-white'; |
|
456 | - |
|
457 | - if ( ! is_admin() ) { |
|
458 | - $table_class = 'table table-bordered'; |
|
459 | - } |
|
460 | - |
|
461 | - ?> |
|
435 | + $columns = apply_filters( |
|
436 | + 'getpaid_subscription_related_invoices_columns', |
|
437 | + array( |
|
438 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
439 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
440 | + 'date' => __( 'Date', 'invoicing' ), |
|
441 | + 'status' => __( 'Status', 'invoicing' ), |
|
442 | + 'total' => __( 'Total', 'invoicing' ), |
|
443 | + ), |
|
444 | + $subscription |
|
445 | + ); |
|
446 | + |
|
447 | + // Prepare the invoices. |
|
448 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
449 | + $parent = $subscription->get_parent_invoice(); |
|
450 | + |
|
451 | + if ( $parent->exists() ) { |
|
452 | + $payments = array_merge( array( $parent ), $payments ); |
|
453 | + } |
|
454 | + |
|
455 | + $table_class = 'w-100 bg-white'; |
|
456 | + |
|
457 | + if ( ! is_admin() ) { |
|
458 | + $table_class = 'table table-bordered'; |
|
459 | + } |
|
460 | + |
|
461 | + ?> |
|
462 | 462 | <div class="m-0" style="overflow: auto;"> |
463 | 463 | |
464 | 464 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -466,10 +466,10 @@ discard block |
||
466 | 466 | <thead> |
467 | 467 | <tr> |
468 | 468 | <?php |
469 | - foreach ( $columns as $key => $label ) { |
|
470 | - echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
471 | - } |
|
472 | - ?> |
|
469 | + foreach ( $columns as $key => $label ) { |
|
470 | + echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
471 | + } |
|
472 | + ?> |
|
473 | 473 | </tr> |
474 | 474 | </thead> |
475 | 475 | |
@@ -485,72 +485,72 @@ discard block |
||
485 | 485 | |
486 | 486 | <?php |
487 | 487 | |
488 | - foreach ( $payments as $payment ) : |
|
488 | + foreach ( $payments as $payment ) : |
|
489 | 489 | |
490 | - // Ensure that we have an invoice. |
|
491 | - $payment = new WPInv_Invoice( $payment ); |
|
490 | + // Ensure that we have an invoice. |
|
491 | + $payment = new WPInv_Invoice( $payment ); |
|
492 | 492 | |
493 | - // Abort if the invoice is invalid... |
|
494 | - if ( ! $payment->exists() ) { |
|
495 | - continue; |
|
496 | - } |
|
493 | + // Abort if the invoice is invalid... |
|
494 | + if ( ! $payment->exists() ) { |
|
495 | + continue; |
|
496 | + } |
|
497 | 497 | |
498 | - // ... or belongs to a different subscription. |
|
499 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
500 | - continue; |
|
501 | - } |
|
498 | + // ... or belongs to a different subscription. |
|
499 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
500 | + continue; |
|
501 | + } |
|
502 | 502 | |
503 | - echo '<tr>'; |
|
503 | + echo '<tr>'; |
|
504 | 504 | |
505 | - foreach ( array_keys( $columns ) as $key ) { |
|
505 | + foreach ( array_keys( $columns ) as $key ) { |
|
506 | 506 | |
507 | - echo "<td class='p-2 text-left'>"; |
|
507 | + echo "<td class='p-2 text-left'>"; |
|
508 | 508 | |
509 | - switch ( $key ) { |
|
509 | + switch ( $key ) { |
|
510 | 510 | |
511 | - case 'total': |
|
512 | - echo '<strong>'; |
|
513 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
514 | - echo '</strong>'; |
|
515 | - break; |
|
511 | + case 'total': |
|
512 | + echo '<strong>'; |
|
513 | + wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
514 | + echo '</strong>'; |
|
515 | + break; |
|
516 | 516 | |
517 | - case 'relationship': |
|
518 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
519 | - break; |
|
517 | + case 'relationship': |
|
518 | + echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
519 | + break; |
|
520 | 520 | |
521 | - case 'date': |
|
522 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
523 | - break; |
|
521 | + case 'date': |
|
522 | + echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
523 | + break; |
|
524 | 524 | |
525 | - case 'status': |
|
526 | - $status = $payment->get_status_nicename(); |
|
527 | - if ( is_admin() ) { |
|
528 | - $status = $payment->get_status_label_html(); |
|
529 | - } |
|
525 | + case 'status': |
|
526 | + $status = $payment->get_status_nicename(); |
|
527 | + if ( is_admin() ) { |
|
528 | + $status = $payment->get_status_label_html(); |
|
529 | + } |
|
530 | 530 | |
531 | - echo wp_kses_post( $status ); |
|
532 | - break; |
|
531 | + echo wp_kses_post( $status ); |
|
532 | + break; |
|
533 | 533 | |
534 | - case 'invoice': |
|
535 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
534 | + case 'invoice': |
|
535 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
536 | 536 | |
537 | - if ( ! is_admin() ) { |
|
538 | - $link = esc_url( $payment->get_view_url() ); |
|
539 | - } |
|
537 | + if ( ! is_admin() ) { |
|
538 | + $link = esc_url( $payment->get_view_url() ); |
|
539 | + } |
|
540 | 540 | |
541 | - $invoice = esc_html( $payment->get_number() ); |
|
542 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
543 | - break; |
|
544 | - } |
|
541 | + $invoice = esc_html( $payment->get_number() ); |
|
542 | + echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
543 | + break; |
|
544 | + } |
|
545 | 545 | |
546 | - echo '</td>'; |
|
546 | + echo '</td>'; |
|
547 | 547 | |
548 | - } |
|
548 | + } |
|
549 | 549 | |
550 | - echo '</tr>'; |
|
550 | + echo '</tr>'; |
|
551 | 551 | |
552 | - endforeach; |
|
553 | - ?> |
|
552 | + endforeach; |
|
553 | + ?> |
|
554 | 554 | |
555 | 555 | </tbody> |
556 | 556 | |
@@ -568,42 +568,42 @@ discard block |
||
568 | 568 | */ |
569 | 569 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
570 | 570 | |
571 | - // Fetch the subscription group. |
|
572 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
571 | + // Fetch the subscription group. |
|
572 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
573 | 573 | |
574 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
575 | - return; |
|
576 | - } |
|
574 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
575 | + return; |
|
576 | + } |
|
577 | 577 | |
578 | - // Prepare table columns. |
|
579 | - $columns = apply_filters( |
|
580 | - 'getpaid_subscription_item_details_columns', |
|
581 | - array( |
|
582 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
583 | - 'price' => __( 'Price', 'invoicing' ), |
|
584 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
585 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
586 | - //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
587 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
588 | - ), |
|
589 | - $subscription |
|
590 | - ); |
|
578 | + // Prepare table columns. |
|
579 | + $columns = apply_filters( |
|
580 | + 'getpaid_subscription_item_details_columns', |
|
581 | + array( |
|
582 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
583 | + 'price' => __( 'Price', 'invoicing' ), |
|
584 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
585 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
586 | + //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
587 | + 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
588 | + ), |
|
589 | + $subscription |
|
590 | + ); |
|
591 | 591 | |
592 | - // Prepare the invoices. |
|
592 | + // Prepare the invoices. |
|
593 | 593 | |
594 | - $invoice = $subscription->get_parent_invoice(); |
|
594 | + $invoice = $subscription->get_parent_invoice(); |
|
595 | 595 | |
596 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
597 | - unset( $columns['tax'] ); |
|
598 | - } |
|
596 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
597 | + unset( $columns['tax'] ); |
|
598 | + } |
|
599 | 599 | |
600 | - $table_class = 'w-100 bg-white'; |
|
600 | + $table_class = 'w-100 bg-white'; |
|
601 | 601 | |
602 | - if ( ! is_admin() ) { |
|
603 | - $table_class = 'table table-bordered'; |
|
604 | - } |
|
602 | + if ( ! is_admin() ) { |
|
603 | + $table_class = 'table table-bordered'; |
|
604 | + } |
|
605 | 605 | |
606 | - ?> |
|
606 | + ?> |
|
607 | 607 | <div class="m-0" style="overflow: auto;"> |
608 | 608 | |
609 | 609 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -612,10 +612,10 @@ discard block |
||
612 | 612 | <tr> |
613 | 613 | <?php |
614 | 614 | |
615 | - foreach ( $columns as $key => $label ) { |
|
616 | - echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
617 | - } |
|
618 | - ?> |
|
615 | + foreach ( $columns as $key => $label ) { |
|
616 | + echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
617 | + } |
|
618 | + ?> |
|
619 | 619 | </tr> |
620 | 620 | </thead> |
621 | 621 | |
@@ -623,106 +623,106 @@ discard block |
||
623 | 623 | |
624 | 624 | <?php |
625 | 625 | |
626 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
626 | + foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
627 | 627 | |
628 | - echo '<tr>'; |
|
628 | + echo '<tr>'; |
|
629 | 629 | |
630 | - foreach ( array_keys( $columns ) as $key ) { |
|
630 | + foreach ( array_keys( $columns ) as $key ) { |
|
631 | 631 | |
632 | - $class = 'text-left'; |
|
632 | + $class = 'text-left'; |
|
633 | 633 | |
634 | - echo "<td class='p-2 text-left'>"; |
|
634 | + echo "<td class='p-2 text-left'>"; |
|
635 | 635 | |
636 | - switch ( $key ) { |
|
636 | + switch ( $key ) { |
|
637 | 637 | |
638 | - case 'item_name': |
|
639 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
640 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
638 | + case 'item_name': |
|
639 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
640 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
641 | 641 | |
642 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
643 | - echo esc_html( $item_name ); |
|
644 | - } else { |
|
645 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
646 | - } |
|
642 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
643 | + echo esc_html( $item_name ); |
|
644 | + } else { |
|
645 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
646 | + } |
|
647 | 647 | |
648 | - break; |
|
648 | + break; |
|
649 | 649 | |
650 | - case 'price': |
|
651 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
652 | - break; |
|
650 | + case 'price': |
|
651 | + wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
652 | + break; |
|
653 | 653 | |
654 | - case 'tax': |
|
655 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
656 | - break; |
|
654 | + case 'tax': |
|
655 | + wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
656 | + break; |
|
657 | 657 | |
658 | - case 'discount': |
|
659 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
660 | - break; |
|
658 | + case 'discount': |
|
659 | + wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
660 | + break; |
|
661 | 661 | |
662 | - case 'initial': |
|
663 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
664 | - break; |
|
662 | + case 'initial': |
|
663 | + wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
664 | + break; |
|
665 | 665 | |
666 | - case 'recurring': |
|
667 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
668 | - break; |
|
666 | + case 'recurring': |
|
667 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
668 | + break; |
|
669 | 669 | |
670 | - } |
|
670 | + } |
|
671 | 671 | |
672 | - echo '</td>'; |
|
672 | + echo '</td>'; |
|
673 | 673 | |
674 | - } |
|
674 | + } |
|
675 | 675 | |
676 | - echo '</tr>'; |
|
676 | + echo '</tr>'; |
|
677 | 677 | |
678 | - endforeach; |
|
678 | + endforeach; |
|
679 | 679 | |
680 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
680 | + foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
681 | 681 | |
682 | - echo '<tr>'; |
|
682 | + echo '<tr>'; |
|
683 | 683 | |
684 | - foreach ( array_keys( $columns ) as $key ) { |
|
684 | + foreach ( array_keys( $columns ) as $key ) { |
|
685 | 685 | |
686 | - $class = 'text-left'; |
|
686 | + $class = 'text-left'; |
|
687 | 687 | |
688 | - echo "<td class='p-2 text-left'>"; |
|
688 | + echo "<td class='p-2 text-left'>"; |
|
689 | 689 | |
690 | - switch ( $key ) { |
|
690 | + switch ( $key ) { |
|
691 | 691 | |
692 | - case 'item_name': |
|
693 | - echo esc_html( $subscription_group_fee['name'] ); |
|
694 | - break; |
|
692 | + case 'item_name': |
|
693 | + echo esc_html( $subscription_group_fee['name'] ); |
|
694 | + break; |
|
695 | 695 | |
696 | - case 'price': |
|
697 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
698 | - break; |
|
696 | + case 'price': |
|
697 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
698 | + break; |
|
699 | 699 | |
700 | - case 'tax': |
|
701 | - echo '—'; |
|
702 | - break; |
|
700 | + case 'tax': |
|
701 | + echo '—'; |
|
702 | + break; |
|
703 | 703 | |
704 | - case 'discount': |
|
705 | - echo '—'; |
|
706 | - break; |
|
704 | + case 'discount': |
|
705 | + echo '—'; |
|
706 | + break; |
|
707 | 707 | |
708 | - case 'initial': |
|
709 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
710 | - break; |
|
708 | + case 'initial': |
|
709 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
710 | + break; |
|
711 | 711 | |
712 | - case 'recurring': |
|
713 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
714 | - break; |
|
712 | + case 'recurring': |
|
713 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
714 | + break; |
|
715 | 715 | |
716 | - } |
|
716 | + } |
|
717 | 717 | |
718 | - echo '</td>'; |
|
718 | + echo '</td>'; |
|
719 | 719 | |
720 | - } |
|
720 | + } |
|
721 | 721 | |
722 | - echo '</tr>'; |
|
722 | + echo '</tr>'; |
|
723 | 723 | |
724 | - endforeach; |
|
725 | - ?> |
|
724 | + endforeach; |
|
725 | + ?> |
|
726 | 726 | |
727 | 727 | </tbody> |
728 | 728 | |
@@ -741,38 +741,38 @@ discard block |
||
741 | 741 | */ |
742 | 742 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
743 | 743 | |
744 | - // Fetch the subscription groups. |
|
745 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
746 | - |
|
747 | - if ( empty( $subscription_groups ) ) { |
|
748 | - return; |
|
749 | - } |
|
750 | - |
|
751 | - // Prepare table columns. |
|
752 | - $columns = apply_filters( |
|
753 | - 'getpaid_subscription_related_subscriptions_columns', |
|
754 | - array( |
|
755 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
756 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
757 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
758 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
759 | - 'item' => __( 'Items', 'invoicing' ), |
|
760 | - 'status' => __( 'Status', 'invoicing' ), |
|
761 | - ), |
|
762 | - $subscription |
|
763 | - ); |
|
764 | - |
|
765 | - if ( $subscription->get_status() == 'pending' ) { |
|
766 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
767 | - } |
|
768 | - |
|
769 | - $table_class = 'w-100 bg-white'; |
|
770 | - |
|
771 | - if ( ! is_admin() ) { |
|
772 | - $table_class = 'table table-bordered'; |
|
773 | - } |
|
774 | - |
|
775 | - ?> |
|
744 | + // Fetch the subscription groups. |
|
745 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
746 | + |
|
747 | + if ( empty( $subscription_groups ) ) { |
|
748 | + return; |
|
749 | + } |
|
750 | + |
|
751 | + // Prepare table columns. |
|
752 | + $columns = apply_filters( |
|
753 | + 'getpaid_subscription_related_subscriptions_columns', |
|
754 | + array( |
|
755 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
756 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
757 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
758 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
759 | + 'item' => __( 'Items', 'invoicing' ), |
|
760 | + 'status' => __( 'Status', 'invoicing' ), |
|
761 | + ), |
|
762 | + $subscription |
|
763 | + ); |
|
764 | + |
|
765 | + if ( $subscription->get_status() == 'pending' ) { |
|
766 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
767 | + } |
|
768 | + |
|
769 | + $table_class = 'w-100 bg-white'; |
|
770 | + |
|
771 | + if ( ! is_admin() ) { |
|
772 | + $table_class = 'table table-bordered'; |
|
773 | + } |
|
774 | + |
|
775 | + ?> |
|
776 | 776 | <div class="m-0" style="overflow: auto;"> |
777 | 777 | |
778 | 778 | <table class="<?php echo esc_attr( $table_class ); ?>"> |
@@ -781,10 +781,10 @@ discard block |
||
781 | 781 | <tr> |
782 | 782 | <?php |
783 | 783 | |
784 | - foreach ( $columns as $key => $label ) { |
|
785 | - echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
786 | - } |
|
787 | - ?> |
|
784 | + foreach ( $columns as $key => $label ) { |
|
785 | + echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
786 | + } |
|
787 | + ?> |
|
788 | 788 | </tr> |
789 | 789 | </thead> |
790 | 790 | |
@@ -792,74 +792,74 @@ discard block |
||
792 | 792 | |
793 | 793 | <?php |
794 | 794 | |
795 | - foreach ( $subscription_groups as $subscription_group ) : |
|
795 | + foreach ( $subscription_groups as $subscription_group ) : |
|
796 | 796 | |
797 | - // Do not list current subscription. |
|
798 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
799 | - continue; |
|
800 | - } |
|
797 | + // Do not list current subscription. |
|
798 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
799 | + continue; |
|
800 | + } |
|
801 | 801 | |
802 | - // Ensure the subscription exists. |
|
803 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
802 | + // Ensure the subscription exists. |
|
803 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
804 | 804 | |
805 | - if ( ! $_suscription->exists() ) { |
|
806 | - continue; |
|
807 | - } |
|
805 | + if ( ! $_suscription->exists() ) { |
|
806 | + continue; |
|
807 | + } |
|
808 | 808 | |
809 | - echo '<tr>'; |
|
809 | + echo '<tr>'; |
|
810 | 810 | |
811 | - foreach ( array_keys( $columns ) as $key ) { |
|
811 | + foreach ( array_keys( $columns ) as $key ) { |
|
812 | 812 | |
813 | - $class = 'text-left'; |
|
813 | + $class = 'text-left'; |
|
814 | 814 | |
815 | - echo "<td class='p-2 text-left'>"; |
|
815 | + echo "<td class='p-2 text-left'>"; |
|
816 | 816 | |
817 | - switch ( $key ) { |
|
817 | + switch ( $key ) { |
|
818 | 818 | |
819 | - case 'status': |
|
820 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
821 | - break; |
|
819 | + case 'status': |
|
820 | + echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
821 | + break; |
|
822 | 822 | |
823 | - case 'item': |
|
824 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
825 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
826 | - break; |
|
823 | + case 'item': |
|
824 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
825 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
826 | + break; |
|
827 | 827 | |
828 | - case 'renewals': |
|
829 | - $max_bills = $_suscription->get_bill_times(); |
|
830 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
831 | - break; |
|
828 | + case 'renewals': |
|
829 | + $max_bills = $_suscription->get_bill_times(); |
|
830 | + echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
831 | + break; |
|
832 | 832 | |
833 | - case 'renewal_date': |
|
834 | - echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
835 | - break; |
|
833 | + case 'renewal_date': |
|
834 | + echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
835 | + break; |
|
836 | 836 | |
837 | - case 'start_date': |
|
838 | - echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
839 | - break; |
|
837 | + case 'start_date': |
|
838 | + echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
839 | + break; |
|
840 | 840 | |
841 | - case 'subscription': |
|
842 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
843 | - printf( |
|
841 | + case 'subscription': |
|
842 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
843 | + printf( |
|
844 | 844 | '%1$s#%2$s%3$s', |
845 | 845 | '<a href="' . esc_url( $url ) . '">', |
846 | 846 | '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
847 | - '</a>' |
|
847 | + '</a>' |
|
848 | 848 | ); |
849 | 849 | |
850 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
851 | - break; |
|
850 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
851 | + break; |
|
852 | 852 | |
853 | - } |
|
853 | + } |
|
854 | 854 | |
855 | - echo '</td>'; |
|
855 | + echo '</td>'; |
|
856 | 856 | |
857 | - } |
|
857 | + } |
|
858 | 858 | |
859 | - echo '</tr>'; |
|
859 | + echo '</tr>'; |
|
860 | 860 | |
861 | - endforeach; |
|
862 | - ?> |
|
861 | + endforeach; |
|
862 | + ?> |
|
863 | 863 | |
864 | 864 | </tbody> |
865 | 865 |
@@ -508,39 +508,39 @@ discard block |
||
508 | 508 | |
509 | 509 | switch ( $key ) { |
510 | 510 | |
511 | - case 'total': |
|
512 | - echo '<strong>'; |
|
513 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
514 | - echo '</strong>'; |
|
515 | - break; |
|
516 | - |
|
517 | - case 'relationship': |
|
518 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
519 | - break; |
|
520 | - |
|
521 | - case 'date': |
|
522 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
523 | - break; |
|
524 | - |
|
525 | - case 'status': |
|
526 | - $status = $payment->get_status_nicename(); |
|
527 | - if ( is_admin() ) { |
|
528 | - $status = $payment->get_status_label_html(); |
|
529 | - } |
|
530 | - |
|
531 | - echo wp_kses_post( $status ); |
|
532 | - break; |
|
533 | - |
|
534 | - case 'invoice': |
|
535 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
536 | - |
|
537 | - if ( ! is_admin() ) { |
|
538 | - $link = esc_url( $payment->get_view_url() ); |
|
539 | - } |
|
540 | - |
|
541 | - $invoice = esc_html( $payment->get_number() ); |
|
542 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
543 | - break; |
|
511 | + case 'total': |
|
512 | + echo '<strong>'; |
|
513 | + wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
514 | + echo '</strong>'; |
|
515 | + break; |
|
516 | + |
|
517 | + case 'relationship': |
|
518 | + echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
519 | + break; |
|
520 | + |
|
521 | + case 'date': |
|
522 | + echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
523 | + break; |
|
524 | + |
|
525 | + case 'status': |
|
526 | + $status = $payment->get_status_nicename(); |
|
527 | + if ( is_admin() ) { |
|
528 | + $status = $payment->get_status_label_html(); |
|
529 | + } |
|
530 | + |
|
531 | + echo wp_kses_post( $status ); |
|
532 | + break; |
|
533 | + |
|
534 | + case 'invoice': |
|
535 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
536 | + |
|
537 | + if ( ! is_admin() ) { |
|
538 | + $link = esc_url( $payment->get_view_url() ); |
|
539 | + } |
|
540 | + |
|
541 | + $invoice = esc_html( $payment->get_number() ); |
|
542 | + echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
543 | + break; |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | echo '</td>'; |
@@ -635,37 +635,37 @@ discard block |
||
635 | 635 | |
636 | 636 | switch ( $key ) { |
637 | 637 | |
638 | - case 'item_name': |
|
639 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
640 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
638 | + case 'item_name': |
|
639 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
640 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
641 | 641 | |
642 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
643 | - echo esc_html( $item_name ); |
|
644 | - } else { |
|
645 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
646 | - } |
|
642 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
643 | + echo esc_html( $item_name ); |
|
644 | + } else { |
|
645 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
646 | + } |
|
647 | 647 | |
648 | - break; |
|
648 | + break; |
|
649 | 649 | |
650 | - case 'price': |
|
651 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
652 | - break; |
|
650 | + case 'price': |
|
651 | + wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
652 | + break; |
|
653 | 653 | |
654 | - case 'tax': |
|
655 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
656 | - break; |
|
654 | + case 'tax': |
|
655 | + wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
656 | + break; |
|
657 | 657 | |
658 | - case 'discount': |
|
659 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
660 | - break; |
|
658 | + case 'discount': |
|
659 | + wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
660 | + break; |
|
661 | 661 | |
662 | - case 'initial': |
|
663 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
664 | - break; |
|
662 | + case 'initial': |
|
663 | + wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
664 | + break; |
|
665 | 665 | |
666 | - case 'recurring': |
|
667 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
668 | - break; |
|
666 | + case 'recurring': |
|
667 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
668 | + break; |
|
669 | 669 | |
670 | 670 | } |
671 | 671 | |
@@ -689,29 +689,29 @@ discard block |
||
689 | 689 | |
690 | 690 | switch ( $key ) { |
691 | 691 | |
692 | - case 'item_name': |
|
693 | - echo esc_html( $subscription_group_fee['name'] ); |
|
694 | - break; |
|
692 | + case 'item_name': |
|
693 | + echo esc_html( $subscription_group_fee['name'] ); |
|
694 | + break; |
|
695 | 695 | |
696 | - case 'price': |
|
697 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
698 | - break; |
|
696 | + case 'price': |
|
697 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
698 | + break; |
|
699 | 699 | |
700 | - case 'tax': |
|
701 | - echo '—'; |
|
702 | - break; |
|
700 | + case 'tax': |
|
701 | + echo '—'; |
|
702 | + break; |
|
703 | 703 | |
704 | - case 'discount': |
|
705 | - echo '—'; |
|
706 | - break; |
|
704 | + case 'discount': |
|
705 | + echo '—'; |
|
706 | + break; |
|
707 | 707 | |
708 | - case 'initial': |
|
709 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
710 | - break; |
|
708 | + case 'initial': |
|
709 | + wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
710 | + break; |
|
711 | 711 | |
712 | - case 'recurring': |
|
713 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
714 | - break; |
|
712 | + case 'recurring': |
|
713 | + echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
714 | + break; |
|
715 | 715 | |
716 | 716 | } |
717 | 717 | |
@@ -816,39 +816,39 @@ discard block |
||
816 | 816 | |
817 | 817 | switch ( $key ) { |
818 | 818 | |
819 | - case 'status': |
|
820 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
821 | - break; |
|
822 | - |
|
823 | - case 'item': |
|
824 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
825 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
826 | - break; |
|
827 | - |
|
828 | - case 'renewals': |
|
829 | - $max_bills = $_suscription->get_bill_times(); |
|
830 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
831 | - break; |
|
832 | - |
|
833 | - case 'renewal_date': |
|
834 | - echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
835 | - break; |
|
836 | - |
|
837 | - case 'start_date': |
|
838 | - echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
839 | - break; |
|
840 | - |
|
841 | - case 'subscription': |
|
842 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
843 | - printf( |
|
844 | - '%1$s#%2$s%3$s', |
|
845 | - '<a href="' . esc_url( $url ) . '">', |
|
846 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
847 | - '</a>' |
|
848 | - ); |
|
849 | - |
|
850 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
851 | - break; |
|
819 | + case 'status': |
|
820 | + echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
821 | + break; |
|
822 | + |
|
823 | + case 'item': |
|
824 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
825 | + echo wp_kses_post( implode( ' | ', $markup ) ); |
|
826 | + break; |
|
827 | + |
|
828 | + case 'renewals': |
|
829 | + $max_bills = $_suscription->get_bill_times(); |
|
830 | + echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
831 | + break; |
|
832 | + |
|
833 | + case 'renewal_date': |
|
834 | + echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
835 | + break; |
|
836 | + |
|
837 | + case 'start_date': |
|
838 | + echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
839 | + break; |
|
840 | + |
|
841 | + case 'subscription': |
|
842 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
843 | + printf( |
|
844 | + '%1$s#%2$s%3$s', |
|
845 | + '<a href="' . esc_url( $url ) . '">', |
|
846 | + '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
847 | + '</a>' |
|
848 | + ); |
|
849 | + |
|
850 | + echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
851 | + break; |
|
852 | 852 | |
853 | 853 | } |
854 | 854 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains functions that display the subscriptions admin page. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Render the Subscriptions page |
@@ -17,23 +17,23 @@ discard block |
||
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
21 | 21 | <div class="bsui"> |
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | 25 | // Verify user permissions. |
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
27 | 27 | |
28 | 28 | aui()->alert( |
29 | 29 | array( |
30 | 30 | 'type' => 'danger', |
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
32 | 32 | ), |
33 | 33 | true |
34 | 34 | ); |
35 | 35 | |
36 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
36 | + } elseif (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
37 | 37 | |
38 | 38 | // Display a single subscription. |
39 | 39 | wpinv_recurring_subscription_details(); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | <?php $subscribers_table->views(); ?> |
68 | 68 | <form id="subscribers-filter" class="bsui" method="get"> |
69 | 69 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
70 | - <?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?> |
|
70 | + <?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?> |
|
71 | 71 | <?php $subscribers_table->display(); ?> |
72 | 72 | </form> |
73 | 73 | <?php |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | function wpinv_recurring_subscription_details() { |
84 | 84 | |
85 | 85 | // Fetch the subscription. |
86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
87 | - if ( ! $sub->exists() ) { |
|
86 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
87 | + if (!$sub->exists()) { |
|
88 | 88 | |
89 | 89 | aui()->alert( |
90 | 90 | array( |
91 | 91 | 'type' => 'danger', |
92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
92 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
93 | 93 | ), |
94 | 94 | true |
95 | 95 | ); |
@@ -98,32 +98,32 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | // Use metaboxes to display the subscription details. |
101 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
102 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
101 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
102 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
103 | 103 | |
104 | 104 | $subscription_id = $sub->get_id(); |
105 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
106 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
105 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
106 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
107 | 107 | |
108 | - if ( 1 < count( $subscription_groups ) ) { |
|
109 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
108 | + if (1 < count($subscription_groups)) { |
|
109 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
110 | 110 | } |
111 | 111 | |
112 | - if ( ! empty( $subscription_group ) ) { |
|
113 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
112 | + if (!empty($subscription_group)) { |
|
113 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
114 | 114 | } |
115 | 115 | |
116 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
116 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
117 | 117 | |
118 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
118 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
119 | 119 | |
120 | 120 | ?> |
121 | 121 | |
122 | - <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
|
122 | + <form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id()))); ?>"> |
|
123 | 123 | |
124 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
125 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
126 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
124 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
125 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
126 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
127 | 127 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
128 | 128 | <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
129 | 129 | |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
132 | 132 | |
133 | 133 | <div id="postbox-container-1" class="postbox-container"> |
134 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
134 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
135 | 135 | </div> |
136 | 136 | |
137 | 137 | <div id="postbox-container-2" class="postbox-container"> |
138 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
139 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
138 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
139 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
140 | 140 | </div> |
141 | 141 | |
142 | 142 | </div> |
@@ -155,43 +155,43 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @param WPInv_Subscription $sub |
157 | 157 | */ |
158 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
158 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
159 | 159 | |
160 | 160 | // Subscription items. |
161 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
162 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
161 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
162 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
163 | 163 | |
164 | 164 | // Prepare subscription detail columns. |
165 | 165 | $fields = apply_filters( |
166 | 166 | 'getpaid_subscription_admin_page_fields', |
167 | 167 | array( |
168 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
169 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
170 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
171 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
172 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
173 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
174 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
177 | - 'status' => __( 'Status', 'invoicing' ), |
|
168 | + 'subscription' => __('Subscription', 'invoicing'), |
|
169 | + 'customer' => __('Customer', 'invoicing'), |
|
170 | + 'amount' => __('Amount', 'invoicing'), |
|
171 | + 'start_date' => __('Start Date', 'invoicing'), |
|
172 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
173 | + 'renewals' => __('Payments', 'invoicing'), |
|
174 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
175 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
176 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
177 | + 'status' => __('Status', 'invoicing'), |
|
178 | 178 | ) |
179 | 179 | ); |
180 | 180 | |
181 | - if ( ! $sub->is_active() ) { |
|
181 | + if (!$sub->is_active()) { |
|
182 | 182 | |
183 | - if ( isset( $fields['renews_on'] ) ) { |
|
184 | - unset( $fields['renews_on'] ); |
|
183 | + if (isset($fields['renews_on'])) { |
|
184 | + unset($fields['renews_on']); |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( isset( $fields['gateway'] ) ) { |
|
188 | - unset( $fields['gateway'] ); |
|
187 | + if (isset($fields['gateway'])) { |
|
188 | + unset($fields['gateway']); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
192 | 192 | $profile_id = $sub->get_profile_id(); |
193 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
194 | - unset( $fields['profile_id'] ); |
|
193 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
194 | + unset($fields['profile_id']); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | ?> |
@@ -199,16 +199,16 @@ discard block |
||
199 | 199 | <table class="table table-borderless" style="font-size: 14px;"> |
200 | 200 | <tbody> |
201 | 201 | |
202 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
202 | + <?php foreach ($fields as $key => $label) : ?> |
|
203 | 203 | |
204 | - <tr class="getpaid-subscription-meta-<?php echo esc_attr( $key ); ?>"> |
|
204 | + <tr class="getpaid-subscription-meta-<?php echo esc_attr($key); ?>"> |
|
205 | 205 | |
206 | 206 | <th class="w-25" style="font-weight: 500;"> |
207 | - <?php echo esc_html( $label ); ?> |
|
207 | + <?php echo esc_html($label); ?> |
|
208 | 208 | </th> |
209 | 209 | |
210 | 210 | <td class="w-75 text-muted"> |
211 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?> |
|
211 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?> |
|
212 | 212 | </td> |
213 | 213 | |
214 | 214 | </tr> |
@@ -226,135 +226,135 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @param WPInv_Subscription $subscription |
228 | 228 | */ |
229 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
229 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
230 | 230 | |
231 | - $username = __( '(Missing User)', 'invoicing' ); |
|
231 | + $username = __('(Missing User)', 'invoicing'); |
|
232 | 232 | |
233 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
234 | - if ( $user ) { |
|
233 | + $user = get_userdata($subscription->get_customer_id()); |
|
234 | + if ($user) { |
|
235 | 235 | |
236 | 236 | $username = sprintf( |
237 | 237 | '<a href="user-edit.php?user_id=%s">%s</a>', |
238 | - absint( $user->ID ), |
|
239 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
238 | + absint($user->ID), |
|
239 | + !empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email) |
|
240 | 240 | ); |
241 | 241 | |
242 | 242 | } |
243 | 243 | |
244 | - echo wp_kses_post( $username ); |
|
244 | + echo wp_kses_post($username); |
|
245 | 245 | } |
246 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
246 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
247 | 247 | |
248 | 248 | /** |
249 | 249 | * Displays the subscription amount. |
250 | 250 | * |
251 | 251 | * @param WPInv_Subscription $subscription |
252 | 252 | */ |
253 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
254 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
255 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
253 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
254 | + $amount = getpaid_get_formatted_subscription_amount($subscription); |
|
255 | + echo wp_kses_post("<span>$amount</span>"); |
|
256 | 256 | } |
257 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
257 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Displays the subscription id. |
261 | 261 | * |
262 | 262 | * @param WPInv_Subscription $subscription |
263 | 263 | */ |
264 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
264 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
265 | 265 | |
266 | 266 | printf( |
267 | 267 | '<a href="%s">#%s</a>', |
268 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
269 | - absint( $subscription->get_id() ) |
|
268 | + esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))), |
|
269 | + absint($subscription->get_id()) |
|
270 | 270 | ); |
271 | 271 | |
272 | 272 | } |
273 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
273 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
274 | 274 | |
275 | 275 | /** |
276 | 276 | * Displays the subscription renewal date. |
277 | 277 | * |
278 | 278 | * @param WPInv_Subscription $subscription |
279 | 279 | */ |
280 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
281 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
280 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
281 | + echo esc_html(getpaid_format_date_value($subscription->get_date_created())); |
|
282 | 282 | } |
283 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
283 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
284 | 284 | |
285 | 285 | /** |
286 | 286 | * Displays the subscription renewal date. |
287 | 287 | * |
288 | 288 | * @param WPInv_Subscription $subscription |
289 | 289 | */ |
290 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
291 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
290 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
291 | + echo esc_html(getpaid_format_date_value($subscription->get_expiration())); |
|
292 | 292 | } |
293 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
293 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
294 | 294 | |
295 | 295 | /** |
296 | 296 | * Displays the subscription renewal count. |
297 | 297 | * |
298 | 298 | * @param WPInv_Subscription $subscription |
299 | 299 | */ |
300 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
300 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
301 | 301 | $max_bills = $subscription->get_bill_times(); |
302 | - echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
302 | + echo ((int) $subscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
303 | 303 | } |
304 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
304 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
305 | 305 | /** |
306 | 306 | * Displays the subscription item. |
307 | 307 | * |
308 | 308 | * @param WPInv_Subscription $subscription |
309 | 309 | * @param false|array $subscription_group |
310 | 310 | */ |
311 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
311 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
312 | 312 | |
313 | - if ( empty( $subscription_group ) ) { |
|
314 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
313 | + if (empty($subscription_group)) { |
|
314 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id())); |
|
315 | 315 | return; |
316 | 316 | } |
317 | 317 | |
318 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
319 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
318 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
319 | + echo wp_kses_post(implode(' | ', $markup)); |
|
320 | 320 | |
321 | 321 | } |
322 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
322 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
323 | 323 | |
324 | 324 | /** |
325 | 325 | * Displays the subscription gateway. |
326 | 326 | * |
327 | 327 | * @param WPInv_Subscription $subscription |
328 | 328 | */ |
329 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
329 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
330 | 330 | |
331 | 331 | $gateway = $subscription->get_gateway(); |
332 | 332 | |
333 | - if ( ! empty( $gateway ) ) { |
|
334 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
333 | + if (!empty($gateway)) { |
|
334 | + echo esc_html(wpinv_get_gateway_admin_label($gateway)); |
|
335 | 335 | } else { |
336 | 336 | echo '—'; |
337 | 337 | } |
338 | 338 | |
339 | 339 | } |
340 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
340 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
341 | 341 | |
342 | 342 | /** |
343 | 343 | * Displays the subscription status. |
344 | 344 | * |
345 | 345 | * @param WPInv_Subscription $subscription |
346 | 346 | */ |
347 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
348 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
347 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
348 | + echo wp_kses_post($subscription->get_status_label_html()); |
|
349 | 349 | } |
350 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
350 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
351 | 351 | |
352 | 352 | /** |
353 | 353 | * Displays the subscription profile id. |
354 | 354 | * |
355 | 355 | * @param WPInv_Subscription $subscription |
356 | 356 | */ |
357 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
357 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
358 | 358 | |
359 | 359 | $profile_id = $subscription->get_profile_id(); |
360 | 360 | |
@@ -363,30 +363,30 @@ discard block |
||
363 | 363 | 'type' => 'text', |
364 | 364 | 'id' => 'wpinv_subscription_profile_id', |
365 | 365 | 'name' => 'wpinv_subscription_profile_id', |
366 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
366 | + 'label' => __('Profile Id', 'invoicing'), |
|
367 | 367 | 'label_type' => 'hidden', |
368 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
369 | - 'value' => esc_attr( $profile_id ), |
|
368 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
369 | + 'value' => esc_attr($profile_id), |
|
370 | 370 | 'input_group_right' => '', |
371 | 371 | 'no_wrap' => true, |
372 | 372 | ), |
373 | 373 | true |
374 | 374 | ); |
375 | 375 | |
376 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
377 | - if ( ! empty( $url ) ) { |
|
378 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
376 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
377 | + if (!empty($url)) { |
|
378 | + echo ' <a href="' . esc_url_raw($url) . '" title="' . esc_attr__('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | } |
382 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
382 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
383 | 383 | |
384 | 384 | /** |
385 | 385 | * Displays the subscriptions update metabox. |
386 | 386 | * |
387 | 387 | * @param WPInv_Subscription $subscription |
388 | 388 | */ |
389 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
389 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
390 | 390 | |
391 | 391 | ?> |
392 | 392 | <div class="mt-3"> |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | 'id' => 'subscription_status_update_select', |
400 | 400 | 'required' => true, |
401 | 401 | 'no_wrap' => false, |
402 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
403 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
402 | + 'label' => __('Subscription Status', 'invoicing'), |
|
403 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
404 | 404 | 'select2' => true, |
405 | - 'value' => $subscription->get_status( 'edit' ), |
|
405 | + 'value' => $subscription->get_status('edit'), |
|
406 | 406 | ), |
407 | 407 | true |
408 | 408 | ); |
@@ -411,14 +411,14 @@ discard block |
||
411 | 411 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
412 | 412 | |
413 | 413 | <?php |
414 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
414 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
415 | 415 | |
416 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
417 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
418 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
416 | + $url = wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'); |
|
417 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
418 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
419 | 419 | |
420 | - if ( $subscription->is_active() ) { |
|
421 | - echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
420 | + if ($subscription->is_active()) { |
|
421 | + echo "<a href='" . esc_url($url) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr($title) . "\")'>" . esc_html($anchor) . "</a>"; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | echo '</div></div>'; |
@@ -430,44 +430,44 @@ discard block |
||
430 | 430 | * @param WPInv_Subscription $subscription |
431 | 431 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
432 | 432 | */ |
433 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
433 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
434 | 434 | |
435 | 435 | $columns = apply_filters( |
436 | 436 | 'getpaid_subscription_related_invoices_columns', |
437 | 437 | array( |
438 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
439 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
440 | - 'date' => __( 'Date', 'invoicing' ), |
|
441 | - 'status' => __( 'Status', 'invoicing' ), |
|
442 | - 'total' => __( 'Total', 'invoicing' ), |
|
438 | + 'invoice' => __('Invoice', 'invoicing'), |
|
439 | + 'relationship' => __('Relationship', 'invoicing'), |
|
440 | + 'date' => __('Date', 'invoicing'), |
|
441 | + 'status' => __('Status', 'invoicing'), |
|
442 | + 'total' => __('Total', 'invoicing'), |
|
443 | 443 | ), |
444 | 444 | $subscription |
445 | 445 | ); |
446 | 446 | |
447 | 447 | // Prepare the invoices. |
448 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
448 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
449 | 449 | $parent = $subscription->get_parent_invoice(); |
450 | 450 | |
451 | - if ( $parent->exists() ) { |
|
452 | - $payments = array_merge( array( $parent ), $payments ); |
|
451 | + if ($parent->exists()) { |
|
452 | + $payments = array_merge(array($parent), $payments); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | $table_class = 'w-100 bg-white'; |
456 | 456 | |
457 | - if ( ! is_admin() ) { |
|
457 | + if (!is_admin()) { |
|
458 | 458 | $table_class = 'table table-bordered'; |
459 | 459 | } |
460 | 460 | |
461 | 461 | ?> |
462 | 462 | <div class="m-0" style="overflow: auto;"> |
463 | 463 | |
464 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
464 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
465 | 465 | |
466 | 466 | <thead> |
467 | 467 | <tr> |
468 | 468 | <?php |
469 | - foreach ( $columns as $key => $label ) { |
|
470 | - echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
469 | + foreach ($columns as $key => $label) { |
|
470 | + echo "<th class='subscription-invoice-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
471 | 471 | } |
472 | 472 | ?> |
473 | 473 | </tr> |
@@ -475,71 +475,71 @@ discard block |
||
475 | 475 | |
476 | 476 | <tbody> |
477 | 477 | |
478 | - <?php if ( empty( $payments ) ) : ?> |
|
478 | + <?php if (empty($payments)) : ?> |
|
479 | 479 | <tr> |
480 | - <td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted"> |
|
481 | - <?php esc_html_e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
480 | + <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
|
481 | + <?php esc_html_e('This subscription has no invoices.', 'invoicing'); ?> |
|
482 | 482 | </td> |
483 | 483 | </tr> |
484 | 484 | <?php endif; ?> |
485 | 485 | |
486 | 486 | <?php |
487 | 487 | |
488 | - foreach ( $payments as $payment ) : |
|
488 | + foreach ($payments as $payment) : |
|
489 | 489 | |
490 | 490 | // Ensure that we have an invoice. |
491 | - $payment = new WPInv_Invoice( $payment ); |
|
491 | + $payment = new WPInv_Invoice($payment); |
|
492 | 492 | |
493 | 493 | // Abort if the invoice is invalid... |
494 | - if ( ! $payment->exists() ) { |
|
494 | + if (!$payment->exists()) { |
|
495 | 495 | continue; |
496 | 496 | } |
497 | 497 | |
498 | 498 | // ... or belongs to a different subscription. |
499 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
499 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
500 | 500 | continue; |
501 | 501 | } |
502 | 502 | |
503 | 503 | echo '<tr>'; |
504 | 504 | |
505 | - foreach ( array_keys( $columns ) as $key ) { |
|
505 | + foreach (array_keys($columns) as $key) { |
|
506 | 506 | |
507 | 507 | echo "<td class='p-2 text-left'>"; |
508 | 508 | |
509 | - switch ( $key ) { |
|
509 | + switch ($key) { |
|
510 | 510 | |
511 | 511 | case 'total': |
512 | 512 | echo '<strong>'; |
513 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
513 | + wpinv_the_price($payment->get_total(), $payment->get_currency()); |
|
514 | 514 | echo '</strong>'; |
515 | 515 | break; |
516 | 516 | |
517 | 517 | case 'relationship': |
518 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
518 | + echo $payment->is_renewal() ? esc_html__('Renewal Invoice', 'invoicing') : esc_html__('Initial Invoice', 'invoicing'); |
|
519 | 519 | break; |
520 | 520 | |
521 | 521 | case 'date': |
522 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
522 | + echo esc_html(getpaid_format_date_value($payment->get_date_created())); |
|
523 | 523 | break; |
524 | 524 | |
525 | 525 | case 'status': |
526 | 526 | $status = $payment->get_status_nicename(); |
527 | - if ( is_admin() ) { |
|
527 | + if (is_admin()) { |
|
528 | 528 | $status = $payment->get_status_label_html(); |
529 | 529 | } |
530 | 530 | |
531 | - echo wp_kses_post( $status ); |
|
531 | + echo wp_kses_post($status); |
|
532 | 532 | break; |
533 | 533 | |
534 | 534 | case 'invoice': |
535 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
535 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
536 | 536 | |
537 | - if ( ! is_admin() ) { |
|
538 | - $link = esc_url( $payment->get_view_url() ); |
|
537 | + if (!is_admin()) { |
|
538 | + $link = esc_url($payment->get_view_url()); |
|
539 | 539 | } |
540 | 540 | |
541 | - $invoice = esc_html( $payment->get_number() ); |
|
542 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
541 | + $invoice = esc_html($payment->get_number()); |
|
542 | + echo wp_kses_post("<a href='$link'>$invoice</a>"); |
|
543 | 543 | break; |
544 | 544 | } |
545 | 545 | |
@@ -566,12 +566,12 @@ discard block |
||
566 | 566 | * |
567 | 567 | * @param WPInv_Subscription $subscription |
568 | 568 | */ |
569 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
569 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
570 | 570 | |
571 | 571 | // Fetch the subscription group. |
572 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
572 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
573 | 573 | |
574 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
574 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
575 | 575 | return; |
576 | 576 | } |
577 | 577 | |
@@ -579,12 +579,12 @@ discard block |
||
579 | 579 | $columns = apply_filters( |
580 | 580 | 'getpaid_subscription_item_details_columns', |
581 | 581 | array( |
582 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
583 | - 'price' => __( 'Price', 'invoicing' ), |
|
584 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
585 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
582 | + 'item_name' => __('Item', 'invoicing'), |
|
583 | + 'price' => __('Price', 'invoicing'), |
|
584 | + 'tax' => __('Tax', 'invoicing'), |
|
585 | + 'discount' => __('Discount', 'invoicing'), |
|
586 | 586 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
587 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
587 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
588 | 588 | ), |
589 | 589 | $subscription |
590 | 590 | ); |
@@ -593,27 +593,27 @@ discard block |
||
593 | 593 | |
594 | 594 | $invoice = $subscription->get_parent_invoice(); |
595 | 595 | |
596 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
597 | - unset( $columns['tax'] ); |
|
596 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
597 | + unset($columns['tax']); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | $table_class = 'w-100 bg-white'; |
601 | 601 | |
602 | - if ( ! is_admin() ) { |
|
602 | + if (!is_admin()) { |
|
603 | 603 | $table_class = 'table table-bordered'; |
604 | 604 | } |
605 | 605 | |
606 | 606 | ?> |
607 | 607 | <div class="m-0" style="overflow: auto;"> |
608 | 608 | |
609 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
609 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
610 | 610 | |
611 | 611 | <thead> |
612 | 612 | <tr> |
613 | 613 | <?php |
614 | 614 | |
615 | - foreach ( $columns as $key => $label ) { |
|
616 | - echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
615 | + foreach ($columns as $key => $label) { |
|
616 | + echo "<th class='subscription-item-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
617 | 617 | } |
618 | 618 | ?> |
619 | 619 | </tr> |
@@ -623,48 +623,48 @@ discard block |
||
623 | 623 | |
624 | 624 | <?php |
625 | 625 | |
626 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
626 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
627 | 627 | |
628 | 628 | echo '<tr>'; |
629 | 629 | |
630 | - foreach ( array_keys( $columns ) as $key ) { |
|
630 | + foreach (array_keys($columns) as $key) { |
|
631 | 631 | |
632 | 632 | $class = 'text-left'; |
633 | 633 | |
634 | 634 | echo "<td class='p-2 text-left'>"; |
635 | 635 | |
636 | - switch ( $key ) { |
|
636 | + switch ($key) { |
|
637 | 637 | |
638 | 638 | case 'item_name': |
639 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
640 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
639 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
640 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
641 | 641 | |
642 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
643 | - echo esc_html( $item_name ); |
|
642 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
643 | + echo esc_html($item_name); |
|
644 | 644 | } else { |
645 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
645 | + printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | break; |
649 | 649 | |
650 | 650 | case 'price': |
651 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
651 | + wpinv_the_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
652 | 652 | break; |
653 | 653 | |
654 | 654 | case 'tax': |
655 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
655 | + wpinv_the_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
656 | 656 | break; |
657 | 657 | |
658 | 658 | case 'discount': |
659 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
659 | + wpinv_the_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
660 | 660 | break; |
661 | 661 | |
662 | 662 | case 'initial': |
663 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
663 | + wpinv_the_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
664 | 664 | break; |
665 | 665 | |
666 | 666 | case 'recurring': |
667 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
667 | + echo wp_kses_post('<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'); |
|
668 | 668 | break; |
669 | 669 | |
670 | 670 | } |
@@ -677,24 +677,24 @@ discard block |
||
677 | 677 | |
678 | 678 | endforeach; |
679 | 679 | |
680 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
680 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
681 | 681 | |
682 | 682 | echo '<tr>'; |
683 | 683 | |
684 | - foreach ( array_keys( $columns ) as $key ) { |
|
684 | + foreach (array_keys($columns) as $key) { |
|
685 | 685 | |
686 | 686 | $class = 'text-left'; |
687 | 687 | |
688 | 688 | echo "<td class='p-2 text-left'>"; |
689 | 689 | |
690 | - switch ( $key ) { |
|
690 | + switch ($key) { |
|
691 | 691 | |
692 | 692 | case 'item_name': |
693 | - echo esc_html( $subscription_group_fee['name'] ); |
|
693 | + echo esc_html($subscription_group_fee['name']); |
|
694 | 694 | break; |
695 | 695 | |
696 | 696 | case 'price': |
697 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
697 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
698 | 698 | break; |
699 | 699 | |
700 | 700 | case 'tax': |
@@ -706,11 +706,11 @@ discard block |
||
706 | 706 | break; |
707 | 707 | |
708 | 708 | case 'initial': |
709 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
709 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
710 | 710 | break; |
711 | 711 | |
712 | 712 | case 'recurring': |
713 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
713 | + echo wp_kses_post('<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'); |
|
714 | 714 | break; |
715 | 715 | |
716 | 716 | } |
@@ -739,12 +739,12 @@ discard block |
||
739 | 739 | * @param WPInv_Subscription $subscription |
740 | 740 | * @param bool $skip_current |
741 | 741 | */ |
742 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
742 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
743 | 743 | |
744 | 744 | // Fetch the subscription groups. |
745 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
745 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
746 | 746 | |
747 | - if ( empty( $subscription_groups ) ) { |
|
747 | + if (empty($subscription_groups)) { |
|
748 | 748 | return; |
749 | 749 | } |
750 | 750 | |
@@ -752,37 +752,37 @@ discard block |
||
752 | 752 | $columns = apply_filters( |
753 | 753 | 'getpaid_subscription_related_subscriptions_columns', |
754 | 754 | array( |
755 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
756 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
757 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
758 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
759 | - 'item' => __( 'Items', 'invoicing' ), |
|
760 | - 'status' => __( 'Status', 'invoicing' ), |
|
755 | + 'subscription' => __('Subscription', 'invoicing'), |
|
756 | + 'start_date' => __('Start Date', 'invoicing'), |
|
757 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
758 | + 'renewals' => __('Payments', 'invoicing'), |
|
759 | + 'item' => __('Items', 'invoicing'), |
|
760 | + 'status' => __('Status', 'invoicing'), |
|
761 | 761 | ), |
762 | 762 | $subscription |
763 | 763 | ); |
764 | 764 | |
765 | - if ( $subscription->get_status() == 'pending' ) { |
|
766 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
765 | + if ($subscription->get_status() == 'pending') { |
|
766 | + unset($columns['start_date'], $columns['renewal_date']); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | $table_class = 'w-100 bg-white'; |
770 | 770 | |
771 | - if ( ! is_admin() ) { |
|
771 | + if (!is_admin()) { |
|
772 | 772 | $table_class = 'table table-bordered'; |
773 | 773 | } |
774 | 774 | |
775 | 775 | ?> |
776 | 776 | <div class="m-0" style="overflow: auto;"> |
777 | 777 | |
778 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
778 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
779 | 779 | |
780 | 780 | <thead> |
781 | 781 | <tr> |
782 | 782 | <?php |
783 | 783 | |
784 | - foreach ( $columns as $key => $label ) { |
|
785 | - echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
784 | + foreach ($columns as $key => $label) { |
|
785 | + echo "<th class='related-subscription-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
786 | 786 | } |
787 | 787 | ?> |
788 | 788 | </tr> |
@@ -792,62 +792,62 @@ discard block |
||
792 | 792 | |
793 | 793 | <?php |
794 | 794 | |
795 | - foreach ( $subscription_groups as $subscription_group ) : |
|
795 | + foreach ($subscription_groups as $subscription_group) : |
|
796 | 796 | |
797 | 797 | // Do not list current subscription. |
798 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
798 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
799 | 799 | continue; |
800 | 800 | } |
801 | 801 | |
802 | 802 | // Ensure the subscription exists. |
803 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
803 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
804 | 804 | |
805 | - if ( ! $_suscription->exists() ) { |
|
805 | + if (!$_suscription->exists()) { |
|
806 | 806 | continue; |
807 | 807 | } |
808 | 808 | |
809 | 809 | echo '<tr>'; |
810 | 810 | |
811 | - foreach ( array_keys( $columns ) as $key ) { |
|
811 | + foreach (array_keys($columns) as $key) { |
|
812 | 812 | |
813 | 813 | $class = 'text-left'; |
814 | 814 | |
815 | 815 | echo "<td class='p-2 text-left'>"; |
816 | 816 | |
817 | - switch ( $key ) { |
|
817 | + switch ($key) { |
|
818 | 818 | |
819 | 819 | case 'status': |
820 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
820 | + echo wp_kses_post($_suscription->get_status_label_html()); |
|
821 | 821 | break; |
822 | 822 | |
823 | 823 | case 'item': |
824 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
825 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
824 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
825 | + echo wp_kses_post(implode(' | ', $markup)); |
|
826 | 826 | break; |
827 | 827 | |
828 | 828 | case 'renewals': |
829 | 829 | $max_bills = $_suscription->get_bill_times(); |
830 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
830 | + echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
831 | 831 | break; |
832 | 832 | |
833 | 833 | case 'renewal_date': |
834 | - echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
834 | + echo $_suscription->is_active() ? esc_html(getpaid_format_date_value($_suscription->get_expiration())) : '—'; |
|
835 | 835 | break; |
836 | 836 | |
837 | 837 | case 'start_date': |
838 | - echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
838 | + echo 'pending' == $_suscription->get_status() ? '—' : esc_html(getpaid_format_date_value($_suscription->get_date_created())); |
|
839 | 839 | break; |
840 | 840 | |
841 | 841 | case 'subscription': |
842 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
842 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
843 | 843 | printf( |
844 | 844 | '%1$s#%2$s%3$s', |
845 | - '<a href="' . esc_url( $url ) . '">', |
|
846 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
845 | + '<a href="' . esc_url($url) . '">', |
|
846 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
847 | 847 | '</a>' |
848 | 848 | ); |
849 | 849 | |
850 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
850 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::column_amount($_suscription)); |
|
851 | 851 | break; |
852 | 852 | |
853 | 853 | } |
@@ -1,38 +1,38 @@ |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( ! defined( 'WPINC' ) ) { |
|
3 | +if (!defined('WPINC')) { |
|
4 | 4 | exit; |
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Notes { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $post; |
10 | 10 | |
11 | - $notes = wpinv_get_invoice_notes( $post->ID ); |
|
11 | + $notes = wpinv_get_invoice_notes($post->ID); |
|
12 | 12 | |
13 | 13 | echo '<ul class="invoice_notes">'; |
14 | 14 | |
15 | - if ( $notes ) { |
|
16 | - foreach ( $notes as $note ) { |
|
17 | - wpinv_get_invoice_note_line_item( $note ); |
|
15 | + if ($notes) { |
|
16 | + foreach ($notes as $note) { |
|
17 | + wpinv_get_invoice_note_line_item($note); |
|
18 | 18 | } |
19 | 19 | } else { |
20 | - echo '<li>' . esc_html__( 'There are no notes yet.', 'invoicing' ) . '</li>'; |
|
20 | + echo '<li>' . esc_html__('There are no notes yet.', 'invoicing') . '</li>'; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | echo '</ul>'; |
24 | 24 | ?> |
25 | 25 | <div class="add_note"> |
26 | - <h4><?php esc_html_e( 'Add note', 'invoicing' ); ?></h4> |
|
26 | + <h4><?php esc_html_e('Add note', 'invoicing'); ?></h4> |
|
27 | 27 | <p> |
28 | 28 | <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea> |
29 | 29 | </p> |
30 | 30 | <p> |
31 | 31 | <select name="invoice_note_type" id="invoice_note_type" class="regular-text"> |
32 | - <option value=""><?php esc_html_e( 'Private note', 'invoicing' ); ?></option> |
|
33 | - <option value="customer"><?php esc_html_e( 'Note to customer', 'invoicing' ); ?></option> |
|
32 | + <option value=""><?php esc_html_e('Private note', 'invoicing'); ?></option> |
|
33 | + <option value="customer"><?php esc_html_e('Note to customer', 'invoicing'); ?></option> |
|
34 | 34 | </select> |
35 | - <a href="#" class="add_note button"><?php esc_html_e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php esc_html_e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span> |
|
35 | + <a href="#" class="add_note button"><?php esc_html_e('Add', 'invoicing'); ?></a> <span class="description"><?php esc_html_e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span> |
|
36 | 36 | </p> |
37 | 37 | </div> |
38 | 38 | <?php |
@@ -126,14 +126,14 @@ |
||
126 | 126 | */ |
127 | 127 | function getpaid_doing_it_wrong( $function, $message, $version ) { |
128 | 128 | |
129 | - $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
|
130 | - |
|
131 | - if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
132 | - do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
133 | - error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
134 | - } else { |
|
135 | - _doing_it_wrong( esc_html( $function ), wp_kses_post( $message ), esc_html( $version ) ); |
|
136 | - } |
|
129 | + $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
|
130 | + |
|
131 | + if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
132 | + do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
133 | + error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
134 | + } else { |
|
135 | + _doing_it_wrong( esc_html( $function ), wp_kses_post( $message ), esc_html( $version ) ); |
|
136 | + } |
|
137 | 137 | |
138 | 138 | } |
139 | 139 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Returns the errors as html |
@@ -15,35 +15,35 @@ discard block |
||
15 | 15 | * @param bool $wrap whether or not to wrap the errors. |
16 | 16 | * @since 1.0.19 |
17 | 17 | */ |
18 | -function getpaid_get_errors_html( $clear = true, $wrap = true ) { |
|
18 | +function getpaid_get_errors_html($clear = true, $wrap = true) { |
|
19 | 19 | |
20 | 20 | $errors = ''; |
21 | - foreach ( wpinv_get_errors() as $id => $error ) { |
|
22 | - $type = 'error'; |
|
21 | + foreach (wpinv_get_errors() as $id => $error) { |
|
22 | + $type = 'error'; |
|
23 | 23 | |
24 | - if ( is_array( $error ) ) { |
|
24 | + if (is_array($error)) { |
|
25 | 25 | $type = $error['type']; |
26 | 26 | $error = $error['text']; |
27 | 27 | } |
28 | 28 | |
29 | - if ( $wrap ) { |
|
29 | + if ($wrap) { |
|
30 | 30 | |
31 | 31 | $errors .= aui()->alert( |
32 | 32 | array( |
33 | - 'content' => wp_kses_post( $error ), |
|
33 | + 'content' => wp_kses_post($error), |
|
34 | 34 | 'type' => $type, |
35 | 35 | ) |
36 | 36 | ); |
37 | 37 | |
38 | 38 | } else { |
39 | 39 | |
40 | - $id = esc_attr( $id ); |
|
41 | - $error = wp_kses_post( $error ); |
|
40 | + $id = esc_attr($id); |
|
41 | + $error = wp_kses_post($error); |
|
42 | 42 | $errors .= "<div data-code='$id'>$error</div>"; |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | - if ( $clear ) { |
|
46 | + if ($clear) { |
|
47 | 47 | wpinv_clear_errors(); |
48 | 48 | } |
49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * Prints (then clears) all available errors. |
56 | 56 | */ |
57 | 57 | function wpinv_print_errors() { |
58 | - echo wp_kses_post( getpaid_get_errors_html() ); |
|
58 | + echo wp_kses_post(getpaid_get_errors_html()); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | * @return array |
65 | 65 | */ |
66 | 66 | function wpinv_get_errors() { |
67 | - $errors = getpaid_session()->get( 'wpinv_errors' ); |
|
68 | - return is_array( $errors ) ? $errors : array(); |
|
67 | + $errors = getpaid_session()->get('wpinv_errors'); |
|
68 | + return is_array($errors) ? $errors : array(); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -75,15 +75,15 @@ discard block |
||
75 | 75 | * @param string $error_message The error message. |
76 | 76 | * @param string $type Either error, info, warning, primary, dark, light or success. |
77 | 77 | */ |
78 | -function wpinv_set_error( $error_id, $error_message, $type = 'error' ) { |
|
78 | +function wpinv_set_error($error_id, $error_message, $type = 'error') { |
|
79 | 79 | |
80 | 80 | $errors = wpinv_get_errors(); |
81 | - $errors[ $error_id ] = array( |
|
81 | + $errors[$error_id] = array( |
|
82 | 82 | 'type' => $type, |
83 | 83 | 'text' => $error_message, |
84 | 84 | ); |
85 | 85 | |
86 | - getpaid_session()->set( 'wpinv_errors', $errors ); |
|
86 | + getpaid_session()->set('wpinv_errors', $errors); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | */ |
93 | 93 | function wpinv_has_errors() { |
94 | - return count( wpinv_get_errors() ) > 0; |
|
94 | + return count(wpinv_get_errors()) > 0; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -99,21 +99,21 @@ discard block |
||
99 | 99 | * |
100 | 100 | */ |
101 | 101 | function wpinv_clear_errors() { |
102 | - getpaid_session()->set( 'wpinv_errors', null ); |
|
102 | + getpaid_session()->set('wpinv_errors', null); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
106 | 106 | * Clears a single error. |
107 | 107 | * |
108 | 108 | */ |
109 | -function wpinv_unset_error( $error_id ) { |
|
109 | +function wpinv_unset_error($error_id) { |
|
110 | 110 | $errors = wpinv_get_errors(); |
111 | 111 | |
112 | - if ( isset( $errors[ $error_id ] ) ) { |
|
113 | - unset( $errors[ $error_id ] ); |
|
112 | + if (isset($errors[$error_id])) { |
|
113 | + unset($errors[$error_id]); |
|
114 | 114 | } |
115 | 115 | |
116 | - getpaid_session()->set( 'wpinv_errors', $errors ); |
|
116 | + getpaid_session()->set('wpinv_errors', $errors); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | * @param string $message Message to log. |
125 | 125 | * @param string $version Version the message was added in. |
126 | 126 | */ |
127 | -function getpaid_doing_it_wrong( $function, $message, $version ) { |
|
127 | +function getpaid_doing_it_wrong($function, $message, $version) { |
|
128 | 128 | |
129 | 129 | $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
130 | 130 | |
131 | - if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
132 | - do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
133 | - error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
131 | + if (wp_doing_ajax() || defined('REST_REQUEST')) { |
|
132 | + do_action('doing_it_wrong_run', $function, $message, $version); |
|
133 | + error_log("{$function} was called incorrectly. {$message}. This message was added in version {$version}."); |
|
134 | 134 | } else { |
135 | - _doing_it_wrong( esc_html( $function ), wp_kses_post( $message ), esc_html( $version ) ); |
|
135 | + _doing_it_wrong(esc_html($function), wp_kses_post($message), esc_html($version)); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | } |
@@ -146,41 +146,41 @@ discard block |
||
146 | 146 | * @param string $line The line that contains the error. |
147 | 147 | * @param bool $exit Whether or not to exit function execution. |
148 | 148 | */ |
149 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
149 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
150 | 150 | |
151 | - if ( true === apply_filters( 'wpinv_log_errors', true ) ) { |
|
151 | + if (true === apply_filters('wpinv_log_errors', true)) { |
|
152 | 152 | |
153 | 153 | // Ensure the log is a scalar. |
154 | - if ( ! is_scalar( $log ) ) { |
|
155 | - $log = print_r( $log, true ); |
|
154 | + if (!is_scalar($log)) { |
|
155 | + $log = print_r($log, true); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // Add title. |
159 | - if ( ! empty( $title ) ) { |
|
160 | - $log = $title . ' ' . trim( $log ); |
|
159 | + if (!empty($title)) { |
|
160 | + $log = $title . ' ' . trim($log); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | // Add the file to the label. |
164 | - if ( ! empty( $file ) ) { |
|
164 | + if (!empty($file)) { |
|
165 | 165 | $log .= ' in ' . $file; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // Add the line number to the label. |
169 | - if ( ! empty( $line ) ) { |
|
169 | + if (!empty($line)) { |
|
170 | 170 | $log .= ' on line ' . $line; |
171 | 171 | } |
172 | 172 | |
173 | 173 | // Log the message. |
174 | - error_log( trim( $log ) ); |
|
174 | + error_log(trim($log)); |
|
175 | 175 | |
176 | 176 | // ... and a backtrace. |
177 | - if ( false !== $title && false !== $file ) { |
|
178 | - error_log( 'Backtrace ' . wp_debug_backtrace_summary() ); |
|
177 | + if (false !== $title && false !== $file) { |
|
178 | + error_log('Backtrace ' . wp_debug_backtrace_summary()); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Maybe exit. |
183 | - if ( $exit ) { |
|
183 | + if ($exit) { |
|
184 | 184 | exit; |
185 | 185 | } |
186 | 186 |
@@ -13,462 +13,462 @@ discard block |
||
13 | 13 | */ |
14 | 14 | abstract class GetPaid_Payment_Gateway { |
15 | 15 | |
16 | - /** |
|
17 | - * Set if the place checkout button should be renamed on selection. |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - public $checkout_button_text; |
|
22 | - |
|
23 | - /** |
|
24 | - * Boolean whether the method is enabled. |
|
25 | - * |
|
26 | - * @var bool |
|
27 | - */ |
|
28 | - public $enabled = true; |
|
29 | - |
|
30 | - /** |
|
31 | - * Payment method id. |
|
32 | - * |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - public $id; |
|
36 | - |
|
37 | - /** |
|
38 | - * Payment method order. |
|
39 | - * |
|
40 | - * @var int |
|
41 | - */ |
|
42 | - public $order = 10; |
|
43 | - |
|
44 | - /** |
|
45 | - * Payment method title for the frontend. |
|
46 | - * |
|
47 | - * @var string |
|
48 | - */ |
|
49 | - public $title; |
|
50 | - |
|
51 | - /** |
|
52 | - * Payment method description for the frontend. |
|
53 | - * |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - public $description; |
|
57 | - |
|
58 | - /** |
|
59 | - * Gateway title. |
|
60 | - * |
|
61 | - * @var string |
|
62 | - */ |
|
63 | - public $method_title = ''; |
|
64 | - |
|
65 | - /** |
|
66 | - * Gateway description. |
|
67 | - * |
|
68 | - * @var string |
|
69 | - */ |
|
70 | - public $method_description = ''; |
|
71 | - |
|
72 | - /** |
|
73 | - * Countries this gateway is allowed for. |
|
74 | - * |
|
75 | - * @var array |
|
76 | - */ |
|
77 | - public $countries; |
|
78 | - |
|
79 | - /** |
|
80 | - * Currencies this gateway is allowed for. |
|
81 | - * |
|
82 | - * @var array |
|
83 | - */ |
|
84 | - public $currencies; |
|
85 | - |
|
86 | - /** |
|
87 | - * Currencies this gateway is not allowed for. |
|
88 | - * |
|
89 | - * @var array |
|
90 | - */ |
|
91 | - public $exclude_currencies; |
|
92 | - |
|
93 | - /** |
|
94 | - * Maximum transaction amount, zero does not define a maximum. |
|
95 | - * |
|
96 | - * @var int |
|
97 | - */ |
|
98 | - public $max_amount = 0; |
|
99 | - |
|
100 | - /** |
|
101 | - * Optional URL to view a transaction. |
|
102 | - * |
|
103 | - * @var string |
|
104 | - */ |
|
105 | - public $view_transaction_url = ''; |
|
106 | - |
|
107 | - /** |
|
108 | - * Optional URL to view a subscription. |
|
109 | - * |
|
110 | - * @var string |
|
111 | - */ |
|
112 | - public $view_subscription_url = ''; |
|
113 | - |
|
114 | - /** |
|
115 | - * Optional label to show for "new payment method" in the payment |
|
116 | - * method/token selection radio selection. |
|
117 | - * |
|
118 | - * @var string |
|
119 | - */ |
|
120 | - public $new_method_label = ''; |
|
121 | - |
|
122 | - /** |
|
123 | - * Contains a user's saved tokens for this gateway. |
|
124 | - * |
|
125 | - * @var array |
|
126 | - */ |
|
127 | - protected $tokens = array(); |
|
128 | - |
|
129 | - /** |
|
130 | - * An array of features that this gateway supports. |
|
131 | - * |
|
132 | - * @var array |
|
133 | - */ |
|
134 | - protected $supports = array(); |
|
135 | - |
|
136 | - /** |
|
137 | - * Class constructor. |
|
138 | - */ |
|
139 | - public function __construct() { |
|
140 | - |
|
141 | - // Register gateway. |
|
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | - |
|
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
145 | - |
|
146 | - // Add support for various features. |
|
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | - add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
151 | - } |
|
152 | - |
|
153 | - // Invoice addons. |
|
154 | - if ( $this->supports( 'addons' ) ) { |
|
155 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
156 | - } |
|
157 | - |
|
158 | - // Gateway settings. |
|
159 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
160 | - |
|
161 | - // Gateway checkout fiellds. |
|
162 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
163 | - |
|
164 | - // Process payment. |
|
165 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
166 | - |
|
167 | - // Change the checkout button text. |
|
168 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
169 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
170 | - } |
|
171 | - |
|
172 | - // Check if a gateway is valid for a given currency. |
|
173 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
174 | - |
|
175 | - // Generate the transaction url. |
|
176 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
177 | - |
|
178 | - // Generate the subscription url. |
|
179 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
180 | - |
|
181 | - // Confirm payments. |
|
182 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
183 | - |
|
184 | - // Verify IPNs. |
|
185 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
186 | - |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Checks if this gateway is a given gateway. |
|
191 | - * |
|
192 | - * @since 1.0.19 |
|
193 | - * @return bool |
|
194 | - */ |
|
195 | - public function is( $gateway ) { |
|
196 | - return $gateway == $this->id; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * Returns a users saved tokens for this gateway. |
|
201 | - * |
|
202 | - * @since 1.0.19 |
|
203 | - * @return array |
|
204 | - */ |
|
205 | - public function get_tokens( $sandbox = null ) { |
|
206 | - |
|
207 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
208 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
209 | - |
|
210 | - if ( is_array( $tokens ) ) { |
|
211 | - $this->tokens = $tokens; |
|
212 | - } |
|
16 | + /** |
|
17 | + * Set if the place checkout button should be renamed on selection. |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + public $checkout_button_text; |
|
22 | + |
|
23 | + /** |
|
24 | + * Boolean whether the method is enabled. |
|
25 | + * |
|
26 | + * @var bool |
|
27 | + */ |
|
28 | + public $enabled = true; |
|
29 | + |
|
30 | + /** |
|
31 | + * Payment method id. |
|
32 | + * |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + public $id; |
|
36 | + |
|
37 | + /** |
|
38 | + * Payment method order. |
|
39 | + * |
|
40 | + * @var int |
|
41 | + */ |
|
42 | + public $order = 10; |
|
43 | + |
|
44 | + /** |
|
45 | + * Payment method title for the frontend. |
|
46 | + * |
|
47 | + * @var string |
|
48 | + */ |
|
49 | + public $title; |
|
50 | + |
|
51 | + /** |
|
52 | + * Payment method description for the frontend. |
|
53 | + * |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + public $description; |
|
57 | + |
|
58 | + /** |
|
59 | + * Gateway title. |
|
60 | + * |
|
61 | + * @var string |
|
62 | + */ |
|
63 | + public $method_title = ''; |
|
64 | + |
|
65 | + /** |
|
66 | + * Gateway description. |
|
67 | + * |
|
68 | + * @var string |
|
69 | + */ |
|
70 | + public $method_description = ''; |
|
71 | + |
|
72 | + /** |
|
73 | + * Countries this gateway is allowed for. |
|
74 | + * |
|
75 | + * @var array |
|
76 | + */ |
|
77 | + public $countries; |
|
78 | + |
|
79 | + /** |
|
80 | + * Currencies this gateway is allowed for. |
|
81 | + * |
|
82 | + * @var array |
|
83 | + */ |
|
84 | + public $currencies; |
|
85 | + |
|
86 | + /** |
|
87 | + * Currencies this gateway is not allowed for. |
|
88 | + * |
|
89 | + * @var array |
|
90 | + */ |
|
91 | + public $exclude_currencies; |
|
92 | + |
|
93 | + /** |
|
94 | + * Maximum transaction amount, zero does not define a maximum. |
|
95 | + * |
|
96 | + * @var int |
|
97 | + */ |
|
98 | + public $max_amount = 0; |
|
99 | + |
|
100 | + /** |
|
101 | + * Optional URL to view a transaction. |
|
102 | + * |
|
103 | + * @var string |
|
104 | + */ |
|
105 | + public $view_transaction_url = ''; |
|
106 | + |
|
107 | + /** |
|
108 | + * Optional URL to view a subscription. |
|
109 | + * |
|
110 | + * @var string |
|
111 | + */ |
|
112 | + public $view_subscription_url = ''; |
|
113 | + |
|
114 | + /** |
|
115 | + * Optional label to show for "new payment method" in the payment |
|
116 | + * method/token selection radio selection. |
|
117 | + * |
|
118 | + * @var string |
|
119 | + */ |
|
120 | + public $new_method_label = ''; |
|
121 | + |
|
122 | + /** |
|
123 | + * Contains a user's saved tokens for this gateway. |
|
124 | + * |
|
125 | + * @var array |
|
126 | + */ |
|
127 | + protected $tokens = array(); |
|
128 | + |
|
129 | + /** |
|
130 | + * An array of features that this gateway supports. |
|
131 | + * |
|
132 | + * @var array |
|
133 | + */ |
|
134 | + protected $supports = array(); |
|
135 | + |
|
136 | + /** |
|
137 | + * Class constructor. |
|
138 | + */ |
|
139 | + public function __construct() { |
|
140 | + |
|
141 | + // Register gateway. |
|
142 | + add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | + |
|
144 | + $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
145 | + |
|
146 | + // Add support for various features. |
|
147 | + foreach ( $this->supports as $feature ) { |
|
148 | + add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | + add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | + add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
151 | + } |
|
152 | + |
|
153 | + // Invoice addons. |
|
154 | + if ( $this->supports( 'addons' ) ) { |
|
155 | + add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
156 | + } |
|
157 | + |
|
158 | + // Gateway settings. |
|
159 | + add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
160 | + |
|
161 | + // Gateway checkout fiellds. |
|
162 | + add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
163 | + |
|
164 | + // Process payment. |
|
165 | + add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
166 | + |
|
167 | + // Change the checkout button text. |
|
168 | + if ( ! empty( $this->checkout_button_text ) ) { |
|
169 | + add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
170 | + } |
|
171 | + |
|
172 | + // Check if a gateway is valid for a given currency. |
|
173 | + add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
174 | + |
|
175 | + // Generate the transaction url. |
|
176 | + add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
177 | + |
|
178 | + // Generate the subscription url. |
|
179 | + add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
180 | + |
|
181 | + // Confirm payments. |
|
182 | + add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
183 | + |
|
184 | + // Verify IPNs. |
|
185 | + add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
186 | + |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Checks if this gateway is a given gateway. |
|
191 | + * |
|
192 | + * @since 1.0.19 |
|
193 | + * @return bool |
|
194 | + */ |
|
195 | + public function is( $gateway ) { |
|
196 | + return $gateway == $this->id; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Returns a users saved tokens for this gateway. |
|
201 | + * |
|
202 | + * @since 1.0.19 |
|
203 | + * @return array |
|
204 | + */ |
|
205 | + public function get_tokens( $sandbox = null ) { |
|
206 | + |
|
207 | + if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
208 | + $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
209 | + |
|
210 | + if ( is_array( $tokens ) ) { |
|
211 | + $this->tokens = $tokens; |
|
212 | + } |
|
213 | 213 | } |
214 | 214 | |
215 | - if ( ! is_bool( $sandbox ) ) { |
|
216 | - return $this->tokens; |
|
217 | - } |
|
218 | - |
|
219 | - // Filter tokens. |
|
220 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | - return wp_list_filter( $this->tokens, $args ); |
|
222 | - |
|
223 | - } |
|
224 | - |
|
225 | - /** |
|
226 | - * Saves a token for this gateway. |
|
227 | - * |
|
228 | - * @since 1.0.19 |
|
229 | - */ |
|
230 | - public function save_token( $token ) { |
|
231 | - |
|
232 | - $tokens = $this->get_tokens(); |
|
233 | - $tokens[] = $token; |
|
234 | - |
|
235 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
236 | - |
|
237 | - $this->tokens = $tokens; |
|
238 | - |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Return the title for admin screens. |
|
243 | - * |
|
244 | - * @return string |
|
245 | - */ |
|
246 | - public function get_method_title() { |
|
247 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * Return the description for admin screens. |
|
252 | - * |
|
253 | - * @return string |
|
254 | - */ |
|
255 | - public function get_method_description() { |
|
256 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Get the success url. |
|
261 | - * |
|
262 | - * @param WPInv_Invoice $invoice Invoice object. |
|
263 | - * @return string |
|
264 | - */ |
|
265 | - public function get_return_url( $invoice ) { |
|
266 | - |
|
267 | - // Payment success url |
|
268 | - $return_url = add_query_arg( |
|
269 | - array( |
|
270 | - 'payment-confirm' => $this->id, |
|
271 | - 'invoice_key' => $invoice->get_key(), |
|
272 | - 'utm_nooverride' => 1, |
|
273 | - ), |
|
274 | - wpinv_get_success_page_uri() |
|
275 | - ); |
|
276 | - |
|
277 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
278 | - } |
|
279 | - |
|
280 | - /** |
|
281 | - * Confirms payments when rendering the success page. |
|
282 | - * |
|
283 | - * @param string $content Success page content. |
|
284 | - * @return string |
|
285 | - */ |
|
286 | - public function confirm_payment( $content ) { |
|
287 | - |
|
288 | - // Retrieve the invoice. |
|
289 | - $invoice_id = getpaid_get_current_invoice_id(); |
|
290 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
291 | - |
|
292 | - // Ensure that it exists and that it is pending payment. |
|
293 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
294 | - return $content; |
|
295 | - } |
|
296 | - |
|
297 | - // Can the user view this invoice?? |
|
298 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
299 | - return $content; |
|
300 | - } |
|
301 | - |
|
302 | - // Show payment processing indicator. |
|
303 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * Processes ipns and marks payments as complete. |
|
308 | - * |
|
309 | - * @return void |
|
310 | - */ |
|
311 | - public function verify_ipn() {} |
|
312 | - |
|
313 | - /** |
|
314 | - * Processes invoice addons. |
|
315 | - * |
|
316 | - * @param WPInv_Invoice $invoice |
|
317 | - * @param GetPaid_Form_Item[] $items |
|
318 | - * @return WPInv_Invoice |
|
319 | - */ |
|
320 | - public function process_addons( $invoice, $items ) { |
|
321 | - |
|
322 | - } |
|
323 | - |
|
324 | - /** |
|
325 | - * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
326 | - * |
|
327 | - * @param string $transaction_url transaction url. |
|
328 | - * @param WPInv_Invoice $invoice Invoice object. |
|
329 | - * @return string transaction URL, or empty string. |
|
330 | - */ |
|
331 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
332 | - |
|
333 | - $transaction_id = $invoice->get_transaction_id(); |
|
334 | - |
|
335 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
336 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
337 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
338 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
339 | - } |
|
340 | - |
|
341 | - return $transaction_url; |
|
342 | - } |
|
343 | - |
|
344 | - /** |
|
345 | - * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
346 | - * |
|
347 | - * @param string $subscription_url transaction url. |
|
348 | - * @param WPInv_Subscription $subscription Subscription objectt. |
|
349 | - * @return string subscription URL, or empty string. |
|
350 | - */ |
|
351 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
352 | - |
|
353 | - $profile_id = $subscription->get_profile_id(); |
|
354 | - |
|
355 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
356 | - |
|
357 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
358 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
359 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
360 | - |
|
361 | - } |
|
362 | - |
|
363 | - return $subscription_url; |
|
364 | - } |
|
365 | - |
|
366 | - /** |
|
367 | - * Check if the gateway is available for use. |
|
368 | - * |
|
369 | - * @return bool |
|
370 | - */ |
|
371 | - public function is_available() { |
|
372 | - return ! empty( $this->enabled ); |
|
373 | - } |
|
374 | - |
|
375 | - /** |
|
376 | - * Return the gateway's title. |
|
377 | - * |
|
378 | - * @return string |
|
379 | - */ |
|
380 | - public function get_title() { |
|
381 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
382 | - } |
|
383 | - |
|
384 | - /** |
|
385 | - * Return the gateway's description. |
|
386 | - * |
|
387 | - * @return string |
|
388 | - */ |
|
389 | - public function get_description() { |
|
390 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
391 | - } |
|
392 | - |
|
393 | - /** |
|
394 | - * Process Payment. |
|
395 | - * |
|
396 | - * |
|
397 | - * @param WPInv_Invoice $invoice Invoice. |
|
398 | - * @param array $submission_data Posted checkout fields. |
|
399 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
400 | - * @return void |
|
401 | - */ |
|
402 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
403 | - // Process the payment then either redirect to the success page or the gateway. |
|
404 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
405 | - } |
|
406 | - |
|
407 | - /** |
|
408 | - * Process refund. |
|
409 | - * |
|
410 | - * If the gateway declares 'refunds' support, this will allow it to refund. |
|
411 | - * a passed in amount. |
|
412 | - * |
|
413 | - * @param WPInv_Invoice $invoice Invoice. |
|
414 | - * @param float $amount Refund amount. |
|
415 | - * @param string $reason Refund reason. |
|
416 | - * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
417 | - */ |
|
418 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
420 | - } |
|
421 | - |
|
422 | - /** |
|
423 | - * Displays the payment fields, credit cards etc. |
|
424 | - * |
|
425 | - * @param int $invoice_id 0 or invoice id. |
|
426 | - * @param GetPaid_Payment_Form $form Current payment form. |
|
427 | - */ |
|
428 | - public function payment_fields( $invoice_id, $form ) { |
|
429 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
430 | - } |
|
431 | - |
|
432 | - /** |
|
433 | - * Filters the gateway settings. |
|
434 | - * |
|
435 | - * @param array $admin_settings |
|
436 | - */ |
|
437 | - public function admin_settings( $admin_settings ) { |
|
438 | - return $admin_settings; |
|
439 | - } |
|
440 | - |
|
441 | - /** |
|
442 | - * Retrieves the value of a gateway setting. |
|
443 | - * |
|
444 | - * @param string $option |
|
445 | - */ |
|
446 | - public function get_option( $option, $default = false ) { |
|
447 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
448 | - } |
|
449 | - |
|
450 | - /** |
|
451 | - * Check if a gateway supports a given feature. |
|
452 | - * |
|
453 | - * Gateways should override this to declare support (or lack of support) for a feature. |
|
454 | - * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
455 | - * |
|
456 | - * @param string $feature string The name of a feature to test support for. |
|
457 | - * @return bool True if the gateway supports the feature, false otherwise. |
|
458 | - * @since 1.0.19 |
|
459 | - */ |
|
460 | - public function supports( $feature ) { |
|
461 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
462 | - } |
|
463 | - |
|
464 | - /** |
|
465 | - * Returns the credit card form html. |
|
466 | - * |
|
467 | - * @param bool $save whether or not to display the save button. |
|
468 | - */ |
|
215 | + if ( ! is_bool( $sandbox ) ) { |
|
216 | + return $this->tokens; |
|
217 | + } |
|
218 | + |
|
219 | + // Filter tokens. |
|
220 | + $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | + return wp_list_filter( $this->tokens, $args ); |
|
222 | + |
|
223 | + } |
|
224 | + |
|
225 | + /** |
|
226 | + * Saves a token for this gateway. |
|
227 | + * |
|
228 | + * @since 1.0.19 |
|
229 | + */ |
|
230 | + public function save_token( $token ) { |
|
231 | + |
|
232 | + $tokens = $this->get_tokens(); |
|
233 | + $tokens[] = $token; |
|
234 | + |
|
235 | + update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
236 | + |
|
237 | + $this->tokens = $tokens; |
|
238 | + |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Return the title for admin screens. |
|
243 | + * |
|
244 | + * @return string |
|
245 | + */ |
|
246 | + public function get_method_title() { |
|
247 | + return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * Return the description for admin screens. |
|
252 | + * |
|
253 | + * @return string |
|
254 | + */ |
|
255 | + public function get_method_description() { |
|
256 | + return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Get the success url. |
|
261 | + * |
|
262 | + * @param WPInv_Invoice $invoice Invoice object. |
|
263 | + * @return string |
|
264 | + */ |
|
265 | + public function get_return_url( $invoice ) { |
|
266 | + |
|
267 | + // Payment success url |
|
268 | + $return_url = add_query_arg( |
|
269 | + array( |
|
270 | + 'payment-confirm' => $this->id, |
|
271 | + 'invoice_key' => $invoice->get_key(), |
|
272 | + 'utm_nooverride' => 1, |
|
273 | + ), |
|
274 | + wpinv_get_success_page_uri() |
|
275 | + ); |
|
276 | + |
|
277 | + return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
278 | + } |
|
279 | + |
|
280 | + /** |
|
281 | + * Confirms payments when rendering the success page. |
|
282 | + * |
|
283 | + * @param string $content Success page content. |
|
284 | + * @return string |
|
285 | + */ |
|
286 | + public function confirm_payment( $content ) { |
|
287 | + |
|
288 | + // Retrieve the invoice. |
|
289 | + $invoice_id = getpaid_get_current_invoice_id(); |
|
290 | + $invoice = wpinv_get_invoice( $invoice_id ); |
|
291 | + |
|
292 | + // Ensure that it exists and that it is pending payment. |
|
293 | + if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
294 | + return $content; |
|
295 | + } |
|
296 | + |
|
297 | + // Can the user view this invoice?? |
|
298 | + if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
299 | + return $content; |
|
300 | + } |
|
301 | + |
|
302 | + // Show payment processing indicator. |
|
303 | + return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * Processes ipns and marks payments as complete. |
|
308 | + * |
|
309 | + * @return void |
|
310 | + */ |
|
311 | + public function verify_ipn() {} |
|
312 | + |
|
313 | + /** |
|
314 | + * Processes invoice addons. |
|
315 | + * |
|
316 | + * @param WPInv_Invoice $invoice |
|
317 | + * @param GetPaid_Form_Item[] $items |
|
318 | + * @return WPInv_Invoice |
|
319 | + */ |
|
320 | + public function process_addons( $invoice, $items ) { |
|
321 | + |
|
322 | + } |
|
323 | + |
|
324 | + /** |
|
325 | + * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
326 | + * |
|
327 | + * @param string $transaction_url transaction url. |
|
328 | + * @param WPInv_Invoice $invoice Invoice object. |
|
329 | + * @return string transaction URL, or empty string. |
|
330 | + */ |
|
331 | + public function filter_transaction_url( $transaction_url, $invoice ) { |
|
332 | + |
|
333 | + $transaction_id = $invoice->get_transaction_id(); |
|
334 | + |
|
335 | + if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
336 | + $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
337 | + $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
338 | + $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
339 | + } |
|
340 | + |
|
341 | + return $transaction_url; |
|
342 | + } |
|
343 | + |
|
344 | + /** |
|
345 | + * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
346 | + * |
|
347 | + * @param string $subscription_url transaction url. |
|
348 | + * @param WPInv_Subscription $subscription Subscription objectt. |
|
349 | + * @return string subscription URL, or empty string. |
|
350 | + */ |
|
351 | + public function generate_subscription_url( $subscription_url, $subscription ) { |
|
352 | + |
|
353 | + $profile_id = $subscription->get_profile_id(); |
|
354 | + |
|
355 | + if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
356 | + |
|
357 | + $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
358 | + $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
359 | + $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
360 | + |
|
361 | + } |
|
362 | + |
|
363 | + return $subscription_url; |
|
364 | + } |
|
365 | + |
|
366 | + /** |
|
367 | + * Check if the gateway is available for use. |
|
368 | + * |
|
369 | + * @return bool |
|
370 | + */ |
|
371 | + public function is_available() { |
|
372 | + return ! empty( $this->enabled ); |
|
373 | + } |
|
374 | + |
|
375 | + /** |
|
376 | + * Return the gateway's title. |
|
377 | + * |
|
378 | + * @return string |
|
379 | + */ |
|
380 | + public function get_title() { |
|
381 | + return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
382 | + } |
|
383 | + |
|
384 | + /** |
|
385 | + * Return the gateway's description. |
|
386 | + * |
|
387 | + * @return string |
|
388 | + */ |
|
389 | + public function get_description() { |
|
390 | + return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
391 | + } |
|
392 | + |
|
393 | + /** |
|
394 | + * Process Payment. |
|
395 | + * |
|
396 | + * |
|
397 | + * @param WPInv_Invoice $invoice Invoice. |
|
398 | + * @param array $submission_data Posted checkout fields. |
|
399 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
400 | + * @return void |
|
401 | + */ |
|
402 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
403 | + // Process the payment then either redirect to the success page or the gateway. |
|
404 | + do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
405 | + } |
|
406 | + |
|
407 | + /** |
|
408 | + * Process refund. |
|
409 | + * |
|
410 | + * If the gateway declares 'refunds' support, this will allow it to refund. |
|
411 | + * a passed in amount. |
|
412 | + * |
|
413 | + * @param WPInv_Invoice $invoice Invoice. |
|
414 | + * @param float $amount Refund amount. |
|
415 | + * @param string $reason Refund reason. |
|
416 | + * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
417 | + */ |
|
418 | + public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | + return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
420 | + } |
|
421 | + |
|
422 | + /** |
|
423 | + * Displays the payment fields, credit cards etc. |
|
424 | + * |
|
425 | + * @param int $invoice_id 0 or invoice id. |
|
426 | + * @param GetPaid_Payment_Form $form Current payment form. |
|
427 | + */ |
|
428 | + public function payment_fields( $invoice_id, $form ) { |
|
429 | + do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
430 | + } |
|
431 | + |
|
432 | + /** |
|
433 | + * Filters the gateway settings. |
|
434 | + * |
|
435 | + * @param array $admin_settings |
|
436 | + */ |
|
437 | + public function admin_settings( $admin_settings ) { |
|
438 | + return $admin_settings; |
|
439 | + } |
|
440 | + |
|
441 | + /** |
|
442 | + * Retrieves the value of a gateway setting. |
|
443 | + * |
|
444 | + * @param string $option |
|
445 | + */ |
|
446 | + public function get_option( $option, $default = false ) { |
|
447 | + return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
448 | + } |
|
449 | + |
|
450 | + /** |
|
451 | + * Check if a gateway supports a given feature. |
|
452 | + * |
|
453 | + * Gateways should override this to declare support (or lack of support) for a feature. |
|
454 | + * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
455 | + * |
|
456 | + * @param string $feature string The name of a feature to test support for. |
|
457 | + * @return bool True if the gateway supports the feature, false otherwise. |
|
458 | + * @since 1.0.19 |
|
459 | + */ |
|
460 | + public function supports( $feature ) { |
|
461 | + return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
462 | + } |
|
463 | + |
|
464 | + /** |
|
465 | + * Returns the credit card form html. |
|
466 | + * |
|
467 | + * @param bool $save whether or not to display the save button. |
|
468 | + */ |
|
469 | 469 | public function get_cc_form( $save = false ) { |
470 | 470 | |
471 | - ob_start(); |
|
471 | + ob_start(); |
|
472 | 472 | |
473 | 473 | $id_prefix = esc_attr( uniqid( $this->id ) ); |
474 | 474 | |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | |
529 | 529 | <?php |
530 | 530 | foreach ( $months as $key => $month ) { |
531 | - echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $month ) . "</option>" . PHP_EOL; |
|
531 | + echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $month ) . "</option>" . PHP_EOL; |
|
532 | 532 | } |
533 | 533 | ?> |
534 | 534 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | |
542 | 542 | <?php |
543 | 543 | foreach ( $years as $key => $year ) { |
544 | - echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $year ) . "</option>" . PHP_EOL; |
|
544 | + echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $year ) . "</option>" . PHP_EOL; |
|
545 | 545 | } |
546 | 546 | ?> |
547 | 547 | |
@@ -559,13 +559,13 @@ discard block |
||
559 | 559 | 'name' => $this->id . '[cc_cvv2]', |
560 | 560 | 'id' => "$id_prefix-cc-cvv2", |
561 | 561 | 'label' => __( 'CCV', 'invoicing' ), |
562 | - 'label_type' => 'vertical', |
|
563 | - 'class' => 'form-control-sm', |
|
564 | - 'extra_attributes' => array( |
|
565 | - 'autocomplete' => 'cc-csc', |
|
566 | - ), |
|
562 | + 'label_type' => 'vertical', |
|
563 | + 'class' => 'form-control-sm', |
|
564 | + 'extra_attributes' => array( |
|
565 | + 'autocomplete' => 'cc-csc', |
|
566 | + ), |
|
567 | 567 | ), |
568 | - true |
|
568 | + true |
|
569 | 569 | ); |
570 | 570 | ?> |
571 | 571 | </div> |
@@ -574,192 +574,192 @@ discard block |
||
574 | 574 | |
575 | 575 | <?php |
576 | 576 | |
577 | - if ( $save ) { |
|
578 | - $this->save_payment_method_checkbox(); |
|
579 | - } |
|
577 | + if ( $save ) { |
|
578 | + $this->save_payment_method_checkbox(); |
|
579 | + } |
|
580 | 580 | |
581 | - ?> |
|
581 | + ?> |
|
582 | 582 | </div> |
583 | 583 | |
584 | 584 | </div> |
585 | 585 | <?php |
586 | 586 | |
587 | - return ob_get_clean(); |
|
587 | + return ob_get_clean(); |
|
588 | + |
|
589 | + } |
|
590 | + |
|
591 | + /** |
|
592 | + * Displays a new payment method entry form. |
|
593 | + * |
|
594 | + * @since 1.0.19 |
|
595 | + */ |
|
596 | + public function new_payment_method_entry( $form ) { |
|
597 | + echo "<div class='getpaid-new-payment-method-form' style='display:none;'> " . wp_kses( $form, getpaid_allowed_html() ) . " . </div>"; |
|
598 | + } |
|
599 | + |
|
600 | + /** |
|
601 | + * Grab and display our saved payment methods. |
|
602 | + * |
|
603 | + * @since 1.0.19 |
|
604 | + */ |
|
605 | + public function saved_payment_methods() { |
|
606 | + echo '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
607 | + |
|
608 | + foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
609 | + $this->get_saved_payment_method_option_html( $token ); |
|
610 | + } |
|
611 | + |
|
612 | + $this->get_new_payment_method_option_html(); |
|
613 | + echo '</ul>'; |
|
588 | 614 | |
589 | 615 | } |
590 | 616 | |
591 | - /** |
|
592 | - * Displays a new payment method entry form. |
|
593 | - * |
|
594 | - * @since 1.0.19 |
|
595 | - */ |
|
596 | - public function new_payment_method_entry( $form ) { |
|
597 | - echo "<div class='getpaid-new-payment-method-form' style='display:none;'> " . wp_kses( $form, getpaid_allowed_html() ) . " . </div>"; |
|
598 | - } |
|
599 | - |
|
600 | - /** |
|
601 | - * Grab and display our saved payment methods. |
|
602 | - * |
|
603 | - * @since 1.0.19 |
|
604 | - */ |
|
605 | - public function saved_payment_methods() { |
|
606 | - echo '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
607 | - |
|
608 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
609 | - $this->get_saved_payment_method_option_html( $token ); |
|
610 | - } |
|
611 | - |
|
612 | - $this->get_new_payment_method_option_html(); |
|
613 | - echo '</ul>'; |
|
614 | - |
|
615 | - } |
|
616 | - |
|
617 | - /** |
|
618 | - * Gets saved payment method HTML from a token. |
|
619 | - * |
|
620 | - * @since 1.0.19 |
|
621 | - * @param array $token Payment Token. |
|
622 | - * @return string Generated payment method HTML |
|
623 | - */ |
|
624 | - public function get_saved_payment_method_option_html( $token ) { |
|
625 | - |
|
626 | - printf( |
|
627 | - '<li class="getpaid-payment-method form-group"> |
|
617 | + /** |
|
618 | + * Gets saved payment method HTML from a token. |
|
619 | + * |
|
620 | + * @since 1.0.19 |
|
621 | + * @param array $token Payment Token. |
|
622 | + * @return string Generated payment method HTML |
|
623 | + */ |
|
624 | + public function get_saved_payment_method_option_html( $token ) { |
|
625 | + |
|
626 | + printf( |
|
627 | + '<li class="getpaid-payment-method form-group"> |
|
628 | 628 | <label> |
629 | 629 | <input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" data-currency="%5$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s /> |
630 | 630 | <span>%3$s</span> |
631 | 631 | </label> |
632 | 632 | </li>', |
633 | - esc_attr( $this->id ), |
|
634 | - esc_attr( $token['id'] ), |
|
635 | - esc_html( $token['name'] ), |
|
636 | - checked( empty( $token['default'] ), false, false ), |
|
637 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
638 | - ); |
|
639 | - |
|
640 | - } |
|
641 | - |
|
642 | - /** |
|
643 | - * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
644 | - * |
|
645 | - * @since 1.0.19 |
|
646 | - */ |
|
647 | - public function get_new_payment_method_option_html() { |
|
648 | - |
|
649 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
650 | - |
|
651 | - printf( |
|
652 | - '<li class="getpaid-new-payment-method"> |
|
633 | + esc_attr( $this->id ), |
|
634 | + esc_attr( $token['id'] ), |
|
635 | + esc_html( $token['name'] ), |
|
636 | + checked( empty( $token['default'] ), false, false ), |
|
637 | + empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
638 | + ); |
|
639 | + |
|
640 | + } |
|
641 | + |
|
642 | + /** |
|
643 | + * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
644 | + * |
|
645 | + * @since 1.0.19 |
|
646 | + */ |
|
647 | + public function get_new_payment_method_option_html() { |
|
648 | + |
|
649 | + $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
650 | + |
|
651 | + printf( |
|
652 | + '<li class="getpaid-new-payment-method"> |
|
653 | 653 | <label> |
654 | 654 | <input name="getpaid-%1$s-payment-method" type="radio" data-currency="none" value="new" style="width:auto;" /> |
655 | 655 | <span>%2$s</span> |
656 | 656 | </label> |
657 | 657 | </li>', |
658 | - esc_attr( $this->id ), |
|
659 | - esc_html( $label ) |
|
660 | - ); |
|
661 | - |
|
662 | - } |
|
663 | - |
|
664 | - /** |
|
665 | - * Outputs a checkbox for saving a new payment method to the database. |
|
666 | - * |
|
667 | - * @since 1.0.19 |
|
668 | - */ |
|
669 | - public function save_payment_method_checkbox() { |
|
670 | - |
|
671 | - aui()->input( |
|
672 | - array( |
|
673 | - 'type' => 'checkbox', |
|
674 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
675 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
676 | - 'required' => false, |
|
677 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
678 | - 'value' => 'true', |
|
679 | - 'checked' => true, |
|
680 | - 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
681 | - ), |
|
682 | - true |
|
683 | - ); |
|
684 | - |
|
685 | - } |
|
686 | - |
|
687 | - /** |
|
688 | - * Registers the gateway. |
|
689 | - * |
|
690 | - * @return array |
|
691 | - */ |
|
692 | - public function register_gateway( $gateways ) { |
|
693 | - |
|
694 | - $gateways[ $this->id ] = array( |
|
695 | - |
|
696 | - 'admin_label' => $this->method_title, |
|
658 | + esc_attr( $this->id ), |
|
659 | + esc_html( $label ) |
|
660 | + ); |
|
661 | + |
|
662 | + } |
|
663 | + |
|
664 | + /** |
|
665 | + * Outputs a checkbox for saving a new payment method to the database. |
|
666 | + * |
|
667 | + * @since 1.0.19 |
|
668 | + */ |
|
669 | + public function save_payment_method_checkbox() { |
|
670 | + |
|
671 | + aui()->input( |
|
672 | + array( |
|
673 | + 'type' => 'checkbox', |
|
674 | + 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
675 | + 'id' => esc_attr( uniqid( $this->id ) ), |
|
676 | + 'required' => false, |
|
677 | + 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
678 | + 'value' => 'true', |
|
679 | + 'checked' => true, |
|
680 | + 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
681 | + ), |
|
682 | + true |
|
683 | + ); |
|
684 | + |
|
685 | + } |
|
686 | + |
|
687 | + /** |
|
688 | + * Registers the gateway. |
|
689 | + * |
|
690 | + * @return array |
|
691 | + */ |
|
692 | + public function register_gateway( $gateways ) { |
|
693 | + |
|
694 | + $gateways[ $this->id ] = array( |
|
695 | + |
|
696 | + 'admin_label' => $this->method_title, |
|
697 | 697 | 'checkout_label' => $this->title, |
698 | - 'ordering' => $this->order, |
|
698 | + 'ordering' => $this->order, |
|
699 | 699 | |
700 | - ); |
|
700 | + ); |
|
701 | 701 | |
702 | - return $gateways; |
|
702 | + return $gateways; |
|
703 | 703 | |
704 | - } |
|
704 | + } |
|
705 | 705 | |
706 | - /** |
|
707 | - * Checks whether or not this is a sandbox request. |
|
708 | - * |
|
709 | - * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
710 | - * @return bool |
|
711 | - */ |
|
712 | - public function is_sandbox( $invoice = null ) { |
|
706 | + /** |
|
707 | + * Checks whether or not this is a sandbox request. |
|
708 | + * |
|
709 | + * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
710 | + * @return bool |
|
711 | + */ |
|
712 | + public function is_sandbox( $invoice = null ) { |
|
713 | 713 | |
714 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
715 | - return $invoice->get_mode() == 'test'; |
|
716 | - } |
|
714 | + if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
715 | + return $invoice->get_mode() == 'test'; |
|
716 | + } |
|
717 | 717 | |
718 | - return wpinv_is_test_mode( $this->id ); |
|
718 | + return wpinv_is_test_mode( $this->id ); |
|
719 | 719 | |
720 | - } |
|
720 | + } |
|
721 | 721 | |
722 | - /** |
|
723 | - * Renames the checkout button |
|
724 | - * |
|
725 | - * @return string |
|
726 | - */ |
|
727 | - public function rename_checkout_button() { |
|
728 | - return $this->checkout_button_text; |
|
729 | - } |
|
722 | + /** |
|
723 | + * Renames the checkout button |
|
724 | + * |
|
725 | + * @return string |
|
726 | + */ |
|
727 | + public function rename_checkout_button() { |
|
728 | + return $this->checkout_button_text; |
|
729 | + } |
|
730 | 730 | |
731 | - /** |
|
732 | - * Validate gateway currency |
|
733 | - * |
|
734 | - * @return bool |
|
735 | - */ |
|
736 | - public function validate_currency( $validation, $currency ) { |
|
731 | + /** |
|
732 | + * Validate gateway currency |
|
733 | + * |
|
734 | + * @return bool |
|
735 | + */ |
|
736 | + public function validate_currency( $validation, $currency ) { |
|
737 | 737 | |
738 | - // Required currencies. |
|
739 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
740 | - return false; |
|
741 | - } |
|
738 | + // Required currencies. |
|
739 | + if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
740 | + return false; |
|
741 | + } |
|
742 | 742 | |
743 | - // Excluded currencies. |
|
744 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
745 | - return false; |
|
746 | - } |
|
743 | + // Excluded currencies. |
|
744 | + if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
745 | + return false; |
|
746 | + } |
|
747 | 747 | |
748 | - return $validation; |
|
749 | - } |
|
748 | + return $validation; |
|
749 | + } |
|
750 | 750 | |
751 | - /** |
|
752 | - * Displays an error |
|
753 | - * |
|
754 | - */ |
|
755 | - public function show_error( $code, $message, $type ) { |
|
751 | + /** |
|
752 | + * Displays an error |
|
753 | + * |
|
754 | + */ |
|
755 | + public function show_error( $code, $message, $type ) { |
|
756 | 756 | |
757 | - if ( is_admin() ) { |
|
758 | - getpaid_admin()->{"show_$type"}( $message ); |
|
759 | - } |
|
757 | + if ( is_admin() ) { |
|
758 | + getpaid_admin()->{"show_$type"}( $message ); |
|
759 | + } |
|
760 | 760 | |
761 | - wpinv_set_error( $code, $message, $type ); |
|
761 | + wpinv_set_error( $code, $message, $type ); |
|
762 | 762 | |
763 | - } |
|
763 | + } |
|
764 | 764 | |
765 | 765 | } |
@@ -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 | * Abstaract Payment Gateway class. |
@@ -139,50 +139,50 @@ discard block |
||
139 | 139 | public function __construct() { |
140 | 140 | |
141 | 141 | // Register gateway. |
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
142 | + add_filter('wpinv_payment_gateways', array($this, 'register_gateway')); |
|
143 | 143 | |
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
144 | + $this->enabled = wpinv_is_gateway_active($this->id); |
|
145 | 145 | |
146 | 146 | // Add support for various features. |
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | - add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
147 | + foreach ($this->supports as $feature) { |
|
148 | + add_filter("wpinv_{$this->id}_support_{$feature}", '__return_true'); |
|
149 | + add_filter("getpaid_{$this->id}_support_{$feature}", '__return_true'); |
|
150 | + add_filter("getpaid_{$this->id}_supports_{$feature}", '__return_true'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Invoice addons. |
154 | - if ( $this->supports( 'addons' ) ) { |
|
155 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
154 | + if ($this->supports('addons')) { |
|
155 | + add_action("getpaid_process_{$this->id}_invoice_addons", array($this, 'process_addons'), 10, 2); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // Gateway settings. |
159 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
159 | + add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings')); |
|
160 | 160 | |
161 | 161 | // Gateway checkout fiellds. |
162 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
162 | + add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2); |
|
163 | 163 | |
164 | 164 | // Process payment. |
165 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
165 | + add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3); |
|
166 | 166 | |
167 | 167 | // Change the checkout button text. |
168 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
169 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
168 | + if (!empty($this->checkout_button_text)) { |
|
169 | + add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button')); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | // Check if a gateway is valid for a given currency. |
173 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
173 | + add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2); |
|
174 | 174 | |
175 | 175 | // Generate the transaction url. |
176 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
176 | + add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2); |
|
177 | 177 | |
178 | 178 | // Generate the subscription url. |
179 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
179 | + add_filter('getpaid_remote_subscription_profile_url', array($this, 'generate_subscription_url'), 10, 2); |
|
180 | 180 | |
181 | 181 | // Confirm payments. |
182 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
182 | + add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2); |
|
183 | 183 | |
184 | 184 | // Verify IPNs. |
185 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
185 | + add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn')); |
|
186 | 186 | |
187 | 187 | } |
188 | 188 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @since 1.0.19 |
193 | 193 | * @return bool |
194 | 194 | */ |
195 | - public function is( $gateway ) { |
|
195 | + public function is($gateway) { |
|
196 | 196 | return $gateway == $this->id; |
197 | 197 | } |
198 | 198 | |
@@ -202,23 +202,23 @@ discard block |
||
202 | 202 | * @since 1.0.19 |
203 | 203 | * @return array |
204 | 204 | */ |
205 | - public function get_tokens( $sandbox = null ) { |
|
205 | + public function get_tokens($sandbox = null) { |
|
206 | 206 | |
207 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
208 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
207 | + if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) { |
|
208 | + $tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true); |
|
209 | 209 | |
210 | - if ( is_array( $tokens ) ) { |
|
210 | + if (is_array($tokens)) { |
|
211 | 211 | $this->tokens = $tokens; |
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - if ( ! is_bool( $sandbox ) ) { |
|
215 | + if (!is_bool($sandbox)) { |
|
216 | 216 | return $this->tokens; |
217 | 217 | } |
218 | 218 | |
219 | 219 | // Filter tokens. |
220 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | - return wp_list_filter( $this->tokens, $args ); |
|
220 | + $args = array('type' => $sandbox ? 'sandbox' : 'live'); |
|
221 | + return wp_list_filter($this->tokens, $args); |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @since 1.0.19 |
229 | 229 | */ |
230 | - public function save_token( $token ) { |
|
230 | + public function save_token($token) { |
|
231 | 231 | |
232 | 232 | $tokens = $this->get_tokens(); |
233 | 233 | $tokens[] = $token; |
234 | 234 | |
235 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
235 | + update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens); |
|
236 | 236 | |
237 | 237 | $this->tokens = $tokens; |
238 | 238 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @return string |
245 | 245 | */ |
246 | 246 | public function get_method_title() { |
247 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
247 | + return apply_filters('getpaid_gateway_method_title', $this->method_title, $this); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @return string |
254 | 254 | */ |
255 | 255 | public function get_method_description() { |
256 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
256 | + return apply_filters('getpaid_gateway_method_description', $this->method_description, $this); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param WPInv_Invoice $invoice Invoice object. |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public function get_return_url( $invoice ) { |
|
265 | + public function get_return_url($invoice) { |
|
266 | 266 | |
267 | 267 | // Payment success url |
268 | 268 | $return_url = add_query_arg( |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | wpinv_get_success_page_uri() |
275 | 275 | ); |
276 | 276 | |
277 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
277 | + return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -283,24 +283,24 @@ discard block |
||
283 | 283 | * @param string $content Success page content. |
284 | 284 | * @return string |
285 | 285 | */ |
286 | - public function confirm_payment( $content ) { |
|
286 | + public function confirm_payment($content) { |
|
287 | 287 | |
288 | 288 | // Retrieve the invoice. |
289 | 289 | $invoice_id = getpaid_get_current_invoice_id(); |
290 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
290 | + $invoice = wpinv_get_invoice($invoice_id); |
|
291 | 291 | |
292 | 292 | // Ensure that it exists and that it is pending payment. |
293 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
293 | + if (empty($invoice_id) || !$invoice->needs_payment()) { |
|
294 | 294 | return $content; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Can the user view this invoice?? |
298 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
298 | + if (!wpinv_user_can_view_invoice($invoice)) { |
|
299 | 299 | return $content; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Show payment processing indicator. |
303 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
303 | + return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice')); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @param GetPaid_Form_Item[] $items |
318 | 318 | * @return WPInv_Invoice |
319 | 319 | */ |
320 | - public function process_addons( $invoice, $items ) { |
|
320 | + public function process_addons($invoice, $items) { |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | * @param WPInv_Invoice $invoice Invoice object. |
329 | 329 | * @return string transaction URL, or empty string. |
330 | 330 | */ |
331 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
331 | + public function filter_transaction_url($transaction_url, $invoice) { |
|
332 | 332 | |
333 | - $transaction_id = $invoice->get_transaction_id(); |
|
333 | + $transaction_id = $invoice->get_transaction_id(); |
|
334 | 334 | |
335 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
336 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
337 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
338 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
335 | + if (!empty($this->view_transaction_url) && !empty($transaction_id)) { |
|
336 | + $transaction_url = sprintf($this->view_transaction_url, $transaction_id); |
|
337 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
338 | + $transaction_url = str_replace('{sandbox}', $replace, $transaction_url); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $transaction_url; |
@@ -348,15 +348,15 @@ discard block |
||
348 | 348 | * @param WPInv_Subscription $subscription Subscription objectt. |
349 | 349 | * @return string subscription URL, or empty string. |
350 | 350 | */ |
351 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
351 | + public function generate_subscription_url($subscription_url, $subscription) { |
|
352 | 352 | |
353 | - $profile_id = $subscription->get_profile_id(); |
|
353 | + $profile_id = $subscription->get_profile_id(); |
|
354 | 354 | |
355 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
355 | + if ($this->id == $subscription->get_gateway() && !empty($this->view_subscription_url) && !empty($profile_id)) { |
|
356 | 356 | |
357 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
358 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
359 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
357 | + $subscription_url = sprintf($this->view_subscription_url, $profile_id); |
|
358 | + $replace = $this->is_sandbox($subscription->get_parent_invoice()) ? 'sandbox' : ''; |
|
359 | + $subscription_url = str_replace('{sandbox}', $replace, $subscription_url); |
|
360 | 360 | |
361 | 361 | } |
362 | 362 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * @return bool |
370 | 370 | */ |
371 | 371 | public function is_available() { |
372 | - return ! empty( $this->enabled ); |
|
372 | + return !empty($this->enabled); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @return string |
379 | 379 | */ |
380 | 380 | public function get_title() { |
381 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
381 | + return apply_filters('getpaid_gateway_title', $this->title, $this); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * @return string |
388 | 388 | */ |
389 | 389 | public function get_description() { |
390 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
390 | + return apply_filters('getpaid_gateway_description', $this->description, $this); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
@@ -399,9 +399,9 @@ discard block |
||
399 | 399 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
400 | 400 | * @return void |
401 | 401 | */ |
402 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
402 | + public function process_payment($invoice, $submission_data, $submission) { |
|
403 | 403 | // Process the payment then either redirect to the success page or the gateway. |
404 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
404 | + do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | * @param string $reason Refund reason. |
416 | 416 | * @return WP_Error|bool True or false based on success, or a WP_Error object. |
417 | 417 | */ |
418 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
418 | + public function process_refund($invoice, $amount = null, $reason = '') { |
|
419 | + return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * @param int $invoice_id 0 or invoice id. |
426 | 426 | * @param GetPaid_Payment_Form $form Current payment form. |
427 | 427 | */ |
428 | - public function payment_fields( $invoice_id, $form ) { |
|
429 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
428 | + public function payment_fields($invoice_id, $form) { |
|
429 | + do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * |
435 | 435 | * @param array $admin_settings |
436 | 436 | */ |
437 | - public function admin_settings( $admin_settings ) { |
|
437 | + public function admin_settings($admin_settings) { |
|
438 | 438 | return $admin_settings; |
439 | 439 | } |
440 | 440 | |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @param string $option |
445 | 445 | */ |
446 | - public function get_option( $option, $default = false ) { |
|
447 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
446 | + public function get_option($option, $default = false) { |
|
447 | + return wpinv_get_option($this->id . '_' . $option, $default); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | * @return bool True if the gateway supports the feature, false otherwise. |
458 | 458 | * @since 1.0.19 |
459 | 459 | */ |
460 | - public function supports( $feature ) { |
|
461 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
460 | + public function supports($feature) { |
|
461 | + return getpaid_payment_gateway_supports($this->id, $feature); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -466,36 +466,36 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @param bool $save whether or not to display the save button. |
468 | 468 | */ |
469 | - public function get_cc_form( $save = false ) { |
|
469 | + public function get_cc_form($save = false) { |
|
470 | 470 | |
471 | 471 | ob_start(); |
472 | 472 | |
473 | - $id_prefix = esc_attr( uniqid( $this->id ) ); |
|
473 | + $id_prefix = esc_attr(uniqid($this->id)); |
|
474 | 474 | |
475 | 475 | $months = array( |
476 | - '01' => __( 'January', 'invoicing' ), |
|
477 | - '02' => __( 'February', 'invoicing' ), |
|
478 | - '03' => __( 'March', 'invoicing' ), |
|
479 | - '04' => __( 'April', 'invoicing' ), |
|
480 | - '05' => __( 'May', 'invoicing' ), |
|
481 | - '06' => __( 'June', 'invoicing' ), |
|
482 | - '07' => __( 'July', 'invoicing' ), |
|
483 | - '08' => __( 'August', 'invoicing' ), |
|
484 | - '09' => __( 'September', 'invoicing' ), |
|
485 | - '10' => __( 'October', 'invoicing' ), |
|
486 | - '11' => __( 'November', 'invoicing' ), |
|
487 | - '12' => __( 'December', 'invoicing' ), |
|
476 | + '01' => __('January', 'invoicing'), |
|
477 | + '02' => __('February', 'invoicing'), |
|
478 | + '03' => __('March', 'invoicing'), |
|
479 | + '04' => __('April', 'invoicing'), |
|
480 | + '05' => __('May', 'invoicing'), |
|
481 | + '06' => __('June', 'invoicing'), |
|
482 | + '07' => __('July', 'invoicing'), |
|
483 | + '08' => __('August', 'invoicing'), |
|
484 | + '09' => __('September', 'invoicing'), |
|
485 | + '10' => __('October', 'invoicing'), |
|
486 | + '11' => __('November', 'invoicing'), |
|
487 | + '12' => __('December', 'invoicing'), |
|
488 | 488 | ); |
489 | 489 | |
490 | - $year = (int) date( 'Y', current_time( 'timestamp' ) ); |
|
490 | + $year = (int) date('Y', current_time('timestamp')); |
|
491 | 491 | $years = array(); |
492 | 492 | |
493 | - for ( $i = 0; $i <= 10; $i++ ) { |
|
494 | - $years[ $year + $i ] = $year + $i; |
|
493 | + for ($i = 0; $i <= 10; $i++) { |
|
494 | + $years[$year + $i] = $year + $i; |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | ?> |
498 | - <div class="<?php echo esc_attr( $this->id ); ?>-cc-form getpaid-cc-form mt-1"> |
|
498 | + <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1"> |
|
499 | 499 | |
500 | 500 | |
501 | 501 | <div class="getpaid-cc-card-inner"> |
@@ -504,14 +504,14 @@ discard block |
||
504 | 504 | <div class="col-12"> |
505 | 505 | |
506 | 506 | <div class="form-group"> |
507 | - <label for="<?php echo esc_attr( "$id_prefix-cc-number" ); ?>"><?php esc_html_e( 'Card number', 'invoicing' ); ?></label> |
|
507 | + <label for="<?php echo esc_attr("$id_prefix-cc-number"); ?>"><?php esc_html_e('Card number', 'invoicing'); ?></label> |
|
508 | 508 | <div class="input-group input-group-sm"> |
509 | 509 | <div class="input-group-prepend "> |
510 | 510 | <span class="input-group-text"> |
511 | 511 | <i class="fa fa-credit-card"></i> |
512 | 512 | </span> |
513 | 513 | </div> |
514 | - <input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ); ?>" id="<?php echo esc_attr( "$id_prefix-cc-number" ); ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
514 | + <input type="text" name="<?php echo esc_attr($this->id . '[cc_number]'); ?>" id="<?php echo esc_attr("$id_prefix-cc-number"); ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
515 | 515 | </div> |
516 | 516 | </div> |
517 | 517 | |
@@ -519,16 +519,16 @@ discard block |
||
519 | 519 | |
520 | 520 | <div class="col-12"> |
521 | 521 | <div class="form-group"> |
522 | - <label><?php esc_html_e( 'Expiration', 'invoicing' ); ?></label> |
|
522 | + <label><?php esc_html_e('Expiration', 'invoicing'); ?></label> |
|
523 | 523 | <div class="form-row"> |
524 | 524 | |
525 | 525 | <div class="col"> |
526 | - <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr( $this->id ); ?>[cc_expire_month]"> |
|
527 | - <option disabled selected="selected"><?php esc_html_e( 'MM', 'invoicing' ); ?></option> |
|
526 | + <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]"> |
|
527 | + <option disabled selected="selected"><?php esc_html_e('MM', 'invoicing'); ?></option> |
|
528 | 528 | |
529 | 529 | <?php |
530 | - foreach ( $months as $key => $month ) { |
|
531 | - echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $month ) . "</option>" . PHP_EOL; |
|
530 | + foreach ($months as $key => $month) { |
|
531 | + echo "<option value='" . esc_attr($key) . "'>" . esc_html($month) . "</option>" . PHP_EOL; |
|
532 | 532 | } |
533 | 533 | ?> |
534 | 534 | |
@@ -536,12 +536,12 @@ discard block |
||
536 | 536 | </div> |
537 | 537 | |
538 | 538 | <div class="col"> |
539 | - <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr( $this->id ); ?>[cc_expire_year]"> |
|
540 | - <option disabled selected="selected"><?php esc_html_e( 'YY', 'invoicing' ); ?></option> |
|
539 | + <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]"> |
|
540 | + <option disabled selected="selected"><?php esc_html_e('YY', 'invoicing'); ?></option> |
|
541 | 541 | |
542 | 542 | <?php |
543 | - foreach ( $years as $key => $year ) { |
|
544 | - echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $year ) . "</option>" . PHP_EOL; |
|
543 | + foreach ($years as $key => $year) { |
|
544 | + echo "<option value='" . esc_attr($key) . "'>" . esc_html($year) . "</option>" . PHP_EOL; |
|
545 | 545 | } |
546 | 546 | ?> |
547 | 547 | |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | array( |
559 | 559 | 'name' => $this->id . '[cc_cvv2]', |
560 | 560 | 'id' => "$id_prefix-cc-cvv2", |
561 | - 'label' => __( 'CCV', 'invoicing' ), |
|
561 | + 'label' => __('CCV', 'invoicing'), |
|
562 | 562 | 'label_type' => 'vertical', |
563 | 563 | 'class' => 'form-control-sm', |
564 | 564 | 'extra_attributes' => array( |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | |
575 | 575 | <?php |
576 | 576 | |
577 | - if ( $save ) { |
|
577 | + if ($save) { |
|
578 | 578 | $this->save_payment_method_checkbox(); |
579 | 579 | } |
580 | 580 | |
@@ -593,8 +593,8 @@ discard block |
||
593 | 593 | * |
594 | 594 | * @since 1.0.19 |
595 | 595 | */ |
596 | - public function new_payment_method_entry( $form ) { |
|
597 | - echo "<div class='getpaid-new-payment-method-form' style='display:none;'> " . wp_kses( $form, getpaid_allowed_html() ) . " . </div>"; |
|
596 | + public function new_payment_method_entry($form) { |
|
597 | + echo "<div class='getpaid-new-payment-method-form' style='display:none;'> " . wp_kses($form, getpaid_allowed_html()) . " . </div>"; |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | /** |
@@ -603,10 +603,10 @@ discard block |
||
603 | 603 | * @since 1.0.19 |
604 | 604 | */ |
605 | 605 | public function saved_payment_methods() { |
606 | - echo '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
606 | + echo '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">'; |
|
607 | 607 | |
608 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
609 | - $this->get_saved_payment_method_option_html( $token ); |
|
608 | + foreach ($this->get_tokens($this->is_sandbox()) as $token) { |
|
609 | + $this->get_saved_payment_method_option_html($token); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | $this->get_new_payment_method_option_html(); |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | * @param array $token Payment Token. |
622 | 622 | * @return string Generated payment method HTML |
623 | 623 | */ |
624 | - public function get_saved_payment_method_option_html( $token ) { |
|
624 | + public function get_saved_payment_method_option_html($token) { |
|
625 | 625 | |
626 | 626 | printf( |
627 | 627 | '<li class="getpaid-payment-method form-group"> |
@@ -630,11 +630,11 @@ discard block |
||
630 | 630 | <span>%3$s</span> |
631 | 631 | </label> |
632 | 632 | </li>', |
633 | - esc_attr( $this->id ), |
|
634 | - esc_attr( $token['id'] ), |
|
635 | - esc_html( $token['name'] ), |
|
636 | - checked( empty( $token['default'] ), false, false ), |
|
637 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
633 | + esc_attr($this->id), |
|
634 | + esc_attr($token['id']), |
|
635 | + esc_html($token['name']), |
|
636 | + checked(empty($token['default']), false, false), |
|
637 | + empty($token['currency']) ? 'none' : esc_attr($token['currency']) |
|
638 | 638 | ); |
639 | 639 | |
640 | 640 | } |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | */ |
647 | 647 | public function get_new_payment_method_option_html() { |
648 | 648 | |
649 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
649 | + $label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this); |
|
650 | 650 | |
651 | 651 | printf( |
652 | 652 | '<li class="getpaid-new-payment-method"> |
@@ -655,8 +655,8 @@ discard block |
||
655 | 655 | <span>%2$s</span> |
656 | 656 | </label> |
657 | 657 | </li>', |
658 | - esc_attr( $this->id ), |
|
659 | - esc_html( $label ) |
|
658 | + esc_attr($this->id), |
|
659 | + esc_html($label) |
|
660 | 660 | ); |
661 | 661 | |
662 | 662 | } |
@@ -671,10 +671,10 @@ discard block |
||
671 | 671 | aui()->input( |
672 | 672 | array( |
673 | 673 | 'type' => 'checkbox', |
674 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
675 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
674 | + 'name' => esc_attr("getpaid-$this->id-new-payment-method"), |
|
675 | + 'id' => esc_attr(uniqid($this->id)), |
|
676 | 676 | 'required' => false, |
677 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
677 | + 'label' => esc_html__('Save payment method', 'invoicing'), |
|
678 | 678 | 'value' => 'true', |
679 | 679 | 'checked' => true, |
680 | 680 | 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
@@ -689,9 +689,9 @@ discard block |
||
689 | 689 | * |
690 | 690 | * @return array |
691 | 691 | */ |
692 | - public function register_gateway( $gateways ) { |
|
692 | + public function register_gateway($gateways) { |
|
693 | 693 | |
694 | - $gateways[ $this->id ] = array( |
|
694 | + $gateways[$this->id] = array( |
|
695 | 695 | |
696 | 696 | 'admin_label' => $this->method_title, |
697 | 697 | 'checkout_label' => $this->title, |
@@ -709,13 +709,13 @@ discard block |
||
709 | 709 | * @param WPInv_Invoice|null $invoice Invoice object or null. |
710 | 710 | * @return bool |
711 | 711 | */ |
712 | - public function is_sandbox( $invoice = null ) { |
|
712 | + public function is_sandbox($invoice = null) { |
|
713 | 713 | |
714 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
714 | + if (!empty($invoice) && !$invoice->needs_payment()) { |
|
715 | 715 | return $invoice->get_mode() == 'test'; |
716 | 716 | } |
717 | 717 | |
718 | - return wpinv_is_test_mode( $this->id ); |
|
718 | + return wpinv_is_test_mode($this->id); |
|
719 | 719 | |
720 | 720 | } |
721 | 721 | |
@@ -733,15 +733,15 @@ discard block |
||
733 | 733 | * |
734 | 734 | * @return bool |
735 | 735 | */ |
736 | - public function validate_currency( $validation, $currency ) { |
|
736 | + public function validate_currency($validation, $currency) { |
|
737 | 737 | |
738 | 738 | // Required currencies. |
739 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
739 | + if (!empty($this->currencies) && !in_array($currency, $this->currencies)) { |
|
740 | 740 | return false; |
741 | 741 | } |
742 | 742 | |
743 | 743 | // Excluded currencies. |
744 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
744 | + if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) { |
|
745 | 745 | return false; |
746 | 746 | } |
747 | 747 | |
@@ -752,13 +752,13 @@ discard block |
||
752 | 752 | * Displays an error |
753 | 753 | * |
754 | 754 | */ |
755 | - public function show_error( $code, $message, $type ) { |
|
755 | + public function show_error($code, $message, $type) { |
|
756 | 756 | |
757 | - if ( is_admin() ) { |
|
758 | - getpaid_admin()->{"show_$type"}( $message ); |
|
757 | + if (is_admin()) { |
|
758 | + getpaid_admin()->{"show_$type"}($message); |
|
759 | 759 | } |
760 | 760 | |
761 | - wpinv_set_error( $code, $message, $type ); |
|
761 | + wpinv_set_error($code, $message, $type); |
|
762 | 762 | |
763 | 763 | } |
764 | 764 |