@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | $args = wp_parse_args( |
58 | 58 | $args, |
59 | 59 | array( |
60 | - 'status' => array( 'publish' ), |
|
61 | - 'limit' => get_option( 'posts_per_page' ), |
|
62 | - 'page' => 1, |
|
63 | - 'exclude' => array(), |
|
64 | - 'orderby' => 'date', |
|
65 | - 'order' => 'DESC', |
|
66 | - 'type' => wpinv_item_types(), |
|
67 | - 'meta_query' => array( |
|
60 | + 'status' => array( 'publish' ), |
|
61 | + 'limit' => get_option( 'posts_per_page' ), |
|
62 | + 'page' => 1, |
|
63 | + 'exclude' => array(), |
|
64 | + 'orderby' => 'date', |
|
65 | + 'order' => 'DESC', |
|
66 | + 'type' => wpinv_item_types(), |
|
67 | + 'meta_query' => array( |
|
68 | 68 | array( |
69 | 69 | 'key' => '_wpinv_one_time', |
70 | 70 | 'compare' => 'NOT EXISTS', |
71 | 71 | ), |
72 | 72 | ), |
73 | - 'return' => 'objects', |
|
74 | - 'paginate' => false, |
|
73 | + 'return' => 'objects', |
|
74 | + 'paginate' => false, |
|
75 | 75 | ) |
76 | 76 | ); |
77 | 77 | |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | |
212 | 212 | function wpinv_get_item_types() { |
213 | 213 | $item_types = array( |
214 | - 'custom' => __( 'Standard', 'invoicing' ), |
|
215 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
216 | - ); |
|
214 | + 'custom' => __( 'Standard', 'invoicing' ), |
|
215 | + 'fee' => __( 'Fee', 'invoicing' ), |
|
216 | + ); |
|
217 | 217 | return apply_filters( 'wpinv_get_item_types', $item_types ); |
218 | 218 | } |
219 | 219 | |
@@ -255,16 +255,16 @@ discard block |
||
255 | 255 | $args = array(); |
256 | 256 | if ( $post_ids ) { |
257 | 257 | $args = array( |
258 | - 'fields' => 'ids', |
|
259 | - ); |
|
258 | + 'fields' => 'ids', |
|
259 | + ); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | $args = array_merge( |
263 | 263 | $args, |
264 | 264 | array( |
265 | 265 | 'post_type' => 'wpi_item', |
266 | - 'orderby' => 'rand', |
|
267 | - 'post_count' => $num, |
|
266 | + 'orderby' => 'rand', |
|
267 | + 'post_count' => $num, |
|
268 | 268 | 'meta_query' => array( |
269 | 269 | array( |
270 | 270 | 'key' => '_wpinv_one_time', |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | $bill_times_less = $bill_times - 1; |
440 | 440 | |
441 | 441 | if ( ! empty( $bill_times ) ) { |
442 | - $bill_times = $item->get_recurring_interval() * $bill_times; |
|
442 | + $bill_times = $item->get_recurring_interval() * $bill_times; |
|
443 | 443 | $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() ); |
444 | - $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
445 | - } |
|
444 | + $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
445 | + } |
|
446 | 446 | |
447 | 447 | if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) { |
448 | 448 | $initial_price = wpinv_price( $item->get_sub_total(), $currency ); |
@@ -587,19 +587,19 @@ discard block |
||
587 | 587 | * @return bool Whether the item type supports the given feature. |
588 | 588 | */ |
589 | 589 | function getpaid_item_type_supports( $item_type, $feature, $item_ID = 0 ) { |
590 | - $supports = false; |
|
590 | + $supports = false; |
|
591 | 591 | |
592 | - if ( ! is_scalar( $item_type ) ) { |
|
593 | - return $supports; |
|
594 | - } |
|
592 | + if ( ! is_scalar( $item_type ) ) { |
|
593 | + return $supports; |
|
594 | + } |
|
595 | 595 | |
596 | - switch ( $feature ) { |
|
597 | - case 'buy_now': |
|
598 | - if ( '' === $item_type || 'fee' === $item_type || 'custom' === $item_type ) { |
|
599 | - $supports = true; |
|
600 | - } |
|
601 | - break; |
|
602 | - } |
|
596 | + switch ( $feature ) { |
|
597 | + case 'buy_now': |
|
598 | + if ( '' === $item_type || 'fee' === $item_type || 'custom' === $item_type ) { |
|
599 | + $supports = true; |
|
600 | + } |
|
601 | + break; |
|
602 | + } |
|
603 | 603 | |
604 | - return apply_filters( 'getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID ); |
|
604 | + return apply_filters( 'getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID ); |
|
605 | 605 | } |
606 | 606 | \ No newline at end of file |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves an item by it's ID. |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | * @param int the item ID to retrieve. |
15 | 15 | * @return WPInv_Item|false |
16 | 16 | */ |
17 | -function wpinv_get_item_by_id( $id ) { |
|
18 | - $item = wpinv_get_item( $id ); |
|
19 | - return empty( $item ) || $id != $item->get_id() ? false : $item; |
|
17 | +function wpinv_get_item_by_id($id) { |
|
18 | + $item = wpinv_get_item($id); |
|
19 | + return empty($item) || $id != $item->get_id() ? false : $item; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return WPInv_Item|false |
26 | 26 | */ |
27 | -function wpinv_get_item_by( $field = '', $value = '', $type = '' ) { |
|
27 | +function wpinv_get_item_by($field = '', $value = '', $type = '') { |
|
28 | 28 | |
29 | - if ( 'id' === strtolower( $field ) ) { |
|
30 | - return wpinv_get_item_by_id( $value ); |
|
29 | + if ('id' === strtolower($field)) { |
|
30 | + return wpinv_get_item_by_id($value); |
|
31 | 31 | } |
32 | 32 | |
33 | - $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type ); |
|
34 | - return empty( $id ) ? false : wpinv_get_item( $id ); |
|
33 | + $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type); |
|
34 | + return empty($id) ? false : wpinv_get_item($id); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
@@ -41,24 +41,24 @@ discard block |
||
41 | 41 | * @param int|WPInv_Item the item to retrieve. |
42 | 42 | * @return WPInv_Item|false |
43 | 43 | */ |
44 | -function wpinv_get_item( $item = 0 ) { |
|
44 | +function wpinv_get_item($item = 0) { |
|
45 | 45 | |
46 | - if ( empty( $item ) ) { |
|
46 | + if (empty($item)) { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | |
50 | - $item = new WPInv_Item( $item ); |
|
50 | + $item = new WPInv_Item($item); |
|
51 | 51 | return $item->exists() ? $item : false; |
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | -function wpinv_get_all_items( $args = array() ) { |
|
55 | +function wpinv_get_all_items($args = array()) { |
|
56 | 56 | |
57 | 57 | $args = wp_parse_args( |
58 | 58 | $args, |
59 | 59 | array( |
60 | - 'status' => array( 'publish' ), |
|
61 | - 'limit' => get_option( 'posts_per_page' ), |
|
60 | + 'status' => array('publish'), |
|
61 | + 'limit' => get_option('posts_per_page'), |
|
62 | 62 | 'page' => 1, |
63 | 63 | 'exclude' => array(), |
64 | 64 | 'orderby' => 'date', |
@@ -83,44 +83,44 @@ discard block |
||
83 | 83 | 'fields' => 'ids', |
84 | 84 | 'orderby' => $args['orderby'], |
85 | 85 | 'order' => $args['order'], |
86 | - 'paged' => absint( $args['page'] ), |
|
86 | + 'paged' => absint($args['page']), |
|
87 | 87 | ); |
88 | 88 | |
89 | - if ( ! empty( $args['exclude'] ) ) { |
|
90 | - $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] ); |
|
89 | + if (!empty($args['exclude'])) { |
|
90 | + $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']); |
|
91 | 91 | } |
92 | 92 | |
93 | - if ( ! $args['paginate'] ) { |
|
93 | + if (!$args['paginate']) { |
|
94 | 94 | $wp_query_args['no_found_rows'] = true; |
95 | 95 | } |
96 | 96 | |
97 | - if ( ! empty( $args['search'] ) ) { |
|
97 | + if (!empty($args['search'])) { |
|
98 | 98 | $wp_query_args['s'] = $args['search']; |
99 | 99 | } |
100 | 100 | |
101 | - if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) { |
|
102 | - $types = wpinv_parse_list( $args['type'] ); |
|
101 | + if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) { |
|
102 | + $types = wpinv_parse_list($args['type']); |
|
103 | 103 | $wp_query_args['meta_query'][] = array( |
104 | 104 | 'key' => '_wpinv_type', |
105 | - 'value' => implode( ',', $types ), |
|
105 | + 'value' => implode(',', $types), |
|
106 | 106 | 'compare' => 'IN', |
107 | 107 | ); |
108 | 108 | } |
109 | 109 | |
110 | - $wp_query_args = apply_filters( 'wpinv_get_items_args', $wp_query_args, $args ); |
|
110 | + $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args); |
|
111 | 111 | |
112 | 112 | // Get results. |
113 | - $items = new WP_Query( $wp_query_args ); |
|
113 | + $items = new WP_Query($wp_query_args); |
|
114 | 114 | |
115 | - if ( 'objects' === $args['return'] ) { |
|
116 | - $return = array_map( 'wpinv_get_item_by_id', $items->posts ); |
|
117 | - } elseif ( 'self' === $args['return'] ) { |
|
115 | + if ('objects' === $args['return']) { |
|
116 | + $return = array_map('wpinv_get_item_by_id', $items->posts); |
|
117 | + } elseif ('self' === $args['return']) { |
|
118 | 118 | return $items; |
119 | 119 | } else { |
120 | 120 | $return = $items->posts; |
121 | 121 | } |
122 | 122 | |
123 | - if ( $args['paginate'] ) { |
|
123 | + if ($args['paginate']) { |
|
124 | 124 | return (object) array( |
125 | 125 | 'items' => $return, |
126 | 126 | 'total' => $items->found_posts, |
@@ -132,12 +132,12 @@ discard block |
||
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | -function wpinv_is_free_item( $item_id = 0 ) { |
|
136 | - if ( empty( $item_id ) ) { |
|
135 | +function wpinv_is_free_item($item_id = 0) { |
|
136 | + if (empty($item_id)) { |
|
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | |
140 | - $item = new WPInv_Item( $item_id ); |
|
140 | + $item = new WPInv_Item($item_id); |
|
141 | 141 | |
142 | 142 | return $item->is_free(); |
143 | 143 | } |
@@ -147,21 +147,21 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @param WP_Post|WPInv_Item|Int $item The item to check for. |
149 | 149 | */ |
150 | -function wpinv_item_is_editable( $item = 0 ) { |
|
150 | +function wpinv_item_is_editable($item = 0) { |
|
151 | 151 | |
152 | 152 | // Fetch the item. |
153 | - $item = new WPInv_Item( $item ); |
|
153 | + $item = new WPInv_Item($item); |
|
154 | 154 | |
155 | 155 | // Check if it is editable. |
156 | 156 | return $item->is_editable(); |
157 | 157 | } |
158 | 158 | |
159 | -function wpinv_get_item_price( $item_id = 0 ) { |
|
160 | - if ( empty( $item_id ) ) { |
|
159 | +function wpinv_get_item_price($item_id = 0) { |
|
160 | + if (empty($item_id)) { |
|
161 | 161 | return false; |
162 | 162 | } |
163 | 163 | |
164 | - $item = new WPInv_Item( $item_id ); |
|
164 | + $item = new WPInv_Item($item_id); |
|
165 | 165 | |
166 | 166 | return $item->get_price(); |
167 | 167 | } |
@@ -171,89 +171,89 @@ discard block |
||
171 | 171 | * |
172 | 172 | * @param WPInv_Item|int $item |
173 | 173 | */ |
174 | -function wpinv_is_recurring_item( $item = 0 ) { |
|
175 | - $item = new WPInv_Item( $item ); |
|
174 | +function wpinv_is_recurring_item($item = 0) { |
|
175 | + $item = new WPInv_Item($item); |
|
176 | 176 | return $item->is_recurring(); |
177 | 177 | } |
178 | 178 | |
179 | -function wpinv_item_price( $item_id = 0 ) { |
|
180 | - if ( empty( $item_id ) ) { |
|
179 | +function wpinv_item_price($item_id = 0) { |
|
180 | + if (empty($item_id)) { |
|
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | |
184 | - $price = wpinv_get_item_price( $item_id ); |
|
185 | - $price = wpinv_price( $price ); |
|
184 | + $price = wpinv_get_item_price($item_id); |
|
185 | + $price = wpinv_price($price); |
|
186 | 186 | |
187 | - return apply_filters( 'wpinv_item_price', $price, $item_id ); |
|
187 | + return apply_filters('wpinv_item_price', $price, $item_id); |
|
188 | 188 | } |
189 | 189 | |
190 | -function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) { |
|
191 | - if ( is_null( $amount_override ) ) { |
|
192 | - $original_price = get_post_meta( $item_id, '_wpinv_price', true ); |
|
190 | +function wpinv_get_item_final_price($item_id = 0, $amount_override = null) { |
|
191 | + if (is_null($amount_override)) { |
|
192 | + $original_price = get_post_meta($item_id, '_wpinv_price', true); |
|
193 | 193 | } else { |
194 | 194 | $original_price = $amount_override; |
195 | 195 | } |
196 | 196 | |
197 | 197 | $price = $original_price; |
198 | 198 | |
199 | - return apply_filters( 'wpinv_get_item_final_price', $price, $item_id ); |
|
199 | + return apply_filters('wpinv_get_item_final_price', $price, $item_id); |
|
200 | 200 | } |
201 | 201 | |
202 | -function wpinv_item_custom_singular_name( $item_id ) { |
|
203 | - if ( empty( $item_id ) ) { |
|
202 | +function wpinv_item_custom_singular_name($item_id) { |
|
203 | + if (empty($item_id)) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | |
207 | - $item = new WPInv_Item( $item_id ); |
|
207 | + $item = new WPInv_Item($item_id); |
|
208 | 208 | |
209 | 209 | return $item->get_custom_singular_name(); |
210 | 210 | } |
211 | 211 | |
212 | 212 | function wpinv_get_item_types() { |
213 | 213 | $item_types = array( |
214 | - 'custom' => __( 'Standard', 'invoicing' ), |
|
215 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
214 | + 'custom' => __('Standard', 'invoicing'), |
|
215 | + 'fee' => __('Fee', 'invoicing'), |
|
216 | 216 | ); |
217 | - return apply_filters( 'wpinv_get_item_types', $item_types ); |
|
217 | + return apply_filters('wpinv_get_item_types', $item_types); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | function wpinv_item_types() { |
221 | 221 | $item_types = wpinv_get_item_types(); |
222 | 222 | |
223 | - return ( ! empty( $item_types ) ? array_keys( $item_types ) : array() ); |
|
223 | + return (!empty($item_types) ? array_keys($item_types) : array()); |
|
224 | 224 | } |
225 | 225 | |
226 | -function wpinv_get_item_type( $item_id ) { |
|
227 | - if ( empty( $item_id ) ) { |
|
226 | +function wpinv_get_item_type($item_id) { |
|
227 | + if (empty($item_id)) { |
|
228 | 228 | return false; |
229 | 229 | } |
230 | 230 | |
231 | - $item = new WPInv_Item( $item_id ); |
|
231 | + $item = new WPInv_Item($item_id); |
|
232 | 232 | |
233 | 233 | return $item->get_type(); |
234 | 234 | } |
235 | 235 | |
236 | -function wpinv_item_type( $item_id ) { |
|
236 | +function wpinv_item_type($item_id) { |
|
237 | 237 | $item_types = wpinv_get_item_types(); |
238 | 238 | |
239 | - $item_type = wpinv_get_item_type( $item_id ); |
|
239 | + $item_type = wpinv_get_item_type($item_id); |
|
240 | 240 | |
241 | - if ( empty( $item_type ) ) { |
|
241 | + if (empty($item_type)) { |
|
242 | 242 | $item_type = '-'; |
243 | 243 | } |
244 | 244 | |
245 | - $item_type = isset( $item_types[ $item_type ] ) ? $item_types[ $item_type ] : __( $item_type, 'invoicing' ); |
|
245 | + $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing'); |
|
246 | 246 | |
247 | - return apply_filters( 'wpinv_item_type', $item_type, $item_id ); |
|
247 | + return apply_filters('wpinv_item_type', $item_type, $item_id); |
|
248 | 248 | } |
249 | 249 | |
250 | -function wpinv_get_random_item( $post_ids = true ) { |
|
251 | - wpinv_get_random_items( 1, $post_ids ); |
|
250 | +function wpinv_get_random_item($post_ids = true) { |
|
251 | + wpinv_get_random_items(1, $post_ids); |
|
252 | 252 | } |
253 | 253 | |
254 | -function wpinv_get_random_items( $num = 3, $post_ids = true ) { |
|
254 | +function wpinv_get_random_items($num = 3, $post_ids = true) { |
|
255 | 255 | $args = array(); |
256 | - if ( $post_ids ) { |
|
256 | + if ($post_ids) { |
|
257 | 257 | $args = array( |
258 | 258 | 'fields' => 'ids', |
259 | 259 | ); |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | ) |
275 | 275 | ); |
276 | 276 | |
277 | - $args = apply_filters( 'wpinv_get_random_items', $args ); |
|
277 | + $args = apply_filters('wpinv_get_random_items', $args); |
|
278 | 278 | |
279 | - return get_posts( $args ); |
|
279 | + return get_posts($args); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -285,13 +285,13 @@ discard block |
||
285 | 285 | * @param WPInv_Item|int $item |
286 | 286 | * @param bool $html |
287 | 287 | */ |
288 | -function wpinv_get_item_suffix( $item, $html = true ) { |
|
288 | +function wpinv_get_item_suffix($item, $html = true) { |
|
289 | 289 | |
290 | - $item = new WPInv_Item( $item ); |
|
291 | - $suffix = $item->is_recurring() ? ' ' . __( '(r)', 'invoicing' ) : ''; |
|
292 | - $suffix = $html ? $suffix : wp_strip_all_tags( $suffix ); |
|
290 | + $item = new WPInv_Item($item); |
|
291 | + $suffix = $item->is_recurring() ? ' ' . __('(r)', 'invoicing') : ''; |
|
292 | + $suffix = $html ? $suffix : wp_strip_all_tags($suffix); |
|
293 | 293 | |
294 | - return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html ); |
|
294 | + return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | * @param WPInv_Item|int $item |
301 | 301 | * @param bool $force_delete |
302 | 302 | */ |
303 | -function wpinv_remove_item( $item = 0, $force_delete = false ) { |
|
304 | - $item = new WPInv_Item( $item ); |
|
305 | - $item->delete( $force_delete ); |
|
303 | +function wpinv_remove_item($item = 0, $force_delete = false) { |
|
304 | + $item = new WPInv_Item($item); |
|
305 | + $item->delete($force_delete); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -341,44 +341,44 @@ discard block |
||
341 | 341 | * @param bool $wp_error whether or not to return a WP_Error on failure. |
342 | 342 | * @return bool|WP_Error|WPInv_Item |
343 | 343 | */ |
344 | -function wpinv_create_item( $args = array(), $wp_error = false ) { |
|
344 | +function wpinv_create_item($args = array(), $wp_error = false) { |
|
345 | 345 | |
346 | 346 | // Prepare the item. |
347 | - if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) { |
|
348 | - $type = empty( $args['type'] ) ? 'custom' : $args['type']; |
|
349 | - $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type ); |
|
347 | + if (!empty($args['custom_id']) && empty($args['ID'])) { |
|
348 | + $type = empty($args['type']) ? 'custom' : $args['type']; |
|
349 | + $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type); |
|
350 | 350 | |
351 | - if ( ! empty( $item ) ) { |
|
351 | + if (!empty($item)) { |
|
352 | 352 | $args['ID'] = $item->get_id(); |
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
356 | 356 | // Do we have an item? |
357 | - if ( ! empty( $args['ID'] ) ) { |
|
358 | - $item = new WPInv_Item( $args['ID'] ); |
|
357 | + if (!empty($args['ID'])) { |
|
358 | + $item = new WPInv_Item($args['ID']); |
|
359 | 359 | } else { |
360 | 360 | $item = new WPInv_Item(); |
361 | 361 | } |
362 | 362 | |
363 | 363 | // Do we have an error? |
364 | - if ( ! empty( $item->last_error ) ) { |
|
365 | - return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false; |
|
364 | + if (!empty($item->last_error)) { |
|
365 | + return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | // Update item props. |
369 | - $item->set_props( $args ); |
|
369 | + $item->set_props($args); |
|
370 | 370 | |
371 | 371 | // Save the item. |
372 | 372 | $item->save(); |
373 | 373 | |
374 | 374 | // Do we have an error? |
375 | - if ( ! empty( $item->last_error ) ) { |
|
376 | - return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false; |
|
375 | + if (!empty($item->last_error)) { |
|
376 | + return $wp_error ? new WP_Error('not_saved', $item->last_error) : false; |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | // Was the item saved? |
380 | - if ( ! $item->get_id() ) { |
|
381 | - return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false; |
|
380 | + if (!$item->get_id()) { |
|
381 | + return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false; |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | return $item; |
@@ -390,14 +390,14 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @see wpinv_create_item() |
392 | 392 | */ |
393 | -function wpinv_update_item( $args = array(), $wp_error = false ) { |
|
394 | - return wpinv_create_item( $args, $wp_error ); |
|
393 | +function wpinv_update_item($args = array(), $wp_error = false) { |
|
394 | + return wpinv_create_item($args, $wp_error); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
398 | 398 | * Sanitizes a recurring period |
399 | 399 | */ |
400 | -function getpaid_sanitize_recurring_period( $period, $full = false ) { |
|
400 | +function getpaid_sanitize_recurring_period($period, $full = false) { |
|
401 | 401 | |
402 | 402 | $periods = array( |
403 | 403 | 'D' => 'day', |
@@ -406,16 +406,16 @@ discard block |
||
406 | 406 | 'Y' => 'year', |
407 | 407 | ); |
408 | 408 | |
409 | - if ( ! isset( $periods[ $period ] ) ) { |
|
409 | + if (!isset($periods[$period])) { |
|
410 | 410 | $period = 'D'; |
411 | 411 | } |
412 | 412 | |
413 | - return $full ? $periods[ $period ] : $period; |
|
413 | + return $full ? $periods[$period] : $period; |
|
414 | 414 | |
415 | 415 | } |
416 | 416 | |
417 | -function wpinv_item_max_buyable_quantity( $item_id ) { |
|
418 | - return apply_filters( 'wpinv_item_max_buyable_quantity', 5, $item_id ); |
|
417 | +function wpinv_item_max_buyable_quantity($item_id) { |
|
418 | + return apply_filters('wpinv_item_max_buyable_quantity', 5, $item_id); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -423,47 +423,47 @@ discard block |
||
423 | 423 | * |
424 | 424 | * @param WPInv_Item|GetPaid_Form_Item $item |
425 | 425 | */ |
426 | -function getpaid_item_recurring_price_help_text( $item, $currency = '', $_initial_price = false, $_recurring_price = false ) { |
|
426 | +function getpaid_item_recurring_price_help_text($item, $currency = '', $_initial_price = false, $_recurring_price = false) { |
|
427 | 427 | |
428 | 428 | // Abort if it is not recurring. |
429 | - if ( ! $item->is_recurring() ) { |
|
429 | + if (!$item->is_recurring()) { |
|
430 | 430 | return ''; |
431 | 431 | } |
432 | 432 | |
433 | - $initial_price = false === $_initial_price ? wpinv_price( $item->get_initial_price(), $currency ) : $_initial_price; |
|
434 | - $recurring_price = false === $_recurring_price ? wpinv_price( $item->get_recurring_price(), $currency ) : $_recurring_price; |
|
435 | - $period = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ); |
|
433 | + $initial_price = false === $_initial_price ? wpinv_price($item->get_initial_price(), $currency) : $_initial_price; |
|
434 | + $recurring_price = false === $_recurring_price ? wpinv_price($item->get_recurring_price(), $currency) : $_recurring_price; |
|
435 | + $period = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), ''); |
|
436 | 436 | $initial_class = 'getpaid-item-initial-price'; |
437 | 437 | $recurring_class = 'getpaid-item-recurring-price'; |
438 | 438 | $bill_times = $item->get_recurring_limit(); |
439 | 439 | $bill_times_less = $bill_times - 1; |
440 | 440 | |
441 | - if ( ! empty( $bill_times ) ) { |
|
441 | + if (!empty($bill_times)) { |
|
442 | 442 | $bill_times = $item->get_recurring_interval() * $bill_times; |
443 | - $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() ); |
|
444 | - $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
443 | + $bill_times_less = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times - $item->get_recurring_interval()); |
|
444 | + $bill_times = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times); |
|
445 | 445 | } |
446 | 446 | |
447 | - if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) { |
|
448 | - $initial_price = wpinv_price( $item->get_sub_total(), $currency ); |
|
449 | - $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency ); |
|
447 | + if ($item instanceof GetPaid_Form_Item && false === $_initial_price) { |
|
448 | + $initial_price = wpinv_price($item->get_sub_total(), $currency); |
|
449 | + $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency); |
|
450 | 450 | } |
451 | 451 | |
452 | - if ( wpinv_price( 0, $currency ) == $initial_price && wpinv_price( 0, $currency ) == $recurring_price ) { |
|
453 | - return __( 'Free forever', 'invoicing' ); |
|
452 | + if (wpinv_price(0, $currency) == $initial_price && wpinv_price(0, $currency) == $recurring_price) { |
|
453 | + return __('Free forever', 'invoicing'); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | // For free trial items. |
457 | - if ( $item->has_free_trial() ) { |
|
458 | - $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() ); |
|
457 | + if ($item->has_free_trial()) { |
|
458 | + $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval()); |
|
459 | 459 | |
460 | - if ( wpinv_price( 0, $currency ) == $initial_price ) { |
|
460 | + if (wpinv_price(0, $currency) == $initial_price) { |
|
461 | 461 | |
462 | - if ( empty( $bill_times ) ) { |
|
462 | + if (empty($bill_times)) { |
|
463 | 463 | |
464 | 464 | return sprintf( |
465 | 465 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period |
466 | - _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ), |
|
466 | + _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'), |
|
467 | 467 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
468 | 468 | "<span class='$recurring_class'>$recurring_price</span>", |
469 | 469 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | |
474 | 474 | return sprintf( |
475 | 475 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period, $4: is the bill times |
476 | - _x( 'Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing' ), |
|
476 | + _x('Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing'), |
|
477 | 477 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
478 | 478 | "<span class='$recurring_class'>$recurring_price</span>", |
479 | 479 | "<span class='getpaid-item-recurring-period'>$period</span>", |
@@ -482,11 +482,11 @@ discard block |
||
482 | 482 | |
483 | 483 | } |
484 | 484 | |
485 | - if ( empty( $bill_times ) ) { |
|
485 | + if (empty($bill_times)) { |
|
486 | 486 | |
487 | 487 | return sprintf( |
488 | 488 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period |
489 | - _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ), |
|
489 | + _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'), |
|
490 | 490 | "<span class='$initial_class'>$initial_price</span>", |
491 | 491 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
492 | 492 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | |
498 | 498 | return sprintf( |
499 | 499 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period, $4: is the susbcription bill times |
500 | - _x( '%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing' ), |
|
500 | + _x('%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing'), |
|
501 | 501 | "<span class='$initial_class'>$initial_price</span>", |
502 | 502 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
503 | 503 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -507,13 +507,13 @@ discard block |
||
507 | 507 | |
508 | 508 | } |
509 | 509 | |
510 | - if ( $initial_price == $recurring_price ) { |
|
510 | + if ($initial_price == $recurring_price) { |
|
511 | 511 | |
512 | - if ( empty( $bill_times ) ) { |
|
512 | + if (empty($bill_times)) { |
|
513 | 513 | |
514 | 514 | return sprintf( |
515 | 515 | // translators: $1: is the recurring price, $2: is the susbcription period |
516 | - _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
516 | + _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
517 | 517 | "<span class='$recurring_class'>$recurring_price</span>", |
518 | 518 | "<span class='getpaid-item-recurring-period'>$period</span>" |
519 | 519 | ); |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | |
523 | 523 | return sprintf( |
524 | 524 | // translators: $1: is the recurring price, $2: is the susbcription period, $3: is the susbcription bill times |
525 | - _x( '%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ), |
|
525 | + _x('%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'), |
|
526 | 526 | "<span class='$recurring_class'>$recurring_price</span>", |
527 | 527 | "<span class='getpaid-item-recurring-period'>$period</span>", |
528 | 528 | "<span class='getpaid-item-recurring-bill-times'>$bill_times</span>" |
@@ -530,13 +530,13 @@ discard block |
||
530 | 530 | |
531 | 531 | } |
532 | 532 | |
533 | - if ( $initial_price == wpinv_price( 0, $currency ) ) { |
|
533 | + if ($initial_price == wpinv_price(0, $currency)) { |
|
534 | 534 | |
535 | - if ( empty( $bill_times ) ) { |
|
535 | + if (empty($bill_times)) { |
|
536 | 536 | |
537 | 537 | return sprintf( |
538 | 538 | // translators: $1: is the recurring period, $2: is the recurring price |
539 | - _x( 'Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing' ), |
|
539 | + _x('Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing'), |
|
540 | 540 | "<span class='getpaid-item-recurring-period'>$period</span>", |
541 | 541 | "<span class='$recurring_class'>$recurring_price</span>" |
542 | 542 | ); |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | |
546 | 546 | return sprintf( |
547 | 547 | // translators: $1: is the recurring period, $2: is the recurring price, $3: is the bill times |
548 | - _x( 'Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing' ), |
|
548 | + _x('Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing'), |
|
549 | 549 | "<span class='getpaid-item-recurring-period'>$period</span>", |
550 | 550 | "<span class='$recurring_class'>$recurring_price</span>", |
551 | 551 | "<span class='getpaid-item-recurring-bill-times'>$bill_times_less</span>" |
@@ -553,11 +553,11 @@ discard block |
||
553 | 553 | |
554 | 554 | } |
555 | 555 | |
556 | - if ( empty( $bill_times ) ) { |
|
556 | + if (empty($bill_times)) { |
|
557 | 557 | |
558 | 558 | return sprintf( |
559 | 559 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period |
560 | - _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ), |
|
560 | + _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'), |
|
561 | 561 | "<span class='$initial_class'>$initial_price</span>", |
562 | 562 | "<span class='$recurring_class'>$recurring_price</span>", |
563 | 563 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | |
568 | 568 | return sprintf( |
569 | 569 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period, $4: is the susbcription bill times |
570 | - _x( 'Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing' ), |
|
570 | + _x('Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing'), |
|
571 | 571 | "<span class='$initial_class'>$initial_price</span>", |
572 | 572 | "<span class='$recurring_class'>$recurring_price</span>", |
573 | 573 | "<span class='getpaid-item-recurring-period'>$period</span>", |
@@ -586,20 +586,20 @@ discard block |
||
586 | 586 | * @param int $item_ID The item post ID. Optional. |
587 | 587 | * @return bool Whether the item type supports the given feature. |
588 | 588 | */ |
589 | -function getpaid_item_type_supports( $item_type, $feature, $item_ID = 0 ) { |
|
589 | +function getpaid_item_type_supports($item_type, $feature, $item_ID = 0) { |
|
590 | 590 | $supports = false; |
591 | 591 | |
592 | - if ( ! is_scalar( $item_type ) ) { |
|
592 | + if (!is_scalar($item_type)) { |
|
593 | 593 | return $supports; |
594 | 594 | } |
595 | 595 | |
596 | - switch ( $feature ) { |
|
596 | + switch ($feature) { |
|
597 | 597 | case 'buy_now': |
598 | - if ( '' === $item_type || 'fee' === $item_type || 'custom' === $item_type ) { |
|
598 | + if ('' === $item_type || 'fee' === $item_type || 'custom' === $item_type) { |
|
599 | 599 | $supports = true; |
600 | 600 | } |
601 | 601 | break; |
602 | 602 | } |
603 | 603 | |
604 | - return apply_filters( 'getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID ); |
|
604 | + return apply_filters('getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID); |
|
605 | 605 | } |
606 | 606 | \ No newline at end of file |
@@ -6,7 +6,7 @@ |
||
6 | 6 | if (!headers_sent()) { |
7 | 7 | header('HTTP/1.1 500 Internal Server Error'); |
8 | 8 | } |
9 | - $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; |
|
9 | + $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running ' . PHP_VERSION . ', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.' . PHP_EOL; |
|
10 | 10 | if (!ini_get('display_errors')) { |
11 | 11 | if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
12 | 12 | fwrite(STDERR, $err); |
@@ -327,11 +327,11 @@ |
||
327 | 327 | foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { |
328 | 328 | if (isset(self::$installedByVendor[$vendorDir])) { |
329 | 329 | $installed[] = self::$installedByVendor[$vendorDir]; |
330 | - } elseif (is_file($vendorDir.'/composer/installed.php')) { |
|
330 | + } elseif (is_file($vendorDir . '/composer/installed.php')) { |
|
331 | 331 | /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ |
332 | - $required = require $vendorDir.'/composer/installed.php'; |
|
332 | + $required = require $vendorDir . '/composer/installed.php'; |
|
333 | 333 | $installed[] = self::$installedByVendor[$vendorDir] = $required; |
334 | - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { |
|
334 | + if (null === self::$installed && strtr($vendorDir . '/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { |
|
335 | 335 | self::$installed = $installed[count($installed) - 1]; |
336 | 336 | } |
337 | 337 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | $loader->register(true); |
35 | 35 | |
36 | 36 | $filesToLoad = \Composer\Autoload\ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$files; |
37 | - $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { |
|
37 | + $requireFile = \Closure::bind(static function($fileIdentifier, $file) { |
|
38 | 38 | if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { |
39 | 39 | $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; |
40 | 40 |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @return array|mixed|string|string[] |
15 | 15 | */ |
16 | -function aui_bs_convert_sd_output( $output, $instance = '', $args = '', $sd = '' ) { |
|
16 | +function aui_bs_convert_sd_output($output, $instance = '', $args = '', $sd = '') { |
|
17 | 17 | global $aui_bs5; |
18 | 18 | |
19 | - if ( $aui_bs5 ) { |
|
19 | + if ($aui_bs5) { |
|
20 | 20 | $convert = array( |
21 | 21 | '"ml-' => '"ms-', |
22 | 22 | '"mr-' => '"me-', |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | 'class="close"' => 'class="btn-close"', |
76 | 76 | '<span aria-hidden="true">×</span>' => '', |
77 | 77 | ); |
78 | - $output = str_replace( |
|
79 | - array_keys( $convert ), |
|
80 | - array_values( $convert ), |
|
78 | + $output = str_replace( |
|
79 | + array_keys($convert), |
|
80 | + array_values($convert), |
|
81 | 81 | $output |
82 | 82 | ); |
83 | 83 | } |
@@ -85,4 +85,4 @@ discard block |
||
85 | 85 | return $output; |
86 | 86 | } |
87 | 87 | |
88 | -add_filter( 'wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4 ); //$output, $instance, $args, $this |
|
88 | +add_filter('wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4); //$output, $instance, $args, $this |
@@ -14,76 +14,76 @@ |
||
14 | 14 | * @return array|mixed|string|string[] |
15 | 15 | */ |
16 | 16 | function aui_bs_convert_sd_output( $output, $instance = '', $args = '', $sd = '' ) { |
17 | - global $aui_bs5; |
|
17 | + global $aui_bs5; |
|
18 | 18 | |
19 | - if ( $aui_bs5 ) { |
|
20 | - $convert = array( |
|
21 | - '"ml-' => '"ms-', |
|
22 | - '"mr-' => '"me-', |
|
23 | - '"pl-' => '"ps-', |
|
24 | - '"pr-' => '"pe-', |
|
25 | - "'ml-" => "'ms-", |
|
26 | - "'mr-" => "'me-", |
|
27 | - "'pl-" => "'ps-", |
|
28 | - "'pr-" => "'pe-", |
|
29 | - ' ml-' => ' ms-', |
|
30 | - ' mr-' => ' me-', |
|
31 | - ' pl-' => ' ps-', |
|
32 | - ' pr-' => ' pe-', |
|
33 | - '.ml-' => '.ms-', |
|
34 | - '.mr-' => '.me-', |
|
35 | - '.pl-' => '.ps-', |
|
36 | - '.pr-' => '.pe-', |
|
37 | - ' form-row' => ' row', |
|
38 | - ' embed-responsive-item' => '', |
|
39 | - ' embed-responsive' => ' ratio', |
|
40 | - '-1by1' => '-1x1', |
|
41 | - '-4by3' => '-4x3', |
|
42 | - '-16by9' => '-16x9', |
|
43 | - '-21by9' => '-21x9', |
|
44 | - 'geodir-lightbox-image' => 'aui-lightbox-image', |
|
45 | - 'geodir-lightbox-iframe' => 'aui-lightbox-iframe', |
|
46 | - ' badge-' => ' text-bg-', |
|
47 | - 'form-group' => 'mb-3', |
|
48 | - 'custom-select' => 'form-select', |
|
49 | - 'float-left' => 'float-start', |
|
50 | - 'float-right' => 'float-end', |
|
51 | - 'text-left' => 'text-start', |
|
52 | - 'text-sm-left' => 'text-sm-start', |
|
53 | - 'text-md-left' => 'text-md-start', |
|
54 | - 'text-lg-left' => 'text-lg-start', |
|
55 | - 'text-right' => 'text-end', |
|
56 | - 'text-sm-right' => 'text-sm-end', |
|
57 | - 'text-md-right' => 'text-md-end', |
|
58 | - 'text-lg-right' => 'text-lg-end', |
|
59 | - 'border-right' => 'border-end', |
|
60 | - 'border-left' => 'border-start', |
|
61 | - 'font-weight-' => 'fw-', |
|
62 | - 'btn-block' => 'w-100', |
|
63 | - 'rounded-left' => 'rounded-start', |
|
64 | - 'rounded-right' => 'rounded-end', |
|
65 | - 'font-italic' => 'fst-italic', |
|
19 | + if ( $aui_bs5 ) { |
|
20 | + $convert = array( |
|
21 | + '"ml-' => '"ms-', |
|
22 | + '"mr-' => '"me-', |
|
23 | + '"pl-' => '"ps-', |
|
24 | + '"pr-' => '"pe-', |
|
25 | + "'ml-" => "'ms-", |
|
26 | + "'mr-" => "'me-", |
|
27 | + "'pl-" => "'ps-", |
|
28 | + "'pr-" => "'pe-", |
|
29 | + ' ml-' => ' ms-', |
|
30 | + ' mr-' => ' me-', |
|
31 | + ' pl-' => ' ps-', |
|
32 | + ' pr-' => ' pe-', |
|
33 | + '.ml-' => '.ms-', |
|
34 | + '.mr-' => '.me-', |
|
35 | + '.pl-' => '.ps-', |
|
36 | + '.pr-' => '.pe-', |
|
37 | + ' form-row' => ' row', |
|
38 | + ' embed-responsive-item' => '', |
|
39 | + ' embed-responsive' => ' ratio', |
|
40 | + '-1by1' => '-1x1', |
|
41 | + '-4by3' => '-4x3', |
|
42 | + '-16by9' => '-16x9', |
|
43 | + '-21by9' => '-21x9', |
|
44 | + 'geodir-lightbox-image' => 'aui-lightbox-image', |
|
45 | + 'geodir-lightbox-iframe' => 'aui-lightbox-iframe', |
|
46 | + ' badge-' => ' text-bg-', |
|
47 | + 'form-group' => 'mb-3', |
|
48 | + 'custom-select' => 'form-select', |
|
49 | + 'float-left' => 'float-start', |
|
50 | + 'float-right' => 'float-end', |
|
51 | + 'text-left' => 'text-start', |
|
52 | + 'text-sm-left' => 'text-sm-start', |
|
53 | + 'text-md-left' => 'text-md-start', |
|
54 | + 'text-lg-left' => 'text-lg-start', |
|
55 | + 'text-right' => 'text-end', |
|
56 | + 'text-sm-right' => 'text-sm-end', |
|
57 | + 'text-md-right' => 'text-md-end', |
|
58 | + 'text-lg-right' => 'text-lg-end', |
|
59 | + 'border-right' => 'border-end', |
|
60 | + 'border-left' => 'border-start', |
|
61 | + 'font-weight-' => 'fw-', |
|
62 | + 'btn-block' => 'w-100', |
|
63 | + 'rounded-left' => 'rounded-start', |
|
64 | + 'rounded-right' => 'rounded-end', |
|
65 | + 'font-italic' => 'fst-italic', |
|
66 | 66 | |
67 | 67 | // 'custom-control custom-checkbox' => 'form-check', |
68 | - // data |
|
69 | - ' data-toggle=' => ' data-bs-toggle=', |
|
70 | - 'data-ride=' => 'data-bs-ride=', |
|
71 | - 'data-controlnav=' => 'data-bs-controlnav=', |
|
72 | - 'data-slide=' => 'data-bs-slide=', |
|
73 | - 'data-slide-to=' => 'data-bs-slide-to=', |
|
74 | - 'data-target=' => 'data-bs-target=', |
|
75 | - 'data-dismiss="modal"' => 'data-bs-dismiss="modal"', |
|
76 | - 'class="close"' => 'class="btn-close"', |
|
77 | - '<span aria-hidden="true">×</span>' => '', |
|
78 | - ); |
|
79 | - $output = str_replace( |
|
80 | - array_keys( $convert ), |
|
81 | - array_values( $convert ), |
|
82 | - $output |
|
83 | - ); |
|
84 | - } |
|
68 | + // data |
|
69 | + ' data-toggle=' => ' data-bs-toggle=', |
|
70 | + 'data-ride=' => 'data-bs-ride=', |
|
71 | + 'data-controlnav=' => 'data-bs-controlnav=', |
|
72 | + 'data-slide=' => 'data-bs-slide=', |
|
73 | + 'data-slide-to=' => 'data-bs-slide-to=', |
|
74 | + 'data-target=' => 'data-bs-target=', |
|
75 | + 'data-dismiss="modal"' => 'data-bs-dismiss="modal"', |
|
76 | + 'class="close"' => 'class="btn-close"', |
|
77 | + '<span aria-hidden="true">×</span>' => '', |
|
78 | + ); |
|
79 | + $output = str_replace( |
|
80 | + array_keys( $convert ), |
|
81 | + array_values( $convert ), |
|
82 | + $output |
|
83 | + ); |
|
84 | + } |
|
85 | 85 | |
86 | - return $output; |
|
86 | + return $output; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | add_filter( 'wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4 ); //$output, $instance, $args, $this |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$invoice = new WPInv_Invoice( $invoice ); |
|
13 | -$address_row = wpinv_get_invoice_address_markup( $invoice->get_user_info() ); |
|
12 | +$invoice = new WPInv_Invoice($invoice); |
|
13 | +$address_row = wpinv_get_invoice_address_markup($invoice->get_user_info()); |
|
14 | 14 | $phone = $invoice->get_phone(); |
15 | 15 | $email = $invoice->get_email(); |
16 | 16 | $vat_number = $invoice->get_vat_number(); |
@@ -22,47 +22,47 @@ discard block |
||
22 | 22 | |
23 | 23 | |
24 | 24 | <div class="invoice-billing-address-label col-2"> |
25 | - <strong><?php esc_html_e( 'To:', 'invoicing' ); ?></strong> |
|
25 | + <strong><?php esc_html_e('To:', 'invoicing'); ?></strong> |
|
26 | 26 | </div> |
27 | 27 | |
28 | 28 | |
29 | 29 | <div class="invoice-billing-address-value col-10"> |
30 | 30 | |
31 | - <?php do_action( 'getpaid_billing_address_top' ); ?> |
|
31 | + <?php do_action('getpaid_billing_address_top'); ?> |
|
32 | 32 | |
33 | - <?php if ( ! empty( $address_row ) ) : ?> |
|
33 | + <?php if (!empty($address_row)) : ?> |
|
34 | 34 | <div class="billing-address"> |
35 | - <?php echo wp_kses_post( $address_row ); ?> |
|
35 | + <?php echo wp_kses_post($address_row); ?> |
|
36 | 36 | </div> |
37 | 37 | <?php endif; ?> |
38 | 38 | |
39 | 39 | |
40 | - <?php if ( ! empty( $phone ) ) : ?> |
|
40 | + <?php if (!empty($phone)) : ?> |
|
41 | 41 | <div class="billing-phone"> |
42 | - <?php echo wp_sprintf( esc_html__( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ); ?> |
|
42 | + <?php echo wp_sprintf(esc_html__('Phone: %s', 'invoicing'), esc_html($phone)); ?> |
|
43 | 43 | </div> |
44 | 44 | <?php endif; ?> |
45 | 45 | |
46 | 46 | |
47 | - <?php if ( ! empty( $email ) ) : ?> |
|
47 | + <?php if (!empty($email)) : ?> |
|
48 | 48 | <div class="billing-email"> |
49 | - <?php echo wp_sprintf( esc_html__( 'Email: %s', 'invoicing' ), esc_html( $email ) ); ?> |
|
49 | + <?php echo wp_sprintf(esc_html__('Email: %s', 'invoicing'), esc_html($email)); ?> |
|
50 | 50 | </div> |
51 | 51 | <?php endif; ?> |
52 | 52 | |
53 | - <?php if ( ! empty( $vat_number ) && wpinv_use_taxes() ) : ?> |
|
53 | + <?php if (!empty($vat_number) && wpinv_use_taxes()) : ?> |
|
54 | 54 | <div class="vat-number"> |
55 | - <?php echo wp_sprintf( esc_html__( 'Vat Number: %s', 'invoicing' ), esc_html( $vat_number ) ); ?> |
|
55 | + <?php echo wp_sprintf(esc_html__('Vat Number: %s', 'invoicing'), esc_html($vat_number)); ?> |
|
56 | 56 | </div> |
57 | 57 | <?php endif; ?> |
58 | 58 | |
59 | - <?php if ( ! empty( $company_id ) ) : ?> |
|
59 | + <?php if (!empty($company_id)) : ?> |
|
60 | 60 | <div class="company-id"> |
61 | - <?php echo wp_sprintf( esc_html__( 'Company ID: %s', 'invoicing' ), esc_html( $company_id ) ); ?> |
|
61 | + <?php echo wp_sprintf(esc_html__('Company ID: %s', 'invoicing'), esc_html($company_id)); ?> |
|
62 | 62 | </div> |
63 | 63 | <?php endif; ?> |
64 | 64 | |
65 | - <?php do_action( 'getpaid_billing_address_bottom' ); ?> |
|
65 | + <?php do_action('getpaid_billing_address_bottom'); ?> |
|
66 | 66 | |
67 | 67 | </div> |
68 | 68 |
@@ -15,12 +15,12 @@ discard block |
||
15 | 15 | */ |
16 | 16 | |
17 | 17 | if ( ! defined( 'ABSPATH' ) ) { |
18 | - exit; |
|
18 | + exit; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | if ( ! class_exists( 'WP_Super_Duper' ) ) { |
22 | - // include the class if needed |
|
23 | - include_once( dirname( __FILE__ ) . "/wp-super-duper.php" ); |
|
22 | + // include the class if needed |
|
23 | + include_once( dirname( __FILE__ ) . "/wp-super-duper.php" ); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /* |
@@ -35,5 +35,5 @@ discard block |
||
35 | 35 | |
36 | 36 | |
37 | 37 | if ( ! function_exists( 'sd_get_class_build_keys' ) ) { |
38 | - include_once( dirname( __FILE__ ) . "/sd-functions.php" ); |
|
38 | + include_once( dirname( __FILE__ ) . "/sd-functions.php" ); |
|
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -14,26 +14,26 @@ |
||
14 | 14 | * Tested up to: 6.7 |
15 | 15 | */ |
16 | 16 | |
17 | -if ( ! defined( 'ABSPATH' ) ) { |
|
17 | +if (!defined('ABSPATH')) { |
|
18 | 18 | exit; |
19 | 19 | } |
20 | 20 | |
21 | -if ( ! class_exists( 'WP_Super_Duper' ) ) { |
|
21 | +if (!class_exists('WP_Super_Duper')) { |
|
22 | 22 | // include the class if needed |
23 | - include_once( dirname( __FILE__ ) . "/wp-super-duper.php" ); |
|
23 | + include_once(dirname(__FILE__) . "/wp-super-duper.php"); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /* |
27 | 27 | * Hello world example. |
28 | 28 | */ |
29 | -include_once( dirname( __FILE__ ) . "/hello-world.php" ); |
|
29 | +include_once(dirname(__FILE__) . "/hello-world.php"); |
|
30 | 30 | |
31 | 31 | /* |
32 | 32 | * Map example. |
33 | 33 | */ |
34 | -include_once( dirname( __FILE__ ) . "/map.php" ); |
|
34 | +include_once(dirname(__FILE__) . "/map.php"); |
|
35 | 35 | |
36 | 36 | |
37 | -if ( ! function_exists( 'sd_get_class_build_keys' ) ) { |
|
38 | - include_once( dirname( __FILE__ ) . "/sd-functions.php" ); |
|
37 | +if (!function_exists('sd_get_class_build_keys')) { |
|
38 | + include_once(dirname(__FILE__) . "/sd-functions.php"); |
|
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -3,114 +3,114 @@ discard block |
||
3 | 3 | class SD_Hello_World extends WP_Super_Duper { |
4 | 4 | |
5 | 5 | |
6 | - public $arguments; |
|
7 | - |
|
8 | - /** |
|
9 | - * Sets up the widgets name etc |
|
10 | - */ |
|
11 | - public function __construct() { |
|
12 | - |
|
13 | - $options = array( |
|
14 | - 'textdomain' => 'super-duper', |
|
15 | - // textdomain of the plugin/theme (used to prefix the Gutenberg block) |
|
16 | - 'block-icon' => 'fas fa-globe-americas', |
|
17 | - // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right |
|
18 | - // OR font-awesome 5 class name: fas fa-globe-americas |
|
19 | - 'block-category' => 'widgets', |
|
20 | - // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'. |
|
21 | - 'block-keywords' => "['hello','world']", |
|
22 | - // used in the block search, MAX 3 |
|
23 | - 'block-output' => array( // the block visual output elements as an array |
|
6 | + public $arguments; |
|
7 | + |
|
8 | + /** |
|
9 | + * Sets up the widgets name etc |
|
10 | + */ |
|
11 | + public function __construct() { |
|
12 | + |
|
13 | + $options = array( |
|
14 | + 'textdomain' => 'super-duper', |
|
15 | + // textdomain of the plugin/theme (used to prefix the Gutenberg block) |
|
16 | + 'block-icon' => 'fas fa-globe-americas', |
|
17 | + // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right |
|
18 | + // OR font-awesome 5 class name: fas fa-globe-americas |
|
19 | + 'block-category' => 'widgets', |
|
20 | + // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'. |
|
21 | + 'block-keywords' => "['hello','world']", |
|
22 | + // used in the block search, MAX 3 |
|
23 | + 'block-output' => array( // the block visual output elements as an array |
|
24 | 24 | // array( |
25 | 25 | // 'element' => 'p', |
26 | 26 | // 'title' => __( 'Placeholder', 'ayecode-connect' ), |
27 | 27 | // 'class' => '[%className%]', |
28 | 28 | // 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
29 | 29 | // ) |
30 | - array( |
|
31 | - 'element' => 'BlocksProps', |
|
32 | - 'inner_element' => 'p', |
|
33 | - 'blockProps' => array( |
|
34 | - 'className' => '[%WrapClass%]', |
|
30 | + array( |
|
31 | + 'element' => 'BlocksProps', |
|
32 | + 'inner_element' => 'p', |
|
33 | + 'blockProps' => array( |
|
34 | + 'className' => '[%WrapClass%]', |
|
35 | 35 | // 'content' => 'Hello: [%after_text%]' |
36 | 36 | // 'if_dangerouslySetInnerHTML' => '{__html: blockstrap_build_shape(props.attributes) }', |
37 | - ), |
|
38 | - 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
|
39 | - |
|
40 | - |
|
41 | - ), |
|
42 | - ), |
|
43 | - 'block-wrap' => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all. |
|
44 | - 'class_name' => __CLASS__, |
|
45 | - // The calling class name |
|
46 | - 'base_id' => 'hello_world', |
|
47 | - // this is used as the widget id and the shortcode id. |
|
48 | - 'name' => __( 'Hello World', 'ayecode-connect' ), |
|
49 | - // the name of the widget/block |
|
50 | - 'widget_ops' => array( |
|
51 | - 'classname' => 'hello-world-class', |
|
52 | - // widget class |
|
53 | - 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ), |
|
54 | - // widget description |
|
55 | - ), |
|
56 | - 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div. |
|
57 | - 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
|
58 | - 'after_text' => array( // this is the input name='' |
|
59 | - 'title' => __( 'Text after hello:', 'ayecode-connect' ), |
|
60 | - // input title |
|
61 | - 'desc' => __( 'This is the text that will appear after `Hello:`.', 'ayecode-connect' ), |
|
62 | - // input description |
|
63 | - 'type' => 'text', |
|
64 | - // the type of input, test, select, checkbox etc. |
|
65 | - 'placeholder' => 'World', |
|
66 | - // the input placeholder text. |
|
67 | - 'desc_tip' => true, |
|
68 | - // if the input should show the widget description text as a tooltip. |
|
69 | - 'default' => 'World', |
|
70 | - // the input default value. |
|
71 | - 'advanced' => false |
|
72 | - // not yet implemented |
|
73 | - ), |
|
74 | - ) |
|
75 | - ); |
|
76 | - |
|
77 | - parent::__construct( $options ); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * This is the output function for the widget, shortcode and block (front end). |
|
83 | - * |
|
84 | - * @param array $args The arguments values. |
|
85 | - * @param array $widget_args The widget arguments when used. |
|
86 | - * @param string $content The shortcode content argument |
|
87 | - * |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
91 | - |
|
92 | - /** |
|
93 | - * @var string $after_text |
|
94 | - * @var string $another_input This is added by filter below. |
|
95 | - */ |
|
96 | - extract( $args, EXTR_SKIP ); |
|
97 | - |
|
98 | - /* |
|
37 | + ), |
|
38 | + 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
|
39 | + |
|
40 | + |
|
41 | + ), |
|
42 | + ), |
|
43 | + 'block-wrap' => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all. |
|
44 | + 'class_name' => __CLASS__, |
|
45 | + // The calling class name |
|
46 | + 'base_id' => 'hello_world', |
|
47 | + // this is used as the widget id and the shortcode id. |
|
48 | + 'name' => __( 'Hello World', 'ayecode-connect' ), |
|
49 | + // the name of the widget/block |
|
50 | + 'widget_ops' => array( |
|
51 | + 'classname' => 'hello-world-class', |
|
52 | + // widget class |
|
53 | + 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ), |
|
54 | + // widget description |
|
55 | + ), |
|
56 | + 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div. |
|
57 | + 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
|
58 | + 'after_text' => array( // this is the input name='' |
|
59 | + 'title' => __( 'Text after hello:', 'ayecode-connect' ), |
|
60 | + // input title |
|
61 | + 'desc' => __( 'This is the text that will appear after `Hello:`.', 'ayecode-connect' ), |
|
62 | + // input description |
|
63 | + 'type' => 'text', |
|
64 | + // the type of input, test, select, checkbox etc. |
|
65 | + 'placeholder' => 'World', |
|
66 | + // the input placeholder text. |
|
67 | + 'desc_tip' => true, |
|
68 | + // if the input should show the widget description text as a tooltip. |
|
69 | + 'default' => 'World', |
|
70 | + // the input default value. |
|
71 | + 'advanced' => false |
|
72 | + // not yet implemented |
|
73 | + ), |
|
74 | + ) |
|
75 | + ); |
|
76 | + |
|
77 | + parent::__construct( $options ); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * This is the output function for the widget, shortcode and block (front end). |
|
83 | + * |
|
84 | + * @param array $args The arguments values. |
|
85 | + * @param array $widget_args The widget arguments when used. |
|
86 | + * @param string $content The shortcode content argument |
|
87 | + * |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
91 | + |
|
92 | + /** |
|
93 | + * @var string $after_text |
|
94 | + * @var string $another_input This is added by filter below. |
|
95 | + */ |
|
96 | + extract( $args, EXTR_SKIP ); |
|
97 | + |
|
98 | + /* |
|
99 | 99 | * This value is added by filter so might not exist if filter is removed so we check. |
100 | 100 | */ |
101 | - if ( ! isset( $another_input ) ) { |
|
102 | - $another_input = ''; |
|
103 | - } |
|
101 | + if ( ! isset( $another_input ) ) { |
|
102 | + $another_input = ''; |
|
103 | + } |
|
104 | 104 | |
105 | - return "Helllo: " . $after_text . "" . $another_input; |
|
105 | + return "Helllo: " . $after_text . "" . $another_input; |
|
106 | 106 | |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | 109 | } |
110 | 110 | |
111 | 111 | // register it. |
112 | 112 | add_action( 'widgets_init', function () { |
113 | - register_widget( 'SD_Hello_World' ); |
|
113 | + register_widget( 'SD_Hello_World' ); |
|
114 | 114 | } ); |
115 | 115 | |
116 | 116 | |
@@ -123,26 +123,26 @@ discard block |
||
123 | 123 | */ |
124 | 124 | function _my_extra_arguments( $options ) { |
125 | 125 | |
126 | - /* |
|
126 | + /* |
|
127 | 127 | * Add a new input option. |
128 | 128 | */ |
129 | - $options['arguments']['another_input'] = array( |
|
130 | - 'name' => 'another_input', // this is the input name='' |
|
131 | - 'title' => __( 'Another input:', 'ayecode-connect' ), // input title |
|
132 | - 'desc' => __( 'This is an input added via filter.', 'ayecode-connect' ), // input description |
|
133 | - 'type' => 'text', // the type of input, test, select, checkbox etc. |
|
134 | - 'placeholder' => 'Placeholder text', // the input placeholder text. |
|
135 | - 'desc_tip' => true, // if the input should show the widget description text as a tooltip. |
|
136 | - 'default' => '', // the input default value. |
|
137 | - 'advanced' => false // not yet implemented |
|
138 | - ); |
|
139 | - |
|
140 | - /* |
|
129 | + $options['arguments']['another_input'] = array( |
|
130 | + 'name' => 'another_input', // this is the input name='' |
|
131 | + 'title' => __( 'Another input:', 'ayecode-connect' ), // input title |
|
132 | + 'desc' => __( 'This is an input added via filter.', 'ayecode-connect' ), // input description |
|
133 | + 'type' => 'text', // the type of input, test, select, checkbox etc. |
|
134 | + 'placeholder' => 'Placeholder text', // the input placeholder text. |
|
135 | + 'desc_tip' => true, // if the input should show the widget description text as a tooltip. |
|
136 | + 'default' => '', // the input default value. |
|
137 | + 'advanced' => false // not yet implemented |
|
138 | + ); |
|
139 | + |
|
140 | + /* |
|
141 | 141 | * Output the new option in the block output also. |
142 | 142 | */ |
143 | - $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";; |
|
143 | + $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";; |
|
144 | 144 | |
145 | - return $options; |
|
145 | + return $options; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | //add_filter( 'wp_super_duper_options_hello_world', '_my_extra_arguments' ); |
149 | 149 | \ No newline at end of file |
@@ -45,20 +45,20 @@ discard block |
||
45 | 45 | // The calling class name |
46 | 46 | 'base_id' => 'hello_world', |
47 | 47 | // this is used as the widget id and the shortcode id. |
48 | - 'name' => __( 'Hello World', 'ayecode-connect' ), |
|
48 | + 'name' => __('Hello World', 'ayecode-connect'), |
|
49 | 49 | // the name of the widget/block |
50 | 50 | 'widget_ops' => array( |
51 | 51 | 'classname' => 'hello-world-class', |
52 | 52 | // widget class |
53 | - 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ), |
|
53 | + 'description' => esc_html__('This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect'), |
|
54 | 54 | // widget description |
55 | 55 | ), |
56 | 56 | 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div. |
57 | 57 | 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
58 | 58 | 'after_text' => array( // this is the input name='' |
59 | - 'title' => __( 'Text after hello:', 'ayecode-connect' ), |
|
59 | + 'title' => __('Text after hello:', 'ayecode-connect'), |
|
60 | 60 | // input title |
61 | - 'desc' => __( 'This is the text that will appear after `Hello:`.', 'ayecode-connect' ), |
|
61 | + 'desc' => __('This is the text that will appear after `Hello:`.', 'ayecode-connect'), |
|
62 | 62 | // input description |
63 | 63 | 'type' => 'text', |
64 | 64 | // the type of input, test, select, checkbox etc. |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | ) |
75 | 75 | ); |
76 | 76 | |
77 | - parent::__construct( $options ); |
|
77 | + parent::__construct($options); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
@@ -87,18 +87,18 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return string |
89 | 89 | */ |
90 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
90 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @var string $after_text |
94 | 94 | * @var string $another_input This is added by filter below. |
95 | 95 | */ |
96 | - extract( $args, EXTR_SKIP ); |
|
96 | + extract($args, EXTR_SKIP); |
|
97 | 97 | |
98 | 98 | /* |
99 | 99 | * This value is added by filter so might not exist if filter is removed so we check. |
100 | 100 | */ |
101 | - if ( ! isset( $another_input ) ) { |
|
101 | + if (!isset($another_input)) { |
|
102 | 102 | $another_input = ''; |
103 | 103 | } |
104 | 104 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | // register it. |
112 | -add_action( 'widgets_init', function () { |
|
113 | - register_widget( 'SD_Hello_World' ); |
|
112 | +add_action('widgets_init', function() { |
|
113 | + register_widget('SD_Hello_World'); |
|
114 | 114 | } ); |
115 | 115 | |
116 | 116 | |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return mixed |
123 | 123 | */ |
124 | -function _my_extra_arguments( $options ) { |
|
124 | +function _my_extra_arguments($options) { |
|
125 | 125 | |
126 | 126 | /* |
127 | 127 | * Add a new input option. |
128 | 128 | */ |
129 | 129 | $options['arguments']['another_input'] = array( |
130 | 130 | 'name' => 'another_input', // this is the input name='' |
131 | - 'title' => __( 'Another input:', 'ayecode-connect' ), // input title |
|
132 | - 'desc' => __( 'This is an input added via filter.', 'ayecode-connect' ), // input description |
|
131 | + 'title' => __('Another input:', 'ayecode-connect'), // input title |
|
132 | + 'desc' => __('This is an input added via filter.', 'ayecode-connect'), // input description |
|
133 | 133 | 'type' => 'text', // the type of input, test, select, checkbox etc. |
134 | 134 | 'placeholder' => 'Placeholder text', // the input placeholder text. |
135 | 135 | 'desc_tip' => true, // if the input should show the widget description text as a tooltip. |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | /* |
141 | 141 | * Output the new option in the block output also. |
142 | 142 | */ |
143 | - $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";; |
|
143 | + $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]"; ; |
|
144 | 144 | |
145 | 145 | return $options; |
146 | 146 | } |
@@ -14,143 +14,143 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class WPInv_Subscriptions_Widget extends WP_Super_Duper { |
16 | 16 | |
17 | - /** |
|
18 | - * Register the widget with WordPress. |
|
19 | - * |
|
20 | - */ |
|
21 | - public function __construct() { |
|
22 | - |
|
23 | - $options = array( |
|
24 | - 'textdomain' => 'invoicing', |
|
25 | - 'block-icon' => 'controls-repeat', |
|
26 | - 'block-category' => 'widgets', |
|
27 | - 'block-keywords' => "['invoicing','subscriptions', 'getpaid']", |
|
28 | - 'class_name' => __CLASS__, |
|
29 | - 'base_id' => 'wpinv_subscriptions', |
|
30 | - 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
31 | - 'widget_ops' => array( |
|
32 | - 'classname' => 'getpaid-subscriptions bsui', |
|
33 | - 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
34 | - ), |
|
35 | - 'arguments' => array( |
|
36 | - 'title' => array( |
|
37 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
38 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
39 | - 'type' => 'text', |
|
40 | - 'desc_tip' => true, |
|
41 | - 'default' => '', |
|
42 | - 'advanced' => false, |
|
43 | - ), |
|
44 | - ), |
|
45 | - |
|
46 | - ); |
|
47 | - |
|
48 | - parent::__construct( $options ); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Retrieves current user's subscriptions. |
|
53 | - * |
|
54 | - * @return GetPaid_Subscriptions_Query |
|
55 | - */ |
|
56 | - public function get_subscriptions() { |
|
57 | - |
|
58 | - // Prepare license args. |
|
59 | - $args = array( |
|
60 | - 'customer_in' => get_current_user_id(), |
|
61 | - 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
62 | - ); |
|
63 | - |
|
64 | - return new GetPaid_Subscriptions_Query( $args ); |
|
65 | - |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * The Super block output function. |
|
70 | - * |
|
71 | - * @param array $args |
|
72 | - * @param array $widget_args |
|
73 | - * @param string $content |
|
74 | - * |
|
75 | - * @return mixed|string|bool |
|
76 | - */ |
|
77 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
78 | - |
|
79 | - // Ensure that the user is logged in. |
|
80 | - if ( ! is_user_logged_in() ) { |
|
81 | - |
|
82 | - return aui()->alert( |
|
83 | - array( |
|
84 | - 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
85 | - 'type' => 'error', |
|
86 | - ) |
|
87 | - ); |
|
88 | - |
|
89 | - } |
|
90 | - |
|
91 | - // Are we displaying a single subscription? |
|
92 | - if ( isset( $_GET['subscription'] ) ) { |
|
93 | - return $this->display_single_subscription( intval( $_GET['subscription'] ) ); |
|
94 | - } |
|
95 | - |
|
96 | - // Retrieve the user's subscriptions. |
|
97 | - $subscriptions = $this->get_subscriptions(); |
|
98 | - |
|
99 | - // Start the output buffer. |
|
100 | - ob_start(); |
|
101 | - |
|
102 | - // Backwards compatibility. |
|
103 | - do_action( 'wpinv_before_user_subscriptions' ); |
|
104 | - |
|
105 | - // Display errors and notices. |
|
106 | - wpinv_print_errors(); |
|
107 | - |
|
108 | - do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
109 | - |
|
110 | - // Print the table header. |
|
111 | - $this->print_table_header(); |
|
112 | - |
|
113 | - // Print table body. |
|
114 | - $this->print_table_body( $subscriptions->get_results() ); |
|
115 | - |
|
116 | - // Print table footer. |
|
117 | - $this->print_table_footer(); |
|
118 | - |
|
119 | - // Print the navigation. |
|
120 | - $this->print_navigation( $subscriptions->get_total() ); |
|
121 | - |
|
122 | - // Backwards compatibility. |
|
123 | - do_action( 'wpinv_after_user_subscriptions' ); |
|
124 | - |
|
125 | - // Return the output. |
|
126 | - return ob_get_clean(); |
|
127 | - |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Retrieves the subscription columns. |
|
132 | - * |
|
133 | - * @return array |
|
134 | - */ |
|
135 | - public function get_subscriptions_table_columns() { |
|
17 | + /** |
|
18 | + * Register the widget with WordPress. |
|
19 | + * |
|
20 | + */ |
|
21 | + public function __construct() { |
|
22 | + |
|
23 | + $options = array( |
|
24 | + 'textdomain' => 'invoicing', |
|
25 | + 'block-icon' => 'controls-repeat', |
|
26 | + 'block-category' => 'widgets', |
|
27 | + 'block-keywords' => "['invoicing','subscriptions', 'getpaid']", |
|
28 | + 'class_name' => __CLASS__, |
|
29 | + 'base_id' => 'wpinv_subscriptions', |
|
30 | + 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
31 | + 'widget_ops' => array( |
|
32 | + 'classname' => 'getpaid-subscriptions bsui', |
|
33 | + 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
34 | + ), |
|
35 | + 'arguments' => array( |
|
36 | + 'title' => array( |
|
37 | + 'title' => __( 'Widget title', 'invoicing' ), |
|
38 | + 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
39 | + 'type' => 'text', |
|
40 | + 'desc_tip' => true, |
|
41 | + 'default' => '', |
|
42 | + 'advanced' => false, |
|
43 | + ), |
|
44 | + ), |
|
45 | + |
|
46 | + ); |
|
47 | + |
|
48 | + parent::__construct( $options ); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Retrieves current user's subscriptions. |
|
53 | + * |
|
54 | + * @return GetPaid_Subscriptions_Query |
|
55 | + */ |
|
56 | + public function get_subscriptions() { |
|
57 | + |
|
58 | + // Prepare license args. |
|
59 | + $args = array( |
|
60 | + 'customer_in' => get_current_user_id(), |
|
61 | + 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
62 | + ); |
|
63 | + |
|
64 | + return new GetPaid_Subscriptions_Query( $args ); |
|
65 | + |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * The Super block output function. |
|
70 | + * |
|
71 | + * @param array $args |
|
72 | + * @param array $widget_args |
|
73 | + * @param string $content |
|
74 | + * |
|
75 | + * @return mixed|string|bool |
|
76 | + */ |
|
77 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
78 | + |
|
79 | + // Ensure that the user is logged in. |
|
80 | + if ( ! is_user_logged_in() ) { |
|
81 | + |
|
82 | + return aui()->alert( |
|
83 | + array( |
|
84 | + 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
85 | + 'type' => 'error', |
|
86 | + ) |
|
87 | + ); |
|
88 | + |
|
89 | + } |
|
90 | + |
|
91 | + // Are we displaying a single subscription? |
|
92 | + if ( isset( $_GET['subscription'] ) ) { |
|
93 | + return $this->display_single_subscription( intval( $_GET['subscription'] ) ); |
|
94 | + } |
|
95 | + |
|
96 | + // Retrieve the user's subscriptions. |
|
97 | + $subscriptions = $this->get_subscriptions(); |
|
98 | + |
|
99 | + // Start the output buffer. |
|
100 | + ob_start(); |
|
101 | + |
|
102 | + // Backwards compatibility. |
|
103 | + do_action( 'wpinv_before_user_subscriptions' ); |
|
104 | + |
|
105 | + // Display errors and notices. |
|
106 | + wpinv_print_errors(); |
|
107 | + |
|
108 | + do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
109 | + |
|
110 | + // Print the table header. |
|
111 | + $this->print_table_header(); |
|
112 | + |
|
113 | + // Print table body. |
|
114 | + $this->print_table_body( $subscriptions->get_results() ); |
|
115 | + |
|
116 | + // Print table footer. |
|
117 | + $this->print_table_footer(); |
|
118 | + |
|
119 | + // Print the navigation. |
|
120 | + $this->print_navigation( $subscriptions->get_total() ); |
|
121 | + |
|
122 | + // Backwards compatibility. |
|
123 | + do_action( 'wpinv_after_user_subscriptions' ); |
|
124 | + |
|
125 | + // Return the output. |
|
126 | + return ob_get_clean(); |
|
127 | + |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Retrieves the subscription columns. |
|
132 | + * |
|
133 | + * @return array |
|
134 | + */ |
|
135 | + public function get_subscriptions_table_columns() { |
|
136 | 136 | |
137 | - $columns = array( |
|
138 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
139 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
140 | - 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
141 | - 'status' => __( 'Status', 'invoicing' ), |
|
142 | - ); |
|
137 | + $columns = array( |
|
138 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
139 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
140 | + 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
141 | + 'status' => __( 'Status', 'invoicing' ), |
|
142 | + ); |
|
143 | 143 | |
144 | - return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
145 | - } |
|
144 | + return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * Displays the table header. |
|
149 | - * |
|
150 | - */ |
|
151 | - public function print_table_header() { |
|
147 | + /** |
|
148 | + * Displays the table header. |
|
149 | + * |
|
150 | + */ |
|
151 | + public function print_table_header() { |
|
152 | 152 | |
153 | - ?> |
|
153 | + ?> |
|
154 | 154 | |
155 | 155 | <table class="table table-bordered table-striped"> |
156 | 156 | |
@@ -166,122 +166,122 @@ discard block |
||
166 | 166 | |
167 | 167 | <?php |
168 | 168 | |
169 | - } |
|
169 | + } |
|
170 | 170 | |
171 | - /** |
|
172 | - * Displays the table body. |
|
173 | - * |
|
174 | - * @param WPInv_Subscription[] $subscriptions |
|
175 | - */ |
|
176 | - public function print_table_body( $subscriptions ) { |
|
171 | + /** |
|
172 | + * Displays the table body. |
|
173 | + * |
|
174 | + * @param WPInv_Subscription[] $subscriptions |
|
175 | + */ |
|
176 | + public function print_table_body( $subscriptions ) { |
|
177 | 177 | |
178 | - if ( empty( $subscriptions ) ) { |
|
179 | - $this->print_table_body_no_subscriptions(); |
|
180 | - } else { |
|
181 | - $this->print_table_body_subscriptions( $subscriptions ); |
|
182 | - } |
|
178 | + if ( empty( $subscriptions ) ) { |
|
179 | + $this->print_table_body_no_subscriptions(); |
|
180 | + } else { |
|
181 | + $this->print_table_body_subscriptions( $subscriptions ); |
|
182 | + } |
|
183 | 183 | |
184 | - } |
|
184 | + } |
|
185 | 185 | |
186 | - /** |
|
187 | - * Displays the table body if no subscriptions were found. |
|
188 | - * |
|
189 | - */ |
|
190 | - public function print_table_body_no_subscriptions() { |
|
186 | + /** |
|
187 | + * Displays the table body if no subscriptions were found. |
|
188 | + * |
|
189 | + */ |
|
190 | + public function print_table_body_no_subscriptions() { |
|
191 | 191 | |
192 | - ?> |
|
192 | + ?> |
|
193 | 193 | <tbody> |
194 | 194 | |
195 | 195 | <tr> |
196 | 196 | <td colspan="<?php echo count( $this->get_subscriptions_table_columns() ); ?>"> |
197 | 197 | |
198 | 198 | <?php |
199 | - aui()->alert( |
|
200 | - array( |
|
201 | - 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
202 | - 'type' => 'warning', |
|
203 | - ), |
|
199 | + aui()->alert( |
|
200 | + array( |
|
201 | + 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
202 | + 'type' => 'warning', |
|
203 | + ), |
|
204 | 204 | true |
205 | - ); |
|
206 | - ?> |
|
205 | + ); |
|
206 | + ?> |
|
207 | 207 | |
208 | 208 | </td> |
209 | 209 | </tr> |
210 | 210 | |
211 | 211 | </tbody> |
212 | 212 | <?php |
213 | - } |
|
213 | + } |
|
214 | 214 | |
215 | - /** |
|
216 | - * Displays the table body if subscriptions were found. |
|
217 | - * |
|
218 | - * @param WPInv_Subscription[] $subscriptions |
|
219 | - */ |
|
220 | - public function print_table_body_subscriptions( $subscriptions ) { |
|
215 | + /** |
|
216 | + * Displays the table body if subscriptions were found. |
|
217 | + * |
|
218 | + * @param WPInv_Subscription[] $subscriptions |
|
219 | + */ |
|
220 | + public function print_table_body_subscriptions( $subscriptions ) { |
|
221 | 221 | |
222 | - ?> |
|
222 | + ?> |
|
223 | 223 | <tbody> |
224 | 224 | |
225 | 225 | <?php foreach ( $subscriptions as $subscription ) : ?> |
226 | 226 | <tr class="getpaid-subscriptions-table-row subscription-<?php echo (int) $subscription->get_id(); ?>"> |
227 | 227 | <?php |
228 | - wpinv_get_template( |
|
229 | - 'subscriptions/subscriptions-table-row.php', |
|
230 | - array( |
|
231 | - 'subscription' => $subscription, |
|
232 | - 'widget' => $this, |
|
233 | - ) |
|
234 | - ); |
|
235 | - ?> |
|
228 | + wpinv_get_template( |
|
229 | + 'subscriptions/subscriptions-table-row.php', |
|
230 | + array( |
|
231 | + 'subscription' => $subscription, |
|
232 | + 'widget' => $this, |
|
233 | + ) |
|
234 | + ); |
|
235 | + ?> |
|
236 | 236 | </tr> |
237 | 237 | <?php endforeach; ?> |
238 | 238 | |
239 | 239 | </tbody> |
240 | 240 | <?php |
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Adds row actions to a column |
|
245 | - * |
|
246 | - * @param string $content column content |
|
247 | - * @param WPInv_Subscription $subscription |
|
248 | - * @since 1.0.0 |
|
249 | - * @return string |
|
250 | - */ |
|
251 | - public function add_row_actions( $content, $subscription ) { |
|
252 | - |
|
253 | - // Prepare row actions. |
|
254 | - $actions = array(); |
|
255 | - |
|
256 | - // View subscription action. |
|
257 | - $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
258 | - $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
259 | - $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
260 | - |
|
261 | - // Filter the actions. |
|
262 | - $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
263 | - |
|
264 | - $sanitized = array(); |
|
265 | - foreach ( $actions as $key => $action ) { |
|
266 | - $key = sanitize_html_class( $key ); |
|
267 | - $action = wp_kses_post( $action ); |
|
268 | - $sanitized[] = "<span class='$key'>$action</span>"; |
|
269 | - } |
|
270 | - |
|
271 | - $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
|
272 | - $row_actions .= implode( ' | ', $sanitized ); |
|
273 | - $row_actions .= '</small>'; |
|
274 | - |
|
275 | - return $content . $row_actions; |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * Displays the table footer. |
|
280 | - * |
|
281 | - */ |
|
282 | - public function print_table_footer() { |
|
283 | - |
|
284 | - ?> |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Adds row actions to a column |
|
245 | + * |
|
246 | + * @param string $content column content |
|
247 | + * @param WPInv_Subscription $subscription |
|
248 | + * @since 1.0.0 |
|
249 | + * @return string |
|
250 | + */ |
|
251 | + public function add_row_actions( $content, $subscription ) { |
|
252 | + |
|
253 | + // Prepare row actions. |
|
254 | + $actions = array(); |
|
255 | + |
|
256 | + // View subscription action. |
|
257 | + $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
258 | + $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
259 | + $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
260 | + |
|
261 | + // Filter the actions. |
|
262 | + $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
263 | + |
|
264 | + $sanitized = array(); |
|
265 | + foreach ( $actions as $key => $action ) { |
|
266 | + $key = sanitize_html_class( $key ); |
|
267 | + $action = wp_kses_post( $action ); |
|
268 | + $sanitized[] = "<span class='$key'>$action</span>"; |
|
269 | + } |
|
270 | + |
|
271 | + $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
|
272 | + $row_actions .= implode( ' | ', $sanitized ); |
|
273 | + $row_actions .= '</small>'; |
|
274 | + |
|
275 | + return $content . $row_actions; |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * Displays the table footer. |
|
280 | + * |
|
281 | + */ |
|
282 | + public function print_table_footer() { |
|
283 | + |
|
284 | + ?> |
|
285 | 285 | |
286 | 286 | <tfoot> |
287 | 287 | <tr> |
@@ -296,145 +296,145 @@ discard block |
||
296 | 296 | </table> |
297 | 297 | <?php |
298 | 298 | |
299 | - } |
|
299 | + } |
|
300 | 300 | |
301 | - /** |
|
302 | - * Displays the navigation. |
|
303 | - * |
|
304 | - * @param int $total |
|
305 | - */ |
|
306 | - public function print_navigation( $total ) { |
|
301 | + /** |
|
302 | + * Displays the navigation. |
|
303 | + * |
|
304 | + * @param int $total |
|
305 | + */ |
|
306 | + public function print_navigation( $total ) { |
|
307 | 307 | |
308 | - if ( $total < 1 ) { |
|
308 | + if ( $total < 1 ) { |
|
309 | 309 | |
310 | - // Out-of-bounds, run the query again without LIMIT for total count. |
|
311 | - $args = array( |
|
312 | - 'customer_in' => get_current_user_id(), |
|
313 | - 'fields' => 'id', |
|
314 | - ); |
|
310 | + // Out-of-bounds, run the query again without LIMIT for total count. |
|
311 | + $args = array( |
|
312 | + 'customer_in' => get_current_user_id(), |
|
313 | + 'fields' => 'id', |
|
314 | + ); |
|
315 | 315 | |
316 | - $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
317 | - $total = $count_query->get_total(); |
|
318 | - } |
|
316 | + $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
317 | + $total = $count_query->get_total(); |
|
318 | + } |
|
319 | 319 | |
320 | - // Abort if we do not have pages. |
|
321 | - if ( 2 > $total ) { |
|
322 | - return; |
|
323 | - } |
|
320 | + // Abort if we do not have pages. |
|
321 | + if ( 2 > $total ) { |
|
322 | + return; |
|
323 | + } |
|
324 | 324 | |
325 | - ?> |
|
325 | + ?> |
|
326 | 326 | |
327 | 327 | <div class="getpaid-subscriptions-pagination"> |
328 | 328 | <?php |
329 | - $big = 999999; |
|
330 | - |
|
331 | - echo wp_kses_post( |
|
332 | - getpaid_paginate_links( |
|
333 | - array( |
|
334 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
335 | - 'format' => '?paged=%#%', |
|
336 | - 'total' => (int) ceil( $total / 10 ), |
|
337 | - ) |
|
338 | - ) |
|
339 | - ); |
|
340 | - ?> |
|
329 | + $big = 999999; |
|
330 | + |
|
331 | + echo wp_kses_post( |
|
332 | + getpaid_paginate_links( |
|
333 | + array( |
|
334 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
335 | + 'format' => '?paged=%#%', |
|
336 | + 'total' => (int) ceil( $total / 10 ), |
|
337 | + ) |
|
338 | + ) |
|
339 | + ); |
|
340 | + ?> |
|
341 | 341 | </div> |
342 | 342 | |
343 | 343 | <?php |
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Returns a single subscription's columns. |
|
348 | - * |
|
349 | - * @param WPInv_Subscription $subscription |
|
350 | - * |
|
351 | - * @return array |
|
352 | - */ |
|
353 | - public function get_single_subscription_columns( $subscription ) { |
|
354 | - |
|
355 | - // Prepare subscription detail columns. |
|
356 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
357 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
358 | - $fields = apply_filters( |
|
359 | - 'getpaid_single_subscription_details_fields', |
|
360 | - array( |
|
361 | - 'status' => __( 'Status', 'invoicing' ), |
|
362 | - 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
363 | - 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
364 | - 'start_date' => __( 'Start date', 'invoicing' ), |
|
365 | - 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
366 | - 'payments' => __( 'Payments', 'invoicing' ), |
|
367 | - 'item' => $items_count > 1 ? __( 'Items', $items_count, 'invoicing' ) : __( 'Item', 'invoicing' ) |
|
368 | - ), |
|
369 | - $subscription, |
|
370 | - $items_count |
|
371 | - ); |
|
372 | - |
|
373 | - if ( isset( $fields['expiry_date'] ) ) { |
|
374 | - |
|
375 | - if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
376 | - $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
377 | - } |
|
378 | - |
|
379 | - if ( 'pending' === $subscription->get_status() ) { |
|
380 | - unset( $fields['expiry_date'] ); |
|
381 | - } |
|
382 | - } |
|
383 | - |
|
384 | - if ( isset( $fields['start_date'] ) && 'pending' === $subscription->get_status() ) { |
|
385 | - unset( $fields['start_date'] ); |
|
386 | - } |
|
387 | - |
|
388 | - if ( $subscription->get_initial_amount() === $subscription->get_recurring_amount() ) { |
|
389 | - unset( $fields['initial_amount'] ); |
|
390 | - } |
|
391 | - |
|
392 | - return $fields; |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * Displays a single subscription. |
|
397 | - * |
|
398 | - * @param string $subscription |
|
399 | - * |
|
400 | - * @return string |
|
401 | - */ |
|
402 | - public function display_single_subscription( $subscription ) { |
|
403 | - |
|
404 | - // Fetch the subscription. |
|
405 | - $subscription = new WPInv_Subscription( (int) $subscription ); |
|
406 | - |
|
407 | - if ( ! $subscription->exists() ) { |
|
408 | - |
|
409 | - return aui()->alert( |
|
410 | - array( |
|
411 | - 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
412 | - 'type' => 'error', |
|
413 | - ) |
|
414 | - ); |
|
415 | - |
|
416 | - } |
|
417 | - |
|
418 | - // Ensure that the user owns this subscription key. |
|
419 | - if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
420 | - |
|
421 | - return aui()->alert( |
|
422 | - array( |
|
423 | - 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
424 | - 'type' => 'error', |
|
425 | - ) |
|
426 | - ); |
|
427 | - |
|
428 | - } |
|
429 | - |
|
430 | - return wpinv_get_template_html( |
|
431 | - 'subscriptions/subscription-details.php', |
|
432 | - array( |
|
433 | - 'subscription' => $subscription, |
|
434 | - 'widget' => $this, |
|
435 | - ) |
|
436 | - ); |
|
437 | - |
|
438 | - } |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * Returns a single subscription's columns. |
|
348 | + * |
|
349 | + * @param WPInv_Subscription $subscription |
|
350 | + * |
|
351 | + * @return array |
|
352 | + */ |
|
353 | + public function get_single_subscription_columns( $subscription ) { |
|
354 | + |
|
355 | + // Prepare subscription detail columns. |
|
356 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
357 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
358 | + $fields = apply_filters( |
|
359 | + 'getpaid_single_subscription_details_fields', |
|
360 | + array( |
|
361 | + 'status' => __( 'Status', 'invoicing' ), |
|
362 | + 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
363 | + 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
364 | + 'start_date' => __( 'Start date', 'invoicing' ), |
|
365 | + 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
366 | + 'payments' => __( 'Payments', 'invoicing' ), |
|
367 | + 'item' => $items_count > 1 ? __( 'Items', $items_count, 'invoicing' ) : __( 'Item', 'invoicing' ) |
|
368 | + ), |
|
369 | + $subscription, |
|
370 | + $items_count |
|
371 | + ); |
|
372 | + |
|
373 | + if ( isset( $fields['expiry_date'] ) ) { |
|
374 | + |
|
375 | + if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
376 | + $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
377 | + } |
|
378 | + |
|
379 | + if ( 'pending' === $subscription->get_status() ) { |
|
380 | + unset( $fields['expiry_date'] ); |
|
381 | + } |
|
382 | + } |
|
383 | + |
|
384 | + if ( isset( $fields['start_date'] ) && 'pending' === $subscription->get_status() ) { |
|
385 | + unset( $fields['start_date'] ); |
|
386 | + } |
|
387 | + |
|
388 | + if ( $subscription->get_initial_amount() === $subscription->get_recurring_amount() ) { |
|
389 | + unset( $fields['initial_amount'] ); |
|
390 | + } |
|
391 | + |
|
392 | + return $fields; |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * Displays a single subscription. |
|
397 | + * |
|
398 | + * @param string $subscription |
|
399 | + * |
|
400 | + * @return string |
|
401 | + */ |
|
402 | + public function display_single_subscription( $subscription ) { |
|
403 | + |
|
404 | + // Fetch the subscription. |
|
405 | + $subscription = new WPInv_Subscription( (int) $subscription ); |
|
406 | + |
|
407 | + if ( ! $subscription->exists() ) { |
|
408 | + |
|
409 | + return aui()->alert( |
|
410 | + array( |
|
411 | + 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
412 | + 'type' => 'error', |
|
413 | + ) |
|
414 | + ); |
|
415 | + |
|
416 | + } |
|
417 | + |
|
418 | + // Ensure that the user owns this subscription key. |
|
419 | + if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
420 | + |
|
421 | + return aui()->alert( |
|
422 | + array( |
|
423 | + 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
424 | + 'type' => 'error', |
|
425 | + ) |
|
426 | + ); |
|
427 | + |
|
428 | + } |
|
429 | + |
|
430 | + return wpinv_get_template_html( |
|
431 | + 'subscriptions/subscription-details.php', |
|
432 | + array( |
|
433 | + 'subscription' => $subscription, |
|
434 | + 'widget' => $this, |
|
435 | + ) |
|
436 | + ); |
|
437 | + |
|
438 | + } |
|
439 | 439 | |
440 | 440 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @version 1.0.0 |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Contains the subscriptions widget. |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | 'block-keywords' => "['invoicing','subscriptions', 'getpaid']", |
28 | 28 | 'class_name' => __CLASS__, |
29 | 29 | 'base_id' => 'wpinv_subscriptions', |
30 | - 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
30 | + 'name' => __('GetPaid > Subscriptions', 'invoicing'), |
|
31 | 31 | 'widget_ops' => array( |
32 | 32 | 'classname' => 'getpaid-subscriptions bsui', |
33 | - 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
33 | + 'description' => esc_html__("Displays the current user's subscriptions.", 'invoicing'), |
|
34 | 34 | ), |
35 | 35 | 'arguments' => array( |
36 | 36 | 'title' => array( |
37 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
38 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
37 | + 'title' => __('Widget title', 'invoicing'), |
|
38 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
39 | 39 | 'type' => 'text', |
40 | 40 | 'desc_tip' => true, |
41 | 41 | 'default' => '', |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | ); |
47 | 47 | |
48 | - parent::__construct( $options ); |
|
48 | + parent::__construct($options); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | public function get_subscriptions() { |
57 | 57 | |
58 | 58 | // Prepare license args. |
59 | - $args = array( |
|
59 | + $args = array( |
|
60 | 60 | 'customer_in' => get_current_user_id(), |
61 | - 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
61 | + 'paged' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
62 | 62 | ); |
63 | 63 | |
64 | - return new GetPaid_Subscriptions_Query( $args ); |
|
64 | + return new GetPaid_Subscriptions_Query($args); |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return mixed|string|bool |
76 | 76 | */ |
77 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
77 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
78 | 78 | |
79 | 79 | // Ensure that the user is logged in. |
80 | - if ( ! is_user_logged_in() ) { |
|
80 | + if (!is_user_logged_in()) { |
|
81 | 81 | |
82 | 82 | return aui()->alert( |
83 | 83 | array( |
84 | - 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
84 | + 'content' => wp_kses_post(__('You need to log-in or create an account to view this section.', 'invoicing')), |
|
85 | 85 | 'type' => 'error', |
86 | 86 | ) |
87 | 87 | ); |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | // Are we displaying a single subscription? |
92 | - if ( isset( $_GET['subscription'] ) ) { |
|
93 | - return $this->display_single_subscription( intval( $_GET['subscription'] ) ); |
|
92 | + if (isset($_GET['subscription'])) { |
|
93 | + return $this->display_single_subscription(intval($_GET['subscription'])); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | // Retrieve the user's subscriptions. |
@@ -100,27 +100,27 @@ discard block |
||
100 | 100 | ob_start(); |
101 | 101 | |
102 | 102 | // Backwards compatibility. |
103 | - do_action( 'wpinv_before_user_subscriptions' ); |
|
103 | + do_action('wpinv_before_user_subscriptions'); |
|
104 | 104 | |
105 | 105 | // Display errors and notices. |
106 | 106 | wpinv_print_errors(); |
107 | 107 | |
108 | - do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
108 | + do_action('getpaid_license_manager_before_subscriptions', $subscriptions); |
|
109 | 109 | |
110 | 110 | // Print the table header. |
111 | 111 | $this->print_table_header(); |
112 | 112 | |
113 | 113 | // Print table body. |
114 | - $this->print_table_body( $subscriptions->get_results() ); |
|
114 | + $this->print_table_body($subscriptions->get_results()); |
|
115 | 115 | |
116 | 116 | // Print table footer. |
117 | 117 | $this->print_table_footer(); |
118 | 118 | |
119 | 119 | // Print the navigation. |
120 | - $this->print_navigation( $subscriptions->get_total() ); |
|
120 | + $this->print_navigation($subscriptions->get_total()); |
|
121 | 121 | |
122 | 122 | // Backwards compatibility. |
123 | - do_action( 'wpinv_after_user_subscriptions' ); |
|
123 | + do_action('wpinv_after_user_subscriptions'); |
|
124 | 124 | |
125 | 125 | // Return the output. |
126 | 126 | return ob_get_clean(); |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | public function get_subscriptions_table_columns() { |
136 | 136 | |
137 | 137 | $columns = array( |
138 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
139 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
140 | - 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
141 | - 'status' => __( 'Status', 'invoicing' ), |
|
138 | + 'subscription' => __('Subscription', 'invoicing'), |
|
139 | + 'amount' => __('Amount', 'invoicing'), |
|
140 | + 'renewal-date' => __('Next payment', 'invoicing'), |
|
141 | + 'status' => __('Status', 'invoicing'), |
|
142 | 142 | ); |
143 | 143 | |
144 | - return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
144 | + return apply_filters('getpaid_frontend_subscriptions_table_columns', $columns); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | |
157 | 157 | <thead> |
158 | 158 | <tr> |
159 | - <?php foreach ( $this->get_subscriptions_table_columns() as $key => $label ) : ?> |
|
160 | - <th scope="col" class="font-weight-bold getpaid-subscriptions-table-<?php echo esc_attr( $key ); ?>"> |
|
161 | - <?php echo esc_html( $label ); ?> |
|
159 | + <?php foreach ($this->get_subscriptions_table_columns() as $key => $label) : ?> |
|
160 | + <th scope="col" class="font-weight-bold getpaid-subscriptions-table-<?php echo esc_attr($key); ?>"> |
|
161 | + <?php echo esc_html($label); ?> |
|
162 | 162 | </th> |
163 | 163 | <?php endforeach; ?> |
164 | 164 | </tr> |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @param WPInv_Subscription[] $subscriptions |
175 | 175 | */ |
176 | - public function print_table_body( $subscriptions ) { |
|
176 | + public function print_table_body($subscriptions) { |
|
177 | 177 | |
178 | - if ( empty( $subscriptions ) ) { |
|
178 | + if (empty($subscriptions)) { |
|
179 | 179 | $this->print_table_body_no_subscriptions(); |
180 | 180 | } else { |
181 | - $this->print_table_body_subscriptions( $subscriptions ); |
|
181 | + $this->print_table_body_subscriptions($subscriptions); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | } |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | <tbody> |
194 | 194 | |
195 | 195 | <tr> |
196 | - <td colspan="<?php echo count( $this->get_subscriptions_table_columns() ); ?>"> |
|
196 | + <td colspan="<?php echo count($this->get_subscriptions_table_columns()); ?>"> |
|
197 | 197 | |
198 | 198 | <?php |
199 | 199 | aui()->alert( |
200 | 200 | array( |
201 | - 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
201 | + 'content' => wp_kses_post(__('No subscriptions found.', 'invoicing')), |
|
202 | 202 | 'type' => 'warning', |
203 | 203 | ), |
204 | 204 | true |
@@ -217,12 +217,12 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @param WPInv_Subscription[] $subscriptions |
219 | 219 | */ |
220 | - public function print_table_body_subscriptions( $subscriptions ) { |
|
220 | + public function print_table_body_subscriptions($subscriptions) { |
|
221 | 221 | |
222 | 222 | ?> |
223 | 223 | <tbody> |
224 | 224 | |
225 | - <?php foreach ( $subscriptions as $subscription ) : ?> |
|
225 | + <?php foreach ($subscriptions as $subscription) : ?> |
|
226 | 226 | <tr class="getpaid-subscriptions-table-row subscription-<?php echo (int) $subscription->get_id(); ?>"> |
227 | 227 | <?php |
228 | 228 | wpinv_get_template( |
@@ -248,28 +248,28 @@ discard block |
||
248 | 248 | * @since 1.0.0 |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function add_row_actions( $content, $subscription ) { |
|
251 | + public function add_row_actions($content, $subscription) { |
|
252 | 252 | |
253 | 253 | // Prepare row actions. |
254 | 254 | $actions = array(); |
255 | 255 | |
256 | 256 | // View subscription action. |
257 | - $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
258 | - $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
259 | - $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
257 | + $view_url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page'))); |
|
258 | + $view_url = esc_url(add_query_arg('subscription', (int) $subscription->get_id(), $view_url)); |
|
259 | + $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __('Manage Subscription', 'invoicing') . '</a>'; |
|
260 | 260 | |
261 | 261 | // Filter the actions. |
262 | - $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
262 | + $actions = apply_filters('getpaid_subscriptions_table_subscription_actions', $actions, $subscription); |
|
263 | 263 | |
264 | - $sanitized = array(); |
|
265 | - foreach ( $actions as $key => $action ) { |
|
266 | - $key = sanitize_html_class( $key ); |
|
267 | - $action = wp_kses_post( $action ); |
|
264 | + $sanitized = array(); |
|
265 | + foreach ($actions as $key => $action) { |
|
266 | + $key = sanitize_html_class($key); |
|
267 | + $action = wp_kses_post($action); |
|
268 | 268 | $sanitized[] = "<span class='$key'>$action</span>"; |
269 | 269 | } |
270 | 270 | |
271 | 271 | $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
272 | - $row_actions .= implode( ' | ', $sanitized ); |
|
272 | + $row_actions .= implode(' | ', $sanitized); |
|
273 | 273 | $row_actions .= '</small>'; |
274 | 274 | |
275 | 275 | return $content . $row_actions; |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | |
286 | 286 | <tfoot> |
287 | 287 | <tr> |
288 | - <?php foreach ( $this->get_subscriptions_table_columns() as $key => $label ) : ?> |
|
289 | - <th class="font-weight-bold getpaid-subscriptions-<?php echo esc_attr( $key ); ?>"> |
|
290 | - <?php echo esc_html( $label ); ?> |
|
288 | + <?php foreach ($this->get_subscriptions_table_columns() as $key => $label) : ?> |
|
289 | + <th class="font-weight-bold getpaid-subscriptions-<?php echo esc_attr($key); ?>"> |
|
290 | + <?php echo esc_html($label); ?> |
|
291 | 291 | </th> |
292 | 292 | <?php endforeach; ?> |
293 | 293 | </tr> |
@@ -303,22 +303,22 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @param int $total |
305 | 305 | */ |
306 | - public function print_navigation( $total ) { |
|
306 | + public function print_navigation($total) { |
|
307 | 307 | |
308 | - if ( $total < 1 ) { |
|
308 | + if ($total < 1) { |
|
309 | 309 | |
310 | 310 | // Out-of-bounds, run the query again without LIMIT for total count. |
311 | - $args = array( |
|
311 | + $args = array( |
|
312 | 312 | 'customer_in' => get_current_user_id(), |
313 | 313 | 'fields' => 'id', |
314 | 314 | ); |
315 | 315 | |
316 | - $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
316 | + $count_query = new GetPaid_Subscriptions_Query($args); |
|
317 | 317 | $total = $count_query->get_total(); |
318 | 318 | } |
319 | 319 | |
320 | 320 | // Abort if we do not have pages. |
321 | - if ( 2 > $total ) { |
|
321 | + if (2 > $total) { |
|
322 | 322 | return; |
323 | 323 | } |
324 | 324 | |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | echo wp_kses_post( |
332 | 332 | getpaid_paginate_links( |
333 | 333 | array( |
334 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
334 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
335 | 335 | 'format' => '?paged=%#%', |
336 | - 'total' => (int) ceil( $total / 10 ), |
|
336 | + 'total' => (int) ceil($total / 10), |
|
337 | 337 | ) |
338 | 338 | ) |
339 | 339 | ); |
@@ -350,43 +350,43 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @return array |
352 | 352 | */ |
353 | - public function get_single_subscription_columns( $subscription ) { |
|
353 | + public function get_single_subscription_columns($subscription) { |
|
354 | 354 | |
355 | 355 | // Prepare subscription detail columns. |
356 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
357 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
356 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_invoice_id(), $subscription->get_id()); |
|
357 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
358 | 358 | $fields = apply_filters( |
359 | 359 | 'getpaid_single_subscription_details_fields', |
360 | 360 | array( |
361 | - 'status' => __( 'Status', 'invoicing' ), |
|
362 | - 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
363 | - 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
364 | - 'start_date' => __( 'Start date', 'invoicing' ), |
|
365 | - 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
366 | - 'payments' => __( 'Payments', 'invoicing' ), |
|
367 | - 'item' => $items_count > 1 ? __( 'Items', $items_count, 'invoicing' ) : __( 'Item', 'invoicing' ) |
|
361 | + 'status' => __('Status', 'invoicing'), |
|
362 | + 'initial_amount' => __('Initial amount', 'invoicing'), |
|
363 | + 'recurring_amount' => __('Recurring amount', 'invoicing'), |
|
364 | + 'start_date' => __('Start date', 'invoicing'), |
|
365 | + 'expiry_date' => __('Next payment', 'invoicing'), |
|
366 | + 'payments' => __('Payments', 'invoicing'), |
|
367 | + 'item' => $items_count > 1 ? __('Items', $items_count, 'invoicing') : __('Item', 'invoicing') |
|
368 | 368 | ), |
369 | 369 | $subscription, |
370 | 370 | $items_count |
371 | 371 | ); |
372 | 372 | |
373 | - if ( isset( $fields['expiry_date'] ) ) { |
|
373 | + if (isset($fields['expiry_date'])) { |
|
374 | 374 | |
375 | - if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
376 | - $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
375 | + if (!$subscription->is_active() || $subscription->is_last_renewal()) { |
|
376 | + $fields['expiry_date'] = __('End date', 'invoicing'); |
|
377 | 377 | } |
378 | 378 | |
379 | - if ( 'pending' === $subscription->get_status() ) { |
|
380 | - unset( $fields['expiry_date'] ); |
|
379 | + if ('pending' === $subscription->get_status()) { |
|
380 | + unset($fields['expiry_date']); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | - if ( isset( $fields['start_date'] ) && 'pending' === $subscription->get_status() ) { |
|
385 | - unset( $fields['start_date'] ); |
|
384 | + if (isset($fields['start_date']) && 'pending' === $subscription->get_status()) { |
|
385 | + unset($fields['start_date']); |
|
386 | 386 | } |
387 | 387 | |
388 | - if ( $subscription->get_initial_amount() === $subscription->get_recurring_amount() ) { |
|
389 | - unset( $fields['initial_amount'] ); |
|
388 | + if ($subscription->get_initial_amount() === $subscription->get_recurring_amount()) { |
|
389 | + unset($fields['initial_amount']); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | return $fields; |
@@ -399,16 +399,16 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return string |
401 | 401 | */ |
402 | - public function display_single_subscription( $subscription ) { |
|
402 | + public function display_single_subscription($subscription) { |
|
403 | 403 | |
404 | 404 | // Fetch the subscription. |
405 | - $subscription = new WPInv_Subscription( (int) $subscription ); |
|
405 | + $subscription = new WPInv_Subscription((int) $subscription); |
|
406 | 406 | |
407 | - if ( ! $subscription->exists() ) { |
|
407 | + if (!$subscription->exists()) { |
|
408 | 408 | |
409 | 409 | return aui()->alert( |
410 | 410 | array( |
411 | - 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
411 | + 'content' => wp_kses_post(__('Subscription not found.', 'invoicing')), |
|
412 | 412 | 'type' => 'error', |
413 | 413 | ) |
414 | 414 | ); |
@@ -416,11 +416,11 @@ discard block |
||
416 | 416 | } |
417 | 417 | |
418 | 418 | // Ensure that the user owns this subscription key. |
419 | - if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
419 | + if (get_current_user_id() != $subscription->get_customer_id() && !wpinv_current_user_can_manage_invoicing()) { |
|
420 | 420 | |
421 | 421 | return aui()->alert( |
422 | 422 | array( |
423 | - 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
423 | + 'content' => wp_kses_post(__('You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing')), |
|
424 | 424 | 'type' => 'error', |
425 | 425 | ) |
426 | 426 | ); |