@@ -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,121 +166,121 @@ 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 | - echo aui()->alert( |
|
200 | - array( |
|
201 | - 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
202 | - 'type' => 'warning', |
|
203 | - ) |
|
204 | - ); |
|
205 | - ?> |
|
199 | + echo aui()->alert( |
|
200 | + array( |
|
201 | + 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
202 | + 'type' => 'warning', |
|
203 | + ) |
|
204 | + ); |
|
205 | + ?> |
|
206 | 206 | |
207 | 207 | </td> |
208 | 208 | </tr> |
209 | 209 | |
210 | 210 | </tbody> |
211 | 211 | <?php |
212 | - } |
|
212 | + } |
|
213 | 213 | |
214 | - /** |
|
215 | - * Displays the table body if subscriptions were found. |
|
216 | - * |
|
217 | - * @param WPInv_Subscription[] $subscriptions |
|
218 | - */ |
|
219 | - public function print_table_body_subscriptions( $subscriptions ) { |
|
214 | + /** |
|
215 | + * Displays the table body if subscriptions were found. |
|
216 | + * |
|
217 | + * @param WPInv_Subscription[] $subscriptions |
|
218 | + */ |
|
219 | + public function print_table_body_subscriptions( $subscriptions ) { |
|
220 | 220 | |
221 | - ?> |
|
221 | + ?> |
|
222 | 222 | <tbody> |
223 | 223 | |
224 | 224 | <?php foreach ( $subscriptions as $subscription ) : ?> |
225 | 225 | <tr class="getpaid-subscriptions-table-row subscription-<?php echo (int) $subscription->get_id(); ?>"> |
226 | 226 | <?php |
227 | - wpinv_get_template( |
|
228 | - 'subscriptions/subscriptions-table-row.php', |
|
229 | - array( |
|
230 | - 'subscription' => $subscription, |
|
231 | - 'widget' => $this, |
|
232 | - ) |
|
233 | - ); |
|
234 | - ?> |
|
227 | + wpinv_get_template( |
|
228 | + 'subscriptions/subscriptions-table-row.php', |
|
229 | + array( |
|
230 | + 'subscription' => $subscription, |
|
231 | + 'widget' => $this, |
|
232 | + ) |
|
233 | + ); |
|
234 | + ?> |
|
235 | 235 | </tr> |
236 | 236 | <?php endforeach; ?> |
237 | 237 | |
238 | 238 | </tbody> |
239 | 239 | <?php |
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * Adds row actions to a column |
|
244 | - * |
|
245 | - * @param string $content column content |
|
246 | - * @param WPInv_Subscription $subscription |
|
247 | - * @since 1.0.0 |
|
248 | - * @return string |
|
249 | - */ |
|
250 | - public function add_row_actions( $content, $subscription ) { |
|
251 | - |
|
252 | - // Prepare row actions. |
|
253 | - $actions = array(); |
|
254 | - |
|
255 | - // View subscription action. |
|
256 | - $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
257 | - $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
258 | - $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
259 | - |
|
260 | - // Filter the actions. |
|
261 | - $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
262 | - |
|
263 | - $sanitized = array(); |
|
264 | - foreach ( $actions as $key => $action ) { |
|
265 | - $key = sanitize_html_class( $key ); |
|
266 | - $action = wp_kses_post( $action ); |
|
267 | - $sanitized[] = "<span class='$key'>$action</span>"; |
|
268 | - } |
|
269 | - |
|
270 | - $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
|
271 | - $row_actions .= implode( ' | ', $sanitized ); |
|
272 | - $row_actions .= '</small>'; |
|
273 | - |
|
274 | - return $content . $row_actions; |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * Displays the table footer. |
|
279 | - * |
|
280 | - */ |
|
281 | - public function print_table_footer() { |
|
282 | - |
|
283 | - ?> |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * Adds row actions to a column |
|
244 | + * |
|
245 | + * @param string $content column content |
|
246 | + * @param WPInv_Subscription $subscription |
|
247 | + * @since 1.0.0 |
|
248 | + * @return string |
|
249 | + */ |
|
250 | + public function add_row_actions( $content, $subscription ) { |
|
251 | + |
|
252 | + // Prepare row actions. |
|
253 | + $actions = array(); |
|
254 | + |
|
255 | + // View subscription action. |
|
256 | + $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
257 | + $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
258 | + $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
259 | + |
|
260 | + // Filter the actions. |
|
261 | + $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
262 | + |
|
263 | + $sanitized = array(); |
|
264 | + foreach ( $actions as $key => $action ) { |
|
265 | + $key = sanitize_html_class( $key ); |
|
266 | + $action = wp_kses_post( $action ); |
|
267 | + $sanitized[] = "<span class='$key'>$action</span>"; |
|
268 | + } |
|
269 | + |
|
270 | + $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
|
271 | + $row_actions .= implode( ' | ', $sanitized ); |
|
272 | + $row_actions .= '</small>'; |
|
273 | + |
|
274 | + return $content . $row_actions; |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * Displays the table footer. |
|
279 | + * |
|
280 | + */ |
|
281 | + public function print_table_footer() { |
|
282 | + |
|
283 | + ?> |
|
284 | 284 | |
285 | 285 | <tfoot> |
286 | 286 | <tr> |
@@ -295,142 +295,142 @@ discard block |
||
295 | 295 | </table> |
296 | 296 | <?php |
297 | 297 | |
298 | - } |
|
298 | + } |
|
299 | 299 | |
300 | - /** |
|
301 | - * Displays the navigation. |
|
302 | - * |
|
303 | - * @param int $total |
|
304 | - */ |
|
305 | - public function print_navigation( $total ) { |
|
300 | + /** |
|
301 | + * Displays the navigation. |
|
302 | + * |
|
303 | + * @param int $total |
|
304 | + */ |
|
305 | + public function print_navigation( $total ) { |
|
306 | 306 | |
307 | - if ( $total < 1 ) { |
|
307 | + if ( $total < 1 ) { |
|
308 | 308 | |
309 | - // Out-of-bounds, run the query again without LIMIT for total count. |
|
310 | - $args = array( |
|
311 | - 'customer_in' => get_current_user_id(), |
|
312 | - 'fields' => 'id', |
|
313 | - ); |
|
309 | + // Out-of-bounds, run the query again without LIMIT for total count. |
|
310 | + $args = array( |
|
311 | + 'customer_in' => get_current_user_id(), |
|
312 | + 'fields' => 'id', |
|
313 | + ); |
|
314 | 314 | |
315 | - $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
316 | - $total = $count_query->get_total(); |
|
317 | - } |
|
315 | + $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
316 | + $total = $count_query->get_total(); |
|
317 | + } |
|
318 | 318 | |
319 | - // Abort if we do not have pages. |
|
320 | - if ( 2 > $total ) { |
|
321 | - return; |
|
322 | - } |
|
319 | + // Abort if we do not have pages. |
|
320 | + if ( 2 > $total ) { |
|
321 | + return; |
|
322 | + } |
|
323 | 323 | |
324 | - ?> |
|
324 | + ?> |
|
325 | 325 | |
326 | 326 | <div class="getpaid-subscriptions-pagination"> |
327 | 327 | <?php |
328 | - $big = 999999; |
|
329 | - |
|
330 | - echo getpaid_paginate_links( |
|
331 | - array( |
|
332 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
333 | - 'format' => '?paged=%#%', |
|
334 | - 'total' => (int) ceil( $total / 10 ), |
|
335 | - ) |
|
336 | - ); |
|
337 | - ?> |
|
328 | + $big = 999999; |
|
329 | + |
|
330 | + echo getpaid_paginate_links( |
|
331 | + array( |
|
332 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
333 | + 'format' => '?paged=%#%', |
|
334 | + 'total' => (int) ceil( $total / 10 ), |
|
335 | + ) |
|
336 | + ); |
|
337 | + ?> |
|
338 | 338 | </div> |
339 | 339 | |
340 | 340 | <?php |
341 | - } |
|
342 | - |
|
343 | - /** |
|
344 | - * Returns a single subscription's columns. |
|
345 | - * |
|
346 | - * @param WPInv_Subscription $subscription |
|
347 | - * |
|
348 | - * @return array |
|
349 | - */ |
|
350 | - public function get_single_subscription_columns( $subscription ) { |
|
351 | - |
|
352 | - // Prepare subscription detail columns. |
|
353 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
354 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
355 | - $fields = apply_filters( |
|
356 | - 'getpaid_single_subscription_details_fields', |
|
357 | - array( |
|
358 | - 'status' => __( 'Status', 'invoicing' ), |
|
359 | - 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
360 | - 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
361 | - 'start_date' => __( 'Start date', 'invoicing' ), |
|
362 | - 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
363 | - 'payments' => __( 'Payments', 'invoicing' ), |
|
364 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
365 | - ), |
|
366 | - $subscription |
|
367 | - ); |
|
368 | - |
|
369 | - if ( isset( $fields['expiry_date'] ) ) { |
|
370 | - |
|
371 | - if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
372 | - $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
373 | - } |
|
374 | - |
|
375 | - if ( 'pending' == $subscription->get_status() ) { |
|
376 | - unset( $fields['expiry_date'] ); |
|
377 | - } |
|
341 | + } |
|
342 | + |
|
343 | + /** |
|
344 | + * Returns a single subscription's columns. |
|
345 | + * |
|
346 | + * @param WPInv_Subscription $subscription |
|
347 | + * |
|
348 | + * @return array |
|
349 | + */ |
|
350 | + public function get_single_subscription_columns( $subscription ) { |
|
351 | + |
|
352 | + // Prepare subscription detail columns. |
|
353 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
354 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
355 | + $fields = apply_filters( |
|
356 | + 'getpaid_single_subscription_details_fields', |
|
357 | + array( |
|
358 | + 'status' => __( 'Status', 'invoicing' ), |
|
359 | + 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
360 | + 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
361 | + 'start_date' => __( 'Start date', 'invoicing' ), |
|
362 | + 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
363 | + 'payments' => __( 'Payments', 'invoicing' ), |
|
364 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
365 | + ), |
|
366 | + $subscription |
|
367 | + ); |
|
368 | + |
|
369 | + if ( isset( $fields['expiry_date'] ) ) { |
|
370 | + |
|
371 | + if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
372 | + $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
373 | + } |
|
374 | + |
|
375 | + if ( 'pending' == $subscription->get_status() ) { |
|
376 | + unset( $fields['expiry_date'] ); |
|
377 | + } |
|
378 | 378 | } |
379 | 379 | |
380 | - if ( isset( $fields['start_date'] ) && 'pending' == $subscription->get_status() ) { |
|
381 | - unset( $fields['start_date'] ); |
|
382 | - } |
|
383 | - |
|
384 | - if ( $subscription->get_initial_amount() == $subscription->get_recurring_amount() ) { |
|
385 | - unset( $fields['initial_amount'] ); |
|
386 | - } |
|
387 | - |
|
388 | - return $fields; |
|
389 | - } |
|
390 | - |
|
391 | - /** |
|
392 | - * Displays a single subscription. |
|
393 | - * |
|
394 | - * @param string $subscription |
|
395 | - * |
|
396 | - * @return string |
|
397 | - */ |
|
398 | - public function display_single_subscription( $subscription ) { |
|
399 | - |
|
400 | - // Fetch the subscription. |
|
401 | - $subscription = new WPInv_Subscription( (int) $subscription ); |
|
402 | - |
|
403 | - if ( ! $subscription->exists() ) { |
|
404 | - |
|
405 | - return aui()->alert( |
|
406 | - array( |
|
407 | - 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
408 | - 'type' => 'error', |
|
409 | - ) |
|
410 | - ); |
|
411 | - |
|
412 | - } |
|
413 | - |
|
414 | - // Ensure that the user owns this subscription key. |
|
415 | - if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
416 | - |
|
417 | - return aui()->alert( |
|
418 | - array( |
|
419 | - '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' ) ), |
|
420 | - 'type' => 'error', |
|
421 | - ) |
|
422 | - ); |
|
423 | - |
|
424 | - } |
|
425 | - |
|
426 | - return wpinv_get_template_html( |
|
427 | - 'subscriptions/subscription-details.php', |
|
428 | - array( |
|
429 | - 'subscription' => $subscription, |
|
430 | - 'widget' => $this, |
|
431 | - ) |
|
432 | - ); |
|
433 | - |
|
434 | - } |
|
380 | + if ( isset( $fields['start_date'] ) && 'pending' == $subscription->get_status() ) { |
|
381 | + unset( $fields['start_date'] ); |
|
382 | + } |
|
383 | + |
|
384 | + if ( $subscription->get_initial_amount() == $subscription->get_recurring_amount() ) { |
|
385 | + unset( $fields['initial_amount'] ); |
|
386 | + } |
|
387 | + |
|
388 | + return $fields; |
|
389 | + } |
|
390 | + |
|
391 | + /** |
|
392 | + * Displays a single subscription. |
|
393 | + * |
|
394 | + * @param string $subscription |
|
395 | + * |
|
396 | + * @return string |
|
397 | + */ |
|
398 | + public function display_single_subscription( $subscription ) { |
|
399 | + |
|
400 | + // Fetch the subscription. |
|
401 | + $subscription = new WPInv_Subscription( (int) $subscription ); |
|
402 | + |
|
403 | + if ( ! $subscription->exists() ) { |
|
404 | + |
|
405 | + return aui()->alert( |
|
406 | + array( |
|
407 | + 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
408 | + 'type' => 'error', |
|
409 | + ) |
|
410 | + ); |
|
411 | + |
|
412 | + } |
|
413 | + |
|
414 | + // Ensure that the user owns this subscription key. |
|
415 | + if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
416 | + |
|
417 | + return aui()->alert( |
|
418 | + array( |
|
419 | + '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' ) ), |
|
420 | + 'type' => 'error', |
|
421 | + ) |
|
422 | + ); |
|
423 | + |
|
424 | + } |
|
425 | + |
|
426 | + return wpinv_get_template_html( |
|
427 | + 'subscriptions/subscription-details.php', |
|
428 | + array( |
|
429 | + 'subscription' => $subscription, |
|
430 | + 'widget' => $this, |
|
431 | + ) |
|
432 | + ); |
|
433 | + |
|
434 | + } |
|
435 | 435 | |
436 | 436 | } |
@@ -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 sanitize_html_class( $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 sanitize_html_class($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 | echo 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 | ); |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @param WPInv_Subscription[] $subscriptions |
218 | 218 | */ |
219 | - public function print_table_body_subscriptions( $subscriptions ) { |
|
219 | + public function print_table_body_subscriptions($subscriptions) { |
|
220 | 220 | |
221 | 221 | ?> |
222 | 222 | <tbody> |
223 | 223 | |
224 | - <?php foreach ( $subscriptions as $subscription ) : ?> |
|
224 | + <?php foreach ($subscriptions as $subscription) : ?> |
|
225 | 225 | <tr class="getpaid-subscriptions-table-row subscription-<?php echo (int) $subscription->get_id(); ?>"> |
226 | 226 | <?php |
227 | 227 | wpinv_get_template( |
@@ -247,28 +247,28 @@ discard block |
||
247 | 247 | * @since 1.0.0 |
248 | 248 | * @return string |
249 | 249 | */ |
250 | - public function add_row_actions( $content, $subscription ) { |
|
250 | + public function add_row_actions($content, $subscription) { |
|
251 | 251 | |
252 | 252 | // Prepare row actions. |
253 | 253 | $actions = array(); |
254 | 254 | |
255 | 255 | // View subscription action. |
256 | - $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
257 | - $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
258 | - $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
256 | + $view_url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page'))); |
|
257 | + $view_url = esc_url(add_query_arg('subscription', (int) $subscription->get_id(), $view_url)); |
|
258 | + $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __('Manage Subscription', 'invoicing') . '</a>'; |
|
259 | 259 | |
260 | 260 | // Filter the actions. |
261 | - $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
261 | + $actions = apply_filters('getpaid_subscriptions_table_subscription_actions', $actions, $subscription); |
|
262 | 262 | |
263 | - $sanitized = array(); |
|
264 | - foreach ( $actions as $key => $action ) { |
|
265 | - $key = sanitize_html_class( $key ); |
|
266 | - $action = wp_kses_post( $action ); |
|
263 | + $sanitized = array(); |
|
264 | + foreach ($actions as $key => $action) { |
|
265 | + $key = sanitize_html_class($key); |
|
266 | + $action = wp_kses_post($action); |
|
267 | 267 | $sanitized[] = "<span class='$key'>$action</span>"; |
268 | 268 | } |
269 | 269 | |
270 | 270 | $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
271 | - $row_actions .= implode( ' | ', $sanitized ); |
|
271 | + $row_actions .= implode(' | ', $sanitized); |
|
272 | 272 | $row_actions .= '</small>'; |
273 | 273 | |
274 | 274 | return $content . $row_actions; |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | |
285 | 285 | <tfoot> |
286 | 286 | <tr> |
287 | - <?php foreach ( $this->get_subscriptions_table_columns() as $key => $label ) : ?> |
|
288 | - <th class="font-weight-bold getpaid-subscriptions-<?php echo sanitize_html_class( $key ); ?>"> |
|
289 | - <?php echo esc_html( $label ); ?> |
|
287 | + <?php foreach ($this->get_subscriptions_table_columns() as $key => $label) : ?> |
|
288 | + <th class="font-weight-bold getpaid-subscriptions-<?php echo sanitize_html_class($key); ?>"> |
|
289 | + <?php echo esc_html($label); ?> |
|
290 | 290 | </th> |
291 | 291 | <?php endforeach; ?> |
292 | 292 | </tr> |
@@ -302,22 +302,22 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @param int $total |
304 | 304 | */ |
305 | - public function print_navigation( $total ) { |
|
305 | + public function print_navigation($total) { |
|
306 | 306 | |
307 | - if ( $total < 1 ) { |
|
307 | + if ($total < 1) { |
|
308 | 308 | |
309 | 309 | // Out-of-bounds, run the query again without LIMIT for total count. |
310 | - $args = array( |
|
310 | + $args = array( |
|
311 | 311 | 'customer_in' => get_current_user_id(), |
312 | 312 | 'fields' => 'id', |
313 | 313 | ); |
314 | 314 | |
315 | - $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
315 | + $count_query = new GetPaid_Subscriptions_Query($args); |
|
316 | 316 | $total = $count_query->get_total(); |
317 | 317 | } |
318 | 318 | |
319 | 319 | // Abort if we do not have pages. |
320 | - if ( 2 > $total ) { |
|
320 | + if (2 > $total) { |
|
321 | 321 | return; |
322 | 322 | } |
323 | 323 | |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | |
330 | 330 | echo getpaid_paginate_links( |
331 | 331 | array( |
332 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
332 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
333 | 333 | 'format' => '?paged=%#%', |
334 | - 'total' => (int) ceil( $total / 10 ), |
|
334 | + 'total' => (int) ceil($total / 10), |
|
335 | 335 | ) |
336 | 336 | ); |
337 | 337 | ?> |
@@ -347,42 +347,42 @@ discard block |
||
347 | 347 | * |
348 | 348 | * @return array |
349 | 349 | */ |
350 | - public function get_single_subscription_columns( $subscription ) { |
|
350 | + public function get_single_subscription_columns($subscription) { |
|
351 | 351 | |
352 | 352 | // Prepare subscription detail columns. |
353 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
354 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
353 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_invoice_id(), $subscription->get_id()); |
|
354 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
355 | 355 | $fields = apply_filters( |
356 | 356 | 'getpaid_single_subscription_details_fields', |
357 | 357 | array( |
358 | - 'status' => __( 'Status', 'invoicing' ), |
|
359 | - 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
360 | - 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
361 | - 'start_date' => __( 'Start date', 'invoicing' ), |
|
362 | - 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
363 | - 'payments' => __( 'Payments', 'invoicing' ), |
|
364 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
358 | + 'status' => __('Status', 'invoicing'), |
|
359 | + 'initial_amount' => __('Initial amount', 'invoicing'), |
|
360 | + 'recurring_amount' => __('Recurring amount', 'invoicing'), |
|
361 | + 'start_date' => __('Start date', 'invoicing'), |
|
362 | + 'expiry_date' => __('Next payment', 'invoicing'), |
|
363 | + 'payments' => __('Payments', 'invoicing'), |
|
364 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
365 | 365 | ), |
366 | 366 | $subscription |
367 | 367 | ); |
368 | 368 | |
369 | - if ( isset( $fields['expiry_date'] ) ) { |
|
369 | + if (isset($fields['expiry_date'])) { |
|
370 | 370 | |
371 | - if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
372 | - $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
371 | + if (!$subscription->is_active() || $subscription->is_last_renewal()) { |
|
372 | + $fields['expiry_date'] = __('End date', 'invoicing'); |
|
373 | 373 | } |
374 | 374 | |
375 | - if ( 'pending' == $subscription->get_status() ) { |
|
376 | - unset( $fields['expiry_date'] ); |
|
375 | + if ('pending' == $subscription->get_status()) { |
|
376 | + unset($fields['expiry_date']); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
380 | - if ( isset( $fields['start_date'] ) && 'pending' == $subscription->get_status() ) { |
|
381 | - unset( $fields['start_date'] ); |
|
380 | + if (isset($fields['start_date']) && 'pending' == $subscription->get_status()) { |
|
381 | + unset($fields['start_date']); |
|
382 | 382 | } |
383 | 383 | |
384 | - if ( $subscription->get_initial_amount() == $subscription->get_recurring_amount() ) { |
|
385 | - unset( $fields['initial_amount'] ); |
|
384 | + if ($subscription->get_initial_amount() == $subscription->get_recurring_amount()) { |
|
385 | + unset($fields['initial_amount']); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | return $fields; |
@@ -395,16 +395,16 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @return string |
397 | 397 | */ |
398 | - public function display_single_subscription( $subscription ) { |
|
398 | + public function display_single_subscription($subscription) { |
|
399 | 399 | |
400 | 400 | // Fetch the subscription. |
401 | - $subscription = new WPInv_Subscription( (int) $subscription ); |
|
401 | + $subscription = new WPInv_Subscription((int) $subscription); |
|
402 | 402 | |
403 | - if ( ! $subscription->exists() ) { |
|
403 | + if (!$subscription->exists()) { |
|
404 | 404 | |
405 | 405 | return aui()->alert( |
406 | 406 | array( |
407 | - 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
407 | + 'content' => wp_kses_post(__('Subscription not found.', 'invoicing')), |
|
408 | 408 | 'type' => 'error', |
409 | 409 | ) |
410 | 410 | ); |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | } |
413 | 413 | |
414 | 414 | // Ensure that the user owns this subscription key. |
415 | - if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
415 | + if (get_current_user_id() != $subscription->get_customer_id() && !wpinv_current_user_can_manage_invoicing()) { |
|
416 | 416 | |
417 | 417 | return aui()->alert( |
418 | 418 | array( |
419 | - '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' ) ), |
|
419 | + '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')), |
|
420 | 420 | 'type' => 'error', |
421 | 421 | ) |
422 | 422 | ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | 'block-keywords' => "['invoicing','checkout']", |
23 | 23 | 'class_name' => __CLASS__, |
24 | 24 | 'base_id' => 'wpinv_checkout', |
25 | - 'name' => __( 'GetPaid > Checkout', 'invoicing' ), |
|
25 | + 'name' => __('GetPaid > Checkout', 'invoicing'), |
|
26 | 26 | 'widget_ops' => array( |
27 | 27 | 'classname' => 'getpaid-checkout bsui', |
28 | - 'description' => esc_html__( 'Displays a checkout form.', 'invoicing' ), |
|
28 | + 'description' => esc_html__('Displays a checkout form.', 'invoicing'), |
|
29 | 29 | ), |
30 | 30 | 'arguments' => array( |
31 | 31 | 'title' => array( |
32 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
33 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
32 | + 'title' => __('Widget title', 'invoicing'), |
|
33 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
34 | 34 | 'type' => 'text', |
35 | 35 | 'desc_tip' => true, |
36 | 36 | 'default' => '', |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | ); |
42 | 42 | |
43 | - parent::__construct( $options ); |
|
43 | + parent::__construct($options); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return mixed|string|bool |
54 | 54 | */ |
55 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
55 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
56 | 56 | return wpinv_checkout_form(); |
57 | 57 | } |
58 | 58 |
@@ -37,29 +37,29 @@ discard block |
||
37 | 37 | 'advanced' => false, |
38 | 38 | ), |
39 | 39 | 'items' => array( |
40 | - 'title' => __( 'Items to buy', 'invoicing' ), |
|
41 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing' ), |
|
42 | - 'type' => 'text', |
|
43 | - 'desc_tip' => true, |
|
44 | - 'default' => '', |
|
45 | - 'placeholder' => __( 'Items to buy', 'invoicing' ), |
|
46 | - 'advanced' => false, |
|
40 | + 'title' => __( 'Items to buy', 'invoicing' ), |
|
41 | + 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing' ), |
|
42 | + 'type' => 'text', |
|
43 | + 'desc_tip' => true, |
|
44 | + 'default' => '', |
|
45 | + 'placeholder' => __( 'Items to buy', 'invoicing' ), |
|
46 | + 'advanced' => false, |
|
47 | 47 | ), |
48 | 48 | 'label' => array( |
49 | - 'title' => __( 'Button Label', 'invoicing' ), |
|
50 | - 'desc' => __( 'Enter button label. Default "Buy Now".', 'invoicing' ), |
|
51 | - 'type' => 'text', |
|
52 | - 'desc_tip' => true, |
|
53 | - 'default' => __( 'Buy Now', 'invoicing' ), |
|
54 | - 'advanced' => false, |
|
49 | + 'title' => __( 'Button Label', 'invoicing' ), |
|
50 | + 'desc' => __( 'Enter button label. Default "Buy Now".', 'invoicing' ), |
|
51 | + 'type' => 'text', |
|
52 | + 'desc_tip' => true, |
|
53 | + 'default' => __( 'Buy Now', 'invoicing' ), |
|
54 | + 'advanced' => false, |
|
55 | 55 | ), |
56 | 56 | 'post_id' => array( |
57 | - 'title' => __( 'Post ID', 'invoicing' ), |
|
58 | - 'desc' => __( 'Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing' ), |
|
59 | - 'type' => 'number', |
|
60 | - 'desc_tip' => true, |
|
61 | - 'default' => '', |
|
62 | - 'advanced' => true, |
|
57 | + 'title' => __( 'Post ID', 'invoicing' ), |
|
58 | + 'desc' => __( 'Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing' ), |
|
59 | + 'type' => 'number', |
|
60 | + 'desc_tip' => true, |
|
61 | + 'default' => '', |
|
62 | + 'advanced' => true, |
|
63 | 63 | ), |
64 | 64 | ), |
65 | 65 | |
@@ -68,43 +68,43 @@ discard block |
||
68 | 68 | parent::__construct( $options ); |
69 | 69 | } |
70 | 70 | |
71 | - /** |
|
72 | - * The Super block output function. |
|
73 | - * |
|
74 | - * @param array $args |
|
75 | - * @param array $widget_args |
|
76 | - * @param string $content |
|
77 | - * |
|
78 | - * @return string |
|
79 | - */ |
|
71 | + /** |
|
72 | + * The Super block output function. |
|
73 | + * |
|
74 | + * @param array $args |
|
75 | + * @param array $widget_args |
|
76 | + * @param string $content |
|
77 | + * |
|
78 | + * @return string |
|
79 | + */ |
|
80 | 80 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
81 | 81 | |
82 | - $defaults = array( |
|
83 | - 'items' => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity |
|
84 | - 'label' => __( 'Buy Now', 'invoicing' ), // the button title |
|
85 | - 'post_id' => '', // any related post_id |
|
86 | - ); |
|
82 | + $defaults = array( |
|
83 | + 'items' => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity |
|
84 | + 'label' => __( 'Buy Now', 'invoicing' ), // the button title |
|
85 | + 'post_id' => '', // any related post_id |
|
86 | + ); |
|
87 | 87 | |
88 | - /** |
|
89 | - * Parse incoming $args into an array and merge it with $defaults |
|
90 | - */ |
|
91 | - $args = wp_parse_args( $args, $defaults ); |
|
88 | + /** |
|
89 | + * Parse incoming $args into an array and merge it with $defaults |
|
90 | + */ |
|
91 | + $args = wp_parse_args( $args, $defaults ); |
|
92 | 92 | |
93 | - $html = '<div class="wpi-buy-button-wrapper wpi-g">'; |
|
93 | + $html = '<div class="wpi-buy-button-wrapper wpi-g">'; |
|
94 | 94 | |
95 | - if ( empty( $args['items'] ) ) { |
|
96 | - $html .= __( 'No items selected', 'invoicing' ); |
|
97 | - } else { |
|
98 | - $post_id = isset( $args['post_id'] ) && is_numeric( $args['post_id'] ) ? sanitize_text_field( $args['post_id'] ) : 0; |
|
99 | - $label = isset( $args['label'] ) ? sanitize_text_field( $args['label'] ) : __( 'Buy Now', 'invoicing' ); |
|
100 | - $items = esc_attr( $args['items'] ); |
|
101 | - $html .= "<button class='button button-primary wpi-buy-button' type='button' onclick=\"wpi_buy(this, '$items','$post_id');\">$label</button>"; |
|
102 | - } |
|
95 | + if ( empty( $args['items'] ) ) { |
|
96 | + $html .= __( 'No items selected', 'invoicing' ); |
|
97 | + } else { |
|
98 | + $post_id = isset( $args['post_id'] ) && is_numeric( $args['post_id'] ) ? sanitize_text_field( $args['post_id'] ) : 0; |
|
99 | + $label = isset( $args['label'] ) ? sanitize_text_field( $args['label'] ) : __( 'Buy Now', 'invoicing' ); |
|
100 | + $items = esc_attr( $args['items'] ); |
|
101 | + $html .= "<button class='button button-primary wpi-buy-button' type='button' onclick=\"wpi_buy(this, '$items','$post_id');\">$label</button>"; |
|
102 | + } |
|
103 | 103 | |
104 | - $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false ); |
|
105 | - $html .= '</div>'; |
|
104 | + $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false ); |
|
105 | + $html .= '</div>'; |
|
106 | 106 | |
107 | - return $html; |
|
107 | + return $html; |
|
108 | 108 | |
109 | 109 | } |
110 | 110 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -22,40 +22,40 @@ discard block |
||
22 | 22 | 'block-keywords' => "['invoicing','buy', 'buy item']", |
23 | 23 | 'class_name' => __CLASS__, |
24 | 24 | 'base_id' => 'wpinv_buy', |
25 | - 'name' => __( 'Get Paid > Buy Item Button (Deprecated)', 'invoicing' ), |
|
25 | + 'name' => __('Get Paid > Buy Item Button (Deprecated)', 'invoicing'), |
|
26 | 26 | 'widget_ops' => array( |
27 | 27 | 'classname' => 'wpinv-buy-item-class wpi-g', |
28 | - 'description' => esc_html__( 'This widget is deprecated. Use the GetPaid widget instead.', 'invoicing' ), |
|
28 | + 'description' => esc_html__('This widget is deprecated. Use the GetPaid widget instead.', 'invoicing'), |
|
29 | 29 | ), |
30 | 30 | 'arguments' => array( |
31 | 31 | 'title' => array( |
32 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
33 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
32 | + 'title' => __('Widget title', 'invoicing'), |
|
33 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
34 | 34 | 'type' => 'text', |
35 | 35 | 'desc_tip' => true, |
36 | 36 | 'default' => '', |
37 | 37 | 'advanced' => false, |
38 | 38 | ), |
39 | 39 | 'items' => array( |
40 | - 'title' => __( 'Items to buy', 'invoicing' ), |
|
41 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing' ), |
|
40 | + 'title' => __('Items to buy', 'invoicing'), |
|
41 | + 'desc' => __('Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing'), |
|
42 | 42 | 'type' => 'text', |
43 | 43 | 'desc_tip' => true, |
44 | 44 | 'default' => '', |
45 | - 'placeholder' => __( 'Items to buy', 'invoicing' ), |
|
45 | + 'placeholder' => __('Items to buy', 'invoicing'), |
|
46 | 46 | 'advanced' => false, |
47 | 47 | ), |
48 | 48 | 'label' => array( |
49 | - 'title' => __( 'Button Label', 'invoicing' ), |
|
50 | - 'desc' => __( 'Enter button label. Default "Buy Now".', 'invoicing' ), |
|
49 | + 'title' => __('Button Label', 'invoicing'), |
|
50 | + 'desc' => __('Enter button label. Default "Buy Now".', 'invoicing'), |
|
51 | 51 | 'type' => 'text', |
52 | 52 | 'desc_tip' => true, |
53 | - 'default' => __( 'Buy Now', 'invoicing' ), |
|
53 | + 'default' => __('Buy Now', 'invoicing'), |
|
54 | 54 | 'advanced' => false, |
55 | 55 | ), |
56 | 56 | 'post_id' => array( |
57 | - 'title' => __( 'Post ID', 'invoicing' ), |
|
58 | - 'desc' => __( 'Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing' ), |
|
57 | + 'title' => __('Post ID', 'invoicing'), |
|
58 | + 'desc' => __('Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing'), |
|
59 | 59 | 'type' => 'number', |
60 | 60 | 'desc_tip' => true, |
61 | 61 | 'default' => '', |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | ); |
67 | 67 | |
68 | - parent::__construct( $options ); |
|
68 | + parent::__construct($options); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -77,31 +77,31 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return string |
79 | 79 | */ |
80 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
80 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
81 | 81 | |
82 | 82 | $defaults = array( |
83 | 83 | 'items' => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity |
84 | - 'label' => __( 'Buy Now', 'invoicing' ), // the button title |
|
84 | + 'label' => __('Buy Now', 'invoicing'), // the button title |
|
85 | 85 | 'post_id' => '', // any related post_id |
86 | 86 | ); |
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Parse incoming $args into an array and merge it with $defaults |
90 | 90 | */ |
91 | - $args = wp_parse_args( $args, $defaults ); |
|
91 | + $args = wp_parse_args($args, $defaults); |
|
92 | 92 | |
93 | 93 | $html = '<div class="wpi-buy-button-wrapper wpi-g">'; |
94 | 94 | |
95 | - if ( empty( $args['items'] ) ) { |
|
96 | - $html .= __( 'No items selected', 'invoicing' ); |
|
95 | + if (empty($args['items'])) { |
|
96 | + $html .= __('No items selected', 'invoicing'); |
|
97 | 97 | } else { |
98 | - $post_id = isset( $args['post_id'] ) && is_numeric( $args['post_id'] ) ? sanitize_text_field( $args['post_id'] ) : 0; |
|
99 | - $label = isset( $args['label'] ) ? sanitize_text_field( $args['label'] ) : __( 'Buy Now', 'invoicing' ); |
|
100 | - $items = esc_attr( $args['items'] ); |
|
98 | + $post_id = isset($args['post_id']) && is_numeric($args['post_id']) ? sanitize_text_field($args['post_id']) : 0; |
|
99 | + $label = isset($args['label']) ? sanitize_text_field($args['label']) : __('Buy Now', 'invoicing'); |
|
100 | + $items = esc_attr($args['items']); |
|
101 | 101 | $html .= "<button class='button button-primary wpi-buy-button' type='button' onclick=\"wpi_buy(this, '$items','$post_id');\">$label</button>"; |
102 | 102 | } |
103 | 103 | |
104 | - $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false ); |
|
104 | + $html .= wp_nonce_field('wpinv_buy_items', 'wpinv_buy_nonce', true, false); |
|
105 | 105 | $html .= '</div>'; |
106 | 106 | |
107 | 107 | return $html; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | 'block-keywords' => "['invoicing','history']", |
22 | 22 | 'class_name' => __CLASS__, |
23 | 23 | 'base_id' => 'wpinv_history', |
24 | - 'name' => __( 'GetPaid > Invoice History', 'invoicing' ), |
|
24 | + 'name' => __('GetPaid > Invoice History', 'invoicing'), |
|
25 | 25 | 'widget_ops' => array( |
26 | 26 | 'classname' => 'wpinv-history-class bsui', |
27 | - 'description' => esc_html__( 'Displays invoice history.', 'invoicing' ), |
|
27 | + 'description' => esc_html__('Displays invoice history.', 'invoicing'), |
|
28 | 28 | ), |
29 | 29 | 'arguments' => array( |
30 | 30 | 'title' => array( |
31 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
32 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
31 | + 'title' => __('Widget title', 'invoicing'), |
|
32 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
33 | 33 | 'type' => 'text', |
34 | 34 | 'desc_tip' => true, |
35 | 35 | 'default' => '', |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | ); |
41 | 41 | |
42 | - parent::__construct( $options ); |
|
42 | + parent::__construct($options); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return mixed|string|bool |
53 | 53 | */ |
54 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
54 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
55 | 55 | return getpaid_invoice_history(); |
56 | 56 | } |
57 | 57 |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | 'advanced' => false, |
37 | 37 | ), |
38 | 38 | 'id' => array( |
39 | - 'title' => __( 'Invoice', 'invoicing' ), |
|
40 | - 'desc' => __( 'Enter the invoice ID', 'invoicing' ), |
|
41 | - 'type' => 'text', |
|
42 | - 'desc_tip' => true, |
|
43 | - 'default' => '', |
|
44 | - 'placeholder' => __( '1', 'invoicing' ), |
|
45 | - 'advanced' => false, |
|
46 | - ), |
|
39 | + 'title' => __( 'Invoice', 'invoicing' ), |
|
40 | + 'desc' => __( 'Enter the invoice ID', 'invoicing' ), |
|
41 | + 'type' => 'text', |
|
42 | + 'desc_tip' => true, |
|
43 | + 'default' => '', |
|
44 | + 'placeholder' => __( '1', 'invoicing' ), |
|
45 | + 'advanced' => false, |
|
46 | + ), |
|
47 | 47 | ), |
48 | 48 | |
49 | 49 | ); |
@@ -51,26 +51,26 @@ discard block |
||
51 | 51 | parent::__construct( $options ); |
52 | 52 | } |
53 | 53 | |
54 | - /** |
|
55 | - * The Super block output function. |
|
56 | - * |
|
57 | - * @param array $args |
|
58 | - * @param array $widget_args |
|
59 | - * @param string $content |
|
60 | - * |
|
61 | - * @return mixed|string|bool |
|
62 | - */ |
|
54 | + /** |
|
55 | + * The Super block output function. |
|
56 | + * |
|
57 | + * @param array $args |
|
58 | + * @param array $widget_args |
|
59 | + * @param string $content |
|
60 | + * |
|
61 | + * @return mixed|string|bool |
|
62 | + */ |
|
63 | 63 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
64 | 64 | |
65 | 65 | // Is the shortcode set up correctly? |
66 | - if ( empty( $args['id'] ) ) { |
|
67 | - return aui()->alert( |
|
68 | - array( |
|
69 | - 'type' => 'warning', |
|
70 | - 'content' => __( 'Missing invoice ID', 'invoicing' ), |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
66 | + if ( empty( $args['id'] ) ) { |
|
67 | + return aui()->alert( |
|
68 | + array( |
|
69 | + 'type' => 'warning', |
|
70 | + 'content' => __( 'Missing invoice ID', 'invoicing' ), |
|
71 | + ) |
|
72 | + ); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | $invoice = wpinv_get_invoice( (int) $args['id'] ); |
76 | 76 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -21,34 +21,34 @@ discard block |
||
21 | 21 | 'block-keywords' => "['invoicing','invoice']", |
22 | 22 | 'class_name' => __CLASS__, |
23 | 23 | 'base_id' => 'getpaid_invoice', |
24 | - 'name' => __( 'GetPaid > Single Invoice', 'invoicing' ), |
|
24 | + 'name' => __('GetPaid > Single Invoice', 'invoicing'), |
|
25 | 25 | 'widget_ops' => array( |
26 | 26 | 'classname' => 'wpinv-invoice-class bsui', |
27 | - 'description' => esc_html__( 'Displays a single invoice.', 'invoicing' ), |
|
27 | + 'description' => esc_html__('Displays a single invoice.', 'invoicing'), |
|
28 | 28 | ), |
29 | 29 | 'arguments' => array( |
30 | 30 | 'title' => array( |
31 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
32 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
31 | + 'title' => __('Widget title', 'invoicing'), |
|
32 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
33 | 33 | 'type' => 'text', |
34 | 34 | 'desc_tip' => true, |
35 | 35 | 'default' => '', |
36 | 36 | 'advanced' => false, |
37 | 37 | ), |
38 | 38 | 'id' => array( |
39 | - 'title' => __( 'Invoice', 'invoicing' ), |
|
40 | - 'desc' => __( 'Enter the invoice ID', 'invoicing' ), |
|
39 | + 'title' => __('Invoice', 'invoicing'), |
|
40 | + 'desc' => __('Enter the invoice ID', 'invoicing'), |
|
41 | 41 | 'type' => 'text', |
42 | 42 | 'desc_tip' => true, |
43 | 43 | 'default' => '', |
44 | - 'placeholder' => __( '1', 'invoicing' ), |
|
44 | + 'placeholder' => __('1', 'invoicing'), |
|
45 | 45 | 'advanced' => false, |
46 | 46 | ), |
47 | 47 | ), |
48 | 48 | |
49 | 49 | ); |
50 | 50 | |
51 | - parent::__construct( $options ); |
|
51 | + parent::__construct($options); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -60,30 +60,30 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return mixed|string|bool |
62 | 62 | */ |
63 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
63 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
64 | 64 | |
65 | 65 | // Is the shortcode set up correctly? |
66 | - if ( empty( $args['id'] ) ) { |
|
66 | + if (empty($args['id'])) { |
|
67 | 67 | return aui()->alert( |
68 | 68 | array( |
69 | 69 | 'type' => 'warning', |
70 | - 'content' => __( 'Missing invoice ID', 'invoicing' ), |
|
70 | + 'content' => __('Missing invoice ID', 'invoicing'), |
|
71 | 71 | ) |
72 | 72 | ); |
73 | 73 | } |
74 | 74 | |
75 | - $invoice = wpinv_get_invoice( (int) $args['id'] ); |
|
75 | + $invoice = wpinv_get_invoice((int) $args['id']); |
|
76 | 76 | |
77 | - if ( $invoice ) { |
|
77 | + if ($invoice) { |
|
78 | 78 | ob_start(); |
79 | - getpaid_invoice( $invoice ); |
|
79 | + getpaid_invoice($invoice); |
|
80 | 80 | return ob_get_clean(); |
81 | 81 | } |
82 | 82 | |
83 | 83 | return aui()->alert( |
84 | 84 | array( |
85 | 85 | 'type' => 'danger', |
86 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
86 | + 'content' => __('Invoice not found', 'invoicing'), |
|
87 | 87 | ) |
88 | 88 | ); |
89 | 89 |
@@ -36,36 +36,36 @@ discard block |
||
36 | 36 | 'desc_tip' => true, |
37 | 37 | 'default' => '', |
38 | 38 | 'advanced' => false, |
39 | - ), |
|
39 | + ), |
|
40 | 40 | |
41 | 41 | 'form' => array( |
42 | - 'title' => __( 'Form', 'invoicing' ), |
|
43 | - 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
44 | - 'type' => 'text', |
|
45 | - 'desc_tip' => true, |
|
46 | - 'default' => '', |
|
47 | - 'placeholder' => __( '1', 'invoicing' ), |
|
48 | - 'advanced' => false, |
|
49 | - ), |
|
50 | - |
|
51 | - 'item' => array( |
|
52 | - 'title' => __( 'Items', 'invoicing' ), |
|
53 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
54 | - 'type' => 'text', |
|
55 | - 'desc_tip' => true, |
|
56 | - 'default' => '', |
|
57 | - 'placeholder' => __( '1', 'invoicing' ), |
|
58 | - 'advanced' => false, |
|
59 | - ), |
|
42 | + 'title' => __( 'Form', 'invoicing' ), |
|
43 | + 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
44 | + 'type' => 'text', |
|
45 | + 'desc_tip' => true, |
|
46 | + 'default' => '', |
|
47 | + 'placeholder' => __( '1', 'invoicing' ), |
|
48 | + 'advanced' => false, |
|
49 | + ), |
|
50 | + |
|
51 | + 'item' => array( |
|
52 | + 'title' => __( 'Items', 'invoicing' ), |
|
53 | + 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
54 | + 'type' => 'text', |
|
55 | + 'desc_tip' => true, |
|
56 | + 'default' => '', |
|
57 | + 'placeholder' => __( '1', 'invoicing' ), |
|
58 | + 'advanced' => false, |
|
59 | + ), |
|
60 | 60 | |
61 | 61 | 'button' => array( |
62 | - 'title' => __( 'Button', 'invoicing' ), |
|
63 | - 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
64 | - 'type' => 'text', |
|
65 | - 'desc_tip' => true, |
|
66 | - 'default' => '', |
|
67 | - 'advanced' => false, |
|
68 | - ), |
|
62 | + 'title' => __( 'Button', 'invoicing' ), |
|
63 | + 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
64 | + 'type' => 'text', |
|
65 | + 'desc_tip' => true, |
|
66 | + 'default' => '', |
|
67 | + 'advanced' => false, |
|
68 | + ), |
|
69 | 69 | |
70 | 70 | ), |
71 | 71 | |
@@ -74,96 +74,96 @@ discard block |
||
74 | 74 | parent::__construct( $options ); |
75 | 75 | } |
76 | 76 | |
77 | - /** |
|
78 | - * The Super block output function. |
|
79 | - * |
|
80 | - * @param array $args |
|
81 | - * @param array $widget_args |
|
82 | - * @param string $content |
|
83 | - * |
|
84 | - * @return string |
|
85 | - */ |
|
77 | + /** |
|
78 | + * The Super block output function. |
|
79 | + * |
|
80 | + * @param array $args |
|
81 | + * @param array $widget_args |
|
82 | + * @param string $content |
|
83 | + * |
|
84 | + * @return string |
|
85 | + */ |
|
86 | 86 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
87 | 87 | |
88 | - // Is the shortcode set up correctly? |
|
89 | - if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
90 | - return aui()->alert( |
|
91 | - array( |
|
92 | - 'type' => 'warning', |
|
93 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
94 | - ) |
|
95 | - ); |
|
96 | - } |
|
97 | - |
|
98 | - // Payment form or button? |
|
99 | - if ( ! empty( $args['form'] ) ) { |
|
100 | - return $this->handle_payment_form( $args ); |
|
101 | - } else { |
|
102 | - return $this->handle_buy_item( $args ); |
|
103 | - } |
|
104 | - |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Displaying a payment form |
|
109 | - * |
|
110 | - * @return string |
|
111 | - */ |
|
88 | + // Is the shortcode set up correctly? |
|
89 | + if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
90 | + return aui()->alert( |
|
91 | + array( |
|
92 | + 'type' => 'warning', |
|
93 | + 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
94 | + ) |
|
95 | + ); |
|
96 | + } |
|
97 | + |
|
98 | + // Payment form or button? |
|
99 | + if ( ! empty( $args['form'] ) ) { |
|
100 | + return $this->handle_payment_form( $args ); |
|
101 | + } else { |
|
102 | + return $this->handle_buy_item( $args ); |
|
103 | + } |
|
104 | + |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Displaying a payment form |
|
109 | + * |
|
110 | + * @return string |
|
111 | + */ |
|
112 | 112 | protected function handle_payment_form( $args = array() ) { |
113 | 113 | |
114 | - if ( empty( $args['button'] ) ) { |
|
115 | - ob_start(); |
|
116 | - getpaid_display_payment_form( $args['form'] ); |
|
117 | - return ob_get_clean(); |
|
118 | - } |
|
114 | + if ( empty( $args['button'] ) ) { |
|
115 | + ob_start(); |
|
116 | + getpaid_display_payment_form( $args['form'] ); |
|
117 | + return ob_get_clean(); |
|
118 | + } |
|
119 | 119 | |
120 | - return $this->payment_form_button( $args['form'], $args['button'] ); |
|
121 | - } |
|
120 | + return $this->payment_form_button( $args['form'], $args['button'] ); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Displays a payment form button. |
|
125 | - * |
|
126 | - * @return string |
|
127 | - */ |
|
123 | + /** |
|
124 | + * Displays a payment form button. |
|
125 | + * |
|
126 | + * @return string |
|
127 | + */ |
|
128 | 128 | protected function payment_form_button( $form, $button ) { |
129 | - return getpaid_get_payment_button( $button, $form ); |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * Selling an item |
|
134 | - * |
|
135 | - * @return string |
|
136 | - */ |
|
129 | + return getpaid_get_payment_button( $button, $form ); |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * Selling an item |
|
134 | + * |
|
135 | + * @return string |
|
136 | + */ |
|
137 | 137 | protected function handle_buy_item( $args = array() ) { |
138 | 138 | |
139 | - if ( empty( $args['button'] ) ) { |
|
140 | - return $this->buy_item_form( $args['item'] ); |
|
141 | - } |
|
139 | + if ( empty( $args['button'] ) ) { |
|
140 | + return $this->buy_item_form( $args['item'] ); |
|
141 | + } |
|
142 | 142 | |
143 | - return $this->buy_item_button( $args['item'], $args['button'] ); |
|
143 | + return $this->buy_item_button( $args['item'], $args['button'] ); |
|
144 | 144 | |
145 | - } |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * Displays a buy item form. |
|
149 | - * |
|
150 | - * @return string |
|
151 | - */ |
|
147 | + /** |
|
148 | + * Displays a buy item form. |
|
149 | + * |
|
150 | + * @return string |
|
151 | + */ |
|
152 | 152 | protected function buy_item_form( $item ) { |
153 | - $items = getpaid_convert_items_to_array( $item ); |
|
154 | - ob_start(); |
|
155 | - getpaid_display_item_payment_form( $items ); |
|
156 | - return ob_get_clean(); |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * Displays a buy item button. |
|
161 | - * |
|
162 | - * @return string |
|
163 | - */ |
|
153 | + $items = getpaid_convert_items_to_array( $item ); |
|
154 | + ob_start(); |
|
155 | + getpaid_display_item_payment_form( $items ); |
|
156 | + return ob_get_clean(); |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * Displays a buy item button. |
|
161 | + * |
|
162 | + * @return string |
|
163 | + */ |
|
164 | 164 | protected function buy_item_button( $item, $button ) { |
165 | - $button = getpaid_get_payment_button( $button, null, $item ); |
|
166 | - return apply_filters( 'getpaid_buy_item_button_widget', $button, $item ); |
|
165 | + $button = getpaid_get_payment_button( $button, null, $item ); |
|
166 | + return apply_filters( 'getpaid_buy_item_button_widget', $button, $item ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | 'block-keywords' => "['invoicing','buy', 'buy item', 'form']", |
23 | 23 | 'class_name' => __CLASS__, |
24 | 24 | 'base_id' => 'getpaid', |
25 | - 'name' => __( 'GetPaid', 'invoicing' ), |
|
25 | + 'name' => __('GetPaid', 'invoicing'), |
|
26 | 26 | 'widget_ops' => array( |
27 | 27 | 'classname' => 'getpaid bsui', |
28 | - 'description' => esc_html__( 'Show payment forms or buttons.', 'invoicing' ), |
|
28 | + 'description' => esc_html__('Show payment forms or buttons.', 'invoicing'), |
|
29 | 29 | ), |
30 | 30 | 'arguments' => array( |
31 | 31 | |
32 | 32 | 'title' => array( |
33 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
34 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
33 | + 'title' => __('Widget title', 'invoicing'), |
|
34 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
35 | 35 | 'type' => 'text', |
36 | 36 | 'desc_tip' => true, |
37 | 37 | 'default' => '', |
@@ -39,28 +39,28 @@ discard block |
||
39 | 39 | ), |
40 | 40 | |
41 | 41 | 'form' => array( |
42 | - 'title' => __( 'Form', 'invoicing' ), |
|
43 | - 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
42 | + 'title' => __('Form', 'invoicing'), |
|
43 | + 'desc' => __('Enter a form id in case you want to display a specific payment form', 'invoicing'), |
|
44 | 44 | 'type' => 'text', |
45 | 45 | 'desc_tip' => true, |
46 | 46 | 'default' => '', |
47 | - 'placeholder' => __( '1', 'invoicing' ), |
|
47 | + 'placeholder' => __('1', 'invoicing'), |
|
48 | 48 | 'advanced' => false, |
49 | 49 | ), |
50 | 50 | |
51 | 51 | 'item' => array( |
52 | - 'title' => __( 'Items', 'invoicing' ), |
|
53 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
52 | + 'title' => __('Items', 'invoicing'), |
|
53 | + 'desc' => __('Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing'), |
|
54 | 54 | 'type' => 'text', |
55 | 55 | 'desc_tip' => true, |
56 | 56 | 'default' => '', |
57 | - 'placeholder' => __( '1', 'invoicing' ), |
|
57 | + 'placeholder' => __('1', 'invoicing'), |
|
58 | 58 | 'advanced' => false, |
59 | 59 | ), |
60 | 60 | |
61 | 61 | 'button' => array( |
62 | - 'title' => __( 'Button', 'invoicing' ), |
|
63 | - 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
62 | + 'title' => __('Button', 'invoicing'), |
|
63 | + 'desc' => __('Enter button label in case you would like to display the forms in a popup.', 'invoicing'), |
|
64 | 64 | 'type' => 'text', |
65 | 65 | 'desc_tip' => true, |
66 | 66 | 'default' => '', |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | ); |
73 | 73 | |
74 | - parent::__construct( $options ); |
|
74 | + parent::__construct($options); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -83,23 +83,23 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return string |
85 | 85 | */ |
86 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
86 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
87 | 87 | |
88 | 88 | // Is the shortcode set up correctly? |
89 | - if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
89 | + if (empty($args['form']) && empty($args['item'])) { |
|
90 | 90 | return aui()->alert( |
91 | 91 | array( |
92 | 92 | 'type' => 'warning', |
93 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
93 | + 'content' => __('No payment form or item selected', 'invoicing'), |
|
94 | 94 | ) |
95 | 95 | ); |
96 | 96 | } |
97 | 97 | |
98 | 98 | // Payment form or button? |
99 | - if ( ! empty( $args['form'] ) ) { |
|
100 | - return $this->handle_payment_form( $args ); |
|
99 | + if (!empty($args['form'])) { |
|
100 | + return $this->handle_payment_form($args); |
|
101 | 101 | } else { |
102 | - return $this->handle_buy_item( $args ); |
|
102 | + return $this->handle_buy_item($args); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | } |
@@ -109,15 +109,15 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return string |
111 | 111 | */ |
112 | - protected function handle_payment_form( $args = array() ) { |
|
112 | + protected function handle_payment_form($args = array()) { |
|
113 | 113 | |
114 | - if ( empty( $args['button'] ) ) { |
|
114 | + if (empty($args['button'])) { |
|
115 | 115 | ob_start(); |
116 | - getpaid_display_payment_form( $args['form'] ); |
|
116 | + getpaid_display_payment_form($args['form']); |
|
117 | 117 | return ob_get_clean(); |
118 | 118 | } |
119 | 119 | |
120 | - return $this->payment_form_button( $args['form'], $args['button'] ); |
|
120 | + return $this->payment_form_button($args['form'], $args['button']); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return string |
127 | 127 | */ |
128 | - protected function payment_form_button( $form, $button ) { |
|
129 | - return getpaid_get_payment_button( $button, $form ); |
|
128 | + protected function payment_form_button($form, $button) { |
|
129 | + return getpaid_get_payment_button($button, $form); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return string |
136 | 136 | */ |
137 | - protected function handle_buy_item( $args = array() ) { |
|
137 | + protected function handle_buy_item($args = array()) { |
|
138 | 138 | |
139 | - if ( empty( $args['button'] ) ) { |
|
140 | - return $this->buy_item_form( $args['item'] ); |
|
139 | + if (empty($args['button'])) { |
|
140 | + return $this->buy_item_form($args['item']); |
|
141 | 141 | } |
142 | 142 | |
143 | - return $this->buy_item_button( $args['item'], $args['button'] ); |
|
143 | + return $this->buy_item_button($args['item'], $args['button']); |
|
144 | 144 | |
145 | 145 | } |
146 | 146 | |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @return string |
151 | 151 | */ |
152 | - protected function buy_item_form( $item ) { |
|
153 | - $items = getpaid_convert_items_to_array( $item ); |
|
152 | + protected function buy_item_form($item) { |
|
153 | + $items = getpaid_convert_items_to_array($item); |
|
154 | 154 | ob_start(); |
155 | - getpaid_display_item_payment_form( $items ); |
|
155 | + getpaid_display_item_payment_form($items); |
|
156 | 156 | return ob_get_clean(); |
157 | 157 | } |
158 | 158 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @return string |
163 | 163 | */ |
164 | - protected function buy_item_button( $item, $button ) { |
|
165 | - $button = getpaid_get_payment_button( $button, null, $item ); |
|
166 | - return apply_filters( 'getpaid_buy_item_button_widget', $button, $item ); |
|
164 | + protected function buy_item_button($item, $button) { |
|
165 | + $button = getpaid_get_payment_button($button, null, $item); |
|
166 | + return apply_filters('getpaid_buy_item_button_widget', $button, $item); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | 'block-keywords' => "['invoicing','receipt']", |
22 | 22 | 'class_name' => __CLASS__, |
23 | 23 | 'base_id' => 'wpinv_receipt', |
24 | - 'name' => __( 'GetPaid > Invoice Receipt', 'invoicing' ), |
|
24 | + 'name' => __('GetPaid > Invoice Receipt', 'invoicing'), |
|
25 | 25 | 'widget_ops' => array( |
26 | 26 | 'classname' => 'wpinv-receipt-class bsui', |
27 | - 'description' => esc_html__( 'Displays invoice receipt after checkout.', 'invoicing' ), |
|
27 | + 'description' => esc_html__('Displays invoice receipt after checkout.', 'invoicing'), |
|
28 | 28 | ), |
29 | 29 | 'arguments' => array( |
30 | 30 | 'title' => array( |
31 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
32 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
31 | + 'title' => __('Widget title', 'invoicing'), |
|
32 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
33 | 33 | 'type' => 'text', |
34 | 34 | 'desc_tip' => true, |
35 | 35 | 'default' => '', |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | ); |
41 | 41 | |
42 | - parent::__construct( $options ); |
|
42 | + parent::__construct($options); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return mixed|string|bool |
53 | 53 | */ |
54 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
54 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
55 | 55 | return wpinv_payment_receipt(); |
56 | 56 | } |
57 | 57 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | 'block-keywords' => "['invoicing','history']", |
22 | 22 | 'class_name' => __CLASS__, |
23 | 23 | 'base_id' => 'wpinv_messages', |
24 | - 'name' => __( 'GetPaid > Invoice Messages', 'invoicing' ), |
|
24 | + 'name' => __('GetPaid > Invoice Messages', 'invoicing'), |
|
25 | 25 | 'widget_ops' => array( |
26 | 26 | 'classname' => 'wpinv-messages-class wpi-g', |
27 | - 'description' => esc_html__( 'Displays invoice error and warning messages on checkout page.', 'invoicing' ), |
|
27 | + 'description' => esc_html__('Displays invoice error and warning messages on checkout page.', 'invoicing'), |
|
28 | 28 | ), |
29 | 29 | 'arguments' => array( |
30 | 30 | 'title' => array( |
31 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
32 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
31 | + 'title' => __('Widget title', 'invoicing'), |
|
32 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
33 | 33 | 'type' => 'text', |
34 | 34 | 'desc_tip' => true, |
35 | 35 | 'default' => '', |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | ); |
41 | 41 | |
42 | - parent::__construct( $options ); |
|
42 | + parent::__construct($options); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return mixed|string|bool |
53 | 53 | */ |
54 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
54 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
55 | 55 | |
56 | 56 | ob_start(); |
57 | 57 |
@@ -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 _e( 'To:', 'invoicing' ); ?></strong> |
|
25 | + <strong><?php _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( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ); ?> |
|
42 | + <?php echo wp_sprintf(__('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( __( 'Email: %s', 'invoicing' ), sanitize_email( $email ) ); ?> |
|
49 | + <?php echo wp_sprintf(__('Email: %s', 'invoicing'), sanitize_email($email)); ?> |
|
50 | 50 | </div> |
51 | 51 | <?php endif; ?> |
52 | 52 | |
53 | - <?php if ( ! empty( $vat_number ) ) : ?> |
|
53 | + <?php if (!empty($vat_number)) : ?> |
|
54 | 54 | <div class="vat-number"> |
55 | - <?php echo wp_sprintf( __( 'Vat Number: %s', 'invoicing' ), esc_html( $vat_number ) ); ?> |
|
55 | + <?php echo wp_sprintf(__('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( __( 'Company ID: %s', 'invoicing' ), esc_html( $company_id ) ); ?> |
|
61 | + <?php echo wp_sprintf(__('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 |