@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | // Load WP_List_Table if not loaded |
11 | 11 | if ( ! class_exists( 'WP_List_Table' ) ) { |
12 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
12 | + require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | /** |
@@ -21,367 +21,367 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class WPInv_Customers_Table extends WP_List_Table { |
23 | 23 | |
24 | - /** |
|
25 | - * @var int Number of items per page |
|
26 | - * @since 1.0.19 |
|
27 | - */ |
|
28 | - public $per_page = 10; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var int Number of items |
|
32 | - * @since 1.0.19 |
|
33 | - */ |
|
34 | - public $total = 0; |
|
35 | - |
|
36 | - /** |
|
37 | - * Get things started |
|
38 | - * |
|
39 | - * @since 1.0.19 |
|
40 | - * @see WP_List_Table::__construct() |
|
41 | - */ |
|
42 | - public function __construct() { |
|
43 | - |
|
44 | - // Set parent defaults |
|
45 | - parent::__construct( array( |
|
46 | - 'singular' => 'id', |
|
47 | - 'plural' => 'ids', |
|
48 | - 'ajax' => false, |
|
49 | - ) ); |
|
50 | - |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Gets the name of the primary column. |
|
55 | - * |
|
56 | - * @since 1.0.19 |
|
57 | - * @access protected |
|
58 | - * |
|
59 | - * @return string Name of the primary column. |
|
60 | - */ |
|
61 | - protected function get_primary_column_name() { |
|
62 | - return 'name'; |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * This function renders most of the columns in the list table. |
|
67 | - * |
|
68 | - * @since 1.0.19 |
|
69 | - * |
|
70 | - * @param WP_User $item |
|
71 | - * @param string $column_name The name of the column |
|
72 | - * |
|
73 | - * @return string Column Name |
|
74 | - */ |
|
75 | - public function column_default( $item, $column_name ) { |
|
76 | - $value = esc_html( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) ); |
|
77 | - return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item ); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Displays the country column. |
|
82 | - * |
|
83 | - * @since 1.0.19 |
|
84 | - * |
|
85 | - * @param WP_User $user |
|
86 | - * |
|
87 | - * @return string Column Name |
|
88 | - */ |
|
89 | - public function column_country( $user ) { |
|
90 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
91 | - if ( $country ) { |
|
92 | - $country = wpinv_country_name( $country ); |
|
93 | - } |
|
94 | - return esc_html( $country ); |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Displays the state column. |
|
99 | - * |
|
100 | - * @since 1.0.19 |
|
101 | - * |
|
102 | - * @param WP_User $user |
|
103 | - * |
|
104 | - * @return string Column Name |
|
105 | - */ |
|
106 | - public function column_state( $user ) { |
|
107 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
108 | - $state = $user->_wpinv_state; |
|
109 | - if ( $state ) { |
|
110 | - $state = wpinv_state_name( $state, $country ); |
|
111 | - } |
|
112 | - |
|
113 | - return esc_html( $state ); |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Displays the signup column. |
|
118 | - * |
|
119 | - * @since 1.0.19 |
|
120 | - * |
|
121 | - * @param WP_User $user |
|
122 | - * |
|
123 | - * @return string Column Name |
|
124 | - */ |
|
125 | - public function column_signup( $user ) { |
|
126 | - return getpaid_format_date_value( $user->user_registered ); |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * Displays the total spent column. |
|
131 | - * |
|
132 | - * @since 1.0.19 |
|
133 | - * |
|
134 | - * @param WP_User $user |
|
135 | - * |
|
136 | - * @return string Column Name |
|
137 | - */ |
|
138 | - public function column_total( $user ) { |
|
139 | - return wpinv_price( $this->column_total_raw( $user ) ); |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Displays the total spent column. |
|
144 | - * |
|
145 | - * @since 1.0.19 |
|
146 | - * |
|
147 | - * @param WP_User $user |
|
148 | - * |
|
149 | - * @return float |
|
150 | - */ |
|
151 | - public function column_total_raw( $user ) { |
|
152 | - |
|
153 | - $args = array( |
|
154 | - 'data' => array( |
|
155 | - |
|
156 | - 'total' => array( |
|
157 | - 'type' => 'invoice_data', |
|
158 | - 'function' => 'SUM', |
|
159 | - 'name' => 'total_sales', |
|
160 | - ) |
|
161 | - |
|
162 | - ), |
|
163 | - 'where' => array( |
|
164 | - |
|
165 | - 'author' => array( |
|
166 | - 'type' => 'post_data', |
|
167 | - 'value' => absint( $user->ID ), |
|
168 | - 'key' => 'posts.post_author', |
|
169 | - 'operator' => '=', |
|
170 | - ), |
|
171 | - |
|
172 | - ), |
|
173 | - 'query_type' => 'get_var', |
|
174 | - 'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ), |
|
175 | - ); |
|
176 | - |
|
177 | - return wpinv_round_amount( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
178 | - |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * Displays the total spent column. |
|
183 | - * |
|
184 | - * @since 1.0.19 |
|
185 | - * |
|
186 | - * @param WP_User $user |
|
187 | - * |
|
188 | - * @return string Column Name |
|
189 | - */ |
|
190 | - public function column_invoices( $user ) { |
|
191 | - |
|
192 | - $args = array( |
|
193 | - 'data' => array( |
|
194 | - |
|
195 | - 'ID' => array( |
|
196 | - 'type' => 'post_data', |
|
197 | - 'function' => 'COUNT', |
|
198 | - 'name' => 'count', |
|
199 | - 'distinct' => true, |
|
200 | - ), |
|
201 | - |
|
202 | - ), |
|
203 | - 'where' => array( |
|
204 | - |
|
205 | - 'author' => array( |
|
206 | - 'type' => 'post_data', |
|
207 | - 'value' => absint( $user->ID ), |
|
208 | - 'key' => 'posts.post_author', |
|
209 | - 'operator' => '=', |
|
210 | - ), |
|
211 | - |
|
212 | - ), |
|
213 | - 'query_type' => 'get_var', |
|
214 | - 'invoice_status' => array_keys( wpinv_get_invoice_statuses() ), |
|
215 | - ); |
|
216 | - |
|
217 | - return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
218 | - |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * Generates content for a single row of the table |
|
223 | - * @since 1.0.19 |
|
224 | - * |
|
225 | - * @param int $item The user id. |
|
226 | - */ |
|
227 | - public function single_row( $item ) { |
|
228 | - $item = get_user_by( 'id', $item ); |
|
229 | - |
|
230 | - if ( empty( $item ) ) { |
|
231 | - return; |
|
232 | - } |
|
233 | - |
|
234 | - echo '<tr>'; |
|
235 | - $this->single_row_columns( $item ); |
|
236 | - echo '</tr>'; |
|
237 | - } |
|
238 | - |
|
239 | - /** |
|
240 | - * Displays the customers name |
|
241 | - * |
|
242 | - * @param WP_User $customer customer. |
|
243 | - * @return string |
|
244 | - */ |
|
245 | - public function column_name( $customer ) { |
|
246 | - |
|
247 | - // Customer view URL. |
|
248 | - $view_url = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) ); |
|
249 | - $row_actions = $this->row_actions( |
|
250 | - array( |
|
251 | - 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
252 | - ) |
|
253 | - ); |
|
254 | - |
|
255 | - // Get user's address. |
|
256 | - $address = wpinv_get_user_address( $customer->ID ); |
|
257 | - |
|
258 | - // Customer email address. |
|
259 | - $email = sanitize_email( $customer->user_email ); |
|
260 | - |
|
261 | - // Customer's avatar. |
|
262 | - $avatar = esc_url( get_avatar_url( $email ) ); |
|
263 | - $avatar = "<img src='$avatar' height='32' width='32'/>"; |
|
264 | - |
|
265 | - // Customer's name. |
|
266 | - $name = esc_html( "{$address['first_name']} {$address['last_name']}" ); |
|
267 | - |
|
268 | - if ( ! empty( $name ) ) { |
|
269 | - $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
|
270 | - } |
|
271 | - |
|
272 | - $email = "<div class='row-title'><a href='$view_url'>$email</a></div>"; |
|
273 | - |
|
274 | - return "<div style='display: flex;'><div>$avatar</div><div style='margin-left: 10px;'>$name<strong>$email</strong>$row_actions</div></div>"; |
|
275 | - |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * Retrieve the table columns |
|
280 | - * |
|
281 | - * @since 1.0.19 |
|
282 | - * @return array $columns Array of all the list table columns |
|
283 | - */ |
|
284 | - public function get_columns() { |
|
285 | - |
|
286 | - $columns = array( |
|
287 | - 'name' => __( 'Name', 'invoicing' ), |
|
288 | - 'country' => __( 'Country', 'invoicing' ), |
|
289 | - 'state' => __( 'State', 'invoicing' ), |
|
290 | - 'city' => __( 'City', 'invoicing' ), |
|
291 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
292 | - 'address' => __( 'Address', 'invoicing' ), |
|
293 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
294 | - 'company' => __( 'Company', 'invoicing' ), |
|
295 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
296 | - 'total' => __( 'Total Spend', 'invoicing' ), |
|
297 | - 'signup' => __( 'Date created', 'invoicing' ), |
|
298 | - ); |
|
299 | - return apply_filters( 'wpinv_customers_table_columns', $columns ); |
|
300 | - |
|
301 | - } |
|
302 | - |
|
303 | - /** |
|
304 | - * Retrieve the current page number |
|
305 | - * |
|
306 | - * @since 1.0.19 |
|
307 | - * @return int Current page number |
|
308 | - */ |
|
309 | - public function get_paged() { |
|
310 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
311 | - } |
|
312 | - |
|
313 | - /** |
|
314 | - * Returns bulk actions. |
|
315 | - * |
|
316 | - * @since 1.0.19 |
|
317 | - * @return void |
|
318 | - */ |
|
319 | - public function bulk_actions( $which = '' ) { |
|
320 | - return array(); |
|
321 | - } |
|
322 | - |
|
323 | - /** |
|
324 | - * Prepares the display query |
|
325 | - */ |
|
326 | - public function prepare_query() { |
|
327 | - global $wpdb; |
|
328 | - |
|
329 | - $post_types = ''; |
|
330 | - |
|
331 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
332 | - $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
333 | - } |
|
334 | - |
|
335 | - $post_types = rtrim( $post_types, ' OR' ); |
|
336 | - |
|
337 | - // Maybe search. |
|
338 | - if ( ! empty( $_POST['s'] ) ) { |
|
339 | - $users = get_users( |
|
340 | - array( |
|
341 | - 'search' => '*' . sanitize_text_field( urldecode( $_POST['s'] ) ) . '*', |
|
342 | - 'search_columns' => array( 'user_login', 'user_email', 'display_name' ), |
|
343 | - 'fields' => 'ID', |
|
344 | - ) |
|
345 | - ); |
|
346 | - |
|
347 | - $users = implode( ', ', $users ); |
|
348 | - $post_types = "($post_types) AND ( post_author IN ( $users ) )"; |
|
349 | - } |
|
350 | - |
|
351 | - // Users with invoices. |
|
352 | - $customers = $wpdb->get_col( |
|
353 | - $wpdb->prepare( |
|
354 | - "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types LIMIT %d,%d", |
|
355 | - $this->get_paged() * 10 - 10, |
|
356 | - $this->per_page |
|
357 | - ) |
|
358 | - ); |
|
359 | - |
|
360 | - $this->items = $customers; |
|
361 | - $this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" ); |
|
362 | - |
|
363 | - } |
|
364 | - |
|
365 | - /** |
|
366 | - * Setup the final data for the table |
|
367 | - * |
|
368 | - * @since 1.0.19 |
|
369 | - * @return void |
|
370 | - */ |
|
371 | - public function prepare_items() { |
|
372 | - $columns = $this->get_columns(); |
|
373 | - $hidden = array(); // No hidden columns |
|
374 | - $sortable = $this->get_sortable_columns(); |
|
375 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
376 | - $this->prepare_query(); |
|
377 | - |
|
378 | - $this->set_pagination_args( |
|
379 | - array( |
|
380 | - 'total_items' => $this->total, |
|
381 | - 'per_page' => $this->per_page, |
|
382 | - 'total_pages' => ceil( $this->total / $this->per_page ) |
|
383 | - ) |
|
384 | - ); |
|
385 | - |
|
386 | - } |
|
24 | + /** |
|
25 | + * @var int Number of items per page |
|
26 | + * @since 1.0.19 |
|
27 | + */ |
|
28 | + public $per_page = 10; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var int Number of items |
|
32 | + * @since 1.0.19 |
|
33 | + */ |
|
34 | + public $total = 0; |
|
35 | + |
|
36 | + /** |
|
37 | + * Get things started |
|
38 | + * |
|
39 | + * @since 1.0.19 |
|
40 | + * @see WP_List_Table::__construct() |
|
41 | + */ |
|
42 | + public function __construct() { |
|
43 | + |
|
44 | + // Set parent defaults |
|
45 | + parent::__construct( array( |
|
46 | + 'singular' => 'id', |
|
47 | + 'plural' => 'ids', |
|
48 | + 'ajax' => false, |
|
49 | + ) ); |
|
50 | + |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Gets the name of the primary column. |
|
55 | + * |
|
56 | + * @since 1.0.19 |
|
57 | + * @access protected |
|
58 | + * |
|
59 | + * @return string Name of the primary column. |
|
60 | + */ |
|
61 | + protected function get_primary_column_name() { |
|
62 | + return 'name'; |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * This function renders most of the columns in the list table. |
|
67 | + * |
|
68 | + * @since 1.0.19 |
|
69 | + * |
|
70 | + * @param WP_User $item |
|
71 | + * @param string $column_name The name of the column |
|
72 | + * |
|
73 | + * @return string Column Name |
|
74 | + */ |
|
75 | + public function column_default( $item, $column_name ) { |
|
76 | + $value = esc_html( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) ); |
|
77 | + return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item ); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Displays the country column. |
|
82 | + * |
|
83 | + * @since 1.0.19 |
|
84 | + * |
|
85 | + * @param WP_User $user |
|
86 | + * |
|
87 | + * @return string Column Name |
|
88 | + */ |
|
89 | + public function column_country( $user ) { |
|
90 | + $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
91 | + if ( $country ) { |
|
92 | + $country = wpinv_country_name( $country ); |
|
93 | + } |
|
94 | + return esc_html( $country ); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Displays the state column. |
|
99 | + * |
|
100 | + * @since 1.0.19 |
|
101 | + * |
|
102 | + * @param WP_User $user |
|
103 | + * |
|
104 | + * @return string Column Name |
|
105 | + */ |
|
106 | + public function column_state( $user ) { |
|
107 | + $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
108 | + $state = $user->_wpinv_state; |
|
109 | + if ( $state ) { |
|
110 | + $state = wpinv_state_name( $state, $country ); |
|
111 | + } |
|
112 | + |
|
113 | + return esc_html( $state ); |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Displays the signup column. |
|
118 | + * |
|
119 | + * @since 1.0.19 |
|
120 | + * |
|
121 | + * @param WP_User $user |
|
122 | + * |
|
123 | + * @return string Column Name |
|
124 | + */ |
|
125 | + public function column_signup( $user ) { |
|
126 | + return getpaid_format_date_value( $user->user_registered ); |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * Displays the total spent column. |
|
131 | + * |
|
132 | + * @since 1.0.19 |
|
133 | + * |
|
134 | + * @param WP_User $user |
|
135 | + * |
|
136 | + * @return string Column Name |
|
137 | + */ |
|
138 | + public function column_total( $user ) { |
|
139 | + return wpinv_price( $this->column_total_raw( $user ) ); |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * Displays the total spent column. |
|
144 | + * |
|
145 | + * @since 1.0.19 |
|
146 | + * |
|
147 | + * @param WP_User $user |
|
148 | + * |
|
149 | + * @return float |
|
150 | + */ |
|
151 | + public function column_total_raw( $user ) { |
|
152 | + |
|
153 | + $args = array( |
|
154 | + 'data' => array( |
|
155 | + |
|
156 | + 'total' => array( |
|
157 | + 'type' => 'invoice_data', |
|
158 | + 'function' => 'SUM', |
|
159 | + 'name' => 'total_sales', |
|
160 | + ) |
|
161 | + |
|
162 | + ), |
|
163 | + 'where' => array( |
|
164 | + |
|
165 | + 'author' => array( |
|
166 | + 'type' => 'post_data', |
|
167 | + 'value' => absint( $user->ID ), |
|
168 | + 'key' => 'posts.post_author', |
|
169 | + 'operator' => '=', |
|
170 | + ), |
|
171 | + |
|
172 | + ), |
|
173 | + 'query_type' => 'get_var', |
|
174 | + 'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ), |
|
175 | + ); |
|
176 | + |
|
177 | + return wpinv_round_amount( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
178 | + |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * Displays the total spent column. |
|
183 | + * |
|
184 | + * @since 1.0.19 |
|
185 | + * |
|
186 | + * @param WP_User $user |
|
187 | + * |
|
188 | + * @return string Column Name |
|
189 | + */ |
|
190 | + public function column_invoices( $user ) { |
|
191 | + |
|
192 | + $args = array( |
|
193 | + 'data' => array( |
|
194 | + |
|
195 | + 'ID' => array( |
|
196 | + 'type' => 'post_data', |
|
197 | + 'function' => 'COUNT', |
|
198 | + 'name' => 'count', |
|
199 | + 'distinct' => true, |
|
200 | + ), |
|
201 | + |
|
202 | + ), |
|
203 | + 'where' => array( |
|
204 | + |
|
205 | + 'author' => array( |
|
206 | + 'type' => 'post_data', |
|
207 | + 'value' => absint( $user->ID ), |
|
208 | + 'key' => 'posts.post_author', |
|
209 | + 'operator' => '=', |
|
210 | + ), |
|
211 | + |
|
212 | + ), |
|
213 | + 'query_type' => 'get_var', |
|
214 | + 'invoice_status' => array_keys( wpinv_get_invoice_statuses() ), |
|
215 | + ); |
|
216 | + |
|
217 | + return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
218 | + |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * Generates content for a single row of the table |
|
223 | + * @since 1.0.19 |
|
224 | + * |
|
225 | + * @param int $item The user id. |
|
226 | + */ |
|
227 | + public function single_row( $item ) { |
|
228 | + $item = get_user_by( 'id', $item ); |
|
229 | + |
|
230 | + if ( empty( $item ) ) { |
|
231 | + return; |
|
232 | + } |
|
233 | + |
|
234 | + echo '<tr>'; |
|
235 | + $this->single_row_columns( $item ); |
|
236 | + echo '</tr>'; |
|
237 | + } |
|
238 | + |
|
239 | + /** |
|
240 | + * Displays the customers name |
|
241 | + * |
|
242 | + * @param WP_User $customer customer. |
|
243 | + * @return string |
|
244 | + */ |
|
245 | + public function column_name( $customer ) { |
|
246 | + |
|
247 | + // Customer view URL. |
|
248 | + $view_url = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) ); |
|
249 | + $row_actions = $this->row_actions( |
|
250 | + array( |
|
251 | + 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
252 | + ) |
|
253 | + ); |
|
254 | + |
|
255 | + // Get user's address. |
|
256 | + $address = wpinv_get_user_address( $customer->ID ); |
|
257 | + |
|
258 | + // Customer email address. |
|
259 | + $email = sanitize_email( $customer->user_email ); |
|
260 | + |
|
261 | + // Customer's avatar. |
|
262 | + $avatar = esc_url( get_avatar_url( $email ) ); |
|
263 | + $avatar = "<img src='$avatar' height='32' width='32'/>"; |
|
264 | + |
|
265 | + // Customer's name. |
|
266 | + $name = esc_html( "{$address['first_name']} {$address['last_name']}" ); |
|
267 | + |
|
268 | + if ( ! empty( $name ) ) { |
|
269 | + $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
|
270 | + } |
|
271 | + |
|
272 | + $email = "<div class='row-title'><a href='$view_url'>$email</a></div>"; |
|
273 | + |
|
274 | + return "<div style='display: flex;'><div>$avatar</div><div style='margin-left: 10px;'>$name<strong>$email</strong>$row_actions</div></div>"; |
|
275 | + |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * Retrieve the table columns |
|
280 | + * |
|
281 | + * @since 1.0.19 |
|
282 | + * @return array $columns Array of all the list table columns |
|
283 | + */ |
|
284 | + public function get_columns() { |
|
285 | + |
|
286 | + $columns = array( |
|
287 | + 'name' => __( 'Name', 'invoicing' ), |
|
288 | + 'country' => __( 'Country', 'invoicing' ), |
|
289 | + 'state' => __( 'State', 'invoicing' ), |
|
290 | + 'city' => __( 'City', 'invoicing' ), |
|
291 | + 'zip' => __( 'ZIP', 'invoicing' ), |
|
292 | + 'address' => __( 'Address', 'invoicing' ), |
|
293 | + 'phone' => __( 'Phone', 'invoicing' ), |
|
294 | + 'company' => __( 'Company', 'invoicing' ), |
|
295 | + 'invoices' => __( 'Invoices', 'invoicing' ), |
|
296 | + 'total' => __( 'Total Spend', 'invoicing' ), |
|
297 | + 'signup' => __( 'Date created', 'invoicing' ), |
|
298 | + ); |
|
299 | + return apply_filters( 'wpinv_customers_table_columns', $columns ); |
|
300 | + |
|
301 | + } |
|
302 | + |
|
303 | + /** |
|
304 | + * Retrieve the current page number |
|
305 | + * |
|
306 | + * @since 1.0.19 |
|
307 | + * @return int Current page number |
|
308 | + */ |
|
309 | + public function get_paged() { |
|
310 | + return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
311 | + } |
|
312 | + |
|
313 | + /** |
|
314 | + * Returns bulk actions. |
|
315 | + * |
|
316 | + * @since 1.0.19 |
|
317 | + * @return void |
|
318 | + */ |
|
319 | + public function bulk_actions( $which = '' ) { |
|
320 | + return array(); |
|
321 | + } |
|
322 | + |
|
323 | + /** |
|
324 | + * Prepares the display query |
|
325 | + */ |
|
326 | + public function prepare_query() { |
|
327 | + global $wpdb; |
|
328 | + |
|
329 | + $post_types = ''; |
|
330 | + |
|
331 | + foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
332 | + $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
333 | + } |
|
334 | + |
|
335 | + $post_types = rtrim( $post_types, ' OR' ); |
|
336 | + |
|
337 | + // Maybe search. |
|
338 | + if ( ! empty( $_POST['s'] ) ) { |
|
339 | + $users = get_users( |
|
340 | + array( |
|
341 | + 'search' => '*' . sanitize_text_field( urldecode( $_POST['s'] ) ) . '*', |
|
342 | + 'search_columns' => array( 'user_login', 'user_email', 'display_name' ), |
|
343 | + 'fields' => 'ID', |
|
344 | + ) |
|
345 | + ); |
|
346 | + |
|
347 | + $users = implode( ', ', $users ); |
|
348 | + $post_types = "($post_types) AND ( post_author IN ( $users ) )"; |
|
349 | + } |
|
350 | + |
|
351 | + // Users with invoices. |
|
352 | + $customers = $wpdb->get_col( |
|
353 | + $wpdb->prepare( |
|
354 | + "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types LIMIT %d,%d", |
|
355 | + $this->get_paged() * 10 - 10, |
|
356 | + $this->per_page |
|
357 | + ) |
|
358 | + ); |
|
359 | + |
|
360 | + $this->items = $customers; |
|
361 | + $this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" ); |
|
362 | + |
|
363 | + } |
|
364 | + |
|
365 | + /** |
|
366 | + * Setup the final data for the table |
|
367 | + * |
|
368 | + * @since 1.0.19 |
|
369 | + * @return void |
|
370 | + */ |
|
371 | + public function prepare_items() { |
|
372 | + $columns = $this->get_columns(); |
|
373 | + $hidden = array(); // No hidden columns |
|
374 | + $sortable = $this->get_sortable_columns(); |
|
375 | + $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
376 | + $this->prepare_query(); |
|
377 | + |
|
378 | + $this->set_pagination_args( |
|
379 | + array( |
|
380 | + 'total_items' => $this->total, |
|
381 | + 'per_page' => $this->per_page, |
|
382 | + 'total_pages' => ceil( $this->total / $this->per_page ) |
|
383 | + ) |
|
384 | + ); |
|
385 | + |
|
386 | + } |
|
387 | 387 | } |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | // Exit if accessed directly |
8 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
8 | +if (!defined('ABSPATH')) exit; |
|
9 | 9 | |
10 | 10 | // Load WP_List_Table if not loaded |
11 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
11 | +if (!class_exists('WP_List_Table')) { |
|
12 | 12 | require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
13 | 13 | } |
14 | 14 | |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | public function __construct() { |
43 | 43 | |
44 | 44 | // Set parent defaults |
45 | - parent::__construct( array( |
|
45 | + parent::__construct(array( |
|
46 | 46 | 'singular' => 'id', |
47 | 47 | 'plural' => 'ids', |
48 | 48 | 'ajax' => false, |
49 | - ) ); |
|
49 | + )); |
|
50 | 50 | |
51 | 51 | } |
52 | 52 | |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return string Column Name |
74 | 74 | */ |
75 | - public function column_default( $item, $column_name ) { |
|
76 | - $value = esc_html( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) ); |
|
77 | - return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item ); |
|
75 | + public function column_default($item, $column_name) { |
|
76 | + $value = esc_html(get_user_meta($item->ID, '_wpinv_' . $column_name, true)); |
|
77 | + return apply_filters('wpinv_customers_table_column' . $column_name, $value, $item); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return string Column Name |
88 | 88 | */ |
89 | - public function column_country( $user ) { |
|
90 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
91 | - if ( $country ) { |
|
92 | - $country = wpinv_country_name( $country ); |
|
89 | + public function column_country($user) { |
|
90 | + $country = wpinv_sanitize_country($user->_wpinv_country); |
|
91 | + if ($country) { |
|
92 | + $country = wpinv_country_name($country); |
|
93 | 93 | } |
94 | - return esc_html( $country ); |
|
94 | + return esc_html($country); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return string Column Name |
105 | 105 | */ |
106 | - public function column_state( $user ) { |
|
107 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
106 | + public function column_state($user) { |
|
107 | + $country = wpinv_sanitize_country($user->_wpinv_country); |
|
108 | 108 | $state = $user->_wpinv_state; |
109 | - if ( $state ) { |
|
110 | - $state = wpinv_state_name( $state, $country ); |
|
109 | + if ($state) { |
|
110 | + $state = wpinv_state_name($state, $country); |
|
111 | 111 | } |
112 | 112 | |
113 | - return esc_html( $state ); |
|
113 | + return esc_html($state); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return string Column Name |
124 | 124 | */ |
125 | - public function column_signup( $user ) { |
|
126 | - return getpaid_format_date_value( $user->user_registered ); |
|
125 | + public function column_signup($user) { |
|
126 | + return getpaid_format_date_value($user->user_registered); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return string Column Name |
137 | 137 | */ |
138 | - public function column_total( $user ) { |
|
139 | - return wpinv_price( $this->column_total_raw( $user ) ); |
|
138 | + public function column_total($user) { |
|
139 | + return wpinv_price($this->column_total_raw($user)); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return float |
150 | 150 | */ |
151 | - public function column_total_raw( $user ) { |
|
151 | + public function column_total_raw($user) { |
|
152 | 152 | |
153 | 153 | $args = array( |
154 | 154 | 'data' => array( |
@@ -164,17 +164,17 @@ discard block |
||
164 | 164 | |
165 | 165 | 'author' => array( |
166 | 166 | 'type' => 'post_data', |
167 | - 'value' => absint( $user->ID ), |
|
167 | + 'value' => absint($user->ID), |
|
168 | 168 | 'key' => 'posts.post_author', |
169 | 169 | 'operator' => '=', |
170 | 170 | ), |
171 | 171 | |
172 | 172 | ), |
173 | 173 | 'query_type' => 'get_var', |
174 | - 'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ), |
|
174 | + 'invoice_status' => array('wpi-renewal', 'wpi-processing', 'publish'), |
|
175 | 175 | ); |
176 | 176 | |
177 | - return wpinv_round_amount( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
177 | + return wpinv_round_amount(GetPaid_Reports_Helper::get_invoice_report_data($args)); |
|
178 | 178 | |
179 | 179 | } |
180 | 180 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return string Column Name |
189 | 189 | */ |
190 | - public function column_invoices( $user ) { |
|
190 | + public function column_invoices($user) { |
|
191 | 191 | |
192 | 192 | $args = array( |
193 | 193 | 'data' => array( |
@@ -204,17 +204,17 @@ discard block |
||
204 | 204 | |
205 | 205 | 'author' => array( |
206 | 206 | 'type' => 'post_data', |
207 | - 'value' => absint( $user->ID ), |
|
207 | + 'value' => absint($user->ID), |
|
208 | 208 | 'key' => 'posts.post_author', |
209 | 209 | 'operator' => '=', |
210 | 210 | ), |
211 | 211 | |
212 | 212 | ), |
213 | 213 | 'query_type' => 'get_var', |
214 | - 'invoice_status' => array_keys( wpinv_get_invoice_statuses() ), |
|
214 | + 'invoice_status' => array_keys(wpinv_get_invoice_statuses()), |
|
215 | 215 | ); |
216 | 216 | |
217 | - return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
217 | + return absint(GetPaid_Reports_Helper::get_invoice_report_data($args)); |
|
218 | 218 | |
219 | 219 | } |
220 | 220 | |
@@ -224,15 +224,15 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @param int $item The user id. |
226 | 226 | */ |
227 | - public function single_row( $item ) { |
|
228 | - $item = get_user_by( 'id', $item ); |
|
227 | + public function single_row($item) { |
|
228 | + $item = get_user_by('id', $item); |
|
229 | 229 | |
230 | - if ( empty( $item ) ) { |
|
230 | + if (empty($item)) { |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | |
234 | 234 | echo '<tr>'; |
235 | - $this->single_row_columns( $item ); |
|
235 | + $this->single_row_columns($item); |
|
236 | 236 | echo '</tr>'; |
237 | 237 | } |
238 | 238 | |
@@ -242,30 +242,30 @@ discard block |
||
242 | 242 | * @param WP_User $customer customer. |
243 | 243 | * @return string |
244 | 244 | */ |
245 | - public function column_name( $customer ) { |
|
245 | + public function column_name($customer) { |
|
246 | 246 | |
247 | 247 | // Customer view URL. |
248 | - $view_url = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) ); |
|
248 | + $view_url = esc_url(add_query_arg('user_id', $customer->ID, admin_url('user-edit.php'))); |
|
249 | 249 | $row_actions = $this->row_actions( |
250 | 250 | array( |
251 | - 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
251 | + 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __('Edit Details', 'invoicing') . '</a>', |
|
252 | 252 | ) |
253 | 253 | ); |
254 | 254 | |
255 | 255 | // Get user's address. |
256 | - $address = wpinv_get_user_address( $customer->ID ); |
|
256 | + $address = wpinv_get_user_address($customer->ID); |
|
257 | 257 | |
258 | 258 | // Customer email address. |
259 | - $email = sanitize_email( $customer->user_email ); |
|
259 | + $email = sanitize_email($customer->user_email); |
|
260 | 260 | |
261 | 261 | // Customer's avatar. |
262 | - $avatar = esc_url( get_avatar_url( $email ) ); |
|
262 | + $avatar = esc_url(get_avatar_url($email)); |
|
263 | 263 | $avatar = "<img src='$avatar' height='32' width='32'/>"; |
264 | 264 | |
265 | 265 | // Customer's name. |
266 | - $name = esc_html( "{$address['first_name']} {$address['last_name']}" ); |
|
266 | + $name = esc_html("{$address['first_name']} {$address['last_name']}"); |
|
267 | 267 | |
268 | - if ( ! empty( $name ) ) { |
|
268 | + if (!empty($name)) { |
|
269 | 269 | $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
270 | 270 | } |
271 | 271 | |
@@ -284,19 +284,19 @@ discard block |
||
284 | 284 | public function get_columns() { |
285 | 285 | |
286 | 286 | $columns = array( |
287 | - 'name' => __( 'Name', 'invoicing' ), |
|
288 | - 'country' => __( 'Country', 'invoicing' ), |
|
289 | - 'state' => __( 'State', 'invoicing' ), |
|
290 | - 'city' => __( 'City', 'invoicing' ), |
|
291 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
292 | - 'address' => __( 'Address', 'invoicing' ), |
|
293 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
294 | - 'company' => __( 'Company', 'invoicing' ), |
|
295 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
296 | - 'total' => __( 'Total Spend', 'invoicing' ), |
|
297 | - 'signup' => __( 'Date created', 'invoicing' ), |
|
287 | + 'name' => __('Name', 'invoicing'), |
|
288 | + 'country' => __('Country', 'invoicing'), |
|
289 | + 'state' => __('State', 'invoicing'), |
|
290 | + 'city' => __('City', 'invoicing'), |
|
291 | + 'zip' => __('ZIP', 'invoicing'), |
|
292 | + 'address' => __('Address', 'invoicing'), |
|
293 | + 'phone' => __('Phone', 'invoicing'), |
|
294 | + 'company' => __('Company', 'invoicing'), |
|
295 | + 'invoices' => __('Invoices', 'invoicing'), |
|
296 | + 'total' => __('Total Spend', 'invoicing'), |
|
297 | + 'signup' => __('Date created', 'invoicing'), |
|
298 | 298 | ); |
299 | - return apply_filters( 'wpinv_customers_table_columns', $columns ); |
|
299 | + return apply_filters('wpinv_customers_table_columns', $columns); |
|
300 | 300 | |
301 | 301 | } |
302 | 302 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @return int Current page number |
308 | 308 | */ |
309 | 309 | public function get_paged() { |
310 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
310 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @since 1.0.19 |
317 | 317 | * @return void |
318 | 318 | */ |
319 | - public function bulk_actions( $which = '' ) { |
|
319 | + public function bulk_actions($which = '') { |
|
320 | 320 | return array(); |
321 | 321 | } |
322 | 322 | |
@@ -328,23 +328,23 @@ discard block |
||
328 | 328 | |
329 | 329 | $post_types = ''; |
330 | 330 | |
331 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
332 | - $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
331 | + foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) { |
|
332 | + $post_types .= $wpdb->prepare("post_type=%s OR ", $post_type); |
|
333 | 333 | } |
334 | 334 | |
335 | - $post_types = rtrim( $post_types, ' OR' ); |
|
335 | + $post_types = rtrim($post_types, ' OR'); |
|
336 | 336 | |
337 | 337 | // Maybe search. |
338 | - if ( ! empty( $_POST['s'] ) ) { |
|
338 | + if (!empty($_POST['s'])) { |
|
339 | 339 | $users = get_users( |
340 | 340 | array( |
341 | - 'search' => '*' . sanitize_text_field( urldecode( $_POST['s'] ) ) . '*', |
|
342 | - 'search_columns' => array( 'user_login', 'user_email', 'display_name' ), |
|
341 | + 'search' => '*' . sanitize_text_field(urldecode($_POST['s'])) . '*', |
|
342 | + 'search_columns' => array('user_login', 'user_email', 'display_name'), |
|
343 | 343 | 'fields' => 'ID', |
344 | 344 | ) |
345 | 345 | ); |
346 | 346 | |
347 | - $users = implode( ', ', $users ); |
|
347 | + $users = implode(', ', $users); |
|
348 | 348 | $post_types = "($post_types) AND ( post_author IN ( $users ) )"; |
349 | 349 | } |
350 | 350 | |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | ); |
359 | 359 | |
360 | 360 | $this->items = $customers; |
361 | - $this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types" ); |
|
361 | + $this->total = (int) $wpdb->get_var("SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE $post_types"); |
|
362 | 362 | |
363 | 363 | } |
364 | 364 | |
@@ -372,14 +372,14 @@ discard block |
||
372 | 372 | $columns = $this->get_columns(); |
373 | 373 | $hidden = array(); // No hidden columns |
374 | 374 | $sortable = $this->get_sortable_columns(); |
375 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
375 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
376 | 376 | $this->prepare_query(); |
377 | 377 | |
378 | 378 | $this->set_pagination_args( |
379 | 379 | array( |
380 | 380 | 'total_items' => $this->total, |
381 | 381 | 'per_page' => $this->per_page, |
382 | - 'total_pages' => ceil( $this->total / $this->per_page ) |
|
382 | + 'total_pages' => ceil($this->total / $this->per_page) |
|
383 | 383 | ) |
384 | 384 | ); |
385 | 385 |
@@ -1,16 +1,16 @@ 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_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
8 | -function wpinv_discount_custom_column( $column ) { |
|
7 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
8 | +function wpinv_discount_custom_column($column) { |
|
9 | 9 | global $post; |
10 | 10 | |
11 | - $discount = new WPInv_Discount( $post ); |
|
11 | + $discount = new WPInv_Discount($post); |
|
12 | 12 | |
13 | - switch ( $column ) { |
|
13 | + switch ($column) { |
|
14 | 14 | case 'code' : |
15 | 15 | echo $discount->get_code(); |
16 | 16 | break; |
@@ -21,31 +21,31 @@ discard block |
||
21 | 21 | echo $discount->get_usage(); |
22 | 22 | break; |
23 | 23 | case 'start_date' : |
24 | - echo getpaid_format_date_value( $discount->get_start_date() ); |
|
24 | + echo getpaid_format_date_value($discount->get_start_date()); |
|
25 | 25 | break; |
26 | 26 | case 'expiry_date' : |
27 | - echo getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) ); |
|
27 | + echo getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing')); |
|
28 | 28 | break; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 90, 2 ); |
|
33 | -function wpinv_post_row_actions( $actions, $post ) { |
|
34 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
32 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 90, 2); |
|
33 | +function wpinv_post_row_actions($actions, $post) { |
|
34 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
35 | 35 | |
36 | - if ( $post_type == 'wpi_discount' ) { |
|
37 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
36 | + if ($post_type == 'wpi_discount') { |
|
37 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | return $actions; |
41 | 41 | } |
42 | 42 | |
43 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
44 | - $row_actions = array(); |
|
45 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
46 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
43 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
44 | + $row_actions = array(); |
|
45 | + $edit_link = get_edit_post_link($discount->ID); |
|
46 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
47 | 47 | |
48 | - if ( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
48 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
49 | 49 | |
50 | 50 | $url = wp_nonce_url( |
51 | 51 | add_query_arg( |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | 'getpaid-nonce', |
58 | 58 | 'getpaid-nonce' |
59 | 59 | ); |
60 | - $anchor = __( 'Deactivate', 'invoicing' ); |
|
61 | - $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
60 | + $anchor = __('Deactivate', 'invoicing'); |
|
61 | + $title = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing'); |
|
62 | 62 | $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
63 | 63 | |
64 | - } else if( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
64 | + } else if (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
65 | 65 | |
66 | - $url = wp_nonce_url( |
|
66 | + $url = wp_nonce_url( |
|
67 | 67 | add_query_arg( |
68 | 68 | array( |
69 | 69 | 'getpaid-admin-action' => 'activate_discount', |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | 'getpaid-nonce', |
74 | 74 | 'getpaid-nonce' |
75 | 75 | ); |
76 | - $anchor = __( 'Activate', 'invoicing' ); |
|
77 | - $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
76 | + $anchor = __('Activate', 'invoicing'); |
|
77 | + $title = esc_attr__('Are you sure you want to activate this discount?', 'invoicing'); |
|
78 | 78 | $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | - $url = esc_url( |
|
82 | + $url = esc_url( |
|
83 | 83 | wp_nonce_url( |
84 | 84 | add_query_arg( |
85 | 85 | array( |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | 'getpaid-nonce' |
92 | 92 | ) |
93 | 93 | ); |
94 | - $anchor = __( 'Delete', 'invoicing' ); |
|
95 | - $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
94 | + $anchor = __('Delete', 'invoicing'); |
|
95 | + $title = esc_attr__('Are you sure you want to delete this discount?', 'invoicing'); |
|
96 | 96 | $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
97 | 97 | |
98 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
98 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
99 | 99 | |
100 | 100 | return $row_actions; |
101 | 101 | } |
@@ -103,68 +103,68 @@ discard block |
||
103 | 103 | function wpinv_restrict_manage_posts() { |
104 | 104 | global $typenow; |
105 | 105 | |
106 | - if( 'wpi_discount' == $typenow ) { |
|
106 | + if ('wpi_discount' == $typenow) { |
|
107 | 107 | wpinv_discount_filters(); |
108 | 108 | } |
109 | 109 | } |
110 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
110 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
111 | 111 | |
112 | 112 | function wpinv_discount_filters() { |
113 | 113 | |
114 | 114 | ?> |
115 | 115 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
116 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
116 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
117 | 117 | <?php |
118 | 118 | $types = wpinv_get_discount_types(); |
119 | 119 | |
120 | - foreach ( $types as $name => $type ) { |
|
121 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
120 | + foreach ($types as $name => $type) { |
|
121 | + echo '<option value="' . esc_attr($name) . '"'; |
|
122 | 122 | |
123 | - if ( isset( $_GET['discount_type'] ) ) |
|
124 | - selected( $name, $_GET['discount_type'] ); |
|
123 | + if (isset($_GET['discount_type'])) |
|
124 | + selected($name, $_GET['discount_type']); |
|
125 | 125 | |
126 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
126 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
127 | 127 | } |
128 | 128 | ?> |
129 | 129 | </select> |
130 | 130 | <?php |
131 | 131 | } |
132 | 132 | |
133 | -function wpinv_request( $vars ) { |
|
133 | +function wpinv_request($vars) { |
|
134 | 134 | global $typenow, $wp_post_statuses; |
135 | 135 | |
136 | - if ( getpaid_is_invoice_post_type( $typenow ) ) { |
|
137 | - if ( ! isset( $vars['post_status'] ) ) { |
|
138 | - $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow ); |
|
136 | + if (getpaid_is_invoice_post_type($typenow)) { |
|
137 | + if (!isset($vars['post_status'])) { |
|
138 | + $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow); |
|
139 | 139 | |
140 | - foreach ( $post_statuses as $status => $value ) { |
|
141 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
142 | - unset( $post_statuses[ $status ] ); |
|
140 | + foreach ($post_statuses as $status => $value) { |
|
141 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
142 | + unset($post_statuses[$status]); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
146 | + $vars['post_status'] = array_keys($post_statuses); |
|
147 | 147 | } |
148 | 148 | |
149 | - } else if ( 'wpi_discount' == $typenow ) { |
|
150 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
149 | + } else if ('wpi_discount' == $typenow) { |
|
150 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
151 | 151 | // Filter vat rule type |
152 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
152 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
153 | 153 | $meta_query[] = array( |
154 | 154 | 'key' => '_wpi_discount_type', |
155 | - 'value' => sanitize_key( urldecode( $_GET['discount_type'] ) ), |
|
155 | + 'value' => sanitize_key(urldecode($_GET['discount_type'])), |
|
156 | 156 | 'compare' => '=' |
157 | 157 | ); |
158 | 158 | } |
159 | 159 | |
160 | - if ( !empty( $meta_query ) ) { |
|
160 | + if (!empty($meta_query)) { |
|
161 | 161 | $vars['meta_query'] = $meta_query; |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | 165 | return $vars; |
166 | 166 | } |
167 | -add_filter( 'request', 'wpinv_request' ); |
|
167 | +add_filter('request', 'wpinv_request'); |
|
168 | 168 | |
169 | 169 | /** |
170 | 170 | * Create a page and store the ID in an option. |
@@ -176,19 +176,19 @@ discard block |
||
176 | 176 | * @param int $post_parent (default: 0) Parent for the new page |
177 | 177 | * @return int page ID |
178 | 178 | */ |
179 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
179 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
180 | 180 | global $wpdb; |
181 | 181 | |
182 | - $option_value = wpinv_get_option( $option ); |
|
182 | + $option_value = wpinv_get_option($option); |
|
183 | 183 | |
184 | - if ( ! empty( $option_value ) && ( $page_object = get_post( $option_value ) ) ) { |
|
185 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
184 | + if (!empty($option_value) && ($page_object = get_post($option_value))) { |
|
185 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
186 | 186 | // Valid page is already in place |
187 | 187 | return $page_object->ID; |
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - if(!empty($post_parent)){ |
|
191 | + if (!empty($post_parent)) { |
|
192 | 192 | $page = get_page_by_path($post_parent); |
193 | 193 | if ($page) { |
194 | 194 | $post_parent = $page->ID; |
@@ -197,40 +197,40 @@ discard block |
||
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - if ( strlen( $page_content ) > 0 ) { |
|
200 | + if (strlen($page_content) > 0) { |
|
201 | 201 | // Search for an existing page with the specified page content (typically a shortcode) |
202 | - $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}%" ) ); |
|
202 | + $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}%")); |
|
203 | 203 | } else { |
204 | 204 | // Search for an existing page with the specified page slug |
205 | - $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 ) ); |
|
205 | + $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)); |
|
206 | 206 | } |
207 | 207 | |
208 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
208 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
209 | 209 | |
210 | - if ( $valid_page_found ) { |
|
211 | - if ( $option ) { |
|
212 | - wpinv_update_option( $option, $valid_page_found ); |
|
210 | + if ($valid_page_found) { |
|
211 | + if ($option) { |
|
212 | + wpinv_update_option($option, $valid_page_found); |
|
213 | 213 | } |
214 | 214 | return $valid_page_found; |
215 | 215 | } |
216 | 216 | |
217 | 217 | // Search for a matching valid trashed page |
218 | - if ( strlen( $page_content ) > 0 ) { |
|
218 | + if (strlen($page_content) > 0) { |
|
219 | 219 | // Search for an existing page with the specified page content (typically a shortcode) |
220 | - $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}%" ) ); |
|
220 | + $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}%")); |
|
221 | 221 | } else { |
222 | 222 | // Search for an existing page with the specified page slug |
223 | - $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 ) ); |
|
223 | + $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)); |
|
224 | 224 | } |
225 | 225 | |
226 | - if ( $trashed_page_found ) { |
|
226 | + if ($trashed_page_found) { |
|
227 | 227 | $page_id = $trashed_page_found; |
228 | 228 | $page_data = array( |
229 | 229 | 'ID' => $page_id, |
230 | 230 | 'post_status' => 'publish', |
231 | 231 | 'post_parent' => $post_parent, |
232 | 232 | ); |
233 | - wp_update_post( $page_data ); |
|
233 | + wp_update_post($page_data); |
|
234 | 234 | } else { |
235 | 235 | $page_data = array( |
236 | 236 | 'post_status' => 'publish', |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | 'post_parent' => $post_parent, |
243 | 243 | 'comment_status' => 'closed', |
244 | 244 | ); |
245 | - $page_id = wp_insert_post( $page_data ); |
|
245 | + $page_id = wp_insert_post($page_data); |
|
246 | 246 | } |
247 | 247 | |
248 | - if ( $option ) { |
|
249 | - wpinv_update_option( $option, (int) $page_id ); |
|
248 | + if ($option) { |
|
249 | + wpinv_update_option($option, (int) $page_id); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | return $page_id; |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @return array |
261 | 261 | */ |
262 | -function wpinv_add_aui_screens($screen_ids){ |
|
262 | +function wpinv_add_aui_screens($screen_ids) { |
|
263 | 263 | |
264 | 264 | // load on these pages if set |
265 | - $screen_ids = array_merge( $screen_ids, wpinv_get_screen_ids() ); |
|
265 | + $screen_ids = array_merge($screen_ids, wpinv_get_screen_ids()); |
|
266 | 266 | |
267 | 267 | return $screen_ids; |
268 | 268 | } |
269 | -add_filter('aui_screen_ids','wpinv_add_aui_screens'); |
|
270 | 269 | \ No newline at end of file |
270 | +add_filter('aui_screen_ids', 'wpinv_add_aui_screens'); |
|
271 | 271 | \ No newline at end of file |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function wpinv_subscriptions_page() { |
16 | 16 | |
17 | - ?> |
|
17 | + ?> |
|
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,27 +22,27 @@ discard block |
||
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | - // Verify user permissions. |
|
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
25 | + // Verify user permissions. |
|
26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
27 | 27 | |
28 | - echo aui()->alert( |
|
29 | - array( |
|
30 | - 'type' => 'danger', |
|
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | - ) |
|
33 | - ); |
|
28 | + echo aui()->alert( |
|
29 | + array( |
|
30 | + 'type' => 'danger', |
|
31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
32 | + ) |
|
33 | + ); |
|
34 | 34 | |
35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
36 | 36 | |
37 | - // Display a single subscription. |
|
38 | - wpinv_recurring_subscription_details(); |
|
39 | - } else { |
|
37 | + // Display a single subscription. |
|
38 | + wpinv_recurring_subscription_details(); |
|
39 | + } else { |
|
40 | 40 | |
41 | - // Display a list of available subscriptions. |
|
42 | - getpaid_print_subscriptions_list(); |
|
43 | - } |
|
41 | + // Display a list of available subscriptions. |
|
42 | + getpaid_print_subscriptions_list(); |
|
43 | + } |
|
44 | 44 | |
45 | - ?> |
|
45 | + ?> |
|
46 | 46 | |
47 | 47 | </div> |
48 | 48 | </div> |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function getpaid_print_subscriptions_list() { |
61 | 61 | |
62 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
63 | - $subscribers_table->prepare_items(); |
|
62 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
63 | + $subscribers_table->prepare_items(); |
|
64 | 64 | |
65 | - ?> |
|
65 | + ?> |
|
66 | 66 | <form id="subscribers-filter" class="bsui" method="get"> |
67 | 67 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
68 | 68 | <?php $subscribers_table->views(); ?> |
@@ -80,41 +80,41 @@ discard block |
||
80 | 80 | */ |
81 | 81 | function wpinv_recurring_subscription_details() { |
82 | 82 | |
83 | - // Fetch the subscription. |
|
84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | - if ( ! $sub->exists() ) { |
|
83 | + // Fetch the subscription. |
|
84 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | + if ( ! $sub->exists() ) { |
|
86 | 86 | |
87 | - echo aui()->alert( |
|
88 | - array( |
|
89 | - 'type' => 'danger', |
|
90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
91 | - ) |
|
92 | - ); |
|
87 | + echo aui()->alert( |
|
88 | + array( |
|
89 | + 'type' => 'danger', |
|
90 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
91 | + ) |
|
92 | + ); |
|
93 | 93 | |
94 | - return; |
|
95 | - } |
|
94 | + return; |
|
95 | + } |
|
96 | 96 | |
97 | - // Use metaboxes to display the subscription details. |
|
98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
97 | + // Use metaboxes to display the subscription details. |
|
98 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
99 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | 100 | |
101 | - $subscription_id = $sub->get_id(); |
|
102 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
103 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
101 | + $subscription_id = $sub->get_id(); |
|
102 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
103 | + $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
104 | 104 | |
105 | - if ( 1 < count( $subscription_groups ) ) { |
|
106 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
107 | - } |
|
105 | + if ( 1 < count( $subscription_groups ) ) { |
|
106 | + add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
107 | + } |
|
108 | 108 | |
109 | - if ( ! empty( $subscription_group ) ) { |
|
110 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
111 | - } |
|
109 | + if ( ! empty( $subscription_group ) ) { |
|
110 | + add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
111 | + } |
|
112 | 112 | |
113 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
113 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
114 | 114 | |
115 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
115 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
116 | 116 | |
117 | - ?> |
|
117 | + ?> |
|
118 | 118 | |
119 | 119 | <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
120 | 120 | |
@@ -154,45 +154,45 @@ discard block |
||
154 | 154 | */ |
155 | 155 | function getpaid_admin_subscription_details_metabox( $sub ) { |
156 | 156 | |
157 | - // Subscription items. |
|
158 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
159 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
160 | - |
|
161 | - // Prepare subscription detail columns. |
|
162 | - $fields = apply_filters( |
|
163 | - 'getpaid_subscription_admin_page_fields', |
|
164 | - array( |
|
165 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
166 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
167 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
168 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
169 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
170 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
171 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
172 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
173 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
174 | - 'status' => __( 'Status', 'invoicing' ), |
|
175 | - ) |
|
176 | - ); |
|
177 | - |
|
178 | - if ( ! $sub->is_active() ) { |
|
179 | - |
|
180 | - if ( isset( $fields['renews_on'] ) ) { |
|
181 | - unset( $fields['renews_on'] ); |
|
182 | - } |
|
183 | - |
|
184 | - if ( isset( $fields['gateway'] ) ) { |
|
185 | - unset( $fields['gateway'] ); |
|
186 | - } |
|
187 | - |
|
188 | - } |
|
189 | - |
|
190 | - $profile_id = $sub->get_profile_id(); |
|
191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | - unset( $fields['profile_id'] ); |
|
193 | - } |
|
194 | - |
|
195 | - ?> |
|
157 | + // Subscription items. |
|
158 | + $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
159 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
160 | + |
|
161 | + // Prepare subscription detail columns. |
|
162 | + $fields = apply_filters( |
|
163 | + 'getpaid_subscription_admin_page_fields', |
|
164 | + array( |
|
165 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
166 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
167 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
168 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
169 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
170 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
171 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
172 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
173 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
174 | + 'status' => __( 'Status', 'invoicing' ), |
|
175 | + ) |
|
176 | + ); |
|
177 | + |
|
178 | + if ( ! $sub->is_active() ) { |
|
179 | + |
|
180 | + if ( isset( $fields['renews_on'] ) ) { |
|
181 | + unset( $fields['renews_on'] ); |
|
182 | + } |
|
183 | + |
|
184 | + if ( isset( $fields['gateway'] ) ) { |
|
185 | + unset( $fields['gateway'] ); |
|
186 | + } |
|
187 | + |
|
188 | + } |
|
189 | + |
|
190 | + $profile_id = $sub->get_profile_id(); |
|
191 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | + unset( $fields['profile_id'] ); |
|
193 | + } |
|
194 | + |
|
195 | + ?> |
|
196 | 196 | |
197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
198 | 198 | <tbody> |
@@ -226,20 +226,20 @@ discard block |
||
226 | 226 | */ |
227 | 227 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
228 | 228 | |
229 | - $username = __( '(Missing User)', 'invoicing' ); |
|
229 | + $username = __( '(Missing User)', 'invoicing' ); |
|
230 | 230 | |
231 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
232 | - if ( $user ) { |
|
231 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
232 | + if ( $user ) { |
|
233 | 233 | |
234 | - $username = sprintf( |
|
235 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
236 | - absint( $user->ID ), |
|
237 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
238 | - ); |
|
234 | + $username = sprintf( |
|
235 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
236 | + absint( $user->ID ), |
|
237 | + ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
238 | + ); |
|
239 | 239 | |
240 | - } |
|
240 | + } |
|
241 | 241 | |
242 | - echo $username; |
|
242 | + echo $username; |
|
243 | 243 | } |
244 | 244 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
245 | 245 | |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | * @param WPInv_Subscription $subscription |
250 | 250 | */ |
251 | 251 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
252 | - $amount = esc_html( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
253 | - echo "<span>$amount</span>"; |
|
252 | + $amount = esc_html( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
253 | + echo "<span>$amount</span>"; |
|
254 | 254 | } |
255 | 255 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
256 | 256 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @param WPInv_Subscription $subscription |
261 | 261 | */ |
262 | 262 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
263 | - echo '#' . absint( $subscription->get_id() ); |
|
263 | + echo '#' . absint( $subscription->get_id() ); |
|
264 | 264 | } |
265 | 265 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
266 | 266 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param WPInv_Subscription $subscription |
271 | 271 | */ |
272 | 272 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
273 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
273 | + echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
274 | 274 | } |
275 | 275 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
276 | 276 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @param WPInv_Subscription $subscription |
281 | 281 | */ |
282 | 282 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
283 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
283 | + echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
284 | 284 | } |
285 | 285 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
286 | 286 | |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @param WPInv_Subscription $subscription |
291 | 291 | */ |
292 | 292 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
293 | - $max_bills = $subscription->get_bill_times(); |
|
294 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
293 | + $max_bills = $subscription->get_bill_times(); |
|
294 | + echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
295 | 295 | } |
296 | 296 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
297 | 297 | /** |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | */ |
303 | 303 | function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
304 | 304 | |
305 | - if ( empty( $subscription_group ) ) { |
|
306 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
307 | - return; |
|
308 | - } |
|
305 | + if ( empty( $subscription_group ) ) { |
|
306 | + echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
307 | + return; |
|
308 | + } |
|
309 | 309 | |
310 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
311 | - echo implode( ' | ', $markup ); |
|
310 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
311 | + echo implode( ' | ', $markup ); |
|
312 | 312 | |
313 | 313 | } |
314 | 314 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -320,13 +320,13 @@ discard block |
||
320 | 320 | */ |
321 | 321 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
322 | 322 | |
323 | - $gateway = $subscription->get_gateway(); |
|
323 | + $gateway = $subscription->get_gateway(); |
|
324 | 324 | |
325 | - if ( ! empty( $gateway ) ) { |
|
326 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
327 | - } else { |
|
328 | - echo "—"; |
|
329 | - } |
|
325 | + if ( ! empty( $gateway ) ) { |
|
326 | + echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
327 | + } else { |
|
328 | + echo "—"; |
|
329 | + } |
|
330 | 330 | |
331 | 331 | } |
332 | 332 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @param WPInv_Subscription $subscription |
338 | 338 | */ |
339 | 339 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
340 | - echo $subscription->get_status_label_html(); |
|
340 | + echo $subscription->get_status_label_html(); |
|
341 | 341 | } |
342 | 342 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
343 | 343 | |
@@ -348,29 +348,29 @@ discard block |
||
348 | 348 | */ |
349 | 349 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
350 | 350 | |
351 | - $profile_id = $subscription->get_profile_id(); |
|
352 | - |
|
353 | - $input = aui()->input( |
|
354 | - array( |
|
355 | - 'type' => 'text', |
|
356 | - 'id' => 'wpinv_subscription_profile_id', |
|
357 | - 'name' => 'wpinv_subscription_profile_id', |
|
358 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
359 | - 'label_type' => 'hidden', |
|
360 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
361 | - 'value' => esc_attr( $profile_id ), |
|
362 | - 'input_group_right' => '', |
|
363 | - 'no_wrap' => true, |
|
364 | - ) |
|
365 | - ); |
|
366 | - |
|
367 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
368 | - |
|
369 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
370 | - if ( ! empty( $url ) ) { |
|
371 | - $url = esc_url_raw( $url ); |
|
372 | - echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
373 | - } |
|
351 | + $profile_id = $subscription->get_profile_id(); |
|
352 | + |
|
353 | + $input = aui()->input( |
|
354 | + array( |
|
355 | + 'type' => 'text', |
|
356 | + 'id' => 'wpinv_subscription_profile_id', |
|
357 | + 'name' => 'wpinv_subscription_profile_id', |
|
358 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
359 | + 'label_type' => 'hidden', |
|
360 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
361 | + 'value' => esc_attr( $profile_id ), |
|
362 | + 'input_group_right' => '', |
|
363 | + 'no_wrap' => true, |
|
364 | + ) |
|
365 | + ); |
|
366 | + |
|
367 | + echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
368 | + |
|
369 | + $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
370 | + if ( ! empty( $url ) ) { |
|
371 | + $url = esc_url_raw( $url ); |
|
372 | + echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
373 | + } |
|
374 | 374 | |
375 | 375 | } |
376 | 376 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -382,39 +382,39 @@ discard block |
||
382 | 382 | */ |
383 | 383 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
384 | 384 | |
385 | - ?> |
|
385 | + ?> |
|
386 | 386 | <div class="mt-3"> |
387 | 387 | |
388 | 388 | <?php |
389 | - echo aui()->select( |
|
390 | - array( |
|
391 | - 'options' => getpaid_get_subscription_statuses(), |
|
392 | - 'name' => 'subscription_status', |
|
393 | - 'id' => 'subscription_status_update_select', |
|
394 | - 'required' => true, |
|
395 | - 'no_wrap' => false, |
|
396 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
397 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
398 | - 'select2' => true, |
|
399 | - 'value' => $subscription->get_status( 'edit' ), |
|
400 | - ) |
|
401 | - ); |
|
402 | - ?> |
|
389 | + echo aui()->select( |
|
390 | + array( |
|
391 | + 'options' => getpaid_get_subscription_statuses(), |
|
392 | + 'name' => 'subscription_status', |
|
393 | + 'id' => 'subscription_status_update_select', |
|
394 | + 'required' => true, |
|
395 | + 'no_wrap' => false, |
|
396 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
397 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
398 | + 'select2' => true, |
|
399 | + 'value' => $subscription->get_status( 'edit' ), |
|
400 | + ) |
|
401 | + ); |
|
402 | + ?> |
|
403 | 403 | |
404 | 404 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
405 | 405 | |
406 | 406 | <?php |
407 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
407 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
408 | 408 | |
409 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
410 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
411 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
409 | + $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
410 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
411 | + $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
412 | 412 | |
413 | - if ( $subscription->is_active() ) { |
|
414 | - echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
415 | - } |
|
413 | + if ( $subscription->is_active() ) { |
|
414 | + echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
415 | + } |
|
416 | 416 | |
417 | - echo '</div></div>'; |
|
417 | + echo '</div></div>'; |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -425,33 +425,33 @@ discard block |
||
425 | 425 | */ |
426 | 426 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
427 | 427 | |
428 | - $columns = apply_filters( |
|
429 | - 'getpaid_subscription_related_invoices_columns', |
|
430 | - array( |
|
431 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
432 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
433 | - 'date' => __( 'Date', 'invoicing' ), |
|
434 | - 'status' => __( 'Status', 'invoicing' ), |
|
435 | - 'total' => __( 'Total', 'invoicing' ), |
|
436 | - ), |
|
437 | - $subscription |
|
438 | - ); |
|
439 | - |
|
440 | - // Prepare the invoices. |
|
441 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
442 | - $parent = $subscription->get_parent_invoice(); |
|
443 | - |
|
444 | - if ( $parent->exists() ) { |
|
445 | - $payments = array_merge( array( $parent ), $payments ); |
|
446 | - } |
|
447 | - |
|
448 | - $table_class = 'w-100 bg-white'; |
|
449 | - |
|
450 | - if ( ! is_admin() ) { |
|
451 | - $table_class = 'table table-bordered'; |
|
452 | - } |
|
453 | - |
|
454 | - ?> |
|
428 | + $columns = apply_filters( |
|
429 | + 'getpaid_subscription_related_invoices_columns', |
|
430 | + array( |
|
431 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
432 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
433 | + 'date' => __( 'Date', 'invoicing' ), |
|
434 | + 'status' => __( 'Status', 'invoicing' ), |
|
435 | + 'total' => __( 'Total', 'invoicing' ), |
|
436 | + ), |
|
437 | + $subscription |
|
438 | + ); |
|
439 | + |
|
440 | + // Prepare the invoices. |
|
441 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
442 | + $parent = $subscription->get_parent_invoice(); |
|
443 | + |
|
444 | + if ( $parent->exists() ) { |
|
445 | + $payments = array_merge( array( $parent ), $payments ); |
|
446 | + } |
|
447 | + |
|
448 | + $table_class = 'w-100 bg-white'; |
|
449 | + |
|
450 | + if ( ! is_admin() ) { |
|
451 | + $table_class = 'table table-bordered'; |
|
452 | + } |
|
453 | + |
|
454 | + ?> |
|
455 | 455 | <div class="m-0" style="overflow: auto;"> |
456 | 456 | |
457 | 457 | <table class="<?php echo $table_class; ?>"> |
@@ -459,14 +459,14 @@ discard block |
||
459 | 459 | <thead> |
460 | 460 | <tr> |
461 | 461 | <?php |
462 | - foreach ( $columns as $key => $label ) { |
|
463 | - $key = esc_attr( $key ); |
|
464 | - $label = esc_html( $label ); |
|
465 | - $class = 'text-left'; |
|
466 | - |
|
467 | - echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
468 | - } |
|
469 | - ?> |
|
462 | + foreach ( $columns as $key => $label ) { |
|
463 | + $key = esc_attr( $key ); |
|
464 | + $label = esc_html( $label ); |
|
465 | + $class = 'text-left'; |
|
466 | + |
|
467 | + echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
468 | + } |
|
469 | + ?> |
|
470 | 470 | </tr> |
471 | 471 | </thead> |
472 | 472 | |
@@ -482,73 +482,73 @@ discard block |
||
482 | 482 | |
483 | 483 | <?php |
484 | 484 | |
485 | - foreach( $payments as $payment ) : |
|
485 | + foreach( $payments as $payment ) : |
|
486 | 486 | |
487 | - // Ensure that we have an invoice. |
|
488 | - $payment = new WPInv_Invoice( $payment ); |
|
487 | + // Ensure that we have an invoice. |
|
488 | + $payment = new WPInv_Invoice( $payment ); |
|
489 | 489 | |
490 | - // Abort if the invoice is invalid... |
|
491 | - if ( ! $payment->exists() ) { |
|
492 | - continue; |
|
493 | - } |
|
490 | + // Abort if the invoice is invalid... |
|
491 | + if ( ! $payment->exists() ) { |
|
492 | + continue; |
|
493 | + } |
|
494 | 494 | |
495 | - // ... or belongs to a different subscription. |
|
496 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
497 | - continue; |
|
498 | - } |
|
495 | + // ... or belongs to a different subscription. |
|
496 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
497 | + continue; |
|
498 | + } |
|
499 | 499 | |
500 | - echo '<tr>'; |
|
500 | + echo '<tr>'; |
|
501 | 501 | |
502 | - foreach ( array_keys( $columns ) as $key ) { |
|
502 | + foreach ( array_keys( $columns ) as $key ) { |
|
503 | 503 | |
504 | - $class = 'text-left'; |
|
504 | + $class = 'text-left'; |
|
505 | 505 | |
506 | - echo "<td class='p-2 $class'>"; |
|
506 | + echo "<td class='p-2 $class'>"; |
|
507 | 507 | |
508 | - switch( $key ) { |
|
508 | + switch( $key ) { |
|
509 | 509 | |
510 | - case 'total': |
|
511 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
512 | - break; |
|
510 | + case 'total': |
|
511 | + echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
512 | + break; |
|
513 | 513 | |
514 | - case 'relationship': |
|
515 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
516 | - break; |
|
514 | + case 'relationship': |
|
515 | + echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
516 | + break; |
|
517 | 517 | |
518 | - case 'date': |
|
519 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
520 | - break; |
|
518 | + case 'date': |
|
519 | + echo getpaid_format_date_value( $payment->get_date_created() ); |
|
520 | + break; |
|
521 | 521 | |
522 | - case 'status': |
|
522 | + case 'status': |
|
523 | 523 | |
524 | - $status = $payment->get_status_nicename(); |
|
525 | - if ( is_admin() ) { |
|
526 | - $status = $payment->get_status_label_html(); |
|
527 | - } |
|
524 | + $status = $payment->get_status_nicename(); |
|
525 | + if ( is_admin() ) { |
|
526 | + $status = $payment->get_status_label_html(); |
|
527 | + } |
|
528 | 528 | |
529 | - echo $status; |
|
530 | - break; |
|
529 | + echo $status; |
|
530 | + break; |
|
531 | 531 | |
532 | - case 'invoice': |
|
533 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
532 | + case 'invoice': |
|
533 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
534 | 534 | |
535 | - if ( ! is_admin() ) { |
|
536 | - $link = esc_url( $payment->get_view_url() ); |
|
537 | - } |
|
535 | + if ( ! is_admin() ) { |
|
536 | + $link = esc_url( $payment->get_view_url() ); |
|
537 | + } |
|
538 | 538 | |
539 | - $invoice = esc_html( $payment->get_number() ); |
|
540 | - echo "<a href='$link'>$invoice</a>"; |
|
541 | - break; |
|
542 | - } |
|
539 | + $invoice = esc_html( $payment->get_number() ); |
|
540 | + echo "<a href='$link'>$invoice</a>"; |
|
541 | + break; |
|
542 | + } |
|
543 | 543 | |
544 | - echo '</td>'; |
|
544 | + echo '</td>'; |
|
545 | 545 | |
546 | - } |
|
546 | + } |
|
547 | 547 | |
548 | - echo '</tr>'; |
|
548 | + echo '</tr>'; |
|
549 | 549 | |
550 | - endforeach; |
|
551 | - ?> |
|
550 | + endforeach; |
|
551 | + ?> |
|
552 | 552 | |
553 | 553 | </tbody> |
554 | 554 | |
@@ -566,42 +566,42 @@ discard block |
||
566 | 566 | */ |
567 | 567 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
568 | 568 | |
569 | - // Fetch the subscription group. |
|
570 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
569 | + // Fetch the subscription group. |
|
570 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
571 | 571 | |
572 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
573 | - return; |
|
574 | - } |
|
572 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
573 | + return; |
|
574 | + } |
|
575 | 575 | |
576 | - // Prepare table columns. |
|
577 | - $columns = apply_filters( |
|
578 | - 'getpaid_subscription_item_details_columns', |
|
579 | - array( |
|
580 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
581 | - 'price' => __( 'Price', 'invoicing' ), |
|
582 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
583 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
584 | - //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
585 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
586 | - ), |
|
587 | - $subscription |
|
588 | - ); |
|
576 | + // Prepare table columns. |
|
577 | + $columns = apply_filters( |
|
578 | + 'getpaid_subscription_item_details_columns', |
|
579 | + array( |
|
580 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
581 | + 'price' => __( 'Price', 'invoicing' ), |
|
582 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
583 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
584 | + //'initial' => __( 'Initial Amount', 'invoicing' ), |
|
585 | + 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
586 | + ), |
|
587 | + $subscription |
|
588 | + ); |
|
589 | 589 | |
590 | - // Prepare the invoices. |
|
590 | + // Prepare the invoices. |
|
591 | 591 | |
592 | - $invoice = $subscription->get_parent_invoice(); |
|
592 | + $invoice = $subscription->get_parent_invoice(); |
|
593 | 593 | |
594 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
595 | - unset( $columns['tax'] ); |
|
596 | - } |
|
594 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
595 | + unset( $columns['tax'] ); |
|
596 | + } |
|
597 | 597 | |
598 | - $table_class = 'w-100 bg-white'; |
|
598 | + $table_class = 'w-100 bg-white'; |
|
599 | 599 | |
600 | - if ( ! is_admin() ) { |
|
601 | - $table_class = 'table table-bordered'; |
|
602 | - } |
|
600 | + if ( ! is_admin() ) { |
|
601 | + $table_class = 'table table-bordered'; |
|
602 | + } |
|
603 | 603 | |
604 | - ?> |
|
604 | + ?> |
|
605 | 605 | <div class="m-0" style="overflow: auto;"> |
606 | 606 | |
607 | 607 | <table class="<?php echo $table_class; ?>"> |
@@ -610,14 +610,14 @@ discard block |
||
610 | 610 | <tr> |
611 | 611 | <?php |
612 | 612 | |
613 | - foreach ( $columns as $key => $label ) { |
|
614 | - $key = esc_attr( $key ); |
|
615 | - $label = esc_html( $label ); |
|
616 | - $class = 'text-left'; |
|
613 | + foreach ( $columns as $key => $label ) { |
|
614 | + $key = esc_attr( $key ); |
|
615 | + $label = esc_html( $label ); |
|
616 | + $class = 'text-left'; |
|
617 | 617 | |
618 | - echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
619 | - } |
|
620 | - ?> |
|
618 | + echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
619 | + } |
|
620 | + ?> |
|
621 | 621 | </tr> |
622 | 622 | </thead> |
623 | 623 | |
@@ -625,106 +625,106 @@ discard block |
||
625 | 625 | |
626 | 626 | <?php |
627 | 627 | |
628 | - foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
628 | + foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
629 | 629 | |
630 | - echo '<tr>'; |
|
630 | + echo '<tr>'; |
|
631 | 631 | |
632 | - foreach ( array_keys( $columns ) as $key ) { |
|
632 | + foreach ( array_keys( $columns ) as $key ) { |
|
633 | 633 | |
634 | - $class = 'text-left'; |
|
634 | + $class = 'text-left'; |
|
635 | 635 | |
636 | - echo "<td class='p-2 $class'>"; |
|
636 | + echo "<td class='p-2 $class'>"; |
|
637 | 637 | |
638 | - switch( $key ) { |
|
638 | + switch( $key ) { |
|
639 | 639 | |
640 | - case 'item_name': |
|
641 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
642 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
640 | + case 'item_name': |
|
641 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
642 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
643 | 643 | |
644 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
645 | - echo esc_html( $item_name ); |
|
646 | - } else { |
|
647 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
648 | - } |
|
644 | + if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
645 | + echo esc_html( $item_name ); |
|
646 | + } else { |
|
647 | + printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
648 | + } |
|
649 | 649 | |
650 | - break; |
|
650 | + break; |
|
651 | 651 | |
652 | - case 'price': |
|
653 | - echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
654 | - break; |
|
652 | + case 'price': |
|
653 | + echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
654 | + break; |
|
655 | 655 | |
656 | - case 'tax': |
|
657 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
658 | - break; |
|
656 | + case 'tax': |
|
657 | + echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
658 | + break; |
|
659 | 659 | |
660 | - case 'discount': |
|
661 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
662 | - break; |
|
660 | + case 'discount': |
|
661 | + echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
662 | + break; |
|
663 | 663 | |
664 | - case 'initial': |
|
665 | - echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
666 | - break; |
|
664 | + case 'initial': |
|
665 | + echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
666 | + break; |
|
667 | 667 | |
668 | - case 'recurring': |
|
669 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
670 | - break; |
|
668 | + case 'recurring': |
|
669 | + echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
670 | + break; |
|
671 | 671 | |
672 | - } |
|
672 | + } |
|
673 | 673 | |
674 | - echo '</td>'; |
|
674 | + echo '</td>'; |
|
675 | 675 | |
676 | - } |
|
676 | + } |
|
677 | 677 | |
678 | - echo '</tr>'; |
|
678 | + echo '</tr>'; |
|
679 | 679 | |
680 | - endforeach; |
|
680 | + endforeach; |
|
681 | 681 | |
682 | - foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
682 | + foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
683 | 683 | |
684 | - echo '<tr>'; |
|
684 | + echo '<tr>'; |
|
685 | 685 | |
686 | - foreach ( array_keys( $columns ) as $key ) { |
|
686 | + foreach ( array_keys( $columns ) as $key ) { |
|
687 | 687 | |
688 | - $class = 'text-left'; |
|
688 | + $class = 'text-left'; |
|
689 | 689 | |
690 | - echo "<td class='p-2 $class'>"; |
|
690 | + echo "<td class='p-2 $class'>"; |
|
691 | 691 | |
692 | - switch( $key ) { |
|
692 | + switch( $key ) { |
|
693 | 693 | |
694 | - case 'item_name': |
|
695 | - echo esc_html( $subscription_group_fee['name'] ); |
|
696 | - break; |
|
694 | + case 'item_name': |
|
695 | + echo esc_html( $subscription_group_fee['name'] ); |
|
696 | + break; |
|
697 | 697 | |
698 | - case 'price': |
|
699 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
700 | - break; |
|
698 | + case 'price': |
|
699 | + echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
700 | + break; |
|
701 | 701 | |
702 | - case 'tax': |
|
703 | - echo "—"; |
|
704 | - break; |
|
702 | + case 'tax': |
|
703 | + echo "—"; |
|
704 | + break; |
|
705 | 705 | |
706 | - case 'discount': |
|
707 | - echo "—"; |
|
708 | - break; |
|
706 | + case 'discount': |
|
707 | + echo "—"; |
|
708 | + break; |
|
709 | 709 | |
710 | - case 'initial': |
|
711 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
712 | - break; |
|
710 | + case 'initial': |
|
711 | + echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
712 | + break; |
|
713 | 713 | |
714 | - case 'recurring': |
|
715 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
716 | - break; |
|
714 | + case 'recurring': |
|
715 | + echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
716 | + break; |
|
717 | 717 | |
718 | - } |
|
718 | + } |
|
719 | 719 | |
720 | - echo '</td>'; |
|
720 | + echo '</td>'; |
|
721 | 721 | |
722 | - } |
|
722 | + } |
|
723 | 723 | |
724 | - echo '</tr>'; |
|
724 | + echo '</tr>'; |
|
725 | 725 | |
726 | - endforeach; |
|
727 | - ?> |
|
726 | + endforeach; |
|
727 | + ?> |
|
728 | 728 | |
729 | 729 | </tbody> |
730 | 730 | |
@@ -743,38 +743,38 @@ discard block |
||
743 | 743 | */ |
744 | 744 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
745 | 745 | |
746 | - // Fetch the subscription groups. |
|
747 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
748 | - |
|
749 | - if ( empty( $subscription_groups ) ) { |
|
750 | - return; |
|
751 | - } |
|
752 | - |
|
753 | - // Prepare table columns. |
|
754 | - $columns = apply_filters( |
|
755 | - 'getpaid_subscription_related_subscriptions_columns', |
|
756 | - array( |
|
757 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
758 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
759 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
760 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
761 | - 'item' => __( 'Items', 'invoicing' ), |
|
762 | - 'status' => __( 'Status', 'invoicing' ), |
|
763 | - ), |
|
764 | - $subscription |
|
765 | - ); |
|
766 | - |
|
767 | - if ( $subscription->get_status() == 'pending' ) { |
|
768 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
769 | - } |
|
770 | - |
|
771 | - $table_class = 'w-100 bg-white'; |
|
772 | - |
|
773 | - if ( ! is_admin() ) { |
|
774 | - $table_class = 'table table-bordered'; |
|
775 | - } |
|
776 | - |
|
777 | - ?> |
|
746 | + // Fetch the subscription groups. |
|
747 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
748 | + |
|
749 | + if ( empty( $subscription_groups ) ) { |
|
750 | + return; |
|
751 | + } |
|
752 | + |
|
753 | + // Prepare table columns. |
|
754 | + $columns = apply_filters( |
|
755 | + 'getpaid_subscription_related_subscriptions_columns', |
|
756 | + array( |
|
757 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
758 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
759 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
760 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
761 | + 'item' => __( 'Items', 'invoicing' ), |
|
762 | + 'status' => __( 'Status', 'invoicing' ), |
|
763 | + ), |
|
764 | + $subscription |
|
765 | + ); |
|
766 | + |
|
767 | + if ( $subscription->get_status() == 'pending' ) { |
|
768 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
769 | + } |
|
770 | + |
|
771 | + $table_class = 'w-100 bg-white'; |
|
772 | + |
|
773 | + if ( ! is_admin() ) { |
|
774 | + $table_class = 'table table-bordered'; |
|
775 | + } |
|
776 | + |
|
777 | + ?> |
|
778 | 778 | <div class="m-0" style="overflow: auto;"> |
779 | 779 | |
780 | 780 | <table class="<?php echo $table_class; ?>"> |
@@ -783,14 +783,14 @@ discard block |
||
783 | 783 | <tr> |
784 | 784 | <?php |
785 | 785 | |
786 | - foreach ( $columns as $key => $label ) { |
|
787 | - $key = esc_attr( $key ); |
|
788 | - $label = esc_html( $label ); |
|
789 | - $class = 'text-left'; |
|
786 | + foreach ( $columns as $key => $label ) { |
|
787 | + $key = esc_attr( $key ); |
|
788 | + $label = esc_html( $label ); |
|
789 | + $class = 'text-left'; |
|
790 | 790 | |
791 | - echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
792 | - } |
|
793 | - ?> |
|
791 | + echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
792 | + } |
|
793 | + ?> |
|
794 | 794 | </tr> |
795 | 795 | </thead> |
796 | 796 | |
@@ -798,74 +798,74 @@ discard block |
||
798 | 798 | |
799 | 799 | <?php |
800 | 800 | |
801 | - foreach( $subscription_groups as $subscription_group ) : |
|
801 | + foreach( $subscription_groups as $subscription_group ) : |
|
802 | 802 | |
803 | - // Do not list current subscription. |
|
804 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
805 | - continue; |
|
806 | - } |
|
803 | + // Do not list current subscription. |
|
804 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
805 | + continue; |
|
806 | + } |
|
807 | 807 | |
808 | - // Ensure the subscription exists. |
|
809 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
808 | + // Ensure the subscription exists. |
|
809 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
810 | 810 | |
811 | - if ( ! $_suscription->exists() ) { |
|
812 | - continue; |
|
813 | - } |
|
811 | + if ( ! $_suscription->exists() ) { |
|
812 | + continue; |
|
813 | + } |
|
814 | 814 | |
815 | - echo '<tr>'; |
|
815 | + echo '<tr>'; |
|
816 | 816 | |
817 | - foreach ( array_keys( $columns ) as $key ) { |
|
817 | + foreach ( array_keys( $columns ) as $key ) { |
|
818 | 818 | |
819 | - $class = 'text-left'; |
|
819 | + $class = 'text-left'; |
|
820 | 820 | |
821 | - echo "<td class='p-2 $class'>"; |
|
821 | + echo "<td class='p-2 $class'>"; |
|
822 | 822 | |
823 | - switch( $key ) { |
|
823 | + switch( $key ) { |
|
824 | 824 | |
825 | - case 'status': |
|
826 | - echo $_suscription->get_status_label_html(); |
|
827 | - break; |
|
825 | + case 'status': |
|
826 | + echo $_suscription->get_status_label_html(); |
|
827 | + break; |
|
828 | 828 | |
829 | - case 'item': |
|
830 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
831 | - echo implode( ' | ', $markup ); |
|
832 | - break; |
|
829 | + case 'item': |
|
830 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
831 | + echo implode( ' | ', $markup ); |
|
832 | + break; |
|
833 | 833 | |
834 | - case 'renewals': |
|
835 | - $max_bills = $_suscription->get_bill_times(); |
|
836 | - echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
837 | - break; |
|
834 | + case 'renewals': |
|
835 | + $max_bills = $_suscription->get_bill_times(); |
|
836 | + echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
837 | + break; |
|
838 | 838 | |
839 | - case 'renewal_date': |
|
840 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
841 | - break; |
|
839 | + case 'renewal_date': |
|
840 | + echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
841 | + break; |
|
842 | 842 | |
843 | - case 'start_date': |
|
844 | - echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
845 | - break; |
|
843 | + case 'start_date': |
|
844 | + echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
845 | + break; |
|
846 | 846 | |
847 | - case 'subscription': |
|
848 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
849 | - printf( |
|
850 | - '%1$s#%2$s%3$s', |
|
851 | - '<a href="' . esc_url( $url ) . '">', |
|
852 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
853 | - '</a>' |
|
854 | - ); |
|
847 | + case 'subscription': |
|
848 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
849 | + printf( |
|
850 | + '%1$s#%2$s%3$s', |
|
851 | + '<a href="' . esc_url( $url ) . '">', |
|
852 | + '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
853 | + '</a>' |
|
854 | + ); |
|
855 | 855 | |
856 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
857 | - break; |
|
856 | + echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
857 | + break; |
|
858 | 858 | |
859 | - } |
|
859 | + } |
|
860 | 860 | |
861 | - echo '</td>'; |
|
861 | + echo '</td>'; |
|
862 | 862 | |
863 | - } |
|
863 | + } |
|
864 | 864 | |
865 | - echo '</tr>'; |
|
865 | + echo '</tr>'; |
|
866 | 866 | |
867 | - endforeach; |
|
868 | - ?> |
|
867 | + endforeach; |
|
868 | + ?> |
|
869 | 869 | |
870 | 870 | </tbody> |
871 | 871 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains functions that display the subscriptions admin page. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Render the Subscriptions page |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
21 | 21 | <div class="bsui"> |
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | 25 | // Verify user permissions. |
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
27 | 27 | |
28 | 28 | echo aui()->alert( |
29 | 29 | array( |
30 | 30 | 'type' => 'danger', |
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
32 | 32 | ) |
33 | 33 | ); |
34 | 34 | |
35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } else if (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
36 | 36 | |
37 | 37 | // Display a single subscription. |
38 | 38 | wpinv_recurring_subscription_details(); |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | function wpinv_recurring_subscription_details() { |
82 | 82 | |
83 | 83 | // Fetch the subscription. |
84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | - if ( ! $sub->exists() ) { |
|
84 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
85 | + if (!$sub->exists()) { |
|
86 | 86 | |
87 | 87 | echo aui()->alert( |
88 | 88 | array( |
89 | 89 | 'type' => 'danger', |
90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
90 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
91 | 91 | ) |
92 | 92 | ); |
93 | 93 | |
@@ -95,45 +95,45 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | // Use metaboxes to display the subscription details. |
98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
98 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
99 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
100 | 100 | |
101 | 101 | $subscription_id = $sub->get_id(); |
102 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
103 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
102 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
103 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
104 | 104 | |
105 | - if ( 1 < count( $subscription_groups ) ) { |
|
106 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
105 | + if (1 < count($subscription_groups)) { |
|
106 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
107 | 107 | } |
108 | 108 | |
109 | - if ( ! empty( $subscription_group ) ) { |
|
110 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
109 | + if (!empty($subscription_group)) { |
|
110 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
111 | 111 | } |
112 | 112 | |
113 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
113 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
114 | 114 | |
115 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
115 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
116 | 116 | |
117 | 117 | ?> |
118 | 118 | |
119 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
119 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
120 | 120 | |
121 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
122 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
123 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
121 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
122 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
123 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
124 | 124 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
125 | - <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" /> |
|
125 | + <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
|
126 | 126 | |
127 | 127 | <div id="poststuff"> |
128 | 128 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
129 | 129 | |
130 | 130 | <div id="postbox-container-1" class="postbox-container"> |
131 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
131 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
132 | 132 | </div> |
133 | 133 | |
134 | 134 | <div id="postbox-container-2" class="postbox-container"> |
135 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
136 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
135 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
136 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
137 | 137 | </div> |
138 | 138 | |
139 | 139 | </div> |
@@ -152,44 +152,44 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @param WPInv_Subscription $sub |
154 | 154 | */ |
155 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
155 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
156 | 156 | |
157 | 157 | // Subscription items. |
158 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
159 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
158 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
159 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
160 | 160 | |
161 | 161 | // Prepare subscription detail columns. |
162 | 162 | $fields = apply_filters( |
163 | 163 | 'getpaid_subscription_admin_page_fields', |
164 | 164 | array( |
165 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
166 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
167 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
168 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
169 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
170 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
171 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
172 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
173 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
174 | - 'status' => __( 'Status', 'invoicing' ), |
|
165 | + 'subscription' => __('Subscription', 'invoicing'), |
|
166 | + 'customer' => __('Customer', 'invoicing'), |
|
167 | + 'amount' => __('Amount', 'invoicing'), |
|
168 | + 'start_date' => __('Start Date', 'invoicing'), |
|
169 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
170 | + 'renewals' => __('Payments', 'invoicing'), |
|
171 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
172 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
173 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
174 | + 'status' => __('Status', 'invoicing'), |
|
175 | 175 | ) |
176 | 176 | ); |
177 | 177 | |
178 | - if ( ! $sub->is_active() ) { |
|
178 | + if (!$sub->is_active()) { |
|
179 | 179 | |
180 | - if ( isset( $fields['renews_on'] ) ) { |
|
181 | - unset( $fields['renews_on'] ); |
|
180 | + if (isset($fields['renews_on'])) { |
|
181 | + unset($fields['renews_on']); |
|
182 | 182 | } |
183 | 183 | |
184 | - if ( isset( $fields['gateway'] ) ) { |
|
185 | - unset( $fields['gateway'] ); |
|
184 | + if (isset($fields['gateway'])) { |
|
185 | + unset($fields['gateway']); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } |
189 | 189 | |
190 | 190 | $profile_id = $sub->get_profile_id(); |
191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
192 | - unset( $fields['profile_id'] ); |
|
191 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
192 | + unset($fields['profile_id']); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | ?> |
@@ -197,16 +197,16 @@ discard block |
||
197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
198 | 198 | <tbody> |
199 | 199 | |
200 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
200 | + <?php foreach ($fields as $key => $label) : ?> |
|
201 | 201 | |
202 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
202 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
203 | 203 | |
204 | 204 | <th class="w-25" style="font-weight: 500;"> |
205 | - <?php echo esc_html( $label ); ?> |
|
205 | + <?php echo esc_html($label); ?> |
|
206 | 206 | </th> |
207 | 207 | |
208 | 208 | <td class="w-75 text-muted"> |
209 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?> |
|
209 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?> |
|
210 | 210 | </td> |
211 | 211 | |
212 | 212 | </tr> |
@@ -224,129 +224,129 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @param WPInv_Subscription $subscription |
226 | 226 | */ |
227 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
227 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
228 | 228 | |
229 | - $username = __( '(Missing User)', 'invoicing' ); |
|
229 | + $username = __('(Missing User)', 'invoicing'); |
|
230 | 230 | |
231 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
232 | - if ( $user ) { |
|
231 | + $user = get_userdata($subscription->get_customer_id()); |
|
232 | + if ($user) { |
|
233 | 233 | |
234 | 234 | $username = sprintf( |
235 | 235 | '<a href="user-edit.php?user_id=%s">%s</a>', |
236 | - absint( $user->ID ), |
|
237 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
236 | + absint($user->ID), |
|
237 | + !empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email) |
|
238 | 238 | ); |
239 | 239 | |
240 | 240 | } |
241 | 241 | |
242 | 242 | echo $username; |
243 | 243 | } |
244 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
244 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
245 | 245 | |
246 | 246 | /** |
247 | 247 | * Displays the subscription amount. |
248 | 248 | * |
249 | 249 | * @param WPInv_Subscription $subscription |
250 | 250 | */ |
251 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
252 | - $amount = esc_html( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
251 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
252 | + $amount = esc_html(getpaid_get_formatted_subscription_amount($subscription)); |
|
253 | 253 | echo "<span>$amount</span>"; |
254 | 254 | } |
255 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
255 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Displays the subscription id. |
259 | 259 | * |
260 | 260 | * @param WPInv_Subscription $subscription |
261 | 261 | */ |
262 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
263 | - echo '#' . absint( $subscription->get_id() ); |
|
262 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
263 | + echo '#' . absint($subscription->get_id()); |
|
264 | 264 | } |
265 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
265 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Displays the subscription renewal date. |
269 | 269 | * |
270 | 270 | * @param WPInv_Subscription $subscription |
271 | 271 | */ |
272 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
273 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
272 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
273 | + echo getpaid_format_date_value($subscription->get_date_created()); |
|
274 | 274 | } |
275 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
275 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
276 | 276 | |
277 | 277 | /** |
278 | 278 | * Displays the subscription renewal date. |
279 | 279 | * |
280 | 280 | * @param WPInv_Subscription $subscription |
281 | 281 | */ |
282 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
283 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
282 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
283 | + echo getpaid_format_date_value($subscription->get_expiration()); |
|
284 | 284 | } |
285 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
285 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
286 | 286 | |
287 | 287 | /** |
288 | 288 | * Displays the subscription renewal count. |
289 | 289 | * |
290 | 290 | * @param WPInv_Subscription $subscription |
291 | 291 | */ |
292 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
292 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
293 | 293 | $max_bills = $subscription->get_bill_times(); |
294 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
294 | + echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
295 | 295 | } |
296 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
296 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
297 | 297 | /** |
298 | 298 | * Displays the subscription item. |
299 | 299 | * |
300 | 300 | * @param WPInv_Subscription $subscription |
301 | 301 | * @param false|array $subscription_group |
302 | 302 | */ |
303 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
303 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
304 | 304 | |
305 | - if ( empty( $subscription_group ) ) { |
|
306 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
305 | + if (empty($subscription_group)) { |
|
306 | + echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()); |
|
307 | 307 | return; |
308 | 308 | } |
309 | 309 | |
310 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
311 | - echo implode( ' | ', $markup ); |
|
310 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
311 | + echo implode(' | ', $markup); |
|
312 | 312 | |
313 | 313 | } |
314 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
314 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
315 | 315 | |
316 | 316 | /** |
317 | 317 | * Displays the subscription gateway. |
318 | 318 | * |
319 | 319 | * @param WPInv_Subscription $subscription |
320 | 320 | */ |
321 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
321 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
322 | 322 | |
323 | 323 | $gateway = $subscription->get_gateway(); |
324 | 324 | |
325 | - if ( ! empty( $gateway ) ) { |
|
326 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
325 | + if (!empty($gateway)) { |
|
326 | + echo esc_html(wpinv_get_gateway_admin_label($gateway)); |
|
327 | 327 | } else { |
328 | 328 | echo "—"; |
329 | 329 | } |
330 | 330 | |
331 | 331 | } |
332 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
332 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
333 | 333 | |
334 | 334 | /** |
335 | 335 | * Displays the subscription status. |
336 | 336 | * |
337 | 337 | * @param WPInv_Subscription $subscription |
338 | 338 | */ |
339 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
339 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
340 | 340 | echo $subscription->get_status_label_html(); |
341 | 341 | } |
342 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
342 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
343 | 343 | |
344 | 344 | /** |
345 | 345 | * Displays the subscription profile id. |
346 | 346 | * |
347 | 347 | * @param WPInv_Subscription $subscription |
348 | 348 | */ |
349 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
349 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
350 | 350 | |
351 | 351 | $profile_id = $subscription->get_profile_id(); |
352 | 352 | |
@@ -355,32 +355,32 @@ discard block |
||
355 | 355 | 'type' => 'text', |
356 | 356 | 'id' => 'wpinv_subscription_profile_id', |
357 | 357 | 'name' => 'wpinv_subscription_profile_id', |
358 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
358 | + 'label' => __('Profile Id', 'invoicing'), |
|
359 | 359 | 'label_type' => 'hidden', |
360 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
361 | - 'value' => esc_attr( $profile_id ), |
|
360 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
361 | + 'value' => esc_attr($profile_id), |
|
362 | 362 | 'input_group_right' => '', |
363 | 363 | 'no_wrap' => true, |
364 | 364 | ) |
365 | 365 | ); |
366 | 366 | |
367 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
367 | + echo str_ireplace('form-control', 'regular-text', $input); |
|
368 | 368 | |
369 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
370 | - if ( ! empty( $url ) ) { |
|
371 | - $url = esc_url_raw( $url ); |
|
372 | - echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
369 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
370 | + if (!empty($url)) { |
|
371 | + $url = esc_url_raw($url); |
|
372 | + echo ' <a href="' . $url . '" title="' . __('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | } |
376 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
376 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
377 | 377 | |
378 | 378 | /** |
379 | 379 | * Displays the subscriptions update metabox. |
380 | 380 | * |
381 | 381 | * @param WPInv_Subscription $subscription |
382 | 382 | */ |
383 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
383 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
384 | 384 | |
385 | 385 | ?> |
386 | 386 | <div class="mt-3"> |
@@ -393,10 +393,10 @@ discard block |
||
393 | 393 | 'id' => 'subscription_status_update_select', |
394 | 394 | 'required' => true, |
395 | 395 | 'no_wrap' => false, |
396 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
397 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
396 | + 'label' => __('Subscription Status', 'invoicing'), |
|
397 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
398 | 398 | 'select2' => true, |
399 | - 'value' => $subscription->get_status( 'edit' ), |
|
399 | + 'value' => $subscription->get_status('edit'), |
|
400 | 400 | ) |
401 | 401 | ); |
402 | 402 | ?> |
@@ -404,13 +404,13 @@ discard block |
||
404 | 404 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
405 | 405 | |
406 | 406 | <?php |
407 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
407 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
408 | 408 | |
409 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
410 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
411 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
409 | + $url = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce')); |
|
410 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
411 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
412 | 412 | |
413 | - if ( $subscription->is_active() ) { |
|
413 | + if ($subscription->is_active()) { |
|
414 | 414 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
415 | 415 | } |
416 | 416 | |
@@ -423,31 +423,31 @@ discard block |
||
423 | 423 | * @param WPInv_Subscription $subscription |
424 | 424 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
425 | 425 | */ |
426 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
426 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
427 | 427 | |
428 | 428 | $columns = apply_filters( |
429 | 429 | 'getpaid_subscription_related_invoices_columns', |
430 | 430 | array( |
431 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
432 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
433 | - 'date' => __( 'Date', 'invoicing' ), |
|
434 | - 'status' => __( 'Status', 'invoicing' ), |
|
435 | - 'total' => __( 'Total', 'invoicing' ), |
|
431 | + 'invoice' => __('Invoice', 'invoicing'), |
|
432 | + 'relationship' => __('Relationship', 'invoicing'), |
|
433 | + 'date' => __('Date', 'invoicing'), |
|
434 | + 'status' => __('Status', 'invoicing'), |
|
435 | + 'total' => __('Total', 'invoicing'), |
|
436 | 436 | ), |
437 | 437 | $subscription |
438 | 438 | ); |
439 | 439 | |
440 | 440 | // Prepare the invoices. |
441 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
441 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
442 | 442 | $parent = $subscription->get_parent_invoice(); |
443 | 443 | |
444 | - if ( $parent->exists() ) { |
|
445 | - $payments = array_merge( array( $parent ), $payments ); |
|
444 | + if ($parent->exists()) { |
|
445 | + $payments = array_merge(array($parent), $payments); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | $table_class = 'w-100 bg-white'; |
449 | 449 | |
450 | - if ( ! is_admin() ) { |
|
450 | + if (!is_admin()) { |
|
451 | 451 | $table_class = 'table table-bordered'; |
452 | 452 | } |
453 | 453 | |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | <thead> |
460 | 460 | <tr> |
461 | 461 | <?php |
462 | - foreach ( $columns as $key => $label ) { |
|
463 | - $key = esc_attr( $key ); |
|
464 | - $label = esc_html( $label ); |
|
462 | + foreach ($columns as $key => $label) { |
|
463 | + $key = esc_attr($key); |
|
464 | + $label = esc_html($label); |
|
465 | 465 | $class = 'text-left'; |
466 | 466 | |
467 | 467 | echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -472,57 +472,57 @@ discard block |
||
472 | 472 | |
473 | 473 | <tbody> |
474 | 474 | |
475 | - <?php if ( empty( $payments ) ) : ?> |
|
475 | + <?php if (empty($payments)) : ?> |
|
476 | 476 | <tr> |
477 | 477 | <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
478 | - <?php _e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
478 | + <?php _e('This subscription has no invoices.', 'invoicing'); ?> |
|
479 | 479 | </td> |
480 | 480 | </tr> |
481 | 481 | <?php endif; ?> |
482 | 482 | |
483 | 483 | <?php |
484 | 484 | |
485 | - foreach( $payments as $payment ) : |
|
485 | + foreach ($payments as $payment) : |
|
486 | 486 | |
487 | 487 | // Ensure that we have an invoice. |
488 | - $payment = new WPInv_Invoice( $payment ); |
|
488 | + $payment = new WPInv_Invoice($payment); |
|
489 | 489 | |
490 | 490 | // Abort if the invoice is invalid... |
491 | - if ( ! $payment->exists() ) { |
|
491 | + if (!$payment->exists()) { |
|
492 | 492 | continue; |
493 | 493 | } |
494 | 494 | |
495 | 495 | // ... or belongs to a different subscription. |
496 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
496 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
497 | 497 | continue; |
498 | 498 | } |
499 | 499 | |
500 | 500 | echo '<tr>'; |
501 | 501 | |
502 | - foreach ( array_keys( $columns ) as $key ) { |
|
502 | + foreach (array_keys($columns) as $key) { |
|
503 | 503 | |
504 | 504 | $class = 'text-left'; |
505 | 505 | |
506 | 506 | echo "<td class='p-2 $class'>"; |
507 | 507 | |
508 | - switch( $key ) { |
|
508 | + switch ($key) { |
|
509 | 509 | |
510 | 510 | case 'total': |
511 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
511 | + echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>'; |
|
512 | 512 | break; |
513 | 513 | |
514 | 514 | case 'relationship': |
515 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
515 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
516 | 516 | break; |
517 | 517 | |
518 | 518 | case 'date': |
519 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
519 | + echo getpaid_format_date_value($payment->get_date_created()); |
|
520 | 520 | break; |
521 | 521 | |
522 | 522 | case 'status': |
523 | 523 | |
524 | 524 | $status = $payment->get_status_nicename(); |
525 | - if ( is_admin() ) { |
|
525 | + if (is_admin()) { |
|
526 | 526 | $status = $payment->get_status_label_html(); |
527 | 527 | } |
528 | 528 | |
@@ -530,13 +530,13 @@ discard block |
||
530 | 530 | break; |
531 | 531 | |
532 | 532 | case 'invoice': |
533 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
533 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
534 | 534 | |
535 | - if ( ! is_admin() ) { |
|
536 | - $link = esc_url( $payment->get_view_url() ); |
|
535 | + if (!is_admin()) { |
|
536 | + $link = esc_url($payment->get_view_url()); |
|
537 | 537 | } |
538 | 538 | |
539 | - $invoice = esc_html( $payment->get_number() ); |
|
539 | + $invoice = esc_html($payment->get_number()); |
|
540 | 540 | echo "<a href='$link'>$invoice</a>"; |
541 | 541 | break; |
542 | 542 | } |
@@ -564,12 +564,12 @@ discard block |
||
564 | 564 | * |
565 | 565 | * @param WPInv_Subscription $subscription |
566 | 566 | */ |
567 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
567 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
568 | 568 | |
569 | 569 | // Fetch the subscription group. |
570 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
570 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
571 | 571 | |
572 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
572 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
573 | 573 | return; |
574 | 574 | } |
575 | 575 | |
@@ -577,12 +577,12 @@ discard block |
||
577 | 577 | $columns = apply_filters( |
578 | 578 | 'getpaid_subscription_item_details_columns', |
579 | 579 | array( |
580 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
581 | - 'price' => __( 'Price', 'invoicing' ), |
|
582 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
583 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
580 | + 'item_name' => __('Item', 'invoicing'), |
|
581 | + 'price' => __('Price', 'invoicing'), |
|
582 | + 'tax' => __('Tax', 'invoicing'), |
|
583 | + 'discount' => __('Discount', 'invoicing'), |
|
584 | 584 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
585 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
585 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
586 | 586 | ), |
587 | 587 | $subscription |
588 | 588 | ); |
@@ -591,13 +591,13 @@ discard block |
||
591 | 591 | |
592 | 592 | $invoice = $subscription->get_parent_invoice(); |
593 | 593 | |
594 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
595 | - unset( $columns['tax'] ); |
|
594 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
595 | + unset($columns['tax']); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | $table_class = 'w-100 bg-white'; |
599 | 599 | |
600 | - if ( ! is_admin() ) { |
|
600 | + if (!is_admin()) { |
|
601 | 601 | $table_class = 'table table-bordered'; |
602 | 602 | } |
603 | 603 | |
@@ -610,9 +610,9 @@ discard block |
||
610 | 610 | <tr> |
611 | 611 | <?php |
612 | 612 | |
613 | - foreach ( $columns as $key => $label ) { |
|
614 | - $key = esc_attr( $key ); |
|
615 | - $label = esc_html( $label ); |
|
613 | + foreach ($columns as $key => $label) { |
|
614 | + $key = esc_attr($key); |
|
615 | + $label = esc_html($label); |
|
616 | 616 | $class = 'text-left'; |
617 | 617 | |
618 | 618 | echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -625,48 +625,48 @@ discard block |
||
625 | 625 | |
626 | 626 | <?php |
627 | 627 | |
628 | - foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
628 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
629 | 629 | |
630 | 630 | echo '<tr>'; |
631 | 631 | |
632 | - foreach ( array_keys( $columns ) as $key ) { |
|
632 | + foreach (array_keys($columns) as $key) { |
|
633 | 633 | |
634 | 634 | $class = 'text-left'; |
635 | 635 | |
636 | 636 | echo "<td class='p-2 $class'>"; |
637 | 637 | |
638 | - switch( $key ) { |
|
638 | + switch ($key) { |
|
639 | 639 | |
640 | 640 | case 'item_name': |
641 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
642 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
641 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
642 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
643 | 643 | |
644 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
645 | - echo esc_html( $item_name ); |
|
644 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
645 | + echo esc_html($item_name); |
|
646 | 646 | } else { |
647 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
647 | + printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | break; |
651 | 651 | |
652 | 652 | case 'price': |
653 | - echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
653 | + echo wpinv_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
654 | 654 | break; |
655 | 655 | |
656 | 656 | case 'tax': |
657 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
657 | + echo wpinv_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
658 | 658 | break; |
659 | 659 | |
660 | 660 | case 'discount': |
661 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
661 | + echo wpinv_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
662 | 662 | break; |
663 | 663 | |
664 | 664 | case 'initial': |
665 | - echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
665 | + echo wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
666 | 666 | break; |
667 | 667 | |
668 | 668 | case 'recurring': |
669 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
669 | + echo '<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'; |
|
670 | 670 | break; |
671 | 671 | |
672 | 672 | } |
@@ -679,24 +679,24 @@ discard block |
||
679 | 679 | |
680 | 680 | endforeach; |
681 | 681 | |
682 | - foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
682 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
683 | 683 | |
684 | 684 | echo '<tr>'; |
685 | 685 | |
686 | - foreach ( array_keys( $columns ) as $key ) { |
|
686 | + foreach (array_keys($columns) as $key) { |
|
687 | 687 | |
688 | 688 | $class = 'text-left'; |
689 | 689 | |
690 | 690 | echo "<td class='p-2 $class'>"; |
691 | 691 | |
692 | - switch( $key ) { |
|
692 | + switch ($key) { |
|
693 | 693 | |
694 | 694 | case 'item_name': |
695 | - echo esc_html( $subscription_group_fee['name'] ); |
|
695 | + echo esc_html($subscription_group_fee['name']); |
|
696 | 696 | break; |
697 | 697 | |
698 | 698 | case 'price': |
699 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
699 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
700 | 700 | break; |
701 | 701 | |
702 | 702 | case 'tax': |
@@ -708,11 +708,11 @@ discard block |
||
708 | 708 | break; |
709 | 709 | |
710 | 710 | case 'initial': |
711 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
711 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
712 | 712 | break; |
713 | 713 | |
714 | 714 | case 'recurring': |
715 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
715 | + echo '<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'; |
|
716 | 716 | break; |
717 | 717 | |
718 | 718 | } |
@@ -741,12 +741,12 @@ discard block |
||
741 | 741 | * @param WPInv_Subscription $subscription |
742 | 742 | * @param bool $skip_current |
743 | 743 | */ |
744 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
744 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
745 | 745 | |
746 | 746 | // Fetch the subscription groups. |
747 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
747 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
748 | 748 | |
749 | - if ( empty( $subscription_groups ) ) { |
|
749 | + if (empty($subscription_groups)) { |
|
750 | 750 | return; |
751 | 751 | } |
752 | 752 | |
@@ -754,23 +754,23 @@ discard block |
||
754 | 754 | $columns = apply_filters( |
755 | 755 | 'getpaid_subscription_related_subscriptions_columns', |
756 | 756 | array( |
757 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
758 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
759 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
760 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
761 | - 'item' => __( 'Items', 'invoicing' ), |
|
762 | - 'status' => __( 'Status', 'invoicing' ), |
|
757 | + 'subscription' => __('Subscription', 'invoicing'), |
|
758 | + 'start_date' => __('Start Date', 'invoicing'), |
|
759 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
760 | + 'renewals' => __('Payments', 'invoicing'), |
|
761 | + 'item' => __('Items', 'invoicing'), |
|
762 | + 'status' => __('Status', 'invoicing'), |
|
763 | 763 | ), |
764 | 764 | $subscription |
765 | 765 | ); |
766 | 766 | |
767 | - if ( $subscription->get_status() == 'pending' ) { |
|
768 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
767 | + if ($subscription->get_status() == 'pending') { |
|
768 | + unset($columns['start_date'], $columns['renewal_date']); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | $table_class = 'w-100 bg-white'; |
772 | 772 | |
773 | - if ( ! is_admin() ) { |
|
773 | + if (!is_admin()) { |
|
774 | 774 | $table_class = 'table table-bordered'; |
775 | 775 | } |
776 | 776 | |
@@ -783,9 +783,9 @@ discard block |
||
783 | 783 | <tr> |
784 | 784 | <?php |
785 | 785 | |
786 | - foreach ( $columns as $key => $label ) { |
|
787 | - $key = esc_attr( $key ); |
|
788 | - $label = esc_html( $label ); |
|
786 | + foreach ($columns as $key => $label) { |
|
787 | + $key = esc_attr($key); |
|
788 | + $label = esc_html($label); |
|
789 | 789 | $class = 'text-left'; |
790 | 790 | |
791 | 791 | echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -798,62 +798,62 @@ discard block |
||
798 | 798 | |
799 | 799 | <?php |
800 | 800 | |
801 | - foreach( $subscription_groups as $subscription_group ) : |
|
801 | + foreach ($subscription_groups as $subscription_group) : |
|
802 | 802 | |
803 | 803 | // Do not list current subscription. |
804 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
804 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
805 | 805 | continue; |
806 | 806 | } |
807 | 807 | |
808 | 808 | // Ensure the subscription exists. |
809 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
809 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
810 | 810 | |
811 | - if ( ! $_suscription->exists() ) { |
|
811 | + if (!$_suscription->exists()) { |
|
812 | 812 | continue; |
813 | 813 | } |
814 | 814 | |
815 | 815 | echo '<tr>'; |
816 | 816 | |
817 | - foreach ( array_keys( $columns ) as $key ) { |
|
817 | + foreach (array_keys($columns) as $key) { |
|
818 | 818 | |
819 | 819 | $class = 'text-left'; |
820 | 820 | |
821 | 821 | echo "<td class='p-2 $class'>"; |
822 | 822 | |
823 | - switch( $key ) { |
|
823 | + switch ($key) { |
|
824 | 824 | |
825 | 825 | case 'status': |
826 | 826 | echo $_suscription->get_status_label_html(); |
827 | 827 | break; |
828 | 828 | |
829 | 829 | case 'item': |
830 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
831 | - echo implode( ' | ', $markup ); |
|
830 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
831 | + echo implode(' | ', $markup); |
|
832 | 832 | break; |
833 | 833 | |
834 | 834 | case 'renewals': |
835 | 835 | $max_bills = $_suscription->get_bill_times(); |
836 | - echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
836 | + echo $_suscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
837 | 837 | break; |
838 | 838 | |
839 | 839 | case 'renewal_date': |
840 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
840 | + echo $_suscription->is_active() ? getpaid_format_date_value($_suscription->get_expiration()) : "—"; |
|
841 | 841 | break; |
842 | 842 | |
843 | 843 | case 'start_date': |
844 | - echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
844 | + echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value($_suscription->get_date_created()); |
|
845 | 845 | break; |
846 | 846 | |
847 | 847 | case 'subscription': |
848 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
848 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
849 | 849 | printf( |
850 | 850 | '%1$s#%2$s%3$s', |
851 | - '<a href="' . esc_url( $url ) . '">', |
|
852 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
851 | + '<a href="' . esc_url($url) . '">', |
|
852 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
853 | 853 | '</a>' |
854 | 854 | ); |
855 | 855 | |
856 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
856 | + echo WPInv_Subscriptions_List_Table::column_amount($_suscription); |
|
857 | 857 | break; |
858 | 858 | |
859 | 859 | } |
@@ -4,29 +4,29 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | $gateways = wpinv_get_payment_gateways(); |
10 | -ksort( $gateways ); |
|
10 | +ksort($gateways); |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | <div class="table-responsive"> |
14 | 14 | <table id="wpinv_gateways_select" class="table border bg-white form-table"> |
15 | - <caption><?php echo esc_html_e( 'This table displays installed payment methods.', 'invoicing' ); ?></caption> |
|
15 | + <caption><?php echo esc_html_e('This table displays installed payment methods.', 'invoicing'); ?></caption> |
|
16 | 16 | |
17 | 17 | <thead> |
18 | 18 | <tr class="table-light"> |
19 | 19 | |
20 | 20 | <th scope="col" class="border-bottom border-top text-left"> |
21 | - <?php _e( 'Payment Method', 'invoicing' ); ?> |
|
21 | + <?php _e('Payment Method', 'invoicing'); ?> |
|
22 | 22 | </th> |
23 | 23 | |
24 | 24 | <th scope="col" class="border-bottom border-top text-center"> |
25 | - <?php _e( 'Enabled', 'invoicing' ); ?> |
|
25 | + <?php _e('Enabled', 'invoicing'); ?> |
|
26 | 26 | </th> |
27 | 27 | |
28 | 28 | <th scope="col" class="border-bottom border-top text-center"> |
29 | - <?php _e( 'Supports Subscriptions', 'invoicing' ); ?> |
|
29 | + <?php _e('Supports Subscriptions', 'invoicing'); ?> |
|
30 | 30 | </th> |
31 | 31 | |
32 | 32 | <th scope="col" class="border-bottom border-top text-right" style="width:32px"> </th> |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | </thead> |
36 | 36 | |
37 | 37 | <tbody> |
38 | - <?php foreach ( $gateways as $id => $gateway ) : ?> |
|
38 | + <?php foreach ($gateways as $id => $gateway) : ?> |
|
39 | 39 | <tr> |
40 | 40 | <td class="getpaid-payment-method text-left"> |
41 | - <a style="color: #0073aa;" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>" class="font-weight-bold"><?php echo esc_html( $gateway['admin_label'] ); ?></a> |
|
41 | + <a style="color: #0073aa;" href="<?php echo esc_url(add_query_arg('section', $id)); ?>" class="font-weight-bold"><?php echo esc_html($gateway['admin_label']); ?></a> |
|
42 | 42 | </td> |
43 | 43 | <td class="getpaid-payment-method-enabled text-center"> |
44 | 44 | <?php |
45 | 45 | |
46 | - if ( wpinv_is_gateway_active( $id ) ) { |
|
46 | + if (wpinv_is_gateway_active($id)) { |
|
47 | 47 | echo "<i class='text-success fa fa-check'></i>"; |
48 | 48 | } else { |
49 | 49 | echo "<i class='text-dark fa fa-times'></i>"; |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | <td class="getpaid-payment-method-subscription text-center"> |
55 | 55 | <?php |
56 | 56 | |
57 | - $supports = apply_filters( "wpinv_{$id}_support_subscription", false ); |
|
58 | - $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $id ); |
|
57 | + $supports = apply_filters("wpinv_{$id}_support_subscription", false); |
|
58 | + $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $id); |
|
59 | 59 | |
60 | - if ( $supports ) { |
|
60 | + if ($supports) { |
|
61 | 61 | echo "<i class='text-success fa fa-check'></i>"; |
62 | 62 | } else { |
63 | 63 | echo "<i class='text-dark fa fa-times'></i>"; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | </td> |
68 | 68 | |
69 | 69 | <td class="getpaid-payment-method-action text-right"> |
70 | - <a class="button button-secondary" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>"><?php _e( 'Manage', 'invoicing' ); ?></a> |
|
70 | + <a class="button button-secondary" href="<?php echo esc_url(add_query_arg('section', $id)); ?>"><?php _e('Manage', 'invoicing'); ?></a> |
|
71 | 71 | </td> |
72 | 72 | |
73 | 73 | </tr> |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | <tfoot> |
78 | 78 | <tr class="table-light"> |
79 | 79 | <td colspan="4" class="border-top"> |
80 | - <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url( admin_url( 'admin.php?page=wpi-addons&tab=gateways' ) ); ?>"> |
|
81 | - <span><?php _e( 'Add Payment Methods', 'invoicing' ); ?></span> |
|
80 | + <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url(admin_url('admin.php?page=wpi-addons&tab=gateways')); ?>"> |
|
81 | + <span><?php _e('Add Payment Methods', 'invoicing'); ?></span> |
|
82 | 82 | </a> |
83 | 83 | </td> |
84 | 84 | </tr> |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @var array $tax_rate |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | ?> |
12 | 12 | |
@@ -18,54 +18,54 @@ discard block |
||
18 | 18 | $country = aui()->select( |
19 | 19 | array( |
20 | 20 | 'options' => array_merge( |
21 | - array( '' => __( 'All Countries', 'invoicing' ) ), |
|
21 | + array('' => __('All Countries', 'invoicing')), |
|
22 | 22 | wpinv_get_country_list() |
23 | 23 | ), |
24 | 24 | 'name' => "tax_rates[$key][country]", |
25 | - 'id' => uniqid( 'tax_rate_country' ), |
|
26 | - 'value' => esc_html( $tax_rate['country'] ), |
|
27 | - 'label' => __( 'Country', 'invoicing' ), |
|
25 | + 'id' => uniqid('tax_rate_country'), |
|
26 | + 'value' => esc_html($tax_rate['country']), |
|
27 | + 'label' => __('Country', 'invoicing'), |
|
28 | 28 | 'class' => 'wpinv_country', |
29 | 29 | 'no_wrap' => true, |
30 | 30 | ) |
31 | 31 | ); |
32 | 32 | |
33 | - echo str_replace( 'custom-select', '', $country ); |
|
33 | + echo str_replace('custom-select', '', $country); |
|
34 | 34 | ?> |
35 | 35 | </td> |
36 | 36 | |
37 | 37 | <td class="wpinv_tax_state"> |
38 | 38 | |
39 | 39 | <label class="w-100"> |
40 | - <span class="screen-reader-text"><?php _e( 'States', 'invoicing' ); ?></span> |
|
41 | - <input type="text" placeholder="<?php esc_attr_e( 'Apply to whole country', 'invoicing' ); ?>" name="tax_rates[<?php echo esc_attr( $key ) ?>][state]" value="<?php echo empty( $tax_rate['global'] ) ? esc_attr( $tax_rate['state'] ) : ''; ?>"/> |
|
40 | + <span class="screen-reader-text"><?php _e('States', 'invoicing'); ?></span> |
|
41 | + <input type="text" placeholder="<?php esc_attr_e('Apply to whole country', 'invoicing'); ?>" name="tax_rates[<?php echo esc_attr($key) ?>][state]" value="<?php echo empty($tax_rate['global']) ? esc_attr($tax_rate['state']) : ''; ?>"/> |
|
42 | 42 | </label> |
43 | 43 | |
44 | 44 | </td> |
45 | 45 | |
46 | 46 | <td class="wpinv_standard_rate"> |
47 | 47 | <label class="w-100"> |
48 | - <span class="screen-reader-text"><?php _e( 'Standard Rate', 'invoicing' ); ?></span> |
|
49 | - <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ) ?>][rate]" value="<?php echo wpinv_sanitize_amount( $tax_rate['rate'] ); ?>"/> |
|
48 | + <span class="screen-reader-text"><?php _e('Standard Rate', 'invoicing'); ?></span> |
|
49 | + <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key) ?>][rate]" value="<?php echo wpinv_sanitize_amount($tax_rate['rate']); ?>"/> |
|
50 | 50 | </label> |
51 | 51 | </td> |
52 | 52 | |
53 | 53 | <td class="wpinv_reduced_rate"> |
54 | 54 | <label class="w-100"> |
55 | - <span class="screen-reader-text"><?php _e( 'Reduced Rate', 'invoicing' ); ?></span> |
|
56 | - <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ) ?>][reduced_rate]" value="<?php echo wpinv_sanitize_amount( $tax_rate['reduced_rate'] ); ?>"/> |
|
55 | + <span class="screen-reader-text"><?php _e('Reduced Rate', 'invoicing'); ?></span> |
|
56 | + <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key) ?>][reduced_rate]" value="<?php echo wpinv_sanitize_amount($tax_rate['reduced_rate']); ?>"/> |
|
57 | 57 | </label> |
58 | 58 | </td> |
59 | 59 | |
60 | 60 | <td class="wpinv_tax_name"> |
61 | 61 | <label class="w-100"> |
62 | - <span class="screen-reader-text"><?php _e( 'Tax Name', 'invoicing' ); ?></span> |
|
63 | - <input type="text" name="tax_rates[<?php echo esc_attr( $key ) ?>][name]" value="<?php echo esc_attr( $tax_rate['name'] ); ?>"/> |
|
62 | + <span class="screen-reader-text"><?php _e('Tax Name', 'invoicing'); ?></span> |
|
63 | + <input type="text" name="tax_rates[<?php echo esc_attr($key) ?>][name]" value="<?php echo esc_attr($tax_rate['name']); ?>"/> |
|
64 | 64 | </label> |
65 | 65 | </td> |
66 | 66 | |
67 | 67 | <td class="wpinv_tax_remove"> |
68 | - <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>" title="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>"> |
|
68 | + <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e('Delete', 'invoicing'); ?>" title="<?php esc_attr_e('Delete', 'invoicing'); ?>"> |
|
69 | 69 | <span aria-hidden="true">×</span> |
70 | 70 | </button> |
71 | 71 | </td> |
@@ -7,36 +7,36 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Cart table columns. |
13 | 13 | $columns = array( |
14 | - 'name' => __( 'Item', 'invoicing' ), |
|
15 | - 'price' => __( 'Price', 'invoicing' ), |
|
16 | - 'quantity' => __( 'Qty', 'invoicing' ), |
|
17 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
14 | + 'name' => __('Item', 'invoicing'), |
|
15 | + 'price' => __('Price', 'invoicing'), |
|
16 | + 'quantity' => __('Qty', 'invoicing'), |
|
17 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
18 | 18 | ); |
19 | 19 | |
20 | -if ( ! empty( $form->invoice ) ) { |
|
21 | - $columns = getpaid_invoice_item_columns( $form->invoice ); |
|
20 | +if (!empty($form->invoice)) { |
|
21 | + $columns = getpaid_invoice_item_columns($form->invoice); |
|
22 | 22 | } |
23 | 23 | |
24 | -if ( isset( $columns['tax_rate'] ) ) { |
|
25 | - unset( $columns['tax_rate'] ); |
|
24 | +if (isset($columns['tax_rate'])) { |
|
25 | + unset($columns['tax_rate']); |
|
26 | 26 | } |
27 | 27 | |
28 | -$columns = apply_filters( 'getpaid_payment_form_cart_table_columns', $columns, $form ); |
|
28 | +$columns = apply_filters('getpaid_payment_form_cart_table_columns', $columns, $form); |
|
29 | 29 | |
30 | -do_action( 'getpaid_before_payment_form_cart', $form ); |
|
30 | +do_action('getpaid_before_payment_form_cart', $form); |
|
31 | 31 | |
32 | 32 | ?> |
33 | 33 | <div class="getpaid-payment-form-items-cart border form-group"> |
34 | 34 | |
35 | 35 | <div class="getpaid-payment-form-items-cart-header font-weight-bold bg-light border-bottom py-2 px-3"> |
36 | 36 | <div class="form-row"> |
37 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
38 | - <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>"> |
|
39 | - <span><?php echo esc_html( $label ); ?></span> |
|
37 | + <?php foreach ($columns as $key => $label) : ?> |
|
38 | + <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>"> |
|
39 | + <span><?php echo esc_html($label); ?></span> |
|
40 | 40 | </div> |
41 | 41 | <?php endforeach; ?> |
42 | 42 | </div> |
@@ -45,16 +45,16 @@ discard block |
||
45 | 45 | <?php |
46 | 46 | |
47 | 47 | // Display the item totals. |
48 | - foreach ( $form->get_items() as $item ) { |
|
49 | - wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) ); |
|
48 | + foreach ($form->get_items() as $item) { |
|
49 | + wpinv_get_template('payment-forms/cart-item.php', compact('form', 'item', 'columns')); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | // Display the cart totals. |
53 | - wpinv_get_template( 'payment-forms/cart-totals.php', compact( 'form' ) ); |
|
53 | + wpinv_get_template('payment-forms/cart-totals.php', compact('form')); |
|
54 | 54 | |
55 | 55 | ?> |
56 | 56 | </div> |
57 | 57 | |
58 | 58 | <?php |
59 | 59 | |
60 | -do_action( 'getpaid_after_payment_form_cart', $form ); |
|
60 | +do_action('getpaid_after_payment_form_cart', $form); |
@@ -7,35 +7,35 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Ensure that we have options. |
13 | -if ( empty( $options ) ) { |
|
13 | +if (empty($options)) { |
|
14 | 14 | return; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Prepare price options. |
18 | -$options = getpaid_convert_price_string_to_options( $options ); |
|
19 | -$keys = array_keys( $options ); |
|
20 | -$value = empty( $options ) ? '' : $keys[0]; |
|
18 | +$options = getpaid_convert_price_string_to_options($options); |
|
19 | +$keys = array_keys($options); |
|
20 | +$value = empty($options) ? '' : $keys[0]; |
|
21 | 21 | |
22 | 22 | // Prepare id. |
23 | -$id = esc_attr( $id ); |
|
23 | +$id = esc_attr($id); |
|
24 | 24 | |
25 | -$select_type = empty( $select_type ) ? 'select' : $select_type; |
|
25 | +$select_type = empty($select_type) ? 'select' : $select_type; |
|
26 | 26 | |
27 | 27 | // Item select; |
28 | -if ( $select_type == 'select' ) { |
|
28 | +if ($select_type == 'select') { |
|
29 | 29 | echo aui()->select( |
30 | 30 | array( |
31 | 31 | 'name' => $id, |
32 | - 'id' => $id . uniqid( '_' ), |
|
33 | - 'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
32 | + 'id' => $id . uniqid('_'), |
|
33 | + 'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder), |
|
34 | 34 | 'value' => $value, |
35 | - 'label' => empty( $label ) ? '' : esc_html( $label ), |
|
35 | + 'label' => empty($label) ? '' : esc_html($label), |
|
36 | 36 | 'label_type' => 'vertical', |
37 | 37 | 'class' => 'getpaid-price-select-dropdown getpaid-refresh-on-change', |
38 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
38 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
39 | 39 | 'options' => $options, |
40 | 40 | ) |
41 | 41 | ); |
@@ -43,18 +43,18 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | // Item radios; |
46 | -if ( $select_type == 'radios' ) { |
|
46 | +if ($select_type == 'radios') { |
|
47 | 47 | echo aui()->radio( |
48 | 48 | array( |
49 | - 'name' => esc_attr( $id ), |
|
50 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
51 | - 'label' => empty( $label ) ? '' : esc_html( $label ), |
|
49 | + 'name' => esc_attr($id), |
|
50 | + 'id' => esc_attr($id) . uniqid('_'), |
|
51 | + 'label' => empty($label) ? '' : esc_html($label), |
|
52 | 52 | 'label_type' => 'vertical', |
53 | 53 | 'class' => 'getpaid-price-select-radio getpaid-refresh-on-change w-100', |
54 | 54 | 'value' => $value, |
55 | 55 | 'inline' => false, |
56 | 56 | 'options' => $options, |
57 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
57 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
58 | 58 | ) |
59 | 59 | ); |
60 | 60 | return; |
@@ -62,30 +62,30 @@ discard block |
||
62 | 62 | |
63 | 63 | |
64 | 64 | // Display the label. |
65 | -if ( ! empty( $label ) ) { |
|
66 | - $label = esc_html( $label ); |
|
65 | +if (!empty($label)) { |
|
66 | + $label = esc_html($label); |
|
67 | 67 | echo "<label>$label</label>"; |
68 | 68 | } |
69 | 69 | |
70 | 70 | // Item buttons; |
71 | -if ( $select_type == 'buttons' || $select_type == 'circles' ) { |
|
71 | +if ($select_type == 'buttons' || $select_type == 'circles') { |
|
72 | 72 | |
73 | 73 | $class = 'getpaid-price-buttons'; |
74 | 74 | |
75 | - if ( $select_type == 'circles' ) { |
|
75 | + if ($select_type == 'circles') { |
|
76 | 76 | $class .= ' getpaid-price-circles'; |
77 | 77 | } |
78 | 78 | echo "<div class='$class'>"; |
79 | 79 | |
80 | - foreach ( $options as $price => $label ) { |
|
81 | - $label = esc_html( $label ); |
|
82 | - $price = esc_attr( $price ); |
|
83 | - $_id = $id . uniqid( '_' ); |
|
84 | - $checked = checked( $price, $value, false ); |
|
80 | + foreach ($options as $price => $label) { |
|
81 | + $label = esc_html($label); |
|
82 | + $price = esc_attr($price); |
|
83 | + $_id = $id . uniqid('_'); |
|
84 | + $checked = checked($price, $value, false); |
|
85 | 85 | |
86 | 86 | $class = 'rounded'; |
87 | 87 | |
88 | - if ( $select_type == 'circles' ) { |
|
88 | + if ($select_type == 'circles') { |
|
89 | 89 | $class = ''; |
90 | 90 | } |
91 | 91 | echo " |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | } |
102 | 102 | |
103 | 103 | // Item checkboxes; |
104 | -if ( $select_type == 'checkboxes' ) { |
|
104 | +if ($select_type == 'checkboxes') { |
|
105 | 105 | echo '<div class="form-group">'; |
106 | 106 | |
107 | - foreach ( $options as $price => $label ) { |
|
108 | - $label = esc_html( $label ); |
|
109 | - $price = esc_attr( $price ); |
|
110 | - $checked = checked( $price, $value, false ); |
|
107 | + foreach ($options as $price => $label) { |
|
108 | + $label = esc_html($label); |
|
109 | + $price = esc_attr($price); |
|
110 | + $checked = checked($price, $value, false); |
|
111 | 111 | echo " |
112 | 112 | <label class='d-block'> |
113 | 113 | <input type='checkbox' class='getpaid-price-select-checkbox getpaid-refresh-on-change w-auto' name='{$id}[]' value='$price' $checked /> |
@@ -120,6 +120,6 @@ discard block |
||
120 | 120 | |
121 | 121 | } |
122 | 122 | |
123 | -if ( ! empty( $description ) ) { |
|
123 | +if (!empty($description)) { |
|
124 | 124 | echo "<small class='form-text text-muted'>$description</small>"; |
125 | 125 | } |
@@ -7,16 +7,16 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -if ( empty( $text ) ) { |
|
13 | - $text = __( 'Your IP address is:', 'invoicing' ); |
|
12 | +if (empty($text)) { |
|
13 | + $text = __('Your IP address is:', 'invoicing'); |
|
14 | 14 | } |
15 | 15 | |
16 | -$ip_address = esc_html( wpinv_get_ip() ); |
|
16 | +$ip_address = esc_html(wpinv_get_ip()); |
|
17 | 17 | |
18 | 18 | ?> |
19 | 19 | <div class="form-group getpaid-ip-info"> |
20 | - <span><?php echo wp_kses_post( $text ); ?></span> |
|
20 | + <span><?php echo wp_kses_post($text); ?></span> |
|
21 | 21 | <strong><?php echo $ip_address; ?></strong> |
22 | 22 | </div> |
@@ -8,24 +8,24 @@ |
||
8 | 8 | * @var GetPaid_Payment_Form $form The current payment form |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | -if ( ! getpaid_has_published_discount() ) { |
|
13 | +if (!getpaid_has_published_discount()) { |
|
14 | 14 | return; |
15 | 15 | } |
16 | 16 | |
17 | -$placeholder = esc_attr( $input_label ); |
|
18 | -$label = esc_html( $button_label ); |
|
17 | +$placeholder = esc_attr($input_label); |
|
18 | +$label = esc_html($button_label); |
|
19 | 19 | |
20 | -if ( ! empty( $description ) ) { |
|
20 | +if (!empty($description)) { |
|
21 | 21 | $description = "<small class='form-text text-muted'>$description</small>"; |
22 | 22 | } else { |
23 | 23 | $description = ''; |
24 | 24 | } |
25 | 25 | |
26 | 26 | $discount_code = ''; |
27 | -if ( ! empty( $form->invoice ) ) { |
|
28 | - $discount_code = esc_attr( $form->invoice->get_discount_code() ); |
|
27 | +if (!empty($form->invoice)) { |
|
28 | + $discount_code = esc_attr($form->invoice->get_discount_code()); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | ?> |