@@ -43,64 +43,64 @@ discard block |
||
43 | 43 | <td class="w-75"> |
44 | 44 | <?php |
45 | 45 | |
46 | - switch ( $key ) { |
|
46 | + switch ( $key ) { |
|
47 | 47 | |
48 | - case 'status': |
|
49 | - echo sanitize_text_field( $subscription->get_status_label() ); |
|
50 | - break; |
|
48 | + case 'status': |
|
49 | + echo sanitize_text_field( $subscription->get_status_label() ); |
|
50 | + break; |
|
51 | 51 | |
52 | - case 'start_date': |
|
53 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
54 | - break; |
|
52 | + case 'start_date': |
|
53 | + echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
54 | + break; |
|
55 | 55 | |
56 | - case 'expiry_date': |
|
57 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) ); |
|
58 | - break; |
|
56 | + case 'expiry_date': |
|
57 | + echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) ); |
|
58 | + break; |
|
59 | 59 | |
60 | - case 'initial_amount': |
|
61 | - echo wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
60 | + case 'initial_amount': |
|
61 | + echo wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
62 | 62 | |
63 | - if ( $subscription->has_trial_period() ) { |
|
63 | + if ( $subscription->has_trial_period() ) { |
|
64 | 64 | |
65 | - echo "<small class='text-muted'> "; |
|
66 | - printf( |
|
67 | - _x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ), |
|
68 | - sanitize_text_field( $subscription->get_trial_period() ) |
|
69 | - ); |
|
70 | - echo '</small>'; |
|
65 | + echo "<small class='text-muted'> "; |
|
66 | + printf( |
|
67 | + _x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ), |
|
68 | + sanitize_text_field( $subscription->get_trial_period() ) |
|
69 | + ); |
|
70 | + echo '</small>'; |
|
71 | 71 | |
72 | - } |
|
72 | + } |
|
73 | 73 | |
74 | - break; |
|
74 | + break; |
|
75 | 75 | |
76 | - case 'recurring_amount': |
|
77 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
78 | - $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
79 | - echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / $frequency" ); |
|
80 | - break; |
|
76 | + case 'recurring_amount': |
|
77 | + $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
78 | + $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
79 | + echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / $frequency" ); |
|
80 | + break; |
|
81 | 81 | |
82 | - case 'item': |
|
83 | - $item = get_post( $subscription->get_product_id() ); |
|
82 | + case 'item': |
|
83 | + $item = get_post( $subscription->get_product_id() ); |
|
84 | 84 | |
85 | - if ( ! empty( $item ) ) { |
|
86 | - echo esc_html( get_the_title( $item ) ); |
|
87 | - } else { |
|
88 | - echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
89 | - } |
|
85 | + if ( ! empty( $item ) ) { |
|
86 | + echo esc_html( get_the_title( $item ) ); |
|
87 | + } else { |
|
88 | + echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
89 | + } |
|
90 | 90 | |
91 | - break; |
|
91 | + break; |
|
92 | 92 | |
93 | - case 'payments': |
|
93 | + case 'payments': |
|
94 | 94 | |
95 | - $max_activations = (int) $subscription->get_bill_times(); |
|
96 | - echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "∞" : $max_activations ); |
|
95 | + $max_activations = (int) $subscription->get_bill_times(); |
|
96 | + echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "∞" : $max_activations ); |
|
97 | 97 | |
98 | - break; |
|
98 | + break; |
|
99 | 99 | |
100 | - } |
|
101 | - do_action( "getpaid_render_single_subscription_column_$key", $subscription ); |
|
100 | + } |
|
101 | + do_action( "getpaid_render_single_subscription_column_$key", $subscription ); |
|
102 | 102 | |
103 | - ?> |
|
103 | + ?> |
|
104 | 104 | </td> |
105 | 105 | |
106 | 106 | </tr> |
@@ -117,17 +117,17 @@ discard block |
||
117 | 117 | <span class="form-text"> |
118 | 118 | |
119 | 119 | <?php |
120 | - if ( $subscription->can_cancel() ) { |
|
121 | - printf( |
|
122 | - '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a> ', |
|
123 | - esc_url( $subscription->get_cancel_url() ), |
|
124 | - esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ), |
|
125 | - __( 'Cancel Subscription', 'invoicing' ) |
|
126 | - ); |
|
127 | - } |
|
128 | - |
|
129 | - do_action( 'getpaid-single-subscription-page-actions', $subscription ); |
|
130 | - ?> |
|
120 | + if ( $subscription->can_cancel() ) { |
|
121 | + printf( |
|
122 | + '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a> ', |
|
123 | + esc_url( $subscription->get_cancel_url() ), |
|
124 | + esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ), |
|
125 | + __( 'Cancel Subscription', 'invoicing' ) |
|
126 | + ); |
|
127 | + } |
|
128 | + |
|
129 | + do_action( 'getpaid-single-subscription-page-actions', $subscription ); |
|
130 | + ?> |
|
131 | 131 | |
132 | 132 | <a href="<?php echo esc_url( getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); ?>" class="btn btn-secondary btn-sm"><?php _e( 'Go Back', 'invoicing' ); ?></a> |
133 | 133 | </span> |
134 | 134 | \ No newline at end of file |
@@ -9,14 +9,14 @@ discard block |
||
9 | 9 | * @var WPInv_Subscriptions_Widget $widget |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | -do_action( 'getpaid_single_subscription_before_notices', $subscription ); |
|
14 | +do_action('getpaid_single_subscription_before_notices', $subscription); |
|
15 | 15 | |
16 | 16 | // Display errors and notices. |
17 | 17 | wpinv_print_errors(); |
18 | 18 | |
19 | -do_action( 'getpaid_before_single_subscription', $subscription ); |
|
19 | +do_action('getpaid_before_single_subscription', $subscription); |
|
20 | 20 | |
21 | 21 | ?> |
22 | 22 | |
@@ -28,44 +28,44 @@ discard block |
||
28 | 28 | |
29 | 29 | </style> |
30 | 30 | |
31 | -<h2 class="mb-1 h4"><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
|
31 | +<h2 class="mb-1 h4"><?php _e('Subscription Details', 'invoicing'); ?></h2> |
|
32 | 32 | <table class="table table-bordered"> |
33 | 33 | <tbody> |
34 | 34 | |
35 | - <?php foreach ( $widget->get_single_subscription_columns( $subscription ) as $key => $label ) : ?> |
|
35 | + <?php foreach ($widget->get_single_subscription_columns($subscription) as $key => $label) : ?> |
|
36 | 36 | |
37 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
37 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
38 | 38 | |
39 | 39 | <th class="w-25 font-weight-bold"> |
40 | - <?php echo sanitize_text_field( $label ); ?> |
|
40 | + <?php echo sanitize_text_field($label); ?> |
|
41 | 41 | </th> |
42 | 42 | |
43 | 43 | <td class="w-75"> |
44 | 44 | <?php |
45 | 45 | |
46 | - switch ( $key ) { |
|
46 | + switch ($key) { |
|
47 | 47 | |
48 | 48 | case 'status': |
49 | - echo sanitize_text_field( $subscription->get_status_label() ); |
|
49 | + echo sanitize_text_field($subscription->get_status_label()); |
|
50 | 50 | break; |
51 | 51 | |
52 | 52 | case 'start_date': |
53 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
53 | + echo sanitize_text_field(getpaid_format_date_value($subscription->get_date_created())); |
|
54 | 54 | break; |
55 | 55 | |
56 | 56 | case 'expiry_date': |
57 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) ); |
|
57 | + echo sanitize_text_field(getpaid_format_date_value($subscription->get_next_renewal_date())); |
|
58 | 58 | break; |
59 | 59 | |
60 | 60 | case 'initial_amount': |
61 | - echo wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
61 | + echo wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency()); |
|
62 | 62 | |
63 | - if ( $subscription->has_trial_period() ) { |
|
63 | + if ($subscription->has_trial_period()) { |
|
64 | 64 | |
65 | 65 | echo "<small class='text-muted'> "; |
66 | 66 | printf( |
67 | - _x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ), |
|
68 | - sanitize_text_field( $subscription->get_trial_period() ) |
|
67 | + _x('( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing'), |
|
68 | + sanitize_text_field($subscription->get_trial_period()) |
|
69 | 69 | ); |
70 | 70 | echo '</small>'; |
71 | 71 | |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | break; |
75 | 75 | |
76 | 76 | case 'recurring_amount': |
77 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
78 | - $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
79 | - echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / $frequency" ); |
|
77 | + $frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
78 | + $amount = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()); |
|
79 | + echo strtolower("<strong style='font-weight: 500;'>$amount</strong> / $frequency"); |
|
80 | 80 | break; |
81 | 81 | |
82 | 82 | case 'item': |
83 | - $item = get_post( $subscription->get_product_id() ); |
|
83 | + $item = get_post($subscription->get_product_id()); |
|
84 | 84 | |
85 | - if ( ! empty( $item ) ) { |
|
86 | - echo esc_html( get_the_title( $item ) ); |
|
85 | + if (!empty($item)) { |
|
86 | + echo esc_html(get_the_title($item)); |
|
87 | 87 | } else { |
88 | - echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
88 | + echo sprintf(__('Item #%s', 'invoicing'), $subscription->get_product_id()); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | break; |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | case 'payments': |
94 | 94 | |
95 | 95 | $max_activations = (int) $subscription->get_bill_times(); |
96 | - echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "∞" : $max_activations ); |
|
96 | + echo (int) $subscription->get_times_billed() . ' / ' . (empty($max_activations) ? "∞" : $max_activations); |
|
97 | 97 | |
98 | 98 | break; |
99 | 99 | |
100 | 100 | } |
101 | - do_action( "getpaid_render_single_subscription_column_$key", $subscription ); |
|
101 | + do_action("getpaid_render_single_subscription_column_$key", $subscription); |
|
102 | 102 | |
103 | 103 | ?> |
104 | 104 | </td> |
@@ -110,24 +110,24 @@ discard block |
||
110 | 110 | </tbody> |
111 | 111 | </table> |
112 | 112 | |
113 | -<h2 class='mt-5 mb-1 h4'><?php _e( 'Subscription Invoices', 'invoicing' ); ?></h2> |
|
113 | +<h2 class='mt-5 mb-1 h4'><?php _e('Subscription Invoices', 'invoicing'); ?></h2> |
|
114 | 114 | |
115 | -<?php echo getpaid_admin_subscription_invoice_details_metabox( $subscription ); ?> |
|
115 | +<?php echo getpaid_admin_subscription_invoice_details_metabox($subscription); ?> |
|
116 | 116 | |
117 | 117 | <span class="form-text"> |
118 | 118 | |
119 | 119 | <?php |
120 | - if ( $subscription->can_cancel() ) { |
|
120 | + if ($subscription->can_cancel()) { |
|
121 | 121 | printf( |
122 | 122 | '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a> ', |
123 | - esc_url( $subscription->get_cancel_url() ), |
|
124 | - esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ), |
|
125 | - __( 'Cancel Subscription', 'invoicing' ) |
|
123 | + esc_url($subscription->get_cancel_url()), |
|
124 | + esc_attr__('Are you sure you want to cancel this subscription?', 'invoicing'), |
|
125 | + __('Cancel Subscription', 'invoicing') |
|
126 | 126 | ); |
127 | 127 | } |
128 | 128 | |
129 | - do_action( 'getpaid-single-subscription-page-actions', $subscription ); |
|
129 | + do_action('getpaid-single-subscription-page-actions', $subscription); |
|
130 | 130 | ?> |
131 | 131 | |
132 | - <a href="<?php echo esc_url( getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); ?>" class="btn btn-secondary btn-sm"><?php _e( 'Go Back', 'invoicing' ); ?></a> |
|
132 | + <a href="<?php echo esc_url(getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page')))); ?>" class="btn btn-secondary btn-sm"><?php _e('Go Back', 'invoicing'); ?></a> |
|
133 | 133 | </span> |
134 | 134 | \ No newline at end of file |
@@ -13,42 +13,42 @@ |
||
13 | 13 | |
14 | 14 | foreach ( array_keys( $widget->get_subscriptions_table_columns() ) as $column ) : |
15 | 15 | |
16 | - $class = sanitize_html_class( $column ); |
|
17 | - echo "<td class='getpaid-subscriptions-table-column-$class'>"; |
|
16 | + $class = sanitize_html_class( $column ); |
|
17 | + echo "<td class='getpaid-subscriptions-table-column-$class'>"; |
|
18 | 18 | |
19 | - do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription ); |
|
19 | + do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription ); |
|
20 | 20 | |
21 | - switch( $column ) : |
|
21 | + switch( $column ) : |
|
22 | 22 | |
23 | - case 'subscription': |
|
24 | - $subscription_id = (int) $subscription->get_id(); |
|
25 | - $url = esc_url( $subscription->get_view_url() ); |
|
26 | - $id_label = sprintf( |
|
27 | - esc_attr_x( '#%s', 'subscription id', 'invoicing' ), |
|
28 | - $subscription->get_id() |
|
29 | - ); |
|
30 | - echo $widget->add_row_actions( "<a href='$url' class='font-weight-bold text-decoration-none'>$id_label</a>", $subscription ); |
|
31 | - break; |
|
23 | + case 'subscription': |
|
24 | + $subscription_id = (int) $subscription->get_id(); |
|
25 | + $url = esc_url( $subscription->get_view_url() ); |
|
26 | + $id_label = sprintf( |
|
27 | + esc_attr_x( '#%s', 'subscription id', 'invoicing' ), |
|
28 | + $subscription->get_id() |
|
29 | + ); |
|
30 | + echo $widget->add_row_actions( "<a href='$url' class='font-weight-bold text-decoration-none'>$id_label</a>", $subscription ); |
|
31 | + break; |
|
32 | 32 | |
33 | - case 'status': |
|
34 | - echo sanitize_text_field( $subscription->get_status_label() ); |
|
35 | - break; |
|
33 | + case 'status': |
|
34 | + echo sanitize_text_field( $subscription->get_status_label() ); |
|
35 | + break; |
|
36 | 36 | |
37 | - case 'renewal-date': |
|
38 | - $renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() ); |
|
39 | - echo $subscription->is_active() ? sanitize_text_field( $renewal ) : "—"; |
|
40 | - break; |
|
37 | + case 'renewal-date': |
|
38 | + $renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() ); |
|
39 | + echo $subscription->is_active() ? sanitize_text_field( $renewal ) : "—"; |
|
40 | + break; |
|
41 | 41 | |
42 | - case 'amount': |
|
43 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
44 | - $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
45 | - echo wp_kses_post( "<span>$amount</span> / $frequency" ); |
|
46 | - break; |
|
42 | + case 'amount': |
|
43 | + $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
44 | + $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
45 | + echo wp_kses_post( "<span>$amount</span> / $frequency" ); |
|
46 | + break; |
|
47 | 47 | |
48 | - endswitch; |
|
48 | + endswitch; |
|
49 | 49 | |
50 | - do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription ); |
|
50 | + do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription ); |
|
51 | 51 | |
52 | - echo '</td>'; |
|
52 | + echo '</td>'; |
|
53 | 53 | |
54 | 54 | endforeach; |
@@ -9,45 +9,45 @@ |
||
9 | 9 | * @var WPInv_Subscriptions_Widget $widget |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | -foreach ( array_keys( $widget->get_subscriptions_table_columns() ) as $column ) : |
|
14 | +foreach (array_keys($widget->get_subscriptions_table_columns()) as $column) : |
|
15 | 15 | |
16 | - $class = sanitize_html_class( $column ); |
|
16 | + $class = sanitize_html_class($column); |
|
17 | 17 | echo "<td class='getpaid-subscriptions-table-column-$class'>"; |
18 | 18 | |
19 | - do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription ); |
|
19 | + do_action("getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription); |
|
20 | 20 | |
21 | - switch( $column ) : |
|
21 | + switch ($column) : |
|
22 | 22 | |
23 | 23 | case 'subscription': |
24 | 24 | $subscription_id = (int) $subscription->get_id(); |
25 | - $url = esc_url( $subscription->get_view_url() ); |
|
25 | + $url = esc_url($subscription->get_view_url()); |
|
26 | 26 | $id_label = sprintf( |
27 | - esc_attr_x( '#%s', 'subscription id', 'invoicing' ), |
|
27 | + esc_attr_x('#%s', 'subscription id', 'invoicing'), |
|
28 | 28 | $subscription->get_id() |
29 | 29 | ); |
30 | - echo $widget->add_row_actions( "<a href='$url' class='font-weight-bold text-decoration-none'>$id_label</a>", $subscription ); |
|
30 | + echo $widget->add_row_actions("<a href='$url' class='font-weight-bold text-decoration-none'>$id_label</a>", $subscription); |
|
31 | 31 | break; |
32 | 32 | |
33 | 33 | case 'status': |
34 | - echo sanitize_text_field( $subscription->get_status_label() ); |
|
34 | + echo sanitize_text_field($subscription->get_status_label()); |
|
35 | 35 | break; |
36 | 36 | |
37 | 37 | case 'renewal-date': |
38 | - $renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() ); |
|
39 | - echo $subscription->is_active() ? sanitize_text_field( $renewal ) : "—"; |
|
38 | + $renewal = getpaid_format_date_value($subscription->get_next_renewal_date()); |
|
39 | + echo $subscription->is_active() ? sanitize_text_field($renewal) : "—"; |
|
40 | 40 | break; |
41 | 41 | |
42 | 42 | case 'amount': |
43 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
44 | - $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
45 | - echo wp_kses_post( "<span>$amount</span> / $frequency" ); |
|
43 | + $frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
44 | + $amount = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()); |
|
45 | + echo wp_kses_post("<span>$amount</span> / $frequency"); |
|
46 | 46 | break; |
47 | 47 | |
48 | 48 | endswitch; |
49 | 49 | |
50 | - do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription ); |
|
50 | + do_action("getpaid_subscriptions_frontend_subscription_table_$column", $subscription); |
|
51 | 51 | |
52 | 52 | echo '</td>'; |
53 | 53 |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Prepare the selectable items. |
13 | 13 | $selectable = array(); |
14 | -foreach ( $form->get_items() as $item ) { |
|
15 | - if ( ! $item->is_required ) { |
|
16 | - $selectable[$item->get_id()] = strip_tags( $item->get_name() . ' — ' . wpinv_price( $item->get_initial_price() ) ); |
|
14 | +foreach ($form->get_items() as $item) { |
|
15 | + if (!$item->is_required) { |
|
16 | + $selectable[$item->get_id()] = strip_tags($item->get_name() . ' — ' . wpinv_price($item->get_initial_price())); |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | -if ( empty( $selectable ) ) { |
|
20 | +if (empty($selectable)) { |
|
21 | 21 | return; |
22 | 22 | } |
23 | 23 | |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | echo aui()->select( |
28 | 28 | array( |
29 | 29 | 'name' => 'getpaid-payment-form-selected-item', |
30 | - 'id' => 'getpaid-payment-form-selected-item' . uniqid( '_' ), |
|
30 | + 'id' => 'getpaid-payment-form-selected-item' . uniqid('_'), |
|
31 | 31 | 'required' => true, |
32 | - 'label' => __( 'Select Item', 'invoicing' ), |
|
32 | + 'label' => __('Select Item', 'invoicing'), |
|
33 | 33 | 'label_type' => 'vertical', |
34 | 34 | 'inline' => false, |
35 | 35 | 'options' => $selectable, |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Prepare the selectable items. |
13 | 13 | $selectable = array(); |
14 | -foreach ( $form->get_items() as $item ) { |
|
15 | - if ( ! $item->is_required ) { |
|
16 | - $selectable[$item->get_id()] = $item->get_name() . ' — ' . wpinv_price( $item->get_initial_price() ); |
|
14 | +foreach ($form->get_items() as $item) { |
|
15 | + if (!$item->is_required) { |
|
16 | + $selectable[$item->get_id()] = $item->get_name() . ' — ' . wpinv_price($item->get_initial_price()); |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | -if ( empty( $selectable ) ) { |
|
20 | +if (empty($selectable)) { |
|
21 | 21 | return; |
22 | 22 | } |
23 | 23 | |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | echo aui()->radio( |
28 | 28 | array( |
29 | 29 | 'name' => 'getpaid-payment-form-selected-item', |
30 | - 'id' => 'getpaid-payment-form-selected-item' . uniqid( '_' ), |
|
30 | + 'id' => 'getpaid-payment-form-selected-item' . uniqid('_'), |
|
31 | 31 | 'required' => true, |
32 | - 'label' => __( 'Select Item', 'invoicing' ), |
|
32 | + 'label' => __('Select Item', 'invoicing'), |
|
33 | 33 | 'label_type' => 'vertical', |
34 | 34 | 'inline' => false, |
35 | 35 | 'options' => $selectable, |
@@ -7,29 +7,29 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Prepare the selectable items. |
13 | 13 | $selectable = array(); |
14 | -foreach ( $form->get_items() as $item ) { |
|
15 | - if ( ! $item->is_required ) { |
|
16 | - $selectable[$item->get_id()] = $item->get_name() . ' — ' . wpinv_price( $item->get_initial_price() ); |
|
14 | +foreach ($form->get_items() as $item) { |
|
15 | + if (!$item->is_required) { |
|
16 | + $selectable[$item->get_id()] = $item->get_name() . ' — ' . wpinv_price($item->get_initial_price()); |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | -if ( empty( $selectable ) ) { |
|
20 | +if (empty($selectable)) { |
|
21 | 21 | return; |
22 | 22 | } |
23 | 23 | |
24 | 24 | echo '<div class="getpaid-payment-form-items-checkbox form-group">'; |
25 | 25 | |
26 | -foreach ( $selectable as $item_id => $item_name ) { |
|
26 | +foreach ($selectable as $item_id => $item_name) { |
|
27 | 27 | |
28 | 28 | echo aui()->input( |
29 | 29 | array( |
30 | 30 | 'type' => 'checkbox', |
31 | 31 | 'name' => 'getpaid-payment-form-selected-item', |
32 | - 'id' => 'getpaid-payment-form-selected-item' . uniqid( '_' ) . $item_id, |
|
32 | + 'id' => 'getpaid-payment-form-selected-item' . uniqid('_') . $item_id, |
|
33 | 33 | 'label' => $item_name, |
34 | 34 | 'value' => $item_id, |
35 | 35 | 'no_wrap' => true, |
@@ -7,80 +7,80 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -do_action( 'getpaid_before_payment_form_cart_item', $form, $item ); |
|
12 | +do_action('getpaid_before_payment_form_cart_item', $form, $item); |
|
13 | 13 | |
14 | 14 | $currency = $form->get_currency(); |
15 | 15 | |
16 | 16 | ?> |
17 | -<div class='getpaid-payment-form-items-cart-item px-3 py-2 getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?>'> |
|
17 | +<div class='getpaid-payment-form-items-cart-item px-3 py-2 getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?>'> |
|
18 | 18 | <div class="form-row"> |
19 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
20 | - <div class="<?php echo 'name' == $key ? 'col-12 col-sm-5' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?>-<?php echo $item->get_id(); ?>"> |
|
19 | + <?php foreach ($columns as $key => $label) : ?> |
|
20 | + <div class="<?php echo 'name' == $key ? 'col-12 col-sm-5' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo esc_attr($key); ?> getpaid-form-cart-item-<?php echo esc_attr($key); ?>-<?php echo $item->get_id(); ?>"> |
|
21 | 21 | <?php |
22 | 22 | |
23 | 23 | // Item name. |
24 | - if ( 'name' == $key ) { |
|
25 | - echo sanitize_text_field( $item->get_name() ); |
|
24 | + if ('name' == $key) { |
|
25 | + echo sanitize_text_field($item->get_name()); |
|
26 | 26 | $description = $item->get_description(); |
27 | 27 | |
28 | - if ( ! empty( $description ) ) { |
|
29 | - $description = wp_kses_post( $description ); |
|
28 | + if (!empty($description)) { |
|
29 | + $description = wp_kses_post($description); |
|
30 | 30 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
31 | 31 | } |
32 | 32 | |
33 | - $description = getpaid_item_recurring_price_help_text( $item, $currency ); |
|
33 | + $description = getpaid_item_recurring_price_help_text($item, $currency); |
|
34 | 34 | |
35 | - if ( $description ) { |
|
35 | + if ($description) { |
|
36 | 36 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | 40 | // Item price. |
41 | - if ( 'price' == $key ) { |
|
41 | + if ('price' == $key) { |
|
42 | 42 | |
43 | 43 | // Set the currency position. |
44 | 44 | $position = wpinv_currency_position(); |
45 | 45 | |
46 | - if ( $position == 'left_space' ) { |
|
46 | + if ($position == 'left_space') { |
|
47 | 47 | $position = 'left'; |
48 | 48 | } |
49 | 49 | |
50 | - if ( $position == 'right_space' ) { |
|
50 | + if ($position == 'right_space') { |
|
51 | 51 | $position = 'right'; |
52 | 52 | } |
53 | 53 | |
54 | - if ( $item->user_can_set_their_price() ) { |
|
55 | - $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() ); |
|
54 | + if ($item->user_can_set_their_price()) { |
|
55 | + $price = max((float) $item->get_price(), (float) $item->get_minimum_price()); |
|
56 | 56 | ?> |
57 | 57 | <div class="input-group input-group-sm"> |
58 | - <?php if( 'left' == $position ) : ?> |
|
58 | + <?php if ('left' == $position) : ?> |
|
59 | 59 | <div class="input-group-prepend"> |
60 | - <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span> |
|
60 | + <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span> |
|
61 | 61 | </div> |
62 | 62 | <?php endif; ?> |
63 | - <input type="text" name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr( $item->get_minimum_price() ); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border border"> |
|
63 | + <input type="text" name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr($item->get_minimum_price()); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border border"> |
|
64 | 64 | |
65 | - <?php if( 'left' != $position ) : ?> |
|
65 | + <?php if ('left' != $position) : ?> |
|
66 | 66 | <div class="input-group-append"> |
67 | - <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span> |
|
67 | + <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span> |
|
68 | 68 | </div> |
69 | 69 | <?php endif; ?> |
70 | 70 | </div> |
71 | 71 | <?php |
72 | 72 | } else { |
73 | - echo wpinv_price( $item->get_price(), $currency ); |
|
73 | + echo wpinv_price($item->get_price(), $currency); |
|
74 | 74 | ?> |
75 | - <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'> |
|
75 | + <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr($item->get_price()); ?>'> |
|
76 | 76 | <?php |
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | 80 | // Item quantity. |
81 | - if ( 'quantity' == $key ) { |
|
81 | + if ('quantity' == $key) { |
|
82 | 82 | |
83 | - if ( $item->allows_quantities() ) { |
|
83 | + if ($item->allows_quantities()) { |
|
84 | 84 | ?> |
85 | 85 | <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='number' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (int) $item->get_qantity(); ?>' min='1' required> |
86 | 86 | <?php |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | // Item sub total. |
97 | - if ( 'subtotal' == $key ) { |
|
98 | - echo wpinv_price( $item->get_sub_total(), $currency ); |
|
97 | + if ('subtotal' == $key) { |
|
98 | + echo wpinv_price($item->get_sub_total(), $currency); |
|
99 | 99 | } |
100 | 100 | |
101 | - do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
101 | + do_action("getpaid_payment_form_cart_item_$key", $item, $form); |
|
102 | 102 | ?> |
103 | 103 | </div> |
104 | 104 | <?php endforeach; ?> |
105 | 105 | </div> |
106 | 106 | </div> |
107 | 107 | <?php |
108 | -do_action( 'getpaid_payment_form_cart_item', $form, $item ); |
|
108 | +do_action('getpaid_payment_form_cart_item', $form, $item); |
@@ -40,86 +40,86 @@ discard block |
||
40 | 40 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
41 | 41 | <?php |
42 | 42 | |
43 | - foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : |
|
43 | + foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : |
|
44 | 44 | |
45 | - $column_id = sanitize_html_class( $column_id ); |
|
46 | - $class = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] ); |
|
45 | + $column_id = sanitize_html_class( $column_id ); |
|
46 | + $class = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] ); |
|
47 | 47 | |
48 | - echo "<td class='$column_id $class'>"; |
|
49 | - switch ( $column_id ) { |
|
48 | + echo "<td class='$column_id $class'>"; |
|
49 | + switch ( $column_id ) { |
|
50 | 50 | |
51 | - case 'invoice-number': |
|
52 | - echo wpinv_invoice_link( $invoice ); |
|
53 | - break; |
|
51 | + case 'invoice-number': |
|
52 | + echo wpinv_invoice_link( $invoice ); |
|
53 | + break; |
|
54 | 54 | |
55 | - case 'created-date': |
|
56 | - echo getpaid_format_date_value( $invoice->get_date_created() ); |
|
57 | - break; |
|
55 | + case 'created-date': |
|
56 | + echo getpaid_format_date_value( $invoice->get_date_created() ); |
|
57 | + break; |
|
58 | 58 | |
59 | - case 'payment-date': |
|
59 | + case 'payment-date': |
|
60 | 60 | |
61 | - if ( $invoice->needs_payment() ) { |
|
62 | - echo "—"; |
|
63 | - } else { |
|
64 | - echo getpaid_format_date_value( $invoice->get_date_completed() ); |
|
65 | - } |
|
61 | + if ( $invoice->needs_payment() ) { |
|
62 | + echo "—"; |
|
63 | + } else { |
|
64 | + echo getpaid_format_date_value( $invoice->get_date_completed() ); |
|
65 | + } |
|
66 | 66 | |
67 | - break; |
|
67 | + break; |
|
68 | 68 | |
69 | - case 'invoice-status': |
|
70 | - echo $invoice->get_status_label_html(); |
|
69 | + case 'invoice-status': |
|
70 | + echo $invoice->get_status_label_html(); |
|
71 | 71 | |
72 | - break; |
|
72 | + break; |
|
73 | 73 | |
74 | - case 'invoice-total': |
|
75 | - echo wpinv_price( $invoice->get_total() ); |
|
74 | + case 'invoice-total': |
|
75 | + echo wpinv_price( $invoice->get_total() ); |
|
76 | 76 | |
77 | - break; |
|
77 | + break; |
|
78 | 78 | |
79 | - case 'invoice-actions': |
|
79 | + case 'invoice-actions': |
|
80 | 80 | |
81 | - $actions = array( |
|
81 | + $actions = array( |
|
82 | 82 | |
83 | - 'pay' => array( |
|
84 | - 'url' => $invoice->get_checkout_payment_url(), |
|
85 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
83 | + 'pay' => array( |
|
84 | + 'url' => $invoice->get_checkout_payment_url(), |
|
85 | + 'name' => __( 'Pay Now', 'invoicing' ), |
|
86 | 86 | 'class' => 'btn-success' |
87 | - ), |
|
87 | + ), |
|
88 | 88 | |
89 | 89 | 'print' => array( |
90 | - 'url' => $invoice->get_view_url(), |
|
91 | - 'name' => __( 'View', 'invoicing' ), |
|
90 | + 'url' => $invoice->get_view_url(), |
|
91 | + 'name' => __( 'View', 'invoicing' ), |
|
92 | 92 | 'class' => 'btn-secondary', |
93 | 93 | 'attrs' => 'target="_blank"' |
94 | - ) |
|
95 | - ); |
|
94 | + ) |
|
95 | + ); |
|
96 | 96 | |
97 | - if ( ! $invoice->needs_payment() ) { |
|
98 | - unset( $actions['pay'] ); |
|
99 | - } |
|
97 | + if ( ! $invoice->needs_payment() ) { |
|
98 | + unset( $actions['pay'] ); |
|
99 | + } |
|
100 | 100 | |
101 | - $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type ); |
|
101 | + $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type ); |
|
102 | 102 | |
103 | - foreach ( $actions as $key => $action ) { |
|
104 | - $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
105 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
106 | - } |
|
103 | + foreach ( $actions as $key => $action ) { |
|
104 | + $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
105 | + echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
106 | + } |
|
107 | 107 | |
108 | - break; |
|
108 | + break; |
|
109 | 109 | |
110 | - default: |
|
111 | - do_action( "wpinv_user_invoices_column_$column_id", $invoice ); |
|
112 | - break; |
|
110 | + default: |
|
111 | + do_action( "wpinv_user_invoices_column_$column_id", $invoice ); |
|
112 | + break; |
|
113 | 113 | |
114 | 114 | |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | - do_action( "wpinv_user_invoices_column_after_$column_id", $invoice ); |
|
117 | + do_action( "wpinv_user_invoices_column_after_$column_id", $invoice ); |
|
118 | 118 | |
119 | - echo '</td>'; |
|
119 | + echo '</td>'; |
|
120 | 120 | |
121 | - endforeach; |
|
122 | - ?> |
|
121 | + endforeach; |
|
122 | + ?> |
|
123 | 123 | </tr> |
124 | 124 | |
125 | 125 | <?php endforeach; ?> |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | <?php if ( 1 < $invoices->max_num_pages ) : ?> |
133 | 133 | <div class="invoicing-Pagination"> |
134 | 134 | <?php |
135 | - $big = 999999; |
|
136 | - |
|
137 | - echo paginate_links( array( |
|
138 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
139 | - 'format' => '?paged=%#%', |
|
140 | - 'total' => $invoices->max_num_pages, |
|
141 | - ) ); |
|
142 | - ?> |
|
135 | + $big = 999999; |
|
136 | + |
|
137 | + echo paginate_links( array( |
|
138 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
139 | + 'format' => '?paged=%#%', |
|
140 | + 'total' => $invoices->max_num_pages, |
|
141 | + ) ); |
|
142 | + ?> |
|
143 | 143 | </div> |
144 | 144 | <?php endif; ?> |
145 | 145 |
@@ -7,25 +7,25 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Current page. |
13 | -$current_page = empty( $_GET[ 'page' ] ) ? 1 : absint( $_GET[ 'page' ] ); |
|
13 | +$current_page = empty($_GET['page']) ? 1 : absint($_GET['page']); |
|
14 | 14 | |
15 | 15 | // Fires before displaying user invoices. |
16 | -do_action( 'wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type ); |
|
16 | +do_action('wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type); |
|
17 | 17 | |
18 | 18 | ?> |
19 | 19 | |
20 | - <table class="table table-bordered table-hover getpaid-user-invoices <?php echo sanitize_html_class( $post_type ); ?>"> |
|
20 | + <table class="table table-bordered table-hover getpaid-user-invoices <?php echo sanitize_html_class($post_type); ?>"> |
|
21 | 21 | |
22 | 22 | |
23 | 23 | <thead> |
24 | 24 | <tr> |
25 | 25 | |
26 | - <?php foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : ?> |
|
27 | - <th class="<?php echo sanitize_html_class( $column_id ); ?> <?php echo ( ! empty( $column_name['class'] ) ? sanitize_html_class( $column_name['class'] ) : '');?> border-bottom-0"> |
|
28 | - <span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span> |
|
26 | + <?php foreach (wpinv_get_user_invoices_columns($post_type) as $column_id => $column_name) : ?> |
|
27 | + <th class="<?php echo sanitize_html_class($column_id); ?> <?php echo (!empty($column_name['class']) ? sanitize_html_class($column_name['class']) : ''); ?> border-bottom-0"> |
|
28 | + <span class="nobr"><?php echo esc_html($column_name['title']); ?></span> |
|
29 | 29 | </th> |
30 | 30 | <?php endforeach; ?> |
31 | 31 | |
@@ -35,33 +35,33 @@ discard block |
||
35 | 35 | |
36 | 36 | |
37 | 37 | <tbody> |
38 | - <?php foreach ( $invoices->invoices as $invoice ) : ?> |
|
38 | + <?php foreach ($invoices->invoices as $invoice) : ?> |
|
39 | 39 | |
40 | 40 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
41 | 41 | <?php |
42 | 42 | |
43 | - foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : |
|
43 | + foreach (wpinv_get_user_invoices_columns($post_type) as $column_id => $column_name) : |
|
44 | 44 | |
45 | - $column_id = sanitize_html_class( $column_id ); |
|
46 | - $class = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] ); |
|
45 | + $column_id = sanitize_html_class($column_id); |
|
46 | + $class = empty($column_name['class']) ? '' : sanitize_html_class($column_name['class']); |
|
47 | 47 | |
48 | 48 | echo "<td class='$column_id $class'>"; |
49 | - switch ( $column_id ) { |
|
49 | + switch ($column_id) { |
|
50 | 50 | |
51 | 51 | case 'invoice-number': |
52 | - echo wpinv_invoice_link( $invoice ); |
|
52 | + echo wpinv_invoice_link($invoice); |
|
53 | 53 | break; |
54 | 54 | |
55 | 55 | case 'created-date': |
56 | - echo getpaid_format_date_value( $invoice->get_date_created() ); |
|
56 | + echo getpaid_format_date_value($invoice->get_date_created()); |
|
57 | 57 | break; |
58 | 58 | |
59 | 59 | case 'payment-date': |
60 | 60 | |
61 | - if ( $invoice->needs_payment() ) { |
|
61 | + if ($invoice->needs_payment()) { |
|
62 | 62 | echo "—"; |
63 | 63 | } else { |
64 | - echo getpaid_format_date_value( $invoice->get_date_completed() ); |
|
64 | + echo getpaid_format_date_value($invoice->get_date_completed()); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | break; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | break; |
73 | 73 | |
74 | 74 | case 'invoice-total': |
75 | - echo wpinv_price( $invoice->get_total() ); |
|
75 | + echo wpinv_price($invoice->get_total()); |
|
76 | 76 | |
77 | 77 | break; |
78 | 78 | |
@@ -82,39 +82,39 @@ discard block |
||
82 | 82 | |
83 | 83 | 'pay' => array( |
84 | 84 | 'url' => $invoice->get_checkout_payment_url(), |
85 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
85 | + 'name' => __('Pay Now', 'invoicing'), |
|
86 | 86 | 'class' => 'btn-success' |
87 | 87 | ), |
88 | 88 | |
89 | 89 | 'print' => array( |
90 | 90 | 'url' => $invoice->get_view_url(), |
91 | - 'name' => __( 'View', 'invoicing' ), |
|
91 | + 'name' => __('View', 'invoicing'), |
|
92 | 92 | 'class' => 'btn-secondary', |
93 | 93 | 'attrs' => 'target="_blank"' |
94 | 94 | ) |
95 | 95 | ); |
96 | 96 | |
97 | - if ( ! $invoice->needs_payment() ) { |
|
98 | - unset( $actions['pay'] ); |
|
97 | + if (!$invoice->needs_payment()) { |
|
98 | + unset($actions['pay']); |
|
99 | 99 | } |
100 | 100 | |
101 | - $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type ); |
|
101 | + $actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice, $post_type); |
|
102 | 102 | |
103 | - foreach ( $actions as $key => $action ) { |
|
103 | + foreach ($actions as $key => $action) { |
|
104 | 104 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
105 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
105 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | break; |
109 | 109 | |
110 | 110 | default: |
111 | - do_action( "wpinv_user_invoices_column_$column_id", $invoice ); |
|
111 | + do_action("wpinv_user_invoices_column_$column_id", $invoice); |
|
112 | 112 | break; |
113 | 113 | |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | - do_action( "wpinv_user_invoices_column_after_$column_id", $invoice ); |
|
117 | + do_action("wpinv_user_invoices_column_after_$column_id", $invoice); |
|
118 | 118 | |
119 | 119 | echo '</td>'; |
120 | 120 | |
@@ -127,20 +127,20 @@ discard block |
||
127 | 127 | </tbody> |
128 | 128 | </table> |
129 | 129 | |
130 | - <?php do_action( 'wpinv_before_user_invoices_pagination' ); ?> |
|
130 | + <?php do_action('wpinv_before_user_invoices_pagination'); ?> |
|
131 | 131 | |
132 | - <?php if ( 1 < $invoices->max_num_pages ) : ?> |
|
132 | + <?php if (1 < $invoices->max_num_pages) : ?> |
|
133 | 133 | <div class="invoicing-Pagination"> |
134 | 134 | <?php |
135 | 135 | $big = 999999; |
136 | 136 | |
137 | - echo paginate_links( array( |
|
138 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
137 | + echo paginate_links(array( |
|
138 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
139 | 139 | 'format' => '?paged=%#%', |
140 | 140 | 'total' => $invoices->max_num_pages, |
141 | - ) ); |
|
141 | + )); |
|
142 | 142 | ?> |
143 | 143 | </div> |
144 | 144 | <?php endif; ?> |
145 | 145 | |
146 | -<?php do_action( 'wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type ); ?> |
|
146 | +<?php do_action('wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type); ?> |
@@ -8,22 +8,22 @@ discard block |
||
8 | 8 | * @var WPInv_Invoice $invoice |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | // Totals rows. |
14 | -$totals = getpaid_invoice_totals_rows( $invoice ); |
|
14 | +$totals = getpaid_invoice_totals_rows($invoice); |
|
15 | 15 | |
16 | -do_action( 'getpaid_before_email_line_totals', $invoice, $totals ); |
|
16 | +do_action('getpaid_before_email_line_totals', $invoice, $totals); |
|
17 | 17 | |
18 | 18 | ?> |
19 | 19 | |
20 | 20 | |
21 | -<?php if ( has_action( 'wpinv_email_footer_buttons' ) ) : ?> |
|
21 | +<?php if (has_action('wpinv_email_footer_buttons')) : ?> |
|
22 | 22 | |
23 | 23 | <tr class="wpinv_cart_footer_row"> |
24 | 24 | |
25 | - <td colspan="<?php echo ( (int) $column_count ); ?>"> |
|
26 | - <?php do_action( 'wpinv_email_footer_buttons' ); ?> |
|
25 | + <td colspan="<?php echo ((int) $column_count); ?>"> |
|
26 | + <?php do_action('wpinv_email_footer_buttons'); ?> |
|
27 | 27 | </td> |
28 | 28 | |
29 | 29 | </tr> |
@@ -31,44 +31,44 @@ discard block |
||
31 | 31 | <?php endif; ?> |
32 | 32 | |
33 | 33 | |
34 | -<?php foreach ( $totals as $key => $label ) : ?> |
|
34 | +<?php foreach ($totals as $key => $label) : ?> |
|
35 | 35 | |
36 | - <tr class="wpinv_cart_footer_row wpinv_cart_<?php echo sanitize_html_class( $key ); ?>_row"> |
|
36 | + <tr class="wpinv_cart_footer_row wpinv_cart_<?php echo sanitize_html_class($key); ?>_row"> |
|
37 | 37 | |
38 | - <td colspan="<?php echo ( $column_count - 1 ); ?>" class="wpinv_cart_<?php echo sanitize_html_class( $key ); ?>_label text-right"> |
|
39 | - <strong><?php echo sanitize_text_field( $label ); ?>:</strong> |
|
38 | + <td colspan="<?php echo ($column_count - 1); ?>" class="wpinv_cart_<?php echo sanitize_html_class($key); ?>_label text-right"> |
|
39 | + <strong><?php echo sanitize_text_field($label); ?>:</strong> |
|
40 | 40 | </td> |
41 | 41 | |
42 | - <td class="wpinv_cart_<?php echo sanitize_html_class( $key ); ?> text-right"> |
|
42 | + <td class="wpinv_cart_<?php echo sanitize_html_class($key); ?> text-right"> |
|
43 | 43 | |
44 | 44 | <?php |
45 | 45 | |
46 | 46 | // Total tax. |
47 | - if ( 'tax' == $key ) { |
|
48 | - echo wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ); |
|
47 | + if ('tax' == $key) { |
|
48 | + echo wpinv_price($invoice->get_total_tax(), $invoice->get_currency()); |
|
49 | 49 | } |
50 | 50 | |
51 | - if ( 'fee' == $key ) { |
|
52 | - echo wpinv_price( $invoice->get_total_fees(), $invoice->get_currency() ); |
|
51 | + if ('fee' == $key) { |
|
52 | + echo wpinv_price($invoice->get_total_fees(), $invoice->get_currency()); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | // Total discount. |
56 | - if ( 'discount' == $key ) { |
|
57 | - echo wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ); |
|
56 | + if ('discount' == $key) { |
|
57 | + echo wpinv_price($invoice->get_total_discount(), $invoice->get_currency()); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // Sub total. |
61 | - if ( 'subtotal' == $key ) { |
|
62 | - echo wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ); |
|
61 | + if ('subtotal' == $key) { |
|
62 | + echo wpinv_price($invoice->get_subtotal(), $invoice->get_currency()); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Total. |
66 | - if ( 'total' == $key ) { |
|
67 | - echo wpinv_price( $invoice->get_total(), $invoice->get_currency() ); |
|
66 | + if ('total' == $key) { |
|
67 | + echo wpinv_price($invoice->get_total(), $invoice->get_currency()); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // Fires when printing a cart total in an email. |
71 | - do_action( "getpaid_email_cart_totals_$key", $invoice ); |
|
71 | + do_action("getpaid_email_cart_totals_$key", $invoice); |
|
72 | 72 | |
73 | 73 | ?> |
74 | 74 | |
@@ -80,4 +80,4 @@ discard block |
||
80 | 80 | |
81 | 81 | <?php |
82 | 82 | |
83 | - do_action( 'getpaid_after_email_line_totals', $invoice, $totals ); |
|
83 | + do_action('getpaid_after_email_line_totals', $invoice, $totals); |
@@ -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 | * Returns an array of eu states. |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @return array |
13 | 13 | */ |
14 | 14 | function getpaid_get_eu_states() { |
15 | - return wpinv_get_data( 'eu-states' ); |
|
15 | + return wpinv_get_data('eu-states'); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return bool |
22 | 22 | */ |
23 | -function getpaid_is_eu_state( $country ) { |
|
24 | - return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_eu_states() ) ? true : false; |
|
23 | +function getpaid_is_eu_state($country) { |
|
24 | + return !empty($country) && in_array(strtoupper($country), getpaid_get_eu_states()) ? true : false; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return array |
31 | 31 | */ |
32 | 32 | function getpaid_get_gst_states() { |
33 | - return array( 'AU', 'NZ', 'CA', 'CN' ); |
|
33 | + return array('AU', 'NZ', 'CA', 'CN'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return bool |
40 | 40 | */ |
41 | -function getpaid_is_gst_country( $country ) { |
|
42 | - return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_gst_states() ) ? true : false; |
|
41 | +function getpaid_is_gst_country($country) { |
|
42 | + return !empty($country) && in_array(strtoupper($country), getpaid_get_gst_states()) ? true : false; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function wpinv_use_taxes() { |
51 | 51 | |
52 | - $ret = wpinv_get_option( 'enable_taxes', false ); |
|
53 | - return (bool) apply_filters( 'wpinv_use_taxes', ! empty( $ret ) ); |
|
52 | + $ret = wpinv_get_option('enable_taxes', false); |
|
53 | + return (bool) apply_filters('wpinv_use_taxes', !empty($ret)); |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param WPInv_Invoice $invoice |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | -function wpinv_is_invoice_taxable( $invoice ) { |
|
63 | +function wpinv_is_invoice_taxable($invoice) { |
|
64 | 64 | return $invoice->is_taxable(); |
65 | 65 | } |
66 | 66 | |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | * @param string $country |
71 | 71 | * @return bool |
72 | 72 | */ |
73 | -function wpinv_is_country_taxable( $country ) { |
|
74 | - $is_eu = getpaid_is_eu_state( $country ); |
|
75 | - $is_exempt = $is_eu && $country == wpinv_is_base_country( $country ) && wpinv_same_country_exempt_vat(); |
|
73 | +function wpinv_is_country_taxable($country) { |
|
74 | + $is_eu = getpaid_is_eu_state($country); |
|
75 | + $is_exempt = $is_eu && $country == wpinv_is_base_country($country) && wpinv_same_country_exempt_vat(); |
|
76 | 76 | |
77 | - return (bool) apply_filters( 'wpinv_is_country_taxable', ! $is_exempt, $country ); |
|
77 | + return (bool) apply_filters('wpinv_is_country_taxable', !$is_exempt, $country); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param WPInv_Item|GetPaid_Form_Item $item |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | -function wpinv_is_item_taxable( $item ) { |
|
87 | +function wpinv_is_item_taxable($item) { |
|
88 | 88 | return '_exempt' != $item->get_vat_rule(); |
89 | 89 | } |
90 | 90 | |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | * @return bool |
95 | 95 | */ |
96 | 96 | function wpinv_use_store_address_as_tax_base() { |
97 | - $use_base = wpinv_get_option( 'tax_base', 'billing' ) == 'base'; |
|
98 | - return (bool) apply_filters( 'wpinv_use_store_address_as_tax_base', $use_base ); |
|
97 | + $use_base = wpinv_get_option('tax_base', 'billing') == 'base'; |
|
98 | + return (bool) apply_filters('wpinv_use_store_address_as_tax_base', $use_base); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @return bool |
105 | 105 | */ |
106 | 106 | function wpinv_prices_include_tax() { |
107 | - $is_inclusive = wpinv_get_option( 'prices_include_tax', 'no' ) == 'yes'; |
|
108 | - return (bool) apply_filters( 'wpinv_prices_include_tax', $is_inclusive ); |
|
107 | + $is_inclusive = wpinv_get_option('prices_include_tax', 'no') == 'yes'; |
|
108 | + return (bool) apply_filters('wpinv_prices_include_tax', $is_inclusive); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @return bool |
115 | 115 | */ |
116 | 116 | function wpinv_round_tax_per_tax_rate() { |
117 | - $subtotal_rounding = wpinv_get_option( 'tax_subtotal_rounding', 1 ); |
|
118 | - return (bool) apply_filters( 'wpinv_round_tax_per_tax_rate', empty( $subtotal_rounding ) ); |
|
117 | + $subtotal_rounding = wpinv_get_option('tax_subtotal_rounding', 1); |
|
118 | + return (bool) apply_filters('wpinv_round_tax_per_tax_rate', empty($subtotal_rounding)); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @return bool |
125 | 125 | */ |
126 | 126 | function wpinv_display_individual_tax_rates() { |
127 | - $individual = wpinv_get_option( 'tax_display_totals', 'single' ) == 'individual'; |
|
128 | - return (bool) apply_filters( 'wpinv_display_individual_tax_rates', $individual ); |
|
127 | + $individual = wpinv_get_option('tax_display_totals', 'single') == 'individual'; |
|
128 | + return (bool) apply_filters('wpinv_display_individual_tax_rates', $individual); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @return float |
135 | 135 | */ |
136 | 136 | function wpinv_get_default_tax_rate() { |
137 | - $rate = wpinv_get_option( 'tax_rate', false ); |
|
138 | - return (float) apply_filters( 'wpinv_get_default_tax_rate', floatval( $rate ) ); |
|
137 | + $rate = wpinv_get_option('tax_rate', false); |
|
138 | + return (float) apply_filters('wpinv_get_default_tax_rate', floatval($rate)); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return bool |
145 | 145 | */ |
146 | 146 | function wpinv_same_country_exempt_vat() { |
147 | - return 'no' == wpinv_get_option( 'vat_same_country_rule' ); |
|
147 | + return 'no' == wpinv_get_option('vat_same_country_rule'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -164,28 +164,28 @@ discard block |
||
164 | 164 | * @param string $state |
165 | 165 | * @return array |
166 | 166 | */ |
167 | -function getpaid_get_item_tax_rates( $item, $country = '', $state = '' ) { |
|
167 | +function getpaid_get_item_tax_rates($item, $country = '', $state = '') { |
|
168 | 168 | |
169 | 169 | // Abort if the item is not taxable. |
170 | - if ( ! wpinv_is_item_taxable( $item ) ) { |
|
170 | + if (!wpinv_is_item_taxable($item)) { |
|
171 | 171 | return array(); |
172 | 172 | } |
173 | 173 | |
174 | 174 | // Maybe use the store address. |
175 | - if ( wpinv_use_store_address_as_tax_base() ) { |
|
175 | + if (wpinv_use_store_address_as_tax_base()) { |
|
176 | 176 | $country = wpinv_get_default_country(); |
177 | 177 | $state = wpinv_get_default_state(); |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Retrieve tax rates. |
181 | - $tax_rates = GetPaid_Tax::get_address_tax_rates( $country, $state ); |
|
181 | + $tax_rates = GetPaid_Tax::get_address_tax_rates($country, $state); |
|
182 | 182 | |
183 | 183 | // Fallback to the default tax rates if non were found. |
184 | - if ( empty( $tax_rates ) ) { |
|
184 | + if (empty($tax_rates)) { |
|
185 | 185 | $tax_rates = GetPaid_Tax::get_default_tax_rates(); |
186 | 186 | } |
187 | 187 | |
188 | - return apply_filters( 'getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state ); |
|
188 | + return apply_filters('getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -195,23 +195,23 @@ discard block |
||
195 | 195 | * @param array $rates |
196 | 196 | * @return array |
197 | 197 | */ |
198 | -function getpaid_filter_item_tax_rates( $item, $rates ) { |
|
198 | +function getpaid_filter_item_tax_rates($item, $rates) { |
|
199 | 199 | |
200 | 200 | $tax_class = $item->get_vat_class(); |
201 | 201 | |
202 | - foreach ( $rates as $i => $rate ) { |
|
202 | + foreach ($rates as $i => $rate) { |
|
203 | 203 | |
204 | - if ( $tax_class == '_reduced' ) { |
|
205 | - $rates[ $i ]['rate'] = empty( $rate['reduced_rate'] ) ? 0 : $rate['reduced_rate']; |
|
204 | + if ($tax_class == '_reduced') { |
|
205 | + $rates[$i]['rate'] = empty($rate['reduced_rate']) ? 0 : $rate['reduced_rate']; |
|
206 | 206 | } |
207 | 207 | |
208 | - if ( $tax_class == '_exempt' ) { |
|
209 | - $rates[ $i ]['rate'] = 0; |
|
208 | + if ($tax_class == '_exempt') { |
|
209 | + $rates[$i]['rate'] = 0; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | } |
213 | 213 | |
214 | - return apply_filters( 'getpaid_filter_item_tax_rates', $rates, $item ); |
|
214 | + return apply_filters('getpaid_filter_item_tax_rates', $rates, $item); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -221,12 +221,12 @@ discard block |
||
221 | 221 | * @param array $rates |
222 | 222 | * @return array |
223 | 223 | */ |
224 | -function getpaid_calculate_item_taxes( $amount, $rates ) { |
|
224 | +function getpaid_calculate_item_taxes($amount, $rates) { |
|
225 | 225 | |
226 | 226 | $is_inclusive = wpinv_prices_include_tax(); |
227 | - $taxes = GetPaid_Tax::calc_tax( $amount, $rates, $is_inclusive ); |
|
227 | + $taxes = GetPaid_Tax::calc_tax($amount, $rates, $is_inclusive); |
|
228 | 228 | |
229 | - return apply_filters( 'getpaid_calculate_taxes', $taxes, $amount, $rates ); |
|
229 | + return apply_filters('getpaid_calculate_taxes', $taxes, $amount, $rates); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | * @param float $recurring_tax_amount |
239 | 239 | * @return array |
240 | 240 | */ |
241 | -function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) { |
|
241 | +function getpaid_prepare_item_tax($item, $tax_name, $tax_amount, $recurring_tax_amount) { |
|
242 | 242 | |
243 | - $initial_tax = $tax_amount; |
|
243 | + $initial_tax = $tax_amount; |
|
244 | 244 | $recurring_tax = 0; |
245 | 245 | |
246 | - if ( $item->is_recurring() ) { |
|
246 | + if ($item->is_recurring()) { |
|
247 | 247 | $recurring_tax = $recurring_tax_amount; |
248 | 248 | } |
249 | 249 | |
250 | 250 | return array( |
251 | - 'name' => sanitize_text_field( $tax_name ), |
|
251 | + 'name' => sanitize_text_field($tax_name), |
|
252 | 252 | 'initial_tax' => $initial_tax, |
253 | 253 | 'recurring_tax' => $recurring_tax, |
254 | 254 | ); |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | * @param string $vat_number |
262 | 262 | * @return string |
263 | 263 | */ |
264 | -function wpinv_sanitize_vat_number( $vat_number ) { |
|
265 | - return str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) ); |
|
264 | +function wpinv_sanitize_vat_number($vat_number) { |
|
265 | + return str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number))); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -271,22 +271,22 @@ discard block |
||
271 | 271 | * @param string $vat_number |
272 | 272 | * @return bool |
273 | 273 | */ |
274 | -function wpinv_regex_validate_vat_number( $vat_number ) { |
|
274 | +function wpinv_regex_validate_vat_number($vat_number) { |
|
275 | 275 | |
276 | - $country = substr( $vat_number, 0, 2 ); |
|
277 | - $vatin = substr( $vat_number, 2 ); |
|
278 | - $regexes = wpinv_get_data( 'vat-number-regexes' ); |
|
276 | + $country = substr($vat_number, 0, 2); |
|
277 | + $vatin = substr($vat_number, 2); |
|
278 | + $regexes = wpinv_get_data('vat-number-regexes'); |
|
279 | 279 | |
280 | - if ( isset( $regexes[ $country ] ) ) { |
|
280 | + if (isset($regexes[$country])) { |
|
281 | 281 | |
282 | - $regex = $regexes[ $country ]; |
|
282 | + $regex = $regexes[$country]; |
|
283 | 283 | $regex = '/^(?:' . $regex . ')$/'; |
284 | - return 1 === preg_match( $regex, $vatin ); |
|
284 | + return 1 === preg_match($regex, $vatin); |
|
285 | 285 | |
286 | 286 | } |
287 | 287 | |
288 | 288 | // Not an EU state, use filters to validate the number. |
289 | - return apply_filters( 'wpinv_regex_validate_vat_number', true, $vat_number ); |
|
289 | + return apply_filters('wpinv_regex_validate_vat_number', true, $vat_number); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -295,29 +295,29 @@ discard block |
||
295 | 295 | * @param string $vat_number |
296 | 296 | * @return bool |
297 | 297 | */ |
298 | -function wpinv_vies_validate_vat_number( $vat_number ) { |
|
298 | +function wpinv_vies_validate_vat_number($vat_number) { |
|
299 | 299 | |
300 | - $country = substr( $vat_number, 0, 2 ); |
|
301 | - $vatin = substr( $vat_number, 2 ); |
|
300 | + $country = substr($vat_number, 0, 2); |
|
301 | + $vatin = substr($vat_number, 2); |
|
302 | 302 | |
303 | 303 | $url = add_query_arg( |
304 | 304 | array( |
305 | - 'ms' => urlencode( $country ), |
|
306 | - 'iso' => urlencode( $country ), |
|
307 | - 'vat' => urlencode( $vatin ), |
|
305 | + 'ms' => urlencode($country), |
|
306 | + 'iso' => urlencode($country), |
|
307 | + 'vat' => urlencode($vatin), |
|
308 | 308 | ), |
309 | 309 | 'http://ec.europa.eu/taxation_customs/vies/viesquer.do' |
310 | 310 | ); |
311 | 311 | |
312 | - $response = wp_remote_get( $url ); |
|
313 | - $response = wp_remote_retrieve_body( $response ); |
|
312 | + $response = wp_remote_get($url); |
|
313 | + $response = wp_remote_retrieve_body($response); |
|
314 | 314 | |
315 | 315 | // Fallback gracefully if the VIES website is down. |
316 | - if ( empty( $response ) ) { |
|
316 | + if (empty($response)) { |
|
317 | 317 | return true; |
318 | 318 | } |
319 | 319 | |
320 | - return 1 !== preg_match( '/invalid VAT number/i', $response ); |
|
320 | + return 1 !== preg_match('/invalid VAT number/i', $response); |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -328,23 +328,23 @@ discard block |
||
328 | 328 | * @param string $country |
329 | 329 | * @return bool |
330 | 330 | */ |
331 | -function wpinv_validate_vat_number( $vat_number, $country ) { |
|
331 | +function wpinv_validate_vat_number($vat_number, $country) { |
|
332 | 332 | |
333 | 333 | // Abort if we are not validating this. |
334 | - if ( ! wpinv_should_validate_vat_number() || empty( $vat_number ) ) { |
|
334 | + if (!wpinv_should_validate_vat_number() || empty($vat_number)) { |
|
335 | 335 | return true; |
336 | 336 | } |
337 | 337 | |
338 | 338 | // In case the vat number does not have a country code... |
339 | - $vat_number = wpinv_sanitize_vat_number( $vat_number ); |
|
340 | - $_country = substr( $vat_number, 0, 2 ); |
|
341 | - $_country = $_country == wpinv_country_name( $_country ); |
|
339 | + $vat_number = wpinv_sanitize_vat_number($vat_number); |
|
340 | + $_country = substr($vat_number, 0, 2); |
|
341 | + $_country = $_country == wpinv_country_name($_country); |
|
342 | 342 | |
343 | - if ( $_country ) { |
|
344 | - $vat_number = strtoupper( $country ) . $vat_number; |
|
343 | + if ($_country) { |
|
344 | + $vat_number = strtoupper($country) . $vat_number; |
|
345 | 345 | } |
346 | 346 | |
347 | - return wpinv_regex_validate_vat_number( $vat_number ) && wpinv_vies_validate_vat_number( $vat_number ); |
|
347 | + return wpinv_regex_validate_vat_number($vat_number) && wpinv_vies_validate_vat_number($vat_number); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -353,40 +353,40 @@ discard block |
||
353 | 353 | * @return bool |
354 | 354 | */ |
355 | 355 | function wpinv_should_validate_vat_number() { |
356 | - $validate = wpinv_get_option( 'validate_vat_number' ); |
|
357 | - return ! empty( $validate ); |
|
356 | + $validate = wpinv_get_option('validate_vat_number'); |
|
357 | + return !empty($validate); |
|
358 | 358 | } |
359 | 359 | |
360 | -function wpinv_sales_tax_for_year( $year = null ) { |
|
361 | - return wpinv_price( wpinv_get_sales_tax_for_year( $year ) ); |
|
360 | +function wpinv_sales_tax_for_year($year = null) { |
|
361 | + return wpinv_price(wpinv_get_sales_tax_for_year($year)); |
|
362 | 362 | } |
363 | 363 | |
364 | -function wpinv_get_sales_tax_for_year( $year = null ) { |
|
364 | +function wpinv_get_sales_tax_for_year($year = null) { |
|
365 | 365 | global $wpdb; |
366 | 366 | |
367 | 367 | // Start at zero |
368 | 368 | $tax = 0; |
369 | 369 | |
370 | - if ( ! empty( $year ) ) { |
|
370 | + if (!empty($year)) { |
|
371 | 371 | $args = array( |
372 | 372 | 'post_type' => 'wpi_invoice', |
373 | - 'post_status' => array( 'publish' ), |
|
373 | + 'post_status' => array('publish'), |
|
374 | 374 | 'posts_per_page' => -1, |
375 | 375 | 'year' => $year, |
376 | 376 | 'fields' => 'ids' |
377 | 377 | ); |
378 | 378 | |
379 | - $payments = get_posts( $args ); |
|
380 | - $payment_ids = implode( ',', $payments ); |
|
379 | + $payments = get_posts($args); |
|
380 | + $payment_ids = implode(',', $payments); |
|
381 | 381 | |
382 | - if ( count( $payments ) > 0 ) { |
|
382 | + if (count($payments) > 0) { |
|
383 | 383 | $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )"; |
384 | - $tax = $wpdb->get_var( $sql ); |
|
384 | + $tax = $wpdb->get_var($sql); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | } |
388 | 388 | |
389 | - return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year ); |
|
389 | + return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | function wpinv_is_cart_taxed() { |
@@ -395,33 +395,33 @@ discard block |
||
395 | 395 | |
396 | 396 | function wpinv_prices_show_tax_on_checkout() { |
397 | 397 | return false; // TODO |
398 | - $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() ); |
|
398 | + $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes()); |
|
399 | 399 | |
400 | - return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret ); |
|
400 | + return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | function wpinv_display_tax_rate() { |
404 | - $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false ); |
|
404 | + $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false); |
|
405 | 405 | |
406 | - return apply_filters( 'wpinv_display_tax_rate', $ret ); |
|
406 | + return apply_filters('wpinv_display_tax_rate', $ret); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | function wpinv_cart_needs_tax_address_fields() { |
410 | - if( !wpinv_is_cart_taxed() ) |
|
410 | + if (!wpinv_is_cart_taxed()) |
|
411 | 411 | return false; |
412 | 412 | |
413 | - return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
|
413 | + return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields'); |
|
414 | 414 | } |
415 | 415 | |
416 | -function wpinv_item_is_tax_exclusive( $item_id = 0 ) { |
|
417 | - $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false ); |
|
418 | - return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id ); |
|
416 | +function wpinv_item_is_tax_exclusive($item_id = 0) { |
|
417 | + $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false); |
|
418 | + return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id); |
|
419 | 419 | } |
420 | 420 | |
421 | -function wpinv_currency_decimal_filter( $decimals = 2 ) { |
|
421 | +function wpinv_currency_decimal_filter($decimals = 2) { |
|
422 | 422 | $currency = wpinv_get_currency(); |
423 | 423 | |
424 | - switch ( $currency ) { |
|
424 | + switch ($currency) { |
|
425 | 425 | case 'RIAL' : |
426 | 426 | case 'JPY' : |
427 | 427 | case 'TWD' : |
@@ -430,13 +430,13 @@ discard block |
||
430 | 430 | break; |
431 | 431 | } |
432 | 432 | |
433 | - return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency ); |
|
433 | + return apply_filters('wpinv_currency_decimal_count', $decimals, $currency); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | function wpinv_tax_amount() { |
437 | 437 | $output = 0.00; |
438 | 438 | |
439 | - return apply_filters( 'wpinv_tax_amount', $output ); |
|
439 | + return apply_filters('wpinv_tax_amount', $output); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -444,25 +444,25 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @param string|bool|null $vat_rule |
446 | 446 | */ |
447 | -function getpaid_filter_vat_rule( $vat_rule ) { |
|
447 | +function getpaid_filter_vat_rule($vat_rule) { |
|
448 | 448 | |
449 | - if ( empty( $vat_rule ) ) { |
|
449 | + if (empty($vat_rule)) { |
|
450 | 450 | return 'digital'; |
451 | 451 | } |
452 | 452 | |
453 | 453 | return $vat_rule; |
454 | 454 | } |
455 | -add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' ); |
|
455 | +add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule'); |
|
456 | 456 | |
457 | 457 | /** |
458 | 458 | * Filters the VAT class to ensure that each item has a VAT class. |
459 | 459 | * |
460 | 460 | * @param string|bool|null $vat_rule |
461 | 461 | */ |
462 | -function getpaid_filter_vat_class( $vat_class ) { |
|
463 | - return empty( $vat_class ) ? '_standard' : $vat_class; |
|
462 | +function getpaid_filter_vat_class($vat_class) { |
|
463 | + return empty($vat_class) ? '_standard' : $vat_class; |
|
464 | 464 | } |
465 | -add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' ); |
|
465 | +add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class'); |
|
466 | 466 | |
467 | 467 | /** |
468 | 468 | * Returns a list of all tax classes. |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | return apply_filters( |
475 | 475 | 'getpaid_tax_classes', |
476 | 476 | array( |
477 | - '_standard' => __( 'Standard Tax Rate', 'invoicing' ), |
|
478 | - '_reduced' => __( 'Reduced Tax Rate', 'invoicing' ), |
|
479 | - '_exempt' => __( 'Tax Exempt', 'invoicing' ), |
|
477 | + '_standard' => __('Standard Tax Rate', 'invoicing'), |
|
478 | + '_reduced' => __('Reduced Tax Rate', 'invoicing'), |
|
479 | + '_exempt' => __('Tax Exempt', 'invoicing'), |
|
480 | 480 | ) |
481 | 481 | ); |
482 | 482 | |
@@ -492,8 +492,8 @@ discard block |
||
492 | 492 | return apply_filters( |
493 | 493 | 'getpaid_tax_rules', |
494 | 494 | array( |
495 | - 'physical' => __( 'Physical Item', 'invoicing' ), |
|
496 | - 'digital' => __( 'Digital Item', 'invoicing' ), |
|
495 | + 'physical' => __('Physical Item', 'invoicing'), |
|
496 | + 'digital' => __('Digital Item', 'invoicing'), |
|
497 | 497 | ) |
498 | 498 | ); |
499 | 499 | |
@@ -505,15 +505,15 @@ discard block |
||
505 | 505 | * @param string $tax_class |
506 | 506 | * @return string |
507 | 507 | */ |
508 | -function getpaid_get_tax_class_label( $tax_class ) { |
|
508 | +function getpaid_get_tax_class_label($tax_class) { |
|
509 | 509 | |
510 | 510 | $classes = getpaid_get_tax_classes(); |
511 | 511 | |
512 | - if ( isset( $classes[ $tax_class ] ) ) { |
|
513 | - return sanitize_text_field( $classes[ $tax_class ] ); |
|
512 | + if (isset($classes[$tax_class])) { |
|
513 | + return sanitize_text_field($classes[$tax_class]); |
|
514 | 514 | } |
515 | 515 | |
516 | - return sanitize_text_field( $tax_class ); |
|
516 | + return sanitize_text_field($tax_class); |
|
517 | 517 | |
518 | 518 | } |
519 | 519 | |
@@ -523,14 +523,14 @@ discard block |
||
523 | 523 | * @param string $tax_rule |
524 | 524 | * @return string |
525 | 525 | */ |
526 | -function getpaid_get_tax_rule_label( $tax_rule ) { |
|
526 | +function getpaid_get_tax_rule_label($tax_rule) { |
|
527 | 527 | |
528 | 528 | $rules = getpaid_get_tax_rules(); |
529 | 529 | |
530 | - if ( isset( $rules[ $tax_rule ] ) ) { |
|
531 | - return sanitize_text_field( $rules[ $tax_rule ] ); |
|
530 | + if (isset($rules[$tax_rule])) { |
|
531 | + return sanitize_text_field($rules[$tax_rule]); |
|
532 | 532 | } |
533 | 533 | |
534 | - return sanitize_text_field( $tax_rule ); |
|
534 | + return sanitize_text_field($tax_rule); |
|
535 | 535 | |
536 | 536 | } |