@@ -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> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
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> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
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> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
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> / <span class='getpaid-item-recurring-period'>$frequency</span>"); |
|
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> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
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> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
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> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
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> / <span class='getpaid-item-recurring-period'>$frequency</span>"); |
|
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 |
@@ -12,227 +12,227 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Payment_Form_Submission_Refresh_Prices { |
14 | 14 | |
15 | - /** |
|
16 | - * Contains the response for refreshing prices. |
|
17 | - * @var array |
|
18 | - */ |
|
19 | - public $response = array(); |
|
15 | + /** |
|
16 | + * Contains the response for refreshing prices. |
|
17 | + * @var array |
|
18 | + */ |
|
19 | + public $response = array(); |
|
20 | 20 | |
21 | 21 | /** |
22 | - * Class constructor |
|
23 | - * |
|
24 | - * @param GetPaid_Payment_Form_Submission $submission |
|
25 | - */ |
|
26 | - public function __construct( $submission ) { |
|
27 | - |
|
28 | - $this->response = array( |
|
29 | - 'submission_id' => $submission->id, |
|
22 | + * Class constructor |
|
23 | + * |
|
24 | + * @param GetPaid_Payment_Form_Submission $submission |
|
25 | + */ |
|
26 | + public function __construct( $submission ) { |
|
27 | + |
|
28 | + $this->response = array( |
|
29 | + 'submission_id' => $submission->id, |
|
30 | 30 | 'has_recurring' => $submission->has_recurring, |
31 | 31 | 'is_free' => ! $submission->should_collect_payment_details(), |
32 | - ); |
|
33 | - |
|
34 | - $this->add_totals( $submission ); |
|
35 | - $this->add_texts( $submission ); |
|
36 | - $this->add_items( $submission ); |
|
37 | - $this->add_fees( $submission ); |
|
38 | - $this->add_discounts( $submission ); |
|
39 | - $this->add_taxes( $submission ); |
|
40 | - $this->add_gateways( $submission ); |
|
41 | - |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Adds totals to a response for submission refresh prices. |
|
46 | - * |
|
47 | - * @param GetPaid_Payment_Form_Submission $submission |
|
48 | - */ |
|
49 | - public function add_totals( $submission ) { |
|
50 | - |
|
51 | - $this->response = array_merge( |
|
52 | - $this->response, |
|
53 | - array( |
|
54 | - |
|
55 | - 'totals' => array( |
|
56 | - 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
57 | - 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
58 | - 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
59 | - 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
60 | - 'total' => $submission->format_amount( $submission->get_total() ), |
|
61 | - 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
62 | - ), |
|
63 | - |
|
64 | - 'recurring' => array( |
|
65 | - 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
66 | - 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
67 | - 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
68 | - 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
69 | - 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
70 | - ), |
|
71 | - |
|
72 | - 'initial_amt' => wpinv_round_amount( $submission->get_total(), null, true ), |
|
73 | - 'currency' => $submission->get_currency(), |
|
74 | - |
|
75 | - ) |
|
76 | - ); |
|
77 | - |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Adds texts to a response for submission refresh prices. |
|
82 | - * |
|
83 | - * @param GetPaid_Payment_Form_Submission $submission |
|
84 | - */ |
|
85 | - public function add_texts( $submission ) { |
|
86 | - |
|
87 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
88 | - |
|
89 | - if ( $submission->has_recurring != 0 ) { |
|
90 | - |
|
91 | - $recurring = new WPInv_Item( $submission->has_recurring ); |
|
92 | - $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
93 | - |
|
94 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
95 | - $payable = "$payable / $period"; |
|
96 | - } else { |
|
97 | - $payable = sprintf( |
|
98 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
99 | - $submission->format_amount( $submission->get_total() ), |
|
100 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
101 | - $period |
|
102 | - ); |
|
103 | - } |
|
104 | - |
|
105 | - } |
|
106 | - |
|
107 | - $texts = array( |
|
108 | - '.getpaid-checkout-total-payable' => $payable, |
|
109 | - ); |
|
110 | - |
|
111 | - foreach ( $submission->get_items() as $item_id => $item ) { |
|
112 | - $texts[".item-$item_id .getpaid-item-initial-price"] = $submission->format_amount( $item->get_sub_total() ); |
|
113 | - $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() ); |
|
114 | - } |
|
115 | - |
|
116 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
117 | - |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Adds items to a response for submission refresh prices. |
|
122 | - * |
|
123 | - * @param GetPaid_Payment_Form_Submission $submission |
|
124 | - */ |
|
125 | - public function add_items( $submission ) { |
|
126 | - |
|
127 | - // Add items. |
|
128 | - $items = array(); |
|
32 | + ); |
|
33 | + |
|
34 | + $this->add_totals( $submission ); |
|
35 | + $this->add_texts( $submission ); |
|
36 | + $this->add_items( $submission ); |
|
37 | + $this->add_fees( $submission ); |
|
38 | + $this->add_discounts( $submission ); |
|
39 | + $this->add_taxes( $submission ); |
|
40 | + $this->add_gateways( $submission ); |
|
41 | + |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Adds totals to a response for submission refresh prices. |
|
46 | + * |
|
47 | + * @param GetPaid_Payment_Form_Submission $submission |
|
48 | + */ |
|
49 | + public function add_totals( $submission ) { |
|
50 | + |
|
51 | + $this->response = array_merge( |
|
52 | + $this->response, |
|
53 | + array( |
|
54 | + |
|
55 | + 'totals' => array( |
|
56 | + 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
57 | + 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
58 | + 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
59 | + 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
60 | + 'total' => $submission->format_amount( $submission->get_total() ), |
|
61 | + 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
62 | + ), |
|
63 | + |
|
64 | + 'recurring' => array( |
|
65 | + 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
66 | + 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
67 | + 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
68 | + 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
69 | + 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
70 | + ), |
|
71 | + |
|
72 | + 'initial_amt' => wpinv_round_amount( $submission->get_total(), null, true ), |
|
73 | + 'currency' => $submission->get_currency(), |
|
74 | + |
|
75 | + ) |
|
76 | + ); |
|
77 | + |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Adds texts to a response for submission refresh prices. |
|
82 | + * |
|
83 | + * @param GetPaid_Payment_Form_Submission $submission |
|
84 | + */ |
|
85 | + public function add_texts( $submission ) { |
|
86 | + |
|
87 | + $payable = $submission->format_amount( $submission->get_total() ); |
|
88 | + |
|
89 | + if ( $submission->has_recurring != 0 ) { |
|
90 | + |
|
91 | + $recurring = new WPInv_Item( $submission->has_recurring ); |
|
92 | + $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
93 | + |
|
94 | + if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
95 | + $payable = "$payable / $period"; |
|
96 | + } else { |
|
97 | + $payable = sprintf( |
|
98 | + __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
99 | + $submission->format_amount( $submission->get_total() ), |
|
100 | + $submission->format_amount( $submission->get_recurring_total() ), |
|
101 | + $period |
|
102 | + ); |
|
103 | + } |
|
104 | + |
|
105 | + } |
|
106 | + |
|
107 | + $texts = array( |
|
108 | + '.getpaid-checkout-total-payable' => $payable, |
|
109 | + ); |
|
129 | 110 | |
130 | 111 | foreach ( $submission->get_items() as $item_id => $item ) { |
131 | - $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
132 | - } |
|
112 | + $texts[".item-$item_id .getpaid-item-initial-price"] = $submission->format_amount( $item->get_sub_total() ); |
|
113 | + $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() ); |
|
114 | + } |
|
133 | 115 | |
134 | - $this->response = array_merge( |
|
135 | - $this->response, |
|
136 | - array( 'items' => $items ) |
|
137 | - ); |
|
116 | + $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
138 | 117 | |
139 | - } |
|
118 | + } |
|
140 | 119 | |
141 | - /** |
|
142 | - * Adds fees to a response for submission refresh prices. |
|
143 | - * |
|
144 | - * @param GetPaid_Payment_Form_Submission $submission |
|
145 | - */ |
|
146 | - public function add_fees( $submission ) { |
|
120 | + /** |
|
121 | + * Adds items to a response for submission refresh prices. |
|
122 | + * |
|
123 | + * @param GetPaid_Payment_Form_Submission $submission |
|
124 | + */ |
|
125 | + public function add_items( $submission ) { |
|
126 | + |
|
127 | + // Add items. |
|
128 | + $items = array(); |
|
129 | + |
|
130 | + foreach ( $submission->get_items() as $item_id => $item ) { |
|
131 | + $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
132 | + } |
|
133 | + |
|
134 | + $this->response = array_merge( |
|
135 | + $this->response, |
|
136 | + array( 'items' => $items ) |
|
137 | + ); |
|
138 | + |
|
139 | + } |
|
147 | 140 | |
148 | - $fees = array(); |
|
141 | + /** |
|
142 | + * Adds fees to a response for submission refresh prices. |
|
143 | + * |
|
144 | + * @param GetPaid_Payment_Form_Submission $submission |
|
145 | + */ |
|
146 | + public function add_fees( $submission ) { |
|
147 | + |
|
148 | + $fees = array(); |
|
149 | 149 | |
150 | 150 | foreach ( $submission->get_fees() as $name => $data ) { |
151 | - $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
152 | - } |
|
151 | + $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
152 | + } |
|
153 | 153 | |
154 | - $this->response = array_merge( |
|
155 | - $this->response, |
|
156 | - array( 'fees' => $fees ) |
|
157 | - ); |
|
154 | + $this->response = array_merge( |
|
155 | + $this->response, |
|
156 | + array( 'fees' => $fees ) |
|
157 | + ); |
|
158 | 158 | |
159 | - } |
|
159 | + } |
|
160 | 160 | |
161 | - /** |
|
162 | - * Adds discounts to a response for submission refresh prices. |
|
163 | - * |
|
164 | - * @param GetPaid_Payment_Form_Submission $submission |
|
165 | - */ |
|
166 | - public function add_discounts( $submission ) { |
|
161 | + /** |
|
162 | + * Adds discounts to a response for submission refresh prices. |
|
163 | + * |
|
164 | + * @param GetPaid_Payment_Form_Submission $submission |
|
165 | + */ |
|
166 | + public function add_discounts( $submission ) { |
|
167 | 167 | |
168 | - $discounts = array(); |
|
168 | + $discounts = array(); |
|
169 | 169 | |
170 | 170 | foreach ( $submission->get_discounts() as $name => $data ) { |
171 | - $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
172 | - } |
|
171 | + $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
172 | + } |
|
173 | 173 | |
174 | - $this->response = array_merge( |
|
175 | - $this->response, |
|
176 | - array( 'discounts' => $discounts ) |
|
177 | - ); |
|
174 | + $this->response = array_merge( |
|
175 | + $this->response, |
|
176 | + array( 'discounts' => $discounts ) |
|
177 | + ); |
|
178 | 178 | |
179 | - } |
|
179 | + } |
|
180 | 180 | |
181 | - /** |
|
182 | - * Adds taxes to a response for submission refresh prices. |
|
183 | - * |
|
184 | - * @param GetPaid_Payment_Form_Submission $submission |
|
185 | - */ |
|
186 | - public function add_taxes( $submission ) { |
|
187 | - |
|
188 | - $taxes = array(); |
|
189 | - $markup = ''; |
|
181 | + /** |
|
182 | + * Adds taxes to a response for submission refresh prices. |
|
183 | + * |
|
184 | + * @param GetPaid_Payment_Form_Submission $submission |
|
185 | + */ |
|
186 | + public function add_taxes( $submission ) { |
|
187 | + |
|
188 | + $taxes = array(); |
|
189 | + $markup = ''; |
|
190 | 190 | foreach ( $submission->get_taxes() as $name => $data ) { |
191 | - $name = sanitize_text_field( $name ); |
|
192 | - $amount = $submission->format_amount( $data['initial_tax'] ); |
|
193 | - $taxes[$name] = $amount; |
|
194 | - $markup .= "<small class='form-text'>$name : $amount</small>"; |
|
195 | - } |
|
191 | + $name = sanitize_text_field( $name ); |
|
192 | + $amount = $submission->format_amount( $data['initial_tax'] ); |
|
193 | + $taxes[$name] = $amount; |
|
194 | + $markup .= "<small class='form-text'>$name : $amount</small>"; |
|
195 | + } |
|
196 | 196 | |
197 | - if ( wpinv_display_individual_tax_rates() ) { |
|
198 | - $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
|
199 | - } |
|
197 | + if ( wpinv_display_individual_tax_rates() ) { |
|
198 | + $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
|
199 | + } |
|
200 | 200 | |
201 | - $this->response = array_merge( |
|
202 | - $this->response, |
|
203 | - array( 'taxes' => $taxes ) |
|
204 | - ); |
|
201 | + $this->response = array_merge( |
|
202 | + $this->response, |
|
203 | + array( 'taxes' => $taxes ) |
|
204 | + ); |
|
205 | 205 | |
206 | - } |
|
206 | + } |
|
207 | 207 | |
208 | - /** |
|
209 | - * Adds gateways to a response for submission refresh prices. |
|
210 | - * |
|
211 | - * @param GetPaid_Payment_Form_Submission $submission |
|
212 | - */ |
|
213 | - public function add_gateways( $submission ) { |
|
208 | + /** |
|
209 | + * Adds gateways to a response for submission refresh prices. |
|
210 | + * |
|
211 | + * @param GetPaid_Payment_Form_Submission $submission |
|
212 | + */ |
|
213 | + public function add_gateways( $submission ) { |
|
214 | 214 | |
215 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
215 | + $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
216 | 216 | |
217 | - if ( $this->response['has_recurring'] ) { |
|
217 | + if ( $this->response['has_recurring'] ) { |
|
218 | 218 | |
219 | - foreach ( $gateways as $i => $gateway ) { |
|
219 | + foreach ( $gateways as $i => $gateway ) { |
|
220 | 220 | |
221 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
222 | - unset( $gateways[ $i ] ); |
|
223 | - } |
|
221 | + if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
222 | + unset( $gateways[ $i ] ); |
|
223 | + } |
|
224 | 224 | |
225 | - } |
|
225 | + } |
|
226 | 226 | |
227 | - } |
|
227 | + } |
|
228 | 228 | |
229 | 229 | |
230 | - $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
231 | - $this->response = array_merge( |
|
232 | - $this->response, |
|
233 | - array( 'gateways' => $gateways ) |
|
234 | - ); |
|
230 | + $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
231 | + $this->response = array_merge( |
|
232 | + $this->response, |
|
233 | + array( 'gateways' => $gateways ) |
|
234 | + ); |
|
235 | 235 | |
236 | - } |
|
236 | + } |
|
237 | 237 | |
238 | 238 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Payment form submission refresh prices class |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param GetPaid_Payment_Form_Submission $submission |
25 | 25 | */ |
26 | - public function __construct( $submission ) { |
|
26 | + public function __construct($submission) { |
|
27 | 27 | |
28 | 28 | $this->response = array( |
29 | 29 | 'submission_id' => $submission->id, |
30 | 30 | 'has_recurring' => $submission->has_recurring, |
31 | - 'is_free' => ! $submission->should_collect_payment_details(), |
|
31 | + 'is_free' => !$submission->should_collect_payment_details(), |
|
32 | 32 | ); |
33 | 33 | |
34 | - $this->add_totals( $submission ); |
|
35 | - $this->add_texts( $submission ); |
|
36 | - $this->add_items( $submission ); |
|
37 | - $this->add_fees( $submission ); |
|
38 | - $this->add_discounts( $submission ); |
|
39 | - $this->add_taxes( $submission ); |
|
40 | - $this->add_gateways( $submission ); |
|
34 | + $this->add_totals($submission); |
|
35 | + $this->add_texts($submission); |
|
36 | + $this->add_items($submission); |
|
37 | + $this->add_fees($submission); |
|
38 | + $this->add_discounts($submission); |
|
39 | + $this->add_taxes($submission); |
|
40 | + $this->add_gateways($submission); |
|
41 | 41 | |
42 | 42 | } |
43 | 43 | |
@@ -46,30 +46,30 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @param GetPaid_Payment_Form_Submission $submission |
48 | 48 | */ |
49 | - public function add_totals( $submission ) { |
|
49 | + public function add_totals($submission) { |
|
50 | 50 | |
51 | 51 | $this->response = array_merge( |
52 | 52 | $this->response, |
53 | 53 | array( |
54 | 54 | |
55 | 55 | 'totals' => array( |
56 | - 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
57 | - 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
58 | - 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
59 | - 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
60 | - 'total' => $submission->format_amount( $submission->get_total() ), |
|
61 | - 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
56 | + 'subtotal' => $submission->format_amount($submission->get_subtotal()), |
|
57 | + 'discount' => $submission->format_amount($submission->get_discount()), |
|
58 | + 'fees' => $submission->format_amount($submission->get_fee()), |
|
59 | + 'tax' => $submission->format_amount($submission->get_tax()), |
|
60 | + 'total' => $submission->format_amount($submission->get_total()), |
|
61 | + 'raw_total' => html_entity_decode(sanitize_text_field($submission->format_amount($submission->get_total())), ENT_QUOTES), |
|
62 | 62 | ), |
63 | 63 | |
64 | 64 | 'recurring' => array( |
65 | - 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
66 | - 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
67 | - 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
68 | - 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
69 | - 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
65 | + 'subtotal' => $submission->format_amount($submission->get_recurring_subtotal()), |
|
66 | + 'discount' => $submission->format_amount($submission->get_recurring_discount()), |
|
67 | + 'fees' => $submission->format_amount($submission->get_recurring_fee()), |
|
68 | + 'tax' => $submission->format_amount($submission->get_recurring_tax()), |
|
69 | + 'total' => $submission->format_amount($submission->get_recurring_total()), |
|
70 | 70 | ), |
71 | 71 | |
72 | - 'initial_amt' => wpinv_round_amount( $submission->get_total(), null, true ), |
|
72 | + 'initial_amt' => wpinv_round_amount($submission->get_total(), null, true), |
|
73 | 73 | 'currency' => $submission->get_currency(), |
74 | 74 | |
75 | 75 | ) |
@@ -82,22 +82,22 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @param GetPaid_Payment_Form_Submission $submission |
84 | 84 | */ |
85 | - public function add_texts( $submission ) { |
|
85 | + public function add_texts($submission) { |
|
86 | 86 | |
87 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
87 | + $payable = $submission->format_amount($submission->get_total()); |
|
88 | 88 | |
89 | - if ( $submission->has_recurring != 0 ) { |
|
89 | + if ($submission->has_recurring != 0) { |
|
90 | 90 | |
91 | - $recurring = new WPInv_Item( $submission->has_recurring ); |
|
92 | - $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
91 | + $recurring = new WPInv_Item($submission->has_recurring); |
|
92 | + $period = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), ''); |
|
93 | 93 | |
94 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
94 | + if ($submission->get_total() == $submission->get_recurring_total()) { |
|
95 | 95 | $payable = "$payable / $period"; |
96 | 96 | } else { |
97 | 97 | $payable = sprintf( |
98 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
99 | - $submission->format_amount( $submission->get_total() ), |
|
100 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
98 | + __('%1$s (renews at %2$s / %3$s)', 'invoicing'), |
|
99 | + $submission->format_amount($submission->get_total()), |
|
100 | + $submission->format_amount($submission->get_recurring_total()), |
|
101 | 101 | $period |
102 | 102 | ); |
103 | 103 | } |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | '.getpaid-checkout-total-payable' => $payable, |
109 | 109 | ); |
110 | 110 | |
111 | - foreach ( $submission->get_items() as $item_id => $item ) { |
|
112 | - $texts[".item-$item_id .getpaid-item-initial-price"] = $submission->format_amount( $item->get_sub_total() ); |
|
113 | - $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() ); |
|
111 | + foreach ($submission->get_items() as $item_id => $item) { |
|
112 | + $texts[".item-$item_id .getpaid-item-initial-price"] = $submission->format_amount($item->get_sub_total()); |
|
113 | + $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount($item->get_recurring_sub_total()); |
|
114 | 114 | } |
115 | 115 | |
116 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
116 | + $this->response = array_merge($this->response, array('texts' => $texts)); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
@@ -122,18 +122,18 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @param GetPaid_Payment_Form_Submission $submission |
124 | 124 | */ |
125 | - public function add_items( $submission ) { |
|
125 | + public function add_items($submission) { |
|
126 | 126 | |
127 | 127 | // Add items. |
128 | 128 | $items = array(); |
129 | 129 | |
130 | - foreach ( $submission->get_items() as $item_id => $item ) { |
|
131 | - $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
130 | + foreach ($submission->get_items() as $item_id => $item) { |
|
131 | + $items["$item_id"] = $submission->format_amount($item->get_sub_total()); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | $this->response = array_merge( |
135 | 135 | $this->response, |
136 | - array( 'items' => $items ) |
|
136 | + array('items' => $items) |
|
137 | 137 | ); |
138 | 138 | |
139 | 139 | } |
@@ -143,17 +143,17 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @param GetPaid_Payment_Form_Submission $submission |
145 | 145 | */ |
146 | - public function add_fees( $submission ) { |
|
146 | + public function add_fees($submission) { |
|
147 | 147 | |
148 | 148 | $fees = array(); |
149 | 149 | |
150 | - foreach ( $submission->get_fees() as $name => $data ) { |
|
151 | - $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
150 | + foreach ($submission->get_fees() as $name => $data) { |
|
151 | + $fees[$name] = $submission->format_amount($data['initial_fee']); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | $this->response = array_merge( |
155 | 155 | $this->response, |
156 | - array( 'fees' => $fees ) |
|
156 | + array('fees' => $fees) |
|
157 | 157 | ); |
158 | 158 | |
159 | 159 | } |
@@ -163,17 +163,17 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @param GetPaid_Payment_Form_Submission $submission |
165 | 165 | */ |
166 | - public function add_discounts( $submission ) { |
|
166 | + public function add_discounts($submission) { |
|
167 | 167 | |
168 | 168 | $discounts = array(); |
169 | 169 | |
170 | - foreach ( $submission->get_discounts() as $name => $data ) { |
|
171 | - $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
170 | + foreach ($submission->get_discounts() as $name => $data) { |
|
171 | + $discounts[$name] = $submission->format_amount($data['initial_discount']); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | $this->response = array_merge( |
175 | 175 | $this->response, |
176 | - array( 'discounts' => $discounts ) |
|
176 | + array('discounts' => $discounts) |
|
177 | 177 | ); |
178 | 178 | |
179 | 179 | } |
@@ -183,24 +183,24 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @param GetPaid_Payment_Form_Submission $submission |
185 | 185 | */ |
186 | - public function add_taxes( $submission ) { |
|
186 | + public function add_taxes($submission) { |
|
187 | 187 | |
188 | 188 | $taxes = array(); |
189 | 189 | $markup = ''; |
190 | - foreach ( $submission->get_taxes() as $name => $data ) { |
|
191 | - $name = sanitize_text_field( $name ); |
|
192 | - $amount = $submission->format_amount( $data['initial_tax'] ); |
|
190 | + foreach ($submission->get_taxes() as $name => $data) { |
|
191 | + $name = sanitize_text_field($name); |
|
192 | + $amount = $submission->format_amount($data['initial_tax']); |
|
193 | 193 | $taxes[$name] = $amount; |
194 | 194 | $markup .= "<small class='form-text'>$name : $amount</small>"; |
195 | 195 | } |
196 | 196 | |
197 | - if ( wpinv_display_individual_tax_rates() ) { |
|
197 | + if (wpinv_display_individual_tax_rates()) { |
|
198 | 198 | $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
199 | 199 | } |
200 | 200 | |
201 | 201 | $this->response = array_merge( |
202 | 202 | $this->response, |
203 | - array( 'taxes' => $taxes ) |
|
203 | + array('taxes' => $taxes) |
|
204 | 204 | ); |
205 | 205 | |
206 | 206 | } |
@@ -210,16 +210,16 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @param GetPaid_Payment_Form_Submission $submission |
212 | 212 | */ |
213 | - public function add_gateways( $submission ) { |
|
213 | + public function add_gateways($submission) { |
|
214 | 214 | |
215 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
215 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
216 | 216 | |
217 | - if ( $this->response['has_recurring'] ) { |
|
217 | + if ($this->response['has_recurring']) { |
|
218 | 218 | |
219 | - foreach ( $gateways as $i => $gateway ) { |
|
219 | + foreach ($gateways as $i => $gateway) { |
|
220 | 220 | |
221 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
222 | - unset( $gateways[ $i ] ); |
|
221 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
222 | + unset($gateways[$i]); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | } |
@@ -227,10 +227,10 @@ discard block |
||
227 | 227 | } |
228 | 228 | |
229 | 229 | |
230 | - $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
230 | + $gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission); |
|
231 | 231 | $this->response = array_merge( |
232 | 232 | $this->response, |
233 | - array( 'gateways' => $gateways ) |
|
233 | + array('gateways' => $gateways) |
|
234 | 234 | ); |
235 | 235 | |
236 | 236 | } |
@@ -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 | * Retrieves an item by it's ID. |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | * @param int the item ID to retrieve. |
15 | 15 | * @return WPInv_Item|false |
16 | 16 | */ |
17 | -function wpinv_get_item_by_id( $id ) { |
|
18 | - $item = wpinv_get_item( $id ); |
|
19 | - return empty( $item ) || $id != $item->get_id() ? false : $item; |
|
17 | +function wpinv_get_item_by_id($id) { |
|
18 | + $item = wpinv_get_item($id); |
|
19 | + return empty($item) || $id != $item->get_id() ? false : $item; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return WPInv_Item|false |
26 | 26 | */ |
27 | -function wpinv_get_item_by( $field = '', $value = '', $type = '' ) { |
|
27 | +function wpinv_get_item_by($field = '', $value = '', $type = '') { |
|
28 | 28 | |
29 | - if ( 'id' == strtolower( $field ) ) { |
|
30 | - return wpinv_get_item_by_id( $field ); |
|
29 | + if ('id' == strtolower($field)) { |
|
30 | + return wpinv_get_item_by_id($field); |
|
31 | 31 | } |
32 | 32 | |
33 | - $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type ); |
|
34 | - return empty( $id ) ? false : wpinv_get_item( $id ); |
|
33 | + $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type); |
|
34 | + return empty($id) ? false : wpinv_get_item($id); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
@@ -41,22 +41,22 @@ discard block |
||
41 | 41 | * @param int|WPInv_Item the item to retrieve. |
42 | 42 | * @return WPInv_Item|false |
43 | 43 | */ |
44 | -function wpinv_get_item( $item = 0 ) { |
|
44 | +function wpinv_get_item($item = 0) { |
|
45 | 45 | |
46 | - if ( empty( $item ) ) { |
|
46 | + if (empty($item)) { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | |
50 | - $item = new WPInv_Item( $item ); |
|
50 | + $item = new WPInv_Item($item); |
|
51 | 51 | return $item->exists() ? $item : false; |
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | -function wpinv_get_all_items( $args = array() ) { |
|
55 | +function wpinv_get_all_items($args = array()) { |
|
56 | 56 | |
57 | - $args = wp_parse_args( $args, array( |
|
58 | - 'status' => array( 'publish' ), |
|
59 | - 'limit' => get_option( 'posts_per_page' ), |
|
57 | + $args = wp_parse_args($args, array( |
|
58 | + 'status' => array('publish'), |
|
59 | + 'limit' => get_option('posts_per_page'), |
|
60 | 60 | 'page' => 1, |
61 | 61 | 'exclude' => array(), |
62 | 62 | 'orderby' => 'date', |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'meta_query' => array(), |
66 | 66 | 'return' => 'objects', |
67 | 67 | 'paginate' => false, |
68 | - ) ); |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | $wp_query_args = array( |
71 | 71 | 'post_type' => 'wpi_item', |
@@ -75,26 +75,26 @@ discard block |
||
75 | 75 | 'fields' => 'ids', |
76 | 76 | 'orderby' => $args['orderby'], |
77 | 77 | 'order' => $args['order'], |
78 | - 'paged' => absint( $args['page'] ), |
|
78 | + 'paged' => absint($args['page']), |
|
79 | 79 | ); |
80 | 80 | |
81 | - if ( ! empty( $args['exclude'] ) ) { |
|
82 | - $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] ); |
|
81 | + if (!empty($args['exclude'])) { |
|
82 | + $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']); |
|
83 | 83 | } |
84 | 84 | |
85 | - if ( ! $args['paginate' ] ) { |
|
85 | + if (!$args['paginate']) { |
|
86 | 86 | $wp_query_args['no_found_rows'] = true; |
87 | 87 | } |
88 | 88 | |
89 | - if ( ! empty( $args['search'] ) ) { |
|
89 | + if (!empty($args['search'])) { |
|
90 | 90 | $wp_query_args['s'] = $args['search']; |
91 | 91 | } |
92 | 92 | |
93 | - if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) { |
|
94 | - $types = wpinv_parse_list( $args['type'] ); |
|
93 | + if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) { |
|
94 | + $types = wpinv_parse_list($args['type']); |
|
95 | 95 | $wp_query_args['meta_query'][] = array( |
96 | 96 | 'key' => '_wpinv_type', |
97 | - 'value' => implode( ',', $types ), |
|
97 | + 'value' => implode(',', $types), |
|
98 | 98 | 'compare' => 'IN', |
99 | 99 | ); |
100 | 100 | } |
@@ -102,17 +102,17 @@ discard block |
||
102 | 102 | $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args); |
103 | 103 | |
104 | 104 | // Get results. |
105 | - $items = new WP_Query( $wp_query_args ); |
|
105 | + $items = new WP_Query($wp_query_args); |
|
106 | 106 | |
107 | - if ( 'objects' === $args['return'] ) { |
|
108 | - $return = array_map( 'wpinv_get_item_by_id', $items->posts ); |
|
109 | - } elseif ( 'self' === $args['return'] ) { |
|
107 | + if ('objects' === $args['return']) { |
|
108 | + $return = array_map('wpinv_get_item_by_id', $items->posts); |
|
109 | + } elseif ('self' === $args['return']) { |
|
110 | 110 | return $items; |
111 | 111 | } else { |
112 | 112 | $return = $items->posts; |
113 | 113 | } |
114 | 114 | |
115 | - if ( $args['paginate' ] ) { |
|
115 | + if ($args['paginate']) { |
|
116 | 116 | return (object) array( |
117 | 117 | 'items' => $return, |
118 | 118 | 'total' => $items->found_posts, |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | |
125 | 125 | } |
126 | 126 | |
127 | -function wpinv_is_free_item( $item_id = 0 ) { |
|
128 | - if( empty( $item_id ) ) { |
|
127 | +function wpinv_is_free_item($item_id = 0) { |
|
128 | + if (empty($item_id)) { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | |
132 | - $item = new WPInv_Item( $item_id ); |
|
132 | + $item = new WPInv_Item($item_id); |
|
133 | 133 | |
134 | 134 | return $item->is_free(); |
135 | 135 | } |
@@ -139,21 +139,21 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @param WP_Post|WPInv_Item|Int $item The item to check for. |
141 | 141 | */ |
142 | -function wpinv_item_is_editable( $item = 0 ) { |
|
142 | +function wpinv_item_is_editable($item = 0) { |
|
143 | 143 | |
144 | 144 | // Fetch the item. |
145 | - $item = new WPInv_Item( $item ); |
|
145 | + $item = new WPInv_Item($item); |
|
146 | 146 | |
147 | 147 | // Check if it is editable. |
148 | 148 | return $item->is_editable(); |
149 | 149 | } |
150 | 150 | |
151 | -function wpinv_get_item_price( $item_id = 0 ) { |
|
152 | - if( empty( $item_id ) ) { |
|
151 | +function wpinv_get_item_price($item_id = 0) { |
|
152 | + if (empty($item_id)) { |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | |
156 | - $item = new WPInv_Item( $item_id ); |
|
156 | + $item = new WPInv_Item($item_id); |
|
157 | 157 | |
158 | 158 | return $item->get_price(); |
159 | 159 | } |
@@ -163,96 +163,96 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @param WPInv_Item|int $item |
165 | 165 | */ |
166 | -function wpinv_is_recurring_item( $item = 0 ) { |
|
167 | - $item = new WPInv_Item( $item ); |
|
166 | +function wpinv_is_recurring_item($item = 0) { |
|
167 | + $item = new WPInv_Item($item); |
|
168 | 168 | return $item->is_recurring(); |
169 | 169 | } |
170 | 170 | |
171 | -function wpinv_item_price( $item_id = 0 ) { |
|
172 | - if( empty( $item_id ) ) { |
|
171 | +function wpinv_item_price($item_id = 0) { |
|
172 | + if (empty($item_id)) { |
|
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | |
176 | - $price = wpinv_get_item_price( $item_id ); |
|
177 | - $price = wpinv_price( $price ); |
|
176 | + $price = wpinv_get_item_price($item_id); |
|
177 | + $price = wpinv_price($price); |
|
178 | 178 | |
179 | - return apply_filters( 'wpinv_item_price', $price, $item_id ); |
|
179 | + return apply_filters('wpinv_item_price', $price, $item_id); |
|
180 | 180 | } |
181 | 181 | |
182 | -function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) { |
|
183 | - if ( is_null( $amount_override ) ) { |
|
184 | - $original_price = get_post_meta( $item_id, '_wpinv_price', true ); |
|
182 | +function wpinv_get_item_final_price($item_id = 0, $amount_override = null) { |
|
183 | + if (is_null($amount_override)) { |
|
184 | + $original_price = get_post_meta($item_id, '_wpinv_price', true); |
|
185 | 185 | } else { |
186 | 186 | $original_price = $amount_override; |
187 | 187 | } |
188 | 188 | |
189 | 189 | $price = $original_price; |
190 | 190 | |
191 | - return apply_filters( 'wpinv_get_item_final_price', $price, $item_id ); |
|
191 | + return apply_filters('wpinv_get_item_final_price', $price, $item_id); |
|
192 | 192 | } |
193 | 193 | |
194 | -function wpinv_item_custom_singular_name( $item_id ) { |
|
195 | - if( empty( $item_id ) ) { |
|
194 | +function wpinv_item_custom_singular_name($item_id) { |
|
195 | + if (empty($item_id)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | |
199 | - $item = new WPInv_Item( $item_id ); |
|
199 | + $item = new WPInv_Item($item_id); |
|
200 | 200 | |
201 | 201 | return $item->get_custom_singular_name(); |
202 | 202 | } |
203 | 203 | |
204 | 204 | function wpinv_get_item_types() { |
205 | 205 | $item_types = array( |
206 | - 'custom' => __( 'Standard', 'invoicing' ), |
|
207 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
206 | + 'custom' => __('Standard', 'invoicing'), |
|
207 | + 'fee' => __('Fee', 'invoicing'), |
|
208 | 208 | ); |
209 | - return apply_filters( 'wpinv_get_item_types', $item_types ); |
|
209 | + return apply_filters('wpinv_get_item_types', $item_types); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | function wpinv_item_types() { |
213 | 213 | $item_types = wpinv_get_item_types(); |
214 | 214 | |
215 | - return ( !empty( $item_types ) ? array_keys( $item_types ) : array() ); |
|
215 | + return (!empty($item_types) ? array_keys($item_types) : array()); |
|
216 | 216 | } |
217 | 217 | |
218 | -function wpinv_get_item_type( $item_id ) { |
|
219 | - if( empty( $item_id ) ) { |
|
218 | +function wpinv_get_item_type($item_id) { |
|
219 | + if (empty($item_id)) { |
|
220 | 220 | return false; |
221 | 221 | } |
222 | 222 | |
223 | - $item = new WPInv_Item( $item_id ); |
|
223 | + $item = new WPInv_Item($item_id); |
|
224 | 224 | |
225 | 225 | return $item->get_type(); |
226 | 226 | } |
227 | 227 | |
228 | -function wpinv_item_type( $item_id ) { |
|
228 | +function wpinv_item_type($item_id) { |
|
229 | 229 | $item_types = wpinv_get_item_types(); |
230 | 230 | |
231 | - $item_type = wpinv_get_item_type( $item_id ); |
|
231 | + $item_type = wpinv_get_item_type($item_id); |
|
232 | 232 | |
233 | - if ( empty( $item_type ) ) { |
|
233 | + if (empty($item_type)) { |
|
234 | 234 | $item_type = '-'; |
235 | 235 | } |
236 | 236 | |
237 | - $item_type = isset( $item_types[$item_type] ) ? $item_types[$item_type] : __( $item_type, 'invoicing' ); |
|
237 | + $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing'); |
|
238 | 238 | |
239 | - return apply_filters( 'wpinv_item_type', $item_type, $item_id ); |
|
239 | + return apply_filters('wpinv_item_type', $item_type, $item_id); |
|
240 | 240 | } |
241 | 241 | |
242 | -function wpinv_get_random_item( $post_ids = true ) { |
|
243 | - wpinv_get_random_items( 1, $post_ids ); |
|
242 | +function wpinv_get_random_item($post_ids = true) { |
|
243 | + wpinv_get_random_items(1, $post_ids); |
|
244 | 244 | } |
245 | 245 | |
246 | -function wpinv_get_random_items( $num = 3, $post_ids = true ) { |
|
247 | - if ( $post_ids ) { |
|
248 | - $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids' ); |
|
246 | +function wpinv_get_random_items($num = 3, $post_ids = true) { |
|
247 | + if ($post_ids) { |
|
248 | + $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids'); |
|
249 | 249 | } else { |
250 | - $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num ); |
|
250 | + $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num); |
|
251 | 251 | } |
252 | 252 | |
253 | - $args = apply_filters( 'wpinv_get_random_items', $args ); |
|
253 | + $args = apply_filters('wpinv_get_random_items', $args); |
|
254 | 254 | |
255 | - return get_posts( $args ); |
|
255 | + return get_posts($args); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -261,13 +261,13 @@ discard block |
||
261 | 261 | * @param WPInv_Item|int $item |
262 | 262 | * @param bool $html |
263 | 263 | */ |
264 | -function wpinv_get_item_suffix( $item, $html = true ) { |
|
264 | +function wpinv_get_item_suffix($item, $html = true) { |
|
265 | 265 | |
266 | - $item = new WPInv_Item( $item ); |
|
267 | - $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : ''; |
|
268 | - $suffix = $html ? $suffix : strip_tags( $suffix ); |
|
266 | + $item = new WPInv_Item($item); |
|
267 | + $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''; |
|
268 | + $suffix = $html ? $suffix : strip_tags($suffix); |
|
269 | 269 | |
270 | - return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html ); |
|
270 | + return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | * @param WPInv_Item|int $item |
277 | 277 | * @param bool $force_delete |
278 | 278 | */ |
279 | -function wpinv_remove_item( $item = 0, $force_delete = false ) { |
|
280 | - $item = new WPInv_Item( $item ); |
|
281 | - $item->delete( $force_delete ); |
|
279 | +function wpinv_remove_item($item = 0, $force_delete = false) { |
|
280 | + $item = new WPInv_Item($item); |
|
281 | + $item->delete($force_delete); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -317,45 +317,45 @@ discard block |
||
317 | 317 | * @param bool $wp_error whether or not to return a WP_Error on failure. |
318 | 318 | * @return bool|WP_Error|WPInv_Item |
319 | 319 | */ |
320 | -function wpinv_create_item( $args = array(), $wp_error = false ) { |
|
320 | +function wpinv_create_item($args = array(), $wp_error = false) { |
|
321 | 321 | |
322 | 322 | // Prepare the item. |
323 | - if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) { |
|
324 | - $type = empty( $args['type'] ) ? 'custom' : $args['type']; |
|
325 | - $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type ); |
|
323 | + if (!empty($args['custom_id']) && empty($args['ID'])) { |
|
324 | + $type = empty($args['type']) ? 'custom' : $args['type']; |
|
325 | + $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type); |
|
326 | 326 | |
327 | - if ( ! empty( $item ) ) { |
|
327 | + if (!empty($item)) { |
|
328 | 328 | $args['ID'] = $item->get_id(); |
329 | 329 | } |
330 | 330 | |
331 | 331 | } |
332 | 332 | |
333 | 333 | // Do we have an item? |
334 | - if ( ! empty( $args['ID'] ) ) { |
|
335 | - $item = new WPInv_Item( $args['ID'] ); |
|
334 | + if (!empty($args['ID'])) { |
|
335 | + $item = new WPInv_Item($args['ID']); |
|
336 | 336 | } else { |
337 | 337 | $item = new WPInv_Item(); |
338 | 338 | } |
339 | 339 | |
340 | 340 | // Do we have an error? |
341 | - if ( ! empty( $item->last_error ) ) { |
|
342 | - return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false; |
|
341 | + if (!empty($item->last_error)) { |
|
342 | + return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | // Update item props. |
346 | - $item->set_props( $args ); |
|
346 | + $item->set_props($args); |
|
347 | 347 | |
348 | 348 | // Save the item. |
349 | 349 | $item->save(); |
350 | 350 | |
351 | 351 | // Do we have an error? |
352 | - if ( ! empty( $item->last_error ) ) { |
|
353 | - return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false; |
|
352 | + if (!empty($item->last_error)) { |
|
353 | + return $wp_error ? new WP_Error('not_saved', $item->last_error) : false; |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | // Was the item saved? |
357 | - if ( ! $item->get_id() ) { |
|
358 | - return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false; |
|
357 | + if (!$item->get_id()) { |
|
358 | + return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false; |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | return $item; |
@@ -367,14 +367,14 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @see wpinv_create_item() |
369 | 369 | */ |
370 | -function wpinv_update_item( $args = array(), $wp_error = false ) { |
|
371 | - return wpinv_create_item( $args, $wp_error ); |
|
370 | +function wpinv_update_item($args = array(), $wp_error = false) { |
|
371 | + return wpinv_create_item($args, $wp_error); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
375 | 375 | * Sanitizes a recurring period |
376 | 376 | */ |
377 | -function getpaid_sanitize_recurring_period( $period, $full = false ) { |
|
377 | +function getpaid_sanitize_recurring_period($period, $full = false) { |
|
378 | 378 | |
379 | 379 | $periods = array( |
380 | 380 | 'D' => 'day', |
@@ -383,11 +383,11 @@ discard block |
||
383 | 383 | 'Y' => 'year', |
384 | 384 | ); |
385 | 385 | |
386 | - if ( ! isset( $periods[ $period ] ) ) { |
|
386 | + if (!isset($periods[$period])) { |
|
387 | 387 | $period = 'D'; |
388 | 388 | } |
389 | 389 | |
390 | - return $full ? $periods[ $period ] : $period; |
|
390 | + return $full ? $periods[$period] : $period; |
|
391 | 391 | |
392 | 392 | } |
393 | 393 | |
@@ -396,34 +396,34 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @param WPInv_Item|GetPaid_Form_Item $item |
398 | 398 | */ |
399 | -function getpaid_item_recurring_price_help_text( $item, $currency = '' ) { |
|
399 | +function getpaid_item_recurring_price_help_text($item, $currency = '') { |
|
400 | 400 | |
401 | 401 | // Abort if it is not recurring. |
402 | - if ( ! $item->is_recurring() ) { |
|
402 | + if (!$item->is_recurring()) { |
|
403 | 403 | return ''; |
404 | 404 | } |
405 | 405 | |
406 | - $initial_price = wpinv_price( $item->get_initial_price(), $currency ); |
|
407 | - $recurring_price = wpinv_price( $item->get_recurring_price(), $currency ); |
|
408 | - $period = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ); |
|
406 | + $initial_price = wpinv_price($item->get_initial_price(), $currency); |
|
407 | + $recurring_price = wpinv_price($item->get_recurring_price(), $currency); |
|
408 | + $period = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), ''); |
|
409 | 409 | $initial_class = 'getpaid-item-initial-price'; |
410 | 410 | $recurring_class = 'getpaid-item-recurring-price'; |
411 | 411 | |
412 | - if ( $item instanceof GetPaid_Form_Item ) { |
|
413 | - $initial_price = wpinv_price( $item->get_sub_total(), $currency ); |
|
414 | - $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency ); |
|
412 | + if ($item instanceof GetPaid_Form_Item) { |
|
413 | + $initial_price = wpinv_price($item->get_sub_total(), $currency); |
|
414 | + $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | // For free trial items. |
418 | - if ( $item->has_free_trial() ) { |
|
419 | - $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() ); |
|
418 | + if ($item->has_free_trial()) { |
|
419 | + $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval()); |
|
420 | 420 | |
421 | - if ( 0 == $item->get_initial_price() ) { |
|
421 | + if (0 == $item->get_initial_price()) { |
|
422 | 422 | |
423 | 423 | return sprintf( |
424 | 424 | |
425 | 425 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period |
426 | - _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ), |
|
426 | + _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'), |
|
427 | 427 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
428 | 428 | "<span class='$recurring_class'>$recurring_price</span>", |
429 | 429 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | return sprintf( |
436 | 436 | |
437 | 437 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period |
438 | - _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ), |
|
438 | + _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'), |
|
439 | 439 | "<span class='$initial_class'>$initial_price</span>", |
440 | 440 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
441 | 441 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -445,12 +445,12 @@ discard block |
||
445 | 445 | |
446 | 446 | } |
447 | 447 | |
448 | - if ( $initial_price == $recurring_price ) { |
|
448 | + if ($initial_price == $recurring_price) { |
|
449 | 449 | |
450 | 450 | return sprintf( |
451 | 451 | |
452 | 452 | // translators: $1: is the recurring price, $2: is the susbcription period |
453 | - _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
453 | + _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
454 | 454 | "<span class='$recurring_class'>$recurring_price</span>", |
455 | 455 | "<span class='getpaid-item-recurring-period'>$period</span>" |
456 | 456 | |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | return sprintf( |
462 | 462 | |
463 | 463 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period |
464 | - _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ), |
|
464 | + _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'), |
|
465 | 465 | "<span class='$initial_class'>$initial_price</span>", |
466 | 466 | "<span class='$recurring_class'>$recurring_price</span>", |
467 | 467 | "<span class='getpaid-item-recurring-period'>$period</span>" |