@@ -13,738 +13,738 @@ 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 | - add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
34 | - add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
35 | - |
|
36 | - // Items table columns. |
|
37 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
38 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
39 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
40 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
41 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
42 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
43 | - |
|
44 | - // Payment forms columns. |
|
45 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
46 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
47 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
48 | - |
|
49 | - // Discount table columns. |
|
50 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
51 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
52 | - |
|
53 | - // Deleting posts. |
|
54 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
55 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
56 | - |
|
57 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Post updated messages. |
|
62 | - */ |
|
63 | - public static function post_updated_messages( $messages ) { |
|
64 | - global $post; |
|
65 | - |
|
66 | - $messages['wpi_discount'] = array( |
|
67 | - 0 => '', |
|
68 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
69 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
70 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
71 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
72 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
73 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
74 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
75 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
76 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
77 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
78 | - ); |
|
79 | - |
|
80 | - $messages['wpi_payment_form'] = array( |
|
81 | - 0 => '', |
|
82 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
83 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
84 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
85 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
87 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
88 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
89 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
90 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
91 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
92 | - ); |
|
93 | - |
|
94 | - return $messages; |
|
95 | - |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Post row actions. |
|
100 | - */ |
|
101 | - public static function post_row_actions( $actions, $post ) { |
|
102 | - |
|
103 | - $post = get_post( $post ); |
|
104 | - |
|
105 | - // We do not want to edit the default payment form. |
|
106 | - if ( 'wpi_payment_form' == $post->post_type ) { |
|
107 | - |
|
108 | - if ( wpinv_get_default_payment_form() === $post->ID ) { |
|
109 | - unset( $actions['trash'] ); |
|
110 | - unset( $actions['inline hide-if-no-js'] ); |
|
111 | - } |
|
112 | - |
|
113 | - $actions['duplicate'] = sprintf( |
|
114 | - '<a href="%1$s">%2$s</a>', |
|
115 | - esc_url( |
|
116 | - wp_nonce_url( |
|
117 | - add_query_arg( |
|
118 | - array( |
|
119 | - 'getpaid-admin-action' => 'duplicate_form', |
|
120 | - 'form_id' => $post->ID, |
|
121 | - ) |
|
122 | - ), |
|
123 | - 'getpaid-nonce', |
|
124 | - 'getpaid-nonce' |
|
125 | - ) |
|
126 | - ), |
|
127 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
128 | - ); |
|
129 | - |
|
130 | - $actions['reset'] = sprintf( |
|
131 | - '<a href="%1$s" style="color: #800">%2$s</a>', |
|
132 | - esc_url( |
|
133 | - wp_nonce_url( |
|
134 | - add_query_arg( |
|
135 | - array( |
|
136 | - 'getpaid-admin-action' => 'reset_form_stats', |
|
137 | - 'form_id' => $post->ID, |
|
138 | - ) |
|
139 | - ), |
|
140 | - 'getpaid-nonce', |
|
141 | - 'getpaid-nonce' |
|
142 | - ) |
|
143 | - ), |
|
144 | - esc_html( __( 'Reset Stats', 'invoicing' ) ) |
|
145 | - ); |
|
146 | - } |
|
147 | - |
|
148 | - // Link to item payment form. |
|
149 | - if ( 'wpi_item' == $post->post_type ) { |
|
150 | - if ( getpaid_item_type_supports( get_post_meta( $post->ID, '_wpinv_type', true ), 'buy_now' ) ) { |
|
151 | - $actions['buy'] = sprintf( |
|
152 | - '<a href="%1$s">%2$s</a>', |
|
153 | - esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
154 | - esc_html( __( 'Buy', 'invoicing' ) ) |
|
155 | - ); |
|
156 | - } |
|
157 | - } |
|
158 | - |
|
159 | - return $actions; |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
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 | + add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
34 | + add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
35 | + |
|
36 | + // Items table columns. |
|
37 | + add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
38 | + add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
39 | + add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
40 | + add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
41 | + add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
42 | + add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
43 | + |
|
44 | + // Payment forms columns. |
|
45 | + add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
46 | + add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
47 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
48 | + |
|
49 | + // Discount table columns. |
|
50 | + add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
51 | + add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
52 | + |
|
53 | + // Deleting posts. |
|
54 | + add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
55 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
56 | + |
|
57 | + add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Post updated messages. |
|
62 | + */ |
|
63 | + public static function post_updated_messages( $messages ) { |
|
64 | + global $post; |
|
65 | + |
|
66 | + $messages['wpi_discount'] = array( |
|
67 | + 0 => '', |
|
68 | + 1 => __( 'Discount updated.', 'invoicing' ), |
|
69 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
70 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
71 | + 4 => __( 'Discount updated.', 'invoicing' ), |
|
72 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
73 | + 6 => __( 'Discount updated.', 'invoicing' ), |
|
74 | + 7 => __( 'Discount saved.', 'invoicing' ), |
|
75 | + 8 => __( 'Discount submitted.', 'invoicing' ), |
|
76 | + 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
77 | + 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
78 | + ); |
|
79 | + |
|
80 | + $messages['wpi_payment_form'] = array( |
|
81 | + 0 => '', |
|
82 | + 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
83 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
84 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
85 | + 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
87 | + 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
88 | + 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
89 | + 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
90 | + 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
91 | + 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
92 | + ); |
|
93 | + |
|
94 | + return $messages; |
|
95 | + |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Post row actions. |
|
100 | + */ |
|
101 | + public static function post_row_actions( $actions, $post ) { |
|
102 | + |
|
103 | + $post = get_post( $post ); |
|
104 | + |
|
105 | + // We do not want to edit the default payment form. |
|
106 | + if ( 'wpi_payment_form' == $post->post_type ) { |
|
107 | + |
|
108 | + if ( wpinv_get_default_payment_form() === $post->ID ) { |
|
109 | + unset( $actions['trash'] ); |
|
110 | + unset( $actions['inline hide-if-no-js'] ); |
|
111 | + } |
|
112 | + |
|
113 | + $actions['duplicate'] = sprintf( |
|
114 | + '<a href="%1$s">%2$s</a>', |
|
115 | + esc_url( |
|
116 | + wp_nonce_url( |
|
117 | + add_query_arg( |
|
118 | + array( |
|
119 | + 'getpaid-admin-action' => 'duplicate_form', |
|
120 | + 'form_id' => $post->ID, |
|
121 | + ) |
|
122 | + ), |
|
123 | + 'getpaid-nonce', |
|
124 | + 'getpaid-nonce' |
|
125 | + ) |
|
126 | + ), |
|
127 | + esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
128 | + ); |
|
129 | + |
|
130 | + $actions['reset'] = sprintf( |
|
131 | + '<a href="%1$s" style="color: #800">%2$s</a>', |
|
132 | + esc_url( |
|
133 | + wp_nonce_url( |
|
134 | + add_query_arg( |
|
135 | + array( |
|
136 | + 'getpaid-admin-action' => 'reset_form_stats', |
|
137 | + 'form_id' => $post->ID, |
|
138 | + ) |
|
139 | + ), |
|
140 | + 'getpaid-nonce', |
|
141 | + 'getpaid-nonce' |
|
142 | + ) |
|
143 | + ), |
|
144 | + esc_html( __( 'Reset Stats', 'invoicing' ) ) |
|
145 | + ); |
|
146 | + } |
|
147 | + |
|
148 | + // Link to item payment form. |
|
149 | + if ( 'wpi_item' == $post->post_type ) { |
|
150 | + if ( getpaid_item_type_supports( get_post_meta( $post->ID, '_wpinv_type', true ), 'buy_now' ) ) { |
|
151 | + $actions['buy'] = sprintf( |
|
152 | + '<a href="%1$s">%2$s</a>', |
|
153 | + esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
154 | + esc_html( __( 'Buy', 'invoicing' ) ) |
|
155 | + ); |
|
156 | + } |
|
157 | + } |
|
158 | + |
|
159 | + return $actions; |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | 163 | * Remove bulk edit option from admin side quote listing |
164 | 164 | * |
165 | 165 | * @since 1.0.0 |
166 | 166 | * @param array $actions post actions |
167 | - * @param WP_Post $post |
|
167 | + * @param WP_Post $post |
|
168 | 168 | * @return array $actions actions without edit option |
169 | 169 | */ |
170 | 170 | public static function filter_invoice_row_actions( $actions, $post ) { |
171 | 171 | |
172 | 172 | if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
173 | 173 | |
174 | - $actions = array(); |
|
175 | - $invoice = new WPInv_Invoice( $post ); |
|
176 | - |
|
177 | - $actions['edit'] = sprintf( |
|
178 | - '<a href="%1$s">%2$s</a>', |
|
179 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
180 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
181 | - ); |
|
182 | - |
|
183 | - if ( ! $invoice->is_draft() ) { |
|
184 | - |
|
185 | - $actions['view'] = sprintf( |
|
186 | - '<a href="%1$s">%2$s</a>', |
|
187 | - esc_url( $invoice->get_view_url() ), |
|
188 | - sprintf( |
|
189 | - // translators: %s is the invoice type |
|
190 | - esc_html__( 'View %s', 'invoicing' ), |
|
191 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
192 | - ) |
|
193 | - ); |
|
194 | - |
|
195 | - $actions['send'] = sprintf( |
|
196 | - '<a href="%1$s">%2$s</a>', |
|
197 | - esc_url( |
|
198 | - wp_nonce_url( |
|
199 | - add_query_arg( |
|
200 | - array( |
|
201 | - 'getpaid-admin-action' => 'send_invoice', |
|
202 | - 'invoice_id' => $invoice->get_id(), |
|
203 | - ) |
|
204 | - ), |
|
205 | - 'getpaid-nonce', |
|
206 | - 'getpaid-nonce' |
|
207 | - ) |
|
208 | - ), |
|
209 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
210 | - ); |
|
211 | - |
|
212 | - } |
|
213 | - |
|
214 | - $actions['duplicate'] = sprintf( |
|
215 | - '<a href="%1$s">%2$s</a>', |
|
216 | - esc_url( |
|
217 | - wp_nonce_url( |
|
218 | - add_query_arg( |
|
219 | - array( |
|
220 | - 'getpaid-admin-action' => 'duplicate_invoice', |
|
221 | - 'invoice_id' => $post->ID, |
|
222 | - ) |
|
223 | - ), |
|
224 | - 'getpaid-nonce', |
|
225 | - 'getpaid-nonce' |
|
226 | - ) |
|
227 | - ), |
|
228 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
229 | - ); |
|
174 | + $actions = array(); |
|
175 | + $invoice = new WPInv_Invoice( $post ); |
|
176 | + |
|
177 | + $actions['edit'] = sprintf( |
|
178 | + '<a href="%1$s">%2$s</a>', |
|
179 | + esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
180 | + esc_html( __( 'Edit', 'invoicing' ) ) |
|
181 | + ); |
|
182 | + |
|
183 | + if ( ! $invoice->is_draft() ) { |
|
184 | + |
|
185 | + $actions['view'] = sprintf( |
|
186 | + '<a href="%1$s">%2$s</a>', |
|
187 | + esc_url( $invoice->get_view_url() ), |
|
188 | + sprintf( |
|
189 | + // translators: %s is the invoice type |
|
190 | + esc_html__( 'View %s', 'invoicing' ), |
|
191 | + getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
192 | + ) |
|
193 | + ); |
|
194 | + |
|
195 | + $actions['send'] = sprintf( |
|
196 | + '<a href="%1$s">%2$s</a>', |
|
197 | + esc_url( |
|
198 | + wp_nonce_url( |
|
199 | + add_query_arg( |
|
200 | + array( |
|
201 | + 'getpaid-admin-action' => 'send_invoice', |
|
202 | + 'invoice_id' => $invoice->get_id(), |
|
203 | + ) |
|
204 | + ), |
|
205 | + 'getpaid-nonce', |
|
206 | + 'getpaid-nonce' |
|
207 | + ) |
|
208 | + ), |
|
209 | + esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
210 | + ); |
|
211 | + |
|
212 | + } |
|
213 | + |
|
214 | + $actions['duplicate'] = sprintf( |
|
215 | + '<a href="%1$s">%2$s</a>', |
|
216 | + esc_url( |
|
217 | + wp_nonce_url( |
|
218 | + add_query_arg( |
|
219 | + array( |
|
220 | + 'getpaid-admin-action' => 'duplicate_invoice', |
|
221 | + 'invoice_id' => $post->ID, |
|
222 | + ) |
|
223 | + ), |
|
224 | + 'getpaid-nonce', |
|
225 | + 'getpaid-nonce' |
|
226 | + ) |
|
227 | + ), |
|
228 | + esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
229 | + ); |
|
230 | 230 | |
231 | 231 | } |
232 | 232 | |
233 | 233 | return $actions; |
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * Returns an array of invoice table columns. |
|
238 | - */ |
|
239 | - public static function invoice_columns( $columns ) { |
|
240 | - |
|
241 | - $columns = array( |
|
242 | - 'cb' => $columns['cb'], |
|
243 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
244 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
245 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
246 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
247 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
248 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
249 | - 'status' => __( 'Status', 'invoicing' ), |
|
250 | - ); |
|
251 | - |
|
252 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
253 | - } |
|
254 | - |
|
255 | - /** |
|
256 | - * Displays invoice table columns. |
|
257 | - */ |
|
258 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
259 | - |
|
260 | - $invoice = new WPInv_Invoice( $post_id ); |
|
261 | - |
|
262 | - switch ( $column_name ) { |
|
263 | - |
|
264 | - case 'invoice_date': |
|
265 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
266 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
267 | - echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
268 | - break; |
|
269 | - |
|
270 | - case 'payment_date': |
|
271 | - if ( $invoice->is_paid() ) { |
|
272 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
273 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
274 | - echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
275 | - } else { |
|
276 | - echo '—'; |
|
277 | - } |
|
278 | - |
|
279 | - break; |
|
280 | - |
|
281 | - case 'amount': |
|
282 | - $amount = $invoice->get_total(); |
|
283 | - $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) ); |
|
284 | - |
|
285 | - if ( $invoice->is_refunded() ) { |
|
286 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
287 | - echo wp_kses_post( "<del>$formated_amount</del> <ins>$refunded_amount</ins>" ); |
|
288 | - } else { |
|
289 | - |
|
290 | - $discount = $invoice->get_total_discount(); |
|
291 | - |
|
292 | - if ( ! empty( $discount ) ) { |
|
293 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
294 | - echo wp_kses_post( "<del>$new_amount</del> <ins>$formated_amount</ins>" ); |
|
295 | - } else { |
|
296 | - echo wp_kses_post( $formated_amount ); |
|
297 | - } |
|
298 | - } |
|
299 | - |
|
300 | - break; |
|
301 | - |
|
302 | - case 'status': |
|
303 | - $status = esc_html( $invoice->get_status() ); |
|
304 | - $status_label = esc_html( $invoice->get_status_nicename() ); |
|
305 | - |
|
306 | - // If it is paid, show the gateway title. |
|
307 | - if ( $invoice->is_paid() ) { |
|
308 | - $gateway = esc_html( $invoice->get_gateway_title() ); |
|
309 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) ); |
|
310 | - |
|
311 | - echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" ); |
|
312 | - } else { |
|
313 | - echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" ); |
|
314 | - } |
|
315 | - |
|
316 | - // If it is not paid, display the overdue and view status. |
|
317 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
318 | - |
|
319 | - // Invoice view status. |
|
320 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
321 | - echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
322 | - } else { |
|
323 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
324 | - } |
|
325 | - |
|
326 | - // Display the overview status. |
|
327 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
328 | - $due_date = $invoice->get_due_date(); |
|
329 | - $fomatted = getpaid_format_date( $due_date ); |
|
330 | - |
|
331 | - if ( ! empty( $fomatted ) ) { |
|
332 | - $date = wp_sprintf( |
|
333 | - // translators: %s is the due date. |
|
334 | - __( 'Due %s', 'invoicing' ), |
|
335 | - $fomatted |
|
336 | - ); |
|
337 | - echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" ); |
|
338 | - } |
|
339 | - } |
|
340 | - } |
|
341 | - |
|
342 | - break; |
|
343 | - |
|
344 | - case 'recurring': |
|
345 | - if ( $invoice->is_recurring() ) { |
|
346 | - echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
347 | - } else { |
|
348 | - echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
349 | - } |
|
350 | - break; |
|
351 | - |
|
352 | - case 'number': |
|
353 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
354 | - $invoice_number = esc_html( $invoice->get_number() ); |
|
355 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
356 | - |
|
357 | - echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" ); |
|
358 | - |
|
359 | - do_action( 'getpaid_admin_table_invoice_number_column', $invoice ); |
|
360 | - break; |
|
361 | - |
|
362 | - case 'customer': |
|
363 | - $customer_name = $invoice->get_user_full_name(); |
|
364 | - |
|
365 | - if ( empty( $customer_name ) ) { |
|
366 | - $customer_name = $invoice->get_email(); |
|
367 | - } |
|
368 | - |
|
369 | - if ( ! empty( $customer_name ) ) { |
|
370 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
371 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
372 | - echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" ); |
|
373 | - } else { |
|
374 | - echo '<div>—</div>'; |
|
375 | - } |
|
376 | - |
|
377 | - break; |
|
378 | - |
|
379 | - } |
|
380 | - |
|
381 | - } |
|
382 | - |
|
383 | - /** |
|
384 | - * Displays invoice bulk actions. |
|
385 | - */ |
|
386 | - public static function invoice_bulk_actions( $actions ) { |
|
387 | - $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
388 | - return $actions; |
|
389 | - } |
|
390 | - |
|
391 | - /** |
|
392 | - * Processes invoice bulk actions. |
|
393 | - */ |
|
394 | - public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
395 | - |
|
396 | - if ( 'resend-invoice' === $action ) { |
|
397 | - foreach ( $post_ids as $post_id ) { |
|
398 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
399 | - } |
|
400 | - } |
|
401 | - |
|
402 | - return $redirect_url; |
|
403 | - |
|
404 | - } |
|
405 | - |
|
406 | - /** |
|
407 | - * Returns an array of payment forms table columns. |
|
408 | - */ |
|
409 | - public static function payment_form_columns( $columns ) { |
|
410 | - |
|
411 | - $columns = array( |
|
412 | - 'cb' => $columns['cb'], |
|
413 | - 'title' => __( 'Name', 'invoicing' ), |
|
414 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
415 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
416 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
417 | - 'items' => __( 'Items', 'invoicing' ), |
|
418 | - 'date' => __( 'Date', 'invoicing' ), |
|
419 | - ); |
|
420 | - |
|
421 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
422 | - |
|
423 | - } |
|
424 | - |
|
425 | - /** |
|
426 | - * Displays payment form table columns. |
|
427 | - */ |
|
428 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
429 | - |
|
430 | - // Retrieve the payment form. |
|
431 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
432 | - |
|
433 | - switch ( $column_name ) { |
|
434 | - |
|
435 | - case 'earnings': |
|
436 | - echo wp_kses_post( wpinv_price( $form->get_earned() ) ); |
|
437 | - break; |
|
438 | - |
|
439 | - case 'refunds': |
|
440 | - echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
441 | - break; |
|
442 | - |
|
443 | - case 'refunds': |
|
444 | - echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
445 | - break; |
|
446 | - |
|
447 | - case 'shortcode': |
|
448 | - if ( $form->is_default() ) { |
|
449 | - echo '—'; |
|
450 | - } else { |
|
451 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
452 | - } |
|
453 | - |
|
454 | - break; |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * Returns an array of invoice table columns. |
|
238 | + */ |
|
239 | + public static function invoice_columns( $columns ) { |
|
240 | + |
|
241 | + $columns = array( |
|
242 | + 'cb' => $columns['cb'], |
|
243 | + 'number' => __( 'Invoice', 'invoicing' ), |
|
244 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
245 | + 'invoice_date' => __( 'Created', 'invoicing' ), |
|
246 | + 'payment_date' => __( 'Completed', 'invoicing' ), |
|
247 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
248 | + 'recurring' => __( 'Recurring', 'invoicing' ), |
|
249 | + 'status' => __( 'Status', 'invoicing' ), |
|
250 | + ); |
|
251 | + |
|
252 | + return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
253 | + } |
|
254 | + |
|
255 | + /** |
|
256 | + * Displays invoice table columns. |
|
257 | + */ |
|
258 | + public static function display_invoice_columns( $column_name, $post_id ) { |
|
259 | + |
|
260 | + $invoice = new WPInv_Invoice( $post_id ); |
|
261 | + |
|
262 | + switch ( $column_name ) { |
|
263 | + |
|
264 | + case 'invoice_date': |
|
265 | + $date_time = esc_attr( $invoice->get_created_date() ); |
|
266 | + $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
267 | + echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
268 | + break; |
|
269 | + |
|
270 | + case 'payment_date': |
|
271 | + if ( $invoice->is_paid() ) { |
|
272 | + $date_time = esc_attr( $invoice->get_completed_date() ); |
|
273 | + $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
274 | + echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
275 | + } else { |
|
276 | + echo '—'; |
|
277 | + } |
|
278 | + |
|
279 | + break; |
|
280 | + |
|
281 | + case 'amount': |
|
282 | + $amount = $invoice->get_total(); |
|
283 | + $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) ); |
|
284 | + |
|
285 | + if ( $invoice->is_refunded() ) { |
|
286 | + $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
287 | + echo wp_kses_post( "<del>$formated_amount</del> <ins>$refunded_amount</ins>" ); |
|
288 | + } else { |
|
289 | + |
|
290 | + $discount = $invoice->get_total_discount(); |
|
291 | + |
|
292 | + if ( ! empty( $discount ) ) { |
|
293 | + $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
294 | + echo wp_kses_post( "<del>$new_amount</del> <ins>$formated_amount</ins>" ); |
|
295 | + } else { |
|
296 | + echo wp_kses_post( $formated_amount ); |
|
297 | + } |
|
298 | + } |
|
299 | + |
|
300 | + break; |
|
301 | + |
|
302 | + case 'status': |
|
303 | + $status = esc_html( $invoice->get_status() ); |
|
304 | + $status_label = esc_html( $invoice->get_status_nicename() ); |
|
305 | + |
|
306 | + // If it is paid, show the gateway title. |
|
307 | + if ( $invoice->is_paid() ) { |
|
308 | + $gateway = esc_html( $invoice->get_gateway_title() ); |
|
309 | + $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) ); |
|
310 | + |
|
311 | + echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" ); |
|
312 | + } else { |
|
313 | + echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" ); |
|
314 | + } |
|
315 | + |
|
316 | + // If it is not paid, display the overdue and view status. |
|
317 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
318 | + |
|
319 | + // Invoice view status. |
|
320 | + if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
321 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
322 | + } else { |
|
323 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
324 | + } |
|
325 | + |
|
326 | + // Display the overview status. |
|
327 | + if ( wpinv_get_option( 'overdue_active' ) ) { |
|
328 | + $due_date = $invoice->get_due_date(); |
|
329 | + $fomatted = getpaid_format_date( $due_date ); |
|
330 | + |
|
331 | + if ( ! empty( $fomatted ) ) { |
|
332 | + $date = wp_sprintf( |
|
333 | + // translators: %s is the due date. |
|
334 | + __( 'Due %s', 'invoicing' ), |
|
335 | + $fomatted |
|
336 | + ); |
|
337 | + echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" ); |
|
338 | + } |
|
339 | + } |
|
340 | + } |
|
341 | + |
|
342 | + break; |
|
343 | + |
|
344 | + case 'recurring': |
|
345 | + if ( $invoice->is_recurring() ) { |
|
346 | + echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
347 | + } else { |
|
348 | + echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
349 | + } |
|
350 | + break; |
|
351 | + |
|
352 | + case 'number': |
|
353 | + $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
354 | + $invoice_number = esc_html( $invoice->get_number() ); |
|
355 | + $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
356 | + |
|
357 | + echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" ); |
|
358 | + |
|
359 | + do_action( 'getpaid_admin_table_invoice_number_column', $invoice ); |
|
360 | + break; |
|
361 | + |
|
362 | + case 'customer': |
|
363 | + $customer_name = $invoice->get_user_full_name(); |
|
364 | + |
|
365 | + if ( empty( $customer_name ) ) { |
|
366 | + $customer_name = $invoice->get_email(); |
|
367 | + } |
|
368 | + |
|
369 | + if ( ! empty( $customer_name ) ) { |
|
370 | + $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
371 | + $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
372 | + echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" ); |
|
373 | + } else { |
|
374 | + echo '<div>—</div>'; |
|
375 | + } |
|
376 | + |
|
377 | + break; |
|
455 | 378 | |
456 | - case 'items': |
|
457 | - $items = $form->get_items(); |
|
458 | - |
|
459 | - if ( $form->is_default() || empty( $items ) ) { |
|
460 | - echo '—'; |
|
461 | - return; |
|
462 | - } |
|
463 | - |
|
464 | - $_items = array(); |
|
465 | - |
|
466 | - foreach ( $items as $item ) { |
|
467 | - $url = $item->get_edit_url(); |
|
468 | - |
|
469 | - if ( empty( $url ) ) { |
|
470 | - $_items[] = esc_html( $item->get_name() ); |
|
471 | - } else { |
|
472 | - $_items[] = sprintf( |
|
473 | - '<a href="%s">%s</a>', |
|
474 | - esc_url( $url ), |
|
475 | - esc_html( $item->get_name() ) |
|
476 | - ); |
|
477 | - } |
|
379 | + } |
|
380 | + |
|
381 | + } |
|
382 | + |
|
383 | + /** |
|
384 | + * Displays invoice bulk actions. |
|
385 | + */ |
|
386 | + public static function invoice_bulk_actions( $actions ) { |
|
387 | + $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
388 | + return $actions; |
|
389 | + } |
|
390 | + |
|
391 | + /** |
|
392 | + * Processes invoice bulk actions. |
|
393 | + */ |
|
394 | + public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
395 | + |
|
396 | + if ( 'resend-invoice' === $action ) { |
|
397 | + foreach ( $post_ids as $post_id ) { |
|
398 | + getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
399 | + } |
|
400 | + } |
|
401 | + |
|
402 | + return $redirect_url; |
|
403 | + |
|
404 | + } |
|
405 | + |
|
406 | + /** |
|
407 | + * Returns an array of payment forms table columns. |
|
408 | + */ |
|
409 | + public static function payment_form_columns( $columns ) { |
|
410 | + |
|
411 | + $columns = array( |
|
412 | + 'cb' => $columns['cb'], |
|
413 | + 'title' => __( 'Name', 'invoicing' ), |
|
414 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
415 | + 'earnings' => __( 'Revenue', 'invoicing' ), |
|
416 | + 'refunds' => __( 'Refunded', 'invoicing' ), |
|
417 | + 'items' => __( 'Items', 'invoicing' ), |
|
418 | + 'date' => __( 'Date', 'invoicing' ), |
|
419 | + ); |
|
420 | + |
|
421 | + return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
422 | + |
|
423 | + } |
|
424 | + |
|
425 | + /** |
|
426 | + * Displays payment form table columns. |
|
427 | + */ |
|
428 | + public static function display_payment_form_columns( $column_name, $post_id ) { |
|
429 | + |
|
430 | + // Retrieve the payment form. |
|
431 | + $form = new GetPaid_Payment_Form( $post_id ); |
|
432 | + |
|
433 | + switch ( $column_name ) { |
|
434 | + |
|
435 | + case 'earnings': |
|
436 | + echo wp_kses_post( wpinv_price( $form->get_earned() ) ); |
|
437 | + break; |
|
438 | + |
|
439 | + case 'refunds': |
|
440 | + echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
441 | + break; |
|
442 | + |
|
443 | + case 'refunds': |
|
444 | + echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
445 | + break; |
|
446 | + |
|
447 | + case 'shortcode': |
|
448 | + if ( $form->is_default() ) { |
|
449 | + echo '—'; |
|
450 | + } else { |
|
451 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
452 | + } |
|
453 | + |
|
454 | + break; |
|
455 | + |
|
456 | + case 'items': |
|
457 | + $items = $form->get_items(); |
|
458 | + |
|
459 | + if ( $form->is_default() || empty( $items ) ) { |
|
460 | + echo '—'; |
|
461 | + return; |
|
462 | + } |
|
463 | + |
|
464 | + $_items = array(); |
|
465 | + |
|
466 | + foreach ( $items as $item ) { |
|
467 | + $url = $item->get_edit_url(); |
|
468 | + |
|
469 | + if ( empty( $url ) ) { |
|
470 | + $_items[] = esc_html( $item->get_name() ); |
|
471 | + } else { |
|
472 | + $_items[] = sprintf( |
|
473 | + '<a href="%s">%s</a>', |
|
474 | + esc_url( $url ), |
|
475 | + esc_html( $item->get_name() ) |
|
476 | + ); |
|
477 | + } |
|
478 | 478 | } |
479 | 479 | |
480 | - echo wp_kses_post( implode( '<br>', $_items ) ); |
|
480 | + echo wp_kses_post( implode( '<br>', $_items ) ); |
|
481 | + |
|
482 | + break; |
|
483 | + |
|
484 | + } |
|
485 | + |
|
486 | + } |
|
487 | + |
|
488 | + /** |
|
489 | + * Filters post states. |
|
490 | + */ |
|
491 | + public static function filter_payment_form_state( $post_states, $post ) { |
|
492 | + |
|
493 | + if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) { |
|
494 | + $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' ); |
|
495 | + } |
|
496 | + |
|
497 | + return $post_states; |
|
498 | + |
|
499 | + } |
|
500 | + |
|
501 | + /** |
|
502 | + * Returns an array of coupon table columns. |
|
503 | + */ |
|
504 | + public static function discount_columns( $columns ) { |
|
505 | + |
|
506 | + $columns = array( |
|
507 | + 'cb' => $columns['cb'], |
|
508 | + 'title' => __( 'Name', 'invoicing' ), |
|
509 | + 'code' => __( 'Code', 'invoicing' ), |
|
510 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
511 | + 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
512 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
513 | + 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
514 | + ); |
|
515 | + |
|
516 | + return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
517 | + } |
|
481 | 518 | |
482 | - break; |
|
519 | + /** |
|
520 | + * Filters post states. |
|
521 | + */ |
|
522 | + public static function filter_discount_state( $post_states, $post ) { |
|
483 | 523 | |
484 | - } |
|
524 | + if ( 'wpi_discount' === $post->post_type ) { |
|
485 | 525 | |
486 | - } |
|
526 | + $discount = new WPInv_Discount( $post ); |
|
487 | 527 | |
488 | - /** |
|
489 | - * Filters post states. |
|
490 | - */ |
|
491 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
528 | + $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
492 | 529 | |
493 | - if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) { |
|
494 | - $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' ); |
|
495 | - } |
|
530 | + if ( 'publish' !== $status ) { |
|
531 | + return array( |
|
532 | + 'discount_status' => wpinv_discount_status( $status ), |
|
533 | + ); |
|
534 | + } |
|
535 | + |
|
536 | + return array(); |
|
537 | + |
|
538 | + } |
|
539 | + |
|
540 | + return $post_states; |
|
496 | 541 | |
497 | - return $post_states; |
|
542 | + } |
|
498 | 543 | |
499 | - } |
|
544 | + /** |
|
545 | + * Returns an array of items table columns. |
|
546 | + */ |
|
547 | + public static function item_columns( $columns ) { |
|
548 | + |
|
549 | + $columns = array( |
|
550 | + 'cb' => $columns['cb'], |
|
551 | + 'title' => __( 'Name', 'invoicing' ), |
|
552 | + 'price' => __( 'Price', 'invoicing' ), |
|
553 | + 'vat_rule' => __( 'Tax Rule', 'invoicing' ), |
|
554 | + 'vat_class' => __( 'Tax Class', 'invoicing' ), |
|
555 | + 'type' => __( 'Type', 'invoicing' ), |
|
556 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
557 | + ); |
|
558 | + |
|
559 | + if ( ! wpinv_use_taxes() ) { |
|
560 | + unset( $columns['vat_rule'] ); |
|
561 | + unset( $columns['vat_class'] ); |
|
562 | + } |
|
500 | 563 | |
501 | - /** |
|
502 | - * Returns an array of coupon table columns. |
|
503 | - */ |
|
504 | - public static function discount_columns( $columns ) { |
|
564 | + return apply_filters( 'wpi_item_table_columns', $columns ); |
|
565 | + } |
|
505 | 566 | |
506 | - $columns = array( |
|
507 | - 'cb' => $columns['cb'], |
|
508 | - 'title' => __( 'Name', 'invoicing' ), |
|
509 | - 'code' => __( 'Code', 'invoicing' ), |
|
510 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
511 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
512 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
513 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
514 | - ); |
|
567 | + /** |
|
568 | + * Returns an array of sortable items table columns. |
|
569 | + */ |
|
570 | + public static function sortable_item_columns( $columns ) { |
|
571 | + |
|
572 | + return array_merge( |
|
573 | + $columns, |
|
574 | + array( |
|
575 | + 'price' => 'price', |
|
576 | + 'vat_rule' => 'vat_rule', |
|
577 | + 'vat_class' => 'vat_class', |
|
578 | + 'type' => 'type', |
|
579 | + ) |
|
580 | + ); |
|
515 | 581 | |
516 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
517 | - } |
|
582 | + } |
|
518 | 583 | |
519 | - /** |
|
520 | - * Filters post states. |
|
521 | - */ |
|
522 | - public static function filter_discount_state( $post_states, $post ) { |
|
584 | + /** |
|
585 | + * Displays items table columns. |
|
586 | + */ |
|
587 | + public static function display_item_columns( $column_name, $post_id ) { |
|
523 | 588 | |
524 | - if ( 'wpi_discount' === $post->post_type ) { |
|
589 | + $item = new WPInv_Item( $post_id ); |
|
525 | 590 | |
526 | - $discount = new WPInv_Discount( $post ); |
|
591 | + switch ( $column_name ) { |
|
527 | 592 | |
528 | - $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
593 | + case 'price': |
|
594 | + if ( ! $item->is_recurring() ) { |
|
595 | + echo wp_kses_post( $item->get_the_price() ); |
|
596 | + break; |
|
597 | + } |
|
529 | 598 | |
530 | - if ( 'publish' !== $status ) { |
|
531 | - return array( |
|
532 | - 'discount_status' => wpinv_discount_status( $status ), |
|
533 | - ); |
|
534 | - } |
|
599 | + $price = wp_sprintf( |
|
600 | + __( '%1$s / %2$s', 'invoicing' ), |
|
601 | + $item->get_the_price(), |
|
602 | + getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
603 | + ); |
|
535 | 604 | |
536 | - return array(); |
|
605 | + if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
606 | + echo wp_kses_post( $price ); |
|
607 | + break; |
|
608 | + } |
|
537 | 609 | |
538 | - } |
|
610 | + echo wp_kses_post( $item->get_the_initial_price() ); |
|
539 | 611 | |
540 | - return $post_states; |
|
612 | + echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>'; |
|
613 | + break; |
|
541 | 614 | |
542 | - } |
|
615 | + case 'vat_rule': |
|
616 | + echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) ); |
|
617 | + break; |
|
543 | 618 | |
544 | - /** |
|
545 | - * Returns an array of items table columns. |
|
546 | - */ |
|
547 | - public static function item_columns( $columns ) { |
|
619 | + case 'vat_class': |
|
620 | + echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) ); |
|
621 | + break; |
|
548 | 622 | |
549 | - $columns = array( |
|
550 | - 'cb' => $columns['cb'], |
|
551 | - 'title' => __( 'Name', 'invoicing' ), |
|
552 | - 'price' => __( 'Price', 'invoicing' ), |
|
553 | - 'vat_rule' => __( 'Tax Rule', 'invoicing' ), |
|
554 | - 'vat_class' => __( 'Tax Class', 'invoicing' ), |
|
555 | - 'type' => __( 'Type', 'invoicing' ), |
|
556 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
557 | - ); |
|
623 | + case 'shortcode': |
|
624 | + if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) { |
|
625 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
626 | + } else { |
|
627 | + echo '—'; |
|
628 | + } |
|
558 | 629 | |
559 | - if ( ! wpinv_use_taxes() ) { |
|
560 | - unset( $columns['vat_rule'] ); |
|
561 | - unset( $columns['vat_class'] ); |
|
562 | - } |
|
630 | + break; |
|
563 | 631 | |
564 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
565 | - } |
|
632 | + case 'type': |
|
633 | + echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' ); |
|
634 | + break; |
|
566 | 635 | |
567 | - /** |
|
568 | - * Returns an array of sortable items table columns. |
|
569 | - */ |
|
570 | - public static function sortable_item_columns( $columns ) { |
|
571 | - |
|
572 | - return array_merge( |
|
573 | - $columns, |
|
574 | - array( |
|
575 | - 'price' => 'price', |
|
576 | - 'vat_rule' => 'vat_rule', |
|
577 | - 'vat_class' => 'vat_class', |
|
578 | - 'type' => 'type', |
|
579 | - ) |
|
580 | - ); |
|
581 | - |
|
582 | - } |
|
583 | - |
|
584 | - /** |
|
585 | - * Displays items table columns. |
|
586 | - */ |
|
587 | - public static function display_item_columns( $column_name, $post_id ) { |
|
588 | - |
|
589 | - $item = new WPInv_Item( $post_id ); |
|
590 | - |
|
591 | - switch ( $column_name ) { |
|
592 | - |
|
593 | - case 'price': |
|
594 | - if ( ! $item->is_recurring() ) { |
|
595 | - echo wp_kses_post( $item->get_the_price() ); |
|
596 | - break; |
|
597 | - } |
|
598 | - |
|
599 | - $price = wp_sprintf( |
|
600 | - __( '%1$s / %2$s', 'invoicing' ), |
|
601 | - $item->get_the_price(), |
|
602 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
603 | - ); |
|
604 | - |
|
605 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
606 | - echo wp_kses_post( $price ); |
|
607 | - break; |
|
608 | - } |
|
609 | - |
|
610 | - echo wp_kses_post( $item->get_the_initial_price() ); |
|
611 | - |
|
612 | - echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>'; |
|
613 | - break; |
|
614 | - |
|
615 | - case 'vat_rule': |
|
616 | - echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) ); |
|
617 | - break; |
|
618 | - |
|
619 | - case 'vat_class': |
|
620 | - echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) ); |
|
621 | - break; |
|
622 | - |
|
623 | - case 'shortcode': |
|
624 | - if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) { |
|
625 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
626 | - } else { |
|
627 | - echo '—'; |
|
628 | - } |
|
629 | - |
|
630 | - break; |
|
631 | - |
|
632 | - case 'type': |
|
633 | - echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' ); |
|
634 | - break; |
|
635 | - |
|
636 | - } |
|
637 | - |
|
638 | - } |
|
639 | - |
|
640 | - /** |
|
641 | - * Lets users filter items using taxes. |
|
642 | - */ |
|
643 | - public static function add_item_filters( $post_type ) { |
|
644 | - |
|
645 | - // Abort if we're not dealing with items. |
|
646 | - if ( 'wpi_item' !== $post_type ) { |
|
647 | - return; |
|
648 | - } |
|
649 | - |
|
650 | - // Filter by vat rules. |
|
651 | - if ( wpinv_use_taxes() ) { |
|
652 | - |
|
653 | - // Sanitize selected vat rule. |
|
654 | - $vat_rule = ''; |
|
655 | - $vat_rules = getpaid_get_tax_rules(); |
|
656 | - if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
657 | - $vat_rule = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
658 | - } |
|
659 | - |
|
660 | - // Filter by VAT rule. |
|
661 | - wpinv_html_select( |
|
662 | - array( |
|
663 | - 'options' => array_merge( |
|
664 | - array( |
|
665 | - '' => __( 'All Tax Rules', 'invoicing' ), |
|
666 | - ), |
|
667 | - $vat_rules |
|
668 | - ), |
|
669 | - 'name' => 'vat_rule', |
|
670 | - 'id' => 'vat_rule', |
|
671 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '', |
|
672 | - 'show_option_all' => false, |
|
673 | - 'show_option_none' => false, |
|
674 | - ) |
|
675 | - ); |
|
676 | - |
|
677 | - // Filter by VAT class. |
|
678 | - |
|
679 | - // Sanitize selected vat rule. |
|
680 | - $vat_class = ''; |
|
681 | - $vat_classes = getpaid_get_tax_classes(); |
|
682 | - if ( isset( $_GET['vat_class'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
683 | - $vat_class = sanitize_text_field( $_GET['vat_class'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
684 | - } |
|
685 | - |
|
686 | - wpinv_html_select( |
|
687 | - array( |
|
688 | - 'options' => array_merge( |
|
689 | - array( |
|
690 | - '' => __( 'All Tax Classes', 'invoicing' ), |
|
691 | - ), |
|
692 | - $vat_classes |
|
693 | - ), |
|
694 | - 'name' => 'vat_class', |
|
695 | - 'id' => 'vat_class', |
|
696 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '', |
|
697 | - 'show_option_all' => false, |
|
698 | - 'show_option_none' => false, |
|
699 | - ) |
|
700 | - ); |
|
701 | - |
|
702 | - } |
|
703 | - |
|
704 | - // Filter by item type. |
|
705 | - $type = ''; |
|
706 | - if ( isset( $_GET['type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
707 | - $type = sanitize_text_field( $_GET['type'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
708 | - } |
|
709 | - |
|
710 | - wpinv_html_select( |
|
711 | - array( |
|
712 | - 'options' => array_merge( |
|
713 | - array( |
|
714 | - '' => __( 'All item types', 'invoicing' ), |
|
715 | - ), |
|
716 | - wpinv_get_item_types() |
|
717 | - ), |
|
718 | - 'name' => 'type', |
|
719 | - 'id' => 'type', |
|
720 | - 'selected' => in_array( $type, wpinv_item_types(), true ) ? $type : '', |
|
721 | - 'show_option_all' => false, |
|
722 | - 'show_option_none' => false, |
|
723 | - ) |
|
724 | - ); |
|
725 | - |
|
726 | - } |
|
727 | - |
|
728 | - /** |
|
729 | - * Filters the item query. |
|
730 | - */ |
|
731 | - public static function filter_item_query( $query ) { |
|
732 | - |
|
733 | - // modify the query only if it admin and main query. |
|
734 | - if ( ! ( is_admin() && $query->is_main_query() ) ) { |
|
735 | - return $query; |
|
736 | - } |
|
737 | - |
|
738 | - // we want to modify the query for our items. |
|
739 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) { |
|
740 | - return $query; |
|
741 | - } |
|
742 | - |
|
743 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
744 | - $query->query_vars['meta_query'] = array(); |
|
745 | - } |
|
746 | - |
|
747 | - // Filter vat rule type |
|
636 | + } |
|
637 | + |
|
638 | + } |
|
639 | + |
|
640 | + /** |
|
641 | + * Lets users filter items using taxes. |
|
642 | + */ |
|
643 | + public static function add_item_filters( $post_type ) { |
|
644 | + |
|
645 | + // Abort if we're not dealing with items. |
|
646 | + if ( 'wpi_item' !== $post_type ) { |
|
647 | + return; |
|
648 | + } |
|
649 | + |
|
650 | + // Filter by vat rules. |
|
651 | + if ( wpinv_use_taxes() ) { |
|
652 | + |
|
653 | + // Sanitize selected vat rule. |
|
654 | + $vat_rule = ''; |
|
655 | + $vat_rules = getpaid_get_tax_rules(); |
|
656 | + if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
657 | + $vat_rule = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
658 | + } |
|
659 | + |
|
660 | + // Filter by VAT rule. |
|
661 | + wpinv_html_select( |
|
662 | + array( |
|
663 | + 'options' => array_merge( |
|
664 | + array( |
|
665 | + '' => __( 'All Tax Rules', 'invoicing' ), |
|
666 | + ), |
|
667 | + $vat_rules |
|
668 | + ), |
|
669 | + 'name' => 'vat_rule', |
|
670 | + 'id' => 'vat_rule', |
|
671 | + 'selected' => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '', |
|
672 | + 'show_option_all' => false, |
|
673 | + 'show_option_none' => false, |
|
674 | + ) |
|
675 | + ); |
|
676 | + |
|
677 | + // Filter by VAT class. |
|
678 | + |
|
679 | + // Sanitize selected vat rule. |
|
680 | + $vat_class = ''; |
|
681 | + $vat_classes = getpaid_get_tax_classes(); |
|
682 | + if ( isset( $_GET['vat_class'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
683 | + $vat_class = sanitize_text_field( $_GET['vat_class'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
684 | + } |
|
685 | + |
|
686 | + wpinv_html_select( |
|
687 | + array( |
|
688 | + 'options' => array_merge( |
|
689 | + array( |
|
690 | + '' => __( 'All Tax Classes', 'invoicing' ), |
|
691 | + ), |
|
692 | + $vat_classes |
|
693 | + ), |
|
694 | + 'name' => 'vat_class', |
|
695 | + 'id' => 'vat_class', |
|
696 | + 'selected' => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '', |
|
697 | + 'show_option_all' => false, |
|
698 | + 'show_option_none' => false, |
|
699 | + ) |
|
700 | + ); |
|
701 | + |
|
702 | + } |
|
703 | + |
|
704 | + // Filter by item type. |
|
705 | + $type = ''; |
|
706 | + if ( isset( $_GET['type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
707 | + $type = sanitize_text_field( $_GET['type'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
708 | + } |
|
709 | + |
|
710 | + wpinv_html_select( |
|
711 | + array( |
|
712 | + 'options' => array_merge( |
|
713 | + array( |
|
714 | + '' => __( 'All item types', 'invoicing' ), |
|
715 | + ), |
|
716 | + wpinv_get_item_types() |
|
717 | + ), |
|
718 | + 'name' => 'type', |
|
719 | + 'id' => 'type', |
|
720 | + 'selected' => in_array( $type, wpinv_item_types(), true ) ? $type : '', |
|
721 | + 'show_option_all' => false, |
|
722 | + 'show_option_none' => false, |
|
723 | + ) |
|
724 | + ); |
|
725 | + |
|
726 | + } |
|
727 | + |
|
728 | + /** |
|
729 | + * Filters the item query. |
|
730 | + */ |
|
731 | + public static function filter_item_query( $query ) { |
|
732 | + |
|
733 | + // modify the query only if it admin and main query. |
|
734 | + if ( ! ( is_admin() && $query->is_main_query() ) ) { |
|
735 | + return $query; |
|
736 | + } |
|
737 | + |
|
738 | + // we want to modify the query for our items. |
|
739 | + if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) { |
|
740 | + return $query; |
|
741 | + } |
|
742 | + |
|
743 | + if ( empty( $query->query_vars['meta_query'] ) ) { |
|
744 | + $query->query_vars['meta_query'] = array(); |
|
745 | + } |
|
746 | + |
|
747 | + // Filter vat rule type |
|
748 | 748 | if ( ! empty( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
749 | 749 | $query->query_vars['meta_query'][] = array( |
750 | 750 | 'key' => '_wpinv_vat_rule', |
@@ -769,101 +769,101 @@ discard block |
||
769 | 769 | 'value' => sanitize_text_field( $_GET['type'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
770 | 770 | 'compare' => '=', |
771 | 771 | ); |
772 | - } |
|
773 | - |
|
774 | - $query->query_vars['meta_query'][] = array( |
|
775 | - 'key' => '_wpinv_one_time', |
|
776 | - 'compare' => 'NOT EXISTS', |
|
777 | - ); |
|
778 | - } |
|
779 | - |
|
780 | - /** |
|
781 | - * Reorders items. |
|
782 | - */ |
|
783 | - public static function reorder_items( $vars ) { |
|
784 | - global $typenow; |
|
785 | - |
|
786 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
787 | - return $vars; |
|
788 | - } |
|
789 | - |
|
790 | - // By item type. |
|
791 | - if ( 'type' === $vars['orderby'] ) { |
|
792 | - return array_merge( |
|
793 | - $vars, |
|
794 | - array( |
|
795 | - 'meta_key' => '_wpinv_type', |
|
796 | - 'orderby' => 'meta_value', |
|
797 | - ) |
|
798 | - ); |
|
799 | - } |
|
800 | - |
|
801 | - // By vat class. |
|
802 | - if ( 'vat_class' === $vars['orderby'] ) { |
|
803 | - return array_merge( |
|
804 | - $vars, |
|
805 | - array( |
|
806 | - 'meta_key' => '_wpinv_vat_class', |
|
807 | - 'orderby' => 'meta_value', |
|
808 | - ) |
|
809 | - ); |
|
810 | - } |
|
811 | - |
|
812 | - // By vat rule. |
|
813 | - if ( 'vat_rule' === $vars['orderby'] ) { |
|
814 | - return array_merge( |
|
815 | - $vars, |
|
816 | - array( |
|
817 | - 'meta_key' => '_wpinv_vat_rule', |
|
818 | - 'orderby' => 'meta_value', |
|
819 | - ) |
|
820 | - ); |
|
821 | - } |
|
822 | - |
|
823 | - // By price. |
|
824 | - if ( 'price' === $vars['orderby'] ) { |
|
825 | - return array_merge( |
|
826 | - $vars, |
|
827 | - array( |
|
828 | - 'meta_key' => '_wpinv_price', |
|
829 | - 'orderby' => 'meta_value_num', |
|
830 | - ) |
|
831 | - ); |
|
832 | - } |
|
833 | - |
|
834 | - return $vars; |
|
835 | - |
|
836 | - } |
|
837 | - |
|
838 | - /** |
|
839 | - * Fired when deleting a post. |
|
840 | - */ |
|
841 | - public static function delete_post( $post_id ) { |
|
842 | - |
|
843 | - switch ( get_post_type( $post_id ) ) { |
|
844 | - |
|
845 | - case 'wpi_item': |
|
846 | - do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) ); |
|
847 | - break; |
|
848 | - |
|
849 | - case 'wpi_payment_form': |
|
850 | - do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) ); |
|
851 | - break; |
|
852 | - |
|
853 | - case 'wpi_discount': |
|
854 | - do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) ); |
|
855 | - break; |
|
856 | - |
|
857 | - case 'wpi_invoice': |
|
858 | - $invoice = new WPInv_Invoice( $post_id ); |
|
859 | - do_action( 'getpaid_before_delete_invoice', $invoice ); |
|
860 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
861 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
862 | - break; |
|
863 | - } |
|
864 | - } |
|
865 | - |
|
866 | - /** |
|
772 | + } |
|
773 | + |
|
774 | + $query->query_vars['meta_query'][] = array( |
|
775 | + 'key' => '_wpinv_one_time', |
|
776 | + 'compare' => 'NOT EXISTS', |
|
777 | + ); |
|
778 | + } |
|
779 | + |
|
780 | + /** |
|
781 | + * Reorders items. |
|
782 | + */ |
|
783 | + public static function reorder_items( $vars ) { |
|
784 | + global $typenow; |
|
785 | + |
|
786 | + if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
787 | + return $vars; |
|
788 | + } |
|
789 | + |
|
790 | + // By item type. |
|
791 | + if ( 'type' === $vars['orderby'] ) { |
|
792 | + return array_merge( |
|
793 | + $vars, |
|
794 | + array( |
|
795 | + 'meta_key' => '_wpinv_type', |
|
796 | + 'orderby' => 'meta_value', |
|
797 | + ) |
|
798 | + ); |
|
799 | + } |
|
800 | + |
|
801 | + // By vat class. |
|
802 | + if ( 'vat_class' === $vars['orderby'] ) { |
|
803 | + return array_merge( |
|
804 | + $vars, |
|
805 | + array( |
|
806 | + 'meta_key' => '_wpinv_vat_class', |
|
807 | + 'orderby' => 'meta_value', |
|
808 | + ) |
|
809 | + ); |
|
810 | + } |
|
811 | + |
|
812 | + // By vat rule. |
|
813 | + if ( 'vat_rule' === $vars['orderby'] ) { |
|
814 | + return array_merge( |
|
815 | + $vars, |
|
816 | + array( |
|
817 | + 'meta_key' => '_wpinv_vat_rule', |
|
818 | + 'orderby' => 'meta_value', |
|
819 | + ) |
|
820 | + ); |
|
821 | + } |
|
822 | + |
|
823 | + // By price. |
|
824 | + if ( 'price' === $vars['orderby'] ) { |
|
825 | + return array_merge( |
|
826 | + $vars, |
|
827 | + array( |
|
828 | + 'meta_key' => '_wpinv_price', |
|
829 | + 'orderby' => 'meta_value_num', |
|
830 | + ) |
|
831 | + ); |
|
832 | + } |
|
833 | + |
|
834 | + return $vars; |
|
835 | + |
|
836 | + } |
|
837 | + |
|
838 | + /** |
|
839 | + * Fired when deleting a post. |
|
840 | + */ |
|
841 | + public static function delete_post( $post_id ) { |
|
842 | + |
|
843 | + switch ( get_post_type( $post_id ) ) { |
|
844 | + |
|
845 | + case 'wpi_item': |
|
846 | + do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) ); |
|
847 | + break; |
|
848 | + |
|
849 | + case 'wpi_payment_form': |
|
850 | + do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) ); |
|
851 | + break; |
|
852 | + |
|
853 | + case 'wpi_discount': |
|
854 | + do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) ); |
|
855 | + break; |
|
856 | + |
|
857 | + case 'wpi_invoice': |
|
858 | + $invoice = new WPInv_Invoice( $post_id ); |
|
859 | + do_action( 'getpaid_before_delete_invoice', $invoice ); |
|
860 | + $invoice->get_data_store()->delete_items( $invoice ); |
|
861 | + $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
862 | + break; |
|
863 | + } |
|
864 | + } |
|
865 | + |
|
866 | + /** |
|
867 | 867 | * Add a post display state for special GetPaid pages in the page list table. |
868 | 868 | * |
869 | 869 | * @param array $post_states An array of post display states. |
@@ -877,21 +877,21 @@ discard block |
||
877 | 877 | $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
878 | 878 | } |
879 | 879 | |
880 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
880 | + foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
881 | 881 | |
882 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
883 | - $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf( |
|
884 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
885 | - $label |
|
886 | - ); |
|
887 | - } |
|
882 | + if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
883 | + $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf( |
|
884 | + __( 'GetPaid %s History Page', 'invoicing' ), |
|
885 | + $label |
|
886 | + ); |
|
887 | + } |
|
888 | 888 | } |
889 | 889 | |
890 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
890 | + if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
891 | 891 | $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
892 | 892 | } |
893 | 893 | |
894 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
894 | + if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
895 | 895 | $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
896 | 896 | } |
897 | 897 |
@@ -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,74 +21,74 @@ 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 ); |
|
33 | - add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
34 | - add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
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 | + add_filter('bulk_actions-edit-wpi_invoice', array(__CLASS__, 'invoice_bulk_actions')); |
|
34 | + add_filter('handle_bulk_actions-edit-wpi_invoice', array(__CLASS__, 'handle_invoice_bulk_actions'), 10, 3); |
|
35 | 35 | |
36 | 36 | // Items table columns. |
37 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
38 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
39 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
40 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
41 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
42 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
37 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
38 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
39 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
40 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
41 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
42 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
43 | 43 | |
44 | 44 | // Payment forms columns. |
45 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
46 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
47 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
45 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
46 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
47 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
48 | 48 | |
49 | 49 | // Discount table columns. |
50 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
51 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
51 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
52 | 52 | |
53 | 53 | // Deleting posts. |
54 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
55 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
55 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
56 | 56 | |
57 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
57 | + add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Post updated messages. |
62 | 62 | */ |
63 | - public static function post_updated_messages( $messages ) { |
|
63 | + public static function post_updated_messages($messages) { |
|
64 | 64 | global $post; |
65 | 65 | |
66 | 66 | $messages['wpi_discount'] = array( |
67 | 67 | 0 => '', |
68 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
69 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
70 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
71 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
72 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
73 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
74 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
75 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
76 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
77 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
68 | + 1 => __('Discount updated.', 'invoicing'), |
|
69 | + 2 => __('Custom field updated.', 'invoicing'), |
|
70 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
71 | + 4 => __('Discount updated.', 'invoicing'), |
|
72 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
73 | + 6 => __('Discount updated.', 'invoicing'), |
|
74 | + 7 => __('Discount saved.', 'invoicing'), |
|
75 | + 8 => __('Discount submitted.', 'invoicing'), |
|
76 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
77 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
78 | 78 | ); |
79 | 79 | |
80 | 80 | $messages['wpi_payment_form'] = array( |
81 | 81 | 0 => '', |
82 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
83 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
84 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
85 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
87 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
88 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
89 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
90 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
91 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
82 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
83 | + 2 => __('Custom field updated.', 'invoicing'), |
|
84 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
85 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
86 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
87 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
88 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
89 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
90 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
91 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
92 | 92 | ); |
93 | 93 | |
94 | 94 | return $messages; |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * Post row actions. |
100 | 100 | */ |
101 | - public static function post_row_actions( $actions, $post ) { |
|
101 | + public static function post_row_actions($actions, $post) { |
|
102 | 102 | |
103 | - $post = get_post( $post ); |
|
103 | + $post = get_post($post); |
|
104 | 104 | |
105 | 105 | // We do not want to edit the default payment form. |
106 | - if ( 'wpi_payment_form' == $post->post_type ) { |
|
106 | + if ('wpi_payment_form' == $post->post_type) { |
|
107 | 107 | |
108 | - if ( wpinv_get_default_payment_form() === $post->ID ) { |
|
109 | - unset( $actions['trash'] ); |
|
110 | - unset( $actions['inline hide-if-no-js'] ); |
|
108 | + if (wpinv_get_default_payment_form() === $post->ID) { |
|
109 | + unset($actions['trash']); |
|
110 | + unset($actions['inline hide-if-no-js']); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $actions['duplicate'] = sprintf( |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | 'getpaid-nonce' |
125 | 125 | ) |
126 | 126 | ), |
127 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
127 | + esc_html(__('Duplicate', 'invoicing')) |
|
128 | 128 | ); |
129 | 129 | |
130 | 130 | $actions['reset'] = sprintf( |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | 'getpaid-nonce' |
142 | 142 | ) |
143 | 143 | ), |
144 | - esc_html( __( 'Reset Stats', 'invoicing' ) ) |
|
144 | + esc_html(__('Reset Stats', 'invoicing')) |
|
145 | 145 | ); |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Link to item payment form. |
149 | - if ( 'wpi_item' == $post->post_type ) { |
|
150 | - if ( getpaid_item_type_supports( get_post_meta( $post->ID, '_wpinv_type', true ), 'buy_now' ) ) { |
|
149 | + if ('wpi_item' == $post->post_type) { |
|
150 | + if (getpaid_item_type_supports(get_post_meta($post->ID, '_wpinv_type', true), 'buy_now')) { |
|
151 | 151 | $actions['buy'] = sprintf( |
152 | 152 | '<a href="%1$s">%2$s</a>', |
153 | - esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
154 | - esc_html( __( 'Buy', 'invoicing' ) ) |
|
153 | + esc_url(getpaid_embed_url(false, $post->ID . '|0')), |
|
154 | + esc_html(__('Buy', 'invoicing')) |
|
155 | 155 | ); |
156 | 156 | } |
157 | 157 | } |
@@ -167,28 +167,28 @@ discard block |
||
167 | 167 | * @param WP_Post $post |
168 | 168 | * @return array $actions actions without edit option |
169 | 169 | */ |
170 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
170 | + public static function filter_invoice_row_actions($actions, $post) { |
|
171 | 171 | |
172 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
172 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
173 | 173 | |
174 | 174 | $actions = array(); |
175 | - $invoice = new WPInv_Invoice( $post ); |
|
175 | + $invoice = new WPInv_Invoice($post); |
|
176 | 176 | |
177 | 177 | $actions['edit'] = sprintf( |
178 | 178 | '<a href="%1$s">%2$s</a>', |
179 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
180 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
179 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
180 | + esc_html(__('Edit', 'invoicing')) |
|
181 | 181 | ); |
182 | 182 | |
183 | - if ( ! $invoice->is_draft() ) { |
|
183 | + if (!$invoice->is_draft()) { |
|
184 | 184 | |
185 | 185 | $actions['view'] = sprintf( |
186 | 186 | '<a href="%1$s">%2$s</a>', |
187 | - esc_url( $invoice->get_view_url() ), |
|
187 | + esc_url($invoice->get_view_url()), |
|
188 | 188 | sprintf( |
189 | 189 | // translators: %s is the invoice type |
190 | - esc_html__( 'View %s', 'invoicing' ), |
|
191 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
190 | + esc_html__('View %s', 'invoicing'), |
|
191 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
192 | 192 | ) |
193 | 193 | ); |
194 | 194 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | 'getpaid-nonce' |
207 | 207 | ) |
208 | 208 | ), |
209 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
209 | + esc_html(__('Send to Customer', 'invoicing')) |
|
210 | 210 | ); |
211 | 211 | |
212 | 212 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | 'getpaid-nonce' |
226 | 226 | ) |
227 | 227 | ), |
228 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
228 | + esc_html(__('Duplicate', 'invoicing')) |
|
229 | 229 | ); |
230 | 230 | |
231 | 231 | } |
@@ -236,42 +236,42 @@ discard block |
||
236 | 236 | /** |
237 | 237 | * Returns an array of invoice table columns. |
238 | 238 | */ |
239 | - public static function invoice_columns( $columns ) { |
|
239 | + public static function invoice_columns($columns) { |
|
240 | 240 | |
241 | 241 | $columns = array( |
242 | 242 | 'cb' => $columns['cb'], |
243 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
244 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
245 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
246 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
247 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
248 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
249 | - 'status' => __( 'Status', 'invoicing' ), |
|
243 | + 'number' => __('Invoice', 'invoicing'), |
|
244 | + 'customer' => __('Customer', 'invoicing'), |
|
245 | + 'invoice_date' => __('Created', 'invoicing'), |
|
246 | + 'payment_date' => __('Completed', 'invoicing'), |
|
247 | + 'amount' => __('Amount', 'invoicing'), |
|
248 | + 'recurring' => __('Recurring', 'invoicing'), |
|
249 | + 'status' => __('Status', 'invoicing'), |
|
250 | 250 | ); |
251 | 251 | |
252 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
252 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
256 | 256 | * Displays invoice table columns. |
257 | 257 | */ |
258 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
258 | + public static function display_invoice_columns($column_name, $post_id) { |
|
259 | 259 | |
260 | - $invoice = new WPInv_Invoice( $post_id ); |
|
260 | + $invoice = new WPInv_Invoice($post_id); |
|
261 | 261 | |
262 | - switch ( $column_name ) { |
|
262 | + switch ($column_name) { |
|
263 | 263 | |
264 | 264 | case 'invoice_date': |
265 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
266 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
267 | - echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
265 | + $date_time = esc_attr($invoice->get_created_date()); |
|
266 | + $date = esc_html(getpaid_format_date_value($date_time, '—', true)); |
|
267 | + echo wp_kses_post("<span title='$date_time'>$date</span>"); |
|
268 | 268 | break; |
269 | 269 | |
270 | 270 | case 'payment_date': |
271 | - if ( $invoice->is_paid() ) { |
|
272 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
273 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
274 | - echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
271 | + if ($invoice->is_paid()) { |
|
272 | + $date_time = esc_attr($invoice->get_completed_date()); |
|
273 | + $date = esc_html(getpaid_format_date_value($date_time, '—', true)); |
|
274 | + echo wp_kses_post("<span title='$date_time'>$date</span>"); |
|
275 | 275 | } else { |
276 | 276 | echo '—'; |
277 | 277 | } |
@@ -280,61 +280,61 @@ discard block |
||
280 | 280 | |
281 | 281 | case 'amount': |
282 | 282 | $amount = $invoice->get_total(); |
283 | - $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) ); |
|
283 | + $formated_amount = wp_kses_post(wpinv_price($amount, $invoice->get_currency())); |
|
284 | 284 | |
285 | - if ( $invoice->is_refunded() ) { |
|
286 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
287 | - echo wp_kses_post( "<del>$formated_amount</del> <ins>$refunded_amount</ins>" ); |
|
285 | + if ($invoice->is_refunded()) { |
|
286 | + $refunded_amount = wpinv_price(0, $invoice->get_currency()); |
|
287 | + echo wp_kses_post("<del>$formated_amount</del> <ins>$refunded_amount</ins>"); |
|
288 | 288 | } else { |
289 | 289 | |
290 | 290 | $discount = $invoice->get_total_discount(); |
291 | 291 | |
292 | - if ( ! empty( $discount ) ) { |
|
293 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
294 | - echo wp_kses_post( "<del>$new_amount</del> <ins>$formated_amount</ins>" ); |
|
292 | + if (!empty($discount)) { |
|
293 | + $new_amount = wpinv_price($amount + $discount, $invoice->get_currency()); |
|
294 | + echo wp_kses_post("<del>$new_amount</del> <ins>$formated_amount</ins>"); |
|
295 | 295 | } else { |
296 | - echo wp_kses_post( $formated_amount ); |
|
296 | + echo wp_kses_post($formated_amount); |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | 300 | break; |
301 | 301 | |
302 | 302 | case 'status': |
303 | - $status = esc_html( $invoice->get_status() ); |
|
304 | - $status_label = esc_html( $invoice->get_status_nicename() ); |
|
303 | + $status = esc_html($invoice->get_status()); |
|
304 | + $status_label = esc_html($invoice->get_status_nicename()); |
|
305 | 305 | |
306 | 306 | // If it is paid, show the gateway title. |
307 | - if ( $invoice->is_paid() ) { |
|
308 | - $gateway = esc_html( $invoice->get_gateway_title() ); |
|
309 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) ); |
|
307 | + if ($invoice->is_paid()) { |
|
308 | + $gateway = esc_html($invoice->get_gateway_title()); |
|
309 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), esc_html($gateway)); |
|
310 | 310 | |
311 | - echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" ); |
|
311 | + echo wp_kses_post("<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"); |
|
312 | 312 | } else { |
313 | - echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" ); |
|
313 | + echo wp_kses_post("<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | // If it is not paid, display the overdue and view status. |
317 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
317 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
318 | 318 | |
319 | 319 | // Invoice view status. |
320 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
321 | - echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
320 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
321 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
322 | 322 | } else { |
323 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
323 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | // Display the overview status. |
327 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
327 | + if (wpinv_get_option('overdue_active')) { |
|
328 | 328 | $due_date = $invoice->get_due_date(); |
329 | - $fomatted = getpaid_format_date( $due_date ); |
|
329 | + $fomatted = getpaid_format_date($due_date); |
|
330 | 330 | |
331 | - if ( ! empty( $fomatted ) ) { |
|
331 | + if (!empty($fomatted)) { |
|
332 | 332 | $date = wp_sprintf( |
333 | 333 | // translators: %s is the due date. |
334 | - __( 'Due %s', 'invoicing' ), |
|
334 | + __('Due %s', 'invoicing'), |
|
335 | 335 | $fomatted |
336 | 336 | ); |
337 | - echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" ); |
|
337 | + echo wp_kses_post("<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | break; |
343 | 343 | |
344 | 344 | case 'recurring': |
345 | - if ( $invoice->is_recurring() ) { |
|
345 | + if ($invoice->is_recurring()) { |
|
346 | 346 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
347 | 347 | } else { |
348 | 348 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -350,26 +350,26 @@ discard block |
||
350 | 350 | break; |
351 | 351 | |
352 | 352 | case 'number': |
353 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
354 | - $invoice_number = esc_html( $invoice->get_number() ); |
|
355 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
353 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
354 | + $invoice_number = esc_html($invoice->get_number()); |
|
355 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
356 | 356 | |
357 | - echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" ); |
|
357 | + echo wp_kses_post("<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"); |
|
358 | 358 | |
359 | - do_action( 'getpaid_admin_table_invoice_number_column', $invoice ); |
|
359 | + do_action('getpaid_admin_table_invoice_number_column', $invoice); |
|
360 | 360 | break; |
361 | 361 | |
362 | 362 | case 'customer': |
363 | 363 | $customer_name = $invoice->get_user_full_name(); |
364 | 364 | |
365 | - if ( empty( $customer_name ) ) { |
|
365 | + if (empty($customer_name)) { |
|
366 | 366 | $customer_name = $invoice->get_email(); |
367 | 367 | } |
368 | 368 | |
369 | - if ( ! empty( $customer_name ) ) { |
|
370 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
371 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
372 | - echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" ); |
|
369 | + if (!empty($customer_name)) { |
|
370 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
371 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
372 | + echo wp_kses_post("<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"); |
|
373 | 373 | } else { |
374 | 374 | echo '<div>—</div>'; |
375 | 375 | } |
@@ -383,19 +383,19 @@ discard block |
||
383 | 383 | /** |
384 | 384 | * Displays invoice bulk actions. |
385 | 385 | */ |
386 | - public static function invoice_bulk_actions( $actions ) { |
|
387 | - $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
386 | + public static function invoice_bulk_actions($actions) { |
|
387 | + $actions['resend-invoice'] = __('Send to Customer', 'invoicing'); |
|
388 | 388 | return $actions; |
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
392 | 392 | * Processes invoice bulk actions. |
393 | 393 | */ |
394 | - public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
394 | + public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) { |
|
395 | 395 | |
396 | - if ( 'resend-invoice' === $action ) { |
|
397 | - foreach ( $post_ids as $post_id ) { |
|
398 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
396 | + if ('resend-invoice' === $action) { |
|
397 | + foreach ($post_ids as $post_id) { |
|
398 | + getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
@@ -406,49 +406,49 @@ discard block |
||
406 | 406 | /** |
407 | 407 | * Returns an array of payment forms table columns. |
408 | 408 | */ |
409 | - public static function payment_form_columns( $columns ) { |
|
409 | + public static function payment_form_columns($columns) { |
|
410 | 410 | |
411 | 411 | $columns = array( |
412 | 412 | 'cb' => $columns['cb'], |
413 | - 'title' => __( 'Name', 'invoicing' ), |
|
414 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
415 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
416 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
417 | - 'items' => __( 'Items', 'invoicing' ), |
|
418 | - 'date' => __( 'Date', 'invoicing' ), |
|
413 | + 'title' => __('Name', 'invoicing'), |
|
414 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
415 | + 'earnings' => __('Revenue', 'invoicing'), |
|
416 | + 'refunds' => __('Refunded', 'invoicing'), |
|
417 | + 'items' => __('Items', 'invoicing'), |
|
418 | + 'date' => __('Date', 'invoicing'), |
|
419 | 419 | ); |
420 | 420 | |
421 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
421 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
422 | 422 | |
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
426 | 426 | * Displays payment form table columns. |
427 | 427 | */ |
428 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
428 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
429 | 429 | |
430 | 430 | // Retrieve the payment form. |
431 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
431 | + $form = new GetPaid_Payment_Form($post_id); |
|
432 | 432 | |
433 | - switch ( $column_name ) { |
|
433 | + switch ($column_name) { |
|
434 | 434 | |
435 | 435 | case 'earnings': |
436 | - echo wp_kses_post( wpinv_price( $form->get_earned() ) ); |
|
436 | + echo wp_kses_post(wpinv_price($form->get_earned())); |
|
437 | 437 | break; |
438 | 438 | |
439 | 439 | case 'refunds': |
440 | - echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
440 | + echo wp_kses_post(wpinv_price($form->get_refunded())); |
|
441 | 441 | break; |
442 | 442 | |
443 | 443 | case 'refunds': |
444 | - echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
444 | + echo wp_kses_post(wpinv_price($form->get_refunded())); |
|
445 | 445 | break; |
446 | 446 | |
447 | 447 | case 'shortcode': |
448 | - if ( $form->is_default() ) { |
|
448 | + if ($form->is_default()) { |
|
449 | 449 | echo '—'; |
450 | 450 | } else { |
451 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
451 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | break; |
@@ -456,28 +456,28 @@ discard block |
||
456 | 456 | case 'items': |
457 | 457 | $items = $form->get_items(); |
458 | 458 | |
459 | - if ( $form->is_default() || empty( $items ) ) { |
|
459 | + if ($form->is_default() || empty($items)) { |
|
460 | 460 | echo '—'; |
461 | 461 | return; |
462 | 462 | } |
463 | 463 | |
464 | 464 | $_items = array(); |
465 | 465 | |
466 | - foreach ( $items as $item ) { |
|
466 | + foreach ($items as $item) { |
|
467 | 467 | $url = $item->get_edit_url(); |
468 | 468 | |
469 | - if ( empty( $url ) ) { |
|
470 | - $_items[] = esc_html( $item->get_name() ); |
|
469 | + if (empty($url)) { |
|
470 | + $_items[] = esc_html($item->get_name()); |
|
471 | 471 | } else { |
472 | 472 | $_items[] = sprintf( |
473 | 473 | '<a href="%s">%s</a>', |
474 | - esc_url( $url ), |
|
475 | - esc_html( $item->get_name() ) |
|
474 | + esc_url($url), |
|
475 | + esc_html($item->get_name()) |
|
476 | 476 | ); |
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
480 | - echo wp_kses_post( implode( '<br>', $_items ) ); |
|
480 | + echo wp_kses_post(implode('<br>', $_items)); |
|
481 | 481 | |
482 | 482 | break; |
483 | 483 | |
@@ -488,10 +488,10 @@ discard block |
||
488 | 488 | /** |
489 | 489 | * Filters post states. |
490 | 490 | */ |
491 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
491 | + public static function filter_payment_form_state($post_states, $post) { |
|
492 | 492 | |
493 | - if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) { |
|
494 | - $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' ); |
|
493 | + if ('wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID) { |
|
494 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | return $post_states; |
@@ -501,35 +501,35 @@ discard block |
||
501 | 501 | /** |
502 | 502 | * Returns an array of coupon table columns. |
503 | 503 | */ |
504 | - public static function discount_columns( $columns ) { |
|
504 | + public static function discount_columns($columns) { |
|
505 | 505 | |
506 | 506 | $columns = array( |
507 | 507 | 'cb' => $columns['cb'], |
508 | - 'title' => __( 'Name', 'invoicing' ), |
|
509 | - 'code' => __( 'Code', 'invoicing' ), |
|
510 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
511 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
512 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
513 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
508 | + 'title' => __('Name', 'invoicing'), |
|
509 | + 'code' => __('Code', 'invoicing'), |
|
510 | + 'amount' => __('Amount', 'invoicing'), |
|
511 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
512 | + 'start_date' => __('Start Date', 'invoicing'), |
|
513 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
514 | 514 | ); |
515 | 515 | |
516 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
516 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | /** |
520 | 520 | * Filters post states. |
521 | 521 | */ |
522 | - public static function filter_discount_state( $post_states, $post ) { |
|
522 | + public static function filter_discount_state($post_states, $post) { |
|
523 | 523 | |
524 | - if ( 'wpi_discount' === $post->post_type ) { |
|
524 | + if ('wpi_discount' === $post->post_type) { |
|
525 | 525 | |
526 | - $discount = new WPInv_Discount( $post ); |
|
526 | + $discount = new WPInv_Discount($post); |
|
527 | 527 | |
528 | 528 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
529 | 529 | |
530 | - if ( 'publish' !== $status ) { |
|
530 | + if ('publish' !== $status) { |
|
531 | 531 | return array( |
532 | - 'discount_status' => wpinv_discount_status( $status ), |
|
532 | + 'discount_status' => wpinv_discount_status($status), |
|
533 | 533 | ); |
534 | 534 | } |
535 | 535 | |
@@ -544,30 +544,30 @@ discard block |
||
544 | 544 | /** |
545 | 545 | * Returns an array of items table columns. |
546 | 546 | */ |
547 | - public static function item_columns( $columns ) { |
|
547 | + public static function item_columns($columns) { |
|
548 | 548 | |
549 | 549 | $columns = array( |
550 | 550 | 'cb' => $columns['cb'], |
551 | - 'title' => __( 'Name', 'invoicing' ), |
|
552 | - 'price' => __( 'Price', 'invoicing' ), |
|
553 | - 'vat_rule' => __( 'Tax Rule', 'invoicing' ), |
|
554 | - 'vat_class' => __( 'Tax Class', 'invoicing' ), |
|
555 | - 'type' => __( 'Type', 'invoicing' ), |
|
556 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
551 | + 'title' => __('Name', 'invoicing'), |
|
552 | + 'price' => __('Price', 'invoicing'), |
|
553 | + 'vat_rule' => __('Tax Rule', 'invoicing'), |
|
554 | + 'vat_class' => __('Tax Class', 'invoicing'), |
|
555 | + 'type' => __('Type', 'invoicing'), |
|
556 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
557 | 557 | ); |
558 | 558 | |
559 | - if ( ! wpinv_use_taxes() ) { |
|
560 | - unset( $columns['vat_rule'] ); |
|
561 | - unset( $columns['vat_class'] ); |
|
559 | + if (!wpinv_use_taxes()) { |
|
560 | + unset($columns['vat_rule']); |
|
561 | + unset($columns['vat_class']); |
|
562 | 562 | } |
563 | 563 | |
564 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
564 | + return apply_filters('wpi_item_table_columns', $columns); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | /** |
568 | 568 | * Returns an array of sortable items table columns. |
569 | 569 | */ |
570 | - public static function sortable_item_columns( $columns ) { |
|
570 | + public static function sortable_item_columns($columns) { |
|
571 | 571 | |
572 | 572 | return array_merge( |
573 | 573 | $columns, |
@@ -584,45 +584,45 @@ discard block |
||
584 | 584 | /** |
585 | 585 | * Displays items table columns. |
586 | 586 | */ |
587 | - public static function display_item_columns( $column_name, $post_id ) { |
|
587 | + public static function display_item_columns($column_name, $post_id) { |
|
588 | 588 | |
589 | - $item = new WPInv_Item( $post_id ); |
|
589 | + $item = new WPInv_Item($post_id); |
|
590 | 590 | |
591 | - switch ( $column_name ) { |
|
591 | + switch ($column_name) { |
|
592 | 592 | |
593 | 593 | case 'price': |
594 | - if ( ! $item->is_recurring() ) { |
|
595 | - echo wp_kses_post( $item->get_the_price() ); |
|
594 | + if (!$item->is_recurring()) { |
|
595 | + echo wp_kses_post($item->get_the_price()); |
|
596 | 596 | break; |
597 | 597 | } |
598 | 598 | |
599 | 599 | $price = wp_sprintf( |
600 | - __( '%1$s / %2$s', 'invoicing' ), |
|
600 | + __('%1$s / %2$s', 'invoicing'), |
|
601 | 601 | $item->get_the_price(), |
602 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
602 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
603 | 603 | ); |
604 | 604 | |
605 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
606 | - echo wp_kses_post( $price ); |
|
605 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
606 | + echo wp_kses_post($price); |
|
607 | 607 | break; |
608 | 608 | } |
609 | 609 | |
610 | - echo wp_kses_post( $item->get_the_initial_price() ); |
|
610 | + echo wp_kses_post($item->get_the_initial_price()); |
|
611 | 611 | |
612 | - echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>'; |
|
612 | + echo '<span class="meta">' . wp_sprintf(esc_html__('then %s', 'invoicing'), wp_kses_post($price)) . '</span>'; |
|
613 | 613 | break; |
614 | 614 | |
615 | 615 | case 'vat_rule': |
616 | - echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) ); |
|
616 | + echo wp_kses_post(getpaid_get_tax_rule_label($item->get_vat_rule())); |
|
617 | 617 | break; |
618 | 618 | |
619 | 619 | case 'vat_class': |
620 | - echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) ); |
|
620 | + echo wp_kses_post(getpaid_get_tax_class_label($item->get_vat_class())); |
|
621 | 621 | break; |
622 | 622 | |
623 | 623 | case 'shortcode': |
624 | - if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) { |
|
625 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
624 | + if ($item->is_type(array('', 'fee', 'custom'))) { |
|
625 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
626 | 626 | } else { |
627 | 627 | echo '—'; |
628 | 628 | } |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | break; |
631 | 631 | |
632 | 632 | case 'type': |
633 | - echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' ); |
|
633 | + echo wp_kses_post(wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'); |
|
634 | 634 | break; |
635 | 635 | |
636 | 636 | } |
@@ -640,21 +640,21 @@ discard block |
||
640 | 640 | /** |
641 | 641 | * Lets users filter items using taxes. |
642 | 642 | */ |
643 | - public static function add_item_filters( $post_type ) { |
|
643 | + public static function add_item_filters($post_type) { |
|
644 | 644 | |
645 | 645 | // Abort if we're not dealing with items. |
646 | - if ( 'wpi_item' !== $post_type ) { |
|
646 | + if ('wpi_item' !== $post_type) { |
|
647 | 647 | return; |
648 | 648 | } |
649 | 649 | |
650 | 650 | // Filter by vat rules. |
651 | - if ( wpinv_use_taxes() ) { |
|
651 | + if (wpinv_use_taxes()) { |
|
652 | 652 | |
653 | 653 | // Sanitize selected vat rule. |
654 | 654 | $vat_rule = ''; |
655 | 655 | $vat_rules = getpaid_get_tax_rules(); |
656 | - if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
657 | - $vat_rule = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
656 | + if (isset($_GET['vat_rule'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
657 | + $vat_rule = sanitize_text_field($_GET['vat_rule']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | // Filter by VAT rule. |
@@ -662,13 +662,13 @@ discard block |
||
662 | 662 | array( |
663 | 663 | 'options' => array_merge( |
664 | 664 | array( |
665 | - '' => __( 'All Tax Rules', 'invoicing' ), |
|
665 | + '' => __('All Tax Rules', 'invoicing'), |
|
666 | 666 | ), |
667 | 667 | $vat_rules |
668 | 668 | ), |
669 | 669 | 'name' => 'vat_rule', |
670 | 670 | 'id' => 'vat_rule', |
671 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '', |
|
671 | + 'selected' => in_array($vat_rule, array_keys($vat_rules), true) ? $vat_rule : '', |
|
672 | 672 | 'show_option_all' => false, |
673 | 673 | 'show_option_none' => false, |
674 | 674 | ) |
@@ -679,21 +679,21 @@ discard block |
||
679 | 679 | // Sanitize selected vat rule. |
680 | 680 | $vat_class = ''; |
681 | 681 | $vat_classes = getpaid_get_tax_classes(); |
682 | - if ( isset( $_GET['vat_class'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
683 | - $vat_class = sanitize_text_field( $_GET['vat_class'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
682 | + if (isset($_GET['vat_class'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
683 | + $vat_class = sanitize_text_field($_GET['vat_class']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | wpinv_html_select( |
687 | 687 | array( |
688 | 688 | 'options' => array_merge( |
689 | 689 | array( |
690 | - '' => __( 'All Tax Classes', 'invoicing' ), |
|
690 | + '' => __('All Tax Classes', 'invoicing'), |
|
691 | 691 | ), |
692 | 692 | $vat_classes |
693 | 693 | ), |
694 | 694 | 'name' => 'vat_class', |
695 | 695 | 'id' => 'vat_class', |
696 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '', |
|
696 | + 'selected' => in_array($vat_class, array_keys($vat_classes), true) ? $vat_class : '', |
|
697 | 697 | 'show_option_all' => false, |
698 | 698 | 'show_option_none' => false, |
699 | 699 | ) |
@@ -702,22 +702,22 @@ discard block |
||
702 | 702 | } |
703 | 703 | |
704 | 704 | // Filter by item type. |
705 | - $type = ''; |
|
706 | - if ( isset( $_GET['type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
707 | - $type = sanitize_text_field( $_GET['type'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
705 | + $type = ''; |
|
706 | + if (isset($_GET['type'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
707 | + $type = sanitize_text_field($_GET['type']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | wpinv_html_select( |
711 | 711 | array( |
712 | 712 | 'options' => array_merge( |
713 | 713 | array( |
714 | - '' => __( 'All item types', 'invoicing' ), |
|
714 | + '' => __('All item types', 'invoicing'), |
|
715 | 715 | ), |
716 | 716 | wpinv_get_item_types() |
717 | 717 | ), |
718 | 718 | 'name' => 'type', |
719 | 719 | 'id' => 'type', |
720 | - 'selected' => in_array( $type, wpinv_item_types(), true ) ? $type : '', |
|
720 | + 'selected' => in_array($type, wpinv_item_types(), true) ? $type : '', |
|
721 | 721 | 'show_option_all' => false, |
722 | 722 | 'show_option_none' => false, |
723 | 723 | ) |
@@ -728,45 +728,45 @@ discard block |
||
728 | 728 | /** |
729 | 729 | * Filters the item query. |
730 | 730 | */ |
731 | - public static function filter_item_query( $query ) { |
|
731 | + public static function filter_item_query($query) { |
|
732 | 732 | |
733 | 733 | // modify the query only if it admin and main query. |
734 | - if ( ! ( is_admin() && $query->is_main_query() ) ) { |
|
734 | + if (!(is_admin() && $query->is_main_query())) { |
|
735 | 735 | return $query; |
736 | 736 | } |
737 | 737 | |
738 | 738 | // we want to modify the query for our items. |
739 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) { |
|
739 | + if (empty($query->query['post_type']) || 'wpi_item' !== $query->query['post_type']) { |
|
740 | 740 | return $query; |
741 | 741 | } |
742 | 742 | |
743 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
743 | + if (empty($query->query_vars['meta_query'])) { |
|
744 | 744 | $query->query_vars['meta_query'] = array(); |
745 | 745 | } |
746 | 746 | |
747 | 747 | // Filter vat rule type |
748 | - if ( ! empty( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
748 | + if (!empty($_GET['vat_rule'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
749 | 749 | $query->query_vars['meta_query'][] = array( |
750 | 750 | 'key' => '_wpinv_vat_rule', |
751 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
751 | + 'value' => sanitize_text_field($_GET['vat_rule']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
752 | 752 | 'compare' => '=', |
753 | 753 | ); |
754 | 754 | } |
755 | 755 | |
756 | 756 | // Filter vat class |
757 | - if ( ! empty( $_GET['vat_class'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
757 | + if (!empty($_GET['vat_class'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
758 | 758 | $query->query_vars['meta_query'][] = array( |
759 | 759 | 'key' => '_wpinv_vat_class', |
760 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
760 | + 'value' => sanitize_text_field($_GET['vat_class']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
761 | 761 | 'compare' => '=', |
762 | 762 | ); |
763 | 763 | } |
764 | 764 | |
765 | 765 | // Filter item type |
766 | - if ( ! empty( $_GET['type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
766 | + if (!empty($_GET['type'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
767 | 767 | $query->query_vars['meta_query'][] = array( |
768 | 768 | 'key' => '_wpinv_type', |
769 | - 'value' => sanitize_text_field( $_GET['type'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
769 | + 'value' => sanitize_text_field($_GET['type']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
770 | 770 | 'compare' => '=', |
771 | 771 | ); |
772 | 772 | } |
@@ -780,15 +780,15 @@ discard block |
||
780 | 780 | /** |
781 | 781 | * Reorders items. |
782 | 782 | */ |
783 | - public static function reorder_items( $vars ) { |
|
783 | + public static function reorder_items($vars) { |
|
784 | 784 | global $typenow; |
785 | 785 | |
786 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
786 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
787 | 787 | return $vars; |
788 | 788 | } |
789 | 789 | |
790 | 790 | // By item type. |
791 | - if ( 'type' === $vars['orderby'] ) { |
|
791 | + if ('type' === $vars['orderby']) { |
|
792 | 792 | return array_merge( |
793 | 793 | $vars, |
794 | 794 | array( |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | } |
800 | 800 | |
801 | 801 | // By vat class. |
802 | - if ( 'vat_class' === $vars['orderby'] ) { |
|
802 | + if ('vat_class' === $vars['orderby']) { |
|
803 | 803 | return array_merge( |
804 | 804 | $vars, |
805 | 805 | array( |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | } |
811 | 811 | |
812 | 812 | // By vat rule. |
813 | - if ( 'vat_rule' === $vars['orderby'] ) { |
|
813 | + if ('vat_rule' === $vars['orderby']) { |
|
814 | 814 | return array_merge( |
815 | 815 | $vars, |
816 | 816 | array( |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | } |
822 | 822 | |
823 | 823 | // By price. |
824 | - if ( 'price' === $vars['orderby'] ) { |
|
824 | + if ('price' === $vars['orderby']) { |
|
825 | 825 | return array_merge( |
826 | 826 | $vars, |
827 | 827 | array( |
@@ -838,27 +838,27 @@ discard block |
||
838 | 838 | /** |
839 | 839 | * Fired when deleting a post. |
840 | 840 | */ |
841 | - public static function delete_post( $post_id ) { |
|
841 | + public static function delete_post($post_id) { |
|
842 | 842 | |
843 | - switch ( get_post_type( $post_id ) ) { |
|
843 | + switch (get_post_type($post_id)) { |
|
844 | 844 | |
845 | 845 | case 'wpi_item': |
846 | - do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) ); |
|
846 | + do_action('getpaid_before_delete_item', new WPInv_Item($post_id)); |
|
847 | 847 | break; |
848 | 848 | |
849 | 849 | case 'wpi_payment_form': |
850 | - do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) ); |
|
850 | + do_action('getpaid_before_delete_payment_form', new GetPaid_Payment_Form($post_id)); |
|
851 | 851 | break; |
852 | 852 | |
853 | 853 | case 'wpi_discount': |
854 | - do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) ); |
|
854 | + do_action('getpaid_before_delete_discount', new WPInv_Discount($post_id)); |
|
855 | 855 | break; |
856 | 856 | |
857 | 857 | case 'wpi_invoice': |
858 | - $invoice = new WPInv_Invoice( $post_id ); |
|
859 | - do_action( 'getpaid_before_delete_invoice', $invoice ); |
|
860 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
861 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
858 | + $invoice = new WPInv_Invoice($post_id); |
|
859 | + do_action('getpaid_before_delete_invoice', $invoice); |
|
860 | + $invoice->get_data_store()->delete_items($invoice); |
|
861 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
862 | 862 | break; |
863 | 863 | } |
864 | 864 | } |
@@ -871,28 +871,28 @@ discard block |
||
871 | 871 | * |
872 | 872 | * @return mixed |
873 | 873 | */ |
874 | - public static function add_display_post_states( $post_states, $post ) { |
|
874 | + public static function add_display_post_states($post_states, $post) { |
|
875 | 875 | |
876 | - if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) { |
|
877 | - $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
|
876 | + if (wpinv_get_option('success_page', 0) == $post->ID) { |
|
877 | + $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing'); |
|
878 | 878 | } |
879 | 879 | |
880 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
880 | + foreach (getpaid_get_invoice_post_types() as $post_type => $label) { |
|
881 | 881 | |
882 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
883 | - $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf( |
|
884 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
882 | + if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) { |
|
883 | + $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
|
884 | + __('GetPaid %s History Page', 'invoicing'), |
|
885 | 885 | $label |
886 | 886 | ); |
887 | 887 | } |
888 | 888 | } |
889 | 889 | |
890 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
891 | - $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
|
890 | + if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) { |
|
891 | + $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing'); |
|
892 | 892 | } |
893 | 893 | |
894 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
895 | - $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
|
894 | + if (wpinv_get_option('checkout_page', 0) == $post->ID) { |
|
895 | + $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing'); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | return $post_states; |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,20 +21,20 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the item. |
27 | - $item = new WPInv_Item( $post ); |
|
27 | + $item = new WPInv_Item($post); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 | |
31 | 31 | <div class='bsui' style='padding-top: 10px;'> |
32 | - <?php do_action( 'wpinv_item_before_info_metabox', $item ); ?> |
|
32 | + <?php do_action('wpinv_item_before_info_metabox', $item); ?> |
|
33 | 33 | |
34 | 34 | <div class="wpinv_item_type form-group mb-3 row"> |
35 | 35 | <label for="wpinv_item_type" class="col-sm-12 col-form-label"> |
36 | - <?php esc_html_e( 'Item Type', 'invoicing' ); ?> |
|
37 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo esc_attr( self::get_tooltip( $post ) ); ?>"></span> |
|
36 | + <?php esc_html_e('Item Type', 'invoicing'); ?> |
|
37 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo esc_attr(self::get_tooltip($post)); ?>"></span> |
|
38 | 38 | </label> |
39 | 39 | |
40 | 40 | <div class="col-sm-12"> |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | array( |
45 | 45 | 'id' => 'wpinv_item_type', |
46 | 46 | 'name' => 'wpinv_item_type', |
47 | - 'placeholder' => __( 'Select item type', 'invoicing' ), |
|
48 | - 'value' => $item->get_type( 'edit' ), |
|
47 | + 'placeholder' => __('Select item type', 'invoicing'), |
|
48 | + 'value' => $item->get_type('edit'), |
|
49 | 49 | 'select2' => true, |
50 | 50 | 'data-allow-clear' => 'false', |
51 | 51 | 'no_wrap' => true, |
@@ -58,58 +58,58 @@ discard block |
||
58 | 58 | </div> |
59 | 59 | </div> |
60 | 60 | |
61 | - <?php if ( getpaid_item_type_supports( $item->get_type( 'edit' ), 'buy_now' ) ) : ?> |
|
61 | + <?php if (getpaid_item_type_supports($item->get_type('edit'), 'buy_now')) : ?> |
|
62 | 62 | <div class="wpinv_item_shortcode form-group mb-3 row"> |
63 | 63 | <label for="wpinv_item_shortcode" class="col-sm-12 col-form-label"> |
64 | - <?php esc_html_e( 'Payment Form Shortcode', 'invoicing' ); ?> |
|
65 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span> |
|
64 | + <?php esc_html_e('Payment Form Shortcode', 'invoicing'); ?> |
|
65 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span> |
|
66 | 66 | </label> |
67 | 67 | |
68 | 68 | <div class="col-sm-12"> |
69 | - <input onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?>]" style="width: 100%;" readonly/> |
|
69 | + <input onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?>]" style="width: 100%;" readonly/> |
|
70 | 70 | </div> |
71 | 71 | </div> |
72 | 72 | |
73 | 73 | <div class="wpinv_item_buy_shortcode form-group mb-3 row"> |
74 | 74 | <label for="wpinv_item_button_shortcode" class="col-sm-12 col-form-label"> |
75 | - <?php esc_html_e( 'Payment Button Shortcode', 'invoicing' ); ?> |
|
76 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span> |
|
75 | + <?php esc_html_e('Payment Button Shortcode', 'invoicing'); ?> |
|
76 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span> |
|
77 | 77 | </label> |
78 | 78 | |
79 | 79 | <div class="col-sm-12"> |
80 | - <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?> button='Buy Now']" style="width: 100%;" readonly/> |
|
80 | + <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?> button='Buy Now']" style="width: 100%;" readonly/> |
|
81 | 81 | <small class="form-text text-muted"> |
82 | - <?php esc_html_e( 'Or use the following URL in a link:', 'invoicing' ); ?> |
|
83 | - <code>#getpaid-item-<?php echo intval( $item->get_id() ); ?>|0</code> |
|
82 | + <?php esc_html_e('Or use the following URL in a link:', 'invoicing'); ?> |
|
83 | + <code>#getpaid-item-<?php echo intval($item->get_id()); ?>|0</code> |
|
84 | 84 | </small> |
85 | 85 | </div> |
86 | 86 | </div> |
87 | 87 | |
88 | 88 | <div class="wpinv_item_buy_url form-group mb-3 row"> |
89 | 89 | <label for="wpinv_item_buy_url" class="col-sm-12 col-form-label"> |
90 | - <?php esc_html_e( 'Direct Payment URL', 'invoicing' ); ?> |
|
91 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'You can use this in an iFrame to embed the payment form on another website', 'invoicing' ); ?>"></span> |
|
90 | + <?php esc_html_e('Direct Payment URL', 'invoicing'); ?> |
|
91 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('You can use this in an iFrame to embed the payment form on another website', 'invoicing'); ?>"></span> |
|
92 | 92 | </label> |
93 | 93 | |
94 | 94 | <div class="col-sm-12"> |
95 | - <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url( getpaid_embed_url( false, $item->get_id() . '|0' ) ); ?>" style="width: 100%;" readonly/> |
|
95 | + <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url(getpaid_embed_url(false, $item->get_id() . '|0')); ?>" style="width: 100%;" readonly/> |
|
96 | 96 | </div> |
97 | 97 | </div> |
98 | 98 | |
99 | 99 | <?php endif; ?> |
100 | 100 | |
101 | 101 | <div class="wpinv_item_custom_id form-group mb-3"> |
102 | - <?php esc_html_e( 'Custom ID', 'invoicing' ); ?> — <?php echo esc_html( $item->get_custom_id() ); ?> |
|
102 | + <?php esc_html_e('Custom ID', 'invoicing'); ?> — <?php echo esc_html($item->get_custom_id()); ?> |
|
103 | 103 | </div> |
104 | 104 | |
105 | - <?php do_action( 'wpinv_meta_values_metabox_before', $post ); ?> |
|
106 | - <?php foreach ( apply_filters( 'wpinv_show_meta_values_for_keys', array() ) as $meta_key ) : ?> |
|
105 | + <?php do_action('wpinv_meta_values_metabox_before', $post); ?> |
|
106 | + <?php foreach (apply_filters('wpinv_show_meta_values_for_keys', array()) as $meta_key) : ?> |
|
107 | 107 | <div class="wpinv_item_custom_id form-group mb-3"> |
108 | - <?php echo esc_html( $meta_key ); ?> — <?php echo esc_html( get_post_meta( $item->get_id(), '_wpinv_' . $meta_key, true ) ); ?> |
|
108 | + <?php echo esc_html($meta_key); ?> — <?php echo esc_html(get_post_meta($item->get_id(), '_wpinv_' . $meta_key, true)); ?> |
|
109 | 109 | </div> |
110 | 110 | <?php endforeach; ?> |
111 | - <?php do_action( 'wpinv_meta_values_metabox_after', $post ); ?> |
|
112 | - <?php do_action( 'wpinv_item_info_metabox', $item ); ?> |
|
111 | + <?php do_action('wpinv_meta_values_metabox_after', $post); ?> |
|
112 | + <?php do_action('wpinv_item_info_metabox', $item); ?> |
|
113 | 113 | </div> |
114 | 114 | <?php |
115 | 115 | |
@@ -119,16 +119,16 @@ discard block |
||
119 | 119 | * Returns item type tolltip. |
120 | 120 | * |
121 | 121 | */ |
122 | - public static function get_tooltip( $post ) { |
|
122 | + public static function get_tooltip($post) { |
|
123 | 123 | |
124 | 124 | ob_start(); |
125 | 125 | ?> |
126 | 126 | |
127 | - <?php esc_html_e( 'Standard: Standard item type', 'invoicing' ); ?> |
|
128 | - <?php esc_html_e( 'Fee: Like Registration Fee, Sign up Fee etc', 'invoicing' ); ?> |
|
127 | + <?php esc_html_e('Standard: Standard item type', 'invoicing'); ?> |
|
128 | + <?php esc_html_e('Fee: Like Registration Fee, Sign up Fee etc', 'invoicing'); ?> |
|
129 | 129 | |
130 | 130 | <?php |
131 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
131 | + do_action('wpinv_item_info_metabox_after', $post); |
|
132 | 132 | |
133 | 133 | return ob_get_clean(); |
134 | 134 |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | $args = wp_parse_args( |
58 | 58 | $args, |
59 | 59 | array( |
60 | - 'status' => array( 'publish' ), |
|
61 | - 'limit' => get_option( 'posts_per_page' ), |
|
62 | - 'page' => 1, |
|
63 | - 'exclude' => array(), |
|
64 | - 'orderby' => 'date', |
|
65 | - 'order' => 'DESC', |
|
66 | - 'type' => wpinv_item_types(), |
|
67 | - 'meta_query' => array( |
|
60 | + 'status' => array( 'publish' ), |
|
61 | + 'limit' => get_option( 'posts_per_page' ), |
|
62 | + 'page' => 1, |
|
63 | + 'exclude' => array(), |
|
64 | + 'orderby' => 'date', |
|
65 | + 'order' => 'DESC', |
|
66 | + 'type' => wpinv_item_types(), |
|
67 | + 'meta_query' => array( |
|
68 | 68 | array( |
69 | 69 | 'key' => '_wpinv_one_time', |
70 | 70 | 'compare' => 'NOT EXISTS', |
71 | 71 | ), |
72 | 72 | ), |
73 | - 'return' => 'objects', |
|
74 | - 'paginate' => false, |
|
73 | + 'return' => 'objects', |
|
74 | + 'paginate' => false, |
|
75 | 75 | ) |
76 | 76 | ); |
77 | 77 | |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | |
212 | 212 | function wpinv_get_item_types() { |
213 | 213 | $item_types = array( |
214 | - 'custom' => __( 'Standard', 'invoicing' ), |
|
215 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
216 | - ); |
|
214 | + 'custom' => __( 'Standard', 'invoicing' ), |
|
215 | + 'fee' => __( 'Fee', 'invoicing' ), |
|
216 | + ); |
|
217 | 217 | return apply_filters( 'wpinv_get_item_types', $item_types ); |
218 | 218 | } |
219 | 219 | |
@@ -255,16 +255,16 @@ discard block |
||
255 | 255 | $args = array(); |
256 | 256 | if ( $post_ids ) { |
257 | 257 | $args = array( |
258 | - 'fields' => 'ids', |
|
259 | - ); |
|
258 | + 'fields' => 'ids', |
|
259 | + ); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | $args = array_merge( |
263 | 263 | $args, |
264 | 264 | array( |
265 | 265 | 'post_type' => 'wpi_item', |
266 | - 'orderby' => 'rand', |
|
267 | - 'post_count' => $num, |
|
266 | + 'orderby' => 'rand', |
|
267 | + 'post_count' => $num, |
|
268 | 268 | 'meta_query' => array( |
269 | 269 | array( |
270 | 270 | 'key' => '_wpinv_one_time', |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | $bill_times_less = $bill_times - 1; |
440 | 440 | |
441 | 441 | if ( ! empty( $bill_times ) ) { |
442 | - $bill_times = $item->get_recurring_interval() * $bill_times; |
|
442 | + $bill_times = $item->get_recurring_interval() * $bill_times; |
|
443 | 443 | $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() ); |
444 | - $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
445 | - } |
|
444 | + $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
445 | + } |
|
446 | 446 | |
447 | 447 | if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) { |
448 | 448 | $initial_price = wpinv_price( $item->get_sub_total(), $currency ); |
@@ -587,19 +587,19 @@ discard block |
||
587 | 587 | * @return bool Whether the item type supports the given feature. |
588 | 588 | */ |
589 | 589 | function getpaid_item_type_supports( $item_type, $feature, $item_ID = 0 ) { |
590 | - $supports = false; |
|
590 | + $supports = false; |
|
591 | 591 | |
592 | - if ( ! is_scalar( $item_type ) ) { |
|
593 | - return $supports; |
|
594 | - } |
|
592 | + if ( ! is_scalar( $item_type ) ) { |
|
593 | + return $supports; |
|
594 | + } |
|
595 | 595 | |
596 | - switch ( $feature ) { |
|
597 | - case 'buy_now': |
|
598 | - if ( '' === $item_type || 'fee' === $item_type || 'custom' === $item_type ) { |
|
599 | - $supports = true; |
|
600 | - } |
|
601 | - break; |
|
602 | - } |
|
596 | + switch ( $feature ) { |
|
597 | + case 'buy_now': |
|
598 | + if ( '' === $item_type || 'fee' === $item_type || 'custom' === $item_type ) { |
|
599 | + $supports = true; |
|
600 | + } |
|
601 | + break; |
|
602 | + } |
|
603 | 603 | |
604 | - return apply_filters( 'getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID ); |
|
604 | + return apply_filters( 'getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID ); |
|
605 | 605 | } |
606 | 606 | \ No newline at end of file |
@@ -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( $value ); |
|
29 | + if ('id' === strtolower($field)) { |
|
30 | + return wpinv_get_item_by_id($value); |
|
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,24 +41,24 @@ 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 | 57 | $args = wp_parse_args( |
58 | 58 | $args, |
59 | 59 | array( |
60 | - 'status' => array( 'publish' ), |
|
61 | - 'limit' => get_option( 'posts_per_page' ), |
|
60 | + 'status' => array('publish'), |
|
61 | + 'limit' => get_option('posts_per_page'), |
|
62 | 62 | 'page' => 1, |
63 | 63 | 'exclude' => array(), |
64 | 64 | 'orderby' => 'date', |
@@ -83,44 +83,44 @@ discard block |
||
83 | 83 | 'fields' => 'ids', |
84 | 84 | 'orderby' => $args['orderby'], |
85 | 85 | 'order' => $args['order'], |
86 | - 'paged' => absint( $args['page'] ), |
|
86 | + 'paged' => absint($args['page']), |
|
87 | 87 | ); |
88 | 88 | |
89 | - if ( ! empty( $args['exclude'] ) ) { |
|
90 | - $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] ); |
|
89 | + if (!empty($args['exclude'])) { |
|
90 | + $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']); |
|
91 | 91 | } |
92 | 92 | |
93 | - if ( ! $args['paginate'] ) { |
|
93 | + if (!$args['paginate']) { |
|
94 | 94 | $wp_query_args['no_found_rows'] = true; |
95 | 95 | } |
96 | 96 | |
97 | - if ( ! empty( $args['search'] ) ) { |
|
97 | + if (!empty($args['search'])) { |
|
98 | 98 | $wp_query_args['s'] = $args['search']; |
99 | 99 | } |
100 | 100 | |
101 | - if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) { |
|
102 | - $types = wpinv_parse_list( $args['type'] ); |
|
101 | + if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) { |
|
102 | + $types = wpinv_parse_list($args['type']); |
|
103 | 103 | $wp_query_args['meta_query'][] = array( |
104 | 104 | 'key' => '_wpinv_type', |
105 | - 'value' => implode( ',', $types ), |
|
105 | + 'value' => implode(',', $types), |
|
106 | 106 | 'compare' => 'IN', |
107 | 107 | ); |
108 | 108 | } |
109 | 109 | |
110 | - $wp_query_args = apply_filters( 'wpinv_get_items_args', $wp_query_args, $args ); |
|
110 | + $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args); |
|
111 | 111 | |
112 | 112 | // Get results. |
113 | - $items = new WP_Query( $wp_query_args ); |
|
113 | + $items = new WP_Query($wp_query_args); |
|
114 | 114 | |
115 | - if ( 'objects' === $args['return'] ) { |
|
116 | - $return = array_map( 'wpinv_get_item_by_id', $items->posts ); |
|
117 | - } elseif ( 'self' === $args['return'] ) { |
|
115 | + if ('objects' === $args['return']) { |
|
116 | + $return = array_map('wpinv_get_item_by_id', $items->posts); |
|
117 | + } elseif ('self' === $args['return']) { |
|
118 | 118 | return $items; |
119 | 119 | } else { |
120 | 120 | $return = $items->posts; |
121 | 121 | } |
122 | 122 | |
123 | - if ( $args['paginate'] ) { |
|
123 | + if ($args['paginate']) { |
|
124 | 124 | return (object) array( |
125 | 125 | 'items' => $return, |
126 | 126 | 'total' => $items->found_posts, |
@@ -132,12 +132,12 @@ discard block |
||
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | -function wpinv_is_free_item( $item_id = 0 ) { |
|
136 | - if ( empty( $item_id ) ) { |
|
135 | +function wpinv_is_free_item($item_id = 0) { |
|
136 | + if (empty($item_id)) { |
|
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | |
140 | - $item = new WPInv_Item( $item_id ); |
|
140 | + $item = new WPInv_Item($item_id); |
|
141 | 141 | |
142 | 142 | return $item->is_free(); |
143 | 143 | } |
@@ -147,21 +147,21 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @param WP_Post|WPInv_Item|Int $item The item to check for. |
149 | 149 | */ |
150 | -function wpinv_item_is_editable( $item = 0 ) { |
|
150 | +function wpinv_item_is_editable($item = 0) { |
|
151 | 151 | |
152 | 152 | // Fetch the item. |
153 | - $item = new WPInv_Item( $item ); |
|
153 | + $item = new WPInv_Item($item); |
|
154 | 154 | |
155 | 155 | // Check if it is editable. |
156 | 156 | return $item->is_editable(); |
157 | 157 | } |
158 | 158 | |
159 | -function wpinv_get_item_price( $item_id = 0 ) { |
|
160 | - if ( empty( $item_id ) ) { |
|
159 | +function wpinv_get_item_price($item_id = 0) { |
|
160 | + if (empty($item_id)) { |
|
161 | 161 | return false; |
162 | 162 | } |
163 | 163 | |
164 | - $item = new WPInv_Item( $item_id ); |
|
164 | + $item = new WPInv_Item($item_id); |
|
165 | 165 | |
166 | 166 | return $item->get_price(); |
167 | 167 | } |
@@ -171,89 +171,89 @@ discard block |
||
171 | 171 | * |
172 | 172 | * @param WPInv_Item|int $item |
173 | 173 | */ |
174 | -function wpinv_is_recurring_item( $item = 0 ) { |
|
175 | - $item = new WPInv_Item( $item ); |
|
174 | +function wpinv_is_recurring_item($item = 0) { |
|
175 | + $item = new WPInv_Item($item); |
|
176 | 176 | return $item->is_recurring(); |
177 | 177 | } |
178 | 178 | |
179 | -function wpinv_item_price( $item_id = 0 ) { |
|
180 | - if ( empty( $item_id ) ) { |
|
179 | +function wpinv_item_price($item_id = 0) { |
|
180 | + if (empty($item_id)) { |
|
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | |
184 | - $price = wpinv_get_item_price( $item_id ); |
|
185 | - $price = wpinv_price( $price ); |
|
184 | + $price = wpinv_get_item_price($item_id); |
|
185 | + $price = wpinv_price($price); |
|
186 | 186 | |
187 | - return apply_filters( 'wpinv_item_price', $price, $item_id ); |
|
187 | + return apply_filters('wpinv_item_price', $price, $item_id); |
|
188 | 188 | } |
189 | 189 | |
190 | -function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) { |
|
191 | - if ( is_null( $amount_override ) ) { |
|
192 | - $original_price = get_post_meta( $item_id, '_wpinv_price', true ); |
|
190 | +function wpinv_get_item_final_price($item_id = 0, $amount_override = null) { |
|
191 | + if (is_null($amount_override)) { |
|
192 | + $original_price = get_post_meta($item_id, '_wpinv_price', true); |
|
193 | 193 | } else { |
194 | 194 | $original_price = $amount_override; |
195 | 195 | } |
196 | 196 | |
197 | 197 | $price = $original_price; |
198 | 198 | |
199 | - return apply_filters( 'wpinv_get_item_final_price', $price, $item_id ); |
|
199 | + return apply_filters('wpinv_get_item_final_price', $price, $item_id); |
|
200 | 200 | } |
201 | 201 | |
202 | -function wpinv_item_custom_singular_name( $item_id ) { |
|
203 | - if ( empty( $item_id ) ) { |
|
202 | +function wpinv_item_custom_singular_name($item_id) { |
|
203 | + if (empty($item_id)) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | |
207 | - $item = new WPInv_Item( $item_id ); |
|
207 | + $item = new WPInv_Item($item_id); |
|
208 | 208 | |
209 | 209 | return $item->get_custom_singular_name(); |
210 | 210 | } |
211 | 211 | |
212 | 212 | function wpinv_get_item_types() { |
213 | 213 | $item_types = array( |
214 | - 'custom' => __( 'Standard', 'invoicing' ), |
|
215 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
214 | + 'custom' => __('Standard', 'invoicing'), |
|
215 | + 'fee' => __('Fee', 'invoicing'), |
|
216 | 216 | ); |
217 | - return apply_filters( 'wpinv_get_item_types', $item_types ); |
|
217 | + return apply_filters('wpinv_get_item_types', $item_types); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | function wpinv_item_types() { |
221 | 221 | $item_types = wpinv_get_item_types(); |
222 | 222 | |
223 | - return ( ! empty( $item_types ) ? array_keys( $item_types ) : array() ); |
|
223 | + return (!empty($item_types) ? array_keys($item_types) : array()); |
|
224 | 224 | } |
225 | 225 | |
226 | -function wpinv_get_item_type( $item_id ) { |
|
227 | - if ( empty( $item_id ) ) { |
|
226 | +function wpinv_get_item_type($item_id) { |
|
227 | + if (empty($item_id)) { |
|
228 | 228 | return false; |
229 | 229 | } |
230 | 230 | |
231 | - $item = new WPInv_Item( $item_id ); |
|
231 | + $item = new WPInv_Item($item_id); |
|
232 | 232 | |
233 | 233 | return $item->get_type(); |
234 | 234 | } |
235 | 235 | |
236 | -function wpinv_item_type( $item_id ) { |
|
236 | +function wpinv_item_type($item_id) { |
|
237 | 237 | $item_types = wpinv_get_item_types(); |
238 | 238 | |
239 | - $item_type = wpinv_get_item_type( $item_id ); |
|
239 | + $item_type = wpinv_get_item_type($item_id); |
|
240 | 240 | |
241 | - if ( empty( $item_type ) ) { |
|
241 | + if (empty($item_type)) { |
|
242 | 242 | $item_type = '-'; |
243 | 243 | } |
244 | 244 | |
245 | - $item_type = isset( $item_types[ $item_type ] ) ? $item_types[ $item_type ] : __( $item_type, 'invoicing' ); |
|
245 | + $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing'); |
|
246 | 246 | |
247 | - return apply_filters( 'wpinv_item_type', $item_type, $item_id ); |
|
247 | + return apply_filters('wpinv_item_type', $item_type, $item_id); |
|
248 | 248 | } |
249 | 249 | |
250 | -function wpinv_get_random_item( $post_ids = true ) { |
|
251 | - wpinv_get_random_items( 1, $post_ids ); |
|
250 | +function wpinv_get_random_item($post_ids = true) { |
|
251 | + wpinv_get_random_items(1, $post_ids); |
|
252 | 252 | } |
253 | 253 | |
254 | -function wpinv_get_random_items( $num = 3, $post_ids = true ) { |
|
254 | +function wpinv_get_random_items($num = 3, $post_ids = true) { |
|
255 | 255 | $args = array(); |
256 | - if ( $post_ids ) { |
|
256 | + if ($post_ids) { |
|
257 | 257 | $args = array( |
258 | 258 | 'fields' => 'ids', |
259 | 259 | ); |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | ) |
275 | 275 | ); |
276 | 276 | |
277 | - $args = apply_filters( 'wpinv_get_random_items', $args ); |
|
277 | + $args = apply_filters('wpinv_get_random_items', $args); |
|
278 | 278 | |
279 | - return get_posts( $args ); |
|
279 | + return get_posts($args); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -285,13 +285,13 @@ discard block |
||
285 | 285 | * @param WPInv_Item|int $item |
286 | 286 | * @param bool $html |
287 | 287 | */ |
288 | -function wpinv_get_item_suffix( $item, $html = true ) { |
|
288 | +function wpinv_get_item_suffix($item, $html = true) { |
|
289 | 289 | |
290 | - $item = new WPInv_Item( $item ); |
|
291 | - $suffix = $item->is_recurring() ? ' ' . __( '(r)', 'invoicing' ) : ''; |
|
292 | - $suffix = $html ? $suffix : wp_strip_all_tags( $suffix ); |
|
290 | + $item = new WPInv_Item($item); |
|
291 | + $suffix = $item->is_recurring() ? ' ' . __('(r)', 'invoicing') : ''; |
|
292 | + $suffix = $html ? $suffix : wp_strip_all_tags($suffix); |
|
293 | 293 | |
294 | - return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html ); |
|
294 | + return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | * @param WPInv_Item|int $item |
301 | 301 | * @param bool $force_delete |
302 | 302 | */ |
303 | -function wpinv_remove_item( $item = 0, $force_delete = false ) { |
|
304 | - $item = new WPInv_Item( $item ); |
|
305 | - $item->delete( $force_delete ); |
|
303 | +function wpinv_remove_item($item = 0, $force_delete = false) { |
|
304 | + $item = new WPInv_Item($item); |
|
305 | + $item->delete($force_delete); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -341,44 +341,44 @@ discard block |
||
341 | 341 | * @param bool $wp_error whether or not to return a WP_Error on failure. |
342 | 342 | * @return bool|WP_Error|WPInv_Item |
343 | 343 | */ |
344 | -function wpinv_create_item( $args = array(), $wp_error = false ) { |
|
344 | +function wpinv_create_item($args = array(), $wp_error = false) { |
|
345 | 345 | |
346 | 346 | // Prepare the item. |
347 | - if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) { |
|
348 | - $type = empty( $args['type'] ) ? 'custom' : $args['type']; |
|
349 | - $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type ); |
|
347 | + if (!empty($args['custom_id']) && empty($args['ID'])) { |
|
348 | + $type = empty($args['type']) ? 'custom' : $args['type']; |
|
349 | + $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type); |
|
350 | 350 | |
351 | - if ( ! empty( $item ) ) { |
|
351 | + if (!empty($item)) { |
|
352 | 352 | $args['ID'] = $item->get_id(); |
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
356 | 356 | // Do we have an item? |
357 | - if ( ! empty( $args['ID'] ) ) { |
|
358 | - $item = new WPInv_Item( $args['ID'] ); |
|
357 | + if (!empty($args['ID'])) { |
|
358 | + $item = new WPInv_Item($args['ID']); |
|
359 | 359 | } else { |
360 | 360 | $item = new WPInv_Item(); |
361 | 361 | } |
362 | 362 | |
363 | 363 | // Do we have an error? |
364 | - if ( ! empty( $item->last_error ) ) { |
|
365 | - return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false; |
|
364 | + if (!empty($item->last_error)) { |
|
365 | + return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | // Update item props. |
369 | - $item->set_props( $args ); |
|
369 | + $item->set_props($args); |
|
370 | 370 | |
371 | 371 | // Save the item. |
372 | 372 | $item->save(); |
373 | 373 | |
374 | 374 | // Do we have an error? |
375 | - if ( ! empty( $item->last_error ) ) { |
|
376 | - return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false; |
|
375 | + if (!empty($item->last_error)) { |
|
376 | + return $wp_error ? new WP_Error('not_saved', $item->last_error) : false; |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | // Was the item saved? |
380 | - if ( ! $item->get_id() ) { |
|
381 | - return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false; |
|
380 | + if (!$item->get_id()) { |
|
381 | + return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false; |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | return $item; |
@@ -390,14 +390,14 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @see wpinv_create_item() |
392 | 392 | */ |
393 | -function wpinv_update_item( $args = array(), $wp_error = false ) { |
|
394 | - return wpinv_create_item( $args, $wp_error ); |
|
393 | +function wpinv_update_item($args = array(), $wp_error = false) { |
|
394 | + return wpinv_create_item($args, $wp_error); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
398 | 398 | * Sanitizes a recurring period |
399 | 399 | */ |
400 | -function getpaid_sanitize_recurring_period( $period, $full = false ) { |
|
400 | +function getpaid_sanitize_recurring_period($period, $full = false) { |
|
401 | 401 | |
402 | 402 | $periods = array( |
403 | 403 | 'D' => 'day', |
@@ -406,16 +406,16 @@ discard block |
||
406 | 406 | 'Y' => 'year', |
407 | 407 | ); |
408 | 408 | |
409 | - if ( ! isset( $periods[ $period ] ) ) { |
|
409 | + if (!isset($periods[$period])) { |
|
410 | 410 | $period = 'D'; |
411 | 411 | } |
412 | 412 | |
413 | - return $full ? $periods[ $period ] : $period; |
|
413 | + return $full ? $periods[$period] : $period; |
|
414 | 414 | |
415 | 415 | } |
416 | 416 | |
417 | -function wpinv_item_max_buyable_quantity( $item_id ) { |
|
418 | - return apply_filters( 'wpinv_item_max_buyable_quantity', 5, $item_id ); |
|
417 | +function wpinv_item_max_buyable_quantity($item_id) { |
|
418 | + return apply_filters('wpinv_item_max_buyable_quantity', 5, $item_id); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -423,47 +423,47 @@ discard block |
||
423 | 423 | * |
424 | 424 | * @param WPInv_Item|GetPaid_Form_Item $item |
425 | 425 | */ |
426 | -function getpaid_item_recurring_price_help_text( $item, $currency = '', $_initial_price = false, $_recurring_price = false ) { |
|
426 | +function getpaid_item_recurring_price_help_text($item, $currency = '', $_initial_price = false, $_recurring_price = false) { |
|
427 | 427 | |
428 | 428 | // Abort if it is not recurring. |
429 | - if ( ! $item->is_recurring() ) { |
|
429 | + if (!$item->is_recurring()) { |
|
430 | 430 | return ''; |
431 | 431 | } |
432 | 432 | |
433 | - $initial_price = false === $_initial_price ? wpinv_price( $item->get_initial_price(), $currency ) : $_initial_price; |
|
434 | - $recurring_price = false === $_recurring_price ? wpinv_price( $item->get_recurring_price(), $currency ) : $_recurring_price; |
|
435 | - $period = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ); |
|
433 | + $initial_price = false === $_initial_price ? wpinv_price($item->get_initial_price(), $currency) : $_initial_price; |
|
434 | + $recurring_price = false === $_recurring_price ? wpinv_price($item->get_recurring_price(), $currency) : $_recurring_price; |
|
435 | + $period = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), ''); |
|
436 | 436 | $initial_class = 'getpaid-item-initial-price'; |
437 | 437 | $recurring_class = 'getpaid-item-recurring-price'; |
438 | 438 | $bill_times = $item->get_recurring_limit(); |
439 | 439 | $bill_times_less = $bill_times - 1; |
440 | 440 | |
441 | - if ( ! empty( $bill_times ) ) { |
|
441 | + if (!empty($bill_times)) { |
|
442 | 442 | $bill_times = $item->get_recurring_interval() * $bill_times; |
443 | - $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() ); |
|
444 | - $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
443 | + $bill_times_less = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times - $item->get_recurring_interval()); |
|
444 | + $bill_times = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times); |
|
445 | 445 | } |
446 | 446 | |
447 | - if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) { |
|
448 | - $initial_price = wpinv_price( $item->get_sub_total(), $currency ); |
|
449 | - $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency ); |
|
447 | + if ($item instanceof GetPaid_Form_Item && false === $_initial_price) { |
|
448 | + $initial_price = wpinv_price($item->get_sub_total(), $currency); |
|
449 | + $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency); |
|
450 | 450 | } |
451 | 451 | |
452 | - if ( wpinv_price( 0, $currency ) == $initial_price && wpinv_price( 0, $currency ) == $recurring_price ) { |
|
453 | - return __( 'Free forever', 'invoicing' ); |
|
452 | + if (wpinv_price(0, $currency) == $initial_price && wpinv_price(0, $currency) == $recurring_price) { |
|
453 | + return __('Free forever', 'invoicing'); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | // For free trial items. |
457 | - if ( $item->has_free_trial() ) { |
|
458 | - $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() ); |
|
457 | + if ($item->has_free_trial()) { |
|
458 | + $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval()); |
|
459 | 459 | |
460 | - if ( wpinv_price( 0, $currency ) == $initial_price ) { |
|
460 | + if (wpinv_price(0, $currency) == $initial_price) { |
|
461 | 461 | |
462 | - if ( empty( $bill_times ) ) { |
|
462 | + if (empty($bill_times)) { |
|
463 | 463 | |
464 | 464 | return sprintf( |
465 | 465 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period |
466 | - _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ), |
|
466 | + _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'), |
|
467 | 467 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
468 | 468 | "<span class='$recurring_class'>$recurring_price</span>", |
469 | 469 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | |
474 | 474 | return sprintf( |
475 | 475 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period, $4: is the bill times |
476 | - _x( 'Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing' ), |
|
476 | + _x('Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing'), |
|
477 | 477 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
478 | 478 | "<span class='$recurring_class'>$recurring_price</span>", |
479 | 479 | "<span class='getpaid-item-recurring-period'>$period</span>", |
@@ -482,11 +482,11 @@ discard block |
||
482 | 482 | |
483 | 483 | } |
484 | 484 | |
485 | - if ( empty( $bill_times ) ) { |
|
485 | + if (empty($bill_times)) { |
|
486 | 486 | |
487 | 487 | return sprintf( |
488 | 488 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period |
489 | - _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ), |
|
489 | + _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'), |
|
490 | 490 | "<span class='$initial_class'>$initial_price</span>", |
491 | 491 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
492 | 492 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | |
498 | 498 | return sprintf( |
499 | 499 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period, $4: is the susbcription bill times |
500 | - _x( '%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing' ), |
|
500 | + _x('%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing'), |
|
501 | 501 | "<span class='$initial_class'>$initial_price</span>", |
502 | 502 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
503 | 503 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -507,13 +507,13 @@ discard block |
||
507 | 507 | |
508 | 508 | } |
509 | 509 | |
510 | - if ( $initial_price == $recurring_price ) { |
|
510 | + if ($initial_price == $recurring_price) { |
|
511 | 511 | |
512 | - if ( empty( $bill_times ) ) { |
|
512 | + if (empty($bill_times)) { |
|
513 | 513 | |
514 | 514 | return sprintf( |
515 | 515 | // translators: $1: is the recurring price, $2: is the susbcription period |
516 | - _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
516 | + _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
517 | 517 | "<span class='$recurring_class'>$recurring_price</span>", |
518 | 518 | "<span class='getpaid-item-recurring-period'>$period</span>" |
519 | 519 | ); |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | |
523 | 523 | return sprintf( |
524 | 524 | // translators: $1: is the recurring price, $2: is the susbcription period, $3: is the susbcription bill times |
525 | - _x( '%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ), |
|
525 | + _x('%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'), |
|
526 | 526 | "<span class='$recurring_class'>$recurring_price</span>", |
527 | 527 | "<span class='getpaid-item-recurring-period'>$period</span>", |
528 | 528 | "<span class='getpaid-item-recurring-bill-times'>$bill_times</span>" |
@@ -530,13 +530,13 @@ discard block |
||
530 | 530 | |
531 | 531 | } |
532 | 532 | |
533 | - if ( $initial_price == wpinv_price( 0, $currency ) ) { |
|
533 | + if ($initial_price == wpinv_price(0, $currency)) { |
|
534 | 534 | |
535 | - if ( empty( $bill_times ) ) { |
|
535 | + if (empty($bill_times)) { |
|
536 | 536 | |
537 | 537 | return sprintf( |
538 | 538 | // translators: $1: is the recurring period, $2: is the recurring price |
539 | - _x( 'Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing' ), |
|
539 | + _x('Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing'), |
|
540 | 540 | "<span class='getpaid-item-recurring-period'>$period</span>", |
541 | 541 | "<span class='$recurring_class'>$recurring_price</span>" |
542 | 542 | ); |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | |
546 | 546 | return sprintf( |
547 | 547 | // translators: $1: is the recurring period, $2: is the recurring price, $3: is the bill times |
548 | - _x( 'Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing' ), |
|
548 | + _x('Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing'), |
|
549 | 549 | "<span class='getpaid-item-recurring-period'>$period</span>", |
550 | 550 | "<span class='$recurring_class'>$recurring_price</span>", |
551 | 551 | "<span class='getpaid-item-recurring-bill-times'>$bill_times_less</span>" |
@@ -553,11 +553,11 @@ discard block |
||
553 | 553 | |
554 | 554 | } |
555 | 555 | |
556 | - if ( empty( $bill_times ) ) { |
|
556 | + if (empty($bill_times)) { |
|
557 | 557 | |
558 | 558 | return sprintf( |
559 | 559 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period |
560 | - _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ), |
|
560 | + _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'), |
|
561 | 561 | "<span class='$initial_class'>$initial_price</span>", |
562 | 562 | "<span class='$recurring_class'>$recurring_price</span>", |
563 | 563 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | |
568 | 568 | return sprintf( |
569 | 569 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period, $4: is the susbcription bill times |
570 | - _x( 'Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing' ), |
|
570 | + _x('Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing'), |
|
571 | 571 | "<span class='$initial_class'>$initial_price</span>", |
572 | 572 | "<span class='$recurring_class'>$recurring_price</span>", |
573 | 573 | "<span class='getpaid-item-recurring-period'>$period</span>", |
@@ -586,20 +586,20 @@ discard block |
||
586 | 586 | * @param int $item_ID The item post ID. Optional. |
587 | 587 | * @return bool Whether the item type supports the given feature. |
588 | 588 | */ |
589 | -function getpaid_item_type_supports( $item_type, $feature, $item_ID = 0 ) { |
|
589 | +function getpaid_item_type_supports($item_type, $feature, $item_ID = 0) { |
|
590 | 590 | $supports = false; |
591 | 591 | |
592 | - if ( ! is_scalar( $item_type ) ) { |
|
592 | + if (!is_scalar($item_type)) { |
|
593 | 593 | return $supports; |
594 | 594 | } |
595 | 595 | |
596 | - switch ( $feature ) { |
|
596 | + switch ($feature) { |
|
597 | 597 | case 'buy_now': |
598 | - if ( '' === $item_type || 'fee' === $item_type || 'custom' === $item_type ) { |
|
598 | + if ('' === $item_type || 'fee' === $item_type || 'custom' === $item_type) { |
|
599 | 599 | $supports = true; |
600 | 600 | } |
601 | 601 | break; |
602 | 602 | } |
603 | 603 | |
604 | - return apply_filters( 'getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID ); |
|
604 | + return apply_filters('getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID); |
|
605 | 605 | } |
606 | 606 | \ No newline at end of file |