@@ -1,47 +1,47 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' ); |
|
8 | -function wpinv_discount_columns( $existing_columns ) { |
|
7 | +add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns'); |
|
8 | +function wpinv_discount_columns($existing_columns) { |
|
9 | 9 | $columns = array(); |
10 | 10 | $columns['cb'] = $existing_columns['cb']; |
11 | - $columns['name'] = __( 'Name', 'invoicing' ); |
|
12 | - $columns['code'] = __( 'Code', 'invoicing' ); |
|
13 | - $columns['amount'] = __( 'Amount', 'invoicing' ); |
|
14 | - $columns['usage'] = __( 'Usage / Limit', 'invoicing' ); |
|
15 | - $columns['start_date'] = __( 'Start Date', 'invoicing' ); |
|
16 | - $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' ); |
|
17 | - $columns['status'] = __( 'Status', 'invoicing' ); |
|
11 | + $columns['name'] = __('Name', 'invoicing'); |
|
12 | + $columns['code'] = __('Code', 'invoicing'); |
|
13 | + $columns['amount'] = __('Amount', 'invoicing'); |
|
14 | + $columns['usage'] = __('Usage / Limit', 'invoicing'); |
|
15 | + $columns['start_date'] = __('Start Date', 'invoicing'); |
|
16 | + $columns['expiry_date'] = __('Expiry Date', 'invoicing'); |
|
17 | + $columns['status'] = __('Status', 'invoicing'); |
|
18 | 18 | |
19 | 19 | return $columns; |
20 | 20 | } |
21 | 21 | |
22 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
23 | -function wpinv_discount_custom_column( $column ) { |
|
22 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
23 | +function wpinv_discount_custom_column($column) { |
|
24 | 24 | global $post; |
25 | 25 | |
26 | 26 | $discount = $post; |
27 | 27 | |
28 | - switch ( $column ) { |
|
28 | + switch ($column) { |
|
29 | 29 | case 'name' : |
30 | - echo get_the_title( $discount->ID ); |
|
30 | + echo get_the_title($discount->ID); |
|
31 | 31 | break; |
32 | 32 | case 'code' : |
33 | - echo wpinv_get_discount_code( $discount->ID ); |
|
33 | + echo wpinv_get_discount_code($discount->ID); |
|
34 | 34 | break; |
35 | 35 | case 'amount' : |
36 | - echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) ); |
|
36 | + echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID)); |
|
37 | 37 | break; |
38 | 38 | case 'usage_limit' : |
39 | - echo wpinv_get_discount_uses( $discount->ID ); |
|
39 | + echo wpinv_get_discount_uses($discount->ID); |
|
40 | 40 | break; |
41 | 41 | case 'usage' : |
42 | - $usage = wpinv_get_discount_uses( $discount->ID ) . ' / '; |
|
43 | - if ( wpinv_get_discount_max_uses( $discount->ID ) ) { |
|
44 | - $usage .= wpinv_get_discount_max_uses( $discount->ID ); |
|
42 | + $usage = wpinv_get_discount_uses($discount->ID) . ' / '; |
|
43 | + if (wpinv_get_discount_max_uses($discount->ID)) { |
|
44 | + $usage .= wpinv_get_discount_max_uses($discount->ID); |
|
45 | 45 | } else { |
46 | 46 | $usage .= ' ∞'; |
47 | 47 | } |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | echo $usage; |
50 | 50 | break; |
51 | 51 | case 'start_date' : |
52 | - if ( $start_date = wpinv_get_discount_start_date( $discount->ID ) ) { |
|
53 | - $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $start_date ) ); |
|
52 | + if ($start_date = wpinv_get_discount_start_date($discount->ID)) { |
|
53 | + $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($start_date)); |
|
54 | 54 | } else { |
55 | 55 | $value = '-'; |
56 | 56 | } |
@@ -58,163 +58,163 @@ discard block |
||
58 | 58 | echo $value; |
59 | 59 | break; |
60 | 60 | case 'expiry_date' : |
61 | - if ( $expiration = wpinv_get_discount_expiration( $discount->ID ) ) { |
|
62 | - $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $expiration ) ); |
|
61 | + if ($expiration = wpinv_get_discount_expiration($discount->ID)) { |
|
62 | + $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($expiration)); |
|
63 | 63 | } else { |
64 | - $value = __( 'Never', 'invoicing' ); |
|
64 | + $value = __('Never', 'invoicing'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | echo $value; |
68 | 68 | break; |
69 | 69 | break; |
70 | 70 | case 'description' : |
71 | - echo wp_kses_post( $post->post_excerpt ); |
|
71 | + echo wp_kses_post($post->post_excerpt); |
|
72 | 72 | break; |
73 | 73 | case 'status' : |
74 | - $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status; |
|
74 | + $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status; |
|
75 | 75 | |
76 | - echo wpinv_discount_status( $status ); |
|
76 | + echo wpinv_discount_status($status); |
|
77 | 77 | break; |
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 ); |
|
82 | -function wpinv_post_row_actions( $actions, $post ) { |
|
83 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
81 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2); |
|
82 | +function wpinv_post_row_actions($actions, $post) { |
|
83 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
84 | 84 | |
85 | - if ( $post_type == 'wpi_invoice' ) { |
|
85 | + if ($post_type == 'wpi_invoice') { |
|
86 | 86 | $actions = array(); |
87 | 87 | } |
88 | 88 | |
89 | - if ( $post_type == 'wpi_discount' ) { |
|
90 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
89 | + if ($post_type == 'wpi_discount') { |
|
90 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | return $actions; |
94 | 94 | } |
95 | 95 | |
96 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
97 | - $row_actions = array(); |
|
98 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
99 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
96 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
97 | + $row_actions = array(); |
|
98 | + $edit_link = get_edit_post_link($discount->ID); |
|
99 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
100 | 100 | |
101 | - if( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
102 | - $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>'; |
|
103 | - } elseif( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
104 | - $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>'; |
|
101 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
102 | + $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>'; |
|
103 | + } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
104 | + $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>'; |
|
105 | 105 | } |
106 | 106 | |
107 | - if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) { |
|
108 | - if ( isset( $row_actions['delete'] ) ) { |
|
109 | - unset( $row_actions['delete'] ); // Don't delete used discounts. |
|
107 | + if (wpinv_get_discount_uses($discount->ID) > 0) { |
|
108 | + if (isset($row_actions['delete'])) { |
|
109 | + unset($row_actions['delete']); // Don't delete used discounts. |
|
110 | 110 | } |
111 | 111 | } else { |
112 | - $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>'; |
|
112 | + $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>'; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
116 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
116 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
117 | 117 | |
118 | 118 | return $row_actions; |
119 | 119 | } |
120 | 120 | |
121 | -add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 ); |
|
122 | -function wpinv_table_primary_column( $default, $screen_id ) { |
|
123 | - if ( 'edit-wpi_invoice' === $screen_id ) { |
|
121 | +add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2); |
|
122 | +function wpinv_table_primary_column($default, $screen_id) { |
|
123 | + if ('edit-wpi_invoice' === $screen_id) { |
|
124 | 124 | return 'name'; |
125 | 125 | } |
126 | 126 | |
127 | 127 | return $default; |
128 | 128 | } |
129 | 129 | |
130 | -function wpinv_discount_bulk_actions( $actions, $display = false ) { |
|
131 | - if ( !$display ) { |
|
130 | +function wpinv_discount_bulk_actions($actions, $display = false) { |
|
131 | + if (!$display) { |
|
132 | 132 | return array(); |
133 | 133 | } |
134 | 134 | |
135 | 135 | $actions = array( |
136 | - 'activate' => __( 'Activate', 'invoicing' ), |
|
137 | - 'deactivate' => __( 'Deactivate', 'invoicing' ), |
|
138 | - 'delete' => __( 'Delete', 'invoicing' ), |
|
136 | + 'activate' => __('Activate', 'invoicing'), |
|
137 | + 'deactivate' => __('Deactivate', 'invoicing'), |
|
138 | + 'delete' => __('Delete', 'invoicing'), |
|
139 | 139 | ); |
140 | 140 | $two = ''; |
141 | 141 | $which = 'top'; |
142 | 142 | echo '</div><div class="alignleft actions bulkactions">'; |
143 | - echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>'; |
|
144 | - echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">"; |
|
145 | - echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>"; |
|
143 | + echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>'; |
|
144 | + echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">"; |
|
145 | + echo '<option value="-1">' . __('Bulk Actions') . "</option>"; |
|
146 | 146 | |
147 | - foreach ( $actions as $name => $title ) { |
|
147 | + foreach ($actions as $name => $title) { |
|
148 | 148 | $class = 'edit' === $name ? ' class="hide-if-no-js"' : ''; |
149 | 149 | |
150 | 150 | echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>"; |
151 | 151 | } |
152 | 152 | echo "</select>"; |
153 | 153 | |
154 | - submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
|
154 | + submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two")); |
|
155 | 155 | |
156 | 156 | echo '</div><div class="alignleft actions">'; |
157 | 157 | } |
158 | -add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 ); |
|
158 | +add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10); |
|
159 | 159 | |
160 | -function wpinv_disable_months_dropdown( $disable, $post_type ) { |
|
161 | - if ( $post_type == 'wpi_discount' ) { |
|
160 | +function wpinv_disable_months_dropdown($disable, $post_type) { |
|
161 | + if ($post_type == 'wpi_discount') { |
|
162 | 162 | $disable = true; |
163 | 163 | } |
164 | 164 | |
165 | 165 | return $disable; |
166 | 166 | } |
167 | -add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 ); |
|
167 | +add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2); |
|
168 | 168 | |
169 | 169 | function wpinv_restrict_manage_posts() { |
170 | 170 | global $typenow; |
171 | 171 | |
172 | - if( 'wpi_discount' == $typenow ) { |
|
172 | + if ('wpi_discount' == $typenow) { |
|
173 | 173 | wpinv_discount_filters(); |
174 | 174 | } |
175 | 175 | } |
176 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
176 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
177 | 177 | |
178 | 178 | function wpinv_discount_filters() { |
179 | - echo wpinv_discount_bulk_actions( array(), true ); |
|
179 | + echo wpinv_discount_bulk_actions(array(), true); |
|
180 | 180 | |
181 | 181 | ?> |
182 | 182 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
183 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
183 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
184 | 184 | <?php |
185 | 185 | $types = wpinv_get_discount_types(); |
186 | 186 | |
187 | - foreach ( $types as $name => $type ) { |
|
188 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
187 | + foreach ($types as $name => $type) { |
|
188 | + echo '<option value="' . esc_attr($name) . '"'; |
|
189 | 189 | |
190 | - if ( isset( $_GET['discount_type'] ) ) |
|
191 | - selected( $name, $_GET['discount_type'] ); |
|
190 | + if (isset($_GET['discount_type'])) |
|
191 | + selected($name, $_GET['discount_type']); |
|
192 | 192 | |
193 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
193 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
194 | 194 | } |
195 | 195 | ?> |
196 | 196 | </select> |
197 | 197 | <?php |
198 | 198 | } |
199 | 199 | |
200 | -function wpinv_request( $vars ) { |
|
200 | +function wpinv_request($vars) { |
|
201 | 201 | global $typenow, $wp_query, $wp_post_statuses; |
202 | 202 | |
203 | - if ( 'wpi_invoice' === $typenow ) { |
|
204 | - if ( !isset( $vars['post_status'] ) ) { |
|
203 | + if ('wpi_invoice' === $typenow) { |
|
204 | + if (!isset($vars['post_status'])) { |
|
205 | 205 | $post_statuses = wpinv_get_invoice_statuses(); |
206 | 206 | |
207 | - foreach ( $post_statuses as $status => $value ) { |
|
208 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
209 | - unset( $post_statuses[ $status ] ); |
|
207 | + foreach ($post_statuses as $status => $value) { |
|
208 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
209 | + unset($post_statuses[$status]); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
213 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
213 | + $vars['post_status'] = array_keys($post_statuses); |
|
214 | 214 | } |
215 | 215 | |
216 | - if ( isset( $vars['orderby'] ) ) { |
|
217 | - if ( 'amount' == $vars['orderby'] ) { |
|
216 | + if (isset($vars['orderby'])) { |
|
217 | + if ('amount' == $vars['orderby']) { |
|
218 | 218 | $vars = array_merge( |
219 | 219 | $vars, |
220 | 220 | array( |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | 'orderby' => 'meta_value_num' |
223 | 223 | ) |
224 | 224 | ); |
225 | - } else if ( 'customer' == $vars['orderby'] ) { |
|
225 | + } else if ('customer' == $vars['orderby']) { |
|
226 | 226 | $vars = array_merge( |
227 | 227 | $vars, |
228 | 228 | array( |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | 'orderby' => 'meta_value' |
231 | 231 | ) |
232 | 232 | ); |
233 | - } else if ( 'number' == $vars['orderby'] ) { |
|
233 | + } else if ('number' == $vars['orderby']) { |
|
234 | 234 | $vars = array_merge( |
235 | 235 | $vars, |
236 | 236 | array( |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | 'orderby' => 'meta_value' |
239 | 239 | ) |
240 | 240 | ); |
241 | - } else if ( 'payment_date' == $vars['orderby'] ) { |
|
241 | + } else if ('payment_date' == $vars['orderby']) { |
|
242 | 242 | $vars = array_merge( |
243 | 243 | $vars, |
244 | 244 | array( |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | ); |
249 | 249 | } |
250 | 250 | } |
251 | - } else if ( 'wpi_item' == $typenow ) { |
|
251 | + } else if ('wpi_item' == $typenow) { |
|
252 | 252 | // Check if 'orderby' is set to "price" |
253 | - if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) { |
|
253 | + if (isset($vars['orderby']) && 'price' == $vars['orderby']) { |
|
254 | 254 | $vars = array_merge( |
255 | 255 | $vars, |
256 | 256 | array( |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | // Check if "orderby" is set to "vat_rule" |
264 | - if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) { |
|
264 | + if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) { |
|
265 | 265 | $vars = array_merge( |
266 | 266 | $vars, |
267 | 267 | array( |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | } |
273 | 273 | |
274 | 274 | // Check if "orderby" is set to "vat_class" |
275 | - if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) { |
|
275 | + if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) { |
|
276 | 276 | $vars = array_merge( |
277 | 277 | $vars, |
278 | 278 | array( |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | // Check if "orderby" is set to "type" |
286 | - if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) { |
|
286 | + if (isset($vars['orderby']) && 'type' == $vars['orderby']) { |
|
287 | 287 | $vars = array_merge( |
288 | 288 | $vars, |
289 | 289 | array( |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | } |
295 | 295 | |
296 | 296 | // Check if "orderby" is set to "recurring" |
297 | - if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) { |
|
297 | + if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) { |
|
298 | 298 | $vars = array_merge( |
299 | 299 | $vars, |
300 | 300 | array( |
@@ -304,104 +304,104 @@ discard block |
||
304 | 304 | ); |
305 | 305 | } |
306 | 306 | |
307 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
307 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
308 | 308 | // Filter vat rule type |
309 | - if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) { |
|
309 | + if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') { |
|
310 | 310 | $meta_query[] = array( |
311 | 311 | 'key' => '_wpinv_vat_rule', |
312 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
312 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
313 | 313 | 'compare' => '=' |
314 | 314 | ); |
315 | 315 | } |
316 | 316 | |
317 | 317 | // Filter vat class |
318 | - if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) { |
|
318 | + if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') { |
|
319 | 319 | $meta_query[] = array( |
320 | 320 | 'key' => '_wpinv_vat_class', |
321 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
321 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
322 | 322 | 'compare' => '=' |
323 | 323 | ); |
324 | 324 | } |
325 | 325 | |
326 | 326 | // Filter item type |
327 | - if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) { |
|
327 | + if (isset($_GET['type']) && $_GET['type'] !== '') { |
|
328 | 328 | $meta_query[] = array( |
329 | 329 | 'key' => '_wpinv_type', |
330 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
330 | + 'value' => sanitize_text_field($_GET['type']), |
|
331 | 331 | 'compare' => '=' |
332 | 332 | ); |
333 | 333 | } |
334 | 334 | |
335 | - if ( !empty( $meta_query ) ) { |
|
335 | + if (!empty($meta_query)) { |
|
336 | 336 | $vars['meta_query'] = $meta_query; |
337 | 337 | } |
338 | - } else if ( 'wpi_discount' == $typenow ) { |
|
339 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
338 | + } else if ('wpi_discount' == $typenow) { |
|
339 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
340 | 340 | // Filter vat rule type |
341 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
341 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
342 | 342 | $meta_query[] = array( |
343 | 343 | 'key' => '_wpi_discount_type', |
344 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
344 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
345 | 345 | 'compare' => '=' |
346 | 346 | ); |
347 | 347 | } |
348 | 348 | |
349 | - if ( !empty( $meta_query ) ) { |
|
349 | + if (!empty($meta_query)) { |
|
350 | 350 | $vars['meta_query'] = $meta_query; |
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | 354 | return $vars; |
355 | 355 | } |
356 | -add_filter( 'request', 'wpinv_request' ); |
|
356 | +add_filter('request', 'wpinv_request'); |
|
357 | 357 | |
358 | -function wpinv_item_type_class( $classes, $class, $post_id ) { |
|
358 | +function wpinv_item_type_class($classes, $class, $post_id) { |
|
359 | 359 | global $pagenow, $typenow; |
360 | 360 | |
361 | - if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) { |
|
362 | - if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) { |
|
363 | - $classes[] = 'wpi-type-' . sanitize_html_class( $type ); |
|
361 | + if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) { |
|
362 | + if ($type = get_post_meta($post_id, '_wpinv_type', true)) { |
|
363 | + $classes[] = 'wpi-type-' . sanitize_html_class($type); |
|
364 | 364 | } |
365 | 365 | |
366 | - if ( !wpinv_item_is_editable( $post_id ) ) { |
|
366 | + if (!wpinv_item_is_editable($post_id)) { |
|
367 | 367 | $classes[] = 'wpi-editable-n'; |
368 | 368 | } |
369 | 369 | } |
370 | 370 | return $classes; |
371 | 371 | } |
372 | -add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 ); |
|
372 | +add_filter('post_class', 'wpinv_item_type_class', 10, 3); |
|
373 | 373 | |
374 | 374 | function wpinv_check_quick_edit() { |
375 | 375 | global $pagenow, $current_screen, $wpinv_item_screen; |
376 | 376 | |
377 | - if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) { |
|
378 | - if ( empty( $wpinv_item_screen ) ) { |
|
379 | - if ( $current_screen->post_type == 'wpi_item' ) { |
|
377 | + if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) { |
|
378 | + if (empty($wpinv_item_screen)) { |
|
379 | + if ($current_screen->post_type == 'wpi_item') { |
|
380 | 380 | $wpinv_item_screen = 'y'; |
381 | 381 | } else { |
382 | 382 | $wpinv_item_screen = 'n'; |
383 | 383 | } |
384 | 384 | } |
385 | 385 | |
386 | - if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) { |
|
387 | - add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 ); |
|
388 | - add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 ); |
|
386 | + if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') { |
|
387 | + add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2); |
|
388 | + add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2); |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | } |
392 | -add_action( 'admin_head', 'wpinv_check_quick_edit', 10 ); |
|
392 | +add_action('admin_head', 'wpinv_check_quick_edit', 10); |
|
393 | 393 | |
394 | -function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) { |
|
395 | - if ( isset( $actions['inline hide-if-no-js'] ) ) { |
|
396 | - unset( $actions['inline hide-if-no-js'] ); |
|
394 | +function wpinv_item_disable_quick_edit($actions = array(), $row = null) { |
|
395 | + if (isset($actions['inline hide-if-no-js'])) { |
|
396 | + unset($actions['inline hide-if-no-js']); |
|
397 | 397 | } |
398 | 398 | |
399 | - if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) { |
|
400 | - if ( isset( $actions['trash'] ) ) { |
|
401 | - unset( $actions['trash'] ); |
|
399 | + if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) { |
|
400 | + if (isset($actions['trash'])) { |
|
401 | + unset($actions['trash']); |
|
402 | 402 | } |
403 | - if ( isset( $actions['delete'] ) ) { |
|
404 | - unset( $actions['delete'] ); |
|
403 | + if (isset($actions['delete'])) { |
|
404 | + unset($actions['delete']); |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
@@ -418,19 +418,19 @@ discard block |
||
418 | 418 | * @param int $post_parent (default: 0) Parent for the new page |
419 | 419 | * @return int page ID |
420 | 420 | */ |
421 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
421 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
422 | 422 | global $wpdb; |
423 | 423 | |
424 | - $option_value = wpinv_get_option( $option ); |
|
424 | + $option_value = wpinv_get_option($option); |
|
425 | 425 | |
426 | - if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) { |
|
427 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
426 | + if ($option_value > 0 && ($page_object = get_post($option_value))) { |
|
427 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
428 | 428 | // Valid page is already in place |
429 | 429 | return $page_object->ID; |
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
433 | - if(!empty($post_parent)){ |
|
433 | + if (!empty($post_parent)) { |
|
434 | 434 | $page = get_page_by_path($post_parent); |
435 | 435 | if ($page) { |
436 | 436 | $post_parent = $page->ID; |
@@ -439,40 +439,40 @@ discard block |
||
439 | 439 | } |
440 | 440 | } |
441 | 441 | |
442 | - if ( strlen( $page_content ) > 0 ) { |
|
442 | + if (strlen($page_content) > 0) { |
|
443 | 443 | // Search for an existing page with the specified page content (typically a shortcode) |
444 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
444 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
445 | 445 | } else { |
446 | 446 | // Search for an existing page with the specified page slug |
447 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) ); |
|
447 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug)); |
|
448 | 448 | } |
449 | 449 | |
450 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
450 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
451 | 451 | |
452 | - if ( $valid_page_found ) { |
|
453 | - if ( $option ) { |
|
454 | - wpinv_update_option( $option, $valid_page_found ); |
|
452 | + if ($valid_page_found) { |
|
453 | + if ($option) { |
|
454 | + wpinv_update_option($option, $valid_page_found); |
|
455 | 455 | } |
456 | 456 | return $valid_page_found; |
457 | 457 | } |
458 | 458 | |
459 | 459 | // Search for a matching valid trashed page |
460 | - if ( strlen( $page_content ) > 0 ) { |
|
460 | + if (strlen($page_content) > 0) { |
|
461 | 461 | // Search for an existing page with the specified page content (typically a shortcode) |
462 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
462 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
463 | 463 | } else { |
464 | 464 | // Search for an existing page with the specified page slug |
465 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) ); |
|
465 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug)); |
|
466 | 466 | } |
467 | 467 | |
468 | - if ( $trashed_page_found ) { |
|
468 | + if ($trashed_page_found) { |
|
469 | 469 | $page_id = $trashed_page_found; |
470 | 470 | $page_data = array( |
471 | 471 | 'ID' => $page_id, |
472 | 472 | 'post_status' => 'publish', |
473 | 473 | 'post_parent' => $post_parent, |
474 | 474 | ); |
475 | - wp_update_post( $page_data ); |
|
475 | + wp_update_post($page_data); |
|
476 | 476 | } else { |
477 | 477 | $page_data = array( |
478 | 478 | 'post_status' => 'publish', |
@@ -484,11 +484,11 @@ discard block |
||
484 | 484 | 'post_parent' => $post_parent, |
485 | 485 | 'comment_status' => 'closed', |
486 | 486 | ); |
487 | - $page_id = wp_insert_post( $page_data ); |
|
487 | + $page_id = wp_insert_post($page_data); |
|
488 | 488 | } |
489 | 489 | |
490 | - if ( $option ) { |
|
491 | - wpinv_update_option( $option, (int)$page_id ); |
|
490 | + if ($option) { |
|
491 | + wpinv_update_option($option, (int)$page_id); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | return $page_id; |
@@ -1,60 +1,60 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | -add_filter( 'wpinv_authorizenet_support_subscription', '__return_true' ); |
|
5 | +add_filter('wpinv_authorizenet_support_subscription', '__return_true'); |
|
6 | 6 | |
7 | -function wpinv_authorizenet_cc_form( $invoice_id ) { |
|
8 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
9 | - $cc_owner = !empty( $invoice ) ? esc_attr( $invoice->get_user_full_name() ) : ''; |
|
7 | +function wpinv_authorizenet_cc_form($invoice_id) { |
|
8 | + $invoice = wpinv_get_invoice($invoice_id); |
|
9 | + $cc_owner = !empty($invoice) ? esc_attr($invoice->get_user_full_name()) : ''; |
|
10 | 10 | ?> |
11 | 11 | <div id="authorizenet_cc_form" class="form-horizontal wpi-cc-form panel panel-default"> |
12 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Card Details', 'invoicing' ) ;?></h3></div> |
|
12 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Card Details', 'invoicing'); ?></h3></div> |
|
13 | 13 | <div class="panel-body"> |
14 | 14 | <div class="form-group required"> |
15 | - <label for="auth-input-cc-owner" class="col-sm-3 control-label"><?php _e( 'Card Owner', 'invoicing' ) ;?></label> |
|
15 | + <label for="auth-input-cc-owner" class="col-sm-3 control-label"><?php _e('Card Owner', 'invoicing'); ?></label> |
|
16 | 16 | <div class="col-sm-5"> |
17 | - <input type="text" class="form-control" id="auth-input-cc-owner" placeholder="<?php esc_attr_e( 'Card Owner', 'invoicing' ) ;?>" value="<?php echo $cc_owner;?>" name="authorizenet[cc_owner]"> |
|
17 | + <input type="text" class="form-control" id="auth-input-cc-owner" placeholder="<?php esc_attr_e('Card Owner', 'invoicing'); ?>" value="<?php echo $cc_owner; ?>" name="authorizenet[cc_owner]"> |
|
18 | 18 | </div> |
19 | 19 | </div> |
20 | 20 | <div class="form-group required"> |
21 | - <label for="auth-input-cc-number" class="col-sm-3 control-label"><?php _e( 'Card Number', 'invoicing' ) ;?></label> |
|
21 | + <label for="auth-input-cc-number" class="col-sm-3 control-label"><?php _e('Card Number', 'invoicing'); ?></label> |
|
22 | 22 | <div class="col-sm-5"> |
23 | - <input type="text" class="form-control" id="auth-input-cc-number" placeholder="<?php esc_attr_e( 'Card Number', 'invoicing' ) ;?>" value="" name="authorizenet[cc_number]"> |
|
23 | + <input type="text" class="form-control" id="auth-input-cc-number" placeholder="<?php esc_attr_e('Card Number', 'invoicing'); ?>" value="" name="authorizenet[cc_number]"> |
|
24 | 24 | </div> |
25 | 25 | </div> |
26 | 26 | <div class="form-group required"> |
27 | - <label for="auth-input-cc-expire-date" class="col-sm-3 control-label"><?php _e( 'Card Expiry Date', 'invoicing' ) ;?></label> |
|
27 | + <label for="auth-input-cc-expire-date" class="col-sm-3 control-label"><?php _e('Card Expiry Date', 'invoicing'); ?></label> |
|
28 | 28 | <div class="col-sm-2"> |
29 | 29 | <select class="form-control" id="auth-input-cc-expire-date" name="authorizenet[cc_expire_month]"> |
30 | - <?php for ( $i = 1; $i <= 12; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
31 | - <option value="<?php echo $value;?>"><?php echo $value;?></option> |
|
30 | + <?php for ($i = 1; $i <= 12; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
31 | + <option value="<?php echo $value; ?>"><?php echo $value; ?></option> |
|
32 | 32 | <?php } ?> |
33 | 33 | </select> |
34 | 34 | </div> |
35 | 35 | <div class="col-sm-3"> |
36 | 36 | <select class="form-control" name="authorizenet[cc_expire_year]"> |
37 | - <?php $year = date( 'Y' ); for ( $i = $year; $i <= ( $year + 10 ); $i++ ) { ?> |
|
38 | - <option value="<?php echo $i;?>"><?php echo $i;?></option> |
|
37 | + <?php $year = date('Y'); for ($i = $year; $i <= ($year + 10); $i++) { ?> |
|
38 | + <option value="<?php echo $i; ?>"><?php echo $i; ?></option> |
|
39 | 39 | <?php } ?> |
40 | 40 | </select> |
41 | 41 | </div> |
42 | 42 | </div> |
43 | 43 | <div class="form-group required"> |
44 | - <label for="auth-input-cc-cvv2" class="col-sm-3 control-label"><?php _e( 'Card Security Code (CVV2)', 'invoicing' ) ;?></label> |
|
44 | + <label for="auth-input-cc-cvv2" class="col-sm-3 control-label"><?php _e('Card Security Code (CVV2)', 'invoicing'); ?></label> |
|
45 | 45 | <div class="col-sm-5"> |
46 | - <input type="text" class="form-control" id="auth-input-cc-cvv2" placeholder="<?php esc_attr_e( 'Card Security Code (CVV2)', 'invoicing' ) ;?>" value="" name="authorizenet[cc_cvv2]""> |
|
46 | + <input type="text" class="form-control" id="auth-input-cc-cvv2" placeholder="<?php esc_attr_e('Card Security Code (CVV2)', 'invoicing'); ?>" value="" name="authorizenet[cc_cvv2]""> |
|
47 | 47 | </div> |
48 | 48 | </div> |
49 | 49 | </div> |
50 | 50 | </div> |
51 | 51 | <?php |
52 | 52 | } |
53 | -add_action( 'wpinv_authorizenet_cc_form', 'wpinv_authorizenet_cc_form', 10, 1 ); |
|
53 | +add_action('wpinv_authorizenet_cc_form', 'wpinv_authorizenet_cc_form', 10, 1); |
|
54 | 54 | |
55 | -function wpinv_process_authorizenet_payment( $purchase_data ) { |
|
56 | - if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) { |
|
57 | - wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
55 | +function wpinv_process_authorizenet_payment($purchase_data) { |
|
56 | + if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) { |
|
57 | + wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // Collect payment data |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | ); |
73 | 73 | |
74 | 74 | // Record the pending payment |
75 | - $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] ); |
|
75 | + $invoice = wpinv_get_invoice($purchase_data['invoice_id']); |
|
76 | 76 | |
77 | - if ( !empty( $invoice ) ) { |
|
78 | - $authorizenet_card = !empty( $_POST['authorizenet'] ) ? $_POST['authorizenet'] : array(); |
|
77 | + if (!empty($invoice)) { |
|
78 | + $authorizenet_card = !empty($_POST['authorizenet']) ? $_POST['authorizenet'] : array(); |
|
79 | 79 | $card_defaults = array( |
80 | 80 | 'cc_owner' => $invoice->get_user_full_name(), |
81 | 81 | 'cc_number' => false, |
@@ -83,192 +83,192 @@ discard block |
||
83 | 83 | 'cc_expire_year' => false, |
84 | 84 | 'cc_cvv2' => false, |
85 | 85 | ); |
86 | - $authorizenet_card = wp_parse_args( $authorizenet_card, $card_defaults ); |
|
86 | + $authorizenet_card = wp_parse_args($authorizenet_card, $card_defaults); |
|
87 | 87 | |
88 | - if ( empty( $authorizenet_card['cc_owner'] ) ) { |
|
89 | - wpinv_set_error( 'empty_card_name', __( 'You must enter the name on your card!', 'invoicing')); |
|
88 | + if (empty($authorizenet_card['cc_owner'])) { |
|
89 | + wpinv_set_error('empty_card_name', __('You must enter the name on your card!', 'invoicing')); |
|
90 | 90 | } |
91 | - if ( empty( $authorizenet_card['cc_number'] ) ) { |
|
92 | - wpinv_set_error( 'empty_card', __( 'You must enter a card number!', 'invoicing')); |
|
91 | + if (empty($authorizenet_card['cc_number'])) { |
|
92 | + wpinv_set_error('empty_card', __('You must enter a card number!', 'invoicing')); |
|
93 | 93 | } |
94 | - if ( empty( $authorizenet_card['cc_expire_month'] ) ) { |
|
95 | - wpinv_set_error( 'empty_month', __( 'You must enter an card expiration month!', 'invoicing')); |
|
94 | + if (empty($authorizenet_card['cc_expire_month'])) { |
|
95 | + wpinv_set_error('empty_month', __('You must enter an card expiration month!', 'invoicing')); |
|
96 | 96 | } |
97 | - if ( empty( $authorizenet_card['cc_expire_year'] ) ) { |
|
98 | - wpinv_set_error( 'empty_year', __( 'You must enter an card expiration year!', 'invoicing')); |
|
97 | + if (empty($authorizenet_card['cc_expire_year'])) { |
|
98 | + wpinv_set_error('empty_year', __('You must enter an card expiration year!', 'invoicing')); |
|
99 | 99 | } |
100 | - if ( empty( $authorizenet_card['cc_cvv2'] ) ) { |
|
101 | - wpinv_set_error( 'empty_cvv2', __( 'You must enter a valid CVV2!', 'invoicing' ) ); |
|
100 | + if (empty($authorizenet_card['cc_cvv2'])) { |
|
101 | + wpinv_set_error('empty_cvv2', __('You must enter a valid CVV2!', 'invoicing')); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $errors = wpinv_get_errors(); |
105 | 105 | |
106 | - if ( empty( $errors ) ) { |
|
106 | + if (empty($errors)) { |
|
107 | 107 | $invoice_id = $invoice->ID; |
108 | 108 | $quantities_enabled = wpinv_item_quantities_enabled(); |
109 | 109 | $use_taxes = wpinv_use_taxes(); |
110 | 110 | |
111 | 111 | $authorizeAIM = wpinv_authorizenet_AIM(); |
112 | - $authorizeAIM->first_name = wpinv_utf8_substr( $invoice->get_first_name(), 0, 50 ); |
|
113 | - $authorizeAIM->last_name = wpinv_utf8_substr( $invoice->get_last_name(), 0, 50 ); |
|
114 | - $authorizeAIM->company = wpinv_utf8_substr( $invoice->company, 0, 50 ); |
|
115 | - $authorizeAIM->address = wpinv_utf8_substr( wp_strip_all_tags( $invoice->get_address(), true ), 0, 60 ); |
|
116 | - $authorizeAIM->city = wpinv_utf8_substr( $invoice->city, 0, 40 ); |
|
117 | - $authorizeAIM->state = wpinv_utf8_substr( $invoice->state, 0, 40 ); |
|
118 | - $authorizeAIM->zip = wpinv_utf8_substr( $invoice->zip, 0, 40 ); |
|
119 | - $authorizeAIM->country = wpinv_utf8_substr( $invoice->country, 0, 60 ); |
|
120 | - $authorizeAIM->phone = wpinv_utf8_substr( $invoice->phone, 0, 25 ); |
|
121 | - $authorizeAIM->email = wpinv_utf8_substr( $invoice->get_email(), 0, 255 ); |
|
122 | - $authorizeAIM->amount = wpinv_sanitize_amount( $invoice->get_total() ); |
|
123 | - $authorizeAIM->card_num = str_replace( ' ', '', sanitize_text_field( $authorizenet_card['cc_number'] ) ); |
|
124 | - $authorizeAIM->exp_date = sanitize_text_field( $authorizenet_card['cc_expire_month'] ) . sanitize_text_field( $authorizenet_card['cc_expire_year'] ); |
|
125 | - $authorizeAIM->card_code = sanitize_text_field( $authorizenet_card['cc_cvv2'] ); |
|
112 | + $authorizeAIM->first_name = wpinv_utf8_substr($invoice->get_first_name(), 0, 50); |
|
113 | + $authorizeAIM->last_name = wpinv_utf8_substr($invoice->get_last_name(), 0, 50); |
|
114 | + $authorizeAIM->company = wpinv_utf8_substr($invoice->company, 0, 50); |
|
115 | + $authorizeAIM->address = wpinv_utf8_substr(wp_strip_all_tags($invoice->get_address(), true), 0, 60); |
|
116 | + $authorizeAIM->city = wpinv_utf8_substr($invoice->city, 0, 40); |
|
117 | + $authorizeAIM->state = wpinv_utf8_substr($invoice->state, 0, 40); |
|
118 | + $authorizeAIM->zip = wpinv_utf8_substr($invoice->zip, 0, 40); |
|
119 | + $authorizeAIM->country = wpinv_utf8_substr($invoice->country, 0, 60); |
|
120 | + $authorizeAIM->phone = wpinv_utf8_substr($invoice->phone, 0, 25); |
|
121 | + $authorizeAIM->email = wpinv_utf8_substr($invoice->get_email(), 0, 255); |
|
122 | + $authorizeAIM->amount = wpinv_sanitize_amount($invoice->get_total()); |
|
123 | + $authorizeAIM->card_num = str_replace(' ', '', sanitize_text_field($authorizenet_card['cc_number'])); |
|
124 | + $authorizeAIM->exp_date = sanitize_text_field($authorizenet_card['cc_expire_month']) . sanitize_text_field($authorizenet_card['cc_expire_year']); |
|
125 | + $authorizeAIM->card_code = sanitize_text_field($authorizenet_card['cc_cvv2']); |
|
126 | 126 | $authorizeAIM->invoice_num = $invoice->ID; |
127 | 127 | |
128 | 128 | $item_desc = array(); |
129 | - foreach ( $invoice->get_cart_details() as $item ) { |
|
130 | - $quantity = $quantities_enabled && !empty( $item['quantity'] ) && $item['quantity'] > 0 ? $item['quantity'] : 1; |
|
131 | - $item_name = wpinv_utf8_substr( $item['name'], 0, 31 ); |
|
132 | - $item_desc[] = $item_name . ' (' . $quantity . 'x ' . wpinv_price( wpinv_format_amount( $item['item_price'] ) ) . ')'; |
|
129 | + foreach ($invoice->get_cart_details() as $item) { |
|
130 | + $quantity = $quantities_enabled && !empty($item['quantity']) && $item['quantity'] > 0 ? $item['quantity'] : 1; |
|
131 | + $item_name = wpinv_utf8_substr($item['name'], 0, 31); |
|
132 | + $item_desc[] = $item_name . ' (' . $quantity . 'x ' . wpinv_price(wpinv_format_amount($item['item_price'])) . ')'; |
|
133 | 133 | |
134 | - $authorizeAIM->addLineItem( $item['id'], $item_name, '', $quantity, $item['item_price'], ( $use_taxes && !empty( $item['tax'] ) && $item['tax'] > 0 ? 'Y' : 'N' ) ); |
|
134 | + $authorizeAIM->addLineItem($item['id'], $item_name, '', $quantity, $item['item_price'], ($use_taxes && !empty($item['tax']) && $item['tax'] > 0 ? 'Y' : 'N')); |
|
135 | 135 | } |
136 | 136 | |
137 | - $item_desc = '#' . $invoice->get_number() . ': ' . implode( ', ', $item_desc ); |
|
137 | + $item_desc = '#' . $invoice->get_number() . ': ' . implode(', ', $item_desc); |
|
138 | 138 | |
139 | - if ( $use_taxes && $invoice->get_tax() > 0 ) { |
|
140 | - $authorizeAIM->tax = $invoice->get_tax(); |
|
139 | + if ($use_taxes && $invoice->get_tax() > 0) { |
|
140 | + $authorizeAIM->tax = $invoice->get_tax(); |
|
141 | 141 | |
142 | - $item_desc .= ', ' . wp_sprintf( __( 'Tax: %s', 'invoicing' ), $invoice->get_tax( true ) ); |
|
142 | + $item_desc .= ', ' . wp_sprintf(__('Tax: %s', 'invoicing'), $invoice->get_tax(true)); |
|
143 | 143 | } |
144 | 144 | |
145 | - if ( $invoice->get_discount() > 0 ) { |
|
146 | - $item_desc .= ', ' . wp_sprintf( __( 'Discount: %s', 'invoicing' ), $invoice->get_discount( true ) ); |
|
145 | + if ($invoice->get_discount() > 0) { |
|
146 | + $item_desc .= ', ' . wp_sprintf(__('Discount: %s', 'invoicing'), $invoice->get_discount(true)); |
|
147 | 147 | } |
148 | 148 | |
149 | - $item_description = wpinv_utf8_substr( $item_desc, 0, 255 ); |
|
150 | - $item_description = html_entity_decode( $item_desc , ENT_QUOTES, 'UTF-8' ); |
|
149 | + $item_description = wpinv_utf8_substr($item_desc, 0, 255); |
|
150 | + $item_description = html_entity_decode($item_desc, ENT_QUOTES, 'UTF-8'); |
|
151 | 151 | |
152 | - $authorizeAIM->description = wpinv_utf8_substr( $item_description, 0, 255 ); |
|
152 | + $authorizeAIM->description = wpinv_utf8_substr($item_description, 0, 255); |
|
153 | 153 | |
154 | 154 | $is_recurring = $invoice->is_recurring(); // Recurring payment. |
155 | 155 | |
156 | - if ( $is_recurring ) { |
|
156 | + if ($is_recurring) { |
|
157 | 157 | $authorizeAIM->recurring_billing = true; |
158 | 158 | } |
159 | 159 | |
160 | 160 | try { |
161 | 161 | |
162 | - if ( $is_recurring ) { |
|
162 | + if ($is_recurring) { |
|
163 | 163 | $trx_type = wpinv_get_option('authorizenet_transaction_type_recurring', 'authorize_only'); |
164 | - if('authorize_capture' == $trx_type){ |
|
164 | + if ('authorize_capture' == $trx_type) { |
|
165 | 165 | $response = $authorizeAIM->authorizeAndCapture(); |
166 | 166 | } else { |
167 | 167 | $response = $authorizeAIM->authorizeOnly(); |
168 | 168 | } |
169 | 169 | } else { |
170 | 170 | $trx_type = wpinv_get_option('authorizenet_transaction_type', 'authorize_capture'); |
171 | - if('authorize_capture' == $trx_type){ |
|
171 | + if ('authorize_capture' == $trx_type) { |
|
172 | 172 | $response = $authorizeAIM->authorizeAndCapture(); |
173 | 173 | } else { |
174 | 174 | $response = $authorizeAIM->authorizeOnly(); |
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | - if ( $response->approved || $response->held ) { |
|
179 | - if ( $response->approved ) { |
|
180 | - wpinv_update_payment_status( $invoice_id, 'publish' ); |
|
178 | + if ($response->approved || $response->held) { |
|
179 | + if ($response->approved) { |
|
180 | + wpinv_update_payment_status($invoice_id, 'publish'); |
|
181 | 181 | } |
182 | - wpinv_set_payment_transaction_id( $invoice_id, $response->transaction_id ); |
|
182 | + wpinv_set_payment_transaction_id($invoice_id, $response->transaction_id); |
|
183 | 183 | |
184 | - wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'Authorize.Net payment response: %s', 'invoicing' ), $response->response_reason_text ), '', '', true ); |
|
185 | - wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'Authorize.Net payment: Transaction ID %s, Transaction Type %s, Authorization Code %s', 'invoicing' ), $response->transaction_id, strtoupper( $response->transaction_type ), $response->authorization_code ), '', '', true ); |
|
184 | + wpinv_insert_payment_note($invoice_id, wp_sprintf(__('Authorize.Net payment response: %s', 'invoicing'), $response->response_reason_text), '', '', true); |
|
185 | + wpinv_insert_payment_note($invoice_id, wp_sprintf(__('Authorize.Net payment: Transaction ID %s, Transaction Type %s, Authorization Code %s', 'invoicing'), $response->transaction_id, strtoupper($response->transaction_type), $response->authorization_code), '', '', true); |
|
186 | 186 | |
187 | - do_action( 'wpinv_authorizenet_handle_response', $response, $invoice, $authorizenet_card ); |
|
187 | + do_action('wpinv_authorizenet_handle_response', $response, $invoice, $authorizenet_card); |
|
188 | 188 | |
189 | 189 | wpinv_clear_errors(); |
190 | 190 | wpinv_empty_cart(); |
191 | 191 | |
192 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
192 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
193 | 193 | } else { |
194 | - if ( !empty( $response->response_reason_text ) ) { |
|
195 | - $error = __( $response->response_reason_text, 'invoicing' ); |
|
196 | - } else if ( !empty( $response->error_message ) ) { |
|
197 | - $error = __( $response->error_message, 'invoicing' ); |
|
194 | + if (!empty($response->response_reason_text)) { |
|
195 | + $error = __($response->response_reason_text, 'invoicing'); |
|
196 | + } else if (!empty($response->error_message)) { |
|
197 | + $error = __($response->error_message, 'invoicing'); |
|
198 | 198 | } else { |
199 | - $error = wp_sprintf( __( 'Error data: %s', 'invoicing' ), print_r( $response, true ) ); |
|
199 | + $error = wp_sprintf(__('Error data: %s', 'invoicing'), print_r($response, true)); |
|
200 | 200 | } |
201 | 201 | |
202 | - $error = wp_sprintf( __( 'Authorize.Net payment error occurred. %s', 'invoicing' ), $error ); |
|
202 | + $error = wp_sprintf(__('Authorize.Net payment error occurred. %s', 'invoicing'), $error); |
|
203 | 203 | |
204 | - wpinv_set_error( 'payment_error', $error ); |
|
205 | - wpinv_record_gateway_error( $error, $response ); |
|
206 | - wpinv_insert_payment_note( $invoice_id, $error, '', '', true ); |
|
204 | + wpinv_set_error('payment_error', $error); |
|
205 | + wpinv_record_gateway_error($error, $response); |
|
206 | + wpinv_insert_payment_note($invoice_id, $error, '', '', true); |
|
207 | 207 | |
208 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
208 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
209 | 209 | } |
210 | - } catch ( AuthorizeNetException $e ) { |
|
211 | - wpinv_set_error( 'request_error', $e->getMessage() ); |
|
212 | - wpinv_record_gateway_error( wp_sprintf( __( 'Authorize.Net payment error occurred. %s', 'invoicing' ), $e->getMessage() ) ); |
|
213 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
210 | + } catch (AuthorizeNetException $e) { |
|
211 | + wpinv_set_error('request_error', $e->getMessage()); |
|
212 | + wpinv_record_gateway_error(wp_sprintf(__('Authorize.Net payment error occurred. %s', 'invoicing'), $e->getMessage())); |
|
213 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
214 | 214 | } |
215 | 215 | } else { |
216 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
216 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
217 | 217 | } |
218 | 218 | } else { |
219 | - wpinv_record_gateway_error( wp_sprintf( __( 'Authorize.Net payment error occurred. Payment creation failed while processing a Authorize.Net payment. Payment data: %s', 'invoicing' ), print_r( $payment_data, true ) ), $invoice ); |
|
220 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
219 | + wpinv_record_gateway_error(wp_sprintf(__('Authorize.Net payment error occurred. Payment creation failed while processing a Authorize.Net payment. Payment data: %s', 'invoicing'), print_r($payment_data, true)), $invoice); |
|
220 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
221 | 221 | } |
222 | 222 | } |
223 | -add_action( 'wpinv_gateway_authorizenet', 'wpinv_process_authorizenet_payment' ); |
|
223 | +add_action('wpinv_gateway_authorizenet', 'wpinv_process_authorizenet_payment'); |
|
224 | 224 | |
225 | -function wpinv_authorizenet_cancel_subscription( $subscription_id = '' ) { |
|
226 | - if ( empty( $subscription_id ) ) { |
|
225 | +function wpinv_authorizenet_cancel_subscription($subscription_id = '') { |
|
226 | + if (empty($subscription_id)) { |
|
227 | 227 | return false; |
228 | 228 | } |
229 | 229 | |
230 | 230 | try { |
231 | 231 | $authnetXML = wpinv_authorizenet_XML(); |
232 | - $authnetXML->ARBCancelSubscriptionRequest( array( 'subscriptionId' => $subscription_id ) ); |
|
232 | + $authnetXML->ARBCancelSubscriptionRequest(array('subscriptionId' => $subscription_id)); |
|
233 | 233 | return $authnetXML->isSuccessful(); |
234 | - } catch( Exception $e ) { |
|
235 | - wpinv_error_log( $e->getMessage(), __( 'Authorize.Net cancel subscription', 'invoicing' ) ); |
|
234 | + } catch (Exception $e) { |
|
235 | + wpinv_error_log($e->getMessage(), __('Authorize.Net cancel subscription', 'invoicing')); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | return false; |
239 | 239 | } |
240 | 240 | |
241 | -function wpinv_recurring_cancel_authorizenet_subscription( $subscription, $valid = false ) { |
|
242 | - if ( ! empty( $valid ) && ! empty( $subscription->profile_id ) ) { |
|
243 | - return wpinv_authorizenet_cancel_subscription( $subscription->profile_id ); |
|
241 | +function wpinv_recurring_cancel_authorizenet_subscription($subscription, $valid = false) { |
|
242 | + if (!empty($valid) && !empty($subscription->profile_id)) { |
|
243 | + return wpinv_authorizenet_cancel_subscription($subscription->profile_id); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | return false; |
247 | 247 | } |
248 | -add_action( 'wpinv_recurring_cancel_authorizenet_subscription', 'wpinv_recurring_cancel_authorizenet_subscription', 10, 2 ); |
|
248 | +add_action('wpinv_recurring_cancel_authorizenet_subscription', 'wpinv_recurring_cancel_authorizenet_subscription', 10, 2); |
|
249 | 249 | |
250 | -function wpinv_authorizenet_valid_ipn( $md5_hash, $transaction_id, $amount ) { |
|
251 | - $authorizenet_md5_hash = wpinv_get_option( 'authorizenet_md5_hash' ); |
|
252 | - if ( empty( $authorizenet_md5_hash ) ) { |
|
250 | +function wpinv_authorizenet_valid_ipn($md5_hash, $transaction_id, $amount) { |
|
251 | + $authorizenet_md5_hash = wpinv_get_option('authorizenet_md5_hash'); |
|
252 | + if (empty($authorizenet_md5_hash)) { |
|
253 | 253 | return true; |
254 | 254 | } |
255 | 255 | |
256 | - $compare_md5 = strtoupper( md5( $authorizenet_md5_hash . $transaction_id . $amount ) ); |
|
256 | + $compare_md5 = strtoupper(md5($authorizenet_md5_hash . $transaction_id . $amount)); |
|
257 | 257 | |
258 | - return hash_equals( $compare_md5, $md5_hash ); |
|
258 | + return hash_equals($compare_md5, $md5_hash); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | function wpinv_authorizenet_AIM() { |
262 | - if ( !class_exists( 'AuthorizeNetException' ) ) { |
|
263 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/gateways/authorizenet/anet_php_sdk/AuthorizeNet.php'; |
|
262 | + if (!class_exists('AuthorizeNetException')) { |
|
263 | + require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/gateways/authorizenet/anet_php_sdk/AuthorizeNet.php'; |
|
264 | 264 | } |
265 | 265 | |
266 | - $authorizeAIM = new AuthorizeNetAIM( wpinv_get_option( 'authorizenet_login_id' ), wpinv_get_option( 'authorizenet_transaction_key' ) ); |
|
266 | + $authorizeAIM = new AuthorizeNetAIM(wpinv_get_option('authorizenet_login_id'), wpinv_get_option('authorizenet_transaction_key')); |
|
267 | 267 | |
268 | - if ( wpinv_is_test_mode( 'authorizenet' ) ) { |
|
269 | - $authorizeAIM->setSandbox( true ); |
|
268 | + if (wpinv_is_test_mode('authorizenet')) { |
|
269 | + $authorizeAIM->setSandbox(true); |
|
270 | 270 | } else { |
271 | - $authorizeAIM->setSandbox( false ); |
|
271 | + $authorizeAIM->setSandbox(false); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | $authorizeAIM->customer_ip = wpinv_get_ip(); |
@@ -277,250 +277,250 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | function wpinv_authorizenet_XML() { |
280 | - if ( !class_exists( 'AuthnetXML' ) ) { |
|
281 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/gateways/authorizenet/Authorize.Net-XML/AuthnetXML.class.php'; |
|
280 | + if (!class_exists('AuthnetXML')) { |
|
281 | + require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/gateways/authorizenet/Authorize.Net-XML/AuthnetXML.class.php'; |
|
282 | 282 | } |
283 | 283 | |
284 | - $authnetXML = new AuthnetXML( wpinv_get_option( 'authorizenet_login_id' ), wpinv_get_option( 'authorizenet_transaction_key' ), (bool)wpinv_is_test_mode( 'authorizenet' ) ); |
|
284 | + $authnetXML = new AuthnetXML(wpinv_get_option('authorizenet_login_id'), wpinv_get_option('authorizenet_transaction_key'), (bool)wpinv_is_test_mode('authorizenet')); |
|
285 | 285 | |
286 | 286 | return $authnetXML; |
287 | 287 | } |
288 | 288 | |
289 | -function wpinv_authorizenet_handle_response( $response, $invoice, $card_info = array() ) { |
|
290 | - if ( empty( $response ) || empty( $invoice ) ) { |
|
289 | +function wpinv_authorizenet_handle_response($response, $invoice, $card_info = array()) { |
|
290 | + if (empty($response) || empty($invoice)) { |
|
291 | 291 | return false; |
292 | 292 | } |
293 | 293 | |
294 | - if ( $invoice->is_recurring() && !empty( $response->approved ) ) { |
|
295 | - $subscription = wpinv_authorizenet_create_new_subscription( $invoice, $response, $card_info ); |
|
294 | + if ($invoice->is_recurring() && !empty($response->approved)) { |
|
295 | + $subscription = wpinv_authorizenet_create_new_subscription($invoice, $response, $card_info); |
|
296 | 296 | $success = false; |
297 | - if ( wpinv_is_test_mode( 'authorizenet' ) ) { |
|
297 | + if (wpinv_is_test_mode('authorizenet')) { |
|
298 | 298 | $success = true; |
299 | 299 | } else { |
300 | 300 | $success = $subscription->isSuccessful(); |
301 | 301 | } |
302 | 302 | |
303 | - if ( !empty( $subscription ) && $success ) { |
|
304 | - do_action( 'wpinv_recurring_post_create_subscription', $subscription, $invoice, 'authorizenet' ); |
|
303 | + if (!empty($subscription) && $success) { |
|
304 | + do_action('wpinv_recurring_post_create_subscription', $subscription, $invoice, 'authorizenet'); |
|
305 | 305 | |
306 | - wpinv_authorizenet_subscription_record_signup( $subscription, $invoice ); |
|
306 | + wpinv_authorizenet_subscription_record_signup($subscription, $invoice); |
|
307 | 307 | |
308 | - do_action( 'wpinv_recurring_post_record_signup', $subscription, $invoice, 'authorizenet' ); |
|
308 | + do_action('wpinv_recurring_post_record_signup', $subscription, $invoice, 'authorizenet'); |
|
309 | 309 | } else { |
310 | - if ( isset( $subscription->messages->message ) ) { |
|
310 | + if (isset($subscription->messages->message)) { |
|
311 | 311 | $error = $subscription->messages->message->code . ': ' . $subscription->messages->message->text; |
312 | - wpinv_set_error( 'wpinv_authorize_recurring_error', $error, 'invoicing' ); |
|
312 | + wpinv_set_error('wpinv_authorize_recurring_error', $error, 'invoicing'); |
|
313 | 313 | } else { |
314 | - $error = __( 'Your subscription cannot be created due to an error.', 'invoicing' ); |
|
315 | - wpinv_set_error( 'wpinv_authorize_recurring_error', $error ); |
|
314 | + $error = __('Your subscription cannot be created due to an error.', 'invoicing'); |
|
315 | + wpinv_set_error('wpinv_authorize_recurring_error', $error); |
|
316 | 316 | } |
317 | 317 | |
318 | - wpinv_record_gateway_error( $error, $subscription ); |
|
318 | + wpinv_record_gateway_error($error, $subscription); |
|
319 | 319 | |
320 | - wpinv_insert_payment_note( $invoice->ID, wp_sprintf( __( 'Authorize.Net subscription error occurred. %s', 'invoicing' ), $error ), '', '', true ); |
|
320 | + wpinv_insert_payment_note($invoice->ID, wp_sprintf(__('Authorize.Net subscription error occurred. %s', 'invoicing'), $error), '', '', true); |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | } |
324 | -add_action( 'wpinv_authorizenet_handle_response', 'wpinv_authorizenet_handle_response', 10, 3 ); |
|
324 | +add_action('wpinv_authorizenet_handle_response', 'wpinv_authorizenet_handle_response', 10, 3); |
|
325 | 325 | |
326 | -function wpinv_authorizenet_create_new_subscription( $invoice, $response = array(), $card_info = array() ) { |
|
327 | - if ( empty( $invoice ) ) { |
|
326 | +function wpinv_authorizenet_create_new_subscription($invoice, $response = array(), $card_info = array()) { |
|
327 | + if (empty($invoice)) { |
|
328 | 328 | return false; |
329 | 329 | } |
330 | 330 | |
331 | - $params = wpinv_authorizenet_generate_subscription_params( $invoice, $card_info, $response ); |
|
331 | + $params = wpinv_authorizenet_generate_subscription_params($invoice, $card_info, $response); |
|
332 | 332 | |
333 | 333 | try { |
334 | 334 | $authnetXML = wpinv_authorizenet_XML(); |
335 | - $authnetXML->ARBCreateSubscriptionRequest( $params ); |
|
336 | - } catch( Exception $e ) { |
|
335 | + $authnetXML->ARBCreateSubscriptionRequest($params); |
|
336 | + } catch (Exception $e) { |
|
337 | 337 | $authnetXML = array(); |
338 | - wpinv_error_log( $e->getMessage(), __( 'Authorize.Net cancel subscription', 'invoicing' ) ); |
|
338 | + wpinv_error_log($e->getMessage(), __('Authorize.Net cancel subscription', 'invoicing')); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $authnetXML; |
342 | 342 | } |
343 | 343 | |
344 | -function wpinv_authorizenet_generate_subscription_params( $invoice, $card_info = array(), $response = array() ) { |
|
345 | - if ( empty( $invoice ) ) { |
|
344 | +function wpinv_authorizenet_generate_subscription_params($invoice, $card_info = array(), $response = array()) { |
|
345 | + if (empty($invoice)) { |
|
346 | 346 | return false; |
347 | 347 | } |
348 | 348 | |
349 | - $subscription_item = $invoice->get_recurring( true ); |
|
350 | - if ( empty( $subscription_item->ID ) ) { |
|
349 | + $subscription_item = $invoice->get_recurring(true); |
|
350 | + if (empty($subscription_item->ID)) { |
|
351 | 351 | return false; |
352 | 352 | } |
353 | 353 | |
354 | - $item = $invoice->get_recurring( true ); |
|
354 | + $item = $invoice->get_recurring(true); |
|
355 | 355 | |
356 | - if ( empty( $item ) ) { |
|
356 | + if (empty($item)) { |
|
357 | 357 | $name = ''; |
358 | 358 | } |
359 | 359 | |
360 | - if ( !( $name = $item->get_name() ) ) { |
|
360 | + if (!($name = $item->get_name())) { |
|
361 | 361 | $name = $item->post_name; |
362 | 362 | } |
363 | 363 | |
364 | - $card_details = wpinv_authorizenet_generate_card_info( $card_info ); |
|
364 | + $card_details = wpinv_authorizenet_generate_card_info($card_info); |
|
365 | 365 | $subscription_name = $invoice->get_subscription_name(); |
366 | - $initial_amount = wpinv_round_amount( $invoice->get_total() ); |
|
367 | - $recurring_amount = wpinv_round_amount( $invoice->get_recurring_details( 'total' ) ); |
|
366 | + $initial_amount = wpinv_round_amount($invoice->get_total()); |
|
367 | + $recurring_amount = wpinv_round_amount($invoice->get_recurring_details('total')); |
|
368 | 368 | $interval = $subscription_item->get_recurring_interval(); |
369 | 369 | $period = $subscription_item->get_recurring_period(); |
370 | 370 | $bill_times = (int)$subscription_item->get_recurring_limit(); |
371 | 371 | $bill_times = $bill_times > 0 ? $bill_times : 9999; |
372 | 372 | |
373 | - $time_period = wpinv_authorizenet_get_time_period( $interval, $period ); |
|
373 | + $time_period = wpinv_authorizenet_get_time_period($interval, $period); |
|
374 | 374 | $interval = $time_period['interval']; |
375 | 375 | $period = $time_period['period']; |
376 | 376 | |
377 | 377 | $current_tz = date_default_timezone_get(); |
378 | - date_default_timezone_set( 'America/Denver' ); // Set same timezone as Authorize's server (Mountain Time) to prevent conflicts. |
|
379 | - $today = date( 'Y-m-d' ); |
|
380 | - date_default_timezone_set( $current_tz ); |
|
378 | + date_default_timezone_set('America/Denver'); // Set same timezone as Authorize's server (Mountain Time) to prevent conflicts. |
|
379 | + $today = date('Y-m-d'); |
|
380 | + date_default_timezone_set($current_tz); |
|
381 | 381 | |
382 | 382 | $free_trial = $invoice->is_free_trial(); |
383 | - if ( $free_trial && $subscription_item->has_free_trial() ) { |
|
383 | + if ($free_trial && $subscription_item->has_free_trial()) { |
|
384 | 384 | $trial_interval = $subscription_item->get_trial_interval(); |
385 | - $trial_period = $subscription_item->get_trial_period( true ); |
|
385 | + $trial_period = $subscription_item->get_trial_period(true); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | $subscription = array(); |
389 | 389 | $subscription['name'] = $subscription_name; |
390 | 390 | |
391 | 391 | $subscription['paymentSchedule'] = array( |
392 | - 'interval' => array( 'length' => $interval, 'unit' => $period ), |
|
392 | + 'interval' => array('length' => $interval, 'unit' => $period), |
|
393 | 393 | 'startDate' => $today, |
394 | 394 | 'totalOccurrences' => $bill_times, |
395 | - 'trialOccurrences' => $free_trial || ( $initial_amount != $recurring_amount ) ? 1 : 0, |
|
395 | + 'trialOccurrences' => $free_trial || ($initial_amount != $recurring_amount) ? 1 : 0, |
|
396 | 396 | ); |
397 | 397 | |
398 | 398 | $subscription['amount'] = $recurring_amount; |
399 | 399 | $subscription['trialAmount'] = $initial_amount; |
400 | - $subscription['payment'] = array( 'creditCard' => $card_details ); |
|
401 | - $subscription['order'] = array( 'invoiceNumber' => $invoice->ID, 'description' => '#' . $invoice->get_number() ); |
|
402 | - $subscription['customer'] = array( 'id' => $invoice->get_user_id(), 'email' => $invoice->get_email(), 'phoneNumber' => $invoice->phone ); |
|
400 | + $subscription['payment'] = array('creditCard' => $card_details); |
|
401 | + $subscription['order'] = array('invoiceNumber' => $invoice->ID, 'description' => '#' . $invoice->get_number()); |
|
402 | + $subscription['customer'] = array('id' => $invoice->get_user_id(), 'email' => $invoice->get_email(), 'phoneNumber' => $invoice->phone); |
|
403 | 403 | |
404 | 404 | $subscription['billTo'] = array( |
405 | 405 | 'firstName' => $invoice->get_first_name(), |
406 | 406 | 'lastName' => $invoice->get_last_name(), |
407 | 407 | 'company' => $invoice->company, |
408 | - 'address' => wp_strip_all_tags( $invoice->get_address(), true ), |
|
408 | + 'address' => wp_strip_all_tags($invoice->get_address(), true), |
|
409 | 409 | 'city' => $invoice->city, |
410 | 410 | 'state' => $invoice->state, |
411 | 411 | 'zip' => $invoice->zip, |
412 | 412 | 'country' => $invoice->country, |
413 | 413 | ); |
414 | 414 | |
415 | - $params = array( 'subscription' => $subscription ); |
|
415 | + $params = array('subscription' => $subscription); |
|
416 | 416 | |
417 | - return apply_filters( 'wpinv_authorizenet_generate_subscription_params', $params, $invoice, $card_info, $response ); |
|
417 | + return apply_filters('wpinv_authorizenet_generate_subscription_params', $params, $invoice, $card_info, $response); |
|
418 | 418 | } |
419 | 419 | |
420 | -function wpinv_authorizenet_generate_card_info( $card_info = array() ) { |
|
421 | - $card_defaults = array( |
|
420 | +function wpinv_authorizenet_generate_card_info($card_info = array()) { |
|
421 | + $card_defaults = array( |
|
422 | 422 | 'cc_owner' => null, |
423 | 423 | 'cc_number' => null, |
424 | 424 | 'cc_expire_month' => null, |
425 | 425 | 'cc_expire_year' => null, |
426 | 426 | 'cc_cvv2' => null, |
427 | 427 | ); |
428 | - $card_info = wp_parse_args( $card_info, $card_defaults ); |
|
428 | + $card_info = wp_parse_args($card_info, $card_defaults); |
|
429 | 429 | |
430 | 430 | $card_details = array( |
431 | - 'cardNumber' => str_replace( ' ', '', sanitize_text_field( $card_info['cc_number'] ) ), |
|
432 | - 'expirationDate' => sanitize_text_field( $card_info['cc_expire_month'] ) . sanitize_text_field( $card_info['cc_expire_year'] ), |
|
433 | - 'cardCode' => sanitize_text_field( $card_info['cc_cvv2'] ), |
|
431 | + 'cardNumber' => str_replace(' ', '', sanitize_text_field($card_info['cc_number'])), |
|
432 | + 'expirationDate' => sanitize_text_field($card_info['cc_expire_month']) . sanitize_text_field($card_info['cc_expire_year']), |
|
433 | + 'cardCode' => sanitize_text_field($card_info['cc_cvv2']), |
|
434 | 434 | ); |
435 | 435 | |
436 | 436 | return $card_details; |
437 | 437 | } |
438 | 438 | |
439 | -function wpinv_authorizenet_subscription_record_signup( $subscription, $invoice ) { |
|
440 | - $parent_invoice_id = absint( $invoice->ID ); |
|
439 | +function wpinv_authorizenet_subscription_record_signup($subscription, $invoice) { |
|
440 | + $parent_invoice_id = absint($invoice->ID); |
|
441 | 441 | |
442 | - if( empty( $parent_invoice_id ) ) { |
|
442 | + if (empty($parent_invoice_id)) { |
|
443 | 443 | return; |
444 | 444 | } |
445 | 445 | |
446 | - $invoice = wpinv_get_invoice( $parent_invoice_id ); |
|
447 | - if ( empty( $invoice ) ) { |
|
446 | + $invoice = wpinv_get_invoice($parent_invoice_id); |
|
447 | + if (empty($invoice)) { |
|
448 | 448 | return; |
449 | 449 | } |
450 | 450 | |
451 | 451 | $subscriptionId = (array)$subscription->subscriptionId; |
452 | - $subscription_id = !empty( $subscriptionId[0] ) ? $subscriptionId[0] : $parent_invoice_id; |
|
452 | + $subscription_id = !empty($subscriptionId[0]) ? $subscriptionId[0] : $parent_invoice_id; |
|
453 | 453 | |
454 | - $subscription = wpinv_get_authorizenet_subscription( $subscription, $parent_invoice_id ); |
|
454 | + $subscription = wpinv_get_authorizenet_subscription($subscription, $parent_invoice_id); |
|
455 | 455 | |
456 | - if ( false === $subscription ) { |
|
456 | + if (false === $subscription) { |
|
457 | 457 | return; |
458 | 458 | } |
459 | 459 | |
460 | 460 | // Set payment to complete |
461 | - wpinv_update_payment_status( $subscription->parent_payment_id, 'publish' ); |
|
461 | + wpinv_update_payment_status($subscription->parent_payment_id, 'publish'); |
|
462 | 462 | sleep(1); |
463 | - wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'Authorize.Net Subscription ID: %s', 'invoicing' ) , $subscription_id ), '', '', true ); |
|
464 | - update_post_meta($parent_invoice_id,'_wpinv_subscr_profile_id', $subscription_id); |
|
463 | + wpinv_insert_payment_note($parent_invoice_id, sprintf(__('Authorize.Net Subscription ID: %s', 'invoicing'), $subscription_id), '', '', true); |
|
464 | + update_post_meta($parent_invoice_id, '_wpinv_subscr_profile_id', $subscription_id); |
|
465 | 465 | |
466 | 466 | $status = 'trialling' == $subscription->status ? 'trialling' : 'active'; |
467 | - $diff_days = absint( ( ( strtotime( $subscription->expiration ) - strtotime( $subscription->created ) ) / DAY_IN_SECONDS ) ); |
|
468 | - $created = date_i18n( 'Y-m-d H:i:s' ); |
|
469 | - $expiration = date_i18n( 'Y-m-d 23:59:59', ( strtotime( $created ) + ( $diff_days * DAY_IN_SECONDS ) ) ); |
|
467 | + $diff_days = absint(((strtotime($subscription->expiration) - strtotime($subscription->created)) / DAY_IN_SECONDS)); |
|
468 | + $created = date_i18n('Y-m-d H:i:s'); |
|
469 | + $expiration = date_i18n('Y-m-d 23:59:59', (strtotime($created) + ($diff_days * DAY_IN_SECONDS))); |
|
470 | 470 | |
471 | 471 | // Retrieve pending subscription from database and update it's status to active and set proper profile ID |
472 | - $subscription->update( array( 'profile_id' => $subscription_id, 'status' => $status, 'created' => $created, 'expiration' => $expiration ) ); |
|
472 | + $subscription->update(array('profile_id' => $subscription_id, 'status' => $status, 'created' => $created, 'expiration' => $expiration)); |
|
473 | 473 | } |
474 | 474 | |
475 | -function wpinv_authorizenet_validate_checkout( $valid_data, $post ) { |
|
476 | - if ( !empty( $post['wpi-gateway'] ) && $post['wpi-gateway'] == 'authorizenet' ) { |
|
475 | +function wpinv_authorizenet_validate_checkout($valid_data, $post) { |
|
476 | + if (!empty($post['wpi-gateway']) && $post['wpi-gateway'] == 'authorizenet') { |
|
477 | 477 | $error = false; |
478 | 478 | |
479 | - if ( empty( $post['authorizenet']['cc_owner'] ) ) { |
|
479 | + if (empty($post['authorizenet']['cc_owner'])) { |
|
480 | 480 | $error = true; |
481 | - wpinv_set_error( 'empty_card_name', __( 'You must enter the name on your card!', 'invoicing')); |
|
481 | + wpinv_set_error('empty_card_name', __('You must enter the name on your card!', 'invoicing')); |
|
482 | 482 | } |
483 | - if ( empty( $post['authorizenet']['cc_number'] ) ) { |
|
483 | + if (empty($post['authorizenet']['cc_number'])) { |
|
484 | 484 | $error = true; |
485 | - wpinv_set_error( 'empty_card', __( 'You must enter a card number!', 'invoicing')); |
|
485 | + wpinv_set_error('empty_card', __('You must enter a card number!', 'invoicing')); |
|
486 | 486 | } |
487 | - if ( empty( $post['authorizenet']['cc_expire_month'] ) ) { |
|
487 | + if (empty($post['authorizenet']['cc_expire_month'])) { |
|
488 | 488 | $error = true; |
489 | - wpinv_set_error( 'empty_month', __( 'You must enter an card expiration month!', 'invoicing')); |
|
489 | + wpinv_set_error('empty_month', __('You must enter an card expiration month!', 'invoicing')); |
|
490 | 490 | } |
491 | - if ( empty( $post['authorizenet']['cc_expire_year'] ) ) { |
|
491 | + if (empty($post['authorizenet']['cc_expire_year'])) { |
|
492 | 492 | $error = true; |
493 | - wpinv_set_error( 'empty_year', __( 'You must enter an card expiration year!', 'invoicing')); |
|
493 | + wpinv_set_error('empty_year', __('You must enter an card expiration year!', 'invoicing')); |
|
494 | 494 | } |
495 | - if ( empty( $post['authorizenet']['cc_cvv2'] ) ) { |
|
495 | + if (empty($post['authorizenet']['cc_cvv2'])) { |
|
496 | 496 | $error = true; |
497 | - wpinv_set_error( 'empty_cvv2', __( 'You must enter a valid CVV2!', 'invoicing' ) ); |
|
497 | + wpinv_set_error('empty_cvv2', __('You must enter a valid CVV2!', 'invoicing')); |
|
498 | 498 | } |
499 | 499 | |
500 | - if ( $error ) { |
|
500 | + if ($error) { |
|
501 | 501 | return; |
502 | 502 | } |
503 | 503 | |
504 | 504 | $invoice = wpinv_get_invoice_cart(); |
505 | 505 | |
506 | - if ( !empty( $invoice ) && $subscription_item = $invoice->get_recurring( true ) ) { |
|
507 | - $subscription_item = $invoice->get_recurring( true ); |
|
506 | + if (!empty($invoice) && $subscription_item = $invoice->get_recurring(true)) { |
|
507 | + $subscription_item = $invoice->get_recurring(true); |
|
508 | 508 | |
509 | 509 | $interval = $subscription_item->get_recurring_interval(); |
510 | 510 | $period = $subscription_item->get_recurring_period(); |
511 | 511 | |
512 | - if ( $period == 'D' && ( $interval < 7 || $interval > 365 ) ) { |
|
513 | - wpinv_set_error( 'authorizenet_subscription_error', __( 'Interval Length must be a value from 7 through 365 for day based subscriptions.', 'invoicing' ) ); |
|
512 | + if ($period == 'D' && ($interval < 7 || $interval > 365)) { |
|
513 | + wpinv_set_error('authorizenet_subscription_error', __('Interval Length must be a value from 7 through 365 for day based subscriptions.', 'invoicing')); |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | } |
517 | 517 | } |
518 | -add_action( 'wpinv_checkout_error_checks', 'wpinv_authorizenet_validate_checkout', 11, 2 ); |
|
518 | +add_action('wpinv_checkout_error_checks', 'wpinv_authorizenet_validate_checkout', 11, 2); |
|
519 | 519 | |
520 | -function wpinv_authorizenet_get_time_period( $subscription_interval, $subscription_period ) { |
|
521 | - $subscription_interval = absint( $subscription_interval ); |
|
520 | +function wpinv_authorizenet_get_time_period($subscription_interval, $subscription_period) { |
|
521 | + $subscription_interval = absint($subscription_interval); |
|
522 | 522 | |
523 | - switch( $subscription_period ) { |
|
523 | + switch ($subscription_period) { |
|
524 | 524 | case 'W': |
525 | 525 | case 'week': |
526 | 526 | case 'weeks': |
@@ -530,14 +530,14 @@ discard block |
||
530 | 530 | case 'M': |
531 | 531 | case 'month': |
532 | 532 | case 'months': |
533 | - if ( $subscription_interval > 12 ) { |
|
533 | + if ($subscription_interval > 12) { |
|
534 | 534 | $subscription_interval = 12; |
535 | 535 | } |
536 | 536 | |
537 | 537 | $interval = $subscription_interval; |
538 | 538 | $period = 'months'; |
539 | 539 | |
540 | - if ( !( $subscription_interval === 1 || $subscription_interval === 2 || $subscription_interval === 3 || $subscription_interval === 6 || $subscription_interval === 12 ) ) { |
|
540 | + if (!($subscription_interval === 1 || $subscription_interval === 2 || $subscription_interval === 3 || $subscription_interval === 6 || $subscription_interval === 12)) { |
|
541 | 541 | $interval = $subscription_interval * 30; |
542 | 542 | $period = 'days'; |
543 | 543 | } |
@@ -554,30 +554,30 @@ discard block |
||
554 | 554 | break; |
555 | 555 | } |
556 | 556 | |
557 | - return compact( 'interval', 'period' ); |
|
557 | + return compact('interval', 'period'); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | function wpinv_authorizenet_process_ipn() { |
561 | - if ( !( !empty( $_REQUEST['wpi-gateway'] ) && $_REQUEST['wpi-gateway'] == 'authorizenet' ) ) { |
|
561 | + if (!(!empty($_REQUEST['wpi-gateway']) && $_REQUEST['wpi-gateway'] == 'authorizenet')) { |
|
562 | 562 | return; |
563 | 563 | } |
564 | 564 | |
565 | - $subscription_id = !empty( $_POST['x_subscription_id'] ) ? intval( $_POST['x_subscription_id'] ) : false; |
|
565 | + $subscription_id = !empty($_POST['x_subscription_id']) ? intval($_POST['x_subscription_id']) : false; |
|
566 | 566 | |
567 | - if ( $subscription_id ) { |
|
568 | - $response_code = intval( $_POST['x_response_code'] ); |
|
569 | - $reason_code = intval( $_POST['x_response_reason_code'] ); |
|
567 | + if ($subscription_id) { |
|
568 | + $response_code = intval($_POST['x_response_code']); |
|
569 | + $reason_code = intval($_POST['x_response_reason_code']); |
|
570 | 570 | |
571 | - $subscription = new WPInv_Subscription( $subscription_id, true ); |
|
571 | + $subscription = new WPInv_Subscription($subscription_id, true); |
|
572 | 572 | |
573 | - if ( !$subscription->id ) { |
|
573 | + if (!$subscription->id) { |
|
574 | 574 | return; |
575 | 575 | } |
576 | 576 | |
577 | - if ( 1 == $response_code ) { |
|
577 | + if (1 == $response_code) { |
|
578 | 578 | // Approved |
579 | - $transaction_id = sanitize_text_field( $_POST['x_trans_id'] ); |
|
580 | - $renewal_amount = sanitize_text_field( $_POST['x_amount'] ); |
|
579 | + $transaction_id = sanitize_text_field($_POST['x_trans_id']); |
|
580 | + $renewal_amount = sanitize_text_field($_POST['x_amount']); |
|
581 | 581 | |
582 | 582 | $args = array( |
583 | 583 | 'amount' => $renewal_amount, |
@@ -585,63 +585,63 @@ discard block |
||
585 | 585 | 'gateway' => 'authorizenet' |
586 | 586 | ); |
587 | 587 | |
588 | - $subscription->add_payment( $args ); |
|
588 | + $subscription->add_payment($args); |
|
589 | 589 | $subscription->renew(); |
590 | 590 | |
591 | - do_action( 'wpinv_recurring_authorizenet_silent_post_payment', $subscription ); |
|
592 | - do_action( 'wpinv_authorizenet_renewal_payment', $subscription ); |
|
593 | - } else if ( 2 == $response_code ) { |
|
591 | + do_action('wpinv_recurring_authorizenet_silent_post_payment', $subscription); |
|
592 | + do_action('wpinv_authorizenet_renewal_payment', $subscription); |
|
593 | + } else if (2 == $response_code) { |
|
594 | 594 | // Declined |
595 | 595 | $subscription->failing(); |
596 | - do_action( 'wpinv_authorizenet_renewal_payment_failed', $subscription ); |
|
597 | - do_action( 'wpinv_authorizenet_renewal_error', $subscription ); |
|
598 | - } else if ( 3 == $response_code || 8 == $reason_code ) { |
|
596 | + do_action('wpinv_authorizenet_renewal_payment_failed', $subscription); |
|
597 | + do_action('wpinv_authorizenet_renewal_error', $subscription); |
|
598 | + } else if (3 == $response_code || 8 == $reason_code) { |
|
599 | 599 | // An expired card |
600 | 600 | $subscription->failing(); |
601 | - do_action( 'wpinv_authorizenet_renewal_payment_failed', $subscription ); |
|
602 | - do_action( 'wpinv_authorizenet_renewal_error', $subscription ); |
|
601 | + do_action('wpinv_authorizenet_renewal_payment_failed', $subscription); |
|
602 | + do_action('wpinv_authorizenet_renewal_error', $subscription); |
|
603 | 603 | } else { |
604 | 604 | // Other Error |
605 | - do_action( 'wpinv_authorizenet_renewal_payment_error', $subscription ); |
|
605 | + do_action('wpinv_authorizenet_renewal_payment_error', $subscription); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | exit; |
609 | 609 | } |
610 | 610 | } |
611 | -add_action( 'wpinv_verify_authorizenet_ipn', 'wpinv_authorizenet_process_ipn' ); |
|
611 | +add_action('wpinv_verify_authorizenet_ipn', 'wpinv_authorizenet_process_ipn'); |
|
612 | 612 | |
613 | 613 | /** |
614 | 614 | * Retrieve the subscription |
615 | 615 | */ |
616 | -function wpinv_get_authorizenet_subscription( $subscription_data = array(), $invoice_id ) { |
|
617 | - $parent_invoice_id = absint( $invoice_id ); |
|
616 | +function wpinv_get_authorizenet_subscription($subscription_data = array(), $invoice_id) { |
|
617 | + $parent_invoice_id = absint($invoice_id); |
|
618 | 618 | |
619 | - if ( empty( $subscription_data ) ) { |
|
619 | + if (empty($subscription_data)) { |
|
620 | 620 | return false; |
621 | 621 | } |
622 | 622 | |
623 | - if ( empty( $parent_invoice_id ) ) { |
|
623 | + if (empty($parent_invoice_id)) { |
|
624 | 624 | return false; |
625 | 625 | } |
626 | 626 | |
627 | - $invoice = wpinv_get_invoice( $parent_invoice_id ); |
|
628 | - if ( empty( $invoice ) ) { |
|
627 | + $invoice = wpinv_get_invoice($parent_invoice_id); |
|
628 | + if (empty($invoice)) { |
|
629 | 629 | return false; |
630 | 630 | } |
631 | 631 | |
632 | 632 | $subscriptionId = (array)$subscription_data->subscriptionId; |
633 | - $subscription_id = !empty( $subscriptionId[0] ) ? $subscriptionId[0] : $parent_invoice_id; |
|
633 | + $subscription_id = !empty($subscriptionId[0]) ? $subscriptionId[0] : $parent_invoice_id; |
|
634 | 634 | |
635 | - $subscription = new WPInv_Subscription( $subscription_id, true ); |
|
635 | + $subscription = new WPInv_Subscription($subscription_id, true); |
|
636 | 636 | |
637 | - if ( ! $subscription || $subscription->id < 1 ) { |
|
637 | + if (!$subscription || $subscription->id < 1) { |
|
638 | 638 | $subs_db = new WPInv_Subscriptions_DB; |
639 | - $subs = $subs_db->get_subscriptions( array( 'parent_payment_id' => $parent_invoice_id, 'number' => 1 ) ); |
|
640 | - $subscription = reset( $subs ); |
|
639 | + $subs = $subs_db->get_subscriptions(array('parent_payment_id' => $parent_invoice_id, 'number' => 1)); |
|
640 | + $subscription = reset($subs); |
|
641 | 641 | |
642 | - if ( $subscription && $subscription->id > 0 ) { |
|
642 | + if ($subscription && $subscription->id > 0) { |
|
643 | 643 | // Update the profile ID so it is set for future renewals |
644 | - $subscription->update( array( 'profile_id' => sanitize_text_field( $subscription_id ) ) ); |
|
644 | + $subscription->update(array('profile_id' => sanitize_text_field($subscription_id))); |
|
645 | 645 | } else { |
646 | 646 | // No subscription found with a matching payment ID, bail |
647 | 647 | return false; |
@@ -652,67 +652,67 @@ discard block |
||
652 | 652 | } |
653 | 653 | |
654 | 654 | function wpinv_is_authorizenet_valid_for_use() { |
655 | - return in_array( wpinv_get_currency(), apply_filters( 'wpinv_authorizenet_supported_currencies', array( 'AUD', 'CAD', 'CHF', 'DKK', 'EUR', 'GBP', 'JPY', 'NOK', 'NZD', 'PLN', 'SEK', 'USD', 'ZAR' ) ) ); |
|
655 | + return in_array(wpinv_get_currency(), apply_filters('wpinv_authorizenet_supported_currencies', array('AUD', 'CAD', 'CHF', 'DKK', 'EUR', 'GBP', 'JPY', 'NOK', 'NZD', 'PLN', 'SEK', 'USD', 'ZAR'))); |
|
656 | 656 | } |
657 | -function wpinv_check_authorizenet_currency_support( $gateway_list ) { |
|
658 | - if ( isset( $gateway_list['authorizenet'] ) && ! wpinv_is_authorizenet_valid_for_use() ) { |
|
659 | - unset( $gateway_list['authorizenet'] ); |
|
657 | +function wpinv_check_authorizenet_currency_support($gateway_list) { |
|
658 | + if (isset($gateway_list['authorizenet']) && !wpinv_is_authorizenet_valid_for_use()) { |
|
659 | + unset($gateway_list['authorizenet']); |
|
660 | 660 | } |
661 | 661 | return $gateway_list; |
662 | 662 | } |
663 | -add_filter( 'wpinv_enabled_payment_gateways', 'wpinv_check_authorizenet_currency_support', 10, 1 ); |
|
663 | +add_filter('wpinv_enabled_payment_gateways', 'wpinv_check_authorizenet_currency_support', 10, 1); |
|
664 | 664 | |
665 | -function wpinv_authorizenet_link_transaction_id( $transaction_id, $invoice_id, $invoice ) { |
|
666 | - if ( $transaction_id == $invoice_id ) { |
|
665 | +function wpinv_authorizenet_link_transaction_id($transaction_id, $invoice_id, $invoice) { |
|
666 | + if ($transaction_id == $invoice_id) { |
|
667 | 667 | $link = $transaction_id; |
668 | 668 | } else { |
669 | - if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) { |
|
669 | + if (!empty($invoice) && !empty($invoice->mode)) { |
|
670 | 670 | $mode = $invoice->mode; |
671 | 671 | } else { |
672 | - $mode = wpinv_is_test_mode( 'authorizenet' ) ? 'test' : 'live'; |
|
672 | + $mode = wpinv_is_test_mode('authorizenet') ? 'test' : 'live'; |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | $url = $mode == 'test' ? 'https://sandbox.authorize.net/' : 'https://authorize.net/'; |
676 | 676 | $url .= 'ui/themes/sandbox/Transaction/TransactionReceipt.aspx?transid=' . $transaction_id; |
677 | 677 | |
678 | - $link = '<a href="' . esc_url( $url ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
678 | + $link = '<a href="' . esc_url($url) . '" target="_blank">' . $transaction_id . '</a>'; |
|
679 | 679 | } |
680 | 680 | |
681 | - return apply_filters( 'wpinv_authorizenet_link_payment_details_transaction_id', $link, $transaction_id, $invoice ); |
|
681 | + return apply_filters('wpinv_authorizenet_link_payment_details_transaction_id', $link, $transaction_id, $invoice); |
|
682 | 682 | } |
683 | -add_filter( 'wpinv_payment_details_transaction_id-authorizenet', 'wpinv_authorizenet_link_transaction_id', 10, 3 ); |
|
683 | +add_filter('wpinv_payment_details_transaction_id-authorizenet', 'wpinv_authorizenet_link_transaction_id', 10, 3); |
|
684 | 684 | |
685 | -function wpinv_authorizenet_transaction_id_link( $transaction_id, $subscription ) { |
|
686 | - if ( ! empty( $transaction_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) { |
|
687 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
685 | +function wpinv_authorizenet_transaction_id_link($transaction_id, $subscription) { |
|
686 | + if (!empty($transaction_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) { |
|
687 | + $invoice = wpinv_get_invoice($invoice_id); |
|
688 | 688 | |
689 | - if ( ! empty( $invoice ) ) { |
|
690 | - return wpinv_authorizenet_link_transaction_id( $transaction_id, $invoice_id, $invoice ); |
|
689 | + if (!empty($invoice)) { |
|
690 | + return wpinv_authorizenet_link_transaction_id($transaction_id, $invoice_id, $invoice); |
|
691 | 691 | } |
692 | 692 | } |
693 | 693 | |
694 | 694 | return $transaction_id; |
695 | 695 | } |
696 | -add_filter( 'wpinv_subscription_transaction_link_authorizenet', 'wpinv_authorizenet_transaction_id_link', 10, 2 ); |
|
696 | +add_filter('wpinv_subscription_transaction_link_authorizenet', 'wpinv_authorizenet_transaction_id_link', 10, 2); |
|
697 | 697 | |
698 | -function wpinv_authorizenet_profile_id_link( $profile_id, $subscription ) { |
|
698 | +function wpinv_authorizenet_profile_id_link($profile_id, $subscription) { |
|
699 | 699 | $link = $profile_id; |
700 | 700 | |
701 | - if ( ! empty( $profile_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) { |
|
702 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
701 | + if (!empty($profile_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) { |
|
702 | + $invoice = wpinv_get_invoice($invoice_id); |
|
703 | 703 | |
704 | - if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) { |
|
704 | + if (!empty($invoice) && !empty($invoice->mode)) { |
|
705 | 705 | $mode = $invoice->mode; |
706 | 706 | } else { |
707 | - $mode = wpinv_is_test_mode( 'authorizenet' ) ? 'test' : 'live'; |
|
707 | + $mode = wpinv_is_test_mode('authorizenet') ? 'test' : 'live'; |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | $url = $mode == 'test' ? 'https://sandbox.authorize.net/' : 'https://authorize.net/'; |
711 | 711 | $url .= 'ui/themes/sandbox/ARB/SubscriptionDetail.aspx?SubscrID=' . $profile_id; |
712 | 712 | |
713 | - $link = '<a href="' . esc_url( $url ) . '" target="_blank">' . $profile_id . '</a>'; |
|
713 | + $link = '<a href="' . esc_url($url) . '" target="_blank">' . $profile_id . '</a>'; |
|
714 | 714 | } |
715 | 715 | |
716 | - return apply_filters( 'wpinv_authorizenet_profile_id_link', $link, $profile_id, $subscription ); |
|
716 | + return apply_filters('wpinv_authorizenet_profile_id_link', $link, $profile_id, $subscription); |
|
717 | 717 | } |
718 | -add_filter( 'wpinv_subscription_profile_link_authorizenet', 'wpinv_authorizenet_profile_id_link', 10, 2 ); |
|
719 | 718 | \ No newline at end of file |
719 | +add_filter('wpinv_subscription_profile_link_authorizenet', 'wpinv_authorizenet_profile_id_link', 10, 2); |
|
720 | 720 | \ No newline at end of file |
@@ -12,19 +12,19 @@ |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // MUST have WordPress. |
15 | -if ( !defined( 'WPINC' ) ) { |
|
16 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
15 | +if (!defined('WPINC')) { |
|
16 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
17 | 17 | } |
18 | 18 | |
19 | -if ( !defined( 'WPINV_VERSION' ) ) { |
|
20 | - define( 'WPINV_VERSION', '1.0.8' ); |
|
19 | +if (!defined('WPINV_VERSION')) { |
|
20 | + define('WPINV_VERSION', '1.0.8'); |
|
21 | 21 | } |
22 | 22 | |
23 | -if ( !defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
24 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
23 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
24 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
25 | 25 | } |
26 | 26 | |
27 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wpinv.php'; |
|
27 | +require plugin_dir_path(__FILE__) . 'includes/class-wpinv.php'; |
|
28 | 28 | |
29 | 29 | function wpinv_run() { |
30 | 30 | global $invoicing; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -11,60 +11,60 @@ discard block |
||
11 | 11 | public function __construct() { |
12 | 12 | global $bp; |
13 | 13 | |
14 | - if ( !defined( 'WPINV_BP_SLUG' ) ) { |
|
15 | - define( 'WPINV_BP_SLUG', 'invoices' ); |
|
14 | + if (!defined('WPINV_BP_SLUG')) { |
|
15 | + define('WPINV_BP_SLUG', 'invoices'); |
|
16 | 16 | } |
17 | 17 | |
18 | - $position = wpinv_get_option( 'wpinv_menu_position' ); |
|
18 | + $position = wpinv_get_option('wpinv_menu_position'); |
|
19 | 19 | $position = $position !== '' && $position !== false ? $position : 91; |
20 | - $this->position = apply_filters( 'wpinv_bp_nav_position', $position ); |
|
20 | + $this->position = apply_filters('wpinv_bp_nav_position', $position); |
|
21 | 21 | $this->slug = WPINV_BP_SLUG; |
22 | 22 | |
23 | 23 | parent::start( |
24 | 24 | 'invoicing', |
25 | - _x( 'Invoices', 'Invoices screen page <title>', 'invoicing' ), |
|
26 | - trailingslashit( dirname( __FILE__ ) ), |
|
25 | + _x('Invoices', 'Invoices screen page <title>', 'invoicing'), |
|
26 | + trailingslashit(dirname(__FILE__)), |
|
27 | 27 | array( |
28 | 28 | 'adminbar_myaccount_order' => $this->position |
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
33 | - public function includes( $includes = array() ) { |
|
34 | - parent::includes( $includes ); |
|
33 | + public function includes($includes = array()) { |
|
34 | + parent::includes($includes); |
|
35 | 35 | } |
36 | 36 | |
37 | - public function setup_globals( $args = array() ) { |
|
37 | + public function setup_globals($args = array()) { |
|
38 | 38 | global $bp; |
39 | 39 | |
40 | 40 | $args = array( |
41 | 41 | 'slug' => $this->slug, |
42 | 42 | ); |
43 | 43 | |
44 | - parent::setup_globals( $args ); |
|
44 | + parent::setup_globals($args); |
|
45 | 45 | } |
46 | 46 | |
47 | - public function setup_nav( $main_nav = array(), $sub_nav = array() ) { |
|
48 | - if ( !bp_is_my_profile() ) { |
|
47 | + public function setup_nav($main_nav = array(), $sub_nav = array()) { |
|
48 | + if (!bp_is_my_profile()) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
52 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | 56 | $this->setup_invoice_count(); |
57 | 57 | |
58 | 58 | $user_domain = bp_loggedin_user_domain(); |
59 | - $invoices_link = trailingslashit( $user_domain . $this->slug ); |
|
60 | - $class = ( 0 === $this->count ) ? 'no-count' : 'count'; |
|
59 | + $invoices_link = trailingslashit($user_domain . $this->slug); |
|
60 | + $class = (0 === $this->count) ? 'no-count' : 'count'; |
|
61 | 61 | |
62 | 62 | $main_nav_name = sprintf( |
63 | - __( 'My Invoices %s', 'invoicing' ), |
|
63 | + __('My Invoices %s', 'invoicing'), |
|
64 | 64 | sprintf( |
65 | 65 | '<span class="%s">%s</span>', |
66 | - esc_attr( $class ), |
|
67 | - bp_core_number_format( $this->count ) |
|
66 | + esc_attr($class), |
|
67 | + bp_core_number_format($this->count) |
|
68 | 68 | ) |
69 | 69 | ); |
70 | 70 | |
@@ -72,54 +72,54 @@ discard block |
||
72 | 72 | 'name' => $main_nav_name, |
73 | 73 | 'slug' => $this->slug, |
74 | 74 | 'position' => $this->position, |
75 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
75 | + 'screen_function' => array($this, 'invoices_screen'), |
|
76 | 76 | 'default_subnav_slug' => 'invoices', |
77 | 77 | 'item_css_id' => $this->id |
78 | 78 | ); |
79 | 79 | |
80 | 80 | $sub_nav[] = array( |
81 | - 'name' => _x( 'My Invoices', 'Invoices screen sub nav', 'invoicing' ), |
|
81 | + 'name' => _x('My Invoices', 'Invoices screen sub nav', 'invoicing'), |
|
82 | 82 | 'slug' => 'invoices', |
83 | 83 | 'parent_url' => $invoices_link, |
84 | 84 | 'parent_slug' => $this->slug, |
85 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
85 | + 'screen_function' => array($this, 'invoices_screen'), |
|
86 | 86 | 'position' => 10, |
87 | 87 | 'item_css_id' => 'invoices-my-invoices' |
88 | 88 | ); |
89 | 89 | |
90 | - parent::setup_nav( $main_nav, $sub_nav ); |
|
90 | + parent::setup_nav($main_nav, $sub_nav); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public function setup_title() { |
94 | 94 | // Adjust title. |
95 | - if ( (bool)bp_is_current_component( 'invoicing' ) ) { |
|
95 | + if ((bool)bp_is_current_component('invoicing')) { |
|
96 | 96 | global $bp; |
97 | 97 | |
98 | - $bp->bp_options_title = __( 'My Invoices', 'invoicing' ); |
|
98 | + $bp->bp_options_title = __('My Invoices', 'invoicing'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | parent::setup_title(); |
102 | 102 | } |
103 | 103 | |
104 | 104 | public function invoices_screen() { |
105 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
105 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | global $bp; |
110 | 110 | |
111 | - add_action( 'bp_template_content', array( $this, 'invoices_content' ) ); |
|
111 | + add_action('bp_template_content', array($this, 'invoices_content')); |
|
112 | 112 | |
113 | - $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ); |
|
113 | + $template = apply_filters('bp_core_template_plugin', 'members/single/plugins'); |
|
114 | 114 | |
115 | - bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) ); |
|
115 | + bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template)); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | public function invoices_content() { |
119 | - if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) { |
|
119 | + if ($this->has_invoices(bp_ajax_querystring('invoices'))) { |
|
120 | 120 | global $invoices_template; |
121 | 121 | |
122 | - do_action( 'wpinv_bp_invoices_before_content' ); |
|
122 | + do_action('wpinv_bp_invoices_before_content'); |
|
123 | 123 | ?> |
124 | 124 | <div class="wpi-g wpi-bp-invoices invoices invoicing" style="position:relative"> |
125 | 125 | <div id="pag-top" class="pagination"> |
@@ -133,61 +133,61 @@ discard block |
||
133 | 133 | <table class="table table-bordered table-hover table-responsive wpi-user-invoices" style="margin:0"> |
134 | 134 | <thead> |
135 | 135 | <tr> |
136 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
137 | - <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th> |
|
136 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
137 | + <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th> |
|
138 | 138 | <?php endforeach; ?> |
139 | 139 | </tr> |
140 | 140 | </thead> |
141 | 141 | <tbody> |
142 | - <?php foreach ( $invoices_template->invoices as $invoice ) { |
|
142 | + <?php foreach ($invoices_template->invoices as $invoice) { |
|
143 | 143 | ?> |
144 | 144 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
145 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
146 | - <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
|
147 | - <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?> |
|
148 | - <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?> |
|
149 | - |
|
150 | - <?php elseif ( 'invoice-number' === $column_id ) : ?> |
|
151 | - <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>"> |
|
152 | - <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?> |
|
145 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
146 | + <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>"> |
|
147 | + <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?> |
|
148 | + <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?> |
|
149 | + |
|
150 | + <?php elseif ('invoice-number' === $column_id) : ?> |
|
151 | + <a href="<?php echo esc_url($invoice->get_view_url()); ?>"> |
|
152 | + <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?> |
|
153 | 153 | </a> |
154 | 154 | |
155 | - <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?> |
|
156 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
155 | + <?php elseif ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($invoice->ID, 'Y-m-d H:i:s'); ?> |
|
156 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
157 | 157 | |
158 | - <?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?> |
|
159 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
158 | + <?php elseif ('payment-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID, '', false); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s', false); ?> |
|
159 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
160 | 160 | |
161 | - <?php elseif ( 'invoice-status' === $column_id ) : ?> |
|
162 | - <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?> |
|
161 | + <?php elseif ('invoice-status' === $column_id) : ?> |
|
162 | + <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?> |
|
163 | 163 | |
164 | - <?php elseif ( 'invoice-total' === $column_id ) : ?> |
|
165 | - <?php echo $invoice->get_total( true ); ?> |
|
164 | + <?php elseif ('invoice-total' === $column_id) : ?> |
|
165 | + <?php echo $invoice->get_total(true); ?> |
|
166 | 166 | |
167 | - <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
|
167 | + <?php elseif ('invoice-actions' === $column_id) : ?> |
|
168 | 168 | <?php |
169 | 169 | $actions = array( |
170 | 170 | 'pay' => array( |
171 | 171 | 'url' => $invoice->get_checkout_payment_url(), |
172 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
172 | + 'name' => __('Pay Now', 'invoicing'), |
|
173 | 173 | 'class' => 'btn-success' |
174 | 174 | ), |
175 | 175 | 'print' => array( |
176 | 176 | 'url' => $invoice->get_view_url(), |
177 | - 'name' => __( 'Print', 'invoicing' ), |
|
177 | + 'name' => __('Print', 'invoicing'), |
|
178 | 178 | 'class' => 'btn-primary', |
179 | 179 | 'attrs' => 'target="_blank"' |
180 | 180 | ) |
181 | 181 | ); |
182 | 182 | |
183 | - if ( ! $invoice->needs_payment() ) { |
|
184 | - unset( $actions['pay'] ); |
|
183 | + if (!$invoice->needs_payment()) { |
|
184 | + unset($actions['pay']); |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
188 | - foreach ( $actions as $key => $action ) { |
|
187 | + if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) { |
|
188 | + foreach ($actions as $key => $action) { |
|
189 | 189 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
190 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
190 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | ?> |
@@ -215,64 +215,64 @@ discard block |
||
215 | 215 | </div> |
216 | 216 | <?php |
217 | 217 | |
218 | - do_action( 'wpinv_bp_invoices_after_content' ); |
|
218 | + do_action('wpinv_bp_invoices_after_content'); |
|
219 | 219 | } else { |
220 | 220 | ?> |
221 | 221 | <div id="message" class="info"> |
222 | - <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p> |
|
222 | + <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p> |
|
223 | 223 | </div> |
224 | 224 | <?php |
225 | 225 | } |
226 | 226 | |
227 | - if ( defined( 'DOING_AJAX' ) ) { |
|
227 | + if (defined('DOING_AJAX')) { |
|
228 | 228 | exit; |
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | - public function has_invoices( $args = '' ) { |
|
232 | + public function has_invoices($args = '') { |
|
233 | 233 | global $invoices_template; |
234 | 234 | |
235 | - $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) ); |
|
235 | + $per_page = absint(wpinv_get_option('wpinv_bp_per_page')); |
|
236 | 236 | // Parse arguments. |
237 | - $r = bp_parse_args( $args, array( |
|
237 | + $r = bp_parse_args($args, array( |
|
238 | 238 | 'status' => 'all', |
239 | 239 | 'page_arg' => 'bpage', |
240 | 240 | 'page' => 1, |
241 | 241 | 'per_page' => $per_page > 0 ? $per_page : 20, |
242 | 242 | 'max' => false, |
243 | 243 | 'user_id' => bp_loggedin_user_id(), |
244 | - ), 'has_invoices' ); |
|
244 | + ), 'has_invoices'); |
|
245 | 245 | |
246 | 246 | |
247 | - if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) { |
|
247 | + if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) { |
|
248 | 248 | $r['per_page'] = (int)$r['max']; |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Get the invoices. |
252 | - $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] ); |
|
252 | + $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']); |
|
253 | 253 | |
254 | - return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r ); |
|
254 | + return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | public function setup_invoice_count() { |
258 | - $query = apply_filters( 'wpinv_user_invoices_count_query', array( 'user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) ); |
|
259 | - $invoices = wpinv_get_invoices( $query ); |
|
258 | + $query = apply_filters('wpinv_user_invoices_count_query', array('user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false)); |
|
259 | + $invoices = wpinv_get_invoices($query); |
|
260 | 260 | |
261 | - $this->count = !empty( $invoices ) ? count( $invoices ) : 0; |
|
261 | + $this->count = !empty($invoices) ? count($invoices) : 0; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | public function pagination_count() { |
265 | 265 | global $invoices_template; |
266 | 266 | |
267 | - $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1; |
|
268 | - $from_num = bp_core_number_format( $start_num ); |
|
269 | - $to_num = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) ); |
|
270 | - $total = bp_core_number_format( $invoices_template->total_invoice_count ); |
|
267 | + $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1; |
|
268 | + $from_num = bp_core_number_format($start_num); |
|
269 | + $to_num = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1)); |
|
270 | + $total = bp_core_number_format($invoices_template->total_invoice_count); |
|
271 | 271 | |
272 | - if ( 1 == $invoices_template->total_invoice_count ) { |
|
273 | - $message = __( 'Viewing 1 invoice', 'invoicing' ); |
|
272 | + if (1 == $invoices_template->total_invoice_count) { |
|
273 | + $message = __('Viewing 1 invoice', 'invoicing'); |
|
274 | 274 | } else { |
275 | - $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total ); |
|
275 | + $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | return $message; |
@@ -281,32 +281,32 @@ discard block |
||
281 | 281 | function pagination_links() { |
282 | 282 | global $invoices_template; |
283 | 283 | |
284 | - return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links ); |
|
284 | + return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links); |
|
285 | 285 | } |
286 | 286 | |
287 | - public function bp_section( $settings = array() ) { |
|
288 | - $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' ); |
|
287 | + public function bp_section($settings = array()) { |
|
288 | + $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing'); |
|
289 | 289 | return $settings; |
290 | 290 | } |
291 | 291 | |
292 | - public function bp_settings( $settings = array() ) { |
|
292 | + public function bp_settings($settings = array()) { |
|
293 | 293 | $settings['wpinv_bp'] = array( |
294 | 294 | 'wpinv_bp_labels' => array( |
295 | 295 | 'id' => 'wpinv_bp_settings', |
296 | - 'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>', |
|
296 | + 'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>', |
|
297 | 297 | 'desc' => '', |
298 | 298 | 'type' => 'header', |
299 | 299 | ), |
300 | 300 | 'wpinv_bp_hide_menu' => array( |
301 | 301 | 'id' => 'wpinv_bp_hide_menu', |
302 | - 'name' => __( 'Hide Invoices link', 'invoicing' ), |
|
303 | - 'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ), |
|
302 | + 'name' => __('Hide Invoices link', 'invoicing'), |
|
303 | + 'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'), |
|
304 | 304 | 'type' => 'checkbox', |
305 | 305 | ), |
306 | 306 | 'wpinv_menu_position' => array( |
307 | 307 | 'id' => 'wpinv_menu_position', |
308 | - 'name' => __( 'Menu position', 'invoicing' ), |
|
309 | - 'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ), |
|
308 | + 'name' => __('Menu position', 'invoicing'), |
|
309 | + 'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'), |
|
310 | 310 | 'type' => 'number', |
311 | 311 | 'size' => 'small', |
312 | 312 | 'min' => '1', |
@@ -316,8 +316,8 @@ discard block |
||
316 | 316 | ), |
317 | 317 | 'wpinv_bp_per_page' => array( |
318 | 318 | 'id' => 'wpinv_bp_per_page', |
319 | - 'name' => __( 'Max invoices per page', 'invoicing' ), |
|
320 | - 'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ), |
|
319 | + 'name' => __('Max invoices per page', 'invoicing'), |
|
320 | + 'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'), |
|
321 | 321 | 'type' => 'number', |
322 | 322 | 'size' => 'small', |
323 | 323 | 'min' => '1', |
@@ -330,20 +330,20 @@ discard block |
||
330 | 330 | return $settings; |
331 | 331 | } |
332 | 332 | |
333 | - public function wp_nav_menu_objects($items, $args){ |
|
334 | - if(!is_user_logged_in()){ |
|
333 | + public function wp_nav_menu_objects($items, $args) { |
|
334 | + if (!is_user_logged_in()) { |
|
335 | 335 | return $items; |
336 | 336 | } |
337 | 337 | |
338 | - if(!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)){ |
|
338 | + if (!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)) { |
|
339 | 339 | return $items; |
340 | 340 | } |
341 | 341 | |
342 | 342 | $user_id = get_current_user_id(); |
343 | - $link = bp_core_get_user_domain( $user_id ).WPINV_BP_SLUG; |
|
343 | + $link = bp_core_get_user_domain($user_id) . WPINV_BP_SLUG; |
|
344 | 344 | $history_link = wpinv_get_history_page_uri(); |
345 | - foreach ( $items as $item ) { |
|
346 | - $item->url = str_replace( $history_link, $link, $item->url ); |
|
345 | + foreach ($items as $item) { |
|
346 | + $item->url = str_replace($history_link, $link, $item->url); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | return $items; |
@@ -361,25 +361,25 @@ discard block |
||
361 | 361 | public $pag_links = ''; |
362 | 362 | public $total_invoice_count = 0; |
363 | 363 | |
364 | - public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) { |
|
365 | - $this->invoices = array( 'invoices' => array(), 'total' => 0 ); |
|
364 | + public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') { |
|
365 | + $this->invoices = array('invoices' => array(), 'total' => 0); |
|
366 | 366 | |
367 | - $this->pag_arg = sanitize_key( $page_arg ); |
|
368 | - $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page ); |
|
369 | - $this->pag_num = bp_sanitize_pagination_arg( 'num', $per_page ); |
|
367 | + $this->pag_arg = sanitize_key($page_arg); |
|
368 | + $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page); |
|
369 | + $this->pag_num = bp_sanitize_pagination_arg('num', $per_page); |
|
370 | 370 | |
371 | - $query_args = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true ); |
|
372 | - if ( !empty( $status ) && $status != 'all' ) { |
|
371 | + $query_args = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true); |
|
372 | + if (!empty($status) && $status != 'all') { |
|
373 | 373 | $query_args['status'] = $status; |
374 | 374 | } |
375 | - $invoices = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) ); |
|
375 | + $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args)); |
|
376 | 376 | |
377 | - if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) { |
|
378 | - $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
377 | + if (!empty($invoices) && !empty($invoices->found_posts)) { |
|
378 | + $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts); |
|
379 | 379 | $this->invoices['total'] = $invoices->found_posts; |
380 | 380 | } |
381 | 381 | |
382 | - if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) { |
|
382 | + if (empty($max) || ($max >= (int)$this->invoices['total'])) { |
|
383 | 383 | $this->total_invoice_count = (int)$this->invoices['total']; |
384 | 384 | } else { |
385 | 385 | $this->total_invoice_count = (int)$max; |
@@ -387,52 +387,52 @@ discard block |
||
387 | 387 | |
388 | 388 | $this->invoices = $this->invoices['invoices']; |
389 | 389 | |
390 | - $invoice_count = count( $this->invoices ); |
|
390 | + $invoice_count = count($this->invoices); |
|
391 | 391 | |
392 | - if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) { |
|
392 | + if (empty($max) || ($max >= (int)$invoice_count)) { |
|
393 | 393 | $this->invoice_count = (int)$invoice_count; |
394 | 394 | } else { |
395 | 395 | $this->invoice_count = (int)$max; |
396 | 396 | } |
397 | 397 | |
398 | - if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) { |
|
399 | - $this->pag_links = paginate_links( array( |
|
400 | - 'base' => add_query_arg( $this->pag_arg, '%#%' ), |
|
398 | + if (!empty($this->total_invoice_count) && !empty($this->pag_num)) { |
|
399 | + $this->pag_links = paginate_links(array( |
|
400 | + 'base' => add_query_arg($this->pag_arg, '%#%'), |
|
401 | 401 | 'format' => '', |
402 | - 'total' => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ), |
|
402 | + 'total' => ceil((int)$this->total_invoice_count / (int)$this->pag_num), |
|
403 | 403 | 'current' => (int)$this->pag_page, |
404 | - 'prev_text' => _x( '←', 'Invoice pagination previous text', 'invoicing' ), |
|
405 | - 'next_text' => _x( '→', 'Invoice pagination next text', 'invoicing' ), |
|
404 | + 'prev_text' => _x('←', 'Invoice pagination previous text', 'invoicing'), |
|
405 | + 'next_text' => _x('→', 'Invoice pagination next text', 'invoicing'), |
|
406 | 406 | 'mid_size' => 1, |
407 | 407 | 'add_args' => array(), |
408 | - ) ); |
|
408 | + )); |
|
409 | 409 | } |
410 | 410 | } |
411 | 411 | |
412 | 412 | public function has_invoices() { |
413 | - return (bool) ! empty( $this->invoice_count ); |
|
413 | + return (bool)!empty($this->invoice_count); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | public function next_invoice() { |
417 | 417 | $this->current_invoice++; |
418 | - $this->invoice = $this->invoices[ $this->current_invoice ]; |
|
418 | + $this->invoice = $this->invoices[$this->current_invoice]; |
|
419 | 419 | |
420 | 420 | return $this->invoice; |
421 | 421 | } |
422 | 422 | |
423 | 423 | public function rewind_invoices() { |
424 | 424 | $this->current_invoice = -1; |
425 | - if ( $this->invoice_count > 0 ) { |
|
425 | + if ($this->invoice_count > 0) { |
|
426 | 426 | $this->invoice = $this->invoices[0]; |
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
430 | 430 | public function invoices() { |
431 | - if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) { |
|
431 | + if (($this->current_invoice + 1) < $this->invoice_count) { |
|
432 | 432 | return true; |
433 | - } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) { |
|
433 | + } elseif (($this->current_invoice + 1) === $this->invoice_count) { |
|
434 | 434 | |
435 | - do_action( 'wpinv_bp_invoice_loop_end' ); |
|
435 | + do_action('wpinv_bp_invoice_loop_end'); |
|
436 | 436 | |
437 | 437 | $this->rewind_invoices(); |
438 | 438 | } |
@@ -446,8 +446,8 @@ discard block |
||
446 | 446 | $this->in_the_loop = true; |
447 | 447 | $this->invoice = $this->next_invoice(); |
448 | 448 | |
449 | - if ( 0 === $this->current_invoice ) { |
|
450 | - do_action( 'wpinv_bp_invoice_loop_start' ); |
|
449 | + if (0 === $this->current_invoice) { |
|
450 | + do_action('wpinv_bp_invoice_loop_start'); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | } |
@@ -457,10 +457,10 @@ discard block |
||
457 | 457 | |
458 | 458 | $bp->invoicing = new WPInv_BP_Component(); |
459 | 459 | |
460 | - add_action( 'wp_ajax_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) ); |
|
461 | - add_action( 'wp_ajax_nopriv_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) ); |
|
462 | - add_filter( 'wpinv_settings_sections_general', array( $bp->invoicing, 'bp_section' ), 10, 1 ); |
|
463 | - add_filter( 'wpinv_settings_general', array( $bp->invoicing, 'bp_settings' ), 10, 1 ); |
|
464 | - add_filter( 'wp_nav_menu_objects', array( $bp->invoicing, 'wp_nav_menu_objects' ), 10, 2 ); |
|
460 | + add_action('wp_ajax_invoicing_filter', array($bp->invoicing, 'invoices_content')); |
|
461 | + add_action('wp_ajax_nopriv_invoicing_filter', array($bp->invoicing, 'invoices_content')); |
|
462 | + add_filter('wpinv_settings_sections_general', array($bp->invoicing, 'bp_section'), 10, 1); |
|
463 | + add_filter('wpinv_settings_general', array($bp->invoicing, 'bp_settings'), 10, 1); |
|
464 | + add_filter('wp_nav_menu_objects', array($bp->invoicing, 'wp_nav_menu_objects'), 10, 2); |
|
465 | 465 | } |
466 | -add_action( 'bp_loaded', 'wpinv_bp_setup_component' ); |
|
467 | 466 | \ No newline at end of file |
467 | +add_action('bp_loaded', 'wpinv_bp_setup_component'); |
|
468 | 468 | \ No newline at end of file |
@@ -1,30 +1,30 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Details { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | $currency_symbol = wpinv_currency_symbol(); |
10 | - $statuses = wpinv_get_invoice_statuses( true ); |
|
10 | + $statuses = wpinv_get_invoice_statuses(true); |
|
11 | 11 | |
12 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
13 | - $invoice = new WPInv_Invoice( $post_id ); |
|
12 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
13 | + $invoice = new WPInv_Invoice($post_id); |
|
14 | 14 | |
15 | - $status = $invoice->get_status( false ); // Current status |
|
15 | + $status = $invoice->get_status(false); // Current status |
|
16 | 16 | $discount = $invoice->get_discount(); |
17 | 17 | $discount_code = $discount > 0 ? $invoice->get_discount_code() : ''; |
18 | 18 | $invoice_number = $invoice->get_number(); |
19 | 19 | |
20 | 20 | $date_created = $invoice->get_created_date(); |
21 | - $datetime_created = strtotime( $date_created ); |
|
22 | - $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : ''; |
|
21 | + $datetime_created = strtotime($date_created); |
|
22 | + $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : ''; |
|
23 | 23 | $date_completed = $invoice->get_completed_date(); |
24 | - $date_completed = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a'; |
|
25 | - $title['status'] = __( 'Invoice Status:', 'invoicing' ); |
|
26 | - $title['number'] = __( 'Invoice Number:', 'invoicing' ); |
|
27 | - $mail_notice = esc_attr__( 'After saving invoice, this will send a copy of the invoice to the user’s email address.', 'invoicing' ); |
|
24 | + $date_completed = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a'; |
|
25 | + $title['status'] = __('Invoice Status:', 'invoicing'); |
|
26 | + $title['number'] = __('Invoice Number:', 'invoicing'); |
|
27 | + $mail_notice = esc_attr__('After saving invoice, this will send a copy of the invoice to the user’s email address.', 'invoicing'); |
|
28 | 28 | |
29 | 29 | $title = apply_filters('wpinv_details_metabox_titles', $title, $invoice); |
30 | 30 | $statuses = apply_filters('wpinv_invoice_statuses', $statuses, $invoice); |
@@ -34,36 +34,36 @@ discard block |
||
34 | 34 | <div class="gdmbx2-wrap form-table"> |
35 | 35 | <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details"> |
36 | 36 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-created"> |
37 | - <div class="gdmbx-th"><label><?php _e( 'Date Created:', 'invoicing' );?></label></div> |
|
38 | - <div class="gdmbx-td"><?php echo $date_created;?></div> |
|
37 | + <div class="gdmbx-th"><label><?php _e('Date Created:', 'invoicing'); ?></label></div> |
|
38 | + <div class="gdmbx-td"><?php echo $date_created; ?></div> |
|
39 | 39 | </div> |
40 | - <?php if ( $invoice->post_type == 'wpi_invoice' && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft', 'draft' ) ) ) ) { ?> |
|
40 | + <?php if ($invoice->post_type == 'wpi_invoice' && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft', 'draft')))) { ?> |
|
41 | 41 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue"> |
42 | - <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div> |
|
42 | + <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div> |
|
43 | 43 | <div class="gdmbx-td"> |
44 | - <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd"> |
|
45 | - <p class="wpi-meta-row wpi-meta-desc"><?php _e( 'Leave blank to disable sending auto reminder for this invoice.', 'invoicing' );?></p> |
|
44 | + <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd"> |
|
45 | + <p class="wpi-meta-row wpi-meta-desc"><?php _e('Leave blank to disable sending auto reminder for this invoice.', 'invoicing'); ?></p> |
|
46 | 46 | </div> |
47 | 47 | </div> |
48 | 48 | <?php } ?> |
49 | - <?php do_action( 'wpinv_meta_box_details_after_due_date', $post_id ); ?> |
|
50 | - <?php if ( $date_completed && $date_completed != 'n/a' ) { ?> |
|
49 | + <?php do_action('wpinv_meta_box_details_after_due_date', $post_id); ?> |
|
50 | + <?php if ($date_completed && $date_completed != 'n/a') { ?> |
|
51 | 51 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed"> |
52 | - <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div> |
|
53 | - <div class="gdmbx-td"><?php echo $date_completed;?></div> |
|
52 | + <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div> |
|
53 | + <div class="gdmbx-td"><?php echo $date_completed; ?></div> |
|
54 | 54 | </div> |
55 | 55 | <?php } ?> |
56 | - <?php $is_viewed = wpinv_is_invoice_viewed( $post_id ); ?> |
|
56 | + <?php $is_viewed = wpinv_is_invoice_viewed($post_id); ?> |
|
57 | 57 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-customer-viewed"> |
58 | - <div class="gdmbx-th"><label><?php _e( 'Viewed by Customer:', 'invoicing' );?></label></div> |
|
59 | - <div class="gdmbx-td"><?php ( 1 == $is_viewed ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?></div> |
|
58 | + <div class="gdmbx-th"><label><?php _e('Viewed by Customer:', 'invoicing'); ?></label></div> |
|
59 | + <div class="gdmbx-td"><?php (1 == $is_viewed) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?></div> |
|
60 | 60 | </div> |
61 | 61 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status"> |
62 | 62 | <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div> |
63 | 63 | <div class="gdmbx-td"> |
64 | 64 | <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select wpi_select2"> |
65 | - <?php foreach ( $statuses as $value => $label ) { ?> |
|
66 | - <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option> |
|
65 | + <?php foreach ($statuses as $value => $label) { ?> |
|
66 | + <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option> |
|
67 | 67 | <?php } ?> |
68 | 68 | </select> |
69 | 69 | </div> |
@@ -71,117 +71,117 @@ discard block |
||
71 | 71 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout"> |
72 | 72 | <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div> |
73 | 73 | <div class="gdmbx-td"> |
74 | - <input type="text" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly> |
|
74 | + <input type="text" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly> |
|
75 | 75 | </div> |
76 | 76 | </div> |
77 | - <?php do_action( 'wpinv_meta_box_details_inner', $post_id ); |
|
77 | + <?php do_action('wpinv_meta_box_details_inner', $post_id); |
|
78 | 78 | $disable_discount = apply_filters('wpinv_disable_apply_discount', false, $invoice, $post_id); |
79 | 79 | ?> |
80 | - <?php if ( !( $is_paid = ( $invoice->is_paid() || $invoice->is_refunded() ) ) && !$disable_discount || $discount_code ) { ?> |
|
80 | + <?php if (!($is_paid = ($invoice->is_paid() || $invoice->is_refunded())) && !$disable_discount || $discount_code) { ?> |
|
81 | 81 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout"> |
82 | - <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div> |
|
82 | + <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div> |
|
83 | 83 | <div class="gdmbx-td"> |
84 | - <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid && !$disable_discount ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?> |
|
84 | + <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid && !$disable_discount) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?> |
|
85 | 85 | </div> |
86 | 86 | </div> |
87 | 87 | <?php } ?> |
88 | 88 | </div> |
89 | 89 | </div> |
90 | 90 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout"> |
91 | - <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__( 'Send %s:', 'invoicing' ),$post_obj->labels->singular_name) ; ?></label> |
|
91 | + <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__('Send %s:', 'invoicing'), $post_obj->labels->singular_name); ?></label> |
|
92 | 92 | <select id="wpi_save_send" name="wpi_save_send" class="wpi_select2"> |
93 | - <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option> |
|
94 | - <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option> |
|
93 | + <option value="1"><?php _e('Yes', 'invoicing'); ?></option> |
|
94 | + <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option> |
|
95 | 95 | </select> |
96 | 96 | </p> |
97 | 97 | <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p> |
98 | 98 | </div> |
99 | -<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?> |
|
99 | +<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?> |
|
100 | 100 | <?php |
101 | 101 | } |
102 | 102 | |
103 | - public static function resend_invoice( $post ) { |
|
103 | + public static function resend_invoice($post) { |
|
104 | 104 | global $wpi_mb_invoice; |
105 | 105 | |
106 | - if ( empty( $wpi_mb_invoice ) ) { |
|
106 | + if (empty($wpi_mb_invoice)) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | 110 | $text = array( |
111 | - 'message' => esc_attr__( 'This will send a copy of the invoice to the customer’s email address.', 'invoicing' ), |
|
112 | - 'button_text' => __( 'Resend Invoice', 'invoicing' ), |
|
111 | + 'message' => esc_attr__('This will send a copy of the invoice to the customer’s email address.', 'invoicing'), |
|
112 | + 'button_text' => __('Resend Invoice', 'invoicing'), |
|
113 | 113 | ); |
114 | 114 | |
115 | 115 | $text = apply_filters('wpinv_resend_invoice_metabox_text', $text); |
116 | - do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice ); |
|
116 | + do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice); |
|
117 | 117 | |
118 | - if ( $email = $wpi_mb_invoice->get_email() ) { |
|
118 | + if ($email = $wpi_mb_invoice->get_email()) { |
|
119 | 119 | $email_actions = array(); |
120 | - $email_actions['email_url'] = remove_query_arg( 'wpinv-message', add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ); |
|
121 | - $email_actions['reminder_url'] = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) ); |
|
120 | + $email_actions['email_url'] = remove_query_arg('wpinv-message', add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))); |
|
121 | + $email_actions['reminder_url'] = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID)); |
|
122 | 122 | |
123 | - $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions ); |
|
123 | + $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions); |
|
124 | 124 | ?> |
125 | 125 | <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p> |
126 | - <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p> |
|
127 | - <?php if ( wpinv_get_option( 'overdue_active' ) && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?> |
|
128 | - <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p> |
|
126 | + <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url($email_actions['email_url']); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p> |
|
127 | + <?php if (wpinv_get_option('overdue_active') && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?> |
|
128 | + <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_actions['reminder_url']); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p> |
|
129 | 129 | <?php } ?> |
130 | 130 | <?php |
131 | 131 | } |
132 | 132 | |
133 | - do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice ); |
|
133 | + do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice); |
|
134 | 134 | } |
135 | 135 | |
136 | - public static function subscriptions( $post ) { |
|
137 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
136 | + public static function subscriptions($post) { |
|
137 | + $invoice = wpinv_get_invoice($post->ID); |
|
138 | 138 | |
139 | - if ( ! empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) { |
|
140 | - $subscription = wpinv_get_subscription( $invoice ); |
|
139 | + if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) { |
|
140 | + $subscription = wpinv_get_subscription($invoice); |
|
141 | 141 | |
142 | - if ( empty( $subscription ) ) { |
|
142 | + if (empty($subscription)) { |
|
143 | 143 | ?> |
144 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( 'New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing' ), '<a href="' . admin_url( 'admin.php?page=wpinv-subscriptions' ).'">', '</a>' ); ?></p> |
|
144 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing'), '<a href="' . admin_url('admin.php?page=wpinv-subscriptions') . '">', '</a>'); ?></p> |
|
145 | 145 | <?php |
146 | 146 | return; |
147 | 147 | } |
148 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period, $subscription->frequency ); |
|
149 | - $billing = wpinv_price(wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency; |
|
150 | - $initial = wpinv_price(wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ); |
|
148 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency); |
|
149 | + $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency; |
|
150 | + $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)); |
|
151 | 151 | $payments = $subscription->get_child_payments(); |
152 | 152 | ?> |
153 | 153 | <p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . $subscription->status; ?>"><?php _e('Recurring Payment', 'invoicing'); ?></p> |
154 | - <?php if ( ! empty( $subscription ) && ! empty( $subscription->id ) ) { ?> |
|
154 | + <?php if (!empty($subscription) && !empty($subscription->id)) { ?> |
|
155 | 155 | <p class="wpi-meta-row wpi-sub-id"> |
156 | - <label><?php _e( 'Subscription ID:', 'invoicing' ); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p> |
|
156 | + <label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p> |
|
157 | 157 | <?php } ?> |
158 | 158 | <p class="wpi-meta-row wpi-bill-cycle"> |
159 | - <label><?php _e( 'Billing Cycle:', 'invoicing'); ?> </label><?php printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); ?> |
|
159 | + <label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); ?> |
|
160 | 160 | </p> |
161 | 161 | <p class="wpi-meta-row wpi-billed-times"> |
162 | - <label><?php _e( 'Times Billed:', 'invoicing' ); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times ); ?> |
|
162 | + <label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? 'Until Cancelled' : $subscription->bill_times); ?> |
|
163 | 163 | </p> |
164 | 164 | <p class="wpi-meta-row wpi-start-date"> |
165 | - <label><?php _e( 'Start Date:', 'invoicing' ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->created, current_time( 'timestamp' ) ) ); ?> |
|
165 | + <label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?> |
|
166 | 166 | </p> |
167 | 167 | <p class="wpi-meta-row wpi-end-date"> |
168 | - <label><?php echo ( 'trialling' == $subscription->status ? __( 'Trialling Until:', 'invoicing' ) : __( 'Expiration Date:', 'invoicing' ) ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration, current_time( 'timestamp' ) ) ); ?> |
|
168 | + <label><?php echo ('trialling' == $subscription->status ? __('Trialling Until:', 'invoicing') : __('Expiration Date:', 'invoicing')); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?> |
|
169 | 169 | </p> |
170 | - <?php if ( $subscription->status ) { ?> |
|
170 | + <?php if ($subscription->status) { ?> |
|
171 | 171 | <p class="wpi-meta-row wpi-sub-status"> |
172 | - <label><?php _e( 'Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?> |
|
172 | + <label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?> |
|
173 | 173 | </p> |
174 | 174 | <?php } ?> |
175 | - <?php if ( !empty( $payments ) ) { ?> |
|
176 | - <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p> |
|
175 | + <?php if (!empty($payments)) { ?> |
|
176 | + <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p> |
|
177 | 177 | <ul id="wpi-sub-payments"> |
178 | - <?php foreach ( $payments as $payment ) { |
|
178 | + <?php foreach ($payments as $payment) { |
|
179 | 179 | $invoice_id = $payment->ID; |
180 | 180 | ?> |
181 | 181 | <li> |
182 | - <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a> – |
|
183 | - <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?> – </span> |
|
184 | - <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span> |
|
182 | + <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a> – |
|
183 | + <span><?php echo wpinv_get_invoice_date($invoice_id); ?> – </span> |
|
184 | + <span><?php echo wpinv_payment_total($invoice_id, true); ?></span> |
|
185 | 185 | </li> |
186 | 186 | <?php } ?> |
187 | 187 | </ul> |
@@ -189,50 +189,50 @@ discard block |
||
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
192 | - public static function renewals( $post ) { |
|
193 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
192 | + public static function renewals($post) { |
|
193 | + $invoice = wpinv_get_invoice($post->ID); |
|
194 | 194 | |
195 | - if ( wpinv_is_subscription_payment( $invoice ) ) { |
|
196 | - $parent_url = get_edit_post_link( $invoice->parent_invoice ); |
|
197 | - $parent_id = wpinv_get_invoice_number( $invoice->parent_invoice ); |
|
198 | - $subscription = wpinv_get_subscription( $invoice ); |
|
195 | + if (wpinv_is_subscription_payment($invoice)) { |
|
196 | + $parent_url = get_edit_post_link($invoice->parent_invoice); |
|
197 | + $parent_id = wpinv_get_invoice_number($invoice->parent_invoice); |
|
198 | + $subscription = wpinv_get_subscription($invoice); |
|
199 | 199 | ?> |
200 | - <?php if ( ! empty( $subscription ) ) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?> |
|
201 | - <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p> |
|
200 | + <?php if (!empty($subscription)) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?> |
|
201 | + <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p> |
|
202 | 202 | <?php |
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | - public static function payment_meta( $post ) { |
|
206 | + public static function payment_meta($post) { |
|
207 | 207 | global $wpi_mb_invoice; |
208 | 208 | |
209 | - $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false; |
|
210 | - if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded() ) { |
|
209 | + $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false; |
|
210 | + if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded()) { |
|
211 | 211 | $set_dateway = true; |
212 | 212 | } |
213 | 213 | |
214 | 214 | ?> |
215 | 215 | <p class="wpi-meta-row"> |
216 | - <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?> |
|
217 | - <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label> |
|
216 | + <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?> |
|
217 | + <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label> |
|
218 | 218 | <select required="required" id="wpinv_gateway" class="wpi_select2" name="wpinv_gateway"> |
219 | - <?php foreach ( $gateways as $name => $gateway ) { |
|
220 | - if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) { |
|
219 | + <?php foreach ($gateways as $name => $gateway) { |
|
220 | + if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) { |
|
221 | 221 | continue; |
222 | 222 | } |
223 | 223 | ?> |
224 | - <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option> |
|
224 | + <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option> |
|
225 | 225 | <?php } ?> |
226 | 226 | </select> |
227 | 227 | <?php } else { |
228 | - echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_admin_label( $wpi_mb_invoice->gateway ) ); |
|
228 | + echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_admin_label($wpi_mb_invoice->gateway)); |
|
229 | 229 | } ?> |
230 | 230 | </p> |
231 | - <?php if ( $key = $wpi_mb_invoice->get_key() ) { ?> |
|
232 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $key ); ?></p> |
|
231 | + <?php if ($key = $wpi_mb_invoice->get_key()) { ?> |
|
232 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $key); ?></p> |
|
233 | 233 | <?php } ?> |
234 | - <?php if ( $wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded() ) { ?> |
|
235 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p> |
|
234 | + <?php if ($wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded()) { ?> |
|
235 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p> |
|
236 | 236 | <?php } ?> |
237 | 237 | <?php |
238 | 238 | } |
@@ -1,34 +1,34 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Billing_Details { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $user_ID; |
10 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
11 | - $invoice = new WPInv_Invoice( $post_id ); |
|
10 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
11 | + $invoice = new WPInv_Invoice($post_id); |
|
12 | 12 | ?> |
13 | 13 | <div class="gdmbx2-wrap form-table"> |
14 | 14 | <div id="gdmbx2-metabox-wpinv_address" class="gdmbx2-metabox gdmbx-field-list wpinv-address gdmbx-row"> |
15 | 15 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-user-id table-layout"> |
16 | 16 | <div class="gdmbx-th"> |
17 | - <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
|
17 | + <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label> |
|
18 | 18 | </div> |
19 | 19 | <div class="gdmbx-td gdmbx-customer-div"> |
20 | - <?php wpinv_dropdown_users( array( |
|
20 | + <?php wpinv_dropdown_users(array( |
|
21 | 21 | 'name' => 'post_author_override', |
22 | 22 | 'selected' => empty($post->ID) ? $user_ID : $post->post_author, |
23 | 23 | 'include_selected' => true, |
24 | 24 | 'show' => 'display_name_with_email', |
25 | 25 | 'orderby' => 'user_email', |
26 | 26 | 'class' => 'gdmbx2-text-large wpi_select2' |
27 | - ) ); ?> |
|
27 | + )); ?> |
|
28 | 28 | </div> |
29 | 29 | </div> |
30 | 30 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-email table-layout" style="display:none"> |
31 | - <div class="gdmbx-th"><label for="wpinv_email"><?php _e( 'Email', 'invoicing' );?> <span class="required">*</span></label> |
|
31 | + <div class="gdmbx-th"><label for="wpinv_email"><?php _e('Email', 'invoicing'); ?> <span class="required">*</span></label> |
|
32 | 32 | </div> |
33 | 33 | <div class="gdmbx-td"> |
34 | 34 | <input type="hidden" id="wpinv_new_user" name="wpinv_new_user" value="" /> |
@@ -36,122 +36,122 @@ discard block |
||
36 | 36 | </div> |
37 | 37 | </div> |
38 | 38 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-btns table-layout"> |
39 | - <div class="gdmbx-th"><label><?php _e( 'Actions', 'invoicing' );?></label> |
|
39 | + <div class="gdmbx-th"><label><?php _e('Actions', 'invoicing'); ?></label> |
|
40 | 40 | </div> |
41 | - <?php if ( $invoice->has_status( array( 'auto-draft', 'draft', 'wpi-pending', 'wpi-quote-pending' ) ) ) { ?> |
|
41 | + <?php if ($invoice->has_status(array('auto-draft', 'draft', 'wpi-pending', 'wpi-quote-pending'))) { ?> |
|
42 | 42 | <div class="gdmbx-td"> |
43 | - <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e( 'Fill User Details', 'invoicing' );?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e( 'Fill User Details', 'invoicing' );?></a> |
|
44 | - <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e( 'Add New User', 'invoicing' );?></a> |
|
45 | - <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e( 'Cancel', 'invoicing' );?> </a> |
|
43 | + <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e('Fill User Details', 'invoicing'); ?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e('Fill User Details', 'invoicing'); ?></a> |
|
44 | + <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e('Add New User', 'invoicing'); ?></a> |
|
45 | + <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e('Cancel', 'invoicing'); ?> </a> |
|
46 | 46 | </div> |
47 | 47 | <?php } ?> |
48 | 48 | </div> |
49 | 49 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-first-name table-layout"> |
50 | - <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e( 'First Name', 'invoicing' );?></label></div> |
|
50 | + <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e('First Name', 'invoicing'); ?></label></div> |
|
51 | 51 | <div class="gdmbx-td"> |
52 | - <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr( $invoice->first_name );?>" /> |
|
52 | + <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr($invoice->first_name); ?>" /> |
|
53 | 53 | </div> |
54 | 54 | </div> |
55 | 55 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-last-name table-layout"> |
56 | - <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e( 'Last Name', 'invoicing' );?></label></div> |
|
56 | + <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e('Last Name', 'invoicing'); ?></label></div> |
|
57 | 57 | <div class="gdmbx-td"> |
58 | - <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr( $invoice->last_name );?>" /> |
|
58 | + <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr($invoice->last_name); ?>" /> |
|
59 | 59 | </div> |
60 | 60 | </div> |
61 | 61 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-company table-layout"> |
62 | - <div class="gdmbx-th"><label for="wpinv_company"><?php _e( 'Company', 'invoicing' );?></label></div> |
|
62 | + <div class="gdmbx-th"><label for="wpinv_company"><?php _e('Company', 'invoicing'); ?></label></div> |
|
63 | 63 | <div class="gdmbx-td"> |
64 | - <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr( $invoice->company );?>" /> |
|
64 | + <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr($invoice->company); ?>" /> |
|
65 | 65 | </div> |
66 | 66 | </div> |
67 | 67 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-vat-number table-layout"> |
68 | - <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e( 'Vat Number', 'invoicing' );?></label></div> |
|
68 | + <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e('Vat Number', 'invoicing'); ?></label></div> |
|
69 | 69 | <div class="gdmbx-td"> |
70 | - <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr( $invoice->vat_number );?>" /> |
|
70 | + <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr($invoice->vat_number); ?>" /> |
|
71 | 71 | </div> |
72 | 72 | </div> |
73 | 73 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-address table-layout"> |
74 | - <div class="gdmbx-th"><label for="wpinv_address"><?php _e( 'Address', 'invoicing' );?></label></div> |
|
74 | + <div class="gdmbx-th"><label for="wpinv_address"><?php _e('Address', 'invoicing'); ?></label></div> |
|
75 | 75 | <div class="gdmbx-td"> |
76 | - <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr( $invoice->address );?>" /> |
|
76 | + <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr($invoice->address); ?>" /> |
|
77 | 77 | </div> |
78 | 78 | </div> |
79 | 79 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-city table-layout"> |
80 | - <div class="gdmbx-th"><label for="wpinv_city"><?php _e( 'City', 'invoicing' );?></label></div> |
|
80 | + <div class="gdmbx-th"><label for="wpinv_city"><?php _e('City', 'invoicing'); ?></label></div> |
|
81 | 81 | <div class="gdmbx-td"> |
82 | - <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr( $invoice->city );?>" /> |
|
82 | + <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr($invoice->city); ?>" /> |
|
83 | 83 | </div> |
84 | 84 | </div> |
85 | 85 | <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-country table-layout"> |
86 | - <div class="gdmbx-th"><label for="wpinv_country"><?php _e( 'Country', 'invoicing' );?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
86 | + <div class="gdmbx-th"><label for="wpinv_country"><?php _e('Country', 'invoicing'); ?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
87 | 87 | <div class="gdmbx-td"> |
88 | 88 | <?php |
89 | - echo wpinv_html_select( array( |
|
90 | - 'options' => array_merge( array( '' => __( 'Choose a country', 'invoicing' ) ), wpinv_get_country_list() ), |
|
89 | + echo wpinv_html_select(array( |
|
90 | + 'options' => array_merge(array('' => __('Choose a country', 'invoicing')), wpinv_get_country_list()), |
|
91 | 91 | 'name' => 'wpinv_country', |
92 | 92 | 'id' => 'wpinv_country', |
93 | 93 | 'selected' => $invoice->country, |
94 | 94 | 'show_option_all' => false, |
95 | 95 | 'show_option_none' => false, |
96 | 96 | 'class' => 'gdmbx2-text-large wpi_select2', |
97 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
97 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
98 | 98 | 'required' => false, |
99 | - ) ); |
|
99 | + )); |
|
100 | 100 | ?> |
101 | 101 | </div> |
102 | 102 | </div> |
103 | 103 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-state table-layout"> |
104 | - <div class="gdmbx-th"><label for="wpinv_state"><?php _e( 'State', 'invoicing' );?></label></div> |
|
104 | + <div class="gdmbx-th"><label for="wpinv_state"><?php _e('State', 'invoicing'); ?></label></div> |
|
105 | 105 | <div class="gdmbx-td"> |
106 | 106 | <?php |
107 | - $states = wpinv_get_country_states( $invoice->country ); |
|
108 | - if( !empty( $states ) ) { |
|
109 | - echo wpinv_html_select( array( |
|
110 | - 'options' => array_merge( array( '' => __( 'Choose a state', 'invoicing' ) ), $states ), |
|
107 | + $states = wpinv_get_country_states($invoice->country); |
|
108 | + if (!empty($states)) { |
|
109 | + echo wpinv_html_select(array( |
|
110 | + 'options' => array_merge(array('' => __('Choose a state', 'invoicing')), $states), |
|
111 | 111 | 'name' => 'wpinv_state', |
112 | 112 | 'id' => 'wpinv_state', |
113 | 113 | 'selected' => $invoice->state, |
114 | 114 | 'show_option_all' => false, |
115 | 115 | 'show_option_none' => false, |
116 | 116 | 'class' => 'gdmbx2-text-large wpi_select2', |
117 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
117 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
118 | 118 | 'required' => false, |
119 | - ) ); |
|
119 | + )); |
|
120 | 120 | } else { |
121 | - echo wpinv_html_text( array( |
|
121 | + echo wpinv_html_text(array( |
|
122 | 122 | 'name' => 'wpinv_state', |
123 | - 'value' => ! empty( $invoice->state ) ? $invoice->state : '', |
|
123 | + 'value' => !empty($invoice->state) ? $invoice->state : '', |
|
124 | 124 | 'id' => 'wpinv_state', |
125 | 125 | 'class' => 'gdmbx2-text-large', |
126 | 126 | 'required' => false, |
127 | - ) ); |
|
127 | + )); |
|
128 | 128 | } |
129 | 129 | ?> |
130 | 130 | </div> |
131 | 131 | </div> |
132 | 132 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-zip table-layout"> |
133 | - <div class="gdmbx-th"><label for="wpinv_zip"><?php _e( 'Zipcode', 'invoicing' );?></label></div> |
|
133 | + <div class="gdmbx-th"><label for="wpinv_zip"><?php _e('Zipcode', 'invoicing'); ?></label></div> |
|
134 | 134 | <div class="gdmbx-td"> |
135 | - <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr( $invoice->zip );?>" /> |
|
135 | + <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr($invoice->zip); ?>" /> |
|
136 | 136 | </div> |
137 | 137 | </div> |
138 | 138 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-phone table-layout"> |
139 | - <div class="gdmbx-th"><label for="wpinv_phone"><?php _e( 'Phone', 'invoicing' );?></label></div> |
|
139 | + <div class="gdmbx-th"><label for="wpinv_phone"><?php _e('Phone', 'invoicing'); ?></label></div> |
|
140 | 140 | <div class="gdmbx-td"> |
141 | - <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr( $invoice->phone );?>" /> |
|
141 | + <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr($invoice->phone); ?>" /> |
|
142 | 142 | </div> |
143 | 143 | </div> |
144 | 144 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-ip table-layout"> |
145 | - <div class="gdmbx-th"><label for="wpinv_ip"><?php _e( 'IP Address', 'invoicing' );?><?php if ($invoice->ip) { ?> |
|
146 | - <a href="<?php echo admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip ); ?>" title="<?php esc_attr_e( 'View IP information', 'invoicing' );?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
145 | + <div class="gdmbx-th"><label for="wpinv_ip"><?php _e('IP Address', 'invoicing'); ?><?php if ($invoice->ip) { ?> |
|
146 | + <a href="<?php echo admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip); ?>" title="<?php esc_attr_e('View IP information', 'invoicing'); ?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
147 | 147 | <?php } ?></label></div> |
148 | 148 | <div class="gdmbx-td"> |
149 | - <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr( $invoice->ip );?>" readonly /> |
|
149 | + <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr($invoice->ip); ?>" readonly /> |
|
150 | 150 | </div> |
151 | 151 | </div> |
152 | 152 | </div> |
153 | 153 | </div> |
154 | -<?php wp_nonce_field( 'wpinv_save_invoice', 'wpinv_save_invoice' ) ;?> |
|
154 | +<?php wp_nonce_field('wpinv_save_invoice', 'wpinv_save_invoice'); ?> |
|
155 | 155 | <?php |
156 | 156 | } |
157 | 157 | } |
@@ -1,47 +1,47 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Items { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $wpinv_euvat, $ajax_cart_details; |
10 | 10 | |
11 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
12 | - $invoice = new WPInv_Invoice( $post_id ); |
|
11 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
12 | + $invoice = new WPInv_Invoice($post_id); |
|
13 | 13 | $ajax_cart_details = $invoice->get_cart_details(); |
14 | - $subtotal = $invoice->get_subtotal( true ); |
|
14 | + $subtotal = $invoice->get_subtotal(true); |
|
15 | 15 | $discount_raw = $invoice->get_discount(); |
16 | - $discount = wpinv_price( $discount_raw, $invoice->get_currency() ); |
|
16 | + $discount = wpinv_price($discount_raw, $invoice->get_currency()); |
|
17 | 17 | $discounts = $discount_raw > 0 ? $invoice->get_discounts() : ''; |
18 | - $tax = $invoice->get_tax( true ); |
|
19 | - $total = $invoice->get_total( true ); |
|
18 | + $tax = $invoice->get_tax(true); |
|
19 | + $total = $invoice->get_total(true); |
|
20 | 20 | $item_quantities = wpinv_item_quantities_enabled(); |
21 | 21 | $use_taxes = wpinv_use_taxes(); |
22 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
22 | + if (!$use_taxes && (float)$invoice->get_tax() > 0) { |
|
23 | 23 | $use_taxes = true; |
24 | 24 | } |
25 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
25 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
26 | 26 | $is_recurring = $invoice->is_recurring(); |
27 | 27 | $post_type_object = get_post_type_object($invoice->post_type); |
28 | 28 | $type_title = $post_type_object->labels->singular_name; |
29 | 29 | |
30 | 30 | $cols = 5; |
31 | - if ( $item_quantities ) { |
|
31 | + if ($item_quantities) { |
|
32 | 32 | $cols++; |
33 | 33 | } |
34 | - if ( $use_taxes ) { |
|
34 | + if ($use_taxes) { |
|
35 | 35 | $cols++; |
36 | 36 | } |
37 | 37 | $class = ''; |
38 | - if ( $invoice->is_paid() ) { |
|
38 | + if ($invoice->is_paid()) { |
|
39 | 39 | $class .= ' wpinv-paid'; |
40 | 40 | } |
41 | - if ( $invoice->is_refunded() ) { |
|
41 | + if ($invoice->is_refunded()) { |
|
42 | 42 | $class .= ' wpinv-refunded'; |
43 | 43 | } |
44 | - if ( $is_recurring ) { |
|
44 | + if ($is_recurring) { |
|
45 | 45 | $class .= ' wpi-recurring'; |
46 | 46 | } |
47 | 47 | ?> |
@@ -49,21 +49,21 @@ discard block |
||
49 | 49 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
50 | 50 | <thead> |
51 | 51 | <tr> |
52 | - <th class="id"><?php _e( 'ID', 'invoicing' );?></th> |
|
53 | - <th class="title"><?php _e( 'Item', 'invoicing' );?></th> |
|
54 | - <th class="price"><?php _e( 'Price', 'invoicing' );?></th> |
|
55 | - <?php if ( $item_quantities ) { ?> |
|
56 | - <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th> |
|
52 | + <th class="id"><?php _e('ID', 'invoicing'); ?></th> |
|
53 | + <th class="title"><?php _e('Item', 'invoicing'); ?></th> |
|
54 | + <th class="price"><?php _e('Price', 'invoicing'); ?></th> |
|
55 | + <?php if ($item_quantities) { ?> |
|
56 | + <th class="qty"><?php _e('Qty', 'invoicing'); ?></th> |
|
57 | 57 | <?php } ?> |
58 | - <th class="total"><?php _e( 'Total', 'invoicing' );?></th> |
|
59 | - <?php if ( $use_taxes ) { ?> |
|
60 | - <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th> |
|
58 | + <th class="total"><?php _e('Total', 'invoicing'); ?></th> |
|
59 | + <?php if ($use_taxes) { ?> |
|
60 | + <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th> |
|
61 | 61 | <?php } ?> |
62 | 62 | <th class="action"></th> |
63 | 63 | </tr> |
64 | 64 | </thead> |
65 | 65 | <tbody class="wpinv-line-items"> |
66 | - <?php echo wpinv_admin_get_line_items( $invoice ); ?> |
|
66 | + <?php echo wpinv_admin_get_line_items($invoice); ?> |
|
67 | 67 | </tbody> |
68 | 68 | <tfoot class="wpinv-totals"> |
69 | 69 | <tr> |
@@ -74,45 +74,45 @@ discard block |
||
74 | 74 | <td class="id"> |
75 | 75 | </td> |
76 | 76 | <td class="title"> |
77 | - <input type="text" class="regular-text" placeholder="<?php _e( 'Item Name', 'invoicing' ); ?>" value="" name="_wpinv_quick[name]"> |
|
78 | - <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?> |
|
77 | + <input type="text" class="regular-text" placeholder="<?php _e('Item Name', 'invoicing'); ?>" value="" name="_wpinv_quick[name]"> |
|
78 | + <?php if ($wpinv_euvat->allow_vat_rules()) { ?> |
|
79 | 79 | <div class="wp-clearfix"> |
80 | 80 | <label class="wpi-vat-rule"> |
81 | - <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span> |
|
81 | + <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span> |
|
82 | 82 | <span class="input-text-wrap"> |
83 | - <?php echo wpinv_html_select( array( |
|
83 | + <?php echo wpinv_html_select(array( |
|
84 | 84 | 'options' => $wpinv_euvat->get_rules(), |
85 | 85 | 'name' => '_wpinv_quick[vat_rule]', |
86 | 86 | 'id' => '_wpinv_quick_vat_rule', |
87 | 87 | 'show_option_all' => false, |
88 | 88 | 'show_option_none' => false, |
89 | 89 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule wpi_select2', |
90 | - ) ); ?> |
|
90 | + )); ?> |
|
91 | 91 | </span> |
92 | 92 | </label> |
93 | 93 | </div> |
94 | - <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?> |
|
94 | + <?php } if ($wpinv_euvat->allow_vat_classes()) { ?> |
|
95 | 95 | <div class="wp-clearfix"> |
96 | 96 | <label class="wpi-vat-class"> |
97 | - <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span> |
|
97 | + <span class="title"><?php _e('VAT class', 'invoicing'); ?></span> |
|
98 | 98 | <span class="input-text-wrap"> |
99 | - <?php echo wpinv_html_select( array( |
|
99 | + <?php echo wpinv_html_select(array( |
|
100 | 100 | 'options' => $wpinv_euvat->get_all_classes(), |
101 | 101 | 'name' => '_wpinv_quick[vat_class]', |
102 | 102 | 'id' => '_wpinv_quick_vat_class', |
103 | 103 | 'show_option_all' => false, |
104 | 104 | 'show_option_none' => false, |
105 | 105 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class wpi_select2', |
106 | - ) ); ?> |
|
106 | + )); ?> |
|
107 | 107 | </span> |
108 | 108 | </label> |
109 | 109 | </div> |
110 | 110 | <?php } ?> |
111 | 111 | <div class="wp-clearfix"> |
112 | 112 | <label class="wpi-item-type"> |
113 | - <span class="title"><?php _e( 'Item type', 'invoicing' );?></span> |
|
113 | + <span class="title"><?php _e('Item type', 'invoicing'); ?></span> |
|
114 | 114 | <span class="input-text-wrap"> |
115 | - <?php echo wpinv_html_select( array( |
|
115 | + <?php echo wpinv_html_select(array( |
|
116 | 116 | 'options' => $item_types, |
117 | 117 | 'name' => '_wpinv_quick[type]', |
118 | 118 | 'id' => '_wpinv_quick_type', |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | 'show_option_all' => false, |
121 | 121 | 'show_option_none' => false, |
122 | 122 | 'class' => 'gdmbx2-text-medium wpinv-quick-type wpi_select2', |
123 | - ) ); ?> |
|
123 | + )); ?> |
|
124 | 124 | </span> |
125 | 125 | </label> |
126 | 126 | </div> |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | </div> |
134 | 134 | </td> |
135 | 135 | <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td> |
136 | - <?php if ( $item_quantities ) { ?> |
|
136 | + <?php if ($item_quantities) { ?> |
|
137 | 137 | <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td> |
138 | 138 | <?php } ?> |
139 | 139 | <td class="total"></td> |
140 | - <?php if ( $use_taxes ) { ?> |
|
140 | + <?php if ($use_taxes) { ?> |
|
141 | 141 | <td class="tax"></td> |
142 | 142 | <?php } ?> |
143 | 143 | <td class="action"></td> |
@@ -150,29 +150,29 @@ discard block |
||
150 | 150 | <td colspan="<?php echo $cols; ?>"></td> |
151 | 151 | </tr> |
152 | 152 | <tr class="totals"> |
153 | - <td colspan="<?php echo ( $cols - 4 ); ?>"></td> |
|
153 | + <td colspan="<?php echo ($cols - 4); ?>"></td> |
|
154 | 154 | <td colspan="4"> |
155 | 155 | <table cellspacing="0" cellpadding="0"> |
156 | 156 | <tr class="subtotal"> |
157 | - <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td> |
|
158 | - <td class="total"><?php echo $subtotal;?></td> |
|
157 | + <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td> |
|
158 | + <td class="total"><?php echo $subtotal; ?></td> |
|
159 | 159 | <td class="action"></td> |
160 | 160 | </tr> |
161 | 161 | <tr class="discount"> |
162 | - <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td> |
|
163 | - <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td> |
|
162 | + <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td> |
|
163 | + <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td> |
|
164 | 164 | <td class="action"></td> |
165 | 165 | </tr> |
166 | - <?php if ( $use_taxes ) { ?> |
|
166 | + <?php if ($use_taxes) { ?> |
|
167 | 167 | <tr class="tax"> |
168 | - <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td> |
|
169 | - <td class="total"><?php echo $tax;?></td> |
|
168 | + <td class="name"><?php _e('Tax:', 'invoicing'); ?></td> |
|
169 | + <td class="total"><?php echo $tax; ?></td> |
|
170 | 170 | <td class="action"></td> |
171 | 171 | </tr> |
172 | 172 | <?php } ?> |
173 | 173 | <tr class="total"> |
174 | - <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td> |
|
175 | - <td class="total"><?php echo $total;?></td> |
|
174 | + <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td> |
|
175 | + <td class="total"><?php echo $total; ?></td> |
|
176 | 176 | <td class="action"></td> |
177 | 177 | </tr> |
178 | 178 | </table> |
@@ -183,60 +183,60 @@ discard block |
||
183 | 183 | <div class="wpinv-actions"> |
184 | 184 | <?php ob_start(); ?> |
185 | 185 | <?php |
186 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() ) { |
|
187 | - if ( !$invoice->is_recurring() ) { |
|
188 | - echo wpinv_item_dropdown( array( |
|
186 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
187 | + if (!$invoice->is_recurring()) { |
|
188 | + echo wpinv_item_dropdown(array( |
|
189 | 189 | 'name' => 'wpinv_invoice_item', |
190 | 190 | 'id' => 'wpinv_invoice_item', |
191 | 191 | 'show_recurring' => true, |
192 | 192 | 'class' => 'wpi_select2', |
193 | - ) ); |
|
193 | + )); |
|
194 | 194 | ?> |
195 | - <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
195 | + <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals"> |
|
196 | 196 | <?php } ?> |
197 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
198 | - <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?> |
|
197 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
198 | + <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?> |
|
199 | 199 | </div> |
200 | 200 | </div> |
201 | 201 | <?php |
202 | 202 | } |
203 | 203 | |
204 | - public static function prices( $post ) { |
|
204 | + public static function prices($post) { |
|
205 | 205 | $symbol = wpinv_currency_symbol(); |
206 | 206 | $position = wpinv_currency_position(); |
207 | - $item = new WPInv_Item( $post->ID ); |
|
207 | + $item = new WPInv_Item($post->ID); |
|
208 | 208 | |
209 | 209 | $price = $item->get_price(); |
210 | 210 | $is_recurring = $item->is_recurring(); |
211 | 211 | $period = $item->get_recurring_period(); |
212 | - $interval = absint( $item->get_recurring_interval() ); |
|
213 | - $times = absint( $item->get_recurring_limit() ); |
|
212 | + $interval = absint($item->get_recurring_interval()); |
|
213 | + $times = absint($item->get_recurring_limit()); |
|
214 | 214 | $free_trial = $item->has_free_trial(); |
215 | 215 | $trial_interval = $item->get_trial_interval(); |
216 | 216 | $trial_period = $item->get_trial_period(); |
217 | 217 | |
218 | 218 | $intervals = array(); |
219 | - for ( $i = 1; $i <= 90; $i++ ) { |
|
219 | + for ($i = 1; $i <= 90; $i++) { |
|
220 | 220 | $intervals[$i] = $i; |
221 | 221 | } |
222 | 222 | |
223 | - $interval = $interval > 0 ? $interval : 1; |
|
223 | + $interval = $interval > 0 ? $interval : 1; |
|
224 | 224 | |
225 | 225 | $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n'; |
226 | 226 | ?> |
227 | - <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . ' ' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? ' ' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" /> |
|
228 | - <?php do_action( 'wpinv_prices_metabox_price', $item ); ?> |
|
227 | + <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . ' ' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? ' ' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" /> |
|
228 | + <?php do_action('wpinv_prices_metabox_price', $item); ?> |
|
229 | 229 | </p> |
230 | 230 | <p class="wpinv-row-is-recurring"> |
231 | 231 | <label for="wpinv_is_recurring"> |
232 | - <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> /> |
|
233 | - <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?> |
|
232 | + <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> /> |
|
233 | + <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?> |
|
234 | 234 | </label> |
235 | - <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?> |
|
235 | + <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?> |
|
236 | 236 | </p> |
237 | - <p class="wpinv-row-recurring-fields <?php echo $class;?>"> |
|
238 | - <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select wpi_select2" id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label> |
|
239 | - <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array( |
|
237 | + <p class="wpinv-row-recurring-fields <?php echo $class; ?>"> |
|
238 | + <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select wpi_select2" id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label> |
|
239 | + <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array( |
|
240 | 240 | 'options' => $intervals, |
241 | 241 | 'name' => 'wpinv_recurring_interval', |
242 | 242 | 'id' => 'wpinv_recurring_interval', |
@@ -244,30 +244,30 @@ discard block |
||
244 | 244 | 'show_option_all' => false, |
245 | 245 | 'show_option_none' => false, |
246 | 246 | 'class' => 'wpi_select2', |
247 | - ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label> |
|
248 | - <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label> |
|
247 | + )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label> |
|
248 | + <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label> |
|
249 | 249 | <span class="clear wpi-trial-clr"></span> |
250 | 250 | <label class="wpinv-free-trial" for="wpinv_free_trial"> |
251 | - <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> |
|
252 | - <?php echo __( 'Offer free trial for', 'invoicing' ); ?> |
|
251 | + <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> |
|
252 | + <?php echo __('Offer free trial for', 'invoicing'); ?> |
|
253 | 253 | </label> |
254 | 254 | <label class="wpinv-trial-interval" for="wpinv_trial_interval"> |
255 | - <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select wpi_select2" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select> |
|
255 | + <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select wpi_select2" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select> |
|
256 | 256 | </label> |
257 | - <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?> |
|
257 | + <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?> |
|
258 | 258 | </p> |
259 | - <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" /> |
|
260 | - <?php do_action( 'wpinv_item_price_field', $post->ID ); ?> |
|
259 | + <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" /> |
|
260 | + <?php do_action('wpinv_item_price_field', $post->ID); ?> |
|
261 | 261 | <?php |
262 | 262 | } |
263 | 263 | |
264 | - public static function vat_rules( $post ) { |
|
264 | + public static function vat_rules($post) { |
|
265 | 265 | global $wpinv_euvat; |
266 | 266 | |
267 | - $rule_type = $wpinv_euvat->get_item_rule( $post->ID ); |
|
267 | + $rule_type = $wpinv_euvat->get_item_rule($post->ID); |
|
268 | 268 | ?> |
269 | - <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label> |
|
270 | - <?php echo wpinv_html_select( array( |
|
269 | + <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label> |
|
270 | + <?php echo wpinv_html_select(array( |
|
271 | 271 | 'options' => $wpinv_euvat->get_rules(), |
272 | 272 | 'name' => 'wpinv_vat_rules', |
273 | 273 | 'id' => 'wpinv_vat_rules', |
@@ -275,19 +275,19 @@ discard block |
||
275 | 275 | 'show_option_all' => false, |
276 | 276 | 'show_option_none' => false, |
277 | 277 | 'class' => 'gdmbx2-text-medium wpinv-vat-rules wpi_select2', |
278 | - ) ); ?> |
|
278 | + )); ?> |
|
279 | 279 | </p> |
280 | - <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p> |
|
281 | - <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p> |
|
280 | + <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT. The VAT rate used will be the rate in your country.', 'invoicing'); ?></p> |
|
281 | + <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer. Only businesses in your country will be charged VAT.', 'invoicing'); ?></p> |
|
282 | 282 | <?php |
283 | 283 | } |
284 | 284 | |
285 | - public static function vat_classes( $post ) { |
|
285 | + public static function vat_classes($post) { |
|
286 | 286 | global $wpinv_euvat; |
287 | 287 | |
288 | - $vat_class = $wpinv_euvat->get_item_class( $post->ID ); |
|
288 | + $vat_class = $wpinv_euvat->get_item_class($post->ID); |
|
289 | 289 | ?> |
290 | - <p><?php echo wpinv_html_select( array( |
|
290 | + <p><?php echo wpinv_html_select(array( |
|
291 | 291 | 'options' => $wpinv_euvat->get_all_classes(), |
292 | 292 | 'name' => 'wpinv_vat_class', |
293 | 293 | 'id' => 'wpinv_vat_class', |
@@ -295,18 +295,18 @@ discard block |
||
295 | 295 | 'show_option_all' => false, |
296 | 296 | 'show_option_none' => false, |
297 | 297 | 'class' => 'gdmbx2-text-medium wpinv-vat-class wpi_select2', |
298 | - ) ); ?> |
|
298 | + )); ?> |
|
299 | 299 | </p> |
300 | - <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p> |
|
300 | + <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p> |
|
301 | 301 | <?php |
302 | 302 | } |
303 | 303 | |
304 | - public static function item_info( $post ) { |
|
305 | - $item_type = wpinv_get_item_type( $post->ID ); |
|
306 | - do_action( 'wpinv_item_info_metabox_before', $post ); |
|
304 | + public static function item_info($post) { |
|
305 | + $item_type = wpinv_get_item_type($post->ID); |
|
306 | + do_action('wpinv_item_info_metabox_before', $post); |
|
307 | 307 | ?> |
308 | - <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label> |
|
309 | - <?php echo wpinv_html_select( array( |
|
308 | + <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label> |
|
309 | + <?php echo wpinv_html_select(array( |
|
310 | 310 | 'options' => wpinv_get_item_types(), |
311 | 311 | 'name' => 'wpinv_item_type', |
312 | 312 | 'id' => 'wpinv_item_type', |
@@ -314,114 +314,114 @@ discard block |
||
314 | 314 | 'show_option_all' => false, |
315 | 315 | 'show_option_none' => false, |
316 | 316 | 'class' => 'gdmbx2-text-medium wpinv-item-type wpi_select2', |
317 | - ) ); ?> |
|
317 | + )); ?> |
|
318 | 318 | </p> |
319 | - <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p> |
|
319 | + <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p> |
|
320 | 320 | <?php |
321 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
321 | + do_action('wpinv_item_info_metabox_after', $post); |
|
322 | 322 | } |
323 | 323 | |
324 | - public static function meta_values( $post ) { |
|
325 | - $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array( |
|
324 | + public static function meta_values($post) { |
|
325 | + $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array( |
|
326 | 326 | 'type', |
327 | 327 | 'custom_id' |
328 | - ) ); |
|
328 | + )); |
|
329 | 329 | |
330 | - if ( empty( $meta_keys ) ) { |
|
330 | + if (empty($meta_keys)) { |
|
331 | 331 | return; |
332 | 332 | } |
333 | 333 | |
334 | - do_action( 'wpinv_meta_values_metabox_before', $post ); |
|
334 | + do_action('wpinv_meta_values_metabox_before', $post); |
|
335 | 335 | |
336 | - foreach ( $meta_keys as $meta_key ) { |
|
336 | + foreach ($meta_keys as $meta_key) { |
|
337 | 337 | ?> |
338 | - <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p> |
|
338 | + <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p> |
|
339 | 339 | <?php |
340 | 340 | } |
341 | 341 | |
342 | - do_action( 'wpinv_meta_values_metabox_after', $post ); |
|
342 | + do_action('wpinv_meta_values_metabox_after', $post); |
|
343 | 343 | } |
344 | 344 | |
345 | - public static function save( $post_id, $data, $post ) { |
|
346 | - $invoice = new WPInv_Invoice( $post_id ); |
|
345 | + public static function save($post_id, $data, $post) { |
|
346 | + $invoice = new WPInv_Invoice($post_id); |
|
347 | 347 | |
348 | 348 | // Billing |
349 | - $first_name = sanitize_text_field( $data['wpinv_first_name'] ); |
|
350 | - $last_name = sanitize_text_field( $data['wpinv_last_name'] ); |
|
351 | - $company = sanitize_text_field( $data['wpinv_company'] ); |
|
352 | - $vat_number = sanitize_text_field( $data['wpinv_vat_number'] ); |
|
353 | - $phone = sanitize_text_field( $data['wpinv_phone'] ); |
|
354 | - $address = sanitize_text_field( $data['wpinv_address'] ); |
|
355 | - $city = sanitize_text_field( $data['wpinv_city'] ); |
|
356 | - $zip = sanitize_text_field( $data['wpinv_zip'] ); |
|
357 | - $country = sanitize_text_field( $data['wpinv_country'] ); |
|
358 | - $state = sanitize_text_field( $data['wpinv_state'] ); |
|
349 | + $first_name = sanitize_text_field($data['wpinv_first_name']); |
|
350 | + $last_name = sanitize_text_field($data['wpinv_last_name']); |
|
351 | + $company = sanitize_text_field($data['wpinv_company']); |
|
352 | + $vat_number = sanitize_text_field($data['wpinv_vat_number']); |
|
353 | + $phone = sanitize_text_field($data['wpinv_phone']); |
|
354 | + $address = sanitize_text_field($data['wpinv_address']); |
|
355 | + $city = sanitize_text_field($data['wpinv_city']); |
|
356 | + $zip = sanitize_text_field($data['wpinv_zip']); |
|
357 | + $country = sanitize_text_field($data['wpinv_country']); |
|
358 | + $state = sanitize_text_field($data['wpinv_state']); |
|
359 | 359 | |
360 | 360 | // Details |
361 | - $status = sanitize_text_field( $data['wpinv_status'] ); |
|
362 | - $old_status = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status; |
|
363 | - $number = sanitize_text_field( $data['wpinv_number'] ); |
|
364 | - $due_date = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : ''; |
|
361 | + $status = sanitize_text_field($data['wpinv_status']); |
|
362 | + $old_status = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status; |
|
363 | + $number = sanitize_text_field($data['wpinv_number']); |
|
364 | + $due_date = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : ''; |
|
365 | 365 | //$discounts = sanitize_text_field( $data['wpinv_discounts'] ); |
366 | 366 | //$discount = sanitize_text_field( $data['wpinv_discount'] ); |
367 | 367 | |
368 | - $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
368 | + $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip(); |
|
369 | 369 | |
370 | - $invoice->set( 'due_date', $due_date ); |
|
371 | - $invoice->set( 'first_name', $first_name ); |
|
372 | - $invoice->set( 'last_name', $last_name ); |
|
373 | - $invoice->set( 'company', $company ); |
|
374 | - $invoice->set( 'vat_number', $vat_number ); |
|
375 | - $invoice->set( 'phone', $phone ); |
|
376 | - $invoice->set( 'address', $address ); |
|
377 | - $invoice->set( 'city', $city ); |
|
378 | - $invoice->set( 'zip', $zip ); |
|
379 | - $invoice->set( 'country', $country ); |
|
380 | - $invoice->set( 'state', $state ); |
|
381 | - $invoice->set( 'status', $status ); |
|
370 | + $invoice->set('due_date', $due_date); |
|
371 | + $invoice->set('first_name', $first_name); |
|
372 | + $invoice->set('last_name', $last_name); |
|
373 | + $invoice->set('company', $company); |
|
374 | + $invoice->set('vat_number', $vat_number); |
|
375 | + $invoice->set('phone', $phone); |
|
376 | + $invoice->set('address', $address); |
|
377 | + $invoice->set('city', $city); |
|
378 | + $invoice->set('zip', $zip); |
|
379 | + $invoice->set('country', $country); |
|
380 | + $invoice->set('state', $state); |
|
381 | + $invoice->set('status', $status); |
|
382 | 382 | //$invoice->set( 'number', $number ); |
383 | 383 | //$invoice->set( 'discounts', $discounts ); |
384 | 384 | //$invoice->set( 'discount', $discount ); |
385 | - $invoice->set( 'ip', $ip ); |
|
385 | + $invoice->set('ip', $ip); |
|
386 | 386 | $invoice->old_status = $_POST['original_post_status']; |
387 | 387 | $invoice->currency = wpinv_get_currency(); |
388 | - if ( !empty( $data['wpinv_gateway'] ) ) { |
|
389 | - $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) ); |
|
388 | + if (!empty($data['wpinv_gateway'])) { |
|
389 | + $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway'])); |
|
390 | 390 | } |
391 | 391 | $saved = $invoice->save(); |
392 | 392 | |
393 | 393 | // Check for payment notes |
394 | - if ( !empty( $data['invoice_note'] ) ) { |
|
395 | - $note = wp_kses( $data['invoice_note'], array() ); |
|
396 | - $note_type = sanitize_text_field( $data['invoice_note_type'] ); |
|
394 | + if (!empty($data['invoice_note'])) { |
|
395 | + $note = wp_kses($data['invoice_note'], array()); |
|
396 | + $note_type = sanitize_text_field($data['invoice_note_type']); |
|
397 | 397 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
398 | 398 | |
399 | - wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note ); |
|
399 | + wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | // Update user address if empty. |
403 | - if ( $saved && !empty( $invoice ) ) { |
|
404 | - if ( $user_id = $invoice->get_user_id() ) { |
|
405 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
403 | + if ($saved && !empty($invoice)) { |
|
404 | + if ($user_id = $invoice->get_user_id()) { |
|
405 | + $user_address = wpinv_get_user_address($user_id, false); |
|
406 | 406 | |
407 | 407 | if (empty($user_address['first_name'])) { |
408 | - update_user_meta( $user_id, '_wpinv_first_name', $first_name ); |
|
409 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
408 | + update_user_meta($user_id, '_wpinv_first_name', $first_name); |
|
409 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
410 | 410 | } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) { |
411 | - update_user_meta( $user_id, '_wpinv_last_name', $last_name ); |
|
411 | + update_user_meta($user_id, '_wpinv_last_name', $last_name); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) { |
415 | - update_user_meta( $user_id, '_wpinv_address', $address ); |
|
416 | - update_user_meta( $user_id, '_wpinv_city', $city ); |
|
417 | - update_user_meta( $user_id, '_wpinv_state', $state ); |
|
418 | - update_user_meta( $user_id, '_wpinv_country', $country ); |
|
419 | - update_user_meta( $user_id, '_wpinv_zip', $zip ); |
|
420 | - update_user_meta( $user_id, '_wpinv_phone', $phone ); |
|
415 | + update_user_meta($user_id, '_wpinv_address', $address); |
|
416 | + update_user_meta($user_id, '_wpinv_city', $city); |
|
417 | + update_user_meta($user_id, '_wpinv_state', $state); |
|
418 | + update_user_meta($user_id, '_wpinv_country', $country); |
|
419 | + update_user_meta($user_id, '_wpinv_zip', $zip); |
|
420 | + update_user_meta($user_id, '_wpinv_phone', $phone); |
|
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
424 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
424 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | return $saved; |
@@ -1,39 +1,39 @@ |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Notes { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $post; |
10 | 10 | |
11 | - $notes = wpinv_get_invoice_notes( $post->ID ); |
|
11 | + $notes = wpinv_get_invoice_notes($post->ID); |
|
12 | 12 | |
13 | 13 | echo '<ul class="invoice_notes">'; |
14 | 14 | |
15 | - if ( $notes ) { |
|
16 | - foreach( $notes as $note ) { |
|
17 | - wpinv_get_invoice_note_line_item( $note ); |
|
15 | + if ($notes) { |
|
16 | + foreach ($notes as $note) { |
|
17 | + wpinv_get_invoice_note_line_item($note); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | } else { |
21 | - echo '<li>' . __( 'There are no notes yet.', 'invoicing' ) . '</li>'; |
|
21 | + echo '<li>' . __('There are no notes yet.', 'invoicing') . '</li>'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | echo '</ul>'; |
25 | 25 | ?> |
26 | 26 | <div class="add_note"> |
27 | - <h4><?php _e( 'Add note', 'invoicing' ); ?></h4> |
|
27 | + <h4><?php _e('Add note', 'invoicing'); ?></h4> |
|
28 | 28 | <p> |
29 | 29 | <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea> |
30 | 30 | </p> |
31 | 31 | <p> |
32 | 32 | <select name="invoice_note_type" id="invoice_note_type" class="wpi_select2"> |
33 | - <option value=""><?php _e( 'Private note', 'invoicing' ); ?></option> |
|
34 | - <option value="customer"><?php _e( 'Note to customer', 'invoicing' ); ?></option> |
|
33 | + <option value=""><?php _e('Private note', 'invoicing'); ?></option> |
|
34 | + <option value="customer"><?php _e('Note to customer', 'invoicing'); ?></option> |
|
35 | 35 | </select> |
36 | - <a href="#" class="add_note button"><?php _e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php _e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span> |
|
36 | + <a href="#" class="add_note button"><?php _e('Add', 'invoicing'); ?></a> <span class="description"><?php _e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span> |
|
37 | 37 | </p> |
38 | 38 | </div> |
39 | 39 | <?php |
@@ -1,65 +1,65 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -function wpinv_add_meta_boxes( $post_type, $post ) { |
|
7 | +function wpinv_add_meta_boxes($post_type, $post) { |
|
8 | 8 | global $wpi_mb_invoice; |
9 | - if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) { |
|
10 | - $wpi_mb_invoice = wpinv_get_invoice( $post->ID ); |
|
9 | + if ($post_type == 'wpi_invoice' && !empty($post->ID)) { |
|
10 | + $wpi_mb_invoice = wpinv_get_invoice($post->ID); |
|
11 | 11 | } |
12 | 12 | |
13 | - if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) { |
|
14 | - add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' ); |
|
13 | + if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) { |
|
14 | + add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high'); |
|
15 | 15 | } |
16 | 16 | |
17 | - if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) { |
|
18 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' ); |
|
17 | + if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) { |
|
18 | + add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high'); |
|
19 | 19 | } |
20 | 20 | |
21 | - if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) { |
|
22 | - add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' ); |
|
21 | + if (wpinv_is_subscription_payment($wpi_mb_invoice)) { |
|
22 | + add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high'); |
|
23 | 23 | } |
24 | 24 | |
25 | - add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' ); |
|
26 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' ); |
|
25 | + add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default'); |
|
26 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default'); |
|
27 | 27 | |
28 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' ); |
|
29 | - add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' ); |
|
30 | - add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
|
28 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high'); |
|
29 | + add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high'); |
|
30 | + add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high'); |
|
31 | 31 | } |
32 | -add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 ); |
|
32 | +add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2); |
|
33 | 33 | |
34 | -function wpinv_save_meta_boxes( $post_id, $post, $update = false ) { |
|
35 | - remove_action( 'save_post', __FUNCTION__ ); |
|
34 | +function wpinv_save_meta_boxes($post_id, $post, $update = false) { |
|
35 | + remove_action('save_post', __FUNCTION__); |
|
36 | 36 | |
37 | 37 | // $post_id and $post are required |
38 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
38 | + if (empty($post_id) || empty($post)) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | |
42 | - if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) { |
|
42 | + if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) { |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Dont' save meta boxes for revisions or autosaves |
47 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
47 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
51 | - if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) { |
|
52 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
51 | + if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') { |
|
52 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | - if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) { |
|
57 | - WPInv_Meta_Box_Items::save( $post_id, $_POST, $post ); |
|
56 | + if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) { |
|
57 | + WPInv_Meta_Box_Items::save($post_id, $_POST, $post); |
|
58 | 58 | } |
59 | - } else if ( $post->post_type == 'wpi_item' ) { |
|
59 | + } else if ($post->post_type == 'wpi_item') { |
|
60 | 60 | // verify nonce |
61 | - if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) { |
|
62 | - $fields = array(); |
|
61 | + if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) { |
|
62 | + $fields = array(); |
|
63 | 63 | $fields['_wpinv_price'] = 'wpinv_item_price'; |
64 | 64 | $fields['_wpinv_vat_class'] = 'wpinv_vat_class'; |
65 | 65 | $fields['_wpinv_vat_rule'] = 'wpinv_vat_rules'; |
@@ -72,92 +72,92 @@ discard block |
||
72 | 72 | $fields['_wpinv_trial_period'] = 'wpinv_trial_period'; |
73 | 73 | $fields['_wpinv_trial_interval'] = 'wpinv_trial_interval'; |
74 | 74 | |
75 | - if ( !isset( $_POST['wpinv_is_recurring'] ) ) { |
|
75 | + if (!isset($_POST['wpinv_is_recurring'])) { |
|
76 | 76 | $_POST['wpinv_is_recurring'] = 0; |
77 | 77 | } |
78 | 78 | |
79 | - if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) { |
|
79 | + if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) { |
|
80 | 80 | $_POST['wpinv_free_trial'] = 0; |
81 | 81 | } |
82 | 82 | |
83 | - foreach ( $fields as $field => $name ) { |
|
84 | - if ( isset( $_POST[ $name ] ) ) { |
|
85 | - $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id ); |
|
83 | + foreach ($fields as $field => $name) { |
|
84 | + if (isset($_POST[$name])) { |
|
85 | + $allowed = apply_filters('wpinv_item_allowed_save_meta_value', true, $field, $post_id); |
|
86 | 86 | |
87 | - if ( !$allowed ) { |
|
87 | + if (!$allowed) { |
|
88 | 88 | continue; |
89 | 89 | } |
90 | 90 | |
91 | - if ( $field == '_wpinv_price' ) { |
|
92 | - $value = wpinv_sanitize_amount( $_POST[ $name ] ); |
|
91 | + if ($field == '_wpinv_price') { |
|
92 | + $value = wpinv_sanitize_amount($_POST[$name]); |
|
93 | 93 | } else { |
94 | - $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ]; |
|
94 | + $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name]; |
|
95 | 95 | } |
96 | 96 | |
97 | - $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name ); |
|
98 | - update_post_meta( $post_id, $field, $value ); |
|
97 | + $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name); |
|
98 | + update_post_meta($post_id, $field, $value); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) { |
|
103 | - update_post_meta( $post_id, '_wpinv_custom_id', $post_id ); |
|
102 | + if (!get_post_meta($post_id, '_wpinv_custom_id', true)) { |
|
103 | + update_post_meta($post_id, '_wpinv_custom_id', $post_id); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
108 | -add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 ); |
|
108 | +add_action('save_post', 'wpinv_save_meta_boxes', 10, 3); |
|
109 | 109 | |
110 | 110 | function wpinv_register_item_meta_boxes() { |
111 | 111 | global $wpinv_euvat; |
112 | 112 | |
113 | - add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' ); |
|
113 | + add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high'); |
|
114 | 114 | |
115 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
116 | - add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' ); |
|
115 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
116 | + add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high'); |
|
117 | 117 | } |
118 | 118 | |
119 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
120 | - add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' ); |
|
119 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
120 | + add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high'); |
|
121 | 121 | } |
122 | 122 | |
123 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' ); |
|
124 | - add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' ); |
|
123 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core'); |
|
124 | + add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core'); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | function wpinv_register_discount_meta_boxes() { |
128 | - add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' ); |
|
128 | + add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high'); |
|
129 | 129 | } |
130 | 130 | |
131 | -function wpinv_discount_metabox_details( $post ) { |
|
131 | +function wpinv_discount_metabox_details($post) { |
|
132 | 132 | $discount_id = $post->ID; |
133 | - $discount = wpinv_get_discount( $discount_id ); |
|
133 | + $discount = wpinv_get_discount($discount_id); |
|
134 | 134 | |
135 | - $type = wpinv_get_discount_type( $discount_id ); |
|
136 | - $item_reqs = wpinv_get_discount_item_reqs( $discount_id ); |
|
137 | - $excluded_items = wpinv_get_discount_excluded_items( $discount_id ); |
|
138 | - $min_total = wpinv_get_discount_min_total( $discount_id ); |
|
139 | - $max_total = wpinv_get_discount_max_total( $discount_id ); |
|
140 | - $max_uses = wpinv_get_discount_max_uses( $discount_id ); |
|
141 | - $single_use = wpinv_discount_is_single_use( $discount_id ); |
|
142 | - $recurring = (bool)wpinv_discount_is_recurring( $discount_id ); |
|
143 | - $start_date = wpinv_get_discount_start_date( $discount_id ); |
|
144 | - $expiration_date = wpinv_get_discount_expiration( $discount_id ); |
|
135 | + $type = wpinv_get_discount_type($discount_id); |
|
136 | + $item_reqs = wpinv_get_discount_item_reqs($discount_id); |
|
137 | + $excluded_items = wpinv_get_discount_excluded_items($discount_id); |
|
138 | + $min_total = wpinv_get_discount_min_total($discount_id); |
|
139 | + $max_total = wpinv_get_discount_max_total($discount_id); |
|
140 | + $max_uses = wpinv_get_discount_max_uses($discount_id); |
|
141 | + $single_use = wpinv_discount_is_single_use($discount_id); |
|
142 | + $recurring = (bool)wpinv_discount_is_recurring($discount_id); |
|
143 | + $start_date = wpinv_get_discount_start_date($discount_id); |
|
144 | + $expiration_date = wpinv_get_discount_expiration($discount_id); |
|
145 | 145 | |
146 | - if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) { |
|
147 | - $start_time = strtotime( $start_date ); |
|
148 | - $start_h = date_i18n( 'H', $start_time ); |
|
149 | - $start_m = date_i18n( 'i', $start_time ); |
|
150 | - $start_date = date_i18n( 'Y-m-d', $start_time ); |
|
146 | + if (!empty($start_date) && strpos($start_date, '0000') === false) { |
|
147 | + $start_time = strtotime($start_date); |
|
148 | + $start_h = date_i18n('H', $start_time); |
|
149 | + $start_m = date_i18n('i', $start_time); |
|
150 | + $start_date = date_i18n('Y-m-d', $start_time); |
|
151 | 151 | } else { |
152 | 152 | $start_h = '00'; |
153 | 153 | $start_m = '00'; |
154 | 154 | } |
155 | 155 | |
156 | - if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) { |
|
157 | - $expiration_time = strtotime( $expiration_date ); |
|
158 | - $expiration_h = date_i18n( 'H', $expiration_time ); |
|
159 | - $expiration_m = date_i18n( 'i', $expiration_time ); |
|
160 | - $expiration_date = date_i18n( 'Y-m-d', $expiration_time ); |
|
156 | + if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) { |
|
157 | + $expiration_time = strtotime($expiration_date); |
|
158 | + $expiration_h = date_i18n('H', $expiration_time); |
|
159 | + $expiration_m = date_i18n('i', $expiration_time); |
|
160 | + $expiration_date = date_i18n('Y-m-d', $expiration_time); |
|
161 | 161 | } else { |
162 | 162 | $expiration_h = '23'; |
163 | 163 | $expiration_m = '59'; |
@@ -167,207 +167,207 @@ discard block |
||
167 | 167 | $max_total = $max_total > 0 ? $max_total : ''; |
168 | 168 | $max_uses = $max_uses > 0 ? $max_uses : ''; |
169 | 169 | ?> |
170 | -<?php do_action( 'wpinv_discount_form_top', $post ); ?> |
|
171 | -<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?> |
|
170 | +<?php do_action('wpinv_discount_form_top', $post); ?> |
|
171 | +<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?> |
|
172 | 172 | <table class="form-table wpi-form-table"> |
173 | 173 | <tbody> |
174 | - <?php do_action( 'wpinv_discount_form_first', $post ); ?> |
|
175 | - <?php do_action( 'wpinv_discount_form_before_code', $post ); ?> |
|
174 | + <?php do_action('wpinv_discount_form_first', $post); ?> |
|
175 | + <?php do_action('wpinv_discount_form_before_code', $post); ?> |
|
176 | 176 | <tr> |
177 | 177 | <th valign="top" scope="row"> |
178 | - <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label> |
|
178 | + <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label> |
|
179 | 179 | </th> |
180 | 180 | <td> |
181 | - <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required> |
|
182 | - <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p> |
|
181 | + <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required> |
|
182 | + <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p> |
|
183 | 183 | </td> |
184 | 184 | </tr> |
185 | - <?php do_action( 'wpinv_discount_form_before_type', $post ); ?> |
|
185 | + <?php do_action('wpinv_discount_form_before_type', $post); ?> |
|
186 | 186 | <tr> |
187 | 187 | <th valign="top" scope="row"> |
188 | - <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label> |
|
188 | + <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label> |
|
189 | 189 | </th> |
190 | 190 | <td> |
191 | 191 | <select id="wpinv_discount_type" name="type" class="medium-text wpi_select2"> |
192 | - <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?> |
|
193 | - <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option> |
|
192 | + <?php foreach (wpinv_get_discount_types() as $value => $label) { ?> |
|
193 | + <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option> |
|
194 | 194 | <?php } ?> |
195 | 195 | </select> |
196 | - <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p> |
|
196 | + <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p> |
|
197 | 197 | </td> |
198 | 198 | </tr> |
199 | - <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?> |
|
199 | + <?php do_action('wpinv_discount_form_before_amount', $post); ?> |
|
200 | 200 | <tr> |
201 | 201 | <th valign="top" scope="row"> |
202 | - <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label> |
|
202 | + <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label> |
|
203 | 203 | </th> |
204 | 204 | <td> |
205 | - <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font> |
|
206 | - <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p> |
|
207 | - <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p> |
|
205 | + <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font> |
|
206 | + <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p> |
|
207 | + <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p> |
|
208 | 208 | </td> |
209 | 209 | </tr> |
210 | - <?php do_action( 'wpinv_discount_form_before_items', $post ); ?> |
|
210 | + <?php do_action('wpinv_discount_form_before_items', $post); ?> |
|
211 | 211 | <tr> |
212 | 212 | <th valign="top" scope="row"> |
213 | - <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label> |
|
213 | + <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label> |
|
214 | 214 | </th> |
215 | 215 | <td> |
216 | - <p><?php echo wpinv_item_dropdown( array( |
|
216 | + <p><?php echo wpinv_item_dropdown(array( |
|
217 | 217 | 'name' => 'items[]', |
218 | 218 | 'id' => 'items', |
219 | 219 | 'selected' => $item_reqs, |
220 | 220 | 'multiple' => true, |
221 | 221 | 'class' => 'medium-text wpi_select2', |
222 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
222 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
223 | 223 | 'show_recurring' => true, |
224 | - ) ); ?> |
|
224 | + )); ?> |
|
225 | 225 | </p> |
226 | - <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p> |
|
226 | + <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p> |
|
227 | 227 | </td> |
228 | 228 | </tr> |
229 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?> |
|
229 | + <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?> |
|
230 | 230 | <tr> |
231 | 231 | <th valign="top" scope="row"> |
232 | - <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label> |
|
232 | + <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label> |
|
233 | 233 | </th> |
234 | 234 | <td> |
235 | - <p><?php echo wpinv_item_dropdown( array( |
|
235 | + <p><?php echo wpinv_item_dropdown(array( |
|
236 | 236 | 'name' => 'excluded_items[]', |
237 | 237 | 'id' => 'excluded_items', |
238 | 238 | 'selected' => $excluded_items, |
239 | 239 | 'multiple' => true, |
240 | 240 | 'class' => 'medium-text wpi_select2', |
241 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
241 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
242 | 242 | 'show_recurring' => true, |
243 | - ) ); ?> |
|
243 | + )); ?> |
|
244 | 244 | </p> |
245 | - <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p> |
|
245 | + <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p> |
|
246 | 246 | </td> |
247 | 247 | </tr> |
248 | - <?php do_action( 'wpinv_discount_form_before_start', $post ); ?> |
|
248 | + <?php do_action('wpinv_discount_form_before_start', $post); ?> |
|
249 | 249 | <tr> |
250 | 250 | <th valign="top" scope="row"> |
251 | - <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label> |
|
251 | + <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label> |
|
252 | 252 | </th> |
253 | 253 | <td> |
254 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
255 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
256 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option> |
|
254 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h"> |
|
255 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
256 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option> |
|
257 | 257 | <?php } ?> |
258 | 258 | </select> : <select id="wpinv_discount_start_m" name="start_m"> |
259 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
260 | - <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option> |
|
259 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
260 | + <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option> |
|
261 | 261 | <?php } ?> |
262 | 262 | </select> |
263 | - <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p> |
|
263 | + <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p> |
|
264 | 264 | </td> |
265 | 265 | </tr> |
266 | - <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?> |
|
266 | + <?php do_action('wpinv_discount_form_before_expiration', $post); ?> |
|
267 | 267 | <tr> |
268 | 268 | <th valign="top" scope="row"> |
269 | - <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label> |
|
269 | + <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label> |
|
270 | 270 | </th> |
271 | 271 | <td> |
272 | - <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
273 | - <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
274 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option> |
|
272 | + <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h"> |
|
273 | + <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
274 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option> |
|
275 | 275 | <?php } ?> |
276 | 276 | </select> : <select id="wpinv_discount_expiration_m" name="expiration_m"> |
277 | - <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
278 | - <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option> |
|
277 | + <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
278 | + <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option> |
|
279 | 279 | <?php } ?> |
280 | 280 | </select> |
281 | - <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p> |
|
281 | + <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p> |
|
282 | 282 | </td> |
283 | 283 | </tr> |
284 | - <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?> |
|
284 | + <?php do_action('wpinv_discount_form_before_min_total', $post); ?> |
|
285 | 285 | <tr> |
286 | 286 | <th valign="top" scope="row"> |
287 | - <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label> |
|
287 | + <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label> |
|
288 | 288 | </th> |
289 | 289 | <td> |
290 | 290 | <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>"> |
291 | - <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
291 | + <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
292 | 292 | </td> |
293 | 293 | </tr> |
294 | - <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?> |
|
294 | + <?php do_action('wpinv_discount_form_before_max_total', $post); ?> |
|
295 | 295 | <tr> |
296 | 296 | <th valign="top" scope="row"> |
297 | - <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label> |
|
297 | + <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label> |
|
298 | 298 | </th> |
299 | 299 | <td> |
300 | 300 | <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>"> |
301 | - <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
301 | + <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
302 | 302 | </td> |
303 | 303 | </tr> |
304 | - <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?> |
|
304 | + <?php do_action('wpinv_discount_form_before_recurring', $post); ?> |
|
305 | 305 | <tr> |
306 | 306 | <th valign="top" scope="row"> |
307 | - <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label> |
|
307 | + <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label> |
|
308 | 308 | </th> |
309 | 309 | <td> |
310 | 310 | <select id="wpinv_discount_recurring" name="recurring" class="medium-text wpi_select2"> |
311 | - <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option> |
|
312 | - <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option> |
|
311 | + <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option> |
|
312 | + <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option> |
|
313 | 313 | </select> |
314 | - <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p> |
|
314 | + <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p> |
|
315 | 315 | </td> |
316 | 316 | </tr> |
317 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?> |
|
317 | + <?php do_action('wpinv_discount_form_before_max_uses', $post); ?> |
|
318 | 318 | <tr> |
319 | 319 | <th valign="top" scope="row"> |
320 | - <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label> |
|
320 | + <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label> |
|
321 | 321 | </th> |
322 | 322 | <td> |
323 | 323 | <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>"> |
324 | - <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p> |
|
324 | + <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p> |
|
325 | 325 | </td> |
326 | 326 | </tr> |
327 | - <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?> |
|
327 | + <?php do_action('wpinv_discount_form_before_single_use', $post); ?> |
|
328 | 328 | <tr> |
329 | 329 | <th valign="top" scope="row"> |
330 | - <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label> |
|
330 | + <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label> |
|
331 | 331 | </th> |
332 | 332 | <td> |
333 | - <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>> |
|
334 | - <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span> |
|
333 | + <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>> |
|
334 | + <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span> |
|
335 | 335 | </td> |
336 | 336 | </tr> |
337 | - <?php do_action( 'wpinv_discount_form_last', $post ); ?> |
|
337 | + <?php do_action('wpinv_discount_form_last', $post); ?> |
|
338 | 338 | </tbody> |
339 | 339 | </table> |
340 | -<?php do_action( 'wpinv_discount_form_bottom', $post ); ?> |
|
340 | +<?php do_action('wpinv_discount_form_bottom', $post); ?> |
|
341 | 341 | <?php |
342 | 342 | } |
343 | 343 | |
344 | -function wpinv_discount_metabox_save( $post_id, $post, $update = false ) { |
|
345 | - $post_type = !empty( $post ) ? $post->post_type : ''; |
|
344 | +function wpinv_discount_metabox_save($post_id, $post, $update = false) { |
|
345 | + $post_type = !empty($post) ? $post->post_type : ''; |
|
346 | 346 | |
347 | - if ( $post_type != 'wpi_discount' ) { |
|
347 | + if ($post_type != 'wpi_discount') { |
|
348 | 348 | return; |
349 | 349 | } |
350 | 350 | |
351 | - if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) { |
|
351 | + if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) { |
|
352 | 352 | return; |
353 | 353 | } |
354 | 354 | |
355 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
355 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
356 | 356 | return; |
357 | 357 | } |
358 | 358 | |
359 | - if ( !current_user_can( 'manage_options', $post_id ) ) { |
|
359 | + if (!current_user_can('manage_options', $post_id)) { |
|
360 | 360 | return; |
361 | 361 | } |
362 | 362 | |
363 | - if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) { |
|
363 | + if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') { |
|
364 | 364 | $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m']; |
365 | 365 | } |
366 | 366 | |
367 | - if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) { |
|
367 | + if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) { |
|
368 | 368 | $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m']; |
369 | 369 | } |
370 | 370 | |
371 | - return wpinv_store_discount( $post_id, $_POST, $post, $update ); |
|
371 | + return wpinv_store_discount($post_id, $_POST, $post, $update); |
|
372 | 372 | } |
373 | -add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 ); |
|
374 | 373 | \ No newline at end of file |
374 | +add_action('save_post', 'wpinv_discount_metabox_save', 10, 3); |
|
375 | 375 | \ No newline at end of file |