@@ -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); |
@@ -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); |
@@ -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 | $trial_period, |
428 | 428 | "<span class='$recurring_class'>$recurring_price</span>", |
429 | 429 | $period |
@@ -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 | $trial_period, |
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 | $period |
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 | $period |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function wpinv_subscriptions_page() { |
16 | 16 | |
17 | - ?> |
|
17 | + ?> |
|
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,27 +22,27 @@ discard block |
||
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | - // Verify user permissions. |
|
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
25 | + // Verify user permissions. |
|
26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
27 | 27 | |
28 | - echo aui()->alert( |
|
29 | - array( |
|
30 | - 'type' => 'danger', |
|
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | - ) |
|
33 | - ); |
|
28 | + echo aui()->alert( |
|
29 | + array( |
|
30 | + 'type' => 'danger', |
|
31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | + ) |
|
33 | + ); |
|
34 | 34 | |
35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
36 | 36 | |
37 | - // Display a single subscription. |
|
38 | - wpinv_recurring_subscription_details(); |
|
39 | - } else { |
|
37 | + // Display a single subscription. |
|
38 | + wpinv_recurring_subscription_details(); |
|
39 | + } else { |
|
40 | 40 | |
41 | - // Display a list of available subscriptions. |
|
42 | - getpaid_print_subscriptions_list(); |
|
43 | - } |
|
41 | + // Display a list of available subscriptions. |
|
42 | + getpaid_print_subscriptions_list(); |
|
43 | + } |
|
44 | 44 | |
45 | - ?> |
|
45 | + ?> |
|
46 | 46 | |
47 | 47 | </div> |
48 | 48 | </div> |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function getpaid_print_subscriptions_list() { |
61 | 61 | |
62 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
63 | - $subscribers_table->prepare_items(); |
|
62 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
63 | + $subscribers_table->prepare_items(); |
|
64 | 64 | |
65 | - ?> |
|
65 | + ?> |
|
66 | 66 | <form id="subscribers-filter" class="bsui" method="get"> |
67 | 67 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
68 | 68 | <?php $subscribers_table->views(); ?> |
@@ -80,27 +80,27 @@ discard block |
||
80 | 80 | */ |
81 | 81 | function wpinv_recurring_subscription_details() { |
82 | 82 | |
83 | - // Fetch the subscription. |
|
84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | - if ( ! $sub->get_id() ) { |
|
83 | + // Fetch the subscription. |
|
84 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | + if ( ! $sub->get_id() ) { |
|
86 | 86 | |
87 | - echo aui()->alert( |
|
88 | - array( |
|
89 | - 'type' => 'danger', |
|
90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
91 | - ) |
|
92 | - ); |
|
87 | + echo aui()->alert( |
|
88 | + array( |
|
89 | + 'type' => 'danger', |
|
90 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
91 | + ) |
|
92 | + ); |
|
93 | 93 | |
94 | - return; |
|
95 | - } |
|
94 | + return; |
|
95 | + } |
|
96 | 96 | |
97 | - // Use metaboxes to display the subscription details. |
|
98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' ); |
|
99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
101 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
97 | + // Use metaboxes to display the subscription details. |
|
98 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' ); |
|
99 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
101 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
102 | 102 | |
103 | - ?> |
|
103 | + ?> |
|
104 | 104 | |
105 | 105 | <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
106 | 106 | |
@@ -140,41 +140,41 @@ discard block |
||
140 | 140 | */ |
141 | 141 | function getpaid_admin_subscription_details_metabox( $sub ) { |
142 | 142 | |
143 | - // Prepare subscription detail columns. |
|
144 | - $fields = apply_filters( |
|
145 | - 'getpaid_subscription_admin_page_fields', |
|
146 | - array( |
|
147 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
148 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
149 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
150 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
151 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
152 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
153 | - 'item' => __( 'Item', 'invoicing' ), |
|
154 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
155 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
156 | - 'status' => __( 'Status', 'invoicing' ), |
|
157 | - ) |
|
158 | - ); |
|
159 | - |
|
160 | - if ( ! $sub->is_active() ) { |
|
161 | - |
|
162 | - if ( isset( $fields['renews_on'] ) ) { |
|
163 | - unset( $fields['renews_on'] ); |
|
164 | - } |
|
165 | - |
|
166 | - if ( isset( $fields['gateway'] ) ) { |
|
167 | - unset( $fields['gateway'] ); |
|
168 | - } |
|
143 | + // Prepare subscription detail columns. |
|
144 | + $fields = apply_filters( |
|
145 | + 'getpaid_subscription_admin_page_fields', |
|
146 | + array( |
|
147 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
148 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
149 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
150 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
151 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
152 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
153 | + 'item' => __( 'Item', 'invoicing' ), |
|
154 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
155 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
156 | + 'status' => __( 'Status', 'invoicing' ), |
|
157 | + ) |
|
158 | + ); |
|
159 | + |
|
160 | + if ( ! $sub->is_active() ) { |
|
161 | + |
|
162 | + if ( isset( $fields['renews_on'] ) ) { |
|
163 | + unset( $fields['renews_on'] ); |
|
164 | + } |
|
165 | + |
|
166 | + if ( isset( $fields['gateway'] ) ) { |
|
167 | + unset( $fields['gateway'] ); |
|
168 | + } |
|
169 | 169 | |
170 | - } |
|
170 | + } |
|
171 | 171 | |
172 | - $profile_id = $sub->get_profile_id(); |
|
173 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
174 | - unset( $fields['profile_id'] ); |
|
175 | - } |
|
172 | + $profile_id = $sub->get_profile_id(); |
|
173 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
174 | + unset( $fields['profile_id'] ); |
|
175 | + } |
|
176 | 176 | |
177 | - ?> |
|
177 | + ?> |
|
178 | 178 | |
179 | 179 | <table class="table table-borderless" style="font-size: 14px;"> |
180 | 180 | <tbody> |
@@ -208,20 +208,20 @@ discard block |
||
208 | 208 | */ |
209 | 209 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
210 | 210 | |
211 | - $username = __( '(Missing User)', 'invoicing' ); |
|
211 | + $username = __( '(Missing User)', 'invoicing' ); |
|
212 | 212 | |
213 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
214 | - if ( $user ) { |
|
213 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
214 | + if ( $user ) { |
|
215 | 215 | |
216 | - $username = sprintf( |
|
217 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
218 | - absint( $user->ID ), |
|
219 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
220 | - ); |
|
216 | + $username = sprintf( |
|
217 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
218 | + absint( $user->ID ), |
|
219 | + ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
220 | + ); |
|
221 | 221 | |
222 | - } |
|
222 | + } |
|
223 | 223 | |
224 | - echo $username; |
|
224 | + echo $username; |
|
225 | 225 | } |
226 | 226 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
227 | 227 | |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * @param WPInv_Subscription $subscription |
232 | 232 | */ |
233 | 233 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
234 | - $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
235 | - echo "<span>$amount</span>"; |
|
234 | + $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
235 | + echo "<span>$amount</span>"; |
|
236 | 236 | } |
237 | 237 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
238 | 238 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @param WPInv_Subscription $subscription |
243 | 243 | */ |
244 | 244 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
245 | - echo '#' . absint( $subscription->get_id() ); |
|
245 | + echo '#' . absint( $subscription->get_id() ); |
|
246 | 246 | } |
247 | 247 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
248 | 248 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @param WPInv_Subscription $subscription |
253 | 253 | */ |
254 | 254 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
255 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
255 | + echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
256 | 256 | } |
257 | 257 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
258 | 258 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param WPInv_Subscription $subscription |
263 | 263 | */ |
264 | 264 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
265 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
265 | + echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
266 | 266 | } |
267 | 267 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
268 | 268 | |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | * @param WPInv_Subscription $subscription |
273 | 273 | */ |
274 | 274 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
275 | - $max_bills = $subscription->get_bill_times(); |
|
276 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
275 | + $max_bills = $subscription->get_bill_times(); |
|
276 | + echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
277 | 277 | } |
278 | 278 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
279 | 279 | /** |
@@ -283,16 +283,16 @@ discard block |
||
283 | 283 | */ |
284 | 284 | function getpaid_admin_subscription_metabox_display_item( $subscription ) { |
285 | 285 | |
286 | - $item = get_post( $subscription->get_product_id() ); |
|
286 | + $item = get_post( $subscription->get_product_id() ); |
|
287 | 287 | |
288 | - if ( ! empty( $item ) ) { |
|
289 | - $link = get_edit_post_link( $item ); |
|
290 | - $link = esc_url( $link ); |
|
291 | - $name = esc_html( get_the_title( $item ) ); |
|
292 | - echo "<a href='$link'>$name</a>"; |
|
293 | - } else { |
|
294 | - echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
295 | - } |
|
288 | + if ( ! empty( $item ) ) { |
|
289 | + $link = get_edit_post_link( $item ); |
|
290 | + $link = esc_url( $link ); |
|
291 | + $name = esc_html( get_the_title( $item ) ); |
|
292 | + echo "<a href='$link'>$name</a>"; |
|
293 | + } else { |
|
294 | + echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
295 | + } |
|
296 | 296 | |
297 | 297 | } |
298 | 298 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item' ); |
@@ -304,13 +304,13 @@ discard block |
||
304 | 304 | */ |
305 | 305 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
306 | 306 | |
307 | - $gateway = $subscription->get_gateway(); |
|
307 | + $gateway = $subscription->get_gateway(); |
|
308 | 308 | |
309 | - if ( ! empty( $gateway ) ) { |
|
310 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
311 | - } else { |
|
312 | - echo "—"; |
|
313 | - } |
|
309 | + if ( ! empty( $gateway ) ) { |
|
310 | + echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
311 | + } else { |
|
312 | + echo "—"; |
|
313 | + } |
|
314 | 314 | |
315 | 315 | } |
316 | 316 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @param WPInv_Subscription $subscription |
322 | 322 | */ |
323 | 323 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
324 | - echo $subscription->get_status_label_html(); |
|
324 | + echo $subscription->get_status_label_html(); |
|
325 | 325 | } |
326 | 326 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
327 | 327 | |
@@ -332,14 +332,14 @@ discard block |
||
332 | 332 | */ |
333 | 333 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
334 | 334 | |
335 | - $profile_id = $subscription->get_profile_id(); |
|
335 | + $profile_id = $subscription->get_profile_id(); |
|
336 | 336 | |
337 | - if ( ! empty( $profile_id ) ) { |
|
338 | - $profile_id = sanitize_text_field( $profile_id ); |
|
339 | - echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription ); |
|
340 | - } else { |
|
341 | - echo "—"; |
|
342 | - } |
|
337 | + if ( ! empty( $profile_id ) ) { |
|
338 | + $profile_id = sanitize_text_field( $profile_id ); |
|
339 | + echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription ); |
|
340 | + } else { |
|
341 | + echo "—"; |
|
342 | + } |
|
343 | 343 | |
344 | 344 | } |
345 | 345 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -351,39 +351,39 @@ discard block |
||
351 | 351 | */ |
352 | 352 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
353 | 353 | |
354 | - ?> |
|
354 | + ?> |
|
355 | 355 | <div class="mt-3"> |
356 | 356 | |
357 | 357 | <?php |
358 | - echo aui()->select( |
|
359 | - array( |
|
360 | - 'options' => getpaid_get_subscription_statuses(), |
|
361 | - 'name' => 'subscription_status', |
|
362 | - 'id' => 'subscription_status_update_select', |
|
363 | - 'required' => true, |
|
364 | - 'no_wrap' => false, |
|
365 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
366 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
367 | - 'select2' => true, |
|
368 | - 'value' => $subscription->get_status( 'edit' ), |
|
369 | - ) |
|
370 | - ); |
|
371 | - ?> |
|
358 | + echo aui()->select( |
|
359 | + array( |
|
360 | + 'options' => getpaid_get_subscription_statuses(), |
|
361 | + 'name' => 'subscription_status', |
|
362 | + 'id' => 'subscription_status_update_select', |
|
363 | + 'required' => true, |
|
364 | + 'no_wrap' => false, |
|
365 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
366 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
367 | + 'select2' => true, |
|
368 | + 'value' => $subscription->get_status( 'edit' ), |
|
369 | + ) |
|
370 | + ); |
|
371 | + ?> |
|
372 | 372 | |
373 | 373 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
374 | 374 | |
375 | 375 | <?php |
376 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
376 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
377 | 377 | |
378 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
379 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
380 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
378 | + $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
379 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
380 | + $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
381 | 381 | |
382 | - if ( $subscription->is_active() ) { |
|
383 | - echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
384 | - } |
|
382 | + if ( $subscription->is_active() ) { |
|
383 | + echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
384 | + } |
|
385 | 385 | |
386 | - echo '</div></div>'; |
|
386 | + echo '</div></div>'; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -393,33 +393,33 @@ discard block |
||
393 | 393 | */ |
394 | 394 | function getpaid_admin_subscription_invoice_details_metabox( $subscription ) { |
395 | 395 | |
396 | - $columns = apply_filters( |
|
397 | - 'getpaid_subscription_related_invoices_columns', |
|
398 | - array( |
|
399 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
400 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
401 | - 'date' => __( 'Date', 'invoicing' ), |
|
402 | - 'status' => __( 'Status', 'invoicing' ), |
|
403 | - 'total' => __( 'Total', 'invoicing' ), |
|
404 | - ), |
|
405 | - $subscription |
|
406 | - ); |
|
407 | - |
|
408 | - // Prepare the invoices. |
|
409 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
410 | - $parent = $subscription->get_parent_invoice(); |
|
411 | - |
|
412 | - if ( $parent->get_id() ) { |
|
413 | - $payments = array_merge( array( $parent ), $payments ); |
|
414 | - } |
|
396 | + $columns = apply_filters( |
|
397 | + 'getpaid_subscription_related_invoices_columns', |
|
398 | + array( |
|
399 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
400 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
401 | + 'date' => __( 'Date', 'invoicing' ), |
|
402 | + 'status' => __( 'Status', 'invoicing' ), |
|
403 | + 'total' => __( 'Total', 'invoicing' ), |
|
404 | + ), |
|
405 | + $subscription |
|
406 | + ); |
|
407 | + |
|
408 | + // Prepare the invoices. |
|
409 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
410 | + $parent = $subscription->get_parent_invoice(); |
|
411 | + |
|
412 | + if ( $parent->get_id() ) { |
|
413 | + $payments = array_merge( array( $parent ), $payments ); |
|
414 | + } |
|
415 | 415 | |
416 | - $table_class = 'w-100 bg-white'; |
|
416 | + $table_class = 'w-100 bg-white'; |
|
417 | 417 | |
418 | - if ( ! is_admin() ) { |
|
419 | - $table_class = 'table table-bordered table-striped'; |
|
420 | - } |
|
418 | + if ( ! is_admin() ) { |
|
419 | + $table_class = 'table table-bordered table-striped'; |
|
420 | + } |
|
421 | 421 | |
422 | - ?> |
|
422 | + ?> |
|
423 | 423 | <div class="m-0" style="overflow: auto;"> |
424 | 424 | |
425 | 425 | <table class="<?php echo $table_class; ?>"> |
@@ -427,13 +427,13 @@ discard block |
||
427 | 427 | <thead> |
428 | 428 | <tr> |
429 | 429 | <?php |
430 | - foreach ( $columns as $key => $label ) { |
|
431 | - $key = esc_attr( $key ); |
|
432 | - $label = sanitize_text_field( $label ); |
|
430 | + foreach ( $columns as $key => $label ) { |
|
431 | + $key = esc_attr( $key ); |
|
432 | + $label = sanitize_text_field( $label ); |
|
433 | 433 | |
434 | - echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
435 | - } |
|
436 | - ?> |
|
434 | + echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
|
435 | + } |
|
436 | + ?> |
|
437 | 437 | </tr> |
438 | 438 | </thead> |
439 | 439 | |
@@ -449,66 +449,66 @@ discard block |
||
449 | 449 | |
450 | 450 | <?php |
451 | 451 | |
452 | - foreach( $payments as $payment ) : |
|
452 | + foreach( $payments as $payment ) : |
|
453 | 453 | |
454 | - // Ensure that we have an invoice. |
|
455 | - $payment = new WPInv_Invoice( $payment ); |
|
454 | + // Ensure that we have an invoice. |
|
455 | + $payment = new WPInv_Invoice( $payment ); |
|
456 | 456 | |
457 | - // Abort if the invoice is invalid. |
|
458 | - if ( ! $payment->get_id() ) { |
|
459 | - continue; |
|
460 | - } |
|
457 | + // Abort if the invoice is invalid. |
|
458 | + if ( ! $payment->get_id() ) { |
|
459 | + continue; |
|
460 | + } |
|
461 | 461 | |
462 | - echo '<tr>'; |
|
462 | + echo '<tr>'; |
|
463 | 463 | |
464 | - foreach ( array_keys( $columns ) as $key ) { |
|
464 | + foreach ( array_keys( $columns ) as $key ) { |
|
465 | 465 | |
466 | - echo '<td class="p-2 text-left">'; |
|
466 | + echo '<td class="p-2 text-left">'; |
|
467 | 467 | |
468 | - switch( $key ) { |
|
468 | + switch( $key ) { |
|
469 | 469 | |
470 | - case 'total': |
|
471 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
472 | - break; |
|
470 | + case 'total': |
|
471 | + echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
472 | + break; |
|
473 | 473 | |
474 | - case 'relationship': |
|
475 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
476 | - break; |
|
474 | + case 'relationship': |
|
475 | + echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
476 | + break; |
|
477 | 477 | |
478 | - case 'date': |
|
479 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
480 | - break; |
|
478 | + case 'date': |
|
479 | + echo getpaid_format_date_value( $payment->get_date_created() ); |
|
480 | + break; |
|
481 | 481 | |
482 | - case 'status': |
|
482 | + case 'status': |
|
483 | 483 | |
484 | - $status = $payment->get_status_nicename(); |
|
485 | - if ( is_admin() ) { |
|
486 | - $status = $payment->get_status_label_html(); |
|
487 | - } |
|
484 | + $status = $payment->get_status_nicename(); |
|
485 | + if ( is_admin() ) { |
|
486 | + $status = $payment->get_status_label_html(); |
|
487 | + } |
|
488 | 488 | |
489 | - echo $status; |
|
490 | - break; |
|
489 | + echo $status; |
|
490 | + break; |
|
491 | 491 | |
492 | - case 'invoice': |
|
493 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
492 | + case 'invoice': |
|
493 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
494 | 494 | |
495 | - if ( ! is_admin() ) { |
|
496 | - $link = esc_url( $payment->get_view_url() ); |
|
497 | - } |
|
495 | + if ( ! is_admin() ) { |
|
496 | + $link = esc_url( $payment->get_view_url() ); |
|
497 | + } |
|
498 | 498 | |
499 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
500 | - echo "<a href='$link'>$invoice</a>"; |
|
501 | - break; |
|
502 | - } |
|
499 | + $invoice = sanitize_text_field( $payment->get_number() ); |
|
500 | + echo "<a href='$link'>$invoice</a>"; |
|
501 | + break; |
|
502 | + } |
|
503 | 503 | |
504 | - echo '</td>'; |
|
504 | + echo '</td>'; |
|
505 | 505 | |
506 | - } |
|
506 | + } |
|
507 | 507 | |
508 | - echo '</tr>'; |
|
508 | + echo '</tr>'; |
|
509 | 509 | |
510 | - endforeach; |
|
511 | - ?> |
|
510 | + endforeach; |
|
511 | + ?> |
|
512 | 512 | |
513 | 513 | </tbody> |
514 | 514 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains functions that display the subscriptions admin page. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Render the Subscriptions page |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
21 | 21 | <div class="bsui"> |
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | 25 | // Verify user permissions. |
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
27 | 27 | |
28 | 28 | echo aui()->alert( |
29 | 29 | array( |
30 | 30 | 'type' => 'danger', |
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
32 | 32 | ) |
33 | 33 | ); |
34 | 34 | |
35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } else if (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
36 | 36 | |
37 | 37 | // Display a single subscription. |
38 | 38 | wpinv_recurring_subscription_details(); |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | function wpinv_recurring_subscription_details() { |
82 | 82 | |
83 | 83 | // Fetch the subscription. |
84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | - if ( ! $sub->get_id() ) { |
|
84 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
85 | + if (!$sub->get_id()) { |
|
86 | 86 | |
87 | 87 | echo aui()->alert( |
88 | 88 | array( |
89 | 89 | 'type' => 'danger', |
90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
90 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
91 | 91 | ) |
92 | 92 | ); |
93 | 93 | |
@@ -95,31 +95,31 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | // Use metaboxes to display the subscription details. |
98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' ); |
|
99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
101 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
98 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal'); |
|
99 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
100 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
101 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
102 | 102 | |
103 | 103 | ?> |
104 | 104 | |
105 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
105 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
106 | 106 | |
107 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
108 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
109 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
107 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
108 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
109 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
110 | 110 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
111 | - <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" /> |
|
111 | + <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
|
112 | 112 | |
113 | 113 | <div id="poststuff"> |
114 | 114 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
115 | 115 | |
116 | 116 | <div id="postbox-container-1" class="postbox-container"> |
117 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
117 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
118 | 118 | </div> |
119 | 119 | |
120 | 120 | <div id="postbox-container-2" class="postbox-container"> |
121 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
122 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
121 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
122 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
123 | 123 | </div> |
124 | 124 | |
125 | 125 | </div> |
@@ -138,40 +138,40 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @param WPInv_Subscription $sub |
140 | 140 | */ |
141 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
141 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
142 | 142 | |
143 | 143 | // Prepare subscription detail columns. |
144 | 144 | $fields = apply_filters( |
145 | 145 | 'getpaid_subscription_admin_page_fields', |
146 | 146 | array( |
147 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
148 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
149 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
150 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
151 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
152 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
153 | - 'item' => __( 'Item', 'invoicing' ), |
|
154 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
155 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
156 | - 'status' => __( 'Status', 'invoicing' ), |
|
147 | + 'subscription' => __('Subscription', 'invoicing'), |
|
148 | + 'customer' => __('Customer', 'invoicing'), |
|
149 | + 'amount' => __('Amount', 'invoicing'), |
|
150 | + 'start_date' => __('Start Date', 'invoicing'), |
|
151 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
152 | + 'renewals' => __('Payments', 'invoicing'), |
|
153 | + 'item' => __('Item', 'invoicing'), |
|
154 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
155 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
156 | + 'status' => __('Status', 'invoicing'), |
|
157 | 157 | ) |
158 | 158 | ); |
159 | 159 | |
160 | - if ( ! $sub->is_active() ) { |
|
160 | + if (!$sub->is_active()) { |
|
161 | 161 | |
162 | - if ( isset( $fields['renews_on'] ) ) { |
|
163 | - unset( $fields['renews_on'] ); |
|
162 | + if (isset($fields['renews_on'])) { |
|
163 | + unset($fields['renews_on']); |
|
164 | 164 | } |
165 | 165 | |
166 | - if ( isset( $fields['gateway'] ) ) { |
|
167 | - unset( $fields['gateway'] ); |
|
166 | + if (isset($fields['gateway'])) { |
|
167 | + unset($fields['gateway']); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | } |
171 | 171 | |
172 | 172 | $profile_id = $sub->get_profile_id(); |
173 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
174 | - unset( $fields['profile_id'] ); |
|
173 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
174 | + unset($fields['profile_id']); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | ?> |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | <table class="table table-borderless" style="font-size: 14px;"> |
180 | 180 | <tbody> |
181 | 181 | |
182 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
182 | + <?php foreach ($fields as $key => $label) : ?> |
|
183 | 183 | |
184 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
184 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
185 | 185 | |
186 | 186 | <th class="w-25" style="font-weight: 500;"> |
187 | - <?php echo sanitize_text_field( $label ); ?> |
|
187 | + <?php echo sanitize_text_field($label); ?> |
|
188 | 188 | </th> |
189 | 189 | |
190 | 190 | <td class="w-75 text-muted"> |
191 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_text_field( $key ), $sub ); ?> |
|
191 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_text_field($key), $sub); ?> |
|
192 | 192 | </td> |
193 | 193 | |
194 | 194 | </tr> |
@@ -206,150 +206,150 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @param WPInv_Subscription $subscription |
208 | 208 | */ |
209 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
209 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
210 | 210 | |
211 | - $username = __( '(Missing User)', 'invoicing' ); |
|
211 | + $username = __('(Missing User)', 'invoicing'); |
|
212 | 212 | |
213 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
214 | - if ( $user ) { |
|
213 | + $user = get_userdata($subscription->get_customer_id()); |
|
214 | + if ($user) { |
|
215 | 215 | |
216 | 216 | $username = sprintf( |
217 | 217 | '<a href="user-edit.php?user_id=%s">%s</a>', |
218 | - absint( $user->ID ), |
|
219 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
218 | + absint($user->ID), |
|
219 | + !empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email) |
|
220 | 220 | ); |
221 | 221 | |
222 | 222 | } |
223 | 223 | |
224 | 224 | echo $username; |
225 | 225 | } |
226 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
226 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
227 | 227 | |
228 | 228 | /** |
229 | 229 | * Displays the subscription amount. |
230 | 230 | * |
231 | 231 | * @param WPInv_Subscription $subscription |
232 | 232 | */ |
233 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
234 | - $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
233 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
234 | + $amount = sanitize_text_field(getpaid_get_formatted_subscription_amount($subscription)); |
|
235 | 235 | echo "<span>$amount</span>"; |
236 | 236 | } |
237 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
237 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
238 | 238 | |
239 | 239 | /** |
240 | 240 | * Displays the subscription id. |
241 | 241 | * |
242 | 242 | * @param WPInv_Subscription $subscription |
243 | 243 | */ |
244 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
245 | - echo '#' . absint( $subscription->get_id() ); |
|
244 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
245 | + echo '#' . absint($subscription->get_id()); |
|
246 | 246 | } |
247 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
247 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
248 | 248 | |
249 | 249 | /** |
250 | 250 | * Displays the subscription renewal date. |
251 | 251 | * |
252 | 252 | * @param WPInv_Subscription $subscription |
253 | 253 | */ |
254 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
255 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
254 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
255 | + echo getpaid_format_date_value($subscription->get_date_created()); |
|
256 | 256 | } |
257 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
257 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Displays the subscription renewal date. |
261 | 261 | * |
262 | 262 | * @param WPInv_Subscription $subscription |
263 | 263 | */ |
264 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
265 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
264 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
265 | + echo getpaid_format_date_value($subscription->get_expiration()); |
|
266 | 266 | } |
267 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
267 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
268 | 268 | |
269 | 269 | /** |
270 | 270 | * Displays the subscription renewal count. |
271 | 271 | * |
272 | 272 | * @param WPInv_Subscription $subscription |
273 | 273 | */ |
274 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
274 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
275 | 275 | $max_bills = $subscription->get_bill_times(); |
276 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
276 | + echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
277 | 277 | } |
278 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
278 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
279 | 279 | /** |
280 | 280 | * Displays the subscription item. |
281 | 281 | * |
282 | 282 | * @param WPInv_Subscription $subscription |
283 | 283 | */ |
284 | -function getpaid_admin_subscription_metabox_display_item( $subscription ) { |
|
284 | +function getpaid_admin_subscription_metabox_display_item($subscription) { |
|
285 | 285 | |
286 | - $item = get_post( $subscription->get_product_id() ); |
|
286 | + $item = get_post($subscription->get_product_id()); |
|
287 | 287 | |
288 | - if ( ! empty( $item ) ) { |
|
289 | - $link = get_edit_post_link( $item ); |
|
290 | - $link = esc_url( $link ); |
|
291 | - $name = esc_html( get_the_title( $item ) ); |
|
288 | + if (!empty($item)) { |
|
289 | + $link = get_edit_post_link($item); |
|
290 | + $link = esc_url($link); |
|
291 | + $name = esc_html(get_the_title($item)); |
|
292 | 292 | echo "<a href='$link'>$name</a>"; |
293 | 293 | } else { |
294 | - echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
294 | + echo sprintf(__('Item #%s', 'invoicing'), $subscription->get_product_id()); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | } |
298 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item' ); |
|
298 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item'); |
|
299 | 299 | |
300 | 300 | /** |
301 | 301 | * Displays the subscription gateway. |
302 | 302 | * |
303 | 303 | * @param WPInv_Subscription $subscription |
304 | 304 | */ |
305 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
305 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
306 | 306 | |
307 | 307 | $gateway = $subscription->get_gateway(); |
308 | 308 | |
309 | - if ( ! empty( $gateway ) ) { |
|
310 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
309 | + if (!empty($gateway)) { |
|
310 | + echo sanitize_text_field(wpinv_get_gateway_admin_label($gateway)); |
|
311 | 311 | } else { |
312 | 312 | echo "—"; |
313 | 313 | } |
314 | 314 | |
315 | 315 | } |
316 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
316 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * Displays the subscription status. |
320 | 320 | * |
321 | 321 | * @param WPInv_Subscription $subscription |
322 | 322 | */ |
323 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
323 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
324 | 324 | echo $subscription->get_status_label_html(); |
325 | 325 | } |
326 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
326 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * Displays the subscription profile id. |
330 | 330 | * |
331 | 331 | * @param WPInv_Subscription $subscription |
332 | 332 | */ |
333 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
333 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
334 | 334 | |
335 | 335 | $profile_id = $subscription->get_profile_id(); |
336 | 336 | |
337 | - if ( ! empty( $profile_id ) ) { |
|
338 | - $profile_id = sanitize_text_field( $profile_id ); |
|
339 | - echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription ); |
|
337 | + if (!empty($profile_id)) { |
|
338 | + $profile_id = sanitize_text_field($profile_id); |
|
339 | + echo apply_filters('getpaid_subscription_profile_id_display', $profile_id, $subscription); |
|
340 | 340 | } else { |
341 | 341 | echo "—"; |
342 | 342 | } |
343 | 343 | |
344 | 344 | } |
345 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
345 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
346 | 346 | |
347 | 347 | /** |
348 | 348 | * Displays the subscriptions update metabox. |
349 | 349 | * |
350 | 350 | * @param WPInv_Subscription $subscription |
351 | 351 | */ |
352 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
352 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
353 | 353 | |
354 | 354 | ?> |
355 | 355 | <div class="mt-3"> |
@@ -362,10 +362,10 @@ discard block |
||
362 | 362 | 'id' => 'subscription_status_update_select', |
363 | 363 | 'required' => true, |
364 | 364 | 'no_wrap' => false, |
365 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
366 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
365 | + 'label' => __('Subscription Status', 'invoicing'), |
|
366 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
367 | 367 | 'select2' => true, |
368 | - 'value' => $subscription->get_status( 'edit' ), |
|
368 | + 'value' => $subscription->get_status('edit'), |
|
369 | 369 | ) |
370 | 370 | ); |
371 | 371 | ?> |
@@ -373,13 +373,13 @@ discard block |
||
373 | 373 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
374 | 374 | |
375 | 375 | <?php |
376 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
376 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
377 | 377 | |
378 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
379 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
380 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
378 | + $url = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce')); |
|
379 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
380 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
381 | 381 | |
382 | - if ( $subscription->is_active() ) { |
|
382 | + if ($subscription->is_active()) { |
|
383 | 383 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
384 | 384 | } |
385 | 385 | |
@@ -391,31 +391,31 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @param WPInv_Subscription $subscription |
393 | 393 | */ |
394 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription ) { |
|
394 | +function getpaid_admin_subscription_invoice_details_metabox($subscription) { |
|
395 | 395 | |
396 | 396 | $columns = apply_filters( |
397 | 397 | 'getpaid_subscription_related_invoices_columns', |
398 | 398 | array( |
399 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
400 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
401 | - 'date' => __( 'Date', 'invoicing' ), |
|
402 | - 'status' => __( 'Status', 'invoicing' ), |
|
403 | - 'total' => __( 'Total', 'invoicing' ), |
|
399 | + 'invoice' => __('Invoice', 'invoicing'), |
|
400 | + 'relationship' => __('Relationship', 'invoicing'), |
|
401 | + 'date' => __('Date', 'invoicing'), |
|
402 | + 'status' => __('Status', 'invoicing'), |
|
403 | + 'total' => __('Total', 'invoicing'), |
|
404 | 404 | ), |
405 | 405 | $subscription |
406 | 406 | ); |
407 | 407 | |
408 | 408 | // Prepare the invoices. |
409 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
409 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
410 | 410 | $parent = $subscription->get_parent_invoice(); |
411 | 411 | |
412 | - if ( $parent->get_id() ) { |
|
413 | - $payments = array_merge( array( $parent ), $payments ); |
|
412 | + if ($parent->get_id()) { |
|
413 | + $payments = array_merge(array($parent), $payments); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | $table_class = 'w-100 bg-white'; |
417 | 417 | |
418 | - if ( ! is_admin() ) { |
|
418 | + if (!is_admin()) { |
|
419 | 419 | $table_class = 'table table-bordered table-striped'; |
420 | 420 | } |
421 | 421 | |
@@ -427,9 +427,9 @@ discard block |
||
427 | 427 | <thead> |
428 | 428 | <tr> |
429 | 429 | <?php |
430 | - foreach ( $columns as $key => $label ) { |
|
431 | - $key = esc_attr( $key ); |
|
432 | - $label = sanitize_text_field( $label ); |
|
430 | + foreach ($columns as $key => $label) { |
|
431 | + $key = esc_attr($key); |
|
432 | + $label = sanitize_text_field($label); |
|
433 | 433 | |
434 | 434 | echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark font-weight-bold'>$label</th>"; |
435 | 435 | } |
@@ -439,50 +439,50 @@ discard block |
||
439 | 439 | |
440 | 440 | <tbody> |
441 | 441 | |
442 | - <?php if ( empty( $payments ) ) : ?> |
|
442 | + <?php if (empty($payments)) : ?> |
|
443 | 443 | <tr> |
444 | 444 | <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
445 | - <?php _e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
445 | + <?php _e('This subscription has no invoices.', 'invoicing'); ?> |
|
446 | 446 | </td> |
447 | 447 | </tr> |
448 | 448 | <?php endif; ?> |
449 | 449 | |
450 | 450 | <?php |
451 | 451 | |
452 | - foreach( $payments as $payment ) : |
|
452 | + foreach ($payments as $payment) : |
|
453 | 453 | |
454 | 454 | // Ensure that we have an invoice. |
455 | - $payment = new WPInv_Invoice( $payment ); |
|
455 | + $payment = new WPInv_Invoice($payment); |
|
456 | 456 | |
457 | 457 | // Abort if the invoice is invalid. |
458 | - if ( ! $payment->get_id() ) { |
|
458 | + if (!$payment->get_id()) { |
|
459 | 459 | continue; |
460 | 460 | } |
461 | 461 | |
462 | 462 | echo '<tr>'; |
463 | 463 | |
464 | - foreach ( array_keys( $columns ) as $key ) { |
|
464 | + foreach (array_keys($columns) as $key) { |
|
465 | 465 | |
466 | 466 | echo '<td class="p-2 text-left">'; |
467 | 467 | |
468 | - switch( $key ) { |
|
468 | + switch ($key) { |
|
469 | 469 | |
470 | 470 | case 'total': |
471 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
471 | + echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>'; |
|
472 | 472 | break; |
473 | 473 | |
474 | 474 | case 'relationship': |
475 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
475 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
476 | 476 | break; |
477 | 477 | |
478 | 478 | case 'date': |
479 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
479 | + echo getpaid_format_date_value($payment->get_date_created()); |
|
480 | 480 | break; |
481 | 481 | |
482 | 482 | case 'status': |
483 | 483 | |
484 | 484 | $status = $payment->get_status_nicename(); |
485 | - if ( is_admin() ) { |
|
485 | + if (is_admin()) { |
|
486 | 486 | $status = $payment->get_status_label_html(); |
487 | 487 | } |
488 | 488 | |
@@ -490,13 +490,13 @@ discard block |
||
490 | 490 | break; |
491 | 491 | |
492 | 492 | case 'invoice': |
493 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
493 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
494 | 494 | |
495 | - if ( ! is_admin() ) { |
|
496 | - $link = esc_url( $payment->get_view_url() ); |
|
495 | + if (!is_admin()) { |
|
496 | + $link = esc_url($payment->get_view_url()); |
|
497 | 497 | } |
498 | 498 | |
499 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
499 | + $invoice = sanitize_text_field($payment->get_number()); |
|
500 | 500 | echo "<a href='$link'>$invoice</a>"; |
501 | 501 | break; |
502 | 502 | } |
@@ -13,633 +13,633 @@ discard block |
||
13 | 13 | class GetPaid_Post_Types_Admin { |
14 | 14 | |
15 | 15 | /** |
16 | - * Hook in methods. |
|
17 | - */ |
|
18 | - public static function init() { |
|
19 | - |
|
20 | - // Init metaboxes. |
|
21 | - GetPaid_Metaboxes::init(); |
|
22 | - |
|
23 | - // Filter the post updated messages. |
|
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
25 | - |
|
26 | - // Filter post actions. |
|
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
29 | - |
|
30 | - // Invoice table columns. |
|
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
33 | - |
|
34 | - // Items table columns. |
|
35 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
41 | - |
|
42 | - // Payment forms columns. |
|
43 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
46 | - |
|
47 | - // Discount table columns. |
|
48 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | - |
|
51 | - // Deleting posts. |
|
52 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * Post updated messages. |
|
58 | - */ |
|
59 | - public static function post_updated_messages( $messages ) { |
|
60 | - global $post; |
|
61 | - |
|
62 | - $messages['wpi_discount'] = array( |
|
63 | - 0 => '', |
|
64 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
65 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
66 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
67 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
68 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
69 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
70 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
71 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
72 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
73 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
74 | - ); |
|
75 | - |
|
76 | - $messages['wpi_payment_form'] = array( |
|
77 | - 0 => '', |
|
78 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
79 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
80 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
81 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
83 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
85 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
86 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
87 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
88 | - ); |
|
89 | - |
|
90 | - return $messages; |
|
91 | - |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Post row actions. |
|
96 | - */ |
|
97 | - public static function post_row_actions( $actions, $post ) { |
|
98 | - |
|
99 | - $post = get_post( $post ); |
|
100 | - |
|
101 | - // We do not want to edit the default payment form. |
|
102 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
103 | - unset( $actions['trash'] ); |
|
104 | - unset( $actions['inline hide-if-no-js'] ); |
|
105 | - } |
|
106 | - |
|
107 | - return $actions; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
16 | + * Hook in methods. |
|
17 | + */ |
|
18 | + public static function init() { |
|
19 | + |
|
20 | + // Init metaboxes. |
|
21 | + GetPaid_Metaboxes::init(); |
|
22 | + |
|
23 | + // Filter the post updated messages. |
|
24 | + add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
25 | + |
|
26 | + // Filter post actions. |
|
27 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
29 | + |
|
30 | + // Invoice table columns. |
|
31 | + add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | + add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
33 | + |
|
34 | + // Items table columns. |
|
35 | + add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | + add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | + add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | + add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | + add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | + add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
41 | + |
|
42 | + // Payment forms columns. |
|
43 | + add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | + add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
46 | + |
|
47 | + // Discount table columns. |
|
48 | + add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | + add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | + |
|
51 | + // Deleting posts. |
|
52 | + add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * Post updated messages. |
|
58 | + */ |
|
59 | + public static function post_updated_messages( $messages ) { |
|
60 | + global $post; |
|
61 | + |
|
62 | + $messages['wpi_discount'] = array( |
|
63 | + 0 => '', |
|
64 | + 1 => __( 'Discount updated.', 'invoicing' ), |
|
65 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
66 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
67 | + 4 => __( 'Discount updated.', 'invoicing' ), |
|
68 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
69 | + 6 => __( 'Discount updated.', 'invoicing' ), |
|
70 | + 7 => __( 'Discount saved.', 'invoicing' ), |
|
71 | + 8 => __( 'Discount submitted.', 'invoicing' ), |
|
72 | + 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
73 | + 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
74 | + ); |
|
75 | + |
|
76 | + $messages['wpi_payment_form'] = array( |
|
77 | + 0 => '', |
|
78 | + 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
79 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
80 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
81 | + 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
83 | + 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | + 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
85 | + 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
86 | + 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
87 | + 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
88 | + ); |
|
89 | + |
|
90 | + return $messages; |
|
91 | + |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Post row actions. |
|
96 | + */ |
|
97 | + public static function post_row_actions( $actions, $post ) { |
|
98 | + |
|
99 | + $post = get_post( $post ); |
|
100 | + |
|
101 | + // We do not want to edit the default payment form. |
|
102 | + if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
103 | + unset( $actions['trash'] ); |
|
104 | + unset( $actions['inline hide-if-no-js'] ); |
|
105 | + } |
|
106 | + |
|
107 | + return $actions; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | 111 | * Remove bulk edit option from admin side quote listing |
112 | 112 | * |
113 | 113 | * @since 1.0.0 |
114 | 114 | * @param array $actions post actions |
115 | - * @param WP_Post $post |
|
115 | + * @param WP_Post $post |
|
116 | 116 | * @return array $actions actions without edit option |
117 | 117 | */ |
118 | 118 | public static function filter_invoice_row_actions( $actions, $post ) { |
119 | 119 | |
120 | 120 | if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
121 | 121 | |
122 | - $actions = array(); |
|
123 | - $invoice = new WPInv_Invoice( $post ); |
|
124 | - |
|
125 | - $actions['edit'] = sprintf( |
|
126 | - '<a href="%1$s">%2$s</a>', |
|
127 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
128 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
129 | - ); |
|
130 | - |
|
131 | - if ( ! $invoice->is_draft() ) { |
|
132 | - |
|
133 | - $actions['view'] = sprintf( |
|
134 | - '<a href="%1$s">%2$s</a>', |
|
135 | - esc_url( $invoice->get_view_url() ), |
|
136 | - sprintf( |
|
137 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
138 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
139 | - ) |
|
140 | - ); |
|
141 | - |
|
142 | - $actions['send'] = sprintf( |
|
143 | - '<a href="%1$s">%2$s</a>', |
|
144 | - esc_url( |
|
145 | - wp_nonce_url( |
|
146 | - add_query_arg( |
|
147 | - array( |
|
148 | - 'getpaid-admin-action' => 'send_invoice', |
|
149 | - 'invoice_id' => $invoice->get_id() |
|
150 | - ) |
|
151 | - ), |
|
152 | - 'getpaid-nonce', |
|
153 | - 'getpaid-nonce' |
|
154 | - ) |
|
155 | - ), |
|
156 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
157 | - ); |
|
158 | - |
|
159 | - } |
|
122 | + $actions = array(); |
|
123 | + $invoice = new WPInv_Invoice( $post ); |
|
124 | + |
|
125 | + $actions['edit'] = sprintf( |
|
126 | + '<a href="%1$s">%2$s</a>', |
|
127 | + esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
128 | + esc_html( __( 'Edit', 'invoicing' ) ) |
|
129 | + ); |
|
130 | + |
|
131 | + if ( ! $invoice->is_draft() ) { |
|
132 | + |
|
133 | + $actions['view'] = sprintf( |
|
134 | + '<a href="%1$s">%2$s</a>', |
|
135 | + esc_url( $invoice->get_view_url() ), |
|
136 | + sprintf( |
|
137 | + esc_html( __( 'View %s', 'invoicing' ) ), |
|
138 | + getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
139 | + ) |
|
140 | + ); |
|
141 | + |
|
142 | + $actions['send'] = sprintf( |
|
143 | + '<a href="%1$s">%2$s</a>', |
|
144 | + esc_url( |
|
145 | + wp_nonce_url( |
|
146 | + add_query_arg( |
|
147 | + array( |
|
148 | + 'getpaid-admin-action' => 'send_invoice', |
|
149 | + 'invoice_id' => $invoice->get_id() |
|
150 | + ) |
|
151 | + ), |
|
152 | + 'getpaid-nonce', |
|
153 | + 'getpaid-nonce' |
|
154 | + ) |
|
155 | + ), |
|
156 | + esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
157 | + ); |
|
158 | + |
|
159 | + } |
|
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | 163 | return $actions; |
164 | - } |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * Returns an array of invoice table columns. |
|
168 | - */ |
|
169 | - public static function invoice_columns( $columns ) { |
|
166 | + /** |
|
167 | + * Returns an array of invoice table columns. |
|
168 | + */ |
|
169 | + public static function invoice_columns( $columns ) { |
|
170 | 170 | |
171 | - $columns = array( |
|
172 | - 'cb' => $columns['cb'], |
|
173 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
174 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
175 | - 'invoice_date' => __( 'Date', 'invoicing' ), |
|
176 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
177 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
178 | - 'status' => __( 'Status', 'invoicing' ), |
|
179 | - ); |
|
171 | + $columns = array( |
|
172 | + 'cb' => $columns['cb'], |
|
173 | + 'number' => __( 'Invoice', 'invoicing' ), |
|
174 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
175 | + 'invoice_date' => __( 'Date', 'invoicing' ), |
|
176 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
177 | + 'recurring' => __( 'Recurring', 'invoicing' ), |
|
178 | + 'status' => __( 'Status', 'invoicing' ), |
|
179 | + ); |
|
180 | 180 | |
181 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
182 | - } |
|
181 | + return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
182 | + } |
|
183 | 183 | |
184 | - /** |
|
185 | - * Displays invoice table columns. |
|
186 | - */ |
|
187 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
184 | + /** |
|
185 | + * Displays invoice table columns. |
|
186 | + */ |
|
187 | + public static function display_invoice_columns( $column_name, $post_id ) { |
|
188 | 188 | |
189 | - $invoice = new WPInv_Invoice( $post_id ); |
|
189 | + $invoice = new WPInv_Invoice( $post_id ); |
|
190 | 190 | |
191 | - switch ( $column_name ) { |
|
191 | + switch ( $column_name ) { |
|
192 | 192 | |
193 | - case 'invoice_date' : |
|
194 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
195 | - $date = getpaid_format_date_value( $date_time ); |
|
196 | - echo "<span title='$date_time'>$date</span>"; |
|
197 | - break; |
|
193 | + case 'invoice_date' : |
|
194 | + $date_time = esc_attr( $invoice->get_created_date() ); |
|
195 | + $date = getpaid_format_date_value( $date_time ); |
|
196 | + echo "<span title='$date_time'>$date</span>"; |
|
197 | + break; |
|
198 | 198 | |
199 | - case 'amount' : |
|
199 | + case 'amount' : |
|
200 | 200 | |
201 | - $amount = $invoice->get_total(); |
|
202 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
201 | + $amount = $invoice->get_total(); |
|
202 | + $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
203 | 203 | |
204 | - if ( $invoice->is_refunded() ) { |
|
205 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
206 | - echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
207 | - } else { |
|
204 | + if ( $invoice->is_refunded() ) { |
|
205 | + $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
206 | + echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
207 | + } else { |
|
208 | 208 | |
209 | - $discount = $invoice->get_total_discount(); |
|
209 | + $discount = $invoice->get_total_discount(); |
|
210 | 210 | |
211 | - if ( ! empty( $discount ) ) { |
|
212 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
213 | - echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
214 | - } else { |
|
215 | - echo $formated_amount; |
|
216 | - } |
|
211 | + if ( ! empty( $discount ) ) { |
|
212 | + $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
213 | + echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
214 | + } else { |
|
215 | + echo $formated_amount; |
|
216 | + } |
|
217 | 217 | |
218 | - } |
|
218 | + } |
|
219 | 219 | |
220 | - break; |
|
220 | + break; |
|
221 | 221 | |
222 | - case 'status' : |
|
223 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
224 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
222 | + case 'status' : |
|
223 | + $status = sanitize_text_field( $invoice->get_status() ); |
|
224 | + $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
225 | 225 | |
226 | - // If it is paid, show the gateway title. |
|
227 | - if ( $invoice->is_paid() ) { |
|
228 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
229 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
226 | + // If it is paid, show the gateway title. |
|
227 | + if ( $invoice->is_paid() ) { |
|
228 | + $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
229 | + $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
230 | 230 | |
231 | - echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
232 | - } else { |
|
233 | - echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
234 | - } |
|
231 | + echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
232 | + } else { |
|
233 | + echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
234 | + } |
|
235 | 235 | |
236 | - // If it is not paid, display the overdue and view status. |
|
237 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
236 | + // If it is not paid, display the overdue and view status. |
|
237 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
238 | 238 | |
239 | - // Invoice view status. |
|
240 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
241 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
242 | - } else { |
|
243 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
244 | - } |
|
239 | + // Invoice view status. |
|
240 | + if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
241 | + echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
242 | + } else { |
|
243 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
244 | + } |
|
245 | 245 | |
246 | - // Display the overview status. |
|
247 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
248 | - $due_date = $invoice->get_due_date(); |
|
249 | - $fomatted = getpaid_format_date( $due_date ); |
|
246 | + // Display the overview status. |
|
247 | + if ( wpinv_get_option( 'overdue_active' ) ) { |
|
248 | + $due_date = $invoice->get_due_date(); |
|
249 | + $fomatted = getpaid_format_date( $due_date ); |
|
250 | 250 | |
251 | - if ( ! empty( $fomatted ) ) { |
|
252 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
253 | - echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
254 | - } |
|
255 | - } |
|
251 | + if ( ! empty( $fomatted ) ) { |
|
252 | + $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
253 | + echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
254 | + } |
|
255 | + } |
|
256 | 256 | |
257 | - } |
|
257 | + } |
|
258 | 258 | |
259 | - break; |
|
259 | + break; |
|
260 | 260 | |
261 | - case 'recurring': |
|
261 | + case 'recurring': |
|
262 | 262 | |
263 | - if ( $invoice->is_recurring() ) { |
|
264 | - echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
265 | - } else { |
|
266 | - echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
267 | - } |
|
268 | - break; |
|
263 | + if ( $invoice->is_recurring() ) { |
|
264 | + echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
265 | + } else { |
|
266 | + echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
267 | + } |
|
268 | + break; |
|
269 | 269 | |
270 | - case 'number' : |
|
270 | + case 'number' : |
|
271 | 271 | |
272 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
273 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
274 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
272 | + $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
273 | + $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
274 | + $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
275 | 275 | |
276 | - echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
276 | + echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
277 | 277 | |
278 | - break; |
|
278 | + break; |
|
279 | 279 | |
280 | - case 'customer' : |
|
280 | + case 'customer' : |
|
281 | 281 | |
282 | - $customer_name = $invoice->get_user_full_name(); |
|
282 | + $customer_name = $invoice->get_user_full_name(); |
|
283 | 283 | |
284 | - if ( empty( $customer_name ) ) { |
|
285 | - $customer_name = $invoice->get_email(); |
|
286 | - } |
|
284 | + if ( empty( $customer_name ) ) { |
|
285 | + $customer_name = $invoice->get_email(); |
|
286 | + } |
|
287 | 287 | |
288 | - if ( ! empty( $customer_name ) ) { |
|
289 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
290 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
291 | - echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
292 | - } else { |
|
293 | - echo '<div>—</div>'; |
|
294 | - } |
|
288 | + if ( ! empty( $customer_name ) ) { |
|
289 | + $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
290 | + $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
291 | + echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
292 | + } else { |
|
293 | + echo '<div>—</div>'; |
|
294 | + } |
|
295 | 295 | |
296 | - break; |
|
296 | + break; |
|
297 | 297 | |
298 | - } |
|
298 | + } |
|
299 | 299 | |
300 | - } |
|
300 | + } |
|
301 | 301 | |
302 | - /** |
|
303 | - * Returns an array of payment forms table columns. |
|
304 | - */ |
|
305 | - public static function payment_form_columns( $columns ) { |
|
302 | + /** |
|
303 | + * Returns an array of payment forms table columns. |
|
304 | + */ |
|
305 | + public static function payment_form_columns( $columns ) { |
|
306 | 306 | |
307 | - $columns = array( |
|
308 | - 'cb' => $columns['cb'], |
|
309 | - 'title' => __( 'Name', 'invoicing' ), |
|
310 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
311 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
312 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
313 | - 'items' => __( 'Items', 'invoicing' ), |
|
314 | - 'date' => __( 'Date', 'invoicing' ), |
|
315 | - ); |
|
307 | + $columns = array( |
|
308 | + 'cb' => $columns['cb'], |
|
309 | + 'title' => __( 'Name', 'invoicing' ), |
|
310 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
311 | + 'earnings' => __( 'Revenue', 'invoicing' ), |
|
312 | + 'refunds' => __( 'Refunded', 'invoicing' ), |
|
313 | + 'items' => __( 'Items', 'invoicing' ), |
|
314 | + 'date' => __( 'Date', 'invoicing' ), |
|
315 | + ); |
|
316 | 316 | |
317 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
317 | + return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
318 | 318 | |
319 | - } |
|
319 | + } |
|
320 | 320 | |
321 | - /** |
|
322 | - * Displays payment form table columns. |
|
323 | - */ |
|
324 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
321 | + /** |
|
322 | + * Displays payment form table columns. |
|
323 | + */ |
|
324 | + public static function display_payment_form_columns( $column_name, $post_id ) { |
|
325 | 325 | |
326 | - // Retrieve the payment form. |
|
327 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
326 | + // Retrieve the payment form. |
|
327 | + $form = new GetPaid_Payment_Form( $post_id ); |
|
328 | 328 | |
329 | - switch ( $column_name ) { |
|
329 | + switch ( $column_name ) { |
|
330 | 330 | |
331 | - case 'earnings' : |
|
332 | - echo wpinv_price( $form->get_earned() ); |
|
333 | - break; |
|
331 | + case 'earnings' : |
|
332 | + echo wpinv_price( $form->get_earned() ); |
|
333 | + break; |
|
334 | 334 | |
335 | - case 'refunds' : |
|
336 | - echo wpinv_price( $form->get_refunded() ); |
|
337 | - break; |
|
335 | + case 'refunds' : |
|
336 | + echo wpinv_price( $form->get_refunded() ); |
|
337 | + break; |
|
338 | 338 | |
339 | - case 'refunds' : |
|
340 | - echo wpinv_price( $form->get_refunded() ); |
|
341 | - break; |
|
339 | + case 'refunds' : |
|
340 | + echo wpinv_price( $form->get_refunded() ); |
|
341 | + break; |
|
342 | 342 | |
343 | - case 'shortcode' : |
|
343 | + case 'shortcode' : |
|
344 | 344 | |
345 | - if ( $form->is_default() ) { |
|
346 | - echo '—'; |
|
347 | - } else { |
|
348 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
349 | - } |
|
345 | + if ( $form->is_default() ) { |
|
346 | + echo '—'; |
|
347 | + } else { |
|
348 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
349 | + } |
|
350 | 350 | |
351 | - break; |
|
351 | + break; |
|
352 | 352 | |
353 | - case 'items' : |
|
353 | + case 'items' : |
|
354 | 354 | |
355 | - $items = $form->get_items(); |
|
355 | + $items = $form->get_items(); |
|
356 | 356 | |
357 | - if ( $form->is_default() || empty( $items ) ) { |
|
358 | - echo '—'; |
|
359 | - return; |
|
360 | - } |
|
357 | + if ( $form->is_default() || empty( $items ) ) { |
|
358 | + echo '—'; |
|
359 | + return; |
|
360 | + } |
|
361 | 361 | |
362 | - $_items = array(); |
|
362 | + $_items = array(); |
|
363 | 363 | |
364 | - foreach ( $items as $item ) { |
|
365 | - $url = $item->get_edit_url(); |
|
364 | + foreach ( $items as $item ) { |
|
365 | + $url = $item->get_edit_url(); |
|
366 | 366 | |
367 | - if ( empty( $url ) ) { |
|
368 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
369 | - } else { |
|
370 | - $_items[] = sprintf( |
|
371 | - '<a href="%s">%s</a>', |
|
372 | - esc_url( $url ), |
|
373 | - sanitize_text_field( $item->get_name() ) |
|
374 | - ); |
|
375 | - } |
|
367 | + if ( empty( $url ) ) { |
|
368 | + $_items[] = sanitize_text_field( $item->get_name() ); |
|
369 | + } else { |
|
370 | + $_items[] = sprintf( |
|
371 | + '<a href="%s">%s</a>', |
|
372 | + esc_url( $url ), |
|
373 | + sanitize_text_field( $item->get_name() ) |
|
374 | + ); |
|
375 | + } |
|
376 | 376 | |
377 | - } |
|
377 | + } |
|
378 | 378 | |
379 | - echo implode( '<br>', $_items ); |
|
379 | + echo implode( '<br>', $_items ); |
|
380 | 380 | |
381 | - break; |
|
381 | + break; |
|
382 | 382 | |
383 | - } |
|
383 | + } |
|
384 | 384 | |
385 | - } |
|
385 | + } |
|
386 | 386 | |
387 | - /** |
|
388 | - * Filters post states. |
|
389 | - */ |
|
390 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
387 | + /** |
|
388 | + * Filters post states. |
|
389 | + */ |
|
390 | + public static function filter_payment_form_state( $post_states, $post ) { |
|
391 | 391 | |
392 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
393 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
394 | - } |
|
392 | + if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
393 | + $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
394 | + } |
|
395 | 395 | |
396 | - return $post_states; |
|
397 | - |
|
398 | - } |
|
399 | - |
|
400 | - /** |
|
401 | - * Returns an array of coupon table columns. |
|
402 | - */ |
|
403 | - public static function discount_columns( $columns ) { |
|
404 | - |
|
405 | - $columns = array( |
|
406 | - 'cb' => $columns['cb'], |
|
407 | - 'title' => __( 'Name', 'invoicing' ), |
|
408 | - 'code' => __( 'Code', 'invoicing' ), |
|
409 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
410 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
411 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
412 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
413 | - ); |
|
414 | - |
|
415 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
416 | - } |
|
417 | - |
|
418 | - /** |
|
419 | - * Filters post states. |
|
420 | - */ |
|
421 | - public static function filter_discount_state( $post_states, $post ) { |
|
422 | - |
|
423 | - if ( 'wpi_discount' == $post->post_type ) { |
|
424 | - |
|
425 | - $discount = new WPInv_Discount( $post ); |
|
426 | - |
|
427 | - $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
428 | - |
|
429 | - if ( $status != 'publish' ) { |
|
430 | - return array( |
|
431 | - 'discount_status' => wpinv_discount_status( $status ), |
|
432 | - ); |
|
433 | - } |
|
434 | - |
|
435 | - return array(); |
|
436 | - |
|
437 | - } |
|
438 | - |
|
439 | - return $post_states; |
|
440 | - |
|
441 | - } |
|
442 | - |
|
443 | - /** |
|
444 | - * Returns an array of items table columns. |
|
445 | - */ |
|
446 | - public static function item_columns( $columns ) { |
|
447 | - |
|
448 | - $columns = array( |
|
449 | - 'cb' => $columns['cb'], |
|
450 | - 'title' => __( 'Name', 'invoicing' ), |
|
451 | - 'price' => __( 'Price', 'invoicing' ), |
|
452 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
453 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
454 | - 'type' => __( 'Type', 'invoicing' ), |
|
455 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
456 | - ); |
|
457 | - |
|
458 | - if ( ! wpinv_use_taxes() ) { |
|
459 | - unset( $columns['vat_rule'] ); |
|
460 | - unset( $columns['vat_class'] ); |
|
461 | - } |
|
462 | - |
|
463 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
464 | - } |
|
465 | - |
|
466 | - /** |
|
467 | - * Returns an array of sortable items table columns. |
|
468 | - */ |
|
469 | - public static function sortable_item_columns( $columns ) { |
|
470 | - |
|
471 | - return array_merge( |
|
472 | - $columns, |
|
473 | - array( |
|
474 | - 'price' => 'price', |
|
475 | - 'vat_rule' => 'vat_rule', |
|
476 | - 'vat_class' => 'vat_class', |
|
477 | - 'type' => 'type', |
|
478 | - ) |
|
479 | - ); |
|
480 | - |
|
481 | - } |
|
482 | - |
|
483 | - /** |
|
484 | - * Displays items table columns. |
|
485 | - */ |
|
486 | - public static function display_item_columns( $column_name, $post_id ) { |
|
396 | + return $post_states; |
|
397 | + |
|
398 | + } |
|
399 | + |
|
400 | + /** |
|
401 | + * Returns an array of coupon table columns. |
|
402 | + */ |
|
403 | + public static function discount_columns( $columns ) { |
|
404 | + |
|
405 | + $columns = array( |
|
406 | + 'cb' => $columns['cb'], |
|
407 | + 'title' => __( 'Name', 'invoicing' ), |
|
408 | + 'code' => __( 'Code', 'invoicing' ), |
|
409 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
410 | + 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
411 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
412 | + 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
413 | + ); |
|
414 | + |
|
415 | + return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
416 | + } |
|
417 | + |
|
418 | + /** |
|
419 | + * Filters post states. |
|
420 | + */ |
|
421 | + public static function filter_discount_state( $post_states, $post ) { |
|
422 | + |
|
423 | + if ( 'wpi_discount' == $post->post_type ) { |
|
424 | + |
|
425 | + $discount = new WPInv_Discount( $post ); |
|
426 | + |
|
427 | + $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
428 | + |
|
429 | + if ( $status != 'publish' ) { |
|
430 | + return array( |
|
431 | + 'discount_status' => wpinv_discount_status( $status ), |
|
432 | + ); |
|
433 | + } |
|
434 | + |
|
435 | + return array(); |
|
436 | + |
|
437 | + } |
|
438 | + |
|
439 | + return $post_states; |
|
440 | + |
|
441 | + } |
|
442 | + |
|
443 | + /** |
|
444 | + * Returns an array of items table columns. |
|
445 | + */ |
|
446 | + public static function item_columns( $columns ) { |
|
447 | + |
|
448 | + $columns = array( |
|
449 | + 'cb' => $columns['cb'], |
|
450 | + 'title' => __( 'Name', 'invoicing' ), |
|
451 | + 'price' => __( 'Price', 'invoicing' ), |
|
452 | + 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
453 | + 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
454 | + 'type' => __( 'Type', 'invoicing' ), |
|
455 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
456 | + ); |
|
457 | + |
|
458 | + if ( ! wpinv_use_taxes() ) { |
|
459 | + unset( $columns['vat_rule'] ); |
|
460 | + unset( $columns['vat_class'] ); |
|
461 | + } |
|
462 | + |
|
463 | + return apply_filters( 'wpi_item_table_columns', $columns ); |
|
464 | + } |
|
465 | + |
|
466 | + /** |
|
467 | + * Returns an array of sortable items table columns. |
|
468 | + */ |
|
469 | + public static function sortable_item_columns( $columns ) { |
|
470 | + |
|
471 | + return array_merge( |
|
472 | + $columns, |
|
473 | + array( |
|
474 | + 'price' => 'price', |
|
475 | + 'vat_rule' => 'vat_rule', |
|
476 | + 'vat_class' => 'vat_class', |
|
477 | + 'type' => 'type', |
|
478 | + ) |
|
479 | + ); |
|
480 | + |
|
481 | + } |
|
482 | + |
|
483 | + /** |
|
484 | + * Displays items table columns. |
|
485 | + */ |
|
486 | + public static function display_item_columns( $column_name, $post_id ) { |
|
487 | 487 | |
488 | - $item = new WPInv_Item( $post_id ); |
|
488 | + $item = new WPInv_Item( $post_id ); |
|
489 | 489 | |
490 | - switch ( $column_name ) { |
|
490 | + switch ( $column_name ) { |
|
491 | 491 | |
492 | - case 'price' : |
|
492 | + case 'price' : |
|
493 | 493 | |
494 | - if ( ! $item->is_recurring() ) { |
|
495 | - echo $item->get_the_price(); |
|
496 | - break; |
|
497 | - } |
|
494 | + if ( ! $item->is_recurring() ) { |
|
495 | + echo $item->get_the_price(); |
|
496 | + break; |
|
497 | + } |
|
498 | 498 | |
499 | - $price = wp_sprintf( |
|
500 | - __( '%s / %s', 'invoicing' ), |
|
501 | - $item->get_the_price(), |
|
502 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
503 | - ); |
|
499 | + $price = wp_sprintf( |
|
500 | + __( '%s / %s', 'invoicing' ), |
|
501 | + $item->get_the_price(), |
|
502 | + getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
503 | + ); |
|
504 | 504 | |
505 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
506 | - echo $price; |
|
507 | - break; |
|
508 | - } |
|
505 | + if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
506 | + echo $price; |
|
507 | + break; |
|
508 | + } |
|
509 | 509 | |
510 | - echo $item->get_the_initial_price(); |
|
510 | + echo $item->get_the_initial_price(); |
|
511 | 511 | |
512 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
513 | - break; |
|
512 | + echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
513 | + break; |
|
514 | 514 | |
515 | - case 'vat_rule' : |
|
516 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
517 | - break; |
|
515 | + case 'vat_rule' : |
|
516 | + echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
517 | + break; |
|
518 | 518 | |
519 | - case 'vat_class' : |
|
520 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
521 | - break; |
|
519 | + case 'vat_class' : |
|
520 | + echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
521 | + break; |
|
522 | 522 | |
523 | - case 'shortcode' : |
|
524 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
525 | - break; |
|
523 | + case 'shortcode' : |
|
524 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
525 | + break; |
|
526 | 526 | |
527 | - case 'type' : |
|
528 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
529 | - break; |
|
527 | + case 'type' : |
|
528 | + echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
529 | + break; |
|
530 | 530 | |
531 | - } |
|
531 | + } |
|
532 | 532 | |
533 | - } |
|
533 | + } |
|
534 | 534 | |
535 | - /** |
|
536 | - * Lets users filter items using taxes. |
|
537 | - */ |
|
538 | - public static function add_item_filters( $post_type ) { |
|
535 | + /** |
|
536 | + * Lets users filter items using taxes. |
|
537 | + */ |
|
538 | + public static function add_item_filters( $post_type ) { |
|
539 | 539 | |
540 | - // Abort if we're not dealing with items. |
|
541 | - if ( $post_type != 'wpi_item' ) { |
|
542 | - return; |
|
543 | - } |
|
540 | + // Abort if we're not dealing with items. |
|
541 | + if ( $post_type != 'wpi_item' ) { |
|
542 | + return; |
|
543 | + } |
|
544 | 544 | |
545 | - // Filter by vat rules. |
|
546 | - if ( wpinv_use_taxes() ) { |
|
545 | + // Filter by vat rules. |
|
546 | + if ( wpinv_use_taxes() ) { |
|
547 | 547 | |
548 | - // Sanitize selected vat rule. |
|
549 | - $vat_rule = ''; |
|
550 | - $vat_rules = getpaid_get_tax_rules(); |
|
551 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
552 | - $vat_rule = $_GET['vat_rule']; |
|
553 | - } |
|
554 | - |
|
555 | - // Filter by VAT rule. |
|
556 | - echo wpinv_html_select( |
|
557 | - array( |
|
558 | - 'options' => array_merge( |
|
559 | - array( |
|
560 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
561 | - ), |
|
562 | - $vat_rules |
|
563 | - ), |
|
564 | - 'name' => 'vat_rule', |
|
565 | - 'id' => 'vat_rule', |
|
566 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
567 | - 'show_option_all' => false, |
|
568 | - 'show_option_none' => false, |
|
569 | - ) |
|
570 | - ); |
|
571 | - |
|
572 | - // Filter by VAT class. |
|
548 | + // Sanitize selected vat rule. |
|
549 | + $vat_rule = ''; |
|
550 | + $vat_rules = getpaid_get_tax_rules(); |
|
551 | + if ( isset( $_GET['vat_rule'] ) ) { |
|
552 | + $vat_rule = $_GET['vat_rule']; |
|
553 | + } |
|
554 | + |
|
555 | + // Filter by VAT rule. |
|
556 | + echo wpinv_html_select( |
|
557 | + array( |
|
558 | + 'options' => array_merge( |
|
559 | + array( |
|
560 | + '' => __( 'All VAT rules', 'invoicing' ) |
|
561 | + ), |
|
562 | + $vat_rules |
|
563 | + ), |
|
564 | + 'name' => 'vat_rule', |
|
565 | + 'id' => 'vat_rule', |
|
566 | + 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
567 | + 'show_option_all' => false, |
|
568 | + 'show_option_none' => false, |
|
569 | + ) |
|
570 | + ); |
|
571 | + |
|
572 | + // Filter by VAT class. |
|
573 | 573 | |
574 | - // Sanitize selected vat rule. |
|
575 | - $vat_class = ''; |
|
576 | - $vat_classes = getpaid_get_tax_classes(); |
|
577 | - if ( isset( $_GET['vat_class'] ) ) { |
|
578 | - $vat_class = $_GET['vat_class']; |
|
579 | - } |
|
580 | - |
|
581 | - echo wpinv_html_select( |
|
582 | - array( |
|
583 | - 'options' => array_merge( |
|
584 | - array( |
|
585 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
586 | - ), |
|
587 | - $vat_classes |
|
588 | - ), |
|
589 | - 'name' => 'vat_class', |
|
590 | - 'id' => 'vat_class', |
|
591 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
592 | - 'show_option_all' => false, |
|
593 | - 'show_option_none' => false, |
|
594 | - ) |
|
595 | - ); |
|
596 | - |
|
597 | - } |
|
598 | - |
|
599 | - // Filter by item type. |
|
600 | - $type = ''; |
|
601 | - if ( isset( $_GET['type'] ) ) { |
|
602 | - $type = $_GET['type']; |
|
603 | - } |
|
604 | - |
|
605 | - echo wpinv_html_select( |
|
606 | - array( |
|
607 | - 'options' => array_merge( |
|
608 | - array( |
|
609 | - '' => __( 'All item types', 'invoicing' ) |
|
610 | - ), |
|
611 | - wpinv_get_item_types() |
|
612 | - ), |
|
613 | - 'name' => 'type', |
|
614 | - 'id' => 'type', |
|
615 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
616 | - 'show_option_all' => false, |
|
617 | - 'show_option_none' => false, |
|
618 | - ) |
|
619 | - ); |
|
620 | - |
|
621 | - } |
|
622 | - |
|
623 | - /** |
|
624 | - * Filters the item query. |
|
625 | - */ |
|
626 | - public static function filter_item_query( $query ) { |
|
627 | - |
|
628 | - // modify the query only if it admin and main query. |
|
629 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
630 | - return $query; |
|
631 | - } |
|
632 | - |
|
633 | - // we want to modify the query for our items. |
|
634 | - if ( 'wpi_item' != $query->query['post_type'] ){ |
|
635 | - return $query; |
|
636 | - } |
|
637 | - |
|
638 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
639 | - $query->query_vars['meta_query'] = array(); |
|
640 | - } |
|
641 | - |
|
642 | - // Filter vat rule type |
|
574 | + // Sanitize selected vat rule. |
|
575 | + $vat_class = ''; |
|
576 | + $vat_classes = getpaid_get_tax_classes(); |
|
577 | + if ( isset( $_GET['vat_class'] ) ) { |
|
578 | + $vat_class = $_GET['vat_class']; |
|
579 | + } |
|
580 | + |
|
581 | + echo wpinv_html_select( |
|
582 | + array( |
|
583 | + 'options' => array_merge( |
|
584 | + array( |
|
585 | + '' => __( 'All VAT classes', 'invoicing' ) |
|
586 | + ), |
|
587 | + $vat_classes |
|
588 | + ), |
|
589 | + 'name' => 'vat_class', |
|
590 | + 'id' => 'vat_class', |
|
591 | + 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
592 | + 'show_option_all' => false, |
|
593 | + 'show_option_none' => false, |
|
594 | + ) |
|
595 | + ); |
|
596 | + |
|
597 | + } |
|
598 | + |
|
599 | + // Filter by item type. |
|
600 | + $type = ''; |
|
601 | + if ( isset( $_GET['type'] ) ) { |
|
602 | + $type = $_GET['type']; |
|
603 | + } |
|
604 | + |
|
605 | + echo wpinv_html_select( |
|
606 | + array( |
|
607 | + 'options' => array_merge( |
|
608 | + array( |
|
609 | + '' => __( 'All item types', 'invoicing' ) |
|
610 | + ), |
|
611 | + wpinv_get_item_types() |
|
612 | + ), |
|
613 | + 'name' => 'type', |
|
614 | + 'id' => 'type', |
|
615 | + 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
616 | + 'show_option_all' => false, |
|
617 | + 'show_option_none' => false, |
|
618 | + ) |
|
619 | + ); |
|
620 | + |
|
621 | + } |
|
622 | + |
|
623 | + /** |
|
624 | + * Filters the item query. |
|
625 | + */ |
|
626 | + public static function filter_item_query( $query ) { |
|
627 | + |
|
628 | + // modify the query only if it admin and main query. |
|
629 | + if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
630 | + return $query; |
|
631 | + } |
|
632 | + |
|
633 | + // we want to modify the query for our items. |
|
634 | + if ( 'wpi_item' != $query->query['post_type'] ){ |
|
635 | + return $query; |
|
636 | + } |
|
637 | + |
|
638 | + if ( empty( $query->query_vars['meta_query'] ) ) { |
|
639 | + $query->query_vars['meta_query'] = array(); |
|
640 | + } |
|
641 | + |
|
642 | + // Filter vat rule type |
|
643 | 643 | if ( ! empty( $_GET['vat_rule'] ) ) { |
644 | 644 | $query->query_vars['meta_query'][] = array( |
645 | 645 | 'key' => '_wpinv_vat_rule', |
@@ -664,94 +664,94 @@ discard block |
||
664 | 664 | 'value' => sanitize_text_field( $_GET['type'] ), |
665 | 665 | 'compare' => '=' |
666 | 666 | ); |
667 | - } |
|
668 | - |
|
669 | - } |
|
670 | - |
|
671 | - /** |
|
672 | - * Reorders items. |
|
673 | - */ |
|
674 | - public static function reorder_items( $vars ) { |
|
675 | - global $typenow; |
|
676 | - |
|
677 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
678 | - return $vars; |
|
679 | - } |
|
680 | - |
|
681 | - // By item type. |
|
682 | - if ( 'type' == $vars['orderby'] ) { |
|
683 | - return array_merge( |
|
684 | - $vars, |
|
685 | - array( |
|
686 | - 'meta_key' => '_wpinv_type', |
|
687 | - 'orderby' => 'meta_value' |
|
688 | - ) |
|
689 | - ); |
|
690 | - } |
|
691 | - |
|
692 | - // By vat class. |
|
693 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
694 | - return array_merge( |
|
695 | - $vars, |
|
696 | - array( |
|
697 | - 'meta_key' => '_wpinv_vat_class', |
|
698 | - 'orderby' => 'meta_value' |
|
699 | - ) |
|
700 | - ); |
|
701 | - } |
|
702 | - |
|
703 | - // By vat rule. |
|
704 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
705 | - return array_merge( |
|
706 | - $vars, |
|
707 | - array( |
|
708 | - 'meta_key' => '_wpinv_vat_rule', |
|
709 | - 'orderby' => 'meta_value' |
|
710 | - ) |
|
711 | - ); |
|
712 | - } |
|
713 | - |
|
714 | - // By price. |
|
715 | - if ( 'price' == $vars['orderby'] ) { |
|
716 | - return array_merge( |
|
717 | - $vars, |
|
718 | - array( |
|
719 | - 'meta_key' => '_wpinv_price', |
|
720 | - 'orderby' => 'meta_value_num' |
|
721 | - ) |
|
722 | - ); |
|
723 | - } |
|
724 | - |
|
725 | - return $vars; |
|
726 | - |
|
727 | - } |
|
728 | - |
|
729 | - /** |
|
730 | - * Fired when deleting a post. |
|
731 | - */ |
|
732 | - public static function delete_post( $post_id ) { |
|
733 | - |
|
734 | - switch ( get_post_type( $post_id ) ) { |
|
735 | - |
|
736 | - case 'wpi_item' : |
|
737 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
738 | - break; |
|
739 | - |
|
740 | - case 'wpi_payment_form' : |
|
741 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
742 | - break; |
|
743 | - |
|
744 | - case 'wpi_discount' : |
|
745 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
746 | - break; |
|
747 | - |
|
748 | - case 'wpi_invoice' : |
|
749 | - $invoice = new WPInv_Invoice( $post_id ); |
|
750 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
751 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
752 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
753 | - break; |
|
754 | - } |
|
755 | - } |
|
667 | + } |
|
668 | + |
|
669 | + } |
|
670 | + |
|
671 | + /** |
|
672 | + * Reorders items. |
|
673 | + */ |
|
674 | + public static function reorder_items( $vars ) { |
|
675 | + global $typenow; |
|
676 | + |
|
677 | + if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
678 | + return $vars; |
|
679 | + } |
|
680 | + |
|
681 | + // By item type. |
|
682 | + if ( 'type' == $vars['orderby'] ) { |
|
683 | + return array_merge( |
|
684 | + $vars, |
|
685 | + array( |
|
686 | + 'meta_key' => '_wpinv_type', |
|
687 | + 'orderby' => 'meta_value' |
|
688 | + ) |
|
689 | + ); |
|
690 | + } |
|
691 | + |
|
692 | + // By vat class. |
|
693 | + if ( 'vat_class' == $vars['orderby'] ) { |
|
694 | + return array_merge( |
|
695 | + $vars, |
|
696 | + array( |
|
697 | + 'meta_key' => '_wpinv_vat_class', |
|
698 | + 'orderby' => 'meta_value' |
|
699 | + ) |
|
700 | + ); |
|
701 | + } |
|
702 | + |
|
703 | + // By vat rule. |
|
704 | + if ( 'vat_rule' == $vars['orderby'] ) { |
|
705 | + return array_merge( |
|
706 | + $vars, |
|
707 | + array( |
|
708 | + 'meta_key' => '_wpinv_vat_rule', |
|
709 | + 'orderby' => 'meta_value' |
|
710 | + ) |
|
711 | + ); |
|
712 | + } |
|
713 | + |
|
714 | + // By price. |
|
715 | + if ( 'price' == $vars['orderby'] ) { |
|
716 | + return array_merge( |
|
717 | + $vars, |
|
718 | + array( |
|
719 | + 'meta_key' => '_wpinv_price', |
|
720 | + 'orderby' => 'meta_value_num' |
|
721 | + ) |
|
722 | + ); |
|
723 | + } |
|
724 | + |
|
725 | + return $vars; |
|
726 | + |
|
727 | + } |
|
728 | + |
|
729 | + /** |
|
730 | + * Fired when deleting a post. |
|
731 | + */ |
|
732 | + public static function delete_post( $post_id ) { |
|
733 | + |
|
734 | + switch ( get_post_type( $post_id ) ) { |
|
735 | + |
|
736 | + case 'wpi_item' : |
|
737 | + do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
738 | + break; |
|
739 | + |
|
740 | + case 'wpi_payment_form' : |
|
741 | + do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
742 | + break; |
|
743 | + |
|
744 | + case 'wpi_discount' : |
|
745 | + do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
746 | + break; |
|
747 | + |
|
748 | + case 'wpi_invoice' : |
|
749 | + $invoice = new WPInv_Invoice( $post_id ); |
|
750 | + do_action( "getpaid_before_delete_invoice", $invoice ); |
|
751 | + $invoice->get_data_store()->delete_items( $invoice ); |
|
752 | + $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
753 | + break; |
|
754 | + } |
|
755 | + } |
|
756 | 756 | |
757 | 757 | } |
@@ -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 | * Post types Admin Class |
@@ -21,70 +21,70 @@ discard block |
||
21 | 21 | GetPaid_Metaboxes::init(); |
22 | 22 | |
23 | 23 | // Filter the post updated messages. |
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
24 | + add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages'); |
|
25 | 25 | |
26 | 26 | // Filter post actions. |
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
28 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2); |
|
29 | 29 | |
30 | 30 | // Invoice table columns. |
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
31 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
32 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
33 | 33 | |
34 | 34 | // Items table columns. |
35 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
35 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
36 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
37 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
38 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
39 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
40 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
41 | 41 | |
42 | 42 | // Payment forms columns. |
43 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
43 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
44 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
45 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
46 | 46 | |
47 | 47 | // Discount table columns. |
48 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
48 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
49 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
50 | 50 | |
51 | 51 | // Deleting posts. |
52 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
52 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
53 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Post updated messages. |
58 | 58 | */ |
59 | - public static function post_updated_messages( $messages ) { |
|
59 | + public static function post_updated_messages($messages) { |
|
60 | 60 | global $post; |
61 | 61 | |
62 | 62 | $messages['wpi_discount'] = array( |
63 | 63 | 0 => '', |
64 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
65 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
66 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
67 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
68 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
69 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
70 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
71 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
72 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
73 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
64 | + 1 => __('Discount updated.', 'invoicing'), |
|
65 | + 2 => __('Custom field updated.', 'invoicing'), |
|
66 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
67 | + 4 => __('Discount updated.', 'invoicing'), |
|
68 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
69 | + 6 => __('Discount updated.', 'invoicing'), |
|
70 | + 7 => __('Discount saved.', 'invoicing'), |
|
71 | + 8 => __('Discount submitted.', 'invoicing'), |
|
72 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
73 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | $messages['wpi_payment_form'] = array( |
77 | 77 | 0 => '', |
78 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
79 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
80 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
81 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
83 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
85 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
86 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
87 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
78 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
79 | + 2 => __('Custom field updated.', 'invoicing'), |
|
80 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
81 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
82 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
83 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
84 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
85 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
86 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
87 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | return $messages; |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * Post row actions. |
96 | 96 | */ |
97 | - public static function post_row_actions( $actions, $post ) { |
|
97 | + public static function post_row_actions($actions, $post) { |
|
98 | 98 | |
99 | - $post = get_post( $post ); |
|
99 | + $post = get_post($post); |
|
100 | 100 | |
101 | 101 | // We do not want to edit the default payment form. |
102 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
103 | - unset( $actions['trash'] ); |
|
104 | - unset( $actions['inline hide-if-no-js'] ); |
|
102 | + if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) { |
|
103 | + unset($actions['trash']); |
|
104 | + unset($actions['inline hide-if-no-js']); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $actions; |
@@ -115,31 +115,31 @@ discard block |
||
115 | 115 | * @param WP_Post $post |
116 | 116 | * @return array $actions actions without edit option |
117 | 117 | */ |
118 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
118 | + public static function filter_invoice_row_actions($actions, $post) { |
|
119 | 119 | |
120 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
120 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
121 | 121 | |
122 | 122 | $actions = array(); |
123 | - $invoice = new WPInv_Invoice( $post ); |
|
123 | + $invoice = new WPInv_Invoice($post); |
|
124 | 124 | |
125 | - $actions['edit'] = sprintf( |
|
125 | + $actions['edit'] = sprintf( |
|
126 | 126 | '<a href="%1$s">%2$s</a>', |
127 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
128 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
127 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
128 | + esc_html(__('Edit', 'invoicing')) |
|
129 | 129 | ); |
130 | 130 | |
131 | - if ( ! $invoice->is_draft() ) { |
|
131 | + if (!$invoice->is_draft()) { |
|
132 | 132 | |
133 | - $actions['view'] = sprintf( |
|
133 | + $actions['view'] = sprintf( |
|
134 | 134 | '<a href="%1$s">%2$s</a>', |
135 | - esc_url( $invoice->get_view_url() ), |
|
135 | + esc_url($invoice->get_view_url()), |
|
136 | 136 | sprintf( |
137 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
138 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
137 | + esc_html(__('View %s', 'invoicing')), |
|
138 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
139 | 139 | ) |
140 | 140 | ); |
141 | 141 | |
142 | - $actions['send'] = sprintf( |
|
142 | + $actions['send'] = sprintf( |
|
143 | 143 | '<a href="%1$s">%2$s</a>', |
144 | 144 | esc_url( |
145 | 145 | wp_nonce_url( |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'getpaid-nonce' |
154 | 154 | ) |
155 | 155 | ), |
156 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
156 | + esc_html(__('Send to Customer', 'invoicing')) |
|
157 | 157 | ); |
158 | 158 | |
159 | 159 | } |
@@ -166,50 +166,50 @@ discard block |
||
166 | 166 | /** |
167 | 167 | * Returns an array of invoice table columns. |
168 | 168 | */ |
169 | - public static function invoice_columns( $columns ) { |
|
169 | + public static function invoice_columns($columns) { |
|
170 | 170 | |
171 | 171 | $columns = array( |
172 | 172 | 'cb' => $columns['cb'], |
173 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
174 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
175 | - 'invoice_date' => __( 'Date', 'invoicing' ), |
|
176 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
177 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
178 | - 'status' => __( 'Status', 'invoicing' ), |
|
173 | + 'number' => __('Invoice', 'invoicing'), |
|
174 | + 'customer' => __('Customer', 'invoicing'), |
|
175 | + 'invoice_date' => __('Date', 'invoicing'), |
|
176 | + 'amount' => __('Amount', 'invoicing'), |
|
177 | + 'recurring' => __('Recurring', 'invoicing'), |
|
178 | + 'status' => __('Status', 'invoicing'), |
|
179 | 179 | ); |
180 | 180 | |
181 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
181 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | 185 | * Displays invoice table columns. |
186 | 186 | */ |
187 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
187 | + public static function display_invoice_columns($column_name, $post_id) { |
|
188 | 188 | |
189 | - $invoice = new WPInv_Invoice( $post_id ); |
|
189 | + $invoice = new WPInv_Invoice($post_id); |
|
190 | 190 | |
191 | - switch ( $column_name ) { |
|
191 | + switch ($column_name) { |
|
192 | 192 | |
193 | 193 | case 'invoice_date' : |
194 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
195 | - $date = getpaid_format_date_value( $date_time ); |
|
194 | + $date_time = esc_attr($invoice->get_created_date()); |
|
195 | + $date = getpaid_format_date_value($date_time); |
|
196 | 196 | echo "<span title='$date_time'>$date</span>"; |
197 | 197 | break; |
198 | 198 | |
199 | 199 | case 'amount' : |
200 | 200 | |
201 | 201 | $amount = $invoice->get_total(); |
202 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
202 | + $formated_amount = wpinv_price($amount, $invoice->get_currency()); |
|
203 | 203 | |
204 | - if ( $invoice->is_refunded() ) { |
|
205 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
204 | + if ($invoice->is_refunded()) { |
|
205 | + $refunded_amount = wpinv_price(0, $invoice->get_currency()); |
|
206 | 206 | echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
207 | 207 | } else { |
208 | 208 | |
209 | 209 | $discount = $invoice->get_total_discount(); |
210 | 210 | |
211 | - if ( ! empty( $discount ) ) { |
|
212 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
211 | + if (!empty($discount)) { |
|
212 | + $new_amount = wpinv_price($amount + $discount, $invoice->get_currency()); |
|
213 | 213 | echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
214 | 214 | } else { |
215 | 215 | echo $formated_amount; |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | break; |
221 | 221 | |
222 | 222 | case 'status' : |
223 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
224 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
223 | + $status = sanitize_text_field($invoice->get_status()); |
|
224 | + $status_label = sanitize_text_field($invoice->get_status_nicename()); |
|
225 | 225 | |
226 | 226 | // If it is paid, show the gateway title. |
227 | - if ( $invoice->is_paid() ) { |
|
228 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
229 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
227 | + if ($invoice->is_paid()) { |
|
228 | + $gateway = sanitize_text_field($invoice->get_gateway_title()); |
|
229 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway); |
|
230 | 230 | |
231 | 231 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
232 | 232 | } else { |
@@ -234,22 +234,22 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | // If it is not paid, display the overdue and view status. |
237 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
237 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
238 | 238 | |
239 | 239 | // Invoice view status. |
240 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
241 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
240 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
241 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
242 | 242 | } else { |
243 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
243 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | // Display the overview status. |
247 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
247 | + if (wpinv_get_option('overdue_active')) { |
|
248 | 248 | $due_date = $invoice->get_due_date(); |
249 | - $fomatted = getpaid_format_date( $due_date ); |
|
249 | + $fomatted = getpaid_format_date($due_date); |
|
250 | 250 | |
251 | - if ( ! empty( $fomatted ) ) { |
|
252 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
251 | + if (!empty($fomatted)) { |
|
252 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
253 | 253 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
254 | 254 | } |
255 | 255 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | |
261 | 261 | case 'recurring': |
262 | 262 | |
263 | - if ( $invoice->is_recurring() ) { |
|
263 | + if ($invoice->is_recurring()) { |
|
264 | 264 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
265 | 265 | } else { |
266 | 266 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | |
270 | 270 | case 'number' : |
271 | 271 | |
272 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
273 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
274 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
272 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
273 | + $invoice_number = sanitize_text_field($invoice->get_number()); |
|
274 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
275 | 275 | |
276 | 276 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
277 | 277 | |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | |
282 | 282 | $customer_name = $invoice->get_user_full_name(); |
283 | 283 | |
284 | - if ( empty( $customer_name ) ) { |
|
284 | + if (empty($customer_name)) { |
|
285 | 285 | $customer_name = $invoice->get_email(); |
286 | 286 | } |
287 | 287 | |
288 | - if ( ! empty( $customer_name ) ) { |
|
289 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
290 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
288 | + if (!empty($customer_name)) { |
|
289 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
290 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
291 | 291 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
292 | 292 | } else { |
293 | 293 | echo '<div>—</div>'; |
@@ -302,50 +302,50 @@ discard block |
||
302 | 302 | /** |
303 | 303 | * Returns an array of payment forms table columns. |
304 | 304 | */ |
305 | - public static function payment_form_columns( $columns ) { |
|
305 | + public static function payment_form_columns($columns) { |
|
306 | 306 | |
307 | 307 | $columns = array( |
308 | 308 | 'cb' => $columns['cb'], |
309 | - 'title' => __( 'Name', 'invoicing' ), |
|
310 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
311 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
312 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
313 | - 'items' => __( 'Items', 'invoicing' ), |
|
314 | - 'date' => __( 'Date', 'invoicing' ), |
|
309 | + 'title' => __('Name', 'invoicing'), |
|
310 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
311 | + 'earnings' => __('Revenue', 'invoicing'), |
|
312 | + 'refunds' => __('Refunded', 'invoicing'), |
|
313 | + 'items' => __('Items', 'invoicing'), |
|
314 | + 'date' => __('Date', 'invoicing'), |
|
315 | 315 | ); |
316 | 316 | |
317 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
317 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
318 | 318 | |
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
322 | 322 | * Displays payment form table columns. |
323 | 323 | */ |
324 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
324 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
325 | 325 | |
326 | 326 | // Retrieve the payment form. |
327 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
327 | + $form = new GetPaid_Payment_Form($post_id); |
|
328 | 328 | |
329 | - switch ( $column_name ) { |
|
329 | + switch ($column_name) { |
|
330 | 330 | |
331 | 331 | case 'earnings' : |
332 | - echo wpinv_price( $form->get_earned() ); |
|
332 | + echo wpinv_price($form->get_earned()); |
|
333 | 333 | break; |
334 | 334 | |
335 | 335 | case 'refunds' : |
336 | - echo wpinv_price( $form->get_refunded() ); |
|
336 | + echo wpinv_price($form->get_refunded()); |
|
337 | 337 | break; |
338 | 338 | |
339 | 339 | case 'refunds' : |
340 | - echo wpinv_price( $form->get_refunded() ); |
|
340 | + echo wpinv_price($form->get_refunded()); |
|
341 | 341 | break; |
342 | 342 | |
343 | 343 | case 'shortcode' : |
344 | 344 | |
345 | - if ( $form->is_default() ) { |
|
345 | + if ($form->is_default()) { |
|
346 | 346 | echo '—'; |
347 | 347 | } else { |
348 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
348 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | break; |
@@ -354,29 +354,29 @@ discard block |
||
354 | 354 | |
355 | 355 | $items = $form->get_items(); |
356 | 356 | |
357 | - if ( $form->is_default() || empty( $items ) ) { |
|
357 | + if ($form->is_default() || empty($items)) { |
|
358 | 358 | echo '—'; |
359 | 359 | return; |
360 | 360 | } |
361 | 361 | |
362 | 362 | $_items = array(); |
363 | 363 | |
364 | - foreach ( $items as $item ) { |
|
364 | + foreach ($items as $item) { |
|
365 | 365 | $url = $item->get_edit_url(); |
366 | 366 | |
367 | - if ( empty( $url ) ) { |
|
368 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
367 | + if (empty($url)) { |
|
368 | + $_items[] = sanitize_text_field($item->get_name()); |
|
369 | 369 | } else { |
370 | 370 | $_items[] = sprintf( |
371 | 371 | '<a href="%s">%s</a>', |
372 | - esc_url( $url ), |
|
373 | - sanitize_text_field( $item->get_name() ) |
|
372 | + esc_url($url), |
|
373 | + sanitize_text_field($item->get_name()) |
|
374 | 374 | ); |
375 | 375 | } |
376 | 376 | |
377 | 377 | } |
378 | 378 | |
379 | - echo implode( '<br>', $_items ); |
|
379 | + echo implode('<br>', $_items); |
|
380 | 380 | |
381 | 381 | break; |
382 | 382 | |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | /** |
388 | 388 | * Filters post states. |
389 | 389 | */ |
390 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
390 | + public static function filter_payment_form_state($post_states, $post) { |
|
391 | 391 | |
392 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
393 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
392 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
393 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | return $post_states; |
@@ -400,35 +400,35 @@ discard block |
||
400 | 400 | /** |
401 | 401 | * Returns an array of coupon table columns. |
402 | 402 | */ |
403 | - public static function discount_columns( $columns ) { |
|
403 | + public static function discount_columns($columns) { |
|
404 | 404 | |
405 | 405 | $columns = array( |
406 | 406 | 'cb' => $columns['cb'], |
407 | - 'title' => __( 'Name', 'invoicing' ), |
|
408 | - 'code' => __( 'Code', 'invoicing' ), |
|
409 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
410 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
411 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
412 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
407 | + 'title' => __('Name', 'invoicing'), |
|
408 | + 'code' => __('Code', 'invoicing'), |
|
409 | + 'amount' => __('Amount', 'invoicing'), |
|
410 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
411 | + 'start_date' => __('Start Date', 'invoicing'), |
|
412 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
413 | 413 | ); |
414 | 414 | |
415 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
415 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
419 | 419 | * Filters post states. |
420 | 420 | */ |
421 | - public static function filter_discount_state( $post_states, $post ) { |
|
421 | + public static function filter_discount_state($post_states, $post) { |
|
422 | 422 | |
423 | - if ( 'wpi_discount' == $post->post_type ) { |
|
423 | + if ('wpi_discount' == $post->post_type) { |
|
424 | 424 | |
425 | - $discount = new WPInv_Discount( $post ); |
|
425 | + $discount = new WPInv_Discount($post); |
|
426 | 426 | |
427 | 427 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
428 | 428 | |
429 | - if ( $status != 'publish' ) { |
|
429 | + if ($status != 'publish') { |
|
430 | 430 | return array( |
431 | - 'discount_status' => wpinv_discount_status( $status ), |
|
431 | + 'discount_status' => wpinv_discount_status($status), |
|
432 | 432 | ); |
433 | 433 | } |
434 | 434 | |
@@ -443,30 +443,30 @@ discard block |
||
443 | 443 | /** |
444 | 444 | * Returns an array of items table columns. |
445 | 445 | */ |
446 | - public static function item_columns( $columns ) { |
|
446 | + public static function item_columns($columns) { |
|
447 | 447 | |
448 | 448 | $columns = array( |
449 | 449 | 'cb' => $columns['cb'], |
450 | - 'title' => __( 'Name', 'invoicing' ), |
|
451 | - 'price' => __( 'Price', 'invoicing' ), |
|
452 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
453 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
454 | - 'type' => __( 'Type', 'invoicing' ), |
|
455 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
450 | + 'title' => __('Name', 'invoicing'), |
|
451 | + 'price' => __('Price', 'invoicing'), |
|
452 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
453 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
454 | + 'type' => __('Type', 'invoicing'), |
|
455 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
456 | 456 | ); |
457 | 457 | |
458 | - if ( ! wpinv_use_taxes() ) { |
|
459 | - unset( $columns['vat_rule'] ); |
|
460 | - unset( $columns['vat_class'] ); |
|
458 | + if (!wpinv_use_taxes()) { |
|
459 | + unset($columns['vat_rule']); |
|
460 | + unset($columns['vat_class']); |
|
461 | 461 | } |
462 | 462 | |
463 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
463 | + return apply_filters('wpi_item_table_columns', $columns); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
467 | 467 | * Returns an array of sortable items table columns. |
468 | 468 | */ |
469 | - public static function sortable_item_columns( $columns ) { |
|
469 | + public static function sortable_item_columns($columns) { |
|
470 | 470 | |
471 | 471 | return array_merge( |
472 | 472 | $columns, |
@@ -483,49 +483,49 @@ discard block |
||
483 | 483 | /** |
484 | 484 | * Displays items table columns. |
485 | 485 | */ |
486 | - public static function display_item_columns( $column_name, $post_id ) { |
|
486 | + public static function display_item_columns($column_name, $post_id) { |
|
487 | 487 | |
488 | - $item = new WPInv_Item( $post_id ); |
|
488 | + $item = new WPInv_Item($post_id); |
|
489 | 489 | |
490 | - switch ( $column_name ) { |
|
490 | + switch ($column_name) { |
|
491 | 491 | |
492 | 492 | case 'price' : |
493 | 493 | |
494 | - if ( ! $item->is_recurring() ) { |
|
494 | + if (!$item->is_recurring()) { |
|
495 | 495 | echo $item->get_the_price(); |
496 | 496 | break; |
497 | 497 | } |
498 | 498 | |
499 | 499 | $price = wp_sprintf( |
500 | - __( '%s / %s', 'invoicing' ), |
|
500 | + __('%s / %s', 'invoicing'), |
|
501 | 501 | $item->get_the_price(), |
502 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
502 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
503 | 503 | ); |
504 | 504 | |
505 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
505 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
506 | 506 | echo $price; |
507 | 507 | break; |
508 | 508 | } |
509 | 509 | |
510 | 510 | echo $item->get_the_initial_price(); |
511 | 511 | |
512 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
512 | + echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>'; |
|
513 | 513 | break; |
514 | 514 | |
515 | 515 | case 'vat_rule' : |
516 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
516 | + echo getpaid_get_tax_rule_label($item->get_vat_rule()); |
|
517 | 517 | break; |
518 | 518 | |
519 | 519 | case 'vat_class' : |
520 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
520 | + echo getpaid_get_tax_class_label($item->get_vat_class()); |
|
521 | 521 | break; |
522 | 522 | |
523 | 523 | case 'shortcode' : |
524 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
524 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
525 | 525 | break; |
526 | 526 | |
527 | 527 | case 'type' : |
528 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
528 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
529 | 529 | break; |
530 | 530 | |
531 | 531 | } |
@@ -535,21 +535,21 @@ discard block |
||
535 | 535 | /** |
536 | 536 | * Lets users filter items using taxes. |
537 | 537 | */ |
538 | - public static function add_item_filters( $post_type ) { |
|
538 | + public static function add_item_filters($post_type) { |
|
539 | 539 | |
540 | 540 | // Abort if we're not dealing with items. |
541 | - if ( $post_type != 'wpi_item' ) { |
|
541 | + if ($post_type != 'wpi_item') { |
|
542 | 542 | return; |
543 | 543 | } |
544 | 544 | |
545 | 545 | // Filter by vat rules. |
546 | - if ( wpinv_use_taxes() ) { |
|
546 | + if (wpinv_use_taxes()) { |
|
547 | 547 | |
548 | 548 | // Sanitize selected vat rule. |
549 | 549 | $vat_rule = ''; |
550 | 550 | $vat_rules = getpaid_get_tax_rules(); |
551 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
552 | - $vat_rule = $_GET['vat_rule']; |
|
551 | + if (isset($_GET['vat_rule'])) { |
|
552 | + $vat_rule = $_GET['vat_rule']; |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | // Filter by VAT rule. |
@@ -557,13 +557,13 @@ discard block |
||
557 | 557 | array( |
558 | 558 | 'options' => array_merge( |
559 | 559 | array( |
560 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
560 | + '' => __('All VAT rules', 'invoicing') |
|
561 | 561 | ), |
562 | 562 | $vat_rules |
563 | 563 | ), |
564 | 564 | 'name' => 'vat_rule', |
565 | 565 | 'id' => 'vat_rule', |
566 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
566 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
567 | 567 | 'show_option_all' => false, |
568 | 568 | 'show_option_none' => false, |
569 | 569 | ) |
@@ -574,21 +574,21 @@ discard block |
||
574 | 574 | // Sanitize selected vat rule. |
575 | 575 | $vat_class = ''; |
576 | 576 | $vat_classes = getpaid_get_tax_classes(); |
577 | - if ( isset( $_GET['vat_class'] ) ) { |
|
578 | - $vat_class = $_GET['vat_class']; |
|
577 | + if (isset($_GET['vat_class'])) { |
|
578 | + $vat_class = $_GET['vat_class']; |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | echo wpinv_html_select( |
582 | 582 | array( |
583 | 583 | 'options' => array_merge( |
584 | 584 | array( |
585 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
585 | + '' => __('All VAT classes', 'invoicing') |
|
586 | 586 | ), |
587 | 587 | $vat_classes |
588 | 588 | ), |
589 | 589 | 'name' => 'vat_class', |
590 | 590 | 'id' => 'vat_class', |
591 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
591 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
592 | 592 | 'show_option_all' => false, |
593 | 593 | 'show_option_none' => false, |
594 | 594 | ) |
@@ -597,22 +597,22 @@ discard block |
||
597 | 597 | } |
598 | 598 | |
599 | 599 | // Filter by item type. |
600 | - $type = ''; |
|
601 | - if ( isset( $_GET['type'] ) ) { |
|
602 | - $type = $_GET['type']; |
|
600 | + $type = ''; |
|
601 | + if (isset($_GET['type'])) { |
|
602 | + $type = $_GET['type']; |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | echo wpinv_html_select( |
606 | 606 | array( |
607 | 607 | 'options' => array_merge( |
608 | 608 | array( |
609 | - '' => __( 'All item types', 'invoicing' ) |
|
609 | + '' => __('All item types', 'invoicing') |
|
610 | 610 | ), |
611 | 611 | wpinv_get_item_types() |
612 | 612 | ), |
613 | 613 | 'name' => 'type', |
614 | 614 | 'id' => 'type', |
615 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
615 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
616 | 616 | 'show_option_all' => false, |
617 | 617 | 'show_option_none' => false, |
618 | 618 | ) |
@@ -623,45 +623,45 @@ discard block |
||
623 | 623 | /** |
624 | 624 | * Filters the item query. |
625 | 625 | */ |
626 | - public static function filter_item_query( $query ) { |
|
626 | + public static function filter_item_query($query) { |
|
627 | 627 | |
628 | 628 | // modify the query only if it admin and main query. |
629 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
629 | + if (!(is_admin() && $query->is_main_query())) { |
|
630 | 630 | return $query; |
631 | 631 | } |
632 | 632 | |
633 | 633 | // we want to modify the query for our items. |
634 | - if ( 'wpi_item' != $query->query['post_type'] ){ |
|
634 | + if ('wpi_item' != $query->query['post_type']) { |
|
635 | 635 | return $query; |
636 | 636 | } |
637 | 637 | |
638 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
638 | + if (empty($query->query_vars['meta_query'])) { |
|
639 | 639 | $query->query_vars['meta_query'] = array(); |
640 | 640 | } |
641 | 641 | |
642 | 642 | // Filter vat rule type |
643 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
643 | + if (!empty($_GET['vat_rule'])) { |
|
644 | 644 | $query->query_vars['meta_query'][] = array( |
645 | 645 | 'key' => '_wpinv_vat_rule', |
646 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
646 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
647 | 647 | 'compare' => '=' |
648 | 648 | ); |
649 | 649 | } |
650 | 650 | |
651 | 651 | // Filter vat class |
652 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
652 | + if (!empty($_GET['vat_class'])) { |
|
653 | 653 | $query->query_vars['meta_query'][] = array( |
654 | 654 | 'key' => '_wpinv_vat_class', |
655 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
655 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
656 | 656 | 'compare' => '=' |
657 | 657 | ); |
658 | 658 | } |
659 | 659 | |
660 | 660 | // Filter item type |
661 | - if ( ! empty( $_GET['type'] ) ) { |
|
661 | + if (!empty($_GET['type'])) { |
|
662 | 662 | $query->query_vars['meta_query'][] = array( |
663 | 663 | 'key' => '_wpinv_type', |
664 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
664 | + 'value' => sanitize_text_field($_GET['type']), |
|
665 | 665 | 'compare' => '=' |
666 | 666 | ); |
667 | 667 | } |
@@ -671,15 +671,15 @@ discard block |
||
671 | 671 | /** |
672 | 672 | * Reorders items. |
673 | 673 | */ |
674 | - public static function reorder_items( $vars ) { |
|
674 | + public static function reorder_items($vars) { |
|
675 | 675 | global $typenow; |
676 | 676 | |
677 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
677 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
678 | 678 | return $vars; |
679 | 679 | } |
680 | 680 | |
681 | 681 | // By item type. |
682 | - if ( 'type' == $vars['orderby'] ) { |
|
682 | + if ('type' == $vars['orderby']) { |
|
683 | 683 | return array_merge( |
684 | 684 | $vars, |
685 | 685 | array( |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | } |
691 | 691 | |
692 | 692 | // By vat class. |
693 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
693 | + if ('vat_class' == $vars['orderby']) { |
|
694 | 694 | return array_merge( |
695 | 695 | $vars, |
696 | 696 | array( |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | } |
702 | 702 | |
703 | 703 | // By vat rule. |
704 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
704 | + if ('vat_rule' == $vars['orderby']) { |
|
705 | 705 | return array_merge( |
706 | 706 | $vars, |
707 | 707 | array( |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | } |
713 | 713 | |
714 | 714 | // By price. |
715 | - if ( 'price' == $vars['orderby'] ) { |
|
715 | + if ('price' == $vars['orderby']) { |
|
716 | 716 | return array_merge( |
717 | 717 | $vars, |
718 | 718 | array( |
@@ -729,27 +729,27 @@ discard block |
||
729 | 729 | /** |
730 | 730 | * Fired when deleting a post. |
731 | 731 | */ |
732 | - public static function delete_post( $post_id ) { |
|
732 | + public static function delete_post($post_id) { |
|
733 | 733 | |
734 | - switch ( get_post_type( $post_id ) ) { |
|
734 | + switch (get_post_type($post_id)) { |
|
735 | 735 | |
736 | 736 | case 'wpi_item' : |
737 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
737 | + do_action("getpaid_before_delete_item", new WPInv_Item($post_id)); |
|
738 | 738 | break; |
739 | 739 | |
740 | 740 | case 'wpi_payment_form' : |
741 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
741 | + do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id)); |
|
742 | 742 | break; |
743 | 743 | |
744 | 744 | case 'wpi_discount' : |
745 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
745 | + do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id)); |
|
746 | 746 | break; |
747 | 747 | |
748 | 748 | case 'wpi_invoice' : |
749 | - $invoice = new WPInv_Invoice( $post_id ); |
|
750 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
751 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
752 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
749 | + $invoice = new WPInv_Invoice($post_id); |
|
750 | + do_action("getpaid_before_delete_invoice", $invoice); |
|
751 | + $invoice->get_data_store()->delete_items($invoice); |
|
752 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
753 | 753 | break; |
754 | 754 | } |
755 | 755 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -10,30 +10,30 @@ discard block |
||
10 | 10 | class WPInv_Item extends GetPaid_Data { |
11 | 11 | |
12 | 12 | /** |
13 | - * Which data store to load. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
13 | + * Which data store to load. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | 17 | protected $data_store_name = 'item'; |
18 | 18 | |
19 | 19 | /** |
20 | - * This is the name of this object type. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $object_type = 'item'; |
|
20 | + * This is the name of this object type. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $object_type = 'item'; |
|
25 | 25 | |
26 | 26 | /** |
27 | - * Item Data array. This is the core item data exposed in APIs. |
|
28 | - * |
|
29 | - * @since 1.0.19 |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - protected $data = array( |
|
33 | - 'parent_id' => 0, |
|
34 | - 'status' => 'draft', |
|
35 | - 'version' => '', |
|
36 | - 'date_created' => null, |
|
27 | + * Item Data array. This is the core item data exposed in APIs. |
|
28 | + * |
|
29 | + * @since 1.0.19 |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + protected $data = array( |
|
33 | + 'parent_id' => 0, |
|
34 | + 'status' => 'draft', |
|
35 | + 'version' => '', |
|
36 | + 'date_created' => null, |
|
37 | 37 | 'date_modified' => null, |
38 | 38 | 'name' => '', |
39 | 39 | 'description' => '', |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | ); |
59 | 59 | |
60 | 60 | /** |
61 | - * Stores meta in cache for future reads. |
|
62 | - * |
|
63 | - * A group must be set to to enable caching. |
|
64 | - * |
|
65 | - * @var string |
|
66 | - */ |
|
67 | - protected $cache_group = 'getpaid_items'; |
|
61 | + * Stores meta in cache for future reads. |
|
62 | + * |
|
63 | + * A group must be set to to enable caching. |
|
64 | + * |
|
65 | + * @var string |
|
66 | + */ |
|
67 | + protected $cache_group = 'getpaid_items'; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Stores a reference to the original WP_Post object |
@@ -74,37 +74,37 @@ discard block |
||
74 | 74 | protected $post = null; |
75 | 75 | |
76 | 76 | /** |
77 | - * Get the item if ID is passed, otherwise the item is new and empty. |
|
78 | - * |
|
79 | - * @param int|object|WPInv_Item|WP_Post $item Item to read. |
|
80 | - */ |
|
81 | - public function __construct( $item = 0 ) { |
|
82 | - parent::__construct( $item ); |
|
83 | - |
|
84 | - if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) { |
|
85 | - $this->set_id( $item ); |
|
86 | - } elseif ( $item instanceof self ) { |
|
87 | - $this->set_id( $item->get_id() ); |
|
88 | - } elseif ( ! empty( $item->ID ) ) { |
|
89 | - $this->set_id( $item->ID ); |
|
90 | - } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) { |
|
91 | - $this->set_id( $item_id ); |
|
92 | - } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) { |
|
93 | - $this->set_id( $item_id ); |
|
94 | - } else { |
|
95 | - $this->set_object_read( true ); |
|
96 | - } |
|
77 | + * Get the item if ID is passed, otherwise the item is new and empty. |
|
78 | + * |
|
79 | + * @param int|object|WPInv_Item|WP_Post $item Item to read. |
|
80 | + */ |
|
81 | + public function __construct( $item = 0 ) { |
|
82 | + parent::__construct( $item ); |
|
83 | + |
|
84 | + if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) { |
|
85 | + $this->set_id( $item ); |
|
86 | + } elseif ( $item instanceof self ) { |
|
87 | + $this->set_id( $item->get_id() ); |
|
88 | + } elseif ( ! empty( $item->ID ) ) { |
|
89 | + $this->set_id( $item->ID ); |
|
90 | + } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) { |
|
91 | + $this->set_id( $item_id ); |
|
92 | + } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) { |
|
93 | + $this->set_id( $item_id ); |
|
94 | + } else { |
|
95 | + $this->set_object_read( true ); |
|
96 | + } |
|
97 | 97 | |
98 | 98 | // Load the datastore. |
99 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
99 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
100 | 100 | |
101 | - if ( $this->get_id() > 0 ) { |
|
101 | + if ( $this->get_id() > 0 ) { |
|
102 | 102 | $this->post = get_post( $this->get_id() ); |
103 | 103 | $this->ID = $this->get_id(); |
104 | - $this->data_store->read( $this ); |
|
104 | + $this->data_store->read( $this ); |
|
105 | 105 | } |
106 | 106 | |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | 109 | /* |
110 | 110 | |-------------------------------------------------------------------------- |
@@ -122,401 +122,401 @@ discard block |
||
122 | 122 | */ |
123 | 123 | |
124 | 124 | /** |
125 | - * Get parent item ID. |
|
126 | - * |
|
127 | - * @since 1.0.19 |
|
128 | - * @param string $context View or edit context. |
|
129 | - * @return int |
|
130 | - */ |
|
131 | - public function get_parent_id( $context = 'view' ) { |
|
132 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
125 | + * Get parent item ID. |
|
126 | + * |
|
127 | + * @since 1.0.19 |
|
128 | + * @param string $context View or edit context. |
|
129 | + * @return int |
|
130 | + */ |
|
131 | + public function get_parent_id( $context = 'view' ) { |
|
132 | + return (int) $this->get_prop( 'parent_id', $context ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | - * Get item status. |
|
137 | - * |
|
138 | - * @since 1.0.19 |
|
139 | - * @param string $context View or edit context. |
|
140 | - * @return string |
|
141 | - */ |
|
142 | - public function get_status( $context = 'view' ) { |
|
143 | - return $this->get_prop( 'status', $context ); |
|
136 | + * Get item status. |
|
137 | + * |
|
138 | + * @since 1.0.19 |
|
139 | + * @param string $context View or edit context. |
|
140 | + * @return string |
|
141 | + */ |
|
142 | + public function get_status( $context = 'view' ) { |
|
143 | + return $this->get_prop( 'status', $context ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | - * Get plugin version when the item was created. |
|
148 | - * |
|
149 | - * @since 1.0.19 |
|
150 | - * @param string $context View or edit context. |
|
151 | - * @return string |
|
152 | - */ |
|
153 | - public function get_version( $context = 'view' ) { |
|
154 | - return $this->get_prop( 'version', $context ); |
|
147 | + * Get plugin version when the item was created. |
|
148 | + * |
|
149 | + * @since 1.0.19 |
|
150 | + * @param string $context View or edit context. |
|
151 | + * @return string |
|
152 | + */ |
|
153 | + public function get_version( $context = 'view' ) { |
|
154 | + return $this->get_prop( 'version', $context ); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
158 | - * Get date when the item was created. |
|
159 | - * |
|
160 | - * @since 1.0.19 |
|
161 | - * @param string $context View or edit context. |
|
162 | - * @return string |
|
163 | - */ |
|
164 | - public function get_date_created( $context = 'view' ) { |
|
165 | - return $this->get_prop( 'date_created', $context ); |
|
158 | + * Get date when the item was created. |
|
159 | + * |
|
160 | + * @since 1.0.19 |
|
161 | + * @param string $context View or edit context. |
|
162 | + * @return string |
|
163 | + */ |
|
164 | + public function get_date_created( $context = 'view' ) { |
|
165 | + return $this->get_prop( 'date_created', $context ); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | - * Get GMT date when the item was created. |
|
170 | - * |
|
171 | - * @since 1.0.19 |
|
172 | - * @param string $context View or edit context. |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - public function get_date_created_gmt( $context = 'view' ) { |
|
169 | + * Get GMT date when the item was created. |
|
170 | + * |
|
171 | + * @since 1.0.19 |
|
172 | + * @param string $context View or edit context. |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + public function get_date_created_gmt( $context = 'view' ) { |
|
176 | 176 | $date = $this->get_date_created( $context ); |
177 | 177 | |
178 | 178 | if ( $date ) { |
179 | 179 | $date = get_gmt_from_date( $date ); |
180 | 180 | } |
181 | - return $date; |
|
181 | + return $date; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | - * Get date when the item was last modified. |
|
186 | - * |
|
187 | - * @since 1.0.19 |
|
188 | - * @param string $context View or edit context. |
|
189 | - * @return string |
|
190 | - */ |
|
191 | - public function get_date_modified( $context = 'view' ) { |
|
192 | - return $this->get_prop( 'date_modified', $context ); |
|
185 | + * Get date when the item was last modified. |
|
186 | + * |
|
187 | + * @since 1.0.19 |
|
188 | + * @param string $context View or edit context. |
|
189 | + * @return string |
|
190 | + */ |
|
191 | + public function get_date_modified( $context = 'view' ) { |
|
192 | + return $this->get_prop( 'date_modified', $context ); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
196 | - * Get GMT date when the item was last modified. |
|
197 | - * |
|
198 | - * @since 1.0.19 |
|
199 | - * @param string $context View or edit context. |
|
200 | - * @return string |
|
201 | - */ |
|
202 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
196 | + * Get GMT date when the item was last modified. |
|
197 | + * |
|
198 | + * @since 1.0.19 |
|
199 | + * @param string $context View or edit context. |
|
200 | + * @return string |
|
201 | + */ |
|
202 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
203 | 203 | $date = $this->get_date_modified( $context ); |
204 | 204 | |
205 | 205 | if ( $date ) { |
206 | 206 | $date = get_gmt_from_date( $date ); |
207 | 207 | } |
208 | - return $date; |
|
208 | + return $date; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
212 | - * Get the item name. |
|
213 | - * |
|
214 | - * @since 1.0.19 |
|
215 | - * @param string $context View or edit context. |
|
216 | - * @return string |
|
217 | - */ |
|
218 | - public function get_name( $context = 'view' ) { |
|
219 | - return $this->get_prop( 'name', $context ); |
|
212 | + * Get the item name. |
|
213 | + * |
|
214 | + * @since 1.0.19 |
|
215 | + * @param string $context View or edit context. |
|
216 | + * @return string |
|
217 | + */ |
|
218 | + public function get_name( $context = 'view' ) { |
|
219 | + return $this->get_prop( 'name', $context ); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | - * Alias of self::get_name(). |
|
224 | - * |
|
225 | - * @since 1.0.19 |
|
226 | - * @param string $context View or edit context. |
|
227 | - * @return string |
|
228 | - */ |
|
229 | - public function get_title( $context = 'view' ) { |
|
230 | - return $this->get_name( $context ); |
|
223 | + * Alias of self::get_name(). |
|
224 | + * |
|
225 | + * @since 1.0.19 |
|
226 | + * @param string $context View or edit context. |
|
227 | + * @return string |
|
228 | + */ |
|
229 | + public function get_title( $context = 'view' ) { |
|
230 | + return $this->get_name( $context ); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
234 | - * Get the item description. |
|
235 | - * |
|
236 | - * @since 1.0.19 |
|
237 | - * @param string $context View or edit context. |
|
238 | - * @return string |
|
239 | - */ |
|
240 | - public function get_description( $context = 'view' ) { |
|
241 | - return $this->get_prop( 'description', $context ); |
|
234 | + * Get the item description. |
|
235 | + * |
|
236 | + * @since 1.0.19 |
|
237 | + * @param string $context View or edit context. |
|
238 | + * @return string |
|
239 | + */ |
|
240 | + public function get_description( $context = 'view' ) { |
|
241 | + return $this->get_prop( 'description', $context ); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
245 | - * Alias of self::get_description(). |
|
246 | - * |
|
247 | - * @since 1.0.19 |
|
248 | - * @param string $context View or edit context. |
|
249 | - * @return string |
|
250 | - */ |
|
251 | - public function get_excerpt( $context = 'view' ) { |
|
252 | - return $this->get_description( $context ); |
|
245 | + * Alias of self::get_description(). |
|
246 | + * |
|
247 | + * @since 1.0.19 |
|
248 | + * @param string $context View or edit context. |
|
249 | + * @return string |
|
250 | + */ |
|
251 | + public function get_excerpt( $context = 'view' ) { |
|
252 | + return $this->get_description( $context ); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
256 | - * Alias of self::get_description(). |
|
257 | - * |
|
258 | - * @since 1.0.19 |
|
259 | - * @param string $context View or edit context. |
|
260 | - * @return string |
|
261 | - */ |
|
262 | - public function get_summary( $context = 'view' ) { |
|
263 | - return $this->get_description( $context ); |
|
256 | + * Alias of self::get_description(). |
|
257 | + * |
|
258 | + * @since 1.0.19 |
|
259 | + * @param string $context View or edit context. |
|
260 | + * @return string |
|
261 | + */ |
|
262 | + public function get_summary( $context = 'view' ) { |
|
263 | + return $this->get_description( $context ); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
267 | - * Get the owner of the item. |
|
268 | - * |
|
269 | - * @since 1.0.19 |
|
270 | - * @param string $context View or edit context. |
|
271 | - * @return int |
|
272 | - */ |
|
273 | - public function get_author( $context = 'view' ) { |
|
274 | - return (int) $this->get_prop( 'author', $context ); |
|
275 | - } |
|
267 | + * Get the owner of the item. |
|
268 | + * |
|
269 | + * @since 1.0.19 |
|
270 | + * @param string $context View or edit context. |
|
271 | + * @return int |
|
272 | + */ |
|
273 | + public function get_author( $context = 'view' ) { |
|
274 | + return (int) $this->get_prop( 'author', $context ); |
|
275 | + } |
|
276 | 276 | |
277 | - /** |
|
278 | - * Alias of self::get_author(). |
|
279 | - * |
|
280 | - * @since 1.0.19 |
|
281 | - * @param string $context View or edit context. |
|
282 | - * @return int |
|
283 | - */ |
|
284 | - public function get_owner( $context = 'view' ) { |
|
285 | - return $this->get_author( $context ); |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * Get the price of the item. |
|
290 | - * |
|
291 | - * @since 1.0.19 |
|
292 | - * @param string $context View or edit context. |
|
293 | - * @return float |
|
294 | - */ |
|
295 | - public function get_price( $context = 'view' ) { |
|
277 | + /** |
|
278 | + * Alias of self::get_author(). |
|
279 | + * |
|
280 | + * @since 1.0.19 |
|
281 | + * @param string $context View or edit context. |
|
282 | + * @return int |
|
283 | + */ |
|
284 | + public function get_owner( $context = 'view' ) { |
|
285 | + return $this->get_author( $context ); |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * Get the price of the item. |
|
290 | + * |
|
291 | + * @since 1.0.19 |
|
292 | + * @param string $context View or edit context. |
|
293 | + * @return float |
|
294 | + */ |
|
295 | + public function get_price( $context = 'view' ) { |
|
296 | 296 | return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) ); |
297 | - } |
|
297 | + } |
|
298 | 298 | |
299 | - /** |
|
300 | - * Get the inital price of the item. |
|
301 | - * |
|
302 | - * @since 1.0.19 |
|
303 | - * @param string $context View or edit context. |
|
304 | - * @return float |
|
305 | - */ |
|
306 | - public function get_initial_price( $context = 'view' ) { |
|
299 | + /** |
|
300 | + * Get the inital price of the item. |
|
301 | + * |
|
302 | + * @since 1.0.19 |
|
303 | + * @param string $context View or edit context. |
|
304 | + * @return float |
|
305 | + */ |
|
306 | + public function get_initial_price( $context = 'view' ) { |
|
307 | 307 | |
308 | - $price = (float) $this->get_price( $context ); |
|
308 | + $price = (float) $this->get_price( $context ); |
|
309 | 309 | |
310 | - if ( $this->has_free_trial() ) { |
|
311 | - $price = 0; |
|
312 | - } |
|
310 | + if ( $this->has_free_trial() ) { |
|
311 | + $price = 0; |
|
312 | + } |
|
313 | 313 | |
314 | 314 | return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) ); |
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
318 | - * Returns a formated price. |
|
319 | - * |
|
320 | - * @since 1.0.19 |
|
321 | - * @param string $context View or edit context. |
|
322 | - * @return string |
|
323 | - */ |
|
318 | + * Returns a formated price. |
|
319 | + * |
|
320 | + * @since 1.0.19 |
|
321 | + * @param string $context View or edit context. |
|
322 | + * @return string |
|
323 | + */ |
|
324 | 324 | public function get_the_price() { |
325 | 325 | return wpinv_price( $this->get_price() ); |
326 | - } |
|
327 | - |
|
328 | - /** |
|
329 | - * Returns the formated initial price. |
|
330 | - * |
|
331 | - * @since 1.0.19 |
|
332 | - * @param string $context View or edit context. |
|
333 | - * @return string |
|
334 | - */ |
|
326 | + } |
|
327 | + |
|
328 | + /** |
|
329 | + * Returns the formated initial price. |
|
330 | + * |
|
331 | + * @since 1.0.19 |
|
332 | + * @param string $context View or edit context. |
|
333 | + * @return string |
|
334 | + */ |
|
335 | 335 | public function get_the_initial_price() { |
336 | 336 | return wpinv_price( $this->get_initial_price() ); |
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
340 | - * Get the VAT rule of the item. |
|
341 | - * |
|
342 | - * @since 1.0.19 |
|
343 | - * @param string $context View or edit context. |
|
344 | - * @return string |
|
345 | - */ |
|
346 | - public function get_vat_rule( $context = 'view' ) { |
|
340 | + * Get the VAT rule of the item. |
|
341 | + * |
|
342 | + * @since 1.0.19 |
|
343 | + * @param string $context View or edit context. |
|
344 | + * @return string |
|
345 | + */ |
|
346 | + public function get_vat_rule( $context = 'view' ) { |
|
347 | 347 | return $this->get_prop( 'vat_rule', $context ); |
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
351 | - * Get the VAT class of the item. |
|
352 | - * |
|
353 | - * @since 1.0.19 |
|
354 | - * @param string $context View or edit context. |
|
355 | - * @return string |
|
356 | - */ |
|
357 | - public function get_vat_class( $context = 'view' ) { |
|
351 | + * Get the VAT class of the item. |
|
352 | + * |
|
353 | + * @since 1.0.19 |
|
354 | + * @param string $context View or edit context. |
|
355 | + * @return string |
|
356 | + */ |
|
357 | + public function get_vat_class( $context = 'view' ) { |
|
358 | 358 | return $this->get_prop( 'vat_class', $context ); |
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
362 | - * Get the type of the item. |
|
363 | - * |
|
364 | - * @since 1.0.19 |
|
365 | - * @param string $context View or edit context. |
|
366 | - * @return string |
|
367 | - */ |
|
368 | - public function get_type( $context = 'view' ) { |
|
362 | + * Get the type of the item. |
|
363 | + * |
|
364 | + * @since 1.0.19 |
|
365 | + * @param string $context View or edit context. |
|
366 | + * @return string |
|
367 | + */ |
|
368 | + public function get_type( $context = 'view' ) { |
|
369 | 369 | return $this->get_prop( 'type', $context ); |
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
373 | - * Get the custom id of the item. |
|
374 | - * |
|
375 | - * @since 1.0.19 |
|
376 | - * @param string $context View or edit context. |
|
377 | - * @return string |
|
378 | - */ |
|
379 | - public function get_custom_id( $context = 'view' ) { |
|
373 | + * Get the custom id of the item. |
|
374 | + * |
|
375 | + * @since 1.0.19 |
|
376 | + * @param string $context View or edit context. |
|
377 | + * @return string |
|
378 | + */ |
|
379 | + public function get_custom_id( $context = 'view' ) { |
|
380 | 380 | return $this->get_prop( 'custom_id', $context ); |
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
384 | - * Get the custom name of the item. |
|
385 | - * |
|
386 | - * @since 1.0.19 |
|
387 | - * @param string $context View or edit context. |
|
388 | - * @return string |
|
389 | - */ |
|
390 | - public function get_custom_name( $context = 'view' ) { |
|
384 | + * Get the custom name of the item. |
|
385 | + * |
|
386 | + * @since 1.0.19 |
|
387 | + * @param string $context View or edit context. |
|
388 | + * @return string |
|
389 | + */ |
|
390 | + public function get_custom_name( $context = 'view' ) { |
|
391 | 391 | return $this->get_prop( 'custom_name', $context ); |
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
395 | - * Get the custom singular name of the item. |
|
396 | - * |
|
397 | - * @since 1.0.19 |
|
398 | - * @param string $context View or edit context. |
|
399 | - * @return string |
|
400 | - */ |
|
401 | - public function get_custom_singular_name( $context = 'view' ) { |
|
395 | + * Get the custom singular name of the item. |
|
396 | + * |
|
397 | + * @since 1.0.19 |
|
398 | + * @param string $context View or edit context. |
|
399 | + * @return string |
|
400 | + */ |
|
401 | + public function get_custom_singular_name( $context = 'view' ) { |
|
402 | 402 | return $this->get_prop( 'custom_singular_name', $context ); |
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
406 | - * Checks if an item is editable.. |
|
407 | - * |
|
408 | - * @since 1.0.19 |
|
409 | - * @param string $context View or edit context. |
|
410 | - * @return int |
|
411 | - */ |
|
412 | - public function get_is_editable( $context = 'view' ) { |
|
406 | + * Checks if an item is editable.. |
|
407 | + * |
|
408 | + * @since 1.0.19 |
|
409 | + * @param string $context View or edit context. |
|
410 | + * @return int |
|
411 | + */ |
|
412 | + public function get_is_editable( $context = 'view' ) { |
|
413 | 413 | return (int) $this->get_prop( 'is_editable', $context ); |
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
417 | - * Alias of self::get_is_editable(). |
|
418 | - * |
|
419 | - * @since 1.0.19 |
|
420 | - * @param string $context View or edit context. |
|
421 | - * @return int |
|
422 | - */ |
|
423 | - public function get_editable( $context = 'view' ) { |
|
424 | - return $this->get_is_editable( $context ); |
|
417 | + * Alias of self::get_is_editable(). |
|
418 | + * |
|
419 | + * @since 1.0.19 |
|
420 | + * @param string $context View or edit context. |
|
421 | + * @return int |
|
422 | + */ |
|
423 | + public function get_editable( $context = 'view' ) { |
|
424 | + return $this->get_is_editable( $context ); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
428 | - * Checks if dynamic pricing is enabled. |
|
429 | - * |
|
430 | - * @since 1.0.19 |
|
431 | - * @param string $context View or edit context. |
|
432 | - * @return int |
|
433 | - */ |
|
434 | - public function get_is_dynamic_pricing( $context = 'view' ) { |
|
428 | + * Checks if dynamic pricing is enabled. |
|
429 | + * |
|
430 | + * @since 1.0.19 |
|
431 | + * @param string $context View or edit context. |
|
432 | + * @return int |
|
433 | + */ |
|
434 | + public function get_is_dynamic_pricing( $context = 'view' ) { |
|
435 | 435 | return (int) $this->get_prop( 'is_dynamic_pricing', $context ); |
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
439 | - * Returns the minimum price if dynamic pricing is enabled. |
|
440 | - * |
|
441 | - * @since 1.0.19 |
|
442 | - * @param string $context View or edit context. |
|
443 | - * @return float |
|
444 | - */ |
|
445 | - public function get_minimum_price( $context = 'view' ) { |
|
439 | + * Returns the minimum price if dynamic pricing is enabled. |
|
440 | + * |
|
441 | + * @since 1.0.19 |
|
442 | + * @param string $context View or edit context. |
|
443 | + * @return float |
|
444 | + */ |
|
445 | + public function get_minimum_price( $context = 'view' ) { |
|
446 | 446 | return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) ); |
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
450 | - * Checks if this is a recurring item. |
|
451 | - * |
|
452 | - * @since 1.0.19 |
|
453 | - * @param string $context View or edit context. |
|
454 | - * @return int |
|
455 | - */ |
|
456 | - public function get_is_recurring( $context = 'view' ) { |
|
450 | + * Checks if this is a recurring item. |
|
451 | + * |
|
452 | + * @since 1.0.19 |
|
453 | + * @param string $context View or edit context. |
|
454 | + * @return int |
|
455 | + */ |
|
456 | + public function get_is_recurring( $context = 'view' ) { |
|
457 | 457 | return (int) $this->get_prop( 'is_recurring', $context ); |
458 | - } |
|
458 | + } |
|
459 | 459 | |
460 | - /** |
|
461 | - * Get the recurring price of the item. |
|
462 | - * |
|
463 | - * @since 1.0.19 |
|
464 | - * @param string $context View or edit context. |
|
465 | - * @return float |
|
466 | - */ |
|
467 | - public function get_recurring_price( $context = 'view' ) { |
|
468 | - $price = $this->get_price( $context ); |
|
460 | + /** |
|
461 | + * Get the recurring price of the item. |
|
462 | + * |
|
463 | + * @since 1.0.19 |
|
464 | + * @param string $context View or edit context. |
|
465 | + * @return float |
|
466 | + */ |
|
467 | + public function get_recurring_price( $context = 'view' ) { |
|
468 | + $price = $this->get_price( $context ); |
|
469 | 469 | return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) ); |
470 | - } |
|
471 | - |
|
472 | - /** |
|
473 | - * Get the formatted recurring price of the item. |
|
474 | - * |
|
475 | - * @since 1.0.19 |
|
476 | - * @param string $context View or edit context. |
|
477 | - * @return string |
|
478 | - */ |
|
470 | + } |
|
471 | + |
|
472 | + /** |
|
473 | + * Get the formatted recurring price of the item. |
|
474 | + * |
|
475 | + * @since 1.0.19 |
|
476 | + * @param string $context View or edit context. |
|
477 | + * @return string |
|
478 | + */ |
|
479 | 479 | public function get_the_recurring_price() { |
480 | 480 | return wpinv_price( $this->get_recurring_price() ); |
481 | - } |
|
482 | - |
|
483 | - /** |
|
484 | - * Get the first renewal date (in timestamps) of the item. |
|
485 | - * |
|
486 | - * @since 1.0.19 |
|
487 | - * @return int |
|
488 | - */ |
|
489 | - public function get_first_renewal_date() { |
|
490 | - |
|
491 | - $periods = array( |
|
492 | - 'D' => 'days', |
|
493 | - 'W' => 'weeks', |
|
494 | - 'M' => 'months', |
|
495 | - 'Y' => 'years', |
|
496 | - ); |
|
497 | - |
|
498 | - $period = $this->get_recurring_period(); |
|
499 | - $interval = $this->get_recurring_interval(); |
|
500 | - |
|
501 | - if ( $this->has_free_trial() ) { |
|
502 | - $period = $this->get_trial_period(); |
|
503 | - $interval = $this->get_trial_interval(); |
|
504 | - } |
|
505 | - |
|
506 | - $period = $periods[ $period ]; |
|
507 | - $interval = empty( $interval ) ? 1 : $interval; |
|
508 | - $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) ); |
|
481 | + } |
|
482 | + |
|
483 | + /** |
|
484 | + * Get the first renewal date (in timestamps) of the item. |
|
485 | + * |
|
486 | + * @since 1.0.19 |
|
487 | + * @return int |
|
488 | + */ |
|
489 | + public function get_first_renewal_date() { |
|
490 | + |
|
491 | + $periods = array( |
|
492 | + 'D' => 'days', |
|
493 | + 'W' => 'weeks', |
|
494 | + 'M' => 'months', |
|
495 | + 'Y' => 'years', |
|
496 | + ); |
|
497 | + |
|
498 | + $period = $this->get_recurring_period(); |
|
499 | + $interval = $this->get_recurring_interval(); |
|
500 | + |
|
501 | + if ( $this->has_free_trial() ) { |
|
502 | + $period = $this->get_trial_period(); |
|
503 | + $interval = $this->get_trial_interval(); |
|
504 | + } |
|
505 | + |
|
506 | + $period = $periods[ $period ]; |
|
507 | + $interval = empty( $interval ) ? 1 : $interval; |
|
508 | + $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) ); |
|
509 | 509 | return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this ); |
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
513 | - * Get the recurring period. |
|
514 | - * |
|
515 | - * @since 1.0.19 |
|
516 | - * @param bool $full Return abbreviation or in full. |
|
517 | - * @return string |
|
518 | - */ |
|
519 | - public function get_recurring_period( $full = false ) { |
|
513 | + * Get the recurring period. |
|
514 | + * |
|
515 | + * @since 1.0.19 |
|
516 | + * @param bool $full Return abbreviation or in full. |
|
517 | + * @return string |
|
518 | + */ |
|
519 | + public function get_recurring_period( $full = false ) { |
|
520 | 520 | $period = $this->get_prop( 'recurring_period', 'view' ); |
521 | 521 | |
522 | 522 | if ( $full && ! is_bool( $full ) ) { |
@@ -527,63 +527,63 @@ discard block |
||
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
530 | - * Get the recurring interval. |
|
531 | - * |
|
532 | - * @since 1.0.19 |
|
533 | - * @param string $context View or edit context. |
|
534 | - * @return int |
|
535 | - */ |
|
536 | - public function get_recurring_interval( $context = 'view' ) { |
|
537 | - $interval = absint( $this->get_prop( 'recurring_interval', $context ) ); |
|
530 | + * Get the recurring interval. |
|
531 | + * |
|
532 | + * @since 1.0.19 |
|
533 | + * @param string $context View or edit context. |
|
534 | + * @return int |
|
535 | + */ |
|
536 | + public function get_recurring_interval( $context = 'view' ) { |
|
537 | + $interval = absint( $this->get_prop( 'recurring_interval', $context ) ); |
|
538 | 538 | |
539 | - if ( $interval < 1 ) { |
|
540 | - $interval = 1; |
|
541 | - } |
|
539 | + if ( $interval < 1 ) { |
|
540 | + $interval = 1; |
|
541 | + } |
|
542 | 542 | |
543 | 543 | return $interval; |
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
547 | - * Get the recurring limit. |
|
548 | - * |
|
549 | - * @since 1.0.19 |
|
550 | - * @param string $context View or edit context. |
|
551 | - * @return int |
|
552 | - */ |
|
553 | - public function get_recurring_limit( $context = 'view' ) { |
|
547 | + * Get the recurring limit. |
|
548 | + * |
|
549 | + * @since 1.0.19 |
|
550 | + * @param string $context View or edit context. |
|
551 | + * @return int |
|
552 | + */ |
|
553 | + public function get_recurring_limit( $context = 'view' ) { |
|
554 | 554 | return (int) $this->get_prop( 'recurring_limit', $context ); |
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
558 | - * Checks if we have a free trial. |
|
559 | - * |
|
560 | - * @since 1.0.19 |
|
561 | - * @param string $context View or edit context. |
|
562 | - * @return int |
|
563 | - */ |
|
564 | - public function get_is_free_trial( $context = 'view' ) { |
|
558 | + * Checks if we have a free trial. |
|
559 | + * |
|
560 | + * @since 1.0.19 |
|
561 | + * @param string $context View or edit context. |
|
562 | + * @return int |
|
563 | + */ |
|
564 | + public function get_is_free_trial( $context = 'view' ) { |
|
565 | 565 | return (int) $this->get_prop( 'is_free_trial', $context ); |
566 | 566 | } |
567 | 567 | |
568 | 568 | /** |
569 | - * Alias for self::get_is_free_trial(). |
|
570 | - * |
|
571 | - * @since 1.0.19 |
|
572 | - * @param string $context View or edit context. |
|
573 | - * @return int |
|
574 | - */ |
|
575 | - public function get_free_trial( $context = 'view' ) { |
|
569 | + * Alias for self::get_is_free_trial(). |
|
570 | + * |
|
571 | + * @since 1.0.19 |
|
572 | + * @param string $context View or edit context. |
|
573 | + * @return int |
|
574 | + */ |
|
575 | + public function get_free_trial( $context = 'view' ) { |
|
576 | 576 | return $this->get_is_free_trial( $context ); |
577 | 577 | } |
578 | 578 | |
579 | 579 | /** |
580 | - * Get the trial period. |
|
581 | - * |
|
582 | - * @since 1.0.19 |
|
583 | - * @param bool $full Return abbreviation or in full. |
|
584 | - * @return string |
|
585 | - */ |
|
586 | - public function get_trial_period( $full = false ) { |
|
580 | + * Get the trial period. |
|
581 | + * |
|
582 | + * @since 1.0.19 |
|
583 | + * @param bool $full Return abbreviation or in full. |
|
584 | + * @return string |
|
585 | + */ |
|
586 | + public function get_trial_period( $full = false ) { |
|
587 | 587 | $period = $this->get_prop( 'trial_period', 'view' ); |
588 | 588 | |
589 | 589 | if ( $full && ! is_bool( $full ) ) { |
@@ -594,104 +594,104 @@ discard block |
||
594 | 594 | } |
595 | 595 | |
596 | 596 | /** |
597 | - * Get the trial interval. |
|
598 | - * |
|
599 | - * @since 1.0.19 |
|
600 | - * @param string $context View or edit context. |
|
601 | - * @return int |
|
602 | - */ |
|
603 | - public function get_trial_interval( $context = 'view' ) { |
|
597 | + * Get the trial interval. |
|
598 | + * |
|
599 | + * @since 1.0.19 |
|
600 | + * @param string $context View or edit context. |
|
601 | + * @return int |
|
602 | + */ |
|
603 | + public function get_trial_interval( $context = 'view' ) { |
|
604 | 604 | return (int) $this->get_prop( 'trial_interval', $context ); |
605 | - } |
|
605 | + } |
|
606 | 606 | |
607 | - /** |
|
608 | - * Get the item's edit url. |
|
609 | - * |
|
610 | - * @since 1.0.19 |
|
611 | - * @return string |
|
612 | - */ |
|
613 | - public function get_edit_url() { |
|
607 | + /** |
|
608 | + * Get the item's edit url. |
|
609 | + * |
|
610 | + * @since 1.0.19 |
|
611 | + * @return string |
|
612 | + */ |
|
613 | + public function get_edit_url() { |
|
614 | 614 | return get_edit_post_link( $this->get_id() ); |
615 | - } |
|
616 | - |
|
617 | - /** |
|
618 | - * Given an item's name/custom id, it returns its id. |
|
619 | - * |
|
620 | - * |
|
621 | - * @static |
|
622 | - * @param string $value The item name or custom id. |
|
623 | - * @param string $field Either name or custom_id. |
|
624 | - * @param string $type in case you need to search for a given type. |
|
625 | - * @since 1.0.15 |
|
626 | - * @return int |
|
627 | - */ |
|
628 | - public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) { |
|
629 | - |
|
630 | - // Trim the value. |
|
631 | - $value = sanitize_text_field( $value ); |
|
632 | - if ( empty( $value ) ) { |
|
633 | - return 0; |
|
634 | - } |
|
615 | + } |
|
616 | + |
|
617 | + /** |
|
618 | + * Given an item's name/custom id, it returns its id. |
|
619 | + * |
|
620 | + * |
|
621 | + * @static |
|
622 | + * @param string $value The item name or custom id. |
|
623 | + * @param string $field Either name or custom_id. |
|
624 | + * @param string $type in case you need to search for a given type. |
|
625 | + * @since 1.0.15 |
|
626 | + * @return int |
|
627 | + */ |
|
628 | + public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) { |
|
629 | + |
|
630 | + // Trim the value. |
|
631 | + $value = sanitize_text_field( $value ); |
|
632 | + if ( empty( $value ) ) { |
|
633 | + return 0; |
|
634 | + } |
|
635 | 635 | |
636 | 636 | // Valid fields. |
637 | 637 | $fields = array( 'custom_id', 'name', 'slug' ); |
638 | 638 | |
639 | - // Ensure a field has been passed. |
|
640 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
641 | - return 0; |
|
642 | - } |
|
643 | - |
|
644 | - if ( $field == 'name' ) { |
|
645 | - $field = 'slug'; |
|
646 | - } |
|
647 | - |
|
648 | - // Maybe retrieve from the cache. |
|
649 | - $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
650 | - if ( ! empty( $item_id ) ) { |
|
651 | - return $item_id; |
|
652 | - } |
|
653 | - |
|
654 | - // Fetch from the db. |
|
655 | - $items = array(); |
|
656 | - if ( $field == 'slug' ) { |
|
657 | - $items = get_posts( |
|
658 | - array( |
|
659 | - 'post_type' => 'wpi_item', |
|
660 | - 'name' => $value, |
|
661 | - 'posts_per_page' => 1, |
|
662 | - 'post_status' => 'any', |
|
663 | - ) |
|
664 | - ); |
|
665 | - } |
|
666 | - |
|
667 | - if ( $field =='custom_id' ) { |
|
668 | - $items = get_posts( |
|
669 | - array( |
|
670 | - 'post_type' => 'wpi_item', |
|
671 | - 'posts_per_page' => 1, |
|
672 | - 'post_status' => 'any', |
|
673 | - 'meta_query' => array( |
|
674 | - array( |
|
675 | - 'key' => '_wpinv_type', |
|
676 | - 'value' => $type, |
|
677 | - ), |
|
678 | - array( |
|
679 | - 'key' => '_wpinv_custom_id', |
|
680 | - 'value' => $value, |
|
681 | - ) |
|
682 | - ) |
|
683 | - ) |
|
684 | - ); |
|
685 | - } |
|
686 | - |
|
687 | - if ( empty( $items ) ) { |
|
688 | - return 0; |
|
689 | - } |
|
690 | - |
|
691 | - // Update the cache with our data |
|
692 | - wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
693 | - |
|
694 | - return $items[0]->ID; |
|
639 | + // Ensure a field has been passed. |
|
640 | + if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
641 | + return 0; |
|
642 | + } |
|
643 | + |
|
644 | + if ( $field == 'name' ) { |
|
645 | + $field = 'slug'; |
|
646 | + } |
|
647 | + |
|
648 | + // Maybe retrieve from the cache. |
|
649 | + $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
650 | + if ( ! empty( $item_id ) ) { |
|
651 | + return $item_id; |
|
652 | + } |
|
653 | + |
|
654 | + // Fetch from the db. |
|
655 | + $items = array(); |
|
656 | + if ( $field == 'slug' ) { |
|
657 | + $items = get_posts( |
|
658 | + array( |
|
659 | + 'post_type' => 'wpi_item', |
|
660 | + 'name' => $value, |
|
661 | + 'posts_per_page' => 1, |
|
662 | + 'post_status' => 'any', |
|
663 | + ) |
|
664 | + ); |
|
665 | + } |
|
666 | + |
|
667 | + if ( $field =='custom_id' ) { |
|
668 | + $items = get_posts( |
|
669 | + array( |
|
670 | + 'post_type' => 'wpi_item', |
|
671 | + 'posts_per_page' => 1, |
|
672 | + 'post_status' => 'any', |
|
673 | + 'meta_query' => array( |
|
674 | + array( |
|
675 | + 'key' => '_wpinv_type', |
|
676 | + 'value' => $type, |
|
677 | + ), |
|
678 | + array( |
|
679 | + 'key' => '_wpinv_custom_id', |
|
680 | + 'value' => $value, |
|
681 | + ) |
|
682 | + ) |
|
683 | + ) |
|
684 | + ); |
|
685 | + } |
|
686 | + |
|
687 | + if ( empty( $items ) ) { |
|
688 | + return 0; |
|
689 | + } |
|
690 | + |
|
691 | + // Update the cache with our data |
|
692 | + wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
693 | + |
|
694 | + return $items[0]->ID; |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
@@ -724,52 +724,52 @@ discard block |
||
724 | 724 | */ |
725 | 725 | |
726 | 726 | /** |
727 | - * Set parent order ID. |
|
728 | - * |
|
729 | - * @since 1.0.19 |
|
730 | - */ |
|
731 | - public function set_parent_id( $value ) { |
|
732 | - if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) { |
|
733 | - return; |
|
734 | - } |
|
735 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
736 | - } |
|
737 | - |
|
738 | - /** |
|
739 | - * Sets item status. |
|
740 | - * |
|
741 | - * @since 1.0.19 |
|
742 | - * @param string $status New status. |
|
743 | - * @return array details of change. |
|
744 | - */ |
|
745 | - public function set_status( $status ) { |
|
727 | + * Set parent order ID. |
|
728 | + * |
|
729 | + * @since 1.0.19 |
|
730 | + */ |
|
731 | + public function set_parent_id( $value ) { |
|
732 | + if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) { |
|
733 | + return; |
|
734 | + } |
|
735 | + $this->set_prop( 'parent_id', absint( $value ) ); |
|
736 | + } |
|
737 | + |
|
738 | + /** |
|
739 | + * Sets item status. |
|
740 | + * |
|
741 | + * @since 1.0.19 |
|
742 | + * @param string $status New status. |
|
743 | + * @return array details of change. |
|
744 | + */ |
|
745 | + public function set_status( $status ) { |
|
746 | 746 | $old_status = $this->get_status(); |
747 | 747 | |
748 | 748 | $this->set_prop( 'status', $status ); |
749 | 749 | |
750 | - return array( |
|
751 | - 'from' => $old_status, |
|
752 | - 'to' => $status, |
|
753 | - ); |
|
750 | + return array( |
|
751 | + 'from' => $old_status, |
|
752 | + 'to' => $status, |
|
753 | + ); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | /** |
757 | - * Set plugin version when the item was created. |
|
758 | - * |
|
759 | - * @since 1.0.19 |
|
760 | - */ |
|
761 | - public function set_version( $value ) { |
|
762 | - $this->set_prop( 'version', $value ); |
|
757 | + * Set plugin version when the item was created. |
|
758 | + * |
|
759 | + * @since 1.0.19 |
|
760 | + */ |
|
761 | + public function set_version( $value ) { |
|
762 | + $this->set_prop( 'version', $value ); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
766 | - * Set date when the item was created. |
|
767 | - * |
|
768 | - * @since 1.0.19 |
|
769 | - * @param string $value Value to set. |
|
766 | + * Set date when the item was created. |
|
767 | + * |
|
768 | + * @since 1.0.19 |
|
769 | + * @param string $value Value to set. |
|
770 | 770 | * @return bool Whether or not the date was set. |
771 | - */ |
|
772 | - public function set_date_created( $value ) { |
|
771 | + */ |
|
772 | + public function set_date_created( $value ) { |
|
773 | 773 | $date = strtotime( $value ); |
774 | 774 | |
775 | 775 | if ( $date ) { |
@@ -782,13 +782,13 @@ discard block |
||
782 | 782 | } |
783 | 783 | |
784 | 784 | /** |
785 | - * Set date when the item was last modified. |
|
786 | - * |
|
787 | - * @since 1.0.19 |
|
788 | - * @param string $value Value to set. |
|
785 | + * Set date when the item was last modified. |
|
786 | + * |
|
787 | + * @since 1.0.19 |
|
788 | + * @param string $value Value to set. |
|
789 | 789 | * @return bool Whether or not the date was set. |
790 | - */ |
|
791 | - public function set_date_modified( $value ) { |
|
790 | + */ |
|
791 | + public function set_date_modified( $value ) { |
|
792 | 792 | $date = strtotime( $value ); |
793 | 793 | |
794 | 794 | if ( $date ) { |
@@ -801,115 +801,115 @@ discard block |
||
801 | 801 | } |
802 | 802 | |
803 | 803 | /** |
804 | - * Set the item name. |
|
805 | - * |
|
806 | - * @since 1.0.19 |
|
807 | - * @param string $value New name. |
|
808 | - */ |
|
809 | - public function set_name( $value ) { |
|
804 | + * Set the item name. |
|
805 | + * |
|
806 | + * @since 1.0.19 |
|
807 | + * @param string $value New name. |
|
808 | + */ |
|
809 | + public function set_name( $value ) { |
|
810 | 810 | $name = sanitize_text_field( $value ); |
811 | - $this->set_prop( 'name', $name ); |
|
811 | + $this->set_prop( 'name', $name ); |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | /** |
815 | - * Alias of self::set_name(). |
|
816 | - * |
|
817 | - * @since 1.0.19 |
|
818 | - * @param string $value New name. |
|
819 | - */ |
|
820 | - public function set_title( $value ) { |
|
821 | - $this->set_name( $value ); |
|
815 | + * Alias of self::set_name(). |
|
816 | + * |
|
817 | + * @since 1.0.19 |
|
818 | + * @param string $value New name. |
|
819 | + */ |
|
820 | + public function set_title( $value ) { |
|
821 | + $this->set_name( $value ); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | /** |
825 | - * Set the item description. |
|
826 | - * |
|
827 | - * @since 1.0.19 |
|
828 | - * @param string $value New description. |
|
829 | - */ |
|
830 | - public function set_description( $value ) { |
|
825 | + * Set the item description. |
|
826 | + * |
|
827 | + * @since 1.0.19 |
|
828 | + * @param string $value New description. |
|
829 | + */ |
|
830 | + public function set_description( $value ) { |
|
831 | 831 | $description = wp_kses_post( $value ); |
832 | - return $this->set_prop( 'description', $description ); |
|
832 | + return $this->set_prop( 'description', $description ); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | /** |
836 | - * Alias of self::set_description(). |
|
837 | - * |
|
838 | - * @since 1.0.19 |
|
839 | - * @param string $value New description. |
|
840 | - */ |
|
841 | - public function set_excerpt( $value ) { |
|
842 | - $this->set_description( $value ); |
|
836 | + * Alias of self::set_description(). |
|
837 | + * |
|
838 | + * @since 1.0.19 |
|
839 | + * @param string $value New description. |
|
840 | + */ |
|
841 | + public function set_excerpt( $value ) { |
|
842 | + $this->set_description( $value ); |
|
843 | 843 | } |
844 | 844 | |
845 | 845 | /** |
846 | - * Alias of self::set_description(). |
|
847 | - * |
|
848 | - * @since 1.0.19 |
|
849 | - * @param string $value New description. |
|
850 | - */ |
|
851 | - public function set_summary( $value ) { |
|
852 | - $this->set_description( $value ); |
|
846 | + * Alias of self::set_description(). |
|
847 | + * |
|
848 | + * @since 1.0.19 |
|
849 | + * @param string $value New description. |
|
850 | + */ |
|
851 | + public function set_summary( $value ) { |
|
852 | + $this->set_description( $value ); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
856 | - * Set the owner of the item. |
|
857 | - * |
|
858 | - * @since 1.0.19 |
|
859 | - * @param int $value New author. |
|
860 | - */ |
|
861 | - public function set_author( $value ) { |
|
862 | - $this->set_prop( 'author', (int) $value ); |
|
863 | - } |
|
856 | + * Set the owner of the item. |
|
857 | + * |
|
858 | + * @since 1.0.19 |
|
859 | + * @param int $value New author. |
|
860 | + */ |
|
861 | + public function set_author( $value ) { |
|
862 | + $this->set_prop( 'author', (int) $value ); |
|
863 | + } |
|
864 | 864 | |
865 | - /** |
|
866 | - * Alias of self::set_author(). |
|
867 | - * |
|
868 | - * @since 1.0.19 |
|
869 | - * @param int $value New author. |
|
870 | - */ |
|
871 | - public function set_owner( $value ) { |
|
872 | - $this->set_author( $value ); |
|
873 | - } |
|
874 | - |
|
875 | - /** |
|
876 | - * Set the price of the item. |
|
877 | - * |
|
878 | - * @since 1.0.19 |
|
879 | - * @param float $value New price. |
|
880 | - */ |
|
881 | - public function set_price( $value ) { |
|
865 | + /** |
|
866 | + * Alias of self::set_author(). |
|
867 | + * |
|
868 | + * @since 1.0.19 |
|
869 | + * @param int $value New author. |
|
870 | + */ |
|
871 | + public function set_owner( $value ) { |
|
872 | + $this->set_author( $value ); |
|
873 | + } |
|
874 | + |
|
875 | + /** |
|
876 | + * Set the price of the item. |
|
877 | + * |
|
878 | + * @since 1.0.19 |
|
879 | + * @param float $value New price. |
|
880 | + */ |
|
881 | + public function set_price( $value ) { |
|
882 | 882 | $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) ); |
883 | 883 | } |
884 | 884 | |
885 | 885 | /** |
886 | - * Set the VAT rule of the item. |
|
887 | - * |
|
888 | - * @since 1.0.19 |
|
889 | - * @param string $value new rule. |
|
890 | - */ |
|
891 | - public function set_vat_rule( $value ) { |
|
886 | + * Set the VAT rule of the item. |
|
887 | + * |
|
888 | + * @since 1.0.19 |
|
889 | + * @param string $value new rule. |
|
890 | + */ |
|
891 | + public function set_vat_rule( $value ) { |
|
892 | 892 | $this->set_prop( 'vat_rule', $value ); |
893 | 893 | } |
894 | 894 | |
895 | 895 | /** |
896 | - * Set the VAT class of the item. |
|
897 | - * |
|
898 | - * @since 1.0.19 |
|
899 | - * @param string $value new class. |
|
900 | - */ |
|
901 | - public function set_vat_class( $value ) { |
|
896 | + * Set the VAT class of the item. |
|
897 | + * |
|
898 | + * @since 1.0.19 |
|
899 | + * @param string $value new class. |
|
900 | + */ |
|
901 | + public function set_vat_class( $value ) { |
|
902 | 902 | $this->set_prop( 'vat_class', $value ); |
903 | 903 | } |
904 | 904 | |
905 | 905 | /** |
906 | - * Set the type of the item. |
|
907 | - * |
|
908 | - * @since 1.0.19 |
|
909 | - * @param string $value new item type. |
|
910 | - * @return string |
|
911 | - */ |
|
912 | - public function set_type( $value ) { |
|
906 | + * Set the type of the item. |
|
907 | + * |
|
908 | + * @since 1.0.19 |
|
909 | + * @param string $value new item type. |
|
910 | + * @return string |
|
911 | + */ |
|
912 | + public function set_type( $value ) { |
|
913 | 913 | |
914 | 914 | if ( empty( $value ) ) { |
915 | 915 | $value = 'custom'; |
@@ -919,132 +919,132 @@ discard block |
||
919 | 919 | } |
920 | 920 | |
921 | 921 | /** |
922 | - * Set the custom id of the item. |
|
923 | - * |
|
924 | - * @since 1.0.19 |
|
925 | - * @param string $value new custom id. |
|
926 | - */ |
|
927 | - public function set_custom_id( $value ) { |
|
922 | + * Set the custom id of the item. |
|
923 | + * |
|
924 | + * @since 1.0.19 |
|
925 | + * @param string $value new custom id. |
|
926 | + */ |
|
927 | + public function set_custom_id( $value ) { |
|
928 | 928 | $this->set_prop( 'custom_id', $value ); |
929 | 929 | } |
930 | 930 | |
931 | 931 | /** |
932 | - * Set the custom name of the item. |
|
933 | - * |
|
934 | - * @since 1.0.19 |
|
935 | - * @param string $value new custom name. |
|
936 | - */ |
|
937 | - public function set_custom_name( $value ) { |
|
932 | + * Set the custom name of the item. |
|
933 | + * |
|
934 | + * @since 1.0.19 |
|
935 | + * @param string $value new custom name. |
|
936 | + */ |
|
937 | + public function set_custom_name( $value ) { |
|
938 | 938 | $this->set_prop( 'custom_name', $value ); |
939 | 939 | } |
940 | 940 | |
941 | 941 | /** |
942 | - * Set the custom singular name of the item. |
|
943 | - * |
|
944 | - * @since 1.0.19 |
|
945 | - * @param string $value new custom singular name. |
|
946 | - */ |
|
947 | - public function set_custom_singular_name( $value ) { |
|
942 | + * Set the custom singular name of the item. |
|
943 | + * |
|
944 | + * @since 1.0.19 |
|
945 | + * @param string $value new custom singular name. |
|
946 | + */ |
|
947 | + public function set_custom_singular_name( $value ) { |
|
948 | 948 | $this->set_prop( 'custom_singular_name', $value ); |
949 | 949 | } |
950 | 950 | |
951 | 951 | /** |
952 | - * Sets if an item is editable.. |
|
953 | - * |
|
954 | - * @since 1.0.19 |
|
955 | - * @param int|bool $value whether or not the item is editable. |
|
956 | - */ |
|
957 | - public function set_is_editable( $value ) { |
|
958 | - $this->set_prop( 'is_editable', (int) $value ); |
|
952 | + * Sets if an item is editable.. |
|
953 | + * |
|
954 | + * @since 1.0.19 |
|
955 | + * @param int|bool $value whether or not the item is editable. |
|
956 | + */ |
|
957 | + public function set_is_editable( $value ) { |
|
958 | + $this->set_prop( 'is_editable', (int) $value ); |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | /** |
962 | - * Sets if dynamic pricing is enabled. |
|
963 | - * |
|
964 | - * @since 1.0.19 |
|
965 | - * @param int|bool $value whether or not dynamic pricing is allowed. |
|
966 | - */ |
|
967 | - public function set_is_dynamic_pricing( $value ) { |
|
962 | + * Sets if dynamic pricing is enabled. |
|
963 | + * |
|
964 | + * @since 1.0.19 |
|
965 | + * @param int|bool $value whether or not dynamic pricing is allowed. |
|
966 | + */ |
|
967 | + public function set_is_dynamic_pricing( $value ) { |
|
968 | 968 | $this->set_prop( 'is_dynamic_pricing', (int) $value ); |
969 | 969 | } |
970 | 970 | |
971 | 971 | /** |
972 | - * Sets the minimum price if dynamic pricing is enabled. |
|
973 | - * |
|
974 | - * @since 1.0.19 |
|
975 | - * @param float $value minimum price. |
|
976 | - */ |
|
977 | - public function set_minimum_price( $value ) { |
|
972 | + * Sets the minimum price if dynamic pricing is enabled. |
|
973 | + * |
|
974 | + * @since 1.0.19 |
|
975 | + * @param float $value minimum price. |
|
976 | + */ |
|
977 | + public function set_minimum_price( $value ) { |
|
978 | 978 | $this->set_prop( 'minimum_price', (float) wpinv_sanitize_amount( $value ) ); |
979 | 979 | } |
980 | 980 | |
981 | 981 | /** |
982 | - * Sets if this is a recurring item. |
|
983 | - * |
|
984 | - * @since 1.0.19 |
|
985 | - * @param int|bool $value whether or not dynamic pricing is allowed. |
|
986 | - */ |
|
987 | - public function set_is_recurring( $value ) { |
|
982 | + * Sets if this is a recurring item. |
|
983 | + * |
|
984 | + * @since 1.0.19 |
|
985 | + * @param int|bool $value whether or not dynamic pricing is allowed. |
|
986 | + */ |
|
987 | + public function set_is_recurring( $value ) { |
|
988 | 988 | $this->set_prop( 'is_recurring', (int) $value ); |
989 | 989 | } |
990 | 990 | |
991 | 991 | /** |
992 | - * Set the recurring period. |
|
993 | - * |
|
994 | - * @since 1.0.19 |
|
995 | - * @param string $value new period. |
|
996 | - */ |
|
997 | - public function set_recurring_period( $value ) { |
|
992 | + * Set the recurring period. |
|
993 | + * |
|
994 | + * @since 1.0.19 |
|
995 | + * @param string $value new period. |
|
996 | + */ |
|
997 | + public function set_recurring_period( $value ) { |
|
998 | 998 | $this->set_prop( 'recurring_period', $value ); |
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | /** |
1002 | - * Set the recurring interval. |
|
1003 | - * |
|
1004 | - * @since 1.0.19 |
|
1005 | - * @param int $value recurring interval. |
|
1006 | - */ |
|
1007 | - public function set_recurring_interval( $value ) { |
|
1002 | + * Set the recurring interval. |
|
1003 | + * |
|
1004 | + * @since 1.0.19 |
|
1005 | + * @param int $value recurring interval. |
|
1006 | + */ |
|
1007 | + public function set_recurring_interval( $value ) { |
|
1008 | 1008 | return $this->set_prop( 'recurring_interval', (int) $value ); |
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | /** |
1012 | - * Get the recurring limit. |
|
1013 | - * @since 1.0.19 |
|
1014 | - * @param int $value The recurring limit. |
|
1015 | - * @return int |
|
1016 | - */ |
|
1017 | - public function set_recurring_limit( $value ) { |
|
1012 | + * Get the recurring limit. |
|
1013 | + * @since 1.0.19 |
|
1014 | + * @param int $value The recurring limit. |
|
1015 | + * @return int |
|
1016 | + */ |
|
1017 | + public function set_recurring_limit( $value ) { |
|
1018 | 1018 | $this->set_prop( 'recurring_limit', (int) $value ); |
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | /** |
1022 | - * Checks if we have a free trial. |
|
1023 | - * |
|
1024 | - * @since 1.0.19 |
|
1025 | - * @param int|bool $value whether or not it has a free trial. |
|
1026 | - */ |
|
1027 | - public function set_is_free_trial( $value ) { |
|
1022 | + * Checks if we have a free trial. |
|
1023 | + * |
|
1024 | + * @since 1.0.19 |
|
1025 | + * @param int|bool $value whether or not it has a free trial. |
|
1026 | + */ |
|
1027 | + public function set_is_free_trial( $value ) { |
|
1028 | 1028 | $this->set_prop( 'is_free_trial', (int) $value ); |
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | /** |
1032 | - * Set the trial period. |
|
1033 | - * |
|
1034 | - * @since 1.0.19 |
|
1035 | - * @param string $value trial period. |
|
1036 | - */ |
|
1037 | - public function set_trial_period( $value ) { |
|
1032 | + * Set the trial period. |
|
1033 | + * |
|
1034 | + * @since 1.0.19 |
|
1035 | + * @param string $value trial period. |
|
1036 | + */ |
|
1037 | + public function set_trial_period( $value ) { |
|
1038 | 1038 | $this->set_prop( 'trial_period', $value ); |
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | /** |
1042 | - * Set the trial interval. |
|
1043 | - * |
|
1044 | - * @since 1.0.19 |
|
1045 | - * @param int $value trial interval. |
|
1046 | - */ |
|
1047 | - public function set_trial_interval( $value ) { |
|
1042 | + * Set the trial interval. |
|
1043 | + * |
|
1044 | + * @since 1.0.19 |
|
1045 | + * @param int $value trial interval. |
|
1046 | + */ |
|
1047 | + public function set_trial_interval( $value ) { |
|
1048 | 1048 | $this->set_prop( 'trial_interval', $value ); |
1049 | 1049 | } |
1050 | 1050 | |
@@ -1052,17 +1052,17 @@ discard block |
||
1052 | 1052 | * Create an item. For backwards compatibilty. |
1053 | 1053 | * |
1054 | 1054 | * @deprecated |
1055 | - * @return int item id |
|
1055 | + * @return int item id |
|
1056 | 1056 | */ |
1057 | 1057 | public function create( $data = array() ) { |
1058 | 1058 | |
1059 | - // Set the properties. |
|
1060 | - if ( is_array( $data ) ) { |
|
1061 | - $this->set_props( $data ); |
|
1062 | - } |
|
1059 | + // Set the properties. |
|
1060 | + if ( is_array( $data ) ) { |
|
1061 | + $this->set_props( $data ); |
|
1062 | + } |
|
1063 | 1063 | |
1064 | - // Save the item. |
|
1065 | - return $this->save(); |
|
1064 | + // Save the item. |
|
1065 | + return $this->save(); |
|
1066 | 1066 | |
1067 | 1067 | } |
1068 | 1068 | |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | * Updates an item. For backwards compatibilty. |
1071 | 1071 | * |
1072 | 1072 | * @deprecated |
1073 | - * @return int item id |
|
1073 | + * @return int item id |
|
1074 | 1074 | */ |
1075 | 1075 | public function update( $data = array() ) { |
1076 | 1076 | return $this->create( $data ); |
@@ -1086,93 +1086,93 @@ discard block |
||
1086 | 1086 | */ |
1087 | 1087 | |
1088 | 1088 | /** |
1089 | - * Checks whether the item has enabled dynamic pricing. |
|
1090 | - * |
|
1091 | - * @since 1.0.19 |
|
1092 | - * @return bool |
|
1093 | - */ |
|
1094 | - public function user_can_set_their_price() { |
|
1089 | + * Checks whether the item has enabled dynamic pricing. |
|
1090 | + * |
|
1091 | + * @since 1.0.19 |
|
1092 | + * @return bool |
|
1093 | + */ |
|
1094 | + public function user_can_set_their_price() { |
|
1095 | 1095 | return (bool) $this->get_is_dynamic_pricing(); |
1096 | - } |
|
1096 | + } |
|
1097 | 1097 | |
1098 | - /** |
|
1099 | - * Checks whether the item is recurring. |
|
1100 | - * |
|
1101 | - * @since 1.0.19 |
|
1102 | - * @return bool |
|
1103 | - */ |
|
1104 | - public function is_recurring() { |
|
1098 | + /** |
|
1099 | + * Checks whether the item is recurring. |
|
1100 | + * |
|
1101 | + * @since 1.0.19 |
|
1102 | + * @return bool |
|
1103 | + */ |
|
1104 | + public function is_recurring() { |
|
1105 | 1105 | return (bool) $this->get_is_recurring(); |
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | /** |
1109 | - * Checks whether the item has a free trial. |
|
1110 | - * |
|
1111 | - * @since 1.0.19 |
|
1112 | - * @return bool |
|
1113 | - */ |
|
1109 | + * Checks whether the item has a free trial. |
|
1110 | + * |
|
1111 | + * @since 1.0.19 |
|
1112 | + * @return bool |
|
1113 | + */ |
|
1114 | 1114 | public function has_free_trial() { |
1115 | 1115 | $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false; |
1116 | 1116 | return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this ); |
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | /** |
1120 | - * Checks whether the item is free. |
|
1121 | - * |
|
1122 | - * @since 1.0.19 |
|
1123 | - * @return bool |
|
1124 | - */ |
|
1120 | + * Checks whether the item is free. |
|
1121 | + * |
|
1122 | + * @since 1.0.19 |
|
1123 | + * @return bool |
|
1124 | + */ |
|
1125 | 1125 | public function is_free() { |
1126 | 1126 | $is_free = $this->get_price() == 0; |
1127 | 1127 | return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this ); |
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | /** |
1131 | - * Checks the item status against a passed in status. |
|
1132 | - * |
|
1133 | - * @param array|string $status Status to check. |
|
1134 | - * @return bool |
|
1135 | - */ |
|
1136 | - public function has_status( $status ) { |
|
1137 | - $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status; |
|
1138 | - return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status ); |
|
1131 | + * Checks the item status against a passed in status. |
|
1132 | + * |
|
1133 | + * @param array|string $status Status to check. |
|
1134 | + * @return bool |
|
1135 | + */ |
|
1136 | + public function has_status( $status ) { |
|
1137 | + $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status; |
|
1138 | + return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status ); |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | /** |
1142 | - * Checks the item type against a passed in types. |
|
1143 | - * |
|
1144 | - * @param array|string $type Type to check. |
|
1145 | - * @return bool |
|
1146 | - */ |
|
1147 | - public function is_type( $type ) { |
|
1148 | - $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type; |
|
1149 | - return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type ); |
|
1150 | - } |
|
1142 | + * Checks the item type against a passed in types. |
|
1143 | + * |
|
1144 | + * @param array|string $type Type to check. |
|
1145 | + * @return bool |
|
1146 | + */ |
|
1147 | + public function is_type( $type ) { |
|
1148 | + $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type; |
|
1149 | + return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type ); |
|
1150 | + } |
|
1151 | 1151 | |
1152 | 1152 | /** |
1153 | - * Checks whether the item is editable. |
|
1154 | - * |
|
1155 | - * @since 1.0.19 |
|
1156 | - * @return bool |
|
1157 | - */ |
|
1153 | + * Checks whether the item is editable. |
|
1154 | + * |
|
1155 | + * @since 1.0.19 |
|
1156 | + * @return bool |
|
1157 | + */ |
|
1158 | 1158 | public function is_editable() { |
1159 | 1159 | $is_editable = $this->get_is_editable(); |
1160 | 1160 | return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this ); |
1161 | - } |
|
1161 | + } |
|
1162 | 1162 | |
1163 | - /** |
|
1164 | - * Returns an array of cart fees. |
|
1165 | - */ |
|
1166 | - public function get_fees() { |
|
1163 | + /** |
|
1164 | + * Returns an array of cart fees. |
|
1165 | + */ |
|
1166 | + public function get_fees() { |
|
1167 | 1167 | return array(); |
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | /** |
1171 | - * Checks whether the item is purchasable. |
|
1172 | - * |
|
1173 | - * @since 1.0.19 |
|
1174 | - * @return bool |
|
1175 | - */ |
|
1171 | + * Checks whether the item is purchasable. |
|
1172 | + * |
|
1173 | + * @since 1.0.19 |
|
1174 | + * @return bool |
|
1175 | + */ |
|
1176 | 1176 | public function can_purchase() { |
1177 | 1177 | $can_purchase = $this->exists(); |
1178 | 1178 | |
@@ -1184,11 +1184,11 @@ discard block |
||
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | /** |
1187 | - * Checks whether the item supports dynamic pricing. |
|
1188 | - * |
|
1189 | - * @since 1.0.19 |
|
1190 | - * @return bool |
|
1191 | - */ |
|
1187 | + * Checks whether the item supports dynamic pricing. |
|
1188 | + * |
|
1189 | + * @since 1.0.19 |
|
1190 | + * @return bool |
|
1191 | + */ |
|
1192 | 1192 | public function supports_dynamic_pricing() { |
1193 | 1193 | return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this ); |
1194 | 1194 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -78,30 +78,30 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @param int|object|WPInv_Item|WP_Post $item Item to read. |
80 | 80 | */ |
81 | - public function __construct( $item = 0 ) { |
|
82 | - parent::__construct( $item ); |
|
83 | - |
|
84 | - if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) { |
|
85 | - $this->set_id( $item ); |
|
86 | - } elseif ( $item instanceof self ) { |
|
87 | - $this->set_id( $item->get_id() ); |
|
88 | - } elseif ( ! empty( $item->ID ) ) { |
|
89 | - $this->set_id( $item->ID ); |
|
90 | - } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) { |
|
91 | - $this->set_id( $item_id ); |
|
92 | - } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) { |
|
93 | - $this->set_id( $item_id ); |
|
81 | + public function __construct($item = 0) { |
|
82 | + parent::__construct($item); |
|
83 | + |
|
84 | + if (!empty($item) && is_numeric($item) && 'wpi_item' == get_post_type($item)) { |
|
85 | + $this->set_id($item); |
|
86 | + } elseif ($item instanceof self) { |
|
87 | + $this->set_id($item->get_id()); |
|
88 | + } elseif (!empty($item->ID)) { |
|
89 | + $this->set_id($item->ID); |
|
90 | + } elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'custom_id')) { |
|
91 | + $this->set_id($item_id); |
|
92 | + } elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'name')) { |
|
93 | + $this->set_id($item_id); |
|
94 | 94 | } else { |
95 | - $this->set_object_read( true ); |
|
95 | + $this->set_object_read(true); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // Load the datastore. |
99 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
99 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
100 | 100 | |
101 | - if ( $this->get_id() > 0 ) { |
|
102 | - $this->post = get_post( $this->get_id() ); |
|
101 | + if ($this->get_id() > 0) { |
|
102 | + $this->post = get_post($this->get_id()); |
|
103 | 103 | $this->ID = $this->get_id(); |
104 | - $this->data_store->read( $this ); |
|
104 | + $this->data_store->read($this); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | } |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * @param string $context View or edit context. |
129 | 129 | * @return int |
130 | 130 | */ |
131 | - public function get_parent_id( $context = 'view' ) { |
|
132 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
131 | + public function get_parent_id($context = 'view') { |
|
132 | + return (int) $this->get_prop('parent_id', $context); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $context View or edit context. |
140 | 140 | * @return string |
141 | 141 | */ |
142 | - public function get_status( $context = 'view' ) { |
|
143 | - return $this->get_prop( 'status', $context ); |
|
142 | + public function get_status($context = 'view') { |
|
143 | + return $this->get_prop('status', $context); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * @param string $context View or edit context. |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public function get_version( $context = 'view' ) { |
|
154 | - return $this->get_prop( 'version', $context ); |
|
153 | + public function get_version($context = 'view') { |
|
154 | + return $this->get_prop('version', $context); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * @param string $context View or edit context. |
162 | 162 | * @return string |
163 | 163 | */ |
164 | - public function get_date_created( $context = 'view' ) { |
|
165 | - return $this->get_prop( 'date_created', $context ); |
|
164 | + public function get_date_created($context = 'view') { |
|
165 | + return $this->get_prop('date_created', $context); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | * @param string $context View or edit context. |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - public function get_date_created_gmt( $context = 'view' ) { |
|
176 | - $date = $this->get_date_created( $context ); |
|
175 | + public function get_date_created_gmt($context = 'view') { |
|
176 | + $date = $this->get_date_created($context); |
|
177 | 177 | |
178 | - if ( $date ) { |
|
179 | - $date = get_gmt_from_date( $date ); |
|
178 | + if ($date) { |
|
179 | + $date = get_gmt_from_date($date); |
|
180 | 180 | } |
181 | 181 | return $date; |
182 | 182 | } |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | * @param string $context View or edit context. |
189 | 189 | * @return string |
190 | 190 | */ |
191 | - public function get_date_modified( $context = 'view' ) { |
|
192 | - return $this->get_prop( 'date_modified', $context ); |
|
191 | + public function get_date_modified($context = 'view') { |
|
192 | + return $this->get_prop('date_modified', $context); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @param string $context View or edit context. |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
203 | - $date = $this->get_date_modified( $context ); |
|
202 | + public function get_date_modified_gmt($context = 'view') { |
|
203 | + $date = $this->get_date_modified($context); |
|
204 | 204 | |
205 | - if ( $date ) { |
|
206 | - $date = get_gmt_from_date( $date ); |
|
205 | + if ($date) { |
|
206 | + $date = get_gmt_from_date($date); |
|
207 | 207 | } |
208 | 208 | return $date; |
209 | 209 | } |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | * @param string $context View or edit context. |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public function get_name( $context = 'view' ) { |
|
219 | - return $this->get_prop( 'name', $context ); |
|
218 | + public function get_name($context = 'view') { |
|
219 | + return $this->get_prop('name', $context); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | * @param string $context View or edit context. |
227 | 227 | * @return string |
228 | 228 | */ |
229 | - public function get_title( $context = 'view' ) { |
|
230 | - return $this->get_name( $context ); |
|
229 | + public function get_title($context = 'view') { |
|
230 | + return $this->get_name($context); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | * @param string $context View or edit context. |
238 | 238 | * @return string |
239 | 239 | */ |
240 | - public function get_description( $context = 'view' ) { |
|
241 | - return $this->get_prop( 'description', $context ); |
|
240 | + public function get_description($context = 'view') { |
|
241 | + return $this->get_prop('description', $context); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | * @param string $context View or edit context. |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function get_excerpt( $context = 'view' ) { |
|
252 | - return $this->get_description( $context ); |
|
251 | + public function get_excerpt($context = 'view') { |
|
252 | + return $this->get_description($context); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -259,8 +259,8 @@ discard block |
||
259 | 259 | * @param string $context View or edit context. |
260 | 260 | * @return string |
261 | 261 | */ |
262 | - public function get_summary( $context = 'view' ) { |
|
263 | - return $this->get_description( $context ); |
|
262 | + public function get_summary($context = 'view') { |
|
263 | + return $this->get_description($context); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | * @param string $context View or edit context. |
271 | 271 | * @return int |
272 | 272 | */ |
273 | - public function get_author( $context = 'view' ) { |
|
274 | - return (int) $this->get_prop( 'author', $context ); |
|
273 | + public function get_author($context = 'view') { |
|
274 | + return (int) $this->get_prop('author', $context); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * @param string $context View or edit context. |
282 | 282 | * @return int |
283 | 283 | */ |
284 | - public function get_owner( $context = 'view' ) { |
|
285 | - return $this->get_author( $context ); |
|
284 | + public function get_owner($context = 'view') { |
|
285 | + return $this->get_author($context); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | * @param string $context View or edit context. |
293 | 293 | * @return float |
294 | 294 | */ |
295 | - public function get_price( $context = 'view' ) { |
|
296 | - return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) ); |
|
295 | + public function get_price($context = 'view') { |
|
296 | + return wpinv_sanitize_amount($this->get_prop('price', $context)); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -303,15 +303,15 @@ discard block |
||
303 | 303 | * @param string $context View or edit context. |
304 | 304 | * @return float |
305 | 305 | */ |
306 | - public function get_initial_price( $context = 'view' ) { |
|
306 | + public function get_initial_price($context = 'view') { |
|
307 | 307 | |
308 | - $price = (float) $this->get_price( $context ); |
|
308 | + $price = (float) $this->get_price($context); |
|
309 | 309 | |
310 | - if ( $this->has_free_trial() ) { |
|
310 | + if ($this->has_free_trial()) { |
|
311 | 311 | $price = 0; |
312 | 312 | } |
313 | 313 | |
314 | - return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) ); |
|
314 | + return wpinv_sanitize_amount(apply_filters('wpinv_get_initial_item_price', $price, $this)); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @return string |
323 | 323 | */ |
324 | 324 | public function get_the_price() { |
325 | - return wpinv_price( $this->get_price() ); |
|
325 | + return wpinv_price($this->get_price()); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @return string |
334 | 334 | */ |
335 | 335 | public function get_the_initial_price() { |
336 | - return wpinv_price( $this->get_initial_price() ); |
|
336 | + return wpinv_price($this->get_initial_price()); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | * @param string $context View or edit context. |
344 | 344 | * @return string |
345 | 345 | */ |
346 | - public function get_vat_rule( $context = 'view' ) { |
|
347 | - return $this->get_prop( 'vat_rule', $context ); |
|
346 | + public function get_vat_rule($context = 'view') { |
|
347 | + return $this->get_prop('vat_rule', $context); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | * @param string $context View or edit context. |
355 | 355 | * @return string |
356 | 356 | */ |
357 | - public function get_vat_class( $context = 'view' ) { |
|
358 | - return $this->get_prop( 'vat_class', $context ); |
|
357 | + public function get_vat_class($context = 'view') { |
|
358 | + return $this->get_prop('vat_class', $context); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @param string $context View or edit context. |
366 | 366 | * @return string |
367 | 367 | */ |
368 | - public function get_type( $context = 'view' ) { |
|
369 | - return $this->get_prop( 'type', $context ); |
|
368 | + public function get_type($context = 'view') { |
|
369 | + return $this->get_prop('type', $context); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | * @param string $context View or edit context. |
377 | 377 | * @return string |
378 | 378 | */ |
379 | - public function get_custom_id( $context = 'view' ) { |
|
380 | - return $this->get_prop( 'custom_id', $context ); |
|
379 | + public function get_custom_id($context = 'view') { |
|
380 | + return $this->get_prop('custom_id', $context); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -387,8 +387,8 @@ discard block |
||
387 | 387 | * @param string $context View or edit context. |
388 | 388 | * @return string |
389 | 389 | */ |
390 | - public function get_custom_name( $context = 'view' ) { |
|
391 | - return $this->get_prop( 'custom_name', $context ); |
|
390 | + public function get_custom_name($context = 'view') { |
|
391 | + return $this->get_prop('custom_name', $context); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -398,8 +398,8 @@ discard block |
||
398 | 398 | * @param string $context View or edit context. |
399 | 399 | * @return string |
400 | 400 | */ |
401 | - public function get_custom_singular_name( $context = 'view' ) { |
|
402 | - return $this->get_prop( 'custom_singular_name', $context ); |
|
401 | + public function get_custom_singular_name($context = 'view') { |
|
402 | + return $this->get_prop('custom_singular_name', $context); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -409,8 +409,8 @@ discard block |
||
409 | 409 | * @param string $context View or edit context. |
410 | 410 | * @return int |
411 | 411 | */ |
412 | - public function get_is_editable( $context = 'view' ) { |
|
413 | - return (int) $this->get_prop( 'is_editable', $context ); |
|
412 | + public function get_is_editable($context = 'view') { |
|
413 | + return (int) $this->get_prop('is_editable', $context); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -420,8 +420,8 @@ discard block |
||
420 | 420 | * @param string $context View or edit context. |
421 | 421 | * @return int |
422 | 422 | */ |
423 | - public function get_editable( $context = 'view' ) { |
|
424 | - return $this->get_is_editable( $context ); |
|
423 | + public function get_editable($context = 'view') { |
|
424 | + return $this->get_is_editable($context); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | * @param string $context View or edit context. |
432 | 432 | * @return int |
433 | 433 | */ |
434 | - public function get_is_dynamic_pricing( $context = 'view' ) { |
|
435 | - return (int) $this->get_prop( 'is_dynamic_pricing', $context ); |
|
434 | + public function get_is_dynamic_pricing($context = 'view') { |
|
435 | + return (int) $this->get_prop('is_dynamic_pricing', $context); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | * @param string $context View or edit context. |
443 | 443 | * @return float |
444 | 444 | */ |
445 | - public function get_minimum_price( $context = 'view' ) { |
|
446 | - return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) ); |
|
445 | + public function get_minimum_price($context = 'view') { |
|
446 | + return wpinv_sanitize_amount($this->get_prop('minimum_price', $context)); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | * @param string $context View or edit context. |
454 | 454 | * @return int |
455 | 455 | */ |
456 | - public function get_is_recurring( $context = 'view' ) { |
|
457 | - return (int) $this->get_prop( 'is_recurring', $context ); |
|
456 | + public function get_is_recurring($context = 'view') { |
|
457 | + return (int) $this->get_prop('is_recurring', $context); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | * @param string $context View or edit context. |
465 | 465 | * @return float |
466 | 466 | */ |
467 | - public function get_recurring_price( $context = 'view' ) { |
|
468 | - $price = $this->get_price( $context ); |
|
469 | - return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) ); |
|
467 | + public function get_recurring_price($context = 'view') { |
|
468 | + $price = $this->get_price($context); |
|
469 | + return wpinv_sanitize_amount(apply_filters('wpinv_get_recurring_item_price', $price, $this->ID)); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | /** |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @return string |
478 | 478 | */ |
479 | 479 | public function get_the_recurring_price() { |
480 | - return wpinv_price( $this->get_recurring_price() ); |
|
480 | + return wpinv_price($this->get_recurring_price()); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -498,15 +498,15 @@ discard block |
||
498 | 498 | $period = $this->get_recurring_period(); |
499 | 499 | $interval = $this->get_recurring_interval(); |
500 | 500 | |
501 | - if ( $this->has_free_trial() ) { |
|
501 | + if ($this->has_free_trial()) { |
|
502 | 502 | $period = $this->get_trial_period(); |
503 | 503 | $interval = $this->get_trial_interval(); |
504 | 504 | } |
505 | 505 | |
506 | - $period = $periods[ $period ]; |
|
507 | - $interval = empty( $interval ) ? 1 : $interval; |
|
508 | - $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) ); |
|
509 | - return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this ); |
|
506 | + $period = $periods[$period]; |
|
507 | + $interval = empty($interval) ? 1 : $interval; |
|
508 | + $next_renewal = strtotime("+$interval $period", current_time('timestamp')); |
|
509 | + return apply_filters('wpinv_get_first_renewal_date', $next_renewal, $this); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -516,14 +516,14 @@ discard block |
||
516 | 516 | * @param bool $full Return abbreviation or in full. |
517 | 517 | * @return string |
518 | 518 | */ |
519 | - public function get_recurring_period( $full = false ) { |
|
520 | - $period = $this->get_prop( 'recurring_period', 'view' ); |
|
519 | + public function get_recurring_period($full = false) { |
|
520 | + $period = $this->get_prop('recurring_period', 'view'); |
|
521 | 521 | |
522 | - if ( $full && ! is_bool( $full ) ) { |
|
522 | + if ($full && !is_bool($full)) { |
|
523 | 523 | $full = false; |
524 | 524 | } |
525 | 525 | |
526 | - return getpaid_sanitize_recurring_period( $period, $full ); |
|
526 | + return getpaid_sanitize_recurring_period($period, $full); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
@@ -533,10 +533,10 @@ discard block |
||
533 | 533 | * @param string $context View or edit context. |
534 | 534 | * @return int |
535 | 535 | */ |
536 | - public function get_recurring_interval( $context = 'view' ) { |
|
537 | - $interval = absint( $this->get_prop( 'recurring_interval', $context ) ); |
|
536 | + public function get_recurring_interval($context = 'view') { |
|
537 | + $interval = absint($this->get_prop('recurring_interval', $context)); |
|
538 | 538 | |
539 | - if ( $interval < 1 ) { |
|
539 | + if ($interval < 1) { |
|
540 | 540 | $interval = 1; |
541 | 541 | } |
542 | 542 | |
@@ -550,8 +550,8 @@ discard block |
||
550 | 550 | * @param string $context View or edit context. |
551 | 551 | * @return int |
552 | 552 | */ |
553 | - public function get_recurring_limit( $context = 'view' ) { |
|
554 | - return (int) $this->get_prop( 'recurring_limit', $context ); |
|
553 | + public function get_recurring_limit($context = 'view') { |
|
554 | + return (int) $this->get_prop('recurring_limit', $context); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -561,8 +561,8 @@ discard block |
||
561 | 561 | * @param string $context View or edit context. |
562 | 562 | * @return int |
563 | 563 | */ |
564 | - public function get_is_free_trial( $context = 'view' ) { |
|
565 | - return (int) $this->get_prop( 'is_free_trial', $context ); |
|
564 | + public function get_is_free_trial($context = 'view') { |
|
565 | + return (int) $this->get_prop('is_free_trial', $context); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | /** |
@@ -572,8 +572,8 @@ discard block |
||
572 | 572 | * @param string $context View or edit context. |
573 | 573 | * @return int |
574 | 574 | */ |
575 | - public function get_free_trial( $context = 'view' ) { |
|
576 | - return $this->get_is_free_trial( $context ); |
|
575 | + public function get_free_trial($context = 'view') { |
|
576 | + return $this->get_is_free_trial($context); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | /** |
@@ -583,14 +583,14 @@ discard block |
||
583 | 583 | * @param bool $full Return abbreviation or in full. |
584 | 584 | * @return string |
585 | 585 | */ |
586 | - public function get_trial_period( $full = false ) { |
|
587 | - $period = $this->get_prop( 'trial_period', 'view' ); |
|
586 | + public function get_trial_period($full = false) { |
|
587 | + $period = $this->get_prop('trial_period', 'view'); |
|
588 | 588 | |
589 | - if ( $full && ! is_bool( $full ) ) { |
|
589 | + if ($full && !is_bool($full)) { |
|
590 | 590 | $full = false; |
591 | 591 | } |
592 | 592 | |
593 | - return getpaid_sanitize_recurring_period( $period, $full ); |
|
593 | + return getpaid_sanitize_recurring_period($period, $full); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | /** |
@@ -600,8 +600,8 @@ discard block |
||
600 | 600 | * @param string $context View or edit context. |
601 | 601 | * @return int |
602 | 602 | */ |
603 | - public function get_trial_interval( $context = 'view' ) { |
|
604 | - return (int) $this->get_prop( 'trial_interval', $context ); |
|
603 | + public function get_trial_interval($context = 'view') { |
|
604 | + return (int) $this->get_prop('trial_interval', $context); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | * @return string |
612 | 612 | */ |
613 | 613 | public function get_edit_url() { |
614 | - return get_edit_post_link( $this->get_id() ); |
|
614 | + return get_edit_post_link($this->get_id()); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
@@ -625,35 +625,35 @@ discard block |
||
625 | 625 | * @since 1.0.15 |
626 | 626 | * @return int |
627 | 627 | */ |
628 | - public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) { |
|
628 | + public static function get_item_id_by_field($value, $field = 'custom_id', $type = '') { |
|
629 | 629 | |
630 | 630 | // Trim the value. |
631 | - $value = sanitize_text_field( $value ); |
|
632 | - if ( empty( $value ) ) { |
|
631 | + $value = sanitize_text_field($value); |
|
632 | + if (empty($value)) { |
|
633 | 633 | return 0; |
634 | 634 | } |
635 | 635 | |
636 | 636 | // Valid fields. |
637 | - $fields = array( 'custom_id', 'name', 'slug' ); |
|
637 | + $fields = array('custom_id', 'name', 'slug'); |
|
638 | 638 | |
639 | 639 | // Ensure a field has been passed. |
640 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
640 | + if (empty($field) || !in_array($field, $fields)) { |
|
641 | 641 | return 0; |
642 | 642 | } |
643 | 643 | |
644 | - if ( $field == 'name' ) { |
|
644 | + if ($field == 'name') { |
|
645 | 645 | $field = 'slug'; |
646 | 646 | } |
647 | 647 | |
648 | 648 | // Maybe retrieve from the cache. |
649 | - $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
650 | - if ( ! empty( $item_id ) ) { |
|
649 | + $item_id = wp_cache_get($value, "getpaid_{$type}_item_{$field}s_to_item_ids"); |
|
650 | + if (!empty($item_id)) { |
|
651 | 651 | return $item_id; |
652 | 652 | } |
653 | 653 | |
654 | 654 | // Fetch from the db. |
655 | 655 | $items = array(); |
656 | - if ( $field == 'slug' ) { |
|
656 | + if ($field == 'slug') { |
|
657 | 657 | $items = get_posts( |
658 | 658 | array( |
659 | 659 | 'post_type' => 'wpi_item', |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | ); |
665 | 665 | } |
666 | 666 | |
667 | - if ( $field =='custom_id' ) { |
|
667 | + if ($field == 'custom_id') { |
|
668 | 668 | $items = get_posts( |
669 | 669 | array( |
670 | 670 | 'post_type' => 'wpi_item', |
@@ -684,12 +684,12 @@ discard block |
||
684 | 684 | ); |
685 | 685 | } |
686 | 686 | |
687 | - if ( empty( $items ) ) { |
|
687 | + if (empty($items)) { |
|
688 | 688 | return 0; |
689 | 689 | } |
690 | 690 | |
691 | 691 | // Update the cache with our data |
692 | - wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" ); |
|
692 | + wp_cache_set($value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids"); |
|
693 | 693 | |
694 | 694 | return $items[0]->ID; |
695 | 695 | } |
@@ -697,19 +697,19 @@ discard block |
||
697 | 697 | /** |
698 | 698 | * Margic method for retrieving a property. |
699 | 699 | */ |
700 | - public function __get( $key ) { |
|
700 | + public function __get($key) { |
|
701 | 701 | |
702 | 702 | // Check if we have a helper method for that. |
703 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
704 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
703 | + if (method_exists($this, 'get_' . $key)) { |
|
704 | + return call_user_func(array($this, 'get_' . $key)); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | // Check if the key is in the associated $post object. |
708 | - if ( ! empty( $this->post ) && isset( $this->post->$key ) ) { |
|
708 | + if (!empty($this->post) && isset($this->post->$key)) { |
|
709 | 709 | return $this->post->$key; |
710 | 710 | } |
711 | 711 | |
712 | - return $this->get_prop( $key ); |
|
712 | + return $this->get_prop($key); |
|
713 | 713 | |
714 | 714 | } |
715 | 715 | |
@@ -728,11 +728,11 @@ discard block |
||
728 | 728 | * |
729 | 729 | * @since 1.0.19 |
730 | 730 | */ |
731 | - public function set_parent_id( $value ) { |
|
732 | - if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) { |
|
731 | + public function set_parent_id($value) { |
|
732 | + if ($value && ($value === $this->get_id() || !get_post($value))) { |
|
733 | 733 | return; |
734 | 734 | } |
735 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
735 | + $this->set_prop('parent_id', absint($value)); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | /** |
@@ -742,10 +742,10 @@ discard block |
||
742 | 742 | * @param string $status New status. |
743 | 743 | * @return array details of change. |
744 | 744 | */ |
745 | - public function set_status( $status ) { |
|
745 | + public function set_status($status) { |
|
746 | 746 | $old_status = $this->get_status(); |
747 | 747 | |
748 | - $this->set_prop( 'status', $status ); |
|
748 | + $this->set_prop('status', $status); |
|
749 | 749 | |
750 | 750 | return array( |
751 | 751 | 'from' => $old_status, |
@@ -758,8 +758,8 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @since 1.0.19 |
760 | 760 | */ |
761 | - public function set_version( $value ) { |
|
762 | - $this->set_prop( 'version', $value ); |
|
761 | + public function set_version($value) { |
|
762 | + $this->set_prop('version', $value); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -769,11 +769,11 @@ discard block |
||
769 | 769 | * @param string $value Value to set. |
770 | 770 | * @return bool Whether or not the date was set. |
771 | 771 | */ |
772 | - public function set_date_created( $value ) { |
|
773 | - $date = strtotime( $value ); |
|
772 | + public function set_date_created($value) { |
|
773 | + $date = strtotime($value); |
|
774 | 774 | |
775 | - if ( $date ) { |
|
776 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
775 | + if ($date) { |
|
776 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
777 | 777 | return true; |
778 | 778 | } |
779 | 779 | |
@@ -788,11 +788,11 @@ discard block |
||
788 | 788 | * @param string $value Value to set. |
789 | 789 | * @return bool Whether or not the date was set. |
790 | 790 | */ |
791 | - public function set_date_modified( $value ) { |
|
792 | - $date = strtotime( $value ); |
|
791 | + public function set_date_modified($value) { |
|
792 | + $date = strtotime($value); |
|
793 | 793 | |
794 | - if ( $date ) { |
|
795 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
794 | + if ($date) { |
|
795 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
796 | 796 | return true; |
797 | 797 | } |
798 | 798 | |
@@ -806,9 +806,9 @@ discard block |
||
806 | 806 | * @since 1.0.19 |
807 | 807 | * @param string $value New name. |
808 | 808 | */ |
809 | - public function set_name( $value ) { |
|
810 | - $name = sanitize_text_field( $value ); |
|
811 | - $this->set_prop( 'name', $name ); |
|
809 | + public function set_name($value) { |
|
810 | + $name = sanitize_text_field($value); |
|
811 | + $this->set_prop('name', $name); |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | /** |
@@ -817,8 +817,8 @@ discard block |
||
817 | 817 | * @since 1.0.19 |
818 | 818 | * @param string $value New name. |
819 | 819 | */ |
820 | - public function set_title( $value ) { |
|
821 | - $this->set_name( $value ); |
|
820 | + public function set_title($value) { |
|
821 | + $this->set_name($value); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | /** |
@@ -827,9 +827,9 @@ discard block |
||
827 | 827 | * @since 1.0.19 |
828 | 828 | * @param string $value New description. |
829 | 829 | */ |
830 | - public function set_description( $value ) { |
|
831 | - $description = wp_kses_post( $value ); |
|
832 | - return $this->set_prop( 'description', $description ); |
|
830 | + public function set_description($value) { |
|
831 | + $description = wp_kses_post($value); |
|
832 | + return $this->set_prop('description', $description); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | /** |
@@ -838,8 +838,8 @@ discard block |
||
838 | 838 | * @since 1.0.19 |
839 | 839 | * @param string $value New description. |
840 | 840 | */ |
841 | - public function set_excerpt( $value ) { |
|
842 | - $this->set_description( $value ); |
|
841 | + public function set_excerpt($value) { |
|
842 | + $this->set_description($value); |
|
843 | 843 | } |
844 | 844 | |
845 | 845 | /** |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | * @since 1.0.19 |
849 | 849 | * @param string $value New description. |
850 | 850 | */ |
851 | - public function set_summary( $value ) { |
|
852 | - $this->set_description( $value ); |
|
851 | + public function set_summary($value) { |
|
852 | + $this->set_description($value); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
@@ -858,8 +858,8 @@ discard block |
||
858 | 858 | * @since 1.0.19 |
859 | 859 | * @param int $value New author. |
860 | 860 | */ |
861 | - public function set_author( $value ) { |
|
862 | - $this->set_prop( 'author', (int) $value ); |
|
861 | + public function set_author($value) { |
|
862 | + $this->set_prop('author', (int) $value); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | /** |
@@ -868,8 +868,8 @@ discard block |
||
868 | 868 | * @since 1.0.19 |
869 | 869 | * @param int $value New author. |
870 | 870 | */ |
871 | - public function set_owner( $value ) { |
|
872 | - $this->set_author( $value ); |
|
871 | + public function set_owner($value) { |
|
872 | + $this->set_author($value); |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | /** |
@@ -878,8 +878,8 @@ discard block |
||
878 | 878 | * @since 1.0.19 |
879 | 879 | * @param float $value New price. |
880 | 880 | */ |
881 | - public function set_price( $value ) { |
|
882 | - $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) ); |
|
881 | + public function set_price($value) { |
|
882 | + $this->set_prop('price', (float) wpinv_sanitize_amount($value)); |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | /** |
@@ -888,8 +888,8 @@ discard block |
||
888 | 888 | * @since 1.0.19 |
889 | 889 | * @param string $value new rule. |
890 | 890 | */ |
891 | - public function set_vat_rule( $value ) { |
|
892 | - $this->set_prop( 'vat_rule', $value ); |
|
891 | + public function set_vat_rule($value) { |
|
892 | + $this->set_prop('vat_rule', $value); |
|
893 | 893 | } |
894 | 894 | |
895 | 895 | /** |
@@ -898,8 +898,8 @@ discard block |
||
898 | 898 | * @since 1.0.19 |
899 | 899 | * @param string $value new class. |
900 | 900 | */ |
901 | - public function set_vat_class( $value ) { |
|
902 | - $this->set_prop( 'vat_class', $value ); |
|
901 | + public function set_vat_class($value) { |
|
902 | + $this->set_prop('vat_class', $value); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | /** |
@@ -909,13 +909,13 @@ discard block |
||
909 | 909 | * @param string $value new item type. |
910 | 910 | * @return string |
911 | 911 | */ |
912 | - public function set_type( $value ) { |
|
912 | + public function set_type($value) { |
|
913 | 913 | |
914 | - if ( empty( $value ) ) { |
|
914 | + if (empty($value)) { |
|
915 | 915 | $value = 'custom'; |
916 | 916 | } |
917 | 917 | |
918 | - $this->set_prop( 'type', $value ); |
|
918 | + $this->set_prop('type', $value); |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | /** |
@@ -924,8 +924,8 @@ discard block |
||
924 | 924 | * @since 1.0.19 |
925 | 925 | * @param string $value new custom id. |
926 | 926 | */ |
927 | - public function set_custom_id( $value ) { |
|
928 | - $this->set_prop( 'custom_id', $value ); |
|
927 | + public function set_custom_id($value) { |
|
928 | + $this->set_prop('custom_id', $value); |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | /** |
@@ -934,8 +934,8 @@ discard block |
||
934 | 934 | * @since 1.0.19 |
935 | 935 | * @param string $value new custom name. |
936 | 936 | */ |
937 | - public function set_custom_name( $value ) { |
|
938 | - $this->set_prop( 'custom_name', $value ); |
|
937 | + public function set_custom_name($value) { |
|
938 | + $this->set_prop('custom_name', $value); |
|
939 | 939 | } |
940 | 940 | |
941 | 941 | /** |
@@ -944,8 +944,8 @@ discard block |
||
944 | 944 | * @since 1.0.19 |
945 | 945 | * @param string $value new custom singular name. |
946 | 946 | */ |
947 | - public function set_custom_singular_name( $value ) { |
|
948 | - $this->set_prop( 'custom_singular_name', $value ); |
|
947 | + public function set_custom_singular_name($value) { |
|
948 | + $this->set_prop('custom_singular_name', $value); |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | /** |
@@ -954,8 +954,8 @@ discard block |
||
954 | 954 | * @since 1.0.19 |
955 | 955 | * @param int|bool $value whether or not the item is editable. |
956 | 956 | */ |
957 | - public function set_is_editable( $value ) { |
|
958 | - $this->set_prop( 'is_editable', (int) $value ); |
|
957 | + public function set_is_editable($value) { |
|
958 | + $this->set_prop('is_editable', (int) $value); |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | /** |
@@ -964,8 +964,8 @@ discard block |
||
964 | 964 | * @since 1.0.19 |
965 | 965 | * @param int|bool $value whether or not dynamic pricing is allowed. |
966 | 966 | */ |
967 | - public function set_is_dynamic_pricing( $value ) { |
|
968 | - $this->set_prop( 'is_dynamic_pricing', (int) $value ); |
|
967 | + public function set_is_dynamic_pricing($value) { |
|
968 | + $this->set_prop('is_dynamic_pricing', (int) $value); |
|
969 | 969 | } |
970 | 970 | |
971 | 971 | /** |
@@ -974,8 +974,8 @@ discard block |
||
974 | 974 | * @since 1.0.19 |
975 | 975 | * @param float $value minimum price. |
976 | 976 | */ |
977 | - public function set_minimum_price( $value ) { |
|
978 | - $this->set_prop( 'minimum_price', (float) wpinv_sanitize_amount( $value ) ); |
|
977 | + public function set_minimum_price($value) { |
|
978 | + $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value)); |
|
979 | 979 | } |
980 | 980 | |
981 | 981 | /** |
@@ -984,8 +984,8 @@ discard block |
||
984 | 984 | * @since 1.0.19 |
985 | 985 | * @param int|bool $value whether or not dynamic pricing is allowed. |
986 | 986 | */ |
987 | - public function set_is_recurring( $value ) { |
|
988 | - $this->set_prop( 'is_recurring', (int) $value ); |
|
987 | + public function set_is_recurring($value) { |
|
988 | + $this->set_prop('is_recurring', (int) $value); |
|
989 | 989 | } |
990 | 990 | |
991 | 991 | /** |
@@ -994,8 +994,8 @@ discard block |
||
994 | 994 | * @since 1.0.19 |
995 | 995 | * @param string $value new period. |
996 | 996 | */ |
997 | - public function set_recurring_period( $value ) { |
|
998 | - $this->set_prop( 'recurring_period', $value ); |
|
997 | + public function set_recurring_period($value) { |
|
998 | + $this->set_prop('recurring_period', $value); |
|
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | /** |
@@ -1004,8 +1004,8 @@ discard block |
||
1004 | 1004 | * @since 1.0.19 |
1005 | 1005 | * @param int $value recurring interval. |
1006 | 1006 | */ |
1007 | - public function set_recurring_interval( $value ) { |
|
1008 | - return $this->set_prop( 'recurring_interval', (int) $value ); |
|
1007 | + public function set_recurring_interval($value) { |
|
1008 | + return $this->set_prop('recurring_interval', (int) $value); |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | /** |
@@ -1014,8 +1014,8 @@ discard block |
||
1014 | 1014 | * @param int $value The recurring limit. |
1015 | 1015 | * @return int |
1016 | 1016 | */ |
1017 | - public function set_recurring_limit( $value ) { |
|
1018 | - $this->set_prop( 'recurring_limit', (int) $value ); |
|
1017 | + public function set_recurring_limit($value) { |
|
1018 | + $this->set_prop('recurring_limit', (int) $value); |
|
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | /** |
@@ -1024,8 +1024,8 @@ discard block |
||
1024 | 1024 | * @since 1.0.19 |
1025 | 1025 | * @param int|bool $value whether or not it has a free trial. |
1026 | 1026 | */ |
1027 | - public function set_is_free_trial( $value ) { |
|
1028 | - $this->set_prop( 'is_free_trial', (int) $value ); |
|
1027 | + public function set_is_free_trial($value) { |
|
1028 | + $this->set_prop('is_free_trial', (int) $value); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | /** |
@@ -1034,8 +1034,8 @@ discard block |
||
1034 | 1034 | * @since 1.0.19 |
1035 | 1035 | * @param string $value trial period. |
1036 | 1036 | */ |
1037 | - public function set_trial_period( $value ) { |
|
1038 | - $this->set_prop( 'trial_period', $value ); |
|
1037 | + public function set_trial_period($value) { |
|
1038 | + $this->set_prop('trial_period', $value); |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | /** |
@@ -1044,8 +1044,8 @@ discard block |
||
1044 | 1044 | * @since 1.0.19 |
1045 | 1045 | * @param int $value trial interval. |
1046 | 1046 | */ |
1047 | - public function set_trial_interval( $value ) { |
|
1048 | - $this->set_prop( 'trial_interval', $value ); |
|
1047 | + public function set_trial_interval($value) { |
|
1048 | + $this->set_prop('trial_interval', $value); |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | /** |
@@ -1054,11 +1054,11 @@ discard block |
||
1054 | 1054 | * @deprecated |
1055 | 1055 | * @return int item id |
1056 | 1056 | */ |
1057 | - public function create( $data = array() ) { |
|
1057 | + public function create($data = array()) { |
|
1058 | 1058 | |
1059 | 1059 | // Set the properties. |
1060 | - if ( is_array( $data ) ) { |
|
1061 | - $this->set_props( $data ); |
|
1060 | + if (is_array($data)) { |
|
1061 | + $this->set_props($data); |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | // Save the item. |
@@ -1072,8 +1072,8 @@ discard block |
||
1072 | 1072 | * @deprecated |
1073 | 1073 | * @return int item id |
1074 | 1074 | */ |
1075 | - public function update( $data = array() ) { |
|
1076 | - return $this->create( $data ); |
|
1075 | + public function update($data = array()) { |
|
1076 | + return $this->create($data); |
|
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | /* |
@@ -1113,7 +1113,7 @@ discard block |
||
1113 | 1113 | */ |
1114 | 1114 | public function has_free_trial() { |
1115 | 1115 | $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false; |
1116 | - return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this ); |
|
1116 | + return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this); |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | /** |
@@ -1123,8 +1123,8 @@ discard block |
||
1123 | 1123 | * @return bool |
1124 | 1124 | */ |
1125 | 1125 | public function is_free() { |
1126 | - $is_free = $this->get_price() == 0; |
|
1127 | - return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this ); |
|
1126 | + $is_free = $this->get_price() == 0; |
|
1127 | + return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | /** |
@@ -1133,9 +1133,9 @@ discard block |
||
1133 | 1133 | * @param array|string $status Status to check. |
1134 | 1134 | * @return bool |
1135 | 1135 | */ |
1136 | - public function has_status( $status ) { |
|
1137 | - $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status; |
|
1138 | - return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status ); |
|
1136 | + public function has_status($status) { |
|
1137 | + $has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status; |
|
1138 | + return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status); |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | /** |
@@ -1144,9 +1144,9 @@ discard block |
||
1144 | 1144 | * @param array|string $type Type to check. |
1145 | 1145 | * @return bool |
1146 | 1146 | */ |
1147 | - public function is_type( $type ) { |
|
1148 | - $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type; |
|
1149 | - return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type ); |
|
1147 | + public function is_type($type) { |
|
1148 | + $is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type; |
|
1149 | + return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type); |
|
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | /** |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | */ |
1158 | 1158 | public function is_editable() { |
1159 | 1159 | $is_editable = $this->get_is_editable(); |
1160 | - return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this ); |
|
1160 | + return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this); |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | /** |
@@ -1176,11 +1176,11 @@ discard block |
||
1176 | 1176 | public function can_purchase() { |
1177 | 1177 | $can_purchase = $this->exists(); |
1178 | 1178 | |
1179 | - if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) { |
|
1179 | + if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') { |
|
1180 | 1180 | $can_purchase = false; |
1181 | 1181 | } |
1182 | 1182 | |
1183 | - return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this ); |
|
1183 | + return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | /** |
@@ -1190,6 +1190,6 @@ discard block |
||
1190 | 1190 | * @return bool |
1191 | 1191 | */ |
1192 | 1192 | public function supports_dynamic_pricing() { |
1193 | - return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this ); |
|
1193 | + return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this); |
|
1194 | 1194 | } |
1195 | 1195 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Personal data exporters. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * WPInv_Privacy_Exporters Class. |
@@ -17,38 +17,38 @@ discard block |
||
17 | 17 | * @param int $page Page. |
18 | 18 | * @return array An array of invoice data in name value pairs |
19 | 19 | */ |
20 | - public static function customer_invoice_data_exporter( $email_address, $page ) { |
|
20 | + public static function customer_invoice_data_exporter($email_address, $page) { |
|
21 | 21 | $done = false; |
22 | 22 | $page = (int) $page; |
23 | 23 | $data_to_export = array(); |
24 | 24 | |
25 | - $user = get_user_by( 'email', $email_address ); |
|
26 | - if ( ! $user instanceof WP_User ) { |
|
25 | + $user = get_user_by('email', $email_address); |
|
26 | + if (!$user instanceof WP_User) { |
|
27 | 27 | return array( |
28 | 28 | 'data' => $data_to_export, |
29 | 29 | 'done' => true, |
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
33 | - $args = array( |
|
33 | + $args = array( |
|
34 | 34 | 'limit' => 30, |
35 | 35 | 'page' => $page, |
36 | 36 | 'user' => $user->ID, |
37 | 37 | ); |
38 | 38 | |
39 | - $invoices = wpinv_get_invoices( $args ); |
|
39 | + $invoices = wpinv_get_invoices($args); |
|
40 | 40 | |
41 | - if ( 0 < count( $invoices ) ) { |
|
42 | - foreach ( $invoices as $invoice ) { |
|
41 | + if (0 < count($invoices)) { |
|
42 | + foreach ($invoices as $invoice) { |
|
43 | 43 | $data_to_export[] = array( |
44 | 44 | 'group_id' => 'customer_invoices', |
45 | - 'group_label' => __( 'Invoicing Data', 'invoicing' ), |
|
46 | - 'group_description' => __( 'Customer invoicing data.', 'invoicing' ), |
|
45 | + 'group_label' => __('Invoicing Data', 'invoicing'), |
|
46 | + 'group_description' => __('Customer invoicing data.', 'invoicing'), |
|
47 | 47 | 'item_id' => "wpinv-{$invoice->ID}", |
48 | - 'data' => self::get_customer_invoice_data( $invoice ), |
|
48 | + 'data' => self::get_customer_invoice_data($invoice), |
|
49 | 49 | ); |
50 | 50 | } |
51 | - $done = 30 > count( $invoices ); |
|
51 | + $done = 30 > count($invoices); |
|
52 | 52 | } else { |
53 | 53 | $done = true; |
54 | 54 | } |
@@ -66,59 +66,59 @@ discard block |
||
66 | 66 | * @param WPInv_Invoice $invoice invoice object. |
67 | 67 | * @return array |
68 | 68 | */ |
69 | - public static function get_customer_invoice_data( $invoice ) { |
|
69 | + public static function get_customer_invoice_data($invoice) { |
|
70 | 70 | $personal_data = array(); |
71 | 71 | |
72 | 72 | $props_to_export = array( |
73 | - 'number' => __( 'Invoice Number', 'invoicing' ), |
|
74 | - 'created_date' => __( 'Invoice Date', 'invoicing' ), |
|
75 | - 'status' => __( 'Invoice Status', 'invoicing' ), |
|
76 | - 'total' => __( 'Invoice Total', 'invoicing' ), |
|
77 | - 'items' => __( 'Invoice Items', 'invoicing' ), |
|
78 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
79 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
80 | - 'email' => __( 'Email Address', 'invoicing' ), |
|
81 | - '_wpinv_company' => __( 'Company', 'invoicing' ), |
|
82 | - 'phone' => __( 'Phone Number', 'invoicing' ), |
|
83 | - 'address' => __( 'Address', 'invoicing' ), |
|
84 | - '_wpinv_city' => __( 'City', 'invoicing' ), |
|
85 | - '_wpinv_country' => __( 'Country', 'invoicing' ), |
|
86 | - '_wpinv_state' => __( 'State', 'invoicing' ), |
|
87 | - '_wpinv_zip' => __( 'Zip Code', 'invoicing' ), |
|
73 | + 'number' => __('Invoice Number', 'invoicing'), |
|
74 | + 'created_date' => __('Invoice Date', 'invoicing'), |
|
75 | + 'status' => __('Invoice Status', 'invoicing'), |
|
76 | + 'total' => __('Invoice Total', 'invoicing'), |
|
77 | + 'items' => __('Invoice Items', 'invoicing'), |
|
78 | + 'first_name' => __('First Name', 'invoicing'), |
|
79 | + 'last_name' => __('Last Name', 'invoicing'), |
|
80 | + 'email' => __('Email Address', 'invoicing'), |
|
81 | + '_wpinv_company' => __('Company', 'invoicing'), |
|
82 | + 'phone' => __('Phone Number', 'invoicing'), |
|
83 | + 'address' => __('Address', 'invoicing'), |
|
84 | + '_wpinv_city' => __('City', 'invoicing'), |
|
85 | + '_wpinv_country' => __('Country', 'invoicing'), |
|
86 | + '_wpinv_state' => __('State', 'invoicing'), |
|
87 | + '_wpinv_zip' => __('Zip Code', 'invoicing'), |
|
88 | 88 | ); |
89 | 89 | |
90 | - $subscription = wpinv_get_subscription( $invoice ); |
|
90 | + $subscription = wpinv_get_subscription($invoice); |
|
91 | 91 | $period = $initial_amt = $bill_times = $billed = $renewal_date = ''; |
92 | 92 | |
93 | - if ( $invoice->is_recurring() && !empty( $subscription ) ) { |
|
94 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(),$subscription->get_frequency() ); |
|
95 | - $period = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ) . ' / ' . $frequency; |
|
96 | - $initial_amt = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
97 | - $bill_times = $subscription->get_times_billed() . ' / ' . ( ( $subscription->get_bill_times() == 0 ) ? __( 'Until Cancelled', 'invoicing' ) : $subscription->get_bill_times() ); |
|
98 | - $renewal_date = ! empty( $subscription->get_expiration() ) ? getpaid_format_date( $subscription->get_expiration() ) : __( 'N/A', 'invoicing' ); |
|
99 | - |
|
100 | - $props_to_export['period'] = __( 'Billing Cycle', 'invoicing' ); |
|
101 | - $props_to_export['initial_amount'] = __( 'Initial Amount', 'invoicing' ); |
|
102 | - $props_to_export['bill_times'] = __( 'Times Billed', 'invoicing' ); |
|
103 | - $props_to_export['renewal_date'] = __( 'Renewal Date', 'invoicing' ); |
|
93 | + if ($invoice->is_recurring() && !empty($subscription)) { |
|
94 | + $frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency()); |
|
95 | + $period = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()) . ' / ' . $frequency; |
|
96 | + $initial_amt = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency()); |
|
97 | + $bill_times = $subscription->get_times_billed() . ' / ' . (($subscription->get_bill_times() == 0) ? __('Until Cancelled', 'invoicing') : $subscription->get_bill_times()); |
|
98 | + $renewal_date = !empty($subscription->get_expiration()) ? getpaid_format_date($subscription->get_expiration()) : __('N/A', 'invoicing'); |
|
99 | + |
|
100 | + $props_to_export['period'] = __('Billing Cycle', 'invoicing'); |
|
101 | + $props_to_export['initial_amount'] = __('Initial Amount', 'invoicing'); |
|
102 | + $props_to_export['bill_times'] = __('Times Billed', 'invoicing'); |
|
103 | + $props_to_export['renewal_date'] = __('Renewal Date', 'invoicing'); |
|
104 | 104 | } |
105 | 105 | |
106 | - $props_to_export['ip'] = __( 'IP Address', 'invoicing' ); |
|
107 | - $props_to_export['view_url'] = __( 'Invoice Link', 'invoicing' ); |
|
106 | + $props_to_export['ip'] = __('IP Address', 'invoicing'); |
|
107 | + $props_to_export['view_url'] = __('Invoice Link', 'invoicing'); |
|
108 | 108 | |
109 | - $props_to_export = apply_filters( 'wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription); |
|
109 | + $props_to_export = apply_filters('wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription); |
|
110 | 110 | |
111 | - foreach ( $props_to_export as $prop => $name ) { |
|
111 | + foreach ($props_to_export as $prop => $name) { |
|
112 | 112 | $value = ''; |
113 | 113 | |
114 | - switch ( $prop ) { |
|
114 | + switch ($prop) { |
|
115 | 115 | case 'items': |
116 | 116 | $item_names = array(); |
117 | - foreach ( $invoice->get_cart_details() as $key => $cart_item ) { |
|
118 | - $item_quantity = $cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
117 | + foreach ($invoice->get_cart_details() as $key => $cart_item) { |
|
118 | + $item_quantity = $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
119 | 119 | $item_names[] = $cart_item['name'] . ' x ' . $item_quantity; |
120 | 120 | } |
121 | - $value = implode( ', ', $item_names ); |
|
121 | + $value = implode(', ', $item_names); |
|
122 | 122 | break; |
123 | 123 | case 'status': |
124 | 124 | $value = $invoice->get_status(true); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $value = $renewal_date; |
140 | 140 | break; |
141 | 141 | default: |
142 | - if ( is_callable( array( $invoice, 'get_' . $prop ) ) ) { |
|
142 | + if (is_callable(array($invoice, 'get_' . $prop))) { |
|
143 | 143 | $value = $invoice->{"get_$prop"}(); |
144 | 144 | } else { |
145 | 145 | $value = $invoice->get_meta($prop); |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | break; |
148 | 148 | } |
149 | 149 | |
150 | - $value = apply_filters( 'wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice ); |
|
150 | + $value = apply_filters('wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice); |
|
151 | 151 | |
152 | - if ( $value ) { |
|
152 | + if ($value) { |
|
153 | 153 | $personal_data[] = array( |
154 | 154 | 'name' => $name, |
155 | 155 | 'value' => $value, |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | } |
160 | 160 | |
161 | - $personal_data = apply_filters( 'wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice ); |
|
161 | + $personal_data = apply_filters('wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice); |
|
162 | 162 | |
163 | 163 | return $personal_data; |
164 | 164 |
@@ -17,28 +17,28 @@ discard block |
||
17 | 17 | */ |
18 | 18 | function getpaid_get_subscriptions( $args = array(), $return = 'results' ) { |
19 | 19 | |
20 | - // Do not retrieve all fields if we just want the count. |
|
21 | - if ( 'count' == $return ) { |
|
22 | - $args['fields'] = 'id'; |
|
23 | - $args['number'] = 1; |
|
24 | - } |
|
20 | + // Do not retrieve all fields if we just want the count. |
|
21 | + if ( 'count' == $return ) { |
|
22 | + $args['fields'] = 'id'; |
|
23 | + $args['number'] = 1; |
|
24 | + } |
|
25 | 25 | |
26 | - // Do not count all matches if we just want the results. |
|
27 | - if ( 'results' == $return ) { |
|
28 | - $args['count_total'] = false; |
|
29 | - } |
|
26 | + // Do not count all matches if we just want the results. |
|
27 | + if ( 'results' == $return ) { |
|
28 | + $args['count_total'] = false; |
|
29 | + } |
|
30 | 30 | |
31 | - $query = new GetPaid_Subscriptions_Query( $args ); |
|
31 | + $query = new GetPaid_Subscriptions_Query( $args ); |
|
32 | 32 | |
33 | - if ( 'results' == $return ) { |
|
34 | - return $query->get_results(); |
|
35 | - } |
|
33 | + if ( 'results' == $return ) { |
|
34 | + return $query->get_results(); |
|
35 | + } |
|
36 | 36 | |
37 | - if ( 'count' == $return ) { |
|
38 | - return $query->get_total(); |
|
39 | - } |
|
37 | + if ( 'count' == $return ) { |
|
38 | + return $query->get_total(); |
|
39 | + } |
|
40 | 40 | |
41 | - return $query; |
|
41 | + return $query; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -48,18 +48,18 @@ discard block |
||
48 | 48 | */ |
49 | 49 | function getpaid_get_subscription_statuses() { |
50 | 50 | |
51 | - return apply_filters( |
|
52 | - 'getpaid_get_subscription_statuses', |
|
53 | - array( |
|
54 | - 'pending' => __( 'Pending', 'invoicing' ), |
|
55 | - 'trialling' => __( 'Trialing', 'invoicing' ), |
|
56 | - 'active' => __( 'Active', 'invoicing' ), |
|
57 | - 'failing' => __( 'Failing', 'invoicing' ), |
|
58 | - 'expired' => __( 'Expired', 'invoicing' ), |
|
59 | - 'completed' => __( 'Complete', 'invoicing' ), |
|
60 | - 'cancelled' => __( 'Cancelled', 'invoicing' ), |
|
61 | - ) |
|
62 | - ); |
|
51 | + return apply_filters( |
|
52 | + 'getpaid_get_subscription_statuses', |
|
53 | + array( |
|
54 | + 'pending' => __( 'Pending', 'invoicing' ), |
|
55 | + 'trialling' => __( 'Trialing', 'invoicing' ), |
|
56 | + 'active' => __( 'Active', 'invoicing' ), |
|
57 | + 'failing' => __( 'Failing', 'invoicing' ), |
|
58 | + 'expired' => __( 'Expired', 'invoicing' ), |
|
59 | + 'completed' => __( 'Complete', 'invoicing' ), |
|
60 | + 'cancelled' => __( 'Cancelled', 'invoicing' ), |
|
61 | + ) |
|
62 | + ); |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | * @return string |
70 | 70 | */ |
71 | 71 | function getpaid_get_subscription_status_label( $status ) { |
72 | - $statuses = getpaid_get_subscription_statuses(); |
|
73 | - return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) ); |
|
72 | + $statuses = getpaid_get_subscription_statuses(); |
|
73 | + return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) ); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -80,18 +80,18 @@ discard block |
||
80 | 80 | */ |
81 | 81 | function getpaid_get_subscription_status_classes() { |
82 | 82 | |
83 | - return apply_filters( |
|
84 | - 'getpaid_get_subscription_status_classes', |
|
85 | - array( |
|
86 | - 'pending' => 'badge-dark', |
|
87 | - 'trialling' => 'badge-info', |
|
88 | - 'active' => 'badge-success', |
|
89 | - 'failing' => 'badge-warning', |
|
90 | - 'expired' => 'badge-danger', |
|
91 | - 'completed' => 'badge-primary', |
|
92 | - 'cancelled' => 'badge-secondary', |
|
93 | - ) |
|
94 | - ); |
|
83 | + return apply_filters( |
|
84 | + 'getpaid_get_subscription_status_classes', |
|
85 | + array( |
|
86 | + 'pending' => 'badge-dark', |
|
87 | + 'trialling' => 'badge-info', |
|
88 | + 'active' => 'badge-success', |
|
89 | + 'failing' => 'badge-warning', |
|
90 | + 'expired' => 'badge-danger', |
|
91 | + 'completed' => 'badge-primary', |
|
92 | + 'cancelled' => 'badge-secondary', |
|
93 | + ) |
|
94 | + ); |
|
95 | 95 | |
96 | 96 | } |
97 | 97 | |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function getpaid_get_subscription_status_counts( $args = array() ) { |
104 | 104 | |
105 | - $statuses = array_keys( getpaid_get_subscription_statuses() ); |
|
106 | - $counts = array(); |
|
105 | + $statuses = array_keys( getpaid_get_subscription_statuses() ); |
|
106 | + $counts = array(); |
|
107 | 107 | |
108 | - foreach ( $statuses as $status ) { |
|
109 | - $_args = wp_parse_args( "status=$status", $args ); |
|
110 | - $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' ); |
|
111 | - } |
|
108 | + foreach ( $statuses as $status ) { |
|
109 | + $_args = wp_parse_args( "status=$status", $args ); |
|
110 | + $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' ); |
|
111 | + } |
|
112 | 112 | |
113 | - return $counts; |
|
113 | + return $counts; |
|
114 | 114 | |
115 | 115 | } |
116 | 116 | |
@@ -121,32 +121,32 @@ discard block |
||
121 | 121 | */ |
122 | 122 | function getpaid_get_subscription_periods() { |
123 | 123 | |
124 | - return apply_filters( |
|
125 | - 'getpaid_get_subscription_periods', |
|
126 | - array( |
|
124 | + return apply_filters( |
|
125 | + 'getpaid_get_subscription_periods', |
|
126 | + array( |
|
127 | 127 | |
128 | - 'day' => array( |
|
129 | - 'singular' => __( '%s day', 'invoicing' ), |
|
130 | - 'plural' => __( '%d days', 'invoicing' ), |
|
131 | - ), |
|
128 | + 'day' => array( |
|
129 | + 'singular' => __( '%s day', 'invoicing' ), |
|
130 | + 'plural' => __( '%d days', 'invoicing' ), |
|
131 | + ), |
|
132 | 132 | |
133 | - 'week' => array( |
|
134 | - 'singular' => __( '%s week', 'invoicing' ), |
|
135 | - 'plural' => __( '%d weeks', 'invoicing' ), |
|
136 | - ), |
|
133 | + 'week' => array( |
|
134 | + 'singular' => __( '%s week', 'invoicing' ), |
|
135 | + 'plural' => __( '%d weeks', 'invoicing' ), |
|
136 | + ), |
|
137 | 137 | |
138 | - 'month' => array( |
|
139 | - 'singular' => __( '%s month', 'invoicing' ), |
|
140 | - 'plural' => __( '%d months', 'invoicing' ), |
|
141 | - ), |
|
138 | + 'month' => array( |
|
139 | + 'singular' => __( '%s month', 'invoicing' ), |
|
140 | + 'plural' => __( '%d months', 'invoicing' ), |
|
141 | + ), |
|
142 | 142 | |
143 | - 'year' => array( |
|
144 | - 'singular' => __( '%s year', 'invoicing' ), |
|
145 | - 'plural' => __( '%d years', 'invoicing' ), |
|
146 | - ), |
|
143 | + 'year' => array( |
|
144 | + 'singular' => __( '%s year', 'invoicing' ), |
|
145 | + 'plural' => __( '%d years', 'invoicing' ), |
|
146 | + ), |
|
147 | 147 | |
148 | - ) |
|
149 | - ); |
|
148 | + ) |
|
149 | + ); |
|
150 | 150 | |
151 | 151 | } |
152 | 152 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return int |
158 | 158 | */ |
159 | 159 | function getpaid_get_subscription_trial_period_interval( $trial_period ) { |
160 | - return (int) preg_replace( '/[^0-9]/', '', $trial_period ); |
|
160 | + return (int) preg_replace( '/[^0-9]/', '', $trial_period ); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @return string |
168 | 168 | */ |
169 | 169 | function getpaid_get_subscription_trial_period_period( $trial_period ) { |
170 | - return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) ); |
|
170 | + return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | * @return string |
179 | 179 | */ |
180 | 180 | function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) { |
181 | - $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix ); |
|
182 | - return strtolower( sanitize_text_field( $label ) ); |
|
181 | + $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix ); |
|
182 | + return strtolower( sanitize_text_field( $label ) ); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -190,22 +190,22 @@ discard block |
||
190 | 190 | */ |
191 | 191 | function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) { |
192 | 192 | |
193 | - $periods = getpaid_get_subscription_periods(); |
|
194 | - $period = strtolower( $period ); |
|
193 | + $periods = getpaid_get_subscription_periods(); |
|
194 | + $period = strtolower( $period ); |
|
195 | 195 | |
196 | - if ( isset( $periods[ $period ] ) ) { |
|
197 | - return sprintf( $periods[ $period ]['singular'], $singular_prefix ); |
|
198 | - } |
|
196 | + if ( isset( $periods[ $period ] ) ) { |
|
197 | + return sprintf( $periods[ $period ]['singular'], $singular_prefix ); |
|
198 | + } |
|
199 | 199 | |
200 | - // Backwards compatibility. |
|
201 | - foreach ( $periods as $key => $data ) { |
|
202 | - if ( strpos( $key, $period ) === 0 ) { |
|
203 | - return sprintf( $data['singular'], $singular_prefix ); |
|
204 | - } |
|
205 | - } |
|
200 | + // Backwards compatibility. |
|
201 | + foreach ( $periods as $key => $data ) { |
|
202 | + if ( strpos( $key, $period ) === 0 ) { |
|
203 | + return sprintf( $data['singular'], $singular_prefix ); |
|
204 | + } |
|
205 | + } |
|
206 | 206 | |
207 | - // Invalid string. |
|
208 | - return ''; |
|
207 | + // Invalid string. |
|
208 | + return ''; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -217,22 +217,22 @@ discard block |
||
217 | 217 | */ |
218 | 218 | function getpaid_get_plural_subscription_period_label( $period, $interval ) { |
219 | 219 | |
220 | - $periods = getpaid_get_subscription_periods(); |
|
221 | - $period = strtolower( $period ); |
|
220 | + $periods = getpaid_get_subscription_periods(); |
|
221 | + $period = strtolower( $period ); |
|
222 | 222 | |
223 | - if ( isset( $periods[ $period ] ) ) { |
|
224 | - return sprintf( $periods[ $period ]['plural'], $interval ); |
|
225 | - } |
|
223 | + if ( isset( $periods[ $period ] ) ) { |
|
224 | + return sprintf( $periods[ $period ]['plural'], $interval ); |
|
225 | + } |
|
226 | 226 | |
227 | - // Backwards compatibility. |
|
228 | - foreach ( $periods as $key => $data ) { |
|
229 | - if ( strpos( $key, $period ) === 0 ) { |
|
230 | - return sprintf( $data['plural'], $interval ); |
|
231 | - } |
|
232 | - } |
|
227 | + // Backwards compatibility. |
|
228 | + foreach ( $periods as $key => $data ) { |
|
229 | + if ( strpos( $key, $period ) === 0 ) { |
|
230 | + return sprintf( $data['plural'], $interval ); |
|
231 | + } |
|
232 | + } |
|
233 | 233 | |
234 | - // Invalid string. |
|
235 | - return ''; |
|
234 | + // Invalid string. |
|
235 | + return ''; |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -243,50 +243,50 @@ discard block |
||
243 | 243 | */ |
244 | 244 | function getpaid_get_formatted_subscription_amount( $subscription ) { |
245 | 245 | |
246 | - $initial = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
247 | - $recurring = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
248 | - $period = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
246 | + $initial = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
247 | + $recurring = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
248 | + $period = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
249 | 249 | |
250 | - // Trial periods. |
|
251 | - if ( $subscription->has_trial_period() ) { |
|
250 | + // Trial periods. |
|
251 | + if ( $subscription->has_trial_period() ) { |
|
252 | 252 | |
253 | - $trial_period = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() ); |
|
254 | - $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() ); |
|
255 | - return sprintf( |
|
253 | + $trial_period = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() ); |
|
254 | + $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() ); |
|
255 | + return sprintf( |
|
256 | 256 | |
257 | - // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
|
258 | - _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
259 | - $initial, |
|
260 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
261 | - $recurring, |
|
262 | - $period |
|
257 | + // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
|
258 | + _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
259 | + $initial, |
|
260 | + getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
261 | + $recurring, |
|
262 | + $period |
|
263 | 263 | |
264 | - ); |
|
264 | + ); |
|
265 | 265 | |
266 | - } |
|
266 | + } |
|
267 | 267 | |
268 | - if ( $initial != $recurring ) { |
|
268 | + if ( $initial != $recurring ) { |
|
269 | 269 | |
270 | - return sprintf( |
|
270 | + return sprintf( |
|
271 | 271 | |
272 | - // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period |
|
273 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ), |
|
274 | - $initial, |
|
275 | - $recurring, |
|
276 | - $period |
|
272 | + // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period |
|
273 | + _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ), |
|
274 | + $initial, |
|
275 | + $recurring, |
|
276 | + $period |
|
277 | 277 | |
278 | - ); |
|
278 | + ); |
|
279 | 279 | |
280 | - } |
|
280 | + } |
|
281 | 281 | |
282 | - return sprintf( |
|
282 | + return sprintf( |
|
283 | 283 | |
284 | - // translators: $1: is the recurring amount, $2: is the recurring period |
|
285 | - _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
286 | - $initial, |
|
287 | - $period |
|
284 | + // translators: $1: is the recurring amount, $2: is the recurring period |
|
285 | + _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
286 | + $initial, |
|
287 | + $period |
|
288 | 288 | |
289 | - ); |
|
289 | + ); |
|
290 | 290 | |
291 | 291 | } |
292 | 292 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @return WPInv_Subscription|bool |
298 | 298 | */ |
299 | 299 | function getpaid_get_invoice_subscription( $invoice ) { |
300 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
300 | + return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -306,10 +306,10 @@ discard block |
||
306 | 306 | * @param WPInv_Invoice $invoice |
307 | 307 | */ |
308 | 308 | function getpaid_activate_invoice_subscription( $invoice ) { |
309 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
310 | - if ( is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
311 | - $subscription->activate(); |
|
312 | - } |
|
309 | + $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
310 | + if ( is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
311 | + $subscription->activate(); |
|
312 | + } |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @return WPInv_Subscriptions |
319 | 319 | */ |
320 | 320 | function getpaid_subscriptions() { |
321 | - return getpaid()->get( 'subscriptions' ); |
|
321 | + return getpaid()->get( 'subscriptions' ); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -336,14 +336,14 @@ discard block |
||
336 | 336 | return false; |
337 | 337 | } |
338 | 338 | |
339 | - // Fetch the invoiec subscription. |
|
340 | - $subscription = getpaid_get_subscriptions( |
|
341 | - array( |
|
342 | - 'invoice_in' => $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id(), |
|
343 | - 'number' => 1, |
|
344 | - ) |
|
345 | - ); |
|
339 | + // Fetch the invoiec subscription. |
|
340 | + $subscription = getpaid_get_subscriptions( |
|
341 | + array( |
|
342 | + 'invoice_in' => $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id(), |
|
343 | + 'number' => 1, |
|
344 | + ) |
|
345 | + ); |
|
346 | 346 | |
347 | - return empty( $subscription ) ? false : $subscription[0]; |
|
347 | + return empty( $subscription ) ? false : $subscription[0]; |
|
348 | 348 | |
349 | 349 | } |
@@ -15,26 +15,26 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @return int|array|WPInv_Subscription[]|GetPaid_Subscriptions_Query |
17 | 17 | */ |
18 | -function getpaid_get_subscriptions( $args = array(), $return = 'results' ) { |
|
18 | +function getpaid_get_subscriptions($args = array(), $return = 'results') { |
|
19 | 19 | |
20 | 20 | // Do not retrieve all fields if we just want the count. |
21 | - if ( 'count' == $return ) { |
|
21 | + if ('count' == $return) { |
|
22 | 22 | $args['fields'] = 'id'; |
23 | 23 | $args['number'] = 1; |
24 | 24 | } |
25 | 25 | |
26 | 26 | // Do not count all matches if we just want the results. |
27 | - if ( 'results' == $return ) { |
|
27 | + if ('results' == $return) { |
|
28 | 28 | $args['count_total'] = false; |
29 | 29 | } |
30 | 30 | |
31 | - $query = new GetPaid_Subscriptions_Query( $args ); |
|
31 | + $query = new GetPaid_Subscriptions_Query($args); |
|
32 | 32 | |
33 | - if ( 'results' == $return ) { |
|
33 | + if ('results' == $return) { |
|
34 | 34 | return $query->get_results(); |
35 | 35 | } |
36 | 36 | |
37 | - if ( 'count' == $return ) { |
|
37 | + if ('count' == $return) { |
|
38 | 38 | return $query->get_total(); |
39 | 39 | } |
40 | 40 | |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | return apply_filters( |
52 | 52 | 'getpaid_get_subscription_statuses', |
53 | 53 | array( |
54 | - 'pending' => __( 'Pending', 'invoicing' ), |
|
55 | - 'trialling' => __( 'Trialing', 'invoicing' ), |
|
56 | - 'active' => __( 'Active', 'invoicing' ), |
|
57 | - 'failing' => __( 'Failing', 'invoicing' ), |
|
58 | - 'expired' => __( 'Expired', 'invoicing' ), |
|
59 | - 'completed' => __( 'Complete', 'invoicing' ), |
|
60 | - 'cancelled' => __( 'Cancelled', 'invoicing' ), |
|
54 | + 'pending' => __('Pending', 'invoicing'), |
|
55 | + 'trialling' => __('Trialing', 'invoicing'), |
|
56 | + 'active' => __('Active', 'invoicing'), |
|
57 | + 'failing' => __('Failing', 'invoicing'), |
|
58 | + 'expired' => __('Expired', 'invoicing'), |
|
59 | + 'completed' => __('Complete', 'invoicing'), |
|
60 | + 'cancelled' => __('Cancelled', 'invoicing'), |
|
61 | 61 | ) |
62 | 62 | ); |
63 | 63 | |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return string |
70 | 70 | */ |
71 | -function getpaid_get_subscription_status_label( $status ) { |
|
71 | +function getpaid_get_subscription_status_label($status) { |
|
72 | 72 | $statuses = getpaid_get_subscription_statuses(); |
73 | - return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) ); |
|
73 | + return isset($statuses[$status]) ? $statuses[$status] : ucfirst(sanitize_text_field($status)); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return array |
102 | 102 | */ |
103 | -function getpaid_get_subscription_status_counts( $args = array() ) { |
|
103 | +function getpaid_get_subscription_status_counts($args = array()) { |
|
104 | 104 | |
105 | - $statuses = array_keys( getpaid_get_subscription_statuses() ); |
|
105 | + $statuses = array_keys(getpaid_get_subscription_statuses()); |
|
106 | 106 | $counts = array(); |
107 | 107 | |
108 | - foreach ( $statuses as $status ) { |
|
109 | - $_args = wp_parse_args( "status=$status", $args ); |
|
110 | - $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' ); |
|
108 | + foreach ($statuses as $status) { |
|
109 | + $_args = wp_parse_args("status=$status", $args); |
|
110 | + $counts[$status] = getpaid_get_subscriptions($_args, 'count'); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return $counts; |
@@ -126,23 +126,23 @@ discard block |
||
126 | 126 | array( |
127 | 127 | |
128 | 128 | 'day' => array( |
129 | - 'singular' => __( '%s day', 'invoicing' ), |
|
130 | - 'plural' => __( '%d days', 'invoicing' ), |
|
129 | + 'singular' => __('%s day', 'invoicing'), |
|
130 | + 'plural' => __('%d days', 'invoicing'), |
|
131 | 131 | ), |
132 | 132 | |
133 | 133 | 'week' => array( |
134 | - 'singular' => __( '%s week', 'invoicing' ), |
|
135 | - 'plural' => __( '%d weeks', 'invoicing' ), |
|
134 | + 'singular' => __('%s week', 'invoicing'), |
|
135 | + 'plural' => __('%d weeks', 'invoicing'), |
|
136 | 136 | ), |
137 | 137 | |
138 | 138 | 'month' => array( |
139 | - 'singular' => __( '%s month', 'invoicing' ), |
|
140 | - 'plural' => __( '%d months', 'invoicing' ), |
|
139 | + 'singular' => __('%s month', 'invoicing'), |
|
140 | + 'plural' => __('%d months', 'invoicing'), |
|
141 | 141 | ), |
142 | 142 | |
143 | 143 | 'year' => array( |
144 | - 'singular' => __( '%s year', 'invoicing' ), |
|
145 | - 'plural' => __( '%d years', 'invoicing' ), |
|
144 | + 'singular' => __('%s year', 'invoicing'), |
|
145 | + 'plural' => __('%d years', 'invoicing'), |
|
146 | 146 | ), |
147 | 147 | |
148 | 148 | ) |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * @param string $trial_period |
157 | 157 | * @return int |
158 | 158 | */ |
159 | -function getpaid_get_subscription_trial_period_interval( $trial_period ) { |
|
160 | - return (int) preg_replace( '/[^0-9]/', '', $trial_period ); |
|
159 | +function getpaid_get_subscription_trial_period_interval($trial_period) { |
|
160 | + return (int) preg_replace('/[^0-9]/', '', $trial_period); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | * @param string $trial_period |
167 | 167 | * @return string |
168 | 168 | */ |
169 | -function getpaid_get_subscription_trial_period_period( $trial_period ) { |
|
170 | - return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) ); |
|
169 | +function getpaid_get_subscription_trial_period_period($trial_period) { |
|
170 | + return preg_replace('/[^a-z]/', '', strtolower($trial_period)); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | * @param int $interval |
178 | 178 | * @return string |
179 | 179 | */ |
180 | -function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) { |
|
181 | - $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix ); |
|
182 | - return strtolower( sanitize_text_field( $label ) ); |
|
180 | +function getpaid_get_subscription_period_label($period, $interval = 1, $singular_prefix = '1') { |
|
181 | + $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label($period, $interval) : getpaid_get_singular_subscription_period_label($period, $singular_prefix); |
|
182 | + return strtolower(sanitize_text_field($label)); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -188,19 +188,19 @@ discard block |
||
188 | 188 | * @param string $period |
189 | 189 | * @return string |
190 | 190 | */ |
191 | -function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) { |
|
191 | +function getpaid_get_singular_subscription_period_label($period, $singular_prefix = '1') { |
|
192 | 192 | |
193 | 193 | $periods = getpaid_get_subscription_periods(); |
194 | - $period = strtolower( $period ); |
|
194 | + $period = strtolower($period); |
|
195 | 195 | |
196 | - if ( isset( $periods[ $period ] ) ) { |
|
197 | - return sprintf( $periods[ $period ]['singular'], $singular_prefix ); |
|
196 | + if (isset($periods[$period])) { |
|
197 | + return sprintf($periods[$period]['singular'], $singular_prefix); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | // Backwards compatibility. |
201 | - foreach ( $periods as $key => $data ) { |
|
202 | - if ( strpos( $key, $period ) === 0 ) { |
|
203 | - return sprintf( $data['singular'], $singular_prefix ); |
|
201 | + foreach ($periods as $key => $data) { |
|
202 | + if (strpos($key, $period) === 0) { |
|
203 | + return sprintf($data['singular'], $singular_prefix); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
@@ -215,19 +215,19 @@ discard block |
||
215 | 215 | * @param int $interval |
216 | 216 | * @return string |
217 | 217 | */ |
218 | -function getpaid_get_plural_subscription_period_label( $period, $interval ) { |
|
218 | +function getpaid_get_plural_subscription_period_label($period, $interval) { |
|
219 | 219 | |
220 | 220 | $periods = getpaid_get_subscription_periods(); |
221 | - $period = strtolower( $period ); |
|
221 | + $period = strtolower($period); |
|
222 | 222 | |
223 | - if ( isset( $periods[ $period ] ) ) { |
|
224 | - return sprintf( $periods[ $period ]['plural'], $interval ); |
|
223 | + if (isset($periods[$period])) { |
|
224 | + return sprintf($periods[$period]['plural'], $interval); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // Backwards compatibility. |
228 | - foreach ( $periods as $key => $data ) { |
|
229 | - if ( strpos( $key, $period ) === 0 ) { |
|
230 | - return sprintf( $data['plural'], $interval ); |
|
228 | + foreach ($periods as $key => $data) { |
|
229 | + if (strpos($key, $period) === 0) { |
|
230 | + return sprintf($data['plural'], $interval); |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
@@ -241,23 +241,23 @@ discard block |
||
241 | 241 | * @param WPInv_Subscription $subscription |
242 | 242 | * @return string |
243 | 243 | */ |
244 | -function getpaid_get_formatted_subscription_amount( $subscription ) { |
|
244 | +function getpaid_get_formatted_subscription_amount($subscription) { |
|
245 | 245 | |
246 | - $initial = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
247 | - $recurring = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
248 | - $period = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
246 | + $initial = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency()); |
|
247 | + $recurring = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()); |
|
248 | + $period = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
249 | 249 | |
250 | 250 | // Trial periods. |
251 | - if ( $subscription->has_trial_period() ) { |
|
251 | + if ($subscription->has_trial_period()) { |
|
252 | 252 | |
253 | - $trial_period = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() ); |
|
254 | - $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() ); |
|
253 | + $trial_period = getpaid_get_subscription_trial_period_period($subscription->get_trial_period()); |
|
254 | + $trial_interval = getpaid_get_subscription_trial_period_interval($subscription->get_trial_period()); |
|
255 | 255 | return sprintf( |
256 | 256 | |
257 | 257 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
258 | - _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
258 | + _x('%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'), |
|
259 | 259 | $initial, |
260 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
260 | + getpaid_get_subscription_period_label($trial_period, $trial_interval), |
|
261 | 261 | $recurring, |
262 | 262 | $period |
263 | 263 | |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | |
266 | 266 | } |
267 | 267 | |
268 | - if ( $initial != $recurring ) { |
|
268 | + if ($initial != $recurring) { |
|
269 | 269 | |
270 | 270 | return sprintf( |
271 | 271 | |
272 | 272 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period |
273 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ), |
|
273 | + _x('Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing'), |
|
274 | 274 | $initial, |
275 | 275 | $recurring, |
276 | 276 | $period |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | return sprintf( |
283 | 283 | |
284 | 284 | // translators: $1: is the recurring amount, $2: is the recurring period |
285 | - _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
285 | + _x('%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
286 | 286 | $initial, |
287 | 287 | $period |
288 | 288 | |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | * @param WPInv_Invoice $invoice |
297 | 297 | * @return WPInv_Subscription|bool |
298 | 298 | */ |
299 | -function getpaid_get_invoice_subscription( $invoice ) { |
|
300 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
299 | +function getpaid_get_invoice_subscription($invoice) { |
|
300 | + return getpaid_subscriptions()->get_invoice_subscription($invoice); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @param WPInv_Invoice $invoice |
307 | 307 | */ |
308 | -function getpaid_activate_invoice_subscription( $invoice ) { |
|
309 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
310 | - if ( is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
308 | +function getpaid_activate_invoice_subscription($invoice) { |
|
309 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
310 | + if (is_a($subscription, 'WPInv_Subscription')) { |
|
311 | 311 | $subscription->activate(); |
312 | 312 | } |
313 | 313 | } |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @return WPInv_Subscriptions |
319 | 319 | */ |
320 | 320 | function getpaid_subscriptions() { |
321 | - return getpaid()->get( 'subscriptions' ); |
|
321 | + return getpaid()->get('subscriptions'); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @return WPInv_Subscription|bool |
328 | 328 | */ |
329 | -function wpinv_get_subscription( $invoice ) { |
|
329 | +function wpinv_get_subscription($invoice) { |
|
330 | 330 | |
331 | 331 | // Retrieve the invoice. |
332 | - $invoice = new WPInv_Invoice( $invoice ); |
|
332 | + $invoice = new WPInv_Invoice($invoice); |
|
333 | 333 | |
334 | 334 | // Ensure it is a recurring invoice. |
335 | - if ( ! $invoice->is_recurring() ) { |
|
335 | + if (!$invoice->is_recurring()) { |
|
336 | 336 | return false; |
337 | 337 | } |
338 | 338 | |
@@ -344,6 +344,6 @@ discard block |
||
344 | 344 | ) |
345 | 345 | ); |
346 | 346 | |
347 | - return empty( $subscription ) ? false : $subscription[0]; |
|
347 | + return empty($subscription) ? false : $subscription[0]; |
|
348 | 348 | |
349 | 349 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -10,60 +10,60 @@ discard block |
||
10 | 10 | class GetPaid_Form_Item extends WPInv_Item { |
11 | 11 | |
12 | 12 | /** |
13 | - * Stores a custom description for the item. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $custom_description = null; |
|
18 | - |
|
19 | - /** |
|
20 | - * Stores the item quantity. |
|
21 | - * |
|
22 | - * @var int |
|
23 | - */ |
|
24 | - protected $quantity = 1; |
|
25 | - |
|
26 | - /** |
|
27 | - * Stores the item meta. |
|
28 | - * |
|
29 | - * @var array |
|
30 | - */ |
|
31 | - protected $meta = array(); |
|
32 | - |
|
33 | - /** |
|
34 | - * Is this item required? |
|
35 | - * |
|
36 | - * @var int |
|
37 | - */ |
|
38 | - protected $is_required = true; |
|
39 | - |
|
40 | - /** |
|
41 | - * Are quantities allowed? |
|
42 | - * |
|
43 | - * @var int |
|
44 | - */ |
|
45 | - protected $allow_quantities = false; |
|
46 | - |
|
47 | - /** |
|
48 | - * Associated invoice. |
|
49 | - * |
|
50 | - * @var int |
|
51 | - */ |
|
52 | - public $invoice_id = 0; |
|
53 | - |
|
54 | - /** |
|
55 | - * Item discount. |
|
56 | - * |
|
57 | - * @var float |
|
58 | - */ |
|
59 | - public $item_discount = 0; |
|
60 | - |
|
61 | - /** |
|
62 | - * Item tax. |
|
63 | - * |
|
64 | - * @var float |
|
65 | - */ |
|
66 | - public $item_tax = 0; |
|
13 | + * Stores a custom description for the item. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $custom_description = null; |
|
18 | + |
|
19 | + /** |
|
20 | + * Stores the item quantity. |
|
21 | + * |
|
22 | + * @var int |
|
23 | + */ |
|
24 | + protected $quantity = 1; |
|
25 | + |
|
26 | + /** |
|
27 | + * Stores the item meta. |
|
28 | + * |
|
29 | + * @var array |
|
30 | + */ |
|
31 | + protected $meta = array(); |
|
32 | + |
|
33 | + /** |
|
34 | + * Is this item required? |
|
35 | + * |
|
36 | + * @var int |
|
37 | + */ |
|
38 | + protected $is_required = true; |
|
39 | + |
|
40 | + /** |
|
41 | + * Are quantities allowed? |
|
42 | + * |
|
43 | + * @var int |
|
44 | + */ |
|
45 | + protected $allow_quantities = false; |
|
46 | + |
|
47 | + /** |
|
48 | + * Associated invoice. |
|
49 | + * |
|
50 | + * @var int |
|
51 | + */ |
|
52 | + public $invoice_id = 0; |
|
53 | + |
|
54 | + /** |
|
55 | + * Item discount. |
|
56 | + * |
|
57 | + * @var float |
|
58 | + */ |
|
59 | + public $item_discount = 0; |
|
60 | + |
|
61 | + /** |
|
62 | + * Item tax. |
|
63 | + * |
|
64 | + * @var float |
|
65 | + */ |
|
66 | + public $item_tax = 0; |
|
67 | 67 | |
68 | 68 | /* |
69 | 69 | |-------------------------------------------------------------------------- |
@@ -81,232 +81,232 @@ discard block |
||
81 | 81 | */ |
82 | 82 | |
83 | 83 | /** |
84 | - * Get the item name. |
|
85 | - * |
|
86 | - * @since 1.0.19 |
|
87 | - * @param string $context View or edit context. |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function get_name( $context = 'view' ) { |
|
91 | - $name = parent::get_name( $context ); |
|
92 | - return $name . wpinv_get_item_suffix( $this ); |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Get the item name without a suffix. |
|
97 | - * |
|
98 | - * @since 1.0.19 |
|
99 | - * @param string $context View or edit context. |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - public function get_raw_name( $context = 'view' ) { |
|
103 | - return parent::get_name( $context ); |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Get the item description. |
|
108 | - * |
|
109 | - * @since 1.0.19 |
|
110 | - * @param string $context View or edit context. |
|
111 | - * @return string |
|
112 | - */ |
|
113 | - public function get_description( $context = 'view' ) { |
|
114 | - |
|
115 | - if ( isset( $this->custom_description ) ) { |
|
116 | - return $this->custom_description; |
|
117 | - } |
|
118 | - |
|
119 | - return parent::get_description( $context ); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Returns the sub total. |
|
124 | - * |
|
125 | - * @since 1.0.19 |
|
126 | - * @param string $context View or edit context. |
|
127 | - * @return float |
|
128 | - */ |
|
129 | - public function get_sub_total( $context = 'view' ) { |
|
130 | - return $this->get_quantity( $context ) * $this->get_initial_price( $context ); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Returns the recurring sub total. |
|
135 | - * |
|
136 | - * @since 1.0.19 |
|
137 | - * @param string $context View or edit context. |
|
138 | - * @return float |
|
139 | - */ |
|
140 | - public function get_recurring_sub_total( $context = 'view' ) { |
|
141 | - |
|
142 | - if ( $this->is_recurring() ) { |
|
143 | - return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
144 | - } |
|
145 | - |
|
146 | - return 0; |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * @deprecated |
|
151 | - */ |
|
152 | - public function get_qantity( $context = 'view' ) { |
|
153 | - return $this->get_quantity( $context ); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Get the item quantity. |
|
158 | - * |
|
159 | - * @since 1.0.19 |
|
160 | - * @param string $context View or edit context. |
|
161 | - * @return int |
|
162 | - */ |
|
163 | - public function get_quantity( $context = 'view' ) { |
|
164 | - $quantity = (int) $this->quantity; |
|
165 | - |
|
166 | - if ( empty( $quantity ) || 1 > $quantity ) { |
|
167 | - $quantity = 1; |
|
168 | - } |
|
169 | - |
|
170 | - if ( 'view' == $context ) { |
|
171 | - return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
172 | - } |
|
173 | - |
|
174 | - return $quantity; |
|
175 | - |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * Get the item meta data. |
|
180 | - * |
|
181 | - * @since 1.0.19 |
|
182 | - * @param string $context View or edit context. |
|
183 | - * @return meta |
|
184 | - */ |
|
185 | - public function get_item_meta( $context = 'view' ) { |
|
186 | - $meta = $this->meta; |
|
187 | - |
|
188 | - if ( 'view' == $context ) { |
|
189 | - return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
190 | - } |
|
191 | - |
|
192 | - return $meta; |
|
193 | - |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * Returns whether or not customers can update the item quantity. |
|
198 | - * |
|
199 | - * @since 1.0.19 |
|
200 | - * @param string $context View or edit context. |
|
201 | - * @return bool |
|
202 | - */ |
|
203 | - public function get_allow_quantities( $context = 'view' ) { |
|
204 | - $allow_quantities = (bool) $this->allow_quantities; |
|
205 | - |
|
206 | - if ( 'view' == $context ) { |
|
207 | - return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
208 | - } |
|
209 | - |
|
210 | - return $allow_quantities; |
|
211 | - |
|
212 | - } |
|
213 | - |
|
214 | - /** |
|
215 | - * Returns whether or not the item is required. |
|
216 | - * |
|
217 | - * @since 1.0.19 |
|
218 | - * @param string $context View or edit context. |
|
219 | - * @return bool |
|
220 | - */ |
|
221 | - public function get_is_required( $context = 'view' ) { |
|
222 | - $is_required = (bool) $this->is_required; |
|
223 | - |
|
224 | - if ( 'view' == $context ) { |
|
225 | - return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
226 | - } |
|
227 | - |
|
228 | - return $is_required; |
|
229 | - |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * Prepares form data for use. |
|
234 | - * |
|
235 | - * @since 1.0.19 |
|
236 | - * @return array |
|
237 | - */ |
|
238 | - public function prepare_data_for_use( $required = null ) { |
|
239 | - |
|
240 | - $required = is_null( $required ) ? $this->is_required() : $required; |
|
241 | - return array( |
|
242 | - 'title' => strip_tags( $this->get_name() ), |
|
243 | - 'id' => $this->get_id(), |
|
244 | - 'price' => $this->get_price(), |
|
245 | - 'recurring' => $this->is_recurring(), |
|
246 | - 'description' => $this->get_description(), |
|
247 | - 'allow_quantities' => $this->allows_quantities(), |
|
248 | - 'required' => $required, |
|
249 | - ); |
|
250 | - |
|
251 | - } |
|
252 | - |
|
253 | - /** |
|
254 | - * Prepares form data for ajax use. |
|
255 | - * |
|
256 | - * @since 1.0.19 |
|
257 | - * @return array |
|
258 | - */ |
|
259 | - public function prepare_data_for_invoice_edit_ajax( $currency = '' ) { |
|
260 | - |
|
261 | - $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
262 | - |
|
263 | - if ( $description ) { |
|
264 | - $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
|
265 | - } |
|
266 | - |
|
267 | - return array( |
|
268 | - 'id' => $this->get_id(), |
|
269 | - 'texts' => array( |
|
270 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
271 | - 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
272 | - 'item-quantity' => absint( $this->get_quantity() ), |
|
273 | - 'item-price' => wpinv_price( $this->get_price(), $currency ), |
|
274 | - 'item-total' => wpinv_price( $this->get_sub_total(), $currency ), |
|
275 | - ), |
|
276 | - 'inputs' => array( |
|
277 | - 'item-id' => $this->get_id(), |
|
278 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
279 | - 'item-description' => wp_kses_post( $this->get_description() ), |
|
280 | - 'item-quantity' => absint( $this->get_quantity() ), |
|
281 | - 'item-price' => $this->get_price(), |
|
282 | - ) |
|
283 | - ); |
|
284 | - |
|
285 | - } |
|
286 | - |
|
287 | - /** |
|
288 | - * Prepares form data for saving (cart_details). |
|
289 | - * |
|
290 | - * @since 1.0.19 |
|
291 | - * @return array |
|
292 | - */ |
|
293 | - public function prepare_data_for_saving() { |
|
294 | - |
|
295 | - return array( |
|
296 | - 'post_id' => $this->invoice_id, |
|
297 | - 'item_id' => $this->get_id(), |
|
298 | - 'item_name' => sanitize_text_field( $this->get_raw_name() ), |
|
299 | - 'item_description' => $this->get_description(), |
|
300 | - 'tax' => $this->item_tax, |
|
301 | - 'item_price' => $this->get_price(), |
|
302 | - 'quantity' => (int) $this->get_quantity(), |
|
303 | - 'discount' => $this->item_discount, |
|
304 | - 'subtotal' => $this->get_sub_total(), |
|
305 | - 'price' => $this->get_sub_total() + $this->item_tax + $this->item_discount, |
|
306 | - 'meta' => $this->get_item_meta(), |
|
307 | - ); |
|
308 | - |
|
309 | - } |
|
84 | + * Get the item name. |
|
85 | + * |
|
86 | + * @since 1.0.19 |
|
87 | + * @param string $context View or edit context. |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function get_name( $context = 'view' ) { |
|
91 | + $name = parent::get_name( $context ); |
|
92 | + return $name . wpinv_get_item_suffix( $this ); |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Get the item name without a suffix. |
|
97 | + * |
|
98 | + * @since 1.0.19 |
|
99 | + * @param string $context View or edit context. |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + public function get_raw_name( $context = 'view' ) { |
|
103 | + return parent::get_name( $context ); |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Get the item description. |
|
108 | + * |
|
109 | + * @since 1.0.19 |
|
110 | + * @param string $context View or edit context. |
|
111 | + * @return string |
|
112 | + */ |
|
113 | + public function get_description( $context = 'view' ) { |
|
114 | + |
|
115 | + if ( isset( $this->custom_description ) ) { |
|
116 | + return $this->custom_description; |
|
117 | + } |
|
118 | + |
|
119 | + return parent::get_description( $context ); |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Returns the sub total. |
|
124 | + * |
|
125 | + * @since 1.0.19 |
|
126 | + * @param string $context View or edit context. |
|
127 | + * @return float |
|
128 | + */ |
|
129 | + public function get_sub_total( $context = 'view' ) { |
|
130 | + return $this->get_quantity( $context ) * $this->get_initial_price( $context ); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Returns the recurring sub total. |
|
135 | + * |
|
136 | + * @since 1.0.19 |
|
137 | + * @param string $context View or edit context. |
|
138 | + * @return float |
|
139 | + */ |
|
140 | + public function get_recurring_sub_total( $context = 'view' ) { |
|
141 | + |
|
142 | + if ( $this->is_recurring() ) { |
|
143 | + return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
144 | + } |
|
145 | + |
|
146 | + return 0; |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * @deprecated |
|
151 | + */ |
|
152 | + public function get_qantity( $context = 'view' ) { |
|
153 | + return $this->get_quantity( $context ); |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Get the item quantity. |
|
158 | + * |
|
159 | + * @since 1.0.19 |
|
160 | + * @param string $context View or edit context. |
|
161 | + * @return int |
|
162 | + */ |
|
163 | + public function get_quantity( $context = 'view' ) { |
|
164 | + $quantity = (int) $this->quantity; |
|
165 | + |
|
166 | + if ( empty( $quantity ) || 1 > $quantity ) { |
|
167 | + $quantity = 1; |
|
168 | + } |
|
169 | + |
|
170 | + if ( 'view' == $context ) { |
|
171 | + return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
172 | + } |
|
173 | + |
|
174 | + return $quantity; |
|
175 | + |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Get the item meta data. |
|
180 | + * |
|
181 | + * @since 1.0.19 |
|
182 | + * @param string $context View or edit context. |
|
183 | + * @return meta |
|
184 | + */ |
|
185 | + public function get_item_meta( $context = 'view' ) { |
|
186 | + $meta = $this->meta; |
|
187 | + |
|
188 | + if ( 'view' == $context ) { |
|
189 | + return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
190 | + } |
|
191 | + |
|
192 | + return $meta; |
|
193 | + |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * Returns whether or not customers can update the item quantity. |
|
198 | + * |
|
199 | + * @since 1.0.19 |
|
200 | + * @param string $context View or edit context. |
|
201 | + * @return bool |
|
202 | + */ |
|
203 | + public function get_allow_quantities( $context = 'view' ) { |
|
204 | + $allow_quantities = (bool) $this->allow_quantities; |
|
205 | + |
|
206 | + if ( 'view' == $context ) { |
|
207 | + return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
208 | + } |
|
209 | + |
|
210 | + return $allow_quantities; |
|
211 | + |
|
212 | + } |
|
213 | + |
|
214 | + /** |
|
215 | + * Returns whether or not the item is required. |
|
216 | + * |
|
217 | + * @since 1.0.19 |
|
218 | + * @param string $context View or edit context. |
|
219 | + * @return bool |
|
220 | + */ |
|
221 | + public function get_is_required( $context = 'view' ) { |
|
222 | + $is_required = (bool) $this->is_required; |
|
223 | + |
|
224 | + if ( 'view' == $context ) { |
|
225 | + return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
226 | + } |
|
227 | + |
|
228 | + return $is_required; |
|
229 | + |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * Prepares form data for use. |
|
234 | + * |
|
235 | + * @since 1.0.19 |
|
236 | + * @return array |
|
237 | + */ |
|
238 | + public function prepare_data_for_use( $required = null ) { |
|
239 | + |
|
240 | + $required = is_null( $required ) ? $this->is_required() : $required; |
|
241 | + return array( |
|
242 | + 'title' => strip_tags( $this->get_name() ), |
|
243 | + 'id' => $this->get_id(), |
|
244 | + 'price' => $this->get_price(), |
|
245 | + 'recurring' => $this->is_recurring(), |
|
246 | + 'description' => $this->get_description(), |
|
247 | + 'allow_quantities' => $this->allows_quantities(), |
|
248 | + 'required' => $required, |
|
249 | + ); |
|
250 | + |
|
251 | + } |
|
252 | + |
|
253 | + /** |
|
254 | + * Prepares form data for ajax use. |
|
255 | + * |
|
256 | + * @since 1.0.19 |
|
257 | + * @return array |
|
258 | + */ |
|
259 | + public function prepare_data_for_invoice_edit_ajax( $currency = '' ) { |
|
260 | + |
|
261 | + $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
262 | + |
|
263 | + if ( $description ) { |
|
264 | + $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
|
265 | + } |
|
266 | + |
|
267 | + return array( |
|
268 | + 'id' => $this->get_id(), |
|
269 | + 'texts' => array( |
|
270 | + 'item-name' => sanitize_text_field( $this->get_name() ), |
|
271 | + 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
272 | + 'item-quantity' => absint( $this->get_quantity() ), |
|
273 | + 'item-price' => wpinv_price( $this->get_price(), $currency ), |
|
274 | + 'item-total' => wpinv_price( $this->get_sub_total(), $currency ), |
|
275 | + ), |
|
276 | + 'inputs' => array( |
|
277 | + 'item-id' => $this->get_id(), |
|
278 | + 'item-name' => sanitize_text_field( $this->get_name() ), |
|
279 | + 'item-description' => wp_kses_post( $this->get_description() ), |
|
280 | + 'item-quantity' => absint( $this->get_quantity() ), |
|
281 | + 'item-price' => $this->get_price(), |
|
282 | + ) |
|
283 | + ); |
|
284 | + |
|
285 | + } |
|
286 | + |
|
287 | + /** |
|
288 | + * Prepares form data for saving (cart_details). |
|
289 | + * |
|
290 | + * @since 1.0.19 |
|
291 | + * @return array |
|
292 | + */ |
|
293 | + public function prepare_data_for_saving() { |
|
294 | + |
|
295 | + return array( |
|
296 | + 'post_id' => $this->invoice_id, |
|
297 | + 'item_id' => $this->get_id(), |
|
298 | + 'item_name' => sanitize_text_field( $this->get_raw_name() ), |
|
299 | + 'item_description' => $this->get_description(), |
|
300 | + 'tax' => $this->item_tax, |
|
301 | + 'item_price' => $this->get_price(), |
|
302 | + 'quantity' => (int) $this->get_quantity(), |
|
303 | + 'discount' => $this->item_discount, |
|
304 | + 'subtotal' => $this->get_sub_total(), |
|
305 | + 'price' => $this->get_sub_total() + $this->item_tax + $this->item_discount, |
|
306 | + 'meta' => $this->get_item_meta(), |
|
307 | + ); |
|
308 | + |
|
309 | + } |
|
310 | 310 | |
311 | 311 | /* |
312 | 312 | |-------------------------------------------------------------------------- |
@@ -318,70 +318,70 @@ discard block |
||
318 | 318 | | object. |
319 | 319 | */ |
320 | 320 | |
321 | - /** |
|
322 | - * Set the item qantity. |
|
323 | - * |
|
324 | - * @since 1.0.19 |
|
325 | - * @param int $quantity The item quantity. |
|
326 | - */ |
|
327 | - public function set_quantity( $quantity ) { |
|
328 | - |
|
329 | - if ( empty( $quantity ) || ! is_numeric( $quantity ) ) { |
|
330 | - $quantity = 1; |
|
331 | - } |
|
332 | - |
|
333 | - $this->quantity = (int) $quantity; |
|
334 | - |
|
335 | - } |
|
336 | - |
|
337 | - /** |
|
338 | - * Set the item meta data. |
|
339 | - * |
|
340 | - * @since 1.0.19 |
|
341 | - * @param array $meta The item meta data. |
|
342 | - */ |
|
343 | - public function set_item_meta( $meta ) { |
|
344 | - $this->meta = maybe_unserialize( $meta ); |
|
345 | - } |
|
346 | - |
|
347 | - /** |
|
348 | - * Set whether or not the quantities are allowed. |
|
349 | - * |
|
350 | - * @since 1.0.19 |
|
351 | - * @param bool $allow_quantities |
|
352 | - */ |
|
353 | - public function set_allow_quantities( $allow_quantities ) { |
|
354 | - $this->allow_quantities = (bool) $allow_quantities; |
|
355 | - } |
|
356 | - |
|
357 | - /** |
|
358 | - * Set whether or not the item is required. |
|
359 | - * |
|
360 | - * @since 1.0.19 |
|
361 | - * @param bool $is_required |
|
362 | - */ |
|
363 | - public function set_is_required( $is_required ) { |
|
364 | - $this->is_required = (bool) $is_required; |
|
365 | - } |
|
366 | - |
|
367 | - /** |
|
368 | - * Sets the custom item description. |
|
369 | - * |
|
370 | - * @since 1.0.19 |
|
371 | - * @param string $description |
|
372 | - */ |
|
373 | - public function set_custom_description( $description ) { |
|
374 | - $this->custom_description = $description; |
|
375 | - } |
|
321 | + /** |
|
322 | + * Set the item qantity. |
|
323 | + * |
|
324 | + * @since 1.0.19 |
|
325 | + * @param int $quantity The item quantity. |
|
326 | + */ |
|
327 | + public function set_quantity( $quantity ) { |
|
328 | + |
|
329 | + if ( empty( $quantity ) || ! is_numeric( $quantity ) ) { |
|
330 | + $quantity = 1; |
|
331 | + } |
|
332 | + |
|
333 | + $this->quantity = (int) $quantity; |
|
334 | + |
|
335 | + } |
|
336 | + |
|
337 | + /** |
|
338 | + * Set the item meta data. |
|
339 | + * |
|
340 | + * @since 1.0.19 |
|
341 | + * @param array $meta The item meta data. |
|
342 | + */ |
|
343 | + public function set_item_meta( $meta ) { |
|
344 | + $this->meta = maybe_unserialize( $meta ); |
|
345 | + } |
|
346 | + |
|
347 | + /** |
|
348 | + * Set whether or not the quantities are allowed. |
|
349 | + * |
|
350 | + * @since 1.0.19 |
|
351 | + * @param bool $allow_quantities |
|
352 | + */ |
|
353 | + public function set_allow_quantities( $allow_quantities ) { |
|
354 | + $this->allow_quantities = (bool) $allow_quantities; |
|
355 | + } |
|
356 | + |
|
357 | + /** |
|
358 | + * Set whether or not the item is required. |
|
359 | + * |
|
360 | + * @since 1.0.19 |
|
361 | + * @param bool $is_required |
|
362 | + */ |
|
363 | + public function set_is_required( $is_required ) { |
|
364 | + $this->is_required = (bool) $is_required; |
|
365 | + } |
|
366 | + |
|
367 | + /** |
|
368 | + * Sets the custom item description. |
|
369 | + * |
|
370 | + * @since 1.0.19 |
|
371 | + * @param string $description |
|
372 | + */ |
|
373 | + public function set_custom_description( $description ) { |
|
374 | + $this->custom_description = $description; |
|
375 | + } |
|
376 | 376 | |
377 | 377 | /** |
378 | 378 | * We do not want to save items to the database. |
379 | 379 | * |
380 | - * @return int item id |
|
380 | + * @return int item id |
|
381 | 381 | */ |
382 | 382 | public function save( $data = array() ) { |
383 | 383 | return $this->get_id(); |
384 | - } |
|
384 | + } |
|
385 | 385 | |
386 | 386 | /* |
387 | 387 | |-------------------------------------------------------------------------- |
@@ -393,23 +393,23 @@ discard block |
||
393 | 393 | */ |
394 | 394 | |
395 | 395 | /** |
396 | - * Checks whether the item has enabled dynamic pricing. |
|
397 | - * |
|
398 | - * @since 1.0.19 |
|
399 | - * @return bool |
|
400 | - */ |
|
401 | - public function is_required() { |
|
396 | + * Checks whether the item has enabled dynamic pricing. |
|
397 | + * |
|
398 | + * @since 1.0.19 |
|
399 | + * @return bool |
|
400 | + */ |
|
401 | + public function is_required() { |
|
402 | 402 | return (bool) $this->get_is_required(); |
403 | - } |
|
404 | - |
|
405 | - /** |
|
406 | - * Checks whether users can edit the quantities. |
|
407 | - * |
|
408 | - * @since 1.0.19 |
|
409 | - * @return bool |
|
410 | - */ |
|
411 | - public function allows_quantities() { |
|
403 | + } |
|
404 | + |
|
405 | + /** |
|
406 | + * Checks whether users can edit the quantities. |
|
407 | + * |
|
408 | + * @since 1.0.19 |
|
409 | + * @return bool |
|
410 | + */ |
|
411 | + public function allows_quantities() { |
|
412 | 412 | return (bool) $this->get_allow_quantities(); |
413 | - } |
|
413 | + } |
|
414 | 414 | |
415 | 415 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @param string $context View or edit context. |
88 | 88 | * @return string |
89 | 89 | */ |
90 | - public function get_name( $context = 'view' ) { |
|
91 | - $name = parent::get_name( $context ); |
|
92 | - return $name . wpinv_get_item_suffix( $this ); |
|
90 | + public function get_name($context = 'view') { |
|
91 | + $name = parent::get_name($context); |
|
92 | + return $name . wpinv_get_item_suffix($this); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | * @param string $context View or edit context. |
100 | 100 | * @return string |
101 | 101 | */ |
102 | - public function get_raw_name( $context = 'view' ) { |
|
103 | - return parent::get_name( $context ); |
|
102 | + public function get_raw_name($context = 'view') { |
|
103 | + return parent::get_name($context); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | * @param string $context View or edit context. |
111 | 111 | * @return string |
112 | 112 | */ |
113 | - public function get_description( $context = 'view' ) { |
|
113 | + public function get_description($context = 'view') { |
|
114 | 114 | |
115 | - if ( isset( $this->custom_description ) ) { |
|
115 | + if (isset($this->custom_description)) { |
|
116 | 116 | return $this->custom_description; |
117 | 117 | } |
118 | 118 | |
119 | - return parent::get_description( $context ); |
|
119 | + return parent::get_description($context); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @param string $context View or edit context. |
127 | 127 | * @return float |
128 | 128 | */ |
129 | - public function get_sub_total( $context = 'view' ) { |
|
130 | - return $this->get_quantity( $context ) * $this->get_initial_price( $context ); |
|
129 | + public function get_sub_total($context = 'view') { |
|
130 | + return $this->get_quantity($context) * $this->get_initial_price($context); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * @param string $context View or edit context. |
138 | 138 | * @return float |
139 | 139 | */ |
140 | - public function get_recurring_sub_total( $context = 'view' ) { |
|
140 | + public function get_recurring_sub_total($context = 'view') { |
|
141 | 141 | |
142 | - if ( $this->is_recurring() ) { |
|
143 | - return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
142 | + if ($this->is_recurring()) { |
|
143 | + return $this->get_quantity($context) * $this->get_price($context); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | return 0; |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | /** |
150 | 150 | * @deprecated |
151 | 151 | */ |
152 | - public function get_qantity( $context = 'view' ) { |
|
153 | - return $this->get_quantity( $context ); |
|
152 | + public function get_qantity($context = 'view') { |
|
153 | + return $this->get_quantity($context); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -160,15 +160,15 @@ discard block |
||
160 | 160 | * @param string $context View or edit context. |
161 | 161 | * @return int |
162 | 162 | */ |
163 | - public function get_quantity( $context = 'view' ) { |
|
163 | + public function get_quantity($context = 'view') { |
|
164 | 164 | $quantity = (int) $this->quantity; |
165 | 165 | |
166 | - if ( empty( $quantity ) || 1 > $quantity ) { |
|
166 | + if (empty($quantity) || 1 > $quantity) { |
|
167 | 167 | $quantity = 1; |
168 | 168 | } |
169 | 169 | |
170 | - if ( 'view' == $context ) { |
|
171 | - return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
170 | + if ('view' == $context) { |
|
171 | + return apply_filters('getpaid_payment_form_item_quantity', $quantity, $this); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | return $quantity; |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | * @param string $context View or edit context. |
183 | 183 | * @return meta |
184 | 184 | */ |
185 | - public function get_item_meta( $context = 'view' ) { |
|
185 | + public function get_item_meta($context = 'view') { |
|
186 | 186 | $meta = $this->meta; |
187 | 187 | |
188 | - if ( 'view' == $context ) { |
|
189 | - return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
188 | + if ('view' == $context) { |
|
189 | + return apply_filters('getpaid_payment_form_item_meta', $meta, $this); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | return $meta; |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | * @param string $context View or edit context. |
201 | 201 | * @return bool |
202 | 202 | */ |
203 | - public function get_allow_quantities( $context = 'view' ) { |
|
203 | + public function get_allow_quantities($context = 'view') { |
|
204 | 204 | $allow_quantities = (bool) $this->allow_quantities; |
205 | 205 | |
206 | - if ( 'view' == $context ) { |
|
207 | - return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
206 | + if ('view' == $context) { |
|
207 | + return apply_filters('getpaid_payment_form_item_allow_quantities', $allow_quantities, $this); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | return $allow_quantities; |
@@ -218,11 +218,11 @@ discard block |
||
218 | 218 | * @param string $context View or edit context. |
219 | 219 | * @return bool |
220 | 220 | */ |
221 | - public function get_is_required( $context = 'view' ) { |
|
221 | + public function get_is_required($context = 'view') { |
|
222 | 222 | $is_required = (bool) $this->is_required; |
223 | 223 | |
224 | - if ( 'view' == $context ) { |
|
225 | - return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
224 | + if ('view' == $context) { |
|
225 | + return apply_filters('getpaid_payment_form_item_is_required', $is_required, $this); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | return $is_required; |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | * @since 1.0.19 |
236 | 236 | * @return array |
237 | 237 | */ |
238 | - public function prepare_data_for_use( $required = null ) { |
|
238 | + public function prepare_data_for_use($required = null) { |
|
239 | 239 | |
240 | - $required = is_null( $required ) ? $this->is_required() : $required; |
|
240 | + $required = is_null($required) ? $this->is_required() : $required; |
|
241 | 241 | return array( |
242 | - 'title' => strip_tags( $this->get_name() ), |
|
242 | + 'title' => strip_tags($this->get_name()), |
|
243 | 243 | 'id' => $this->get_id(), |
244 | 244 | 'price' => $this->get_price(), |
245 | 245 | 'recurring' => $this->is_recurring(), |
@@ -256,28 +256,28 @@ discard block |
||
256 | 256 | * @since 1.0.19 |
257 | 257 | * @return array |
258 | 258 | */ |
259 | - public function prepare_data_for_invoice_edit_ajax( $currency = '' ) { |
|
259 | + public function prepare_data_for_invoice_edit_ajax($currency = '') { |
|
260 | 260 | |
261 | - $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
261 | + $description = getpaid_item_recurring_price_help_text($this, $currency); |
|
262 | 262 | |
263 | - if ( $description ) { |
|
263 | + if ($description) { |
|
264 | 264 | $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
265 | 265 | } |
266 | 266 | |
267 | 267 | return array( |
268 | 268 | 'id' => $this->get_id(), |
269 | 269 | 'texts' => array( |
270 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
271 | - 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
272 | - 'item-quantity' => absint( $this->get_quantity() ), |
|
273 | - 'item-price' => wpinv_price( $this->get_price(), $currency ), |
|
274 | - 'item-total' => wpinv_price( $this->get_sub_total(), $currency ), |
|
270 | + 'item-name' => sanitize_text_field($this->get_name()), |
|
271 | + 'item-description' => wp_kses_post($this->get_description()) . $description, |
|
272 | + 'item-quantity' => absint($this->get_quantity()), |
|
273 | + 'item-price' => wpinv_price($this->get_price(), $currency), |
|
274 | + 'item-total' => wpinv_price($this->get_sub_total(), $currency), |
|
275 | 275 | ), |
276 | 276 | 'inputs' => array( |
277 | 277 | 'item-id' => $this->get_id(), |
278 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
279 | - 'item-description' => wp_kses_post( $this->get_description() ), |
|
280 | - 'item-quantity' => absint( $this->get_quantity() ), |
|
278 | + 'item-name' => sanitize_text_field($this->get_name()), |
|
279 | + 'item-description' => wp_kses_post($this->get_description()), |
|
280 | + 'item-quantity' => absint($this->get_quantity()), |
|
281 | 281 | 'item-price' => $this->get_price(), |
282 | 282 | ) |
283 | 283 | ); |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | return array( |
296 | 296 | 'post_id' => $this->invoice_id, |
297 | 297 | 'item_id' => $this->get_id(), |
298 | - 'item_name' => sanitize_text_field( $this->get_raw_name() ), |
|
298 | + 'item_name' => sanitize_text_field($this->get_raw_name()), |
|
299 | 299 | 'item_description' => $this->get_description(), |
300 | 300 | 'tax' => $this->item_tax, |
301 | 301 | 'item_price' => $this->get_price(), |
@@ -324,9 +324,9 @@ discard block |
||
324 | 324 | * @since 1.0.19 |
325 | 325 | * @param int $quantity The item quantity. |
326 | 326 | */ |
327 | - public function set_quantity( $quantity ) { |
|
327 | + public function set_quantity($quantity) { |
|
328 | 328 | |
329 | - if ( empty( $quantity ) || ! is_numeric( $quantity ) ) { |
|
329 | + if (empty($quantity) || !is_numeric($quantity)) { |
|
330 | 330 | $quantity = 1; |
331 | 331 | } |
332 | 332 | |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | * @since 1.0.19 |
341 | 341 | * @param array $meta The item meta data. |
342 | 342 | */ |
343 | - public function set_item_meta( $meta ) { |
|
344 | - $this->meta = maybe_unserialize( $meta ); |
|
343 | + public function set_item_meta($meta) { |
|
344 | + $this->meta = maybe_unserialize($meta); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * @since 1.0.19 |
351 | 351 | * @param bool $allow_quantities |
352 | 352 | */ |
353 | - public function set_allow_quantities( $allow_quantities ) { |
|
353 | + public function set_allow_quantities($allow_quantities) { |
|
354 | 354 | $this->allow_quantities = (bool) $allow_quantities; |
355 | 355 | } |
356 | 356 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @since 1.0.19 |
361 | 361 | * @param bool $is_required |
362 | 362 | */ |
363 | - public function set_is_required( $is_required ) { |
|
363 | + public function set_is_required($is_required) { |
|
364 | 364 | $this->is_required = (bool) $is_required; |
365 | 365 | } |
366 | 366 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | * @since 1.0.19 |
371 | 371 | * @param string $description |
372 | 372 | */ |
373 | - public function set_custom_description( $description ) { |
|
373 | + public function set_custom_description($description) { |
|
374 | 374 | $this->custom_description = $description; |
375 | 375 | } |
376 | 376 | |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @return int item id |
381 | 381 | */ |
382 | - public function save( $data = array() ) { |
|
382 | + public function save($data = array()) { |
|
383 | 383 | return $this->get_id(); |
384 | 384 | } |
385 | 385 |