@@ -7,14 +7,14 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div class='alert mb-0' :class='form_element.class' role='alert'> |
15 | 15 | <span v-html='form_element.text'></span> |
16 | 16 | <button v-if='form_element.dismissible' type='button' class='close btn-close' @click.prevent='' style="margin-top: -4px;"> |
17 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
17 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
18 | 18 | <span aria-hidden="true">×</span> |
19 | 19 | <?php endif; ?> |
20 | 20 | </button> |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -16,82 +16,82 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class GetPaid_Meta_Box_Invoice_Items { |
18 | 18 | |
19 | - public static function get_columns( $invoice ) { |
|
19 | + public static function get_columns($invoice) { |
|
20 | 20 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
21 | 21 | $columns = array( |
22 | - 'id' => __( 'ID', 'invoicing' ), |
|
23 | - 'title' => __( 'Item', 'invoicing' ), |
|
22 | + 'id' => __('ID', 'invoicing'), |
|
23 | + 'title' => __('Item', 'invoicing'), |
|
24 | 24 | 'price' => sprintf( |
25 | 25 | '<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span> |
26 | 26 | <span class="getpaid-hide-if-hours hide-if-amount">%s</span> |
27 | 27 | <span class="getpaid-hide-if-quantity hide-if-amount">%s</span>', |
28 | - __( 'Amount', 'invoicing' ), |
|
29 | - __( 'Price', 'invoicing' ), |
|
30 | - __( 'Rate', 'invoicing' ) |
|
28 | + __('Amount', 'invoicing'), |
|
29 | + __('Price', 'invoicing'), |
|
30 | + __('Rate', 'invoicing') |
|
31 | 31 | ), |
32 | 32 | 'qty' => sprintf( |
33 | 33 | '<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>', |
34 | - __( 'Quantity', 'invoicing' ), |
|
35 | - __( 'Hours', 'invoicing' ) |
|
34 | + __('Quantity', 'invoicing'), |
|
35 | + __('Hours', 'invoicing') |
|
36 | 36 | ), |
37 | - 'total' => __( 'Total', 'invoicing' ), |
|
38 | - 'tax' => __( 'Tax (%)', 'invoicing' ), |
|
37 | + 'total' => __('Total', 'invoicing'), |
|
38 | + 'tax' => __('Tax (%)', 'invoicing'), |
|
39 | 39 | 'action' => '', |
40 | 40 | ); |
41 | 41 | |
42 | - if ( ! $use_taxes ) { |
|
43 | - unset( $columns['tax'] ); |
|
42 | + if (!$use_taxes) { |
|
43 | + unset($columns['tax']); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | return $columns; |
47 | 47 | } |
48 | 48 | |
49 | - public static function output( $post, $invoice = false ) { |
|
49 | + public static function output($post, $invoice = false) { |
|
50 | 50 | |
51 | - if ( apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) { |
|
52 | - return self::output2( $post ); |
|
51 | + if (apply_filters('getpaid_use_new_invoice_items_metabox', false)) { |
|
52 | + return self::output2($post); |
|
53 | 53 | } |
54 | 54 | |
55 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
56 | - $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id ); |
|
55 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
56 | + $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id); |
|
57 | 57 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
58 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
59 | - $columns = self::get_columns( $invoice ); |
|
60 | - $cols = count( $columns ); |
|
58 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
59 | + $columns = self::get_columns($invoice); |
|
60 | + $cols = count($columns); |
|
61 | 61 | $class = ''; |
62 | 62 | |
63 | - unset( $item_types['adv'] ); |
|
64 | - unset( $item_types['package'] ); |
|
63 | + unset($item_types['adv']); |
|
64 | + unset($item_types['package']); |
|
65 | 65 | |
66 | - if ( $invoice->is_paid() ) { |
|
66 | + if ($invoice->is_paid()) { |
|
67 | 67 | $class .= ' wpinv-paid'; |
68 | 68 | } |
69 | 69 | |
70 | - if ( $invoice->is_refunded() ) { |
|
70 | + if ($invoice->is_refunded()) { |
|
71 | 71 | $class .= ' wpinv-refunded'; |
72 | 72 | } |
73 | 73 | |
74 | - if ( $invoice->is_recurring() ) { |
|
74 | + if ($invoice->is_recurring()) { |
|
75 | 75 | $class .= ' wpi-recurring'; |
76 | 76 | } |
77 | 77 | |
78 | 78 | ?> |
79 | 79 | |
80 | - <div class="wpinv-items-wrap<?php echo esc_attr( $class ); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>"> |
|
80 | + <div class="wpinv-items-wrap<?php echo esc_attr($class); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>"> |
|
81 | 81 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
82 | 82 | |
83 | 83 | <thead> |
84 | 84 | <tr> |
85 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
86 | - <th class="<?php echo esc_attr( $key ); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post( $label ); ?></th> |
|
85 | + <?php foreach ($columns as $key => $label) : ?> |
|
86 | + <th class="<?php echo esc_attr($key); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post($label); ?></th> |
|
87 | 87 | <?php endforeach; ?> |
88 | 88 | </tr> |
89 | 89 | </thead> |
90 | 90 | |
91 | 91 | <tbody class="wpinv-line-items"> |
92 | 92 | <?php |
93 | - foreach ( $invoice->get_items() as $int => $item ) { |
|
94 | - self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' ); |
|
93 | + foreach ($invoice->get_items() as $int => $item) { |
|
94 | + self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd'); |
|
95 | 95 | } |
96 | 96 | ?> |
97 | 97 | </tbody> |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | <div class="wp-clearfix"> |
109 | 109 | <label class="wpi-item-name"> |
110 | 110 | <span class="input-text-wrap"> |
111 | - <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' );?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
111 | + <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
112 | 112 | </span> |
113 | 113 | </label> |
114 | 114 | </div> |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | <div class="wp-clearfix"> |
117 | 117 | <label class="wpi-item-price"> |
118 | 118 | <span class="input-text-wrap"> |
119 | - <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' );?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
120 | - × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' );?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
119 | + <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
120 | + × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
121 | 121 | </span> |
122 | 122 | </label> |
123 | 123 | </div> |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | <div class="wp-clearfix"> |
126 | 126 | <label class="wpi-item-name"> |
127 | 127 | <span class="input-text-wrap"> |
128 | - <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' );?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
128 | + <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
129 | 129 | </span> |
130 | 130 | </label> |
131 | 131 | </div> |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | <div class="wp-clearfix"> |
134 | 134 | <label class="wpi-item-type"> |
135 | 135 | <span class="input-text-wrap"> |
136 | - <?php wpinv_html_select( array( |
|
136 | + <?php wpinv_html_select(array( |
|
137 | 137 | 'options' => $item_types, |
138 | 138 | 'name' => '_wpinv_quick[type]', |
139 | 139 | 'id' => '_wpinv_quick_type', |
@@ -141,19 +141,19 @@ discard block |
||
141 | 141 | 'show_option_all' => false, |
142 | 142 | 'show_option_none' => false, |
143 | 143 | 'class' => 'gdmbx2-text-medium wpinv-quick-type', |
144 | - ) ); ?> |
|
144 | + )); ?> |
|
145 | 145 | </span> |
146 | 146 | </label> |
147 | 147 | </div> |
148 | 148 | |
149 | - <?php if ( $use_taxes ) : ?> |
|
149 | + <?php if ($use_taxes) : ?> |
|
150 | 150 | <div class="wp-clearfix"> |
151 | 151 | <label class="wpi-vat-rule"> |
152 | 152 | <span class="input-text-wrap"> |
153 | 153 | <?php |
154 | - wpinv_html_select( array( |
|
154 | + wpinv_html_select(array( |
|
155 | 155 | 'options' => array_merge( |
156 | - array( '' => __( 'Select VAT Rule', 'invoicing' ) ), |
|
156 | + array('' => __('Select VAT Rule', 'invoicing')), |
|
157 | 157 | getpaid_get_tax_rules() |
158 | 158 | ), |
159 | 159 | 'name' => '_wpinv_quick[vat_rule]', |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | 'show_option_none' => false, |
163 | 163 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule', |
164 | 164 | 'selected' => 'digital', |
165 | - ) ); |
|
165 | + )); |
|
166 | 166 | ?> |
167 | 167 | </span> |
168 | 168 | </label> |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | <label class="wpi-vat-class"> |
172 | 172 | <span class="input-text-wrap"> |
173 | 173 | <?php |
174 | - wpinv_html_select( array( |
|
174 | + wpinv_html_select(array( |
|
175 | 175 | 'options' => array_merge( |
176 | - array( '' => __( 'Select VAT Class', 'invoicing' ) ), |
|
176 | + array('' => __('Select VAT Class', 'invoicing')), |
|
177 | 177 | getpaid_get_tax_classes() |
178 | 178 | ), |
179 | 179 | 'name' => '_wpinv_quick[vat_class]', |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | 'show_option_none' => false, |
183 | 183 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class', |
184 | 184 | 'selected' => '_standard', |
185 | - ) ); |
|
185 | + )); |
|
186 | 186 | ?> |
187 | 187 | </span> |
188 | 188 | </label> |
@@ -203,29 +203,29 @@ discard block |
||
203 | 203 | </td> |
204 | 204 | </tr> |
205 | 205 | <tr class="totals"> |
206 | - <td colspan="<?php echo ( (int) $cols - 4 ); ?>"></td> |
|
206 | + <td colspan="<?php echo ((int) $cols - 4); ?>"></td> |
|
207 | 207 | <td colspan="4"> |
208 | 208 | <table cellspacing="0" cellpadding="0"> |
209 | 209 | <tr class="subtotal"> |
210 | - <td class="name"><?php esc_html_e( 'Sub Total:', 'invoicing' );?></td> |
|
211 | - <td class="total"><?php wpinv_the_price( $invoice->get_subtotal(), $invoice->get_currency() );?></td> |
|
210 | + <td class="name"><?php esc_html_e('Sub Total:', 'invoicing'); ?></td> |
|
211 | + <td class="total"><?php wpinv_the_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td> |
|
212 | 212 | <td class="action"></td> |
213 | 213 | </tr> |
214 | 214 | <tr class="discount"> |
215 | - <td class="name"><?php esc_html_e( 'Discount:', 'invoicing' ) ; ?></td> |
|
216 | - <td class="total"><?php wpinv_the_price( $invoice->get_total_discount(), $invoice->get_currency() );?></td> |
|
215 | + <td class="name"><?php esc_html_e('Discount:', 'invoicing'); ?></td> |
|
216 | + <td class="total"><?php wpinv_the_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td> |
|
217 | 217 | <td class="action"></td> |
218 | 218 | </tr> |
219 | - <?php if ( $use_taxes ) : ?> |
|
219 | + <?php if ($use_taxes) : ?> |
|
220 | 220 | <tr class="tax"> |
221 | - <td class="name"><?php esc_html_e( 'Tax:', 'invoicing' );?></td> |
|
222 | - <td class="total"><?php wpinv_the_price( $invoice->get_total_tax(), $invoice->get_currency() );?></td> |
|
221 | + <td class="name"><?php esc_html_e('Tax:', 'invoicing'); ?></td> |
|
222 | + <td class="total"><?php wpinv_the_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td> |
|
223 | 223 | <td class="action"></td> |
224 | 224 | </tr> |
225 | 225 | <?php endif; ?> |
226 | 226 | <tr class="total"> |
227 | - <td class="name"><?php esc_html_e( 'Total:', 'invoicing' );?></td> |
|
228 | - <td class="total"><?php wpinv_the_price( $invoice->get_total(), $invoice->get_currency() );?></td> |
|
227 | + <td class="name"><?php esc_html_e('Total:', 'invoicing'); ?></td> |
|
228 | + <td class="total"><?php wpinv_the_price($invoice->get_total(), $invoice->get_currency()); ?></td> |
|
229 | 229 | <td class="action"></td> |
230 | 230 | </tr> |
231 | 231 | </table> |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | </table> |
237 | 237 | <div class="wpinv-actions"> |
238 | 238 | <?php |
239 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
239 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
240 | 240 | wpinv_item_dropdown( |
241 | 241 | array( |
242 | 242 | 'name' => 'wpinv_invoice_item', |
@@ -246,61 +246,61 @@ discard block |
||
246 | 246 | ) |
247 | 247 | ); |
248 | 248 | |
249 | - echo " " . '<button class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), esc_html( $invoice->get_label() ) ) . '</button>'; |
|
250 | - echo " " . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>'; |
|
251 | - echo " " . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>'; |
|
249 | + echo " " . '<button class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), esc_html($invoice->get_label())) . '</button>'; |
|
250 | + echo " " . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>'; |
|
251 | + echo " " . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>'; |
|
252 | 252 | |
253 | 253 | } |
254 | 254 | ?> |
255 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
255 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
256 | 256 | </div> |
257 | 257 | </div> |
258 | 258 | <?php |
259 | 259 | } |
260 | 260 | |
261 | - public static function output_row( $columns, $item, $invoice, $class='even' ) { |
|
261 | + public static function output_row($columns, $item, $invoice, $class = 'even') { |
|
262 | 262 | |
263 | 263 | ?> |
264 | - <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>"> |
|
265 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
266 | - <td class="<?php echo esc_attr( $column ); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>"> |
|
264 | + <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>"> |
|
265 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
266 | + <td class="<?php echo esc_attr($column); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>"> |
|
267 | 267 | <?php |
268 | - switch ( $column ) { |
|
268 | + switch ($column) { |
|
269 | 269 | case 'id': |
270 | 270 | echo (int) $item->get_id(); |
271 | 271 | break; |
272 | 272 | case 'title': |
273 | 273 | printf( |
274 | 274 | '<a href="%s" target="_blank">%s</a>', |
275 | - esc_url( get_edit_post_link( $item->get_id() ) ), |
|
276 | - esc_html( $item->get_raw_name() ) |
|
275 | + esc_url(get_edit_post_link($item->get_id())), |
|
276 | + esc_html($item->get_raw_name()) |
|
277 | 277 | ); |
278 | 278 | |
279 | - $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
280 | - if ( $summary !== '' ) { |
|
279 | + $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice); |
|
280 | + if ($summary !== '') { |
|
281 | 281 | printf( |
282 | 282 | '<span class="meta">%s</span>', |
283 | - wp_kses_post( wpautop( $summary ) ) |
|
283 | + wp_kses_post(wpautop($summary)) |
|
284 | 284 | ); |
285 | 285 | } |
286 | 286 | |
287 | 287 | printf( |
288 | 288 | '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />', |
289 | - esc_attr( $item->get_raw_name() ), |
|
289 | + esc_attr($item->get_raw_name()), |
|
290 | 290 | (int) $item->get_id() |
291 | 291 | ); |
292 | 292 | |
293 | 293 | printf( |
294 | 294 | '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>', |
295 | 295 | (int) $item->get_id(), |
296 | - esc_attr( $item->get_description() ) |
|
296 | + esc_attr($item->get_description()) |
|
297 | 297 | ); |
298 | 298 | |
299 | 299 | break; |
300 | 300 | case 'price': |
301 | 301 | printf( |
302 | 302 | '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />', |
303 | - esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ), |
|
303 | + esc_attr(getpaid_unstandardize_amount($item->get_price())), |
|
304 | 304 | (int) $item->get_id() |
305 | 305 | ); |
306 | 306 | |
@@ -308,26 +308,26 @@ discard block |
||
308 | 308 | case 'qty': |
309 | 309 | printf( |
310 | 310 | '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />', |
311 | - floatval( $item->get_quantity() ), |
|
311 | + floatval($item->get_quantity()), |
|
312 | 312 | (int) $item->get_id() |
313 | 313 | ); |
314 | 314 | |
315 | 315 | break; |
316 | 316 | case 'total': |
317 | - wpinv_the_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
317 | + wpinv_the_price($item->get_sub_total(), $invoice->get_currency()); |
|
318 | 318 | |
319 | 319 | break; |
320 | 320 | case 'tax': |
321 | - echo floatval( wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
321 | + echo floatval(wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2)) . '%'; |
|
322 | 322 | |
323 | 323 | break; |
324 | 324 | case 'action': |
325 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
325 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
326 | 326 | echo '<i class="fa fa-trash wpinv-item-remove"></i>'; |
327 | 327 | } |
328 | 328 | break; |
329 | 329 | } |
330 | - do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice ); |
|
330 | + do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice); |
|
331 | 331 | ?> |
332 | 332 | </td> |
333 | 333 | <?php endforeach; ?> |
@@ -340,10 +340,10 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @param WP_Post $post |
342 | 342 | */ |
343 | - public static function output2( $post ) { |
|
343 | + public static function output2($post) { |
|
344 | 344 | |
345 | 345 | // Prepare the invoice. |
346 | - $invoice = new WPInv_Invoice( $post ); |
|
346 | + $invoice = new WPInv_Invoice($post); |
|
347 | 347 | |
348 | 348 | // Invoice items. |
349 | 349 | $items = $invoice->get_items(); |
@@ -351,28 +351,28 @@ discard block |
||
351 | 351 | $totals = array( |
352 | 352 | |
353 | 353 | 'subtotal' => array( |
354 | - 'label' => __( 'Items Subtotal', 'invoicing' ), |
|
355 | - 'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
354 | + 'label' => __('Items Subtotal', 'invoicing'), |
|
355 | + 'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
356 | 356 | ), |
357 | 357 | |
358 | 358 | 'discount' => array( |
359 | - 'label' => __( 'Total Discount', 'invoicing' ), |
|
360 | - 'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
359 | + 'label' => __('Total Discount', 'invoicing'), |
|
360 | + 'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
361 | 361 | ), |
362 | 362 | |
363 | 363 | 'tax' => array( |
364 | - 'label' => __( 'Total Tax', 'invoicing' ), |
|
365 | - 'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
364 | + 'label' => __('Total Tax', 'invoicing'), |
|
365 | + 'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
366 | 366 | ), |
367 | 367 | |
368 | 368 | 'total' => array( |
369 | - 'label' => __( 'Invoice Total', 'invoicing' ), |
|
370 | - 'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
|
369 | + 'label' => __('Invoice Total', 'invoicing'), |
|
370 | + 'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()), |
|
371 | 371 | ) |
372 | 372 | ); |
373 | 373 | |
374 | - if ( ! wpinv_use_taxes() ) { |
|
375 | - unset( $totals['tax'] ); |
|
374 | + if (!wpinv_use_taxes()) { |
|
375 | + unset($totals['tax']); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | $item_args = array( |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | 'orderby' => 'title', |
381 | 381 | 'order' => 'ASC', |
382 | 382 | 'posts_per_page' => -1, |
383 | - 'post_status' => array( 'publish' ), |
|
383 | + 'post_status' => array('publish'), |
|
384 | 384 | 'meta_query' => array( |
385 | 385 | array( |
386 | 386 | 'key' => '_wpinv_type', |
@@ -404,10 +404,10 @@ discard block |
||
404 | 404 | } |
405 | 405 | </style> |
406 | 406 | |
407 | - <div class="bsui getpaid-invoice-items-inner <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
|
407 | + <div class="bsui getpaid-invoice-items-inner <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
|
408 | 408 | |
409 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
410 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
409 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
410 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
411 | 411 | |
412 | 412 | <div class="row"> |
413 | 413 | <div class="col-12 col-sm-6"> |
@@ -416,15 +416,15 @@ discard block |
||
416 | 416 | array( |
417 | 417 | 'id' => 'wpinv_template', |
418 | 418 | 'name' => 'wpinv_template', |
419 | - 'label' => __( 'Template', 'invoicing' ), |
|
419 | + 'label' => __('Template', 'invoicing'), |
|
420 | 420 | 'label_type' => 'vertical', |
421 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
421 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
422 | 422 | 'class' => 'form-control-sm', |
423 | - 'value' => $invoice->get_template( 'edit' ), |
|
423 | + 'value' => $invoice->get_template('edit'), |
|
424 | 424 | 'options' => array( |
425 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
426 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
427 | - 'amount' => __( 'Amount Only', 'invoicing' ), |
|
425 | + 'quantity' => __('Quantity', 'invoicing'), |
|
426 | + 'hours' => __('Hours', 'invoicing'), |
|
427 | + 'amount' => __('Amount Only', 'invoicing'), |
|
428 | 428 | ), |
429 | 429 | 'data-allow-clear' => 'false', |
430 | 430 | 'select2' => true, |
@@ -441,11 +441,11 @@ discard block |
||
441 | 441 | array( |
442 | 442 | 'id' => 'wpinv_currency', |
443 | 443 | 'name' => 'wpinv_currency', |
444 | - 'label' => __( 'Currency', 'invoicing' ), |
|
444 | + 'label' => __('Currency', 'invoicing'), |
|
445 | 445 | 'label_type' => 'vertical', |
446 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
446 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
447 | 447 | 'class' => 'form-control-sm', |
448 | - 'value' => $invoice->get_currency( 'edit' ), |
|
448 | + 'value' => $invoice->get_currency('edit'), |
|
449 | 449 | 'required' => false, |
450 | 450 | 'data-allow-clear' => 'false', |
451 | 451 | 'select2' => true, |
@@ -458,24 +458,24 @@ discard block |
||
458 | 458 | </div> |
459 | 459 | </div> |
460 | 460 | |
461 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
461 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
462 | 462 | <?php endif; ?> |
463 | 463 | |
464 | 464 | <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items"> |
465 | 465 | <thead> |
466 | 466 | <tr> |
467 | - <th class="getpaid-item" colspan="2"><?php esc_html_e( 'Item', 'invoicing' ) ?></th> |
|
467 | + <th class="getpaid-item" colspan="2"><?php esc_html_e('Item', 'invoicing') ?></th> |
|
468 | 468 | <th class="getpaid-quantity hide-if-amount text-right"> |
469 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ) ?></span> |
|
470 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ) ?></span> |
|
469 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing') ?></span> |
|
470 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing') ?></span> |
|
471 | 471 | </th> |
472 | 472 | <th class="getpaid-price hide-if-amount text-right"> |
473 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Price', 'invoicing' ) ?></span> |
|
474 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Rate', 'invoicing' ) ?></span> |
|
473 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Price', 'invoicing') ?></span> |
|
474 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Rate', 'invoicing') ?></span> |
|
475 | 475 | </th> |
476 | 476 | <th class="getpaid-item-subtotal text-right"> |
477 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e( 'Amount', 'invoicing' ) ?></span> |
|
478 | - <span class="hide-if-amount"><?php esc_html_e( 'Total', 'invoicing' ) ?></span> |
|
477 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e('Amount', 'invoicing') ?></span> |
|
478 | + <span class="hide-if-amount"><?php esc_html_e('Total', 'invoicing') ?></span> |
|
479 | 479 | </th> |
480 | 480 | <th class="getpaid-item-actions hide-if-not-editable" width="70px"> </th> |
481 | 481 | </tr> |
@@ -483,8 +483,8 @@ discard block |
||
483 | 483 | <tbody class="getpaid_invoice_line_items"> |
484 | 484 | <tr class="hide-if-has-items hide-if-not-editable"> |
485 | 485 | <td colspan="2" class="pt-4 pb-4"> |
486 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Items', 'invoicing' ) ?></button> |
|
487 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ) ?></button> |
|
486 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Items', 'invoicing') ?></button> |
|
487 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing') ?></button> |
|
488 | 488 | </td> |
489 | 489 | <td class="hide-if-amount"> </th> |
490 | 490 | <td class="hide-if-amount"> </th> |
@@ -516,11 +516,11 @@ discard block |
||
516 | 516 | <div class="col-12 col-sm-6 offset-sm-6"> |
517 | 517 | <table class="getpaid-invoice-totals text-right w-100"> |
518 | 518 | <tbody> |
519 | - <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?> |
|
520 | - <tr class="getpaid-totals-<?php echo esc_attr( $key ); ?>"> |
|
521 | - <td class="label"><?php echo esc_html( $data['label'] ) ?>:</td> |
|
519 | + <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?> |
|
520 | + <tr class="getpaid-totals-<?php echo esc_attr($key); ?>"> |
|
521 | + <td class="label"><?php echo esc_html($data['label']) ?>:</td> |
|
522 | 522 | <td width="1%"></td> |
523 | - <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td> |
|
523 | + <td class="value"><?php echo wp_kses_post($data['value']) ?></td> |
|
524 | 524 | </tr> |
525 | 525 | <?php endforeach; ?> |
526 | 526 | </tbody> |
@@ -533,18 +533,18 @@ discard block |
||
533 | 533 | <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable"> |
534 | 534 | <div class="row"> |
535 | 535 | <div class="text-left col-12 col-sm-8"> |
536 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Item', 'invoicing' ) ?></button> |
|
537 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ) ?></button> |
|
538 | - <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?> |
|
536 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Item', 'invoicing') ?></button> |
|
537 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing') ?></button> |
|
538 | + <?php do_action('getpaid-invoice-items-actions', $invoice); ?> |
|
539 | 539 | </div> |
540 | 540 | <div class="text-right col-12 col-sm-4"> |
541 | - <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e( 'Recalculate Totals', 'invoicing' ) ?></button> |
|
541 | + <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e('Recalculate Totals', 'invoicing') ?></button> |
|
542 | 542 | </div> |
543 | 543 | </div> |
544 | 544 | </div> |
545 | 545 | |
546 | 546 | <div class="getpaid-invoice-item-actions hide-if-editable"> |
547 | - <p class="description m-2 text-right text-muted"><?php esc_html_e( 'This invoice is no longer editable', 'invoicing' ); ?></p> |
|
547 | + <p class="description m-2 text-right text-muted"><?php esc_html_e('This invoice is no longer editable', 'invoicing'); ?></p> |
|
548 | 548 | </div> |
549 | 549 | |
550 | 550 | <!-- Add items to an invoice --> |
@@ -552,9 +552,9 @@ discard block |
||
552 | 552 | <div class="modal-dialog modal-dialog-centered" role="document"> |
553 | 553 | <div class="modal-content"> |
554 | 554 | <div class="modal-header"> |
555 | - <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e( "Add Item(s)", 'invoicing' ); ?></h5> |
|
556 | - <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>"> |
|
557 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
555 | + <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e("Add Item(s)", 'invoicing'); ?></h5> |
|
556 | + <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>"> |
|
557 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
558 | 558 | <span aria-hidden="true">×</span> |
559 | 559 | <?php endif; ?> |
560 | 560 | </button> |
@@ -563,10 +563,10 @@ discard block |
||
563 | 563 | <table class="widefat"> |
564 | 564 | <thead> |
565 | 565 | <tr> |
566 | - <th class="pl-0 text-left"><?php esc_html_e( 'Item', 'invoicing' ) ?></th> |
|
566 | + <th class="pl-0 text-left"><?php esc_html_e('Item', 'invoicing') ?></th> |
|
567 | 567 | <th class="pr-0 text-right hide-if-amount"> |
568 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ) ?></span> |
|
569 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ) ?></span> |
|
568 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing') ?></span> |
|
569 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing') ?></span> |
|
570 | 570 | </th> |
571 | 571 | </tr> |
572 | 572 | </thead> |
@@ -574,9 +574,9 @@ discard block |
||
574 | 574 | <tr> |
575 | 575 | <td class="pl-0 text-left"> |
576 | 576 | <select class="regular-text getpaid-add-invoice-item-select"> |
577 | - <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option> |
|
578 | - <?php foreach ( get_posts( $item_args ) as $item ) : ?> |
|
579 | - <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html( $item->post_title ); ?></option> |
|
577 | + <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option> |
|
578 | + <?php foreach (get_posts($item_args) as $item) : ?> |
|
579 | + <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html($item->post_title); ?></option> |
|
580 | 580 | <?php endforeach; ?> |
581 | 581 | </select> |
582 | 582 | </td> |
@@ -588,8 +588,8 @@ discard block |
||
588 | 588 | </table> |
589 | 589 | </div> |
590 | 590 | <div class="modal-footer"> |
591 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
592 | - <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e( 'Add', 'invoicing' ); ?></button> |
|
591 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
592 | + <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e('Add', 'invoicing'); ?></button> |
|
593 | 593 | </div> |
594 | 594 | </div> |
595 | 595 | </div> |
@@ -600,9 +600,9 @@ discard block |
||
600 | 600 | <div class="modal-dialog modal-dialog-centered" role="document"> |
601 | 601 | <div class="modal-content"> |
602 | 602 | <div class="modal-header"> |
603 | - <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e( "Create Item", 'invoicing' ); ?></h5> |
|
604 | - <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>"> |
|
605 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
603 | + <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e("Create Item", 'invoicing'); ?></h5> |
|
604 | + <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>"> |
|
605 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
606 | 606 | <span aria-hidden="true">×</span> |
607 | 607 | <?php endif; ?> |
608 | 608 | </button> |
@@ -611,27 +611,27 @@ discard block |
||
611 | 611 | <div class="getpaid-create-item-div"> |
612 | 612 | <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id"> |
613 | 613 | <label class="form-group mb-3 w-100"> |
614 | - <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span> |
|
615 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
614 | + <span><?php esc_html_e('Name', 'invoicing'); ?></span> |
|
615 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
616 | 616 | </label> |
617 | 617 | <label class="form-group mb-3 w-100"> |
618 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
619 | - <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
620 | - <input type="text" name="price" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control form-control-sm item-price"> |
|
618 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
619 | + <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
620 | + <input type="text" name="price" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control form-control-sm item-price"> |
|
621 | 621 | </label> |
622 | 622 | <label class="form-group mb-3 w-100 hide-if-amount"> |
623 | - <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
623 | + <span><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
624 | 624 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
625 | 625 | </label> |
626 | 626 | <label class="form-group mb-3 w-100"> |
627 | - <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span> |
|
628 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
627 | + <span><?php esc_html_e('Item Description', 'invoicing'); ?></span> |
|
628 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
629 | 629 | </label> |
630 | 630 | </div> |
631 | 631 | </div> |
632 | 632 | <div class="modal-footer"> |
633 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
634 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Create', 'invoicing' ); ?></button> |
|
633 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
634 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Create', 'invoicing'); ?></button> |
|
635 | 635 | </div> |
636 | 636 | </div> |
637 | 637 | </div> |
@@ -642,9 +642,9 @@ discard block |
||
642 | 642 | <div class="modal-dialog modal-dialog-centered" role="document"> |
643 | 643 | <div class="modal-content"> |
644 | 644 | <div class="modal-header"> |
645 | - <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e( "Edit Item", 'invoicing' ); ?></h5> |
|
646 | - <button type="button" class="close close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>"> |
|
647 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
645 | + <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e("Edit Item", 'invoicing'); ?></h5> |
|
646 | + <button type="button" class="close close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>"> |
|
647 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
648 | 648 | <span aria-hidden="true">×</span> |
649 | 649 | <?php endif; ?> |
650 | 650 | </button> |
@@ -653,27 +653,27 @@ discard block |
||
653 | 653 | <div class="getpaid-edit-item-div"> |
654 | 654 | <input type="hidden" name="id" class="form-control form-control-sm item-id"> |
655 | 655 | <label class="form-group mb-3 w-100"> |
656 | - <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span> |
|
657 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
656 | + <span><?php esc_html_e('Name', 'invoicing'); ?></span> |
|
657 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
658 | 658 | </label> |
659 | 659 | <label class="form-group mb-3 w-100"> |
660 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
661 | - <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
662 | - <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price"> |
|
660 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
661 | + <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
662 | + <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price"> |
|
663 | 663 | </label> |
664 | 664 | <label class="form-group mb-3 w-100 hide-if-amount"> |
665 | - <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
665 | + <span><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
666 | 666 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
667 | 667 | </label> |
668 | 668 | <label class="form-group mb-3 w-100"> |
669 | - <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span> |
|
670 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
669 | + <span><?php esc_html_e('Item Description', 'invoicing'); ?></span> |
|
670 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
671 | 671 | </label> |
672 | 672 | </div> |
673 | 673 | </div> |
674 | 674 | <div class="modal-footer"> |
675 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
676 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Save', 'invoicing' ); ?></button> |
|
675 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
676 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Save', 'invoicing'); ?></button> |
|
677 | 677 | </div> |
678 | 678 | </div> |
679 | 679 | </div> |
@@ -5,38 +5,38 @@ |
||
5 | 5 | * @var array $tax_rule |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | ?> |
11 | 11 | |
12 | 12 | <tr> |
13 | 13 | |
14 | 14 | <td class="wpinv-tax-rule-key"> |
15 | - <input type="text" name="tax_rules[<?php echo esc_attr( $tax_rule['key'] ); ?>][key]" value="<?php echo esc_attr( $tax_rule['key'] ); ?>" required/> |
|
15 | + <input type="text" name="tax_rules[<?php echo esc_attr($tax_rule['key']); ?>][key]" value="<?php echo esc_attr($tax_rule['key']); ?>" required/> |
|
16 | 16 | </td> |
17 | 17 | |
18 | 18 | <td class="wpinv-tax-rule-label"> |
19 | - <input type="text" name="tax_rules[<?php echo esc_attr( $tax_rule['key'] ); ?>][label]" value="<?php echo esc_attr( $tax_rule['label'] ); ?>" required/> |
|
19 | + <input type="text" name="tax_rules[<?php echo esc_attr($tax_rule['key']); ?>][label]" value="<?php echo esc_attr($tax_rule['label']); ?>" required/> |
|
20 | 20 | </td> |
21 | 21 | |
22 | 22 | <td class="wpinv-tax-rule-base-address"> |
23 | - <select name="tax_rules[<?php echo esc_attr( $tax_rule['key'] ); ?>][tax_base]" class="getpaid-tax-rule-base-address" required> |
|
24 | - <option value="billing" <?php selected( $tax_rule['tax_base'], 'billing' ); ?>><?php esc_html_e( 'Customer billing address', 'invoicing' ); ?></option> |
|
25 | - <option value="base" <?php selected( $tax_rule['tax_base'], 'base' ); ?>><?php esc_html_e( 'Shop base address', 'invoicing' ); ?></option> |
|
23 | + <select name="tax_rules[<?php echo esc_attr($tax_rule['key']); ?>][tax_base]" class="getpaid-tax-rule-base-address" required> |
|
24 | + <option value="billing" <?php selected($tax_rule['tax_base'], 'billing'); ?>><?php esc_html_e('Customer billing address', 'invoicing'); ?></option> |
|
25 | + <option value="base" <?php selected($tax_rule['tax_base'], 'base'); ?>><?php esc_html_e('Shop base address', 'invoicing'); ?></option> |
|
26 | 26 | </select> |
27 | 27 | </td> |
28 | 28 | |
29 | 29 | <!-- <td class="wpinv-tax-rule-same-country"> |
30 | - <select name="tax_rules[<?php echo esc_attr( $tax_rule['key'] ); ?>][same_country_rule]" class="getpaid-tax-rule-same-country" required> |
|
31 | - <option value="no" <?php selected( $tax_rule['same_country_rule'], 'no' ); ?>><?php esc_html_e( 'Do not charge tax', 'invoicing' ); ?></option> |
|
32 | - <option value="always" <?php selected( $tax_rule['same_country_rule'], 'always' ); ?>><?php esc_html_e( 'Charge tax unless vat number is validated', 'invoicing' ); ?></option> |
|
33 | - <option value="vat_too" <?php selected( $tax_rule['same_country_rule'], 'vat_too' ); ?>><?php esc_html_e( 'Charge tax even if vat number is validated', 'invoicing' ); ?></option> |
|
30 | + <select name="tax_rules[<?php echo esc_attr($tax_rule['key']); ?>][same_country_rule]" class="getpaid-tax-rule-same-country" required> |
|
31 | + <option value="no" <?php selected($tax_rule['same_country_rule'], 'no'); ?>><?php esc_html_e('Do not charge tax', 'invoicing'); ?></option> |
|
32 | + <option value="always" <?php selected($tax_rule['same_country_rule'], 'always'); ?>><?php esc_html_e('Charge tax unless vat number is validated', 'invoicing'); ?></option> |
|
33 | + <option value="vat_too" <?php selected($tax_rule['same_country_rule'], 'vat_too'); ?>><?php esc_html_e('Charge tax even if vat number is validated', 'invoicing'); ?></option> |
|
34 | 34 | </select> |
35 | 35 | </td> --> |
36 | 36 | |
37 | 37 | <td class="wpinv_tax_remove"> |
38 | - <button type="button" class="close btn-close wpinv_remove_tax_rule" aria-label="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>" title="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>"> |
|
39 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
38 | + <button type="button" class="close btn-close wpinv_remove_tax_rule" aria-label="<?php esc_attr_e('Delete', 'invoicing'); ?>" title="<?php esc_attr_e('Delete', 'invoicing'); ?>"> |
|
39 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
40 | 40 | <span aria-hidden="true">×</span> |
41 | 41 | <?php endif; ?> |
42 | 42 | </button> |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @var array $tax_rate |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | ?> |
12 | 12 | |
@@ -18,13 +18,13 @@ discard block |
||
18 | 18 | aui()->select( |
19 | 19 | array( |
20 | 20 | 'options' => array_merge( |
21 | - array( '' => __( 'All Countries', 'invoicing' ) ), |
|
21 | + array('' => __('All Countries', 'invoicing')), |
|
22 | 22 | wpinv_get_country_list() |
23 | 23 | ), |
24 | 24 | 'name' => "tax_rates[$key][country]", |
25 | - 'id' => uniqid( 'tax_rate_country' ), |
|
26 | - 'value' => esc_html( $tax_rate['country'] ), |
|
27 | - 'label' => __( 'Country', 'invoicing' ), |
|
25 | + 'id' => uniqid('tax_rate_country'), |
|
26 | + 'value' => esc_html($tax_rate['country']), |
|
27 | + 'label' => __('Country', 'invoicing'), |
|
28 | 28 | 'class' => 'wpinv_country', |
29 | 29 | 'no_wrap' => true, |
30 | 30 | ), |
@@ -37,36 +37,36 @@ discard block |
||
37 | 37 | <td class="wpinv_tax_state"> |
38 | 38 | |
39 | 39 | <label class="w-100"> |
40 | - <span class="screen-reader-text"><?php esc_html_e( 'States', 'invoicing' ); ?></span> |
|
41 | - <input type="text" placeholder="<?php esc_attr_e( 'Apply to whole country', 'invoicing' ); ?>" name="tax_rates[<?php echo esc_attr( $key ); ?>][state]" value="<?php echo empty( $tax_rate['global'] ) ? esc_attr( $tax_rate['state'] ) : ''; ?>"/> |
|
40 | + <span class="screen-reader-text"><?php esc_html_e('States', 'invoicing'); ?></span> |
|
41 | + <input type="text" placeholder="<?php esc_attr_e('Apply to whole country', 'invoicing'); ?>" name="tax_rates[<?php echo esc_attr($key); ?>][state]" value="<?php echo empty($tax_rate['global']) ? esc_attr($tax_rate['state']) : ''; ?>"/> |
|
42 | 42 | </label> |
43 | 43 | |
44 | 44 | </td> |
45 | 45 | |
46 | 46 | <td class="wpinv_standard_rate"> |
47 | 47 | <label class="w-100"> |
48 | - <span class="screen-reader-text"><?php esc_html_e( 'Standard Rate', 'invoicing' ); ?></span> |
|
49 | - <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ); ?>][rate]" value="<?php echo esc_attr( $tax_rate['rate'] ); ?>"/> |
|
48 | + <span class="screen-reader-text"><?php esc_html_e('Standard Rate', 'invoicing'); ?></span> |
|
49 | + <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key); ?>][rate]" value="<?php echo esc_attr($tax_rate['rate']); ?>"/> |
|
50 | 50 | </label> |
51 | 51 | </td> |
52 | 52 | |
53 | 53 | <td class="wpinv_reduced_rate"> |
54 | 54 | <label class="w-100"> |
55 | - <span class="screen-reader-text"><?php esc_html_e( 'Reduced Rate', 'invoicing' ); ?></span> |
|
56 | - <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr( $key ); ?>][reduced_rate]" value="<?php echo esc_attr( $tax_rate['reduced_rate'] ); ?>"/> |
|
55 | + <span class="screen-reader-text"><?php esc_html_e('Reduced Rate', 'invoicing'); ?></span> |
|
56 | + <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo esc_attr($key); ?>][reduced_rate]" value="<?php echo esc_attr($tax_rate['reduced_rate']); ?>"/> |
|
57 | 57 | </label> |
58 | 58 | </td> |
59 | 59 | |
60 | 60 | <td class="wpinv_tax_name"> |
61 | 61 | <label class="w-100"> |
62 | - <span class="screen-reader-text"><?php esc_html_e( 'Tax Name', 'invoicing' ); ?></span> |
|
63 | - <input type="text" name="tax_rates[<?php echo esc_attr( $key ); ?>][name]" value="<?php echo esc_attr( $tax_rate['name'] ); ?>"/> |
|
62 | + <span class="screen-reader-text"><?php esc_html_e('Tax Name', 'invoicing'); ?></span> |
|
63 | + <input type="text" name="tax_rates[<?php echo esc_attr($key); ?>][name]" value="<?php echo esc_attr($tax_rate['name']); ?>"/> |
|
64 | 64 | </label> |
65 | 65 | </td> |
66 | 66 | |
67 | 67 | <td class="wpinv_tax_remove"> |
68 | - <button type="button" class="close btn-close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>" title="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>"> |
|
69 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
68 | + <button type="button" class="close btn-close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e('Delete', 'invoicing'); ?>" title="<?php esc_attr_e('Delete', 'invoicing'); ?>"> |
|
69 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
70 | 70 | <span aria-hidden="true">×</span> |
71 | 71 | <?php endif; ?> |
72 | 72 | </button> |
@@ -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 | * @deprecated |
@@ -19,48 +19,48 @@ discard block |
||
19 | 19 | * @deprecated |
20 | 20 | */ |
21 | 21 | function wpinv_get_invoice_cart() { |
22 | - return wpinv_get_invoice( getpaid_get_current_invoice_id() ); |
|
22 | + return wpinv_get_invoice(getpaid_get_current_invoice_id()); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @deprecated |
27 | 27 | */ |
28 | -function wpinv_get_invoice_description( $invoice ) { |
|
29 | - $invoice = new WPInv_Invoice( $invoice ); |
|
28 | +function wpinv_get_invoice_description($invoice) { |
|
29 | + $invoice = new WPInv_Invoice($invoice); |
|
30 | 30 | return $invoice->get_description(); |
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @deprecated |
35 | 35 | */ |
36 | -function wpinv_get_invoice_currency_code( $invoice ) { |
|
37 | - $invoice = new WPInv_Invoice( $invoice ); |
|
36 | +function wpinv_get_invoice_currency_code($invoice) { |
|
37 | + $invoice = new WPInv_Invoice($invoice); |
|
38 | 38 | return $invoice->get_currency(); |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @deprecated |
43 | 43 | */ |
44 | -function wpinv_get_payment_user_email( $invoice ) { |
|
45 | - $invoice = new WPInv_Invoice( $invoice ); |
|
44 | +function wpinv_get_payment_user_email($invoice) { |
|
45 | + $invoice = new WPInv_Invoice($invoice); |
|
46 | 46 | return $invoice->get_email(); |
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @deprecated |
51 | 51 | */ |
52 | -function wpinv_get_user_id( $invoice ) { |
|
53 | - $invoice = new WPInv_Invoice( $invoice ); |
|
52 | +function wpinv_get_user_id($invoice) { |
|
53 | + $invoice = new WPInv_Invoice($invoice); |
|
54 | 54 | return $invoice->get_user_id(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @deprecated |
59 | 59 | */ |
60 | -function wpinv_get_invoice_status( $invoice, $return_label = false ) { |
|
61 | - $invoice = new WPInv_Invoice( $invoice ); |
|
60 | +function wpinv_get_invoice_status($invoice, $return_label = false) { |
|
61 | + $invoice = new WPInv_Invoice($invoice); |
|
62 | 62 | |
63 | - if ( $return_label ) { |
|
63 | + if ($return_label) { |
|
64 | 64 | return $invoice->get_status_nicename(); |
65 | 65 | } |
66 | 66 | |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | /** |
71 | 71 | * @deprecated |
72 | 72 | */ |
73 | -function wpinv_get_payment_gateway( $invoice, $return_label = false ) { |
|
74 | - $invoice = new WPInv_Invoice( $invoice ); |
|
73 | +function wpinv_get_payment_gateway($invoice, $return_label = false) { |
|
74 | + $invoice = new WPInv_Invoice($invoice); |
|
75 | 75 | |
76 | - if ( $return_label ) { |
|
76 | + if ($return_label) { |
|
77 | 77 | return $invoice->get_gateway_title(); |
78 | 78 | } |
79 | 79 | |
@@ -83,75 +83,75 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @deprecated |
85 | 85 | */ |
86 | -function wpinv_get_payment_gateway_name( $invoice ) { |
|
87 | - return wpinv_get_payment_gateway( $invoice, true ); |
|
86 | +function wpinv_get_payment_gateway_name($invoice) { |
|
87 | + return wpinv_get_payment_gateway($invoice, true); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @deprecated |
92 | 92 | */ |
93 | -function wpinv_get_payment_transaction_id( $invoice ) { |
|
94 | - $invoice = new WPInv_Invoice( $invoice ); |
|
93 | +function wpinv_get_payment_transaction_id($invoice) { |
|
94 | + $invoice = new WPInv_Invoice($invoice); |
|
95 | 95 | return $invoice->get_transaction_id(); |
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * @deprecated |
100 | 100 | */ |
101 | -function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
102 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
103 | - return $invoice->get_meta( $meta_key, $single ); |
|
101 | +function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) { |
|
102 | + $invoice = new WPInv_Invoice($invoice_id); |
|
103 | + return $invoice->get_meta($meta_key, $single); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @deprecated |
108 | 108 | */ |
109 | -function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '' ) { |
|
110 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
111 | - return $invoice->update_meta_data( $meta_key, $meta_value ); |
|
109 | +function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '') { |
|
110 | + $invoice = new WPInv_Invoice($invoice_id); |
|
111 | + return $invoice->update_meta_data($meta_key, $meta_value); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @deprecated |
116 | 116 | */ |
117 | -function wpinv_get_items( $invoice = 0 ) { |
|
118 | - $invoice = new WPInv_Invoice( $invoice ); |
|
117 | +function wpinv_get_items($invoice = 0) { |
|
118 | + $invoice = new WPInv_Invoice($invoice); |
|
119 | 119 | return $invoice->get_items(); |
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * @deprecated |
124 | 124 | */ |
125 | -function wpinv_get_fees( $invoice = 0 ) { |
|
126 | - $invoice = new WPInv_Invoice( $invoice ); |
|
125 | +function wpinv_get_fees($invoice = 0) { |
|
126 | + $invoice = new WPInv_Invoice($invoice); |
|
127 | 127 | return $invoice->get_fees(); |
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | 131 | * @deprecated |
132 | 132 | */ |
133 | -function wpinv_get_invoice_ip( $invoice ) { |
|
134 | - $invoice = new WPInv_Invoice( $invoice ); |
|
133 | +function wpinv_get_invoice_ip($invoice) { |
|
134 | + $invoice = new WPInv_Invoice($invoice); |
|
135 | 135 | return $invoice->get_ip(); |
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | 139 | * @deprecated |
140 | 140 | */ |
141 | -function wpinv_get_invoice_user_info( $invoice ) { |
|
142 | - $invoice = new WPInv_Invoice( $invoice ); |
|
141 | +function wpinv_get_invoice_user_info($invoice) { |
|
142 | + $invoice = new WPInv_Invoice($invoice); |
|
143 | 143 | return $invoice->get_user_info(); |
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | 147 | * @deprecated |
148 | 148 | */ |
149 | -function wpinv_subtotal( $invoice = 0, $currency = false ) { |
|
150 | - $invoice = new WPInv_Invoice( $invoice ); |
|
149 | +function wpinv_subtotal($invoice = 0, $currency = false) { |
|
150 | + $invoice = new WPInv_Invoice($invoice); |
|
151 | 151 | $subtotal = $invoice->get_subtotal(); |
152 | 152 | |
153 | - if ( $currency ) { |
|
154 | - return wpinv_price( $subtotal, $invoice->get_currency() ); |
|
153 | + if ($currency) { |
|
154 | + return wpinv_price($subtotal, $invoice->get_currency()); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $subtotal; |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | /** |
161 | 161 | * @deprecated |
162 | 162 | */ |
163 | -function wpinv_tax( $invoice = 0, $currency = false ) { |
|
164 | - $invoice = new WPInv_Invoice( $invoice ); |
|
163 | +function wpinv_tax($invoice = 0, $currency = false) { |
|
164 | + $invoice = new WPInv_Invoice($invoice); |
|
165 | 165 | $tax = $invoice->get_total_tax(); |
166 | 166 | |
167 | - if ( $currency ) { |
|
168 | - return wpinv_price( $tax, $invoice->get_currency() ); |
|
167 | + if ($currency) { |
|
168 | + return wpinv_price($tax, $invoice->get_currency()); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | return $tax; |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * @deprecated |
176 | 176 | */ |
177 | -function wpinv_discount( $invoice = 0, $currency = false ) { |
|
178 | - $invoice = new WPInv_Invoice( $invoice ); |
|
177 | +function wpinv_discount($invoice = 0, $currency = false) { |
|
178 | + $invoice = new WPInv_Invoice($invoice); |
|
179 | 179 | $discount = $invoice->get_total_discount(); |
180 | 180 | |
181 | - if ( $currency ) { |
|
182 | - return wpinv_price( $discount, $invoice->get_currency() ); |
|
181 | + if ($currency) { |
|
182 | + return wpinv_price($discount, $invoice->get_currency()); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | return $discount; |
@@ -188,20 +188,20 @@ discard block |
||
188 | 188 | /** |
189 | 189 | * @deprecated |
190 | 190 | */ |
191 | -function wpinv_discount_code( $invoice = 0 ) { |
|
192 | - $invoice = new WPInv_Invoice( $invoice ); |
|
191 | +function wpinv_discount_code($invoice = 0) { |
|
192 | + $invoice = new WPInv_Invoice($invoice); |
|
193 | 193 | return $invoice->get_discount_code(); |
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
197 | 197 | * @deprecated |
198 | 198 | */ |
199 | -function wpinv_payment_total( $invoice = 0, $currency = false ) { |
|
200 | - $invoice = new WPInv_Invoice( $invoice ); |
|
199 | +function wpinv_payment_total($invoice = 0, $currency = false) { |
|
200 | + $invoice = new WPInv_Invoice($invoice); |
|
201 | 201 | $total = $invoice->get_total(); |
202 | 202 | |
203 | - if ( $currency ) { |
|
204 | - return wpinv_price( $total, $invoice->get_currency() ); |
|
203 | + if ($currency) { |
|
204 | + return wpinv_price($total, $invoice->get_currency()); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | return $total; |
@@ -210,51 +210,51 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * @deprecated |
212 | 212 | */ |
213 | -function wpinv_get_date_created( $invoice = 0, $format = '' ) { |
|
214 | - $invoice = new WPInv_Invoice( $invoice ); |
|
213 | +function wpinv_get_date_created($invoice = 0, $format = '') { |
|
214 | + $invoice = new WPInv_Invoice($invoice); |
|
215 | 215 | |
216 | - $format = ! empty( $format ) ? $format : get_option( 'date_format' ); |
|
216 | + $format = !empty($format) ? $format : get_option('date_format'); |
|
217 | 217 | $date_created = $invoice->get_created_date(); |
218 | 218 | |
219 | - return empty( $date_created ) ? date_i18n( $format, strtotime( $date_created ) ) : ''; |
|
219 | + return empty($date_created) ? date_i18n($format, strtotime($date_created)) : ''; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | 223 | * @deprecated |
224 | 224 | */ |
225 | -function wpinv_get_invoice_date( $invoice = 0, $format = '' ) { |
|
226 | - wpinv_get_date_created( $invoice, $format ); |
|
225 | +function wpinv_get_invoice_date($invoice = 0, $format = '') { |
|
226 | + wpinv_get_date_created($invoice, $format); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
230 | 230 | * @deprecated |
231 | 231 | */ |
232 | -function wpinv_get_invoice_vat_number( $invoice = 0 ) { |
|
233 | - $invoice = new WPInv_Invoice( $invoice ); |
|
232 | +function wpinv_get_invoice_vat_number($invoice = 0) { |
|
233 | + $invoice = new WPInv_Invoice($invoice); |
|
234 | 234 | return $invoice->get_vat_number(); |
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
238 | 238 | * @deprecated |
239 | 239 | */ |
240 | -function wpinv_insert_payment_note( $invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false ) { |
|
241 | - $invoice = new WPInv_Invoice( $invoice ); |
|
242 | - return $invoice->add_note( $note, $user_type, $added_by_user, $system ); |
|
240 | +function wpinv_insert_payment_note($invoice = 0, $note = '', $user_type = false, $added_by_user = false, $system = false) { |
|
241 | + $invoice = new WPInv_Invoice($invoice); |
|
242 | + return $invoice->add_note($note, $user_type, $added_by_user, $system); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | 246 | * @deprecated |
247 | 247 | */ |
248 | -function wpinv_get_payment_key( $invoice = 0 ) { |
|
249 | - $invoice = new WPInv_Invoice( $invoice ); |
|
248 | +function wpinv_get_payment_key($invoice = 0) { |
|
249 | + $invoice = new WPInv_Invoice($invoice); |
|
250 | 250 | return $invoice->get_key(); |
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
254 | 254 | * @deprecated |
255 | 255 | */ |
256 | -function wpinv_get_invoice_number( $invoice = 0 ) { |
|
257 | - $invoice = new WPInv_Invoice( $invoice ); |
|
256 | +function wpinv_get_invoice_number($invoice = 0) { |
|
257 | + $invoice = new WPInv_Invoice($invoice); |
|
258 | 258 | return $invoice->get_number(); |
259 | 259 | } |
260 | 260 | |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | /** |
402 | 402 | * @deprecated |
403 | 403 | */ |
404 | -function wpinv_update_payment_status( $invoice, $new_status = 'publish' ) { |
|
405 | - $invoice = new WPInv_Invoice( $invoice ); |
|
406 | - return $invoice->update_status( $new_status ); |
|
404 | +function wpinv_update_payment_status($invoice, $new_status = 'publish') { |
|
405 | + $invoice = new WPInv_Invoice($invoice); |
|
406 | + return $invoice->update_status($new_status); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -456,22 +456,22 @@ discard block |
||
456 | 456 | /** |
457 | 457 | * @deprecated |
458 | 458 | */ |
459 | -function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) { |
|
459 | +function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') { |
|
460 | 460 | |
461 | 461 | // Fetch the invoice. |
462 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
462 | + $invoice = new WPInv_Invoice($invoice_id); |
|
463 | 463 | |
464 | - if ( 0 == $invoice->get_id() ) { |
|
464 | + if (0 == $invoice->get_id()) { |
|
465 | 465 | return false; |
466 | 466 | } |
467 | 467 | |
468 | 468 | // Prepare the transaction id. |
469 | - if ( empty( $transaction_id ) ) { |
|
469 | + if (empty($transaction_id)) { |
|
470 | 470 | $transaction_id = $invoice_id; |
471 | 471 | } |
472 | 472 | |
473 | 473 | // Set the transaction id; |
474 | - $invoice->set_transaction_id( apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice ) ); |
|
474 | + $invoice->set_transaction_id(apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice)); |
|
475 | 475 | |
476 | 476 | // Save the invoice. |
477 | 477 | return $invoice->save(); |
@@ -484,12 +484,12 @@ discard block |
||
484 | 484 | * @param WPInv_Invoice $invoice |
485 | 485 | * @param string $gateway |
486 | 486 | */ |
487 | -function wpinv_send_to_gateway( $gateway, $invoice ) { |
|
487 | +function wpinv_send_to_gateway($gateway, $invoice) { |
|
488 | 488 | |
489 | 489 | $payment_data = array( |
490 | 490 | 'invoice_id' => $invoice->get_id(), |
491 | 491 | 'items' => $invoice->get_cart_details(), |
492 | - 'cart_discounts' => array( $invoice->get_discount_code() ), |
|
492 | + 'cart_discounts' => array($invoice->get_discount_code()), |
|
493 | 493 | 'fees' => $invoice->get_total_fees(), |
494 | 494 | 'subtotal' => $invoice->get_subtotal(), |
495 | 495 | 'discount' => $invoice->get_total_discount(), |
@@ -497,16 +497,16 @@ discard block |
||
497 | 497 | 'price' => $invoice->get_total(), |
498 | 498 | 'invoice_key' => $invoice->get_key(), |
499 | 499 | 'user_email' => $invoice->get_email(), |
500 | - 'date' => gmdate( 'Y-m-d H:i:s', time() ), |
|
500 | + 'date' => gmdate('Y-m-d H:i:s', time()), |
|
501 | 501 | 'user_info' => $invoice->get_user_info(), |
502 | - 'post_data' => wp_kses_post_deep( wp_unslash( $_POST ) ), |
|
502 | + 'post_data' => wp_kses_post_deep(wp_unslash($_POST)), |
|
503 | 503 | 'cart_details' => $invoice->get_cart_details(), |
504 | 504 | 'gateway' => $gateway, |
505 | 505 | 'card_info' => array(), |
506 | - 'gateway_nonce' => wp_create_nonce( 'wpi-gateway' ), |
|
506 | + 'gateway_nonce' => wp_create_nonce('wpi-gateway'), |
|
507 | 507 | ); |
508 | 508 | |
509 | - do_action( 'wpinv_gateway_' . $gateway, $payment_data ); |
|
509 | + do_action('wpinv_gateway_' . $gateway, $payment_data); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | /** |
520 | 520 | * @deprecated |
521 | 521 | */ |
522 | -function wpinv_die( $message = '', $title = '', $status = 400 ) { |
|
523 | - add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 ); |
|
524 | - add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 ); |
|
525 | - wp_die( esc_html( $message ), esc_html( $title ), array( 'response' => (int) $status ) ); |
|
522 | +function wpinv_die($message = '', $title = '', $status = 400) { |
|
523 | + add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3); |
|
524 | + add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3); |
|
525 | + wp_die(esc_html($message), esc_html($title), array('response' => (int) $status)); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -640,14 +640,14 @@ discard block |
||
640 | 640 | /** |
641 | 641 | * @deprecated |
642 | 642 | */ |
643 | -function wpinv_invoice_status_label( $status, $status_display = '' ) { |
|
644 | - return empty( $status_display ) ? sanitize_text_field( $status ) : sanitize_text_field( $status_display ); |
|
643 | +function wpinv_invoice_status_label($status, $status_display = '') { |
|
644 | + return empty($status_display) ? sanitize_text_field($status) : sanitize_text_field($status_display); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
648 | 648 | * @deprecated |
649 | 649 | */ |
650 | -function wpinv_clean_invoice_number( $number ) { |
|
650 | +function wpinv_clean_invoice_number($number) { |
|
651 | 651 | return $number; |
652 | 652 | } |
653 | 653 | |
@@ -852,12 +852,12 @@ discard block |
||
852 | 852 | /** |
853 | 853 | * @deprecated |
854 | 854 | */ |
855 | -function wpinv_item_show_price( $item_id = 0, $echo = true ) { |
|
855 | +function wpinv_item_show_price($item_id = 0, $echo = true) { |
|
856 | 856 | |
857 | - if ( $echo ) { |
|
858 | - echo wp_kses_post( wpinv_item_price( $item_id ) ); |
|
857 | + if ($echo) { |
|
858 | + echo wp_kses_post(wpinv_item_price($item_id)); |
|
859 | 859 | } else { |
860 | - return wpinv_item_price( $item_id ); |
|
860 | + return wpinv_item_price($item_id); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | } |
@@ -1272,6 +1272,6 @@ discard block |
||
1272 | 1272 | * @return WPInv_Subscription|bool |
1273 | 1273 | * @deprecated |
1274 | 1274 | */ |
1275 | -function wpinv_get_subscription( $invoice ) { |
|
1276 | - return wpinv_get_invoice_subscription( $invoice ); |
|
1275 | +function wpinv_get_subscription($invoice) { |
|
1276 | + return wpinv_get_invoice_subscription($invoice); |
|
1277 | 1277 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Abstaract Payment Gateway class. |
@@ -138,53 +138,53 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function __construct() { |
140 | 140 | |
141 | - do_action( 'getpaid_before_init_payment_gateway_' . $this->id, $this ); |
|
141 | + do_action('getpaid_before_init_payment_gateway_' . $this->id, $this); |
|
142 | 142 | |
143 | 143 | // Register gateway. |
144 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
144 | + add_filter('wpinv_payment_gateways', array($this, 'register_gateway')); |
|
145 | 145 | |
146 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
146 | + $this->enabled = wpinv_is_gateway_active($this->id); |
|
147 | 147 | |
148 | 148 | // Add support for various features. |
149 | - foreach ( $this->supports as $feature ) { |
|
150 | - add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
151 | - add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
152 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
149 | + foreach ($this->supports as $feature) { |
|
150 | + add_filter("wpinv_{$this->id}_support_{$feature}", '__return_true'); |
|
151 | + add_filter("getpaid_{$this->id}_support_{$feature}", '__return_true'); |
|
152 | + add_filter("getpaid_{$this->id}_supports_{$feature}", '__return_true'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | // Invoice addons. |
156 | - if ( $this->supports( 'addons' ) ) { |
|
157 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
156 | + if ($this->supports('addons')) { |
|
157 | + add_action("getpaid_process_{$this->id}_invoice_addons", array($this, 'process_addons'), 10, 2); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | // Gateway settings. |
161 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
161 | + add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings')); |
|
162 | 162 | |
163 | 163 | // Gateway checkout fiellds. |
164 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
164 | + add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2); |
|
165 | 165 | |
166 | 166 | // Process payment. |
167 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
167 | + add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3); |
|
168 | 168 | |
169 | 169 | // Change the checkout button text. |
170 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
171 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
170 | + if (!empty($this->checkout_button_text)) { |
|
171 | + add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button')); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Check if a gateway is valid for a given currency. |
175 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
175 | + add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2); |
|
176 | 176 | |
177 | 177 | // Generate the transaction url. |
178 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
178 | + add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2); |
|
179 | 179 | |
180 | 180 | // Generate the subscription url. |
181 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
181 | + add_filter('getpaid_remote_subscription_profile_url', array($this, 'generate_subscription_url'), 10, 2); |
|
182 | 182 | |
183 | 183 | // Confirm payments. |
184 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
184 | + add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2); |
|
185 | 185 | |
186 | 186 | // Verify IPNs. |
187 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
187 | + add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn')); |
|
188 | 188 | |
189 | 189 | } |
190 | 190 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @since 1.0.19 |
195 | 195 | * @return bool |
196 | 196 | */ |
197 | - public function is( $gateway ) { |
|
197 | + public function is($gateway) { |
|
198 | 198 | return $gateway == $this->id; |
199 | 199 | } |
200 | 200 | |
@@ -204,23 +204,23 @@ discard block |
||
204 | 204 | * @since 1.0.19 |
205 | 205 | * @return array |
206 | 206 | */ |
207 | - public function get_tokens( $sandbox = null ) { |
|
207 | + public function get_tokens($sandbox = null) { |
|
208 | 208 | |
209 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
210 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
209 | + if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) { |
|
210 | + $tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true); |
|
211 | 211 | |
212 | - if ( is_array( $tokens ) ) { |
|
212 | + if (is_array($tokens)) { |
|
213 | 213 | $this->tokens = $tokens; |
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | - if ( ! is_bool( $sandbox ) ) { |
|
217 | + if (!is_bool($sandbox)) { |
|
218 | 218 | return $this->tokens; |
219 | 219 | } |
220 | 220 | |
221 | 221 | // Filter tokens. |
222 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
223 | - return wp_list_filter( $this->tokens, $args ); |
|
222 | + $args = array('type' => $sandbox ? 'sandbox' : 'live'); |
|
223 | + return wp_list_filter($this->tokens, $args); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
@@ -229,12 +229,12 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @since 1.0.19 |
231 | 231 | */ |
232 | - public function save_token( $token ) { |
|
232 | + public function save_token($token) { |
|
233 | 233 | |
234 | 234 | $tokens = $this->get_tokens(); |
235 | 235 | $tokens[] = $token; |
236 | 236 | |
237 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
237 | + update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens); |
|
238 | 238 | |
239 | 239 | $this->tokens = $tokens; |
240 | 240 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @return string |
247 | 247 | */ |
248 | 248 | public function get_method_title() { |
249 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
249 | + return apply_filters('getpaid_gateway_method_title', $this->method_title, $this); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @return string |
256 | 256 | */ |
257 | 257 | public function get_method_description() { |
258 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
258 | + return apply_filters('getpaid_gateway_method_description', $this->method_description, $this); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @param WPInv_Invoice $invoice Invoice object. |
265 | 265 | * @return string |
266 | 266 | */ |
267 | - public function get_return_url( $invoice ) { |
|
267 | + public function get_return_url($invoice) { |
|
268 | 268 | |
269 | 269 | // Payment success url |
270 | 270 | $return_url = add_query_arg( |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | wpinv_get_success_page_uri() |
277 | 277 | ); |
278 | 278 | |
279 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
279 | + return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -285,24 +285,24 @@ discard block |
||
285 | 285 | * @param string $content Success page content. |
286 | 286 | * @return string |
287 | 287 | */ |
288 | - public function confirm_payment( $content ) { |
|
288 | + public function confirm_payment($content) { |
|
289 | 289 | |
290 | 290 | // Retrieve the invoice. |
291 | 291 | $invoice_id = getpaid_get_current_invoice_id(); |
292 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
292 | + $invoice = wpinv_get_invoice($invoice_id); |
|
293 | 293 | |
294 | 294 | // Ensure that it exists and that it is pending payment. |
295 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
295 | + if (empty($invoice_id) || !$invoice->needs_payment()) { |
|
296 | 296 | return $content; |
297 | 297 | } |
298 | 298 | |
299 | 299 | // Can the user view this invoice?? |
300 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
300 | + if (!wpinv_user_can_view_invoice($invoice)) { |
|
301 | 301 | return $content; |
302 | 302 | } |
303 | 303 | |
304 | 304 | // Show payment processing indicator. |
305 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
305 | + return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice')); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @param GetPaid_Form_Item[] $items |
320 | 320 | * @return WPInv_Invoice |
321 | 321 | */ |
322 | - public function process_addons( $invoice, $items ) { |
|
322 | + public function process_addons($invoice, $items) { |
|
323 | 323 | |
324 | 324 | } |
325 | 325 | |
@@ -330,14 +330,14 @@ discard block |
||
330 | 330 | * @param WPInv_Invoice $invoice Invoice object. |
331 | 331 | * @return string transaction URL, or empty string. |
332 | 332 | */ |
333 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
333 | + public function filter_transaction_url($transaction_url, $invoice) { |
|
334 | 334 | |
335 | - $transaction_id = $invoice->get_transaction_id(); |
|
335 | + $transaction_id = $invoice->get_transaction_id(); |
|
336 | 336 | |
337 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
338 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
339 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
340 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
337 | + if (!empty($this->view_transaction_url) && !empty($transaction_id)) { |
|
338 | + $transaction_url = sprintf($this->view_transaction_url, $transaction_id); |
|
339 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
340 | + $transaction_url = str_replace('{sandbox}', $replace, $transaction_url); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | return $transaction_url; |
@@ -350,15 +350,15 @@ discard block |
||
350 | 350 | * @param WPInv_Subscription $subscription Subscription objectt. |
351 | 351 | * @return string subscription URL, or empty string. |
352 | 352 | */ |
353 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
353 | + public function generate_subscription_url($subscription_url, $subscription) { |
|
354 | 354 | |
355 | - $profile_id = $subscription->get_profile_id(); |
|
355 | + $profile_id = $subscription->get_profile_id(); |
|
356 | 356 | |
357 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
357 | + if ($this->id == $subscription->get_gateway() && !empty($this->view_subscription_url) && !empty($profile_id)) { |
|
358 | 358 | |
359 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
360 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
361 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
359 | + $subscription_url = sprintf($this->view_subscription_url, $profile_id); |
|
360 | + $replace = $this->is_sandbox($subscription->get_parent_invoice()) ? 'sandbox' : ''; |
|
361 | + $subscription_url = str_replace('{sandbox}', $replace, $subscription_url); |
|
362 | 362 | |
363 | 363 | } |
364 | 364 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * @return bool |
372 | 372 | */ |
373 | 373 | public function is_available() { |
374 | - return ! empty( $this->enabled ); |
|
374 | + return !empty($this->enabled); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | /** |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @return string |
381 | 381 | */ |
382 | 382 | public function get_title() { |
383 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
383 | + return apply_filters('getpaid_gateway_title', $this->title, $this); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * @return string |
390 | 390 | */ |
391 | 391 | public function get_description() { |
392 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
392 | + return apply_filters('getpaid_gateway_description', $this->description, $this); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
402 | 402 | * @return void |
403 | 403 | */ |
404 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
404 | + public function process_payment($invoice, $submission_data, $submission) { |
|
405 | 405 | // Process the payment then either redirect to the success page or the gateway. |
406 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
406 | + do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | * @param string $reason Refund reason. |
418 | 418 | * @return WP_Error|bool True or false based on success, or a WP_Error object. |
419 | 419 | */ |
420 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
421 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
420 | + public function process_refund($invoice, $amount = null, $reason = '') { |
|
421 | + return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | * @param int $invoice_id 0 or invoice id. |
428 | 428 | * @param GetPaid_Payment_Form $form Current payment form. |
429 | 429 | */ |
430 | - public function payment_fields( $invoice_id, $form ) { |
|
431 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
430 | + public function payment_fields($invoice_id, $form) { |
|
431 | + do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | * |
437 | 437 | * @param array $admin_settings |
438 | 438 | */ |
439 | - public function admin_settings( $admin_settings ) { |
|
439 | + public function admin_settings($admin_settings) { |
|
440 | 440 | return $admin_settings; |
441 | 441 | } |
442 | 442 | |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | * |
446 | 446 | * @param string $option |
447 | 447 | */ |
448 | - public function get_option( $option, $default = false ) { |
|
449 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
448 | + public function get_option($option, $default = false) { |
|
449 | + return wpinv_get_option($this->id . '_' . $option, $default); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -459,8 +459,8 @@ discard block |
||
459 | 459 | * @return bool True if the gateway supports the feature, false otherwise. |
460 | 460 | * @since 1.0.19 |
461 | 461 | */ |
462 | - public function supports( $feature ) { |
|
463 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
462 | + public function supports($feature) { |
|
463 | + return getpaid_payment_gateway_supports($this->id, $feature); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -468,39 +468,39 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @param bool $save whether or not to display the save button. |
470 | 470 | */ |
471 | - public function get_cc_form( $save = false ) { |
|
471 | + public function get_cc_form($save = false) { |
|
472 | 472 | |
473 | 473 | ob_start(); |
474 | 474 | |
475 | - $id_prefix = esc_attr( uniqid( $this->id ) ); |
|
475 | + $id_prefix = esc_attr(uniqid($this->id)); |
|
476 | 476 | |
477 | 477 | $months = array( |
478 | - '01' => __( 'January', 'invoicing' ), |
|
479 | - '02' => __( 'February', 'invoicing' ), |
|
480 | - '03' => __( 'March', 'invoicing' ), |
|
481 | - '04' => __( 'April', 'invoicing' ), |
|
482 | - '05' => __( 'May', 'invoicing' ), |
|
483 | - '06' => __( 'June', 'invoicing' ), |
|
484 | - '07' => __( 'July', 'invoicing' ), |
|
485 | - '08' => __( 'August', 'invoicing' ), |
|
486 | - '09' => __( 'September', 'invoicing' ), |
|
487 | - '10' => __( 'October', 'invoicing' ), |
|
488 | - '11' => __( 'November', 'invoicing' ), |
|
489 | - '12' => __( 'December', 'invoicing' ), |
|
478 | + '01' => __('January', 'invoicing'), |
|
479 | + '02' => __('February', 'invoicing'), |
|
480 | + '03' => __('March', 'invoicing'), |
|
481 | + '04' => __('April', 'invoicing'), |
|
482 | + '05' => __('May', 'invoicing'), |
|
483 | + '06' => __('June', 'invoicing'), |
|
484 | + '07' => __('July', 'invoicing'), |
|
485 | + '08' => __('August', 'invoicing'), |
|
486 | + '09' => __('September', 'invoicing'), |
|
487 | + '10' => __('October', 'invoicing'), |
|
488 | + '11' => __('November', 'invoicing'), |
|
489 | + '12' => __('December', 'invoicing'), |
|
490 | 490 | ); |
491 | - $months = apply_filters( 'getpaid_cc_months', $months, $this ); |
|
491 | + $months = apply_filters('getpaid_cc_months', $months, $this); |
|
492 | 492 | |
493 | - $year = (int) current_time( 'Y' ); |
|
493 | + $year = (int) current_time('Y'); |
|
494 | 494 | $years = array(); |
495 | 495 | |
496 | - for ( $i = 0; $i <= 10; $i++ ) { |
|
497 | - $years[ $year + $i ] = $year + $i; |
|
496 | + for ($i = 0; $i <= 10; $i++) { |
|
497 | + $years[$year + $i] = $year + $i; |
|
498 | 498 | } |
499 | 499 | |
500 | - $years = apply_filters( 'getpaid_cc_years', $years, $this ); |
|
500 | + $years = apply_filters('getpaid_cc_years', $years, $this); |
|
501 | 501 | |
502 | 502 | ?> |
503 | - <div class="<?php echo esc_attr( $this->id ); ?>-cc-form getpaid-cc-form mt-1"> |
|
503 | + <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1"> |
|
504 | 504 | |
505 | 505 | |
506 | 506 | <div class="getpaid-cc-card-inner"> |
@@ -509,9 +509,9 @@ discard block |
||
509 | 509 | <div class="col-12"> |
510 | 510 | |
511 | 511 | <div class="form-group mb-3"> |
512 | - <label for="<?php echo esc_attr( "$id_prefix-cc-number" ); ?>"><?php esc_html_e( 'Card number', 'invoicing' ); ?></label> |
|
512 | + <label for="<?php echo esc_attr("$id_prefix-cc-number"); ?>"><?php esc_html_e('Card number', 'invoicing'); ?></label> |
|
513 | 513 | <div class="input-group input-group-sm"> |
514 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
514 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
515 | 515 | <div class="input-group-prepend "> |
516 | 516 | <span class="input-group-text"> |
517 | 517 | <i class="fa fa-credit-card"></i> |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | <i class="fa fa-credit-card"></i> |
523 | 523 | </span> |
524 | 524 | <?php endif; ?> |
525 | - <input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ); ?>" id="<?php echo esc_attr( "$id_prefix-cc-number" ); ?>" class="form-control form-control-sm getpaid-format-card-number" autocomplete="cc-number"> |
|
525 | + <input type="text" name="<?php echo esc_attr($this->id . '[cc_number]'); ?>" id="<?php echo esc_attr("$id_prefix-cc-number"); ?>" class="form-control form-control-sm getpaid-format-card-number" autocomplete="cc-number"> |
|
526 | 526 | </div> |
527 | 527 | </div> |
528 | 528 | |
@@ -530,16 +530,16 @@ discard block |
||
530 | 530 | |
531 | 531 | <div class="col-12"> |
532 | 532 | <div class="form-group mb-3"> |
533 | - <label><?php esc_html_e( 'Expiration', 'invoicing' ); ?></label> |
|
533 | + <label><?php esc_html_e('Expiration', 'invoicing'); ?></label> |
|
534 | 534 | <div class="form-row row"> |
535 | 535 | |
536 | 536 | <div class="col"> |
537 | - <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr( $this->id ); ?>[cc_expire_month]"> |
|
538 | - <option disabled selected="selected"><?php esc_html_e( 'MM', 'invoicing' ); ?></option> |
|
537 | + <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]"> |
|
538 | + <option disabled selected="selected"><?php esc_html_e('MM', 'invoicing'); ?></option> |
|
539 | 539 | |
540 | 540 | <?php |
541 | - foreach ( $months as $key => $month ) { |
|
542 | - echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $month ) . '</option>'; |
|
541 | + foreach ($months as $key => $month) { |
|
542 | + echo "<option value='" . esc_attr($key) . "'>" . esc_html($month) . '</option>'; |
|
543 | 543 | } |
544 | 544 | ?> |
545 | 545 | |
@@ -547,12 +547,12 @@ discard block |
||
547 | 547 | </div> |
548 | 548 | |
549 | 549 | <div class="col"> |
550 | - <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr( $this->id ); ?>[cc_expire_year]"> |
|
551 | - <option disabled selected="selected"><?php esc_html_e( 'YY', 'invoicing' ); ?></option> |
|
550 | + <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]"> |
|
551 | + <option disabled selected="selected"><?php esc_html_e('YY', 'invoicing'); ?></option> |
|
552 | 552 | |
553 | 553 | <?php |
554 | - foreach ( $years as $key => $year ) { |
|
555 | - echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $year ) . '</option>'; |
|
554 | + foreach ($years as $key => $year) { |
|
555 | + echo "<option value='" . esc_attr($key) . "'>" . esc_html($year) . '</option>'; |
|
556 | 556 | } |
557 | 557 | ?> |
558 | 558 | |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | array( |
570 | 570 | 'name' => $this->id . '[cc_cvv2]', |
571 | 571 | 'id' => "$id_prefix-cc-cvv2", |
572 | - 'label' => __( 'CCV', 'invoicing' ), |
|
572 | + 'label' => __('CCV', 'invoicing'), |
|
573 | 573 | 'label_type' => 'vertical', |
574 | 574 | 'class' => 'form-control-sm', |
575 | 575 | 'extra_attributes' => array( |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | |
586 | 586 | <?php |
587 | 587 | |
588 | - if ( $save ) { |
|
588 | + if ($save) { |
|
589 | 589 | $this->save_payment_method_checkbox(); |
590 | 590 | } |
591 | 591 | |
@@ -604,8 +604,8 @@ discard block |
||
604 | 604 | * |
605 | 605 | * @since 1.0.19 |
606 | 606 | */ |
607 | - public function new_payment_method_entry( $form ) { |
|
608 | - echo "<div class='getpaid-new-payment-method-form' style='display:none;'> " . wp_kses( $form, getpaid_allowed_html() ) . '</div>'; |
|
607 | + public function new_payment_method_entry($form) { |
|
608 | + echo "<div class='getpaid-new-payment-method-form' style='display:none;'> " . wp_kses($form, getpaid_allowed_html()) . '</div>'; |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | /** |
@@ -614,10 +614,10 @@ discard block |
||
614 | 614 | * @since 1.0.19 |
615 | 615 | */ |
616 | 616 | public function saved_payment_methods() { |
617 | - echo '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
617 | + echo '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">'; |
|
618 | 618 | |
619 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
620 | - $this->get_saved_payment_method_option_html( $token ); |
|
619 | + foreach ($this->get_tokens($this->is_sandbox()) as $token) { |
|
620 | + $this->get_saved_payment_method_option_html($token); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | $this->get_new_payment_method_option_html(); |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | * @param array $token Payment Token. |
633 | 633 | * @return string Generated payment method HTML |
634 | 634 | */ |
635 | - public function get_saved_payment_method_option_html( $token ) { |
|
635 | + public function get_saved_payment_method_option_html($token) { |
|
636 | 636 | |
637 | 637 | printf( |
638 | 638 | '<li class="getpaid-payment-method form-group mb-3"> |
@@ -641,11 +641,11 @@ discard block |
||
641 | 641 | <span>%3$s</span> |
642 | 642 | </label> |
643 | 643 | </li>', |
644 | - esc_attr( $this->id ), |
|
645 | - esc_attr( $token['id'] ), |
|
646 | - esc_html( $token['name'] ), |
|
647 | - checked( empty( $token['default'] ), false, false ), |
|
648 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
644 | + esc_attr($this->id), |
|
645 | + esc_attr($token['id']), |
|
646 | + esc_html($token['name']), |
|
647 | + checked(empty($token['default']), false, false), |
|
648 | + empty($token['currency']) ? 'none' : esc_attr($token['currency']) |
|
649 | 649 | ); |
650 | 650 | |
651 | 651 | } |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | */ |
658 | 658 | public function get_new_payment_method_option_html() { |
659 | 659 | |
660 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
660 | + $label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this); |
|
661 | 661 | |
662 | 662 | printf( |
663 | 663 | '<li class="getpaid-new-payment-method"> |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | <span>%2$s</span> |
667 | 667 | </label> |
668 | 668 | </li>', |
669 | - esc_attr( $this->id ), |
|
670 | - esc_html( $label ) |
|
669 | + esc_attr($this->id), |
|
670 | + esc_html($label) |
|
671 | 671 | ); |
672 | 672 | |
673 | 673 | } |
@@ -682,10 +682,10 @@ discard block |
||
682 | 682 | aui()->input( |
683 | 683 | array( |
684 | 684 | 'type' => 'checkbox', |
685 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
686 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
685 | + 'name' => esc_attr("getpaid-$this->id-new-payment-method"), |
|
686 | + 'id' => esc_attr(uniqid($this->id)), |
|
687 | 687 | 'required' => false, |
688 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
688 | + 'label' => esc_html__('Save payment method', 'invoicing'), |
|
689 | 689 | 'value' => 'true', |
690 | 690 | 'checked' => true, |
691 | 691 | 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
@@ -700,9 +700,9 @@ discard block |
||
700 | 700 | * |
701 | 701 | * @return array |
702 | 702 | */ |
703 | - public function register_gateway( $gateways ) { |
|
703 | + public function register_gateway($gateways) { |
|
704 | 704 | |
705 | - $gateways[ $this->id ] = array( |
|
705 | + $gateways[$this->id] = array( |
|
706 | 706 | |
707 | 707 | 'admin_label' => $this->method_title, |
708 | 708 | 'checkout_label' => $this->title, |
@@ -720,13 +720,13 @@ discard block |
||
720 | 720 | * @param WPInv_Invoice|null $invoice Invoice object or null. |
721 | 721 | * @return bool |
722 | 722 | */ |
723 | - public function is_sandbox( $invoice = null ) { |
|
723 | + public function is_sandbox($invoice = null) { |
|
724 | 724 | |
725 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
725 | + if (!empty($invoice) && !$invoice->needs_payment()) { |
|
726 | 726 | return $invoice->get_mode() == 'test'; |
727 | 727 | } |
728 | 728 | |
729 | - return wpinv_is_test_mode( $this->id ); |
|
729 | + return wpinv_is_test_mode($this->id); |
|
730 | 730 | |
731 | 731 | } |
732 | 732 | |
@@ -744,15 +744,15 @@ discard block |
||
744 | 744 | * |
745 | 745 | * @return bool |
746 | 746 | */ |
747 | - public function validate_currency( $validation, $currency ) { |
|
747 | + public function validate_currency($validation, $currency) { |
|
748 | 748 | |
749 | 749 | // Required currencies. |
750 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
750 | + if (!empty($this->currencies) && !in_array($currency, $this->currencies)) { |
|
751 | 751 | return false; |
752 | 752 | } |
753 | 753 | |
754 | 754 | // Excluded currencies. |
755 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
755 | + if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) { |
|
756 | 756 | return false; |
757 | 757 | } |
758 | 758 | |
@@ -763,13 +763,13 @@ discard block |
||
763 | 763 | * Displays an error |
764 | 764 | * |
765 | 765 | */ |
766 | - public function show_error( $code, $message, $type ) { |
|
766 | + public function show_error($code, $message, $type) { |
|
767 | 767 | |
768 | - if ( is_admin() ) { |
|
769 | - getpaid_admin()->{"show_$type"}( $message ); |
|
768 | + if (is_admin()) { |
|
769 | + getpaid_admin()->{"show_$type"}($message); |
|
770 | 770 | } |
771 | 771 | |
772 | - wpinv_set_error( $code, $message, $type ); |
|
772 | + wpinv_set_error($code, $message, $type); |
|
773 | 773 | |
774 | 774 | } |
775 | 775 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains gateway functions. |
4 | 4 | * |
5 | 5 | */ |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Returns an array of payment gateways. |
@@ -11,30 +11,30 @@ discard block |
||
11 | 11 | * @return array |
12 | 12 | */ |
13 | 13 | function wpinv_get_payment_gateways() { |
14 | - return apply_filters( 'wpinv_payment_gateways', array() ); |
|
14 | + return apply_filters('wpinv_payment_gateways', array()); |
|
15 | 15 | } |
16 | 16 | |
17 | -function wpinv_payment_gateway_titles( $all_gateways ) { |
|
17 | +function wpinv_payment_gateway_titles($all_gateways) { |
|
18 | 18 | |
19 | 19 | $options = wpinv_get_options(); |
20 | 20 | $gateways = array(); |
21 | - foreach ( $all_gateways as $key => $gateway ) { |
|
22 | - if ( ! empty( $options[ $key . '_title' ] ) ) { |
|
23 | - $all_gateways[ $key ]['checkout_label'] = __( $options[ $key . '_title' ], 'invoicing' ); |
|
21 | + foreach ($all_gateways as $key => $gateway) { |
|
22 | + if (!empty($options[$key . '_title'])) { |
|
23 | + $all_gateways[$key]['checkout_label'] = __($options[$key . '_title'], 'invoicing'); |
|
24 | 24 | } |
25 | 25 | |
26 | - $gateways[ $key ] = isset( $options[ $key . '_ordering' ] ) ? $options[ $key . '_ordering' ] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' ); |
|
26 | + $gateways[$key] = isset($options[$key . '_ordering']) ? $options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : ''); |
|
27 | 27 | } |
28 | 28 | |
29 | - asort( $gateways ); |
|
29 | + asort($gateways); |
|
30 | 30 | |
31 | - foreach ( $gateways as $gateway => $key ) { |
|
32 | - $gateways[ $gateway ] = $all_gateways[ $gateway ]; |
|
31 | + foreach ($gateways as $gateway => $key) { |
|
32 | + $gateways[$gateway] = $all_gateways[$gateway]; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | return $gateways; |
36 | 36 | } |
37 | -add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 ); |
|
37 | +add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Returns an array of enabled gateways. |
@@ -42,36 +42,36 @@ discard block |
||
42 | 42 | * @param bool $sort |
43 | 43 | * @return array |
44 | 44 | */ |
45 | -function wpinv_get_enabled_payment_gateways( $sort = false ) { |
|
45 | +function wpinv_get_enabled_payment_gateways($sort = false) { |
|
46 | 46 | |
47 | 47 | $enabled = array(); |
48 | 48 | |
49 | - foreach ( wpinv_get_payment_gateways() as $gateway => $data ) { |
|
49 | + foreach (wpinv_get_payment_gateways() as $gateway => $data) { |
|
50 | 50 | |
51 | - if ( (int) wpinv_get_option( "{$gateway}_active", $gateway === 'manual' ) === 1 ) { |
|
52 | - $enabled[ $gateway ] = $data; |
|
51 | + if ((int) wpinv_get_option("{$gateway}_active", $gateway === 'manual') === 1) { |
|
52 | + $enabled[$gateway] = $data; |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | - if ( true === $sort ) { |
|
57 | - uasort( $enabled, 'wpinv_sort_gateway_order' ); |
|
56 | + if (true === $sort) { |
|
57 | + uasort($enabled, 'wpinv_sort_gateway_order'); |
|
58 | 58 | |
59 | 59 | // Reorder our gateways so the default is first |
60 | 60 | $default_gateway_id = wpinv_get_default_gateway(); |
61 | - if ( isset( $enabled[ $default_gateway_id ] ) ) { |
|
61 | + if (isset($enabled[$default_gateway_id])) { |
|
62 | 62 | $default_gateway = array( |
63 | - $default_gateway_id => $enabled[ $default_gateway_id ], |
|
63 | + $default_gateway_id => $enabled[$default_gateway_id], |
|
64 | 64 | ); |
65 | 65 | |
66 | - unset( $enabled[ $default_gateway_id ] ); |
|
67 | - $enabled = array_merge( $default_gateway, $enabled ); |
|
66 | + unset($enabled[$default_gateway_id]); |
|
67 | + $enabled = array_merge($default_gateway, $enabled); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - return apply_filters( 'wpinv_enabled_payment_gateways', $enabled ); |
|
71 | + return apply_filters('wpinv_enabled_payment_gateways', $enabled); |
|
72 | 72 | } |
73 | 73 | |
74 | -function wpinv_sort_gateway_order( $a, $b ) { |
|
74 | +function wpinv_sort_gateway_order($a, $b) { |
|
75 | 75 | return $a['ordering'] - $b['ordering']; |
76 | 76 | } |
77 | 77 | |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | * @param string $gateway |
82 | 82 | * @return bool |
83 | 83 | */ |
84 | -function wpinv_is_gateway_active( $gateway ) { |
|
85 | - $is_active = (int) wpinv_get_option( "{$gateway}_active", $gateway === 'manual' ) === 1; |
|
86 | - return apply_filters( 'wpinv_is_gateway_active', $is_active, $gateway ); |
|
84 | +function wpinv_is_gateway_active($gateway) { |
|
85 | + $is_active = (int) wpinv_get_option("{$gateway}_active", $gateway === 'manual') === 1; |
|
86 | + return apply_filters('wpinv_is_gateway_active', $is_active, $gateway); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | * @return string|false |
93 | 93 | */ |
94 | 94 | function wpinv_get_default_gateway() { |
95 | - $default = wpinv_get_option( 'default_gateway' ); |
|
95 | + $default = wpinv_get_option('default_gateway'); |
|
96 | 96 | $gateways = wpinv_get_enabled_payment_gateways(); |
97 | - $default = ! empty( $default ) && isset( $gateways[ $default ] ) ? $default : false; |
|
97 | + $default = !empty($default) && isset($gateways[$default]) ? $default : false; |
|
98 | 98 | |
99 | - return apply_filters( 'wpinv_default_gateway', $default ); |
|
99 | + return apply_filters('wpinv_default_gateway', $default); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -105,17 +105,17 @@ discard block |
||
105 | 105 | * @param string $gateway The gateway to key. |
106 | 106 | * @return string |
107 | 107 | */ |
108 | -function wpinv_get_gateway_admin_label( $gateway ) { |
|
108 | +function wpinv_get_gateway_admin_label($gateway) { |
|
109 | 109 | |
110 | - if ( empty( $gateway ) || 'none' == $gateway ) { |
|
111 | - return esc_html__( 'No Gateway', 'invoicing' ); |
|
110 | + if (empty($gateway) || 'none' == $gateway) { |
|
111 | + return esc_html__('No Gateway', 'invoicing'); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | $gateways = wpinv_get_payment_gateways(); |
115 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
116 | - $gateway = apply_filters( 'wpinv_gateway_admin_label', $label, $gateway ); |
|
115 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
116 | + $gateway = apply_filters('wpinv_gateway_admin_label', $label, $gateway); |
|
117 | 117 | |
118 | - return wpinv_clean( $gateway ); |
|
118 | + return wpinv_clean($gateway); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -123,48 +123,48 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @param string $gateway |
125 | 125 | */ |
126 | -function wpinv_get_gateway_description( $gateway ) { |
|
126 | +function wpinv_get_gateway_description($gateway) { |
|
127 | 127 | |
128 | 128 | $options = wpinv_get_options(); |
129 | - $description = ! empty( $options[ $gateway . '_desc' ] ) ? $options[ $gateway . '_desc' ] : ''; |
|
129 | + $description = !empty($options[$gateway . '_desc']) ? $options[$gateway . '_desc'] : ''; |
|
130 | 130 | |
131 | - return apply_filters( 'wpinv_gateway_description', $description, $gateway ); |
|
131 | + return apply_filters('wpinv_gateway_description', $description, $gateway); |
|
132 | 132 | } |
133 | 133 | |
134 | -function wpinv_get_gateway_button_label( $gateway ) { |
|
135 | - return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' ); |
|
134 | +function wpinv_get_gateway_button_label($gateway) { |
|
135 | + return apply_filters('wpinv_gateway_' . $gateway . '_button_label', ''); |
|
136 | 136 | } |
137 | 137 | |
138 | -function wpinv_get_gateway_checkout_label( $gateway ) { |
|
138 | +function wpinv_get_gateway_checkout_label($gateway) { |
|
139 | 139 | $gateways = wpinv_get_payment_gateways(); |
140 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
140 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
141 | 141 | |
142 | - if ( $gateway == 'none' ) { |
|
143 | - $label = __( 'None', 'invoicing' ); |
|
142 | + if ($gateway == 'none') { |
|
143 | + $label = __('None', 'invoicing'); |
|
144 | 144 | } |
145 | 145 | |
146 | - return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway ); |
|
146 | + return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway); |
|
147 | 147 | } |
148 | 148 | |
149 | -function wpinv_settings_sections_gateways( $settings ) { |
|
149 | +function wpinv_settings_sections_gateways($settings) { |
|
150 | 150 | $gateways = wpinv_get_payment_gateways(); |
151 | - ksort( $gateways ); |
|
151 | + ksort($gateways); |
|
152 | 152 | |
153 | - foreach ( $gateways as $key => $gateway ) { |
|
154 | - $settings[ $key ] = $gateway['admin_label']; |
|
153 | + foreach ($gateways as $key => $gateway) { |
|
154 | + $settings[$key] = $gateway['admin_label']; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $settings; |
158 | 158 | } |
159 | -add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 ); |
|
159 | +add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1); |
|
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Adds GateWay settings. |
163 | 163 | */ |
164 | -function wpinv_settings_gateways( $settings ) { |
|
164 | +function wpinv_settings_gateways($settings) { |
|
165 | 165 | |
166 | 166 | // Loop through each gateway. |
167 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
167 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
168 | 168 | |
169 | 169 | $gateway_settings = array( |
170 | 170 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | "{$key}_header" => array( |
173 | 173 | |
174 | 174 | 'id' => "{$key}_gateway_header", |
175 | - 'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>', |
|
175 | + 'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>', |
|
176 | 176 | 'custom' => $key, |
177 | 177 | 'type' => 'gateway_header', |
178 | 178 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | // Activate/Deactivate a gateway. |
182 | 182 | "{$key}_active" => array( |
183 | 183 | 'id' => $key . '_active', |
184 | - 'name' => __( 'Activate', 'invoicing' ), |
|
185 | - 'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ), |
|
184 | + 'name' => __('Activate', 'invoicing'), |
|
185 | + 'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']), |
|
186 | 186 | 'type' => 'checkbox', |
187 | 187 | 'std' => $key === 'manual' ? '1' : '0', |
188 | 188 | ), |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | // Activate/Deactivate sandbox. |
191 | 191 | "{$key}_sandbox" => array( |
192 | 192 | 'id' => $key . '_sandbox', |
193 | - 'name' => __( 'Sandbox', 'invoicing' ), |
|
194 | - 'desc' => __( 'Enable sandbox to test payments', 'invoicing' ), |
|
193 | + 'name' => __('Sandbox', 'invoicing'), |
|
194 | + 'desc' => __('Enable sandbox to test payments', 'invoicing'), |
|
195 | 195 | 'type' => 'checkbox', |
196 | 196 | 'std' => '1', |
197 | 197 | ), |
@@ -199,52 +199,52 @@ discard block |
||
199 | 199 | // Checkout title. |
200 | 200 | "{$key}_title" => array( |
201 | 201 | 'id' => $key . '_title', |
202 | - 'name' => __( 'Checkout Title', 'invoicing' ), |
|
203 | - 'std' => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '', |
|
202 | + 'name' => __('Checkout Title', 'invoicing'), |
|
203 | + 'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '', |
|
204 | 204 | 'type' => 'text', |
205 | 205 | ), |
206 | 206 | |
207 | 207 | // Checkout description. |
208 | 208 | "{$key}_desc" => array( |
209 | 209 | 'id' => $key . '_desc', |
210 | - 'name' => __( 'Checkout Description', 'invoicing' ), |
|
211 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
210 | + 'name' => __('Checkout Description', 'invoicing'), |
|
211 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
212 | 212 | 'type' => 'text', |
213 | 213 | ), |
214 | 214 | |
215 | 215 | // Checkout order. |
216 | 216 | "{$key}_ordering" => array( |
217 | 217 | 'id' => $key . '_ordering', |
218 | - 'name' => __( 'Priority', 'invoicing' ), |
|
219 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
218 | + 'name' => __('Priority', 'invoicing'), |
|
219 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
220 | 220 | 'type' => 'number', |
221 | 221 | 'step' => '1', |
222 | 222 | 'min' => '0', |
223 | 223 | 'max' => '100000', |
224 | - 'std' => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10', |
|
224 | + 'std' => isset($gateway['ordering']) ? $gateway['ordering'] : '10', |
|
225 | 225 | ), |
226 | 226 | |
227 | 227 | ); |
228 | 228 | |
229 | 229 | // Maybe remove the sandbox. |
230 | - if ( ! getpaid_payment_gateway_supports( $key, 'sandbox' ) ) { |
|
231 | - unset( $gateway_settings[ "{$key}_sandbox" ] ); |
|
230 | + if (!getpaid_payment_gateway_supports($key, 'sandbox')) { |
|
231 | + unset($gateway_settings["{$key}_sandbox"]); |
|
232 | 232 | } |
233 | 233 | |
234 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway ); |
|
235 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway ); |
|
234 | + $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway); |
|
235 | + $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway); |
|
236 | 236 | |
237 | - $settings[ $key ] = $gateway_settings; |
|
237 | + $settings[$key] = $gateway_settings; |
|
238 | 238 | } |
239 | 239 | |
240 | - do_action( 'getpaid_after_gateway_settings', $settings ); |
|
240 | + do_action('getpaid_after_gateway_settings', $settings); |
|
241 | 241 | return $settings; |
242 | 242 | |
243 | 243 | } |
244 | -add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 ); |
|
244 | +add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1); |
|
245 | 245 | |
246 | -function wpinv_gateway_header_callback( $args ) { |
|
247 | - echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />'; |
|
246 | +function wpinv_gateway_header_callback($args) { |
|
247 | + echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />'; |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -255,60 +255,60 @@ discard block |
||
255 | 255 | * @return bool |
256 | 256 | * @since 2.3.0 |
257 | 257 | */ |
258 | -function getpaid_payment_gateway_supports( $gateway, $feature ) { |
|
258 | +function getpaid_payment_gateway_supports($gateway, $feature) { |
|
259 | 259 | |
260 | 260 | $supports = false; |
261 | 261 | |
262 | - $supports = apply_filters( "getpaid_{$gateway}_supports_{$feature}", false ); |
|
262 | + $supports = apply_filters("getpaid_{$gateway}_supports_{$feature}", false); |
|
263 | 263 | |
264 | 264 | // Backwards compatibility. |
265 | - $supports = apply_filters( "wpinv_{$gateway}_supports_{$feature}", $supports ); |
|
266 | - $supports = apply_filters( "wpinv_{$gateway}_support_{$feature}", $supports ); |
|
265 | + $supports = apply_filters("wpinv_{$gateway}_supports_{$feature}", $supports); |
|
266 | + $supports = apply_filters("wpinv_{$gateway}_support_{$feature}", $supports); |
|
267 | 267 | |
268 | - $supports = apply_filters( "getpaid_gateway_supports_{$feature}", $supports, $gateway ); |
|
269 | - $supports = apply_filters( 'getpaid_payment_gateway_supports', $supports, $feature, $gateway ); |
|
268 | + $supports = apply_filters("getpaid_gateway_supports_{$feature}", $supports, $gateway); |
|
269 | + $supports = apply_filters('getpaid_payment_gateway_supports', $supports, $feature, $gateway); |
|
270 | 270 | |
271 | 271 | return $supports; |
272 | 272 | } |
273 | 273 | |
274 | -function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
|
275 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
274 | +function wpinv_get_chosen_gateway($invoice_id = 0) { |
|
275 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
276 | 276 | |
277 | 277 | $chosen = false; |
278 | - if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
278 | + if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) { |
|
279 | 279 | $chosen = $invoice->get_gateway(); |
280 | 280 | } |
281 | 281 | |
282 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
282 | + $chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen; |
|
283 | 283 | |
284 | - if ( false !== $chosen ) { |
|
285 | - $chosen = preg_replace( '/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
284 | + if (false !== $chosen) { |
|
285 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen); |
|
286 | 286 | } |
287 | 287 | |
288 | - if ( ! empty( $chosen ) ) { |
|
289 | - $enabled_gateway = urldecode( $chosen ); |
|
290 | - } elseif ( ! empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
288 | + if (!empty($chosen)) { |
|
289 | + $enabled_gateway = urldecode($chosen); |
|
290 | + } elseif (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) { |
|
291 | 291 | $enabled_gateway = 'manual'; |
292 | 292 | } else { |
293 | 293 | $enabled_gateway = wpinv_get_default_gateway(); |
294 | 294 | } |
295 | 295 | |
296 | - if ( ! wpinv_is_gateway_active( $enabled_gateway ) && ! empty( $gateways ) ) { |
|
297 | - if ( wpinv_is_gateway_active( wpinv_get_default_gateway() ) ) { |
|
296 | + if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) { |
|
297 | + if (wpinv_is_gateway_active(wpinv_get_default_gateway())) { |
|
298 | 298 | $enabled_gateway = wpinv_get_default_gateway(); |
299 | 299 | } else { |
300 | 300 | $enabled_gateway = $gateways[0]; |
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
304 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
304 | + return apply_filters('wpinv_chosen_gateway', $enabled_gateway); |
|
305 | 305 | } |
306 | 306 | |
307 | -function wpinv_record_gateway_error( $title = '', $message = '' ) { |
|
308 | - return wpinv_error_log( $message, $title ); |
|
307 | +function wpinv_record_gateway_error($title = '', $message = '') { |
|
308 | + return wpinv_error_log($message, $title); |
|
309 | 309 | } |
310 | 310 | |
311 | -function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
311 | +function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
312 | 312 | $ret = 0; |
313 | 313 | $args = array( |
314 | 314 | 'meta_key' => '_wpinv_gateway', |
@@ -319,9 +319,9 @@ discard block |
||
319 | 319 | 'fields' => 'ids', |
320 | 320 | ); |
321 | 321 | |
322 | - $payments = new WP_Query( $args ); |
|
322 | + $payments = new WP_Query($args); |
|
323 | 323 | |
324 | - if ( $payments ) { |
|
324 | + if ($payments) { |
|
325 | 325 | $ret = $payments->post_count; |
326 | 326 | } |
327 | 327 | return $ret; |
@@ -330,11 +330,11 @@ discard block |
||
330 | 330 | /** |
331 | 331 | * Displays the ipn url field. |
332 | 332 | */ |
333 | -function wpinv_ipn_url_callback( $args ) { |
|
334 | - $sanitize_id = esc_attr( wpinv_sanitize_key( $args['id'] ) ); |
|
333 | +function wpinv_ipn_url_callback($args) { |
|
334 | + $sanitize_id = esc_attr(wpinv_sanitize_key($args['id'])); |
|
335 | 335 | |
336 | - echo '<input class="regular-text" type="text" ' . ( $args['readonly'] ? ' readonly' : '' ) . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" onClick="this.select()">'; |
|
337 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']">' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
336 | + echo '<input class="regular-text" type="text" ' . ($args['readonly'] ? ' readonly' : '') . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . esc_attr($sanitize_id) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" onClick="this.select()">'; |
|
337 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']">' . wp_kses_post($args['desc']) . '</label>'; |
|
338 | 338 | |
339 | 339 | } |
340 | 340 | |
@@ -345,10 +345,10 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return bool |
347 | 347 | */ |
348 | -function wpinv_is_test_mode( $gateway = '' ) { |
|
349 | - $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", true ); |
|
350 | - $supports = getpaid_payment_gateway_supports( $gateway, 'sandbox' ); |
|
351 | - return apply_filters( 'wpinv_is_test_mode', $sandbox && $supports, $gateway ); |
|
348 | +function wpinv_is_test_mode($gateway = '') { |
|
349 | + $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", true); |
|
350 | + $supports = getpaid_payment_gateway_supports($gateway, 'sandbox'); |
|
351 | + return apply_filters('wpinv_is_test_mode', $sandbox && $supports, $gateway); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * |
360 | 360 | * @return string |
361 | 361 | */ |
362 | -function wpinv_get_ipn_url( $gateway = false, $args = array() ) { |
|
362 | +function wpinv_get_ipn_url($gateway = false, $args = array()) { |
|
363 | 363 | $args = wp_parse_args( |
364 | 364 | array( |
365 | 365 | 'wpi-listener' => 'IPN', |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | $args |
369 | 369 | ); |
370 | 370 | |
371 | - return apply_filters( 'wpinv_ipn_url', add_query_arg( $args, home_url( 'index.php' ) ), $gateway, $args ); |
|
371 | + return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args); |
|
372 | 372 | |
373 | 373 | } |
374 | 374 | |
@@ -379,34 +379,34 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @return string |
381 | 381 | */ |
382 | -function getpaid_get_non_query_string_ipn_url( $gateway ) { |
|
383 | - $gateway = wpinv_sanitize_key( $gateway ); |
|
384 | - return home_url( "getpaid-ipn/$gateway" ); |
|
382 | +function getpaid_get_non_query_string_ipn_url($gateway) { |
|
383 | + $gateway = wpinv_sanitize_key($gateway); |
|
384 | + return home_url("getpaid-ipn/$gateway"); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | |
388 | 388 | /** |
389 | 389 | * Retrieves request data with slashes removed slashes. |
390 | 390 | */ |
391 | -function wpinv_get_post_data( $method = 'request' ) { |
|
391 | +function wpinv_get_post_data($method = 'request') { |
|
392 | 392 | |
393 | - if ( $method == 'post' ) { |
|
394 | - return wp_kses_post_deep( wp_unslash( $_POST ) ); |
|
393 | + if ($method == 'post') { |
|
394 | + return wp_kses_post_deep(wp_unslash($_POST)); |
|
395 | 395 | } |
396 | 396 | |
397 | - if ( $method == 'get' ) { |
|
398 | - return wp_kses_post_deep( wp_unslash( $_GET ) ); |
|
397 | + if ($method == 'get') { |
|
398 | + return wp_kses_post_deep(wp_unslash($_GET)); |
|
399 | 399 | } |
400 | 400 | |
401 | - return wp_kses_post_deep( wp_unslash( $_REQUEST ) ); |
|
401 | + return wp_kses_post_deep(wp_unslash($_REQUEST)); |
|
402 | 402 | |
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
406 | 406 | * Checks if a given gateway supports subscription payments. |
407 | 407 | */ |
408 | -function wpinv_gateway_support_subscription( $gateway ) { |
|
409 | - return getpaid_payment_gateway_supports( $gateway, 'subscription' ); |
|
408 | +function wpinv_gateway_support_subscription($gateway) { |
|
409 | + return getpaid_payment_gateway_supports($gateway, 'subscription'); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | /** |
@@ -415,18 +415,18 @@ discard block |
||
415 | 415 | * @param array $gateways an array of gateways. |
416 | 416 | * @param GetPaid_Payment_Form $form payment form. |
417 | 417 | */ |
418 | -function wpinv_payment_gateways_on_cart( $gateways, $form ) { |
|
418 | +function wpinv_payment_gateways_on_cart($gateways, $form) { |
|
419 | 419 | |
420 | - if ( $form->is_recurring() ) { |
|
420 | + if ($form->is_recurring()) { |
|
421 | 421 | |
422 | - foreach ( array_keys( $gateways ) as $gateway ) { |
|
422 | + foreach (array_keys($gateways) as $gateway) { |
|
423 | 423 | |
424 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
425 | - unset( $gateways[ $gateway ] ); |
|
424 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
425 | + unset($gateways[$gateway]); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
430 | 430 | return $gateways; |
431 | 431 | } |
432 | -add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 ); |
|
432 | +add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This class handles invoice notificaiton emails. |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $this->invoice_actions = apply_filters( |
29 | 29 | 'getpaid_notification_email_invoice_triggers', |
30 | 30 | array( |
31 | - 'getpaid_new_invoice' => array( 'new_invoice', 'user_invoice' ), |
|
31 | + 'getpaid_new_invoice' => array('new_invoice', 'user_invoice'), |
|
32 | 32 | 'getpaid_invoice_status_wpi-cancelled' => 'cancelled_invoice', |
33 | 33 | 'getpaid_invoice_status_wpi-failed' => 'failed_invoice', |
34 | 34 | 'getpaid_invoice_status_wpi-onhold' => 'onhold_invoice', |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function init_hooks() { |
52 | 52 | |
53 | - add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 ); |
|
54 | - add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 ); |
|
53 | + add_filter('getpaid_get_email_merge_tags', array($this, 'invoice_merge_tags'), 10, 2); |
|
54 | + add_filter('getpaid_invoice_email_recipients', array($this, 'filter_email_recipients'), 10, 2); |
|
55 | 55 | |
56 | - foreach ( $this->invoice_actions as $hook => $email_type ) { |
|
57 | - $this->init_email_type_hook( $hook, $email_type ); |
|
56 | + foreach ($this->invoice_actions as $hook => $email_type) { |
|
57 | + $this->init_email_type_hook($hook, $email_type); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -64,25 +64,25 @@ discard block |
||
64 | 64 | * @param string $hook |
65 | 65 | * @param string|array $email_type |
66 | 66 | */ |
67 | - public function init_email_type_hook( $hook, $email_type ) { |
|
67 | + public function init_email_type_hook($hook, $email_type) { |
|
68 | 68 | |
69 | - $email_type = wpinv_parse_list( $email_type ); |
|
69 | + $email_type = wpinv_parse_list($email_type); |
|
70 | 70 | |
71 | - foreach ( $email_type as $type ) { |
|
71 | + foreach ($email_type as $type) { |
|
72 | 72 | |
73 | - $email = new GetPaid_Notification_Email( $type ); |
|
73 | + $email = new GetPaid_Notification_Email($type); |
|
74 | 74 | |
75 | 75 | // Abort if it is not active. |
76 | - if ( ! $email->is_active() ) { |
|
76 | + if (!$email->is_active()) { |
|
77 | 77 | continue; |
78 | 78 | } |
79 | 79 | |
80 | - if ( method_exists( $this, $type ) ) { |
|
81 | - add_action( $hook, array( $this, $type ), 100, 2 ); |
|
80 | + if (method_exists($this, $type)) { |
|
81 | + add_action($hook, array($this, $type), 100, 2); |
|
82 | 82 | continue; |
83 | 83 | } |
84 | 84 | |
85 | - do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook ); |
|
85 | + do_action('getpaid_invoice_init_email_type_hook', $type, $hook); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | } |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | * @param array $merge_tags |
94 | 94 | * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
95 | 95 | */ |
96 | - public function invoice_merge_tags( $merge_tags, $object ) { |
|
96 | + public function invoice_merge_tags($merge_tags, $object) { |
|
97 | 97 | |
98 | - if ( is_a( $object, 'WPInv_Invoice' ) ) { |
|
98 | + if (is_a($object, 'WPInv_Invoice')) { |
|
99 | 99 | return array_merge( |
100 | 100 | $merge_tags, |
101 | - $this->get_invoice_merge_tags( $object ) |
|
101 | + $this->get_invoice_merge_tags($object) |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
105 | + if (is_a($object, 'WPInv_Subscription')) { |
|
106 | 106 | return array_merge( |
107 | 107 | $merge_tags, |
108 | - $this->get_invoice_merge_tags( $object->get_parent_payment() ) |
|
108 | + $this->get_invoice_merge_tags($object->get_parent_payment()) |
|
109 | 109 | ); |
110 | 110 | } |
111 | 111 | |
@@ -119,50 +119,50 @@ discard block |
||
119 | 119 | * @param WPInv_Invoice $invoice |
120 | 120 | * @return array |
121 | 121 | */ |
122 | - public function get_invoice_merge_tags( $invoice ) { |
|
122 | + public function get_invoice_merge_tags($invoice) { |
|
123 | 123 | |
124 | 124 | // Abort if it does not exist. |
125 | - if ( ! $invoice->get_id() ) { |
|
125 | + if (!$invoice->get_id()) { |
|
126 | 126 | return array(); |
127 | 127 | } |
128 | 128 | |
129 | 129 | $merge_tags = array( |
130 | - '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
131 | - '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
132 | - '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
133 | - '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
134 | - '{email}' => sanitize_email( $invoice->get_email() ), |
|
135 | - '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
136 | - '{invoice_currency}' => sanitize_text_field( $invoice->get_currency() ), |
|
137 | - '{invoice_total}' => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ), |
|
138 | - '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
139 | - '{invoice_pay_link}' => esc_url( $invoice->get_checkout_payment_url() ), |
|
140 | - '{invoice_receipt_link}' => esc_url( $invoice->get_receipt_url() ), |
|
141 | - '{invoice_date}' => getpaid_format_date_value( $invoice->get_date_created() ), |
|
142 | - '{invoice_due_date}' => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ), |
|
143 | - '{invoice_quote}' => sanitize_text_field( strtolower( $invoice->get_label() ) ), |
|
144 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_label() ) ), |
|
145 | - '{invoice_description}' => wp_kses_post( $invoice->get_description() ), |
|
146 | - '{subscription_name}' => wp_kses_post( $invoice->get_subscription_name() ), |
|
147 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
130 | + '{name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
131 | + '{full_name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
132 | + '{first_name}' => sanitize_text_field($invoice->get_first_name()), |
|
133 | + '{last_name}' => sanitize_text_field($invoice->get_last_name()), |
|
134 | + '{email}' => sanitize_email($invoice->get_email()), |
|
135 | + '{invoice_number}' => sanitize_text_field($invoice->get_number()), |
|
136 | + '{invoice_currency}' => sanitize_text_field($invoice->get_currency()), |
|
137 | + '{invoice_total}' => sanitize_text_field(wpinv_price($invoice->get_total(), $invoice->get_currency())), |
|
138 | + '{invoice_link}' => esc_url($invoice->get_view_url()), |
|
139 | + '{invoice_pay_link}' => esc_url($invoice->get_checkout_payment_url()), |
|
140 | + '{invoice_receipt_link}' => esc_url($invoice->get_receipt_url()), |
|
141 | + '{invoice_date}' => getpaid_format_date_value($invoice->get_date_created()), |
|
142 | + '{invoice_due_date}' => getpaid_format_date_value($invoice->get_due_date(), __('on receipt', 'invoicing')), |
|
143 | + '{invoice_quote}' => sanitize_text_field(strtolower($invoice->get_label())), |
|
144 | + '{invoice_label}' => sanitize_text_field(ucfirst($invoice->get_label())), |
|
145 | + '{invoice_description}' => wp_kses_post($invoice->get_description()), |
|
146 | + '{subscription_name}' => wp_kses_post($invoice->get_subscription_name()), |
|
147 | + '{is_was}' => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
148 | 148 | ); |
149 | 149 | |
150 | - $payment_form_data = $invoice->get_meta( 'payment_form_data', true ); |
|
150 | + $payment_form_data = $invoice->get_meta('payment_form_data', true); |
|
151 | 151 | |
152 | - if ( is_array( $payment_form_data ) ) { |
|
152 | + if (is_array($payment_form_data)) { |
|
153 | 153 | |
154 | - foreach ( $payment_form_data as $label => $value ) { |
|
154 | + foreach ($payment_form_data as $label => $value) { |
|
155 | 155 | |
156 | - $label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) ); |
|
157 | - $value = is_array( $value ) ? implode( ', ', $value ) : $value; |
|
156 | + $label = preg_replace('/[^a-z0-9]+/', '_', strtolower($label)); |
|
157 | + $value = is_array($value) ? implode(', ', $value) : $value; |
|
158 | 158 | |
159 | - if ( is_scalar( $value ) ) { |
|
160 | - $merge_tags[ "{{$label}}" ] = wp_kses_post( $value ); |
|
159 | + if (is_scalar($value)) { |
|
160 | + $merge_tags["{{$label}}"] = wp_kses_post($value); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | - return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice ); |
|
165 | + return apply_filters('getpaid_invoice_email_merge_tags', $merge_tags, $invoice); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | * @param string|array $recipients |
175 | 175 | * @param array $extra_args Extra template args. |
176 | 176 | */ |
177 | - public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
177 | + public function send_email($invoice, $email, $type, $recipients, $extra_args = array()) { |
|
178 | 178 | |
179 | - do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
179 | + do_action('getpaid_before_send_invoice_notification', $type, $invoice, $email); |
|
180 | 180 | |
181 | - $skip = $invoice->is_free() && wpinv_get_option( 'skip_email_free_invoice' ); |
|
182 | - if ( apply_filters( 'getpaid_skip_invoice_email', $skip, $type, $invoice ) ) { |
|
181 | + $skip = $invoice->is_free() && wpinv_get_option('skip_email_free_invoice'); |
|
182 | + if (apply_filters('getpaid_skip_invoice_email', $skip, $type, $invoice)) { |
|
183 | 183 | return; |
184 | 184 | } |
185 | 185 | |
@@ -187,43 +187,43 @@ discard block |
||
187 | 187 | $merge_tags = $email->get_merge_tags(); |
188 | 188 | |
189 | 189 | $result = $mailer->send( |
190 | - apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
191 | - $email->add_merge_tags( $email->get_subject(), $merge_tags ), |
|
192 | - $email->get_content( $merge_tags, $extra_args ), |
|
190 | + apply_filters('getpaid_invoice_email_recipients', wpinv_parse_list($recipients), $email), |
|
191 | + $email->add_merge_tags($email->get_subject(), $merge_tags), |
|
192 | + $email->get_content($merge_tags, $extra_args), |
|
193 | 193 | $email->get_attachments() |
194 | 194 | ); |
195 | 195 | |
196 | 196 | // Maybe send a copy to the admin. |
197 | - if ( $email->include_admin_bcc() ) { |
|
197 | + if ($email->include_admin_bcc()) { |
|
198 | 198 | $mailer->send( |
199 | 199 | wpinv_get_admin_email(), |
200 | - $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ), |
|
201 | - $email->get_content( $merge_tags ), |
|
200 | + $email->add_merge_tags($email->get_subject() . __(' - ADMIN BCC COPY', 'invoicing'), $merge_tags), |
|
201 | + $email->get_content($merge_tags), |
|
202 | 202 | $email->get_attachments() |
203 | 203 | ); |
204 | 204 | } |
205 | 205 | |
206 | - if ( $result ) { |
|
206 | + if ($result) { |
|
207 | 207 | $invoice->add_system_note( |
208 | 208 | sprintf( |
209 | 209 | // translators: %1 is the email type, %2 is the invoice recipient. |
210 | - __( 'Successfully sent %1$s notification email to %2$s.', 'invoicing' ), |
|
211 | - sanitize_key( $type ), |
|
212 | - $email->is_admin_email() ? __( 'admin', 'invoicing' ) : __( 'the customer', 'invoicing' ) |
|
210 | + __('Successfully sent %1$s notification email to %2$s.', 'invoicing'), |
|
211 | + sanitize_key($type), |
|
212 | + $email->is_admin_email() ? __('admin', 'invoicing') : __('the customer', 'invoicing') |
|
213 | 213 | ) |
214 | 214 | ); |
215 | 215 | } else { |
216 | 216 | $invoice->add_system_note( |
217 | 217 | sprintf( |
218 | 218 | // translators: %1 is the email type, %2 is the invoice recipient. |
219 | - __( 'Failed sending %1$s notification email to %2$s.', 'invoicing' ), |
|
220 | - sanitize_key( $type ), |
|
221 | - $email->is_admin_email() ? __( 'admin', 'invoicing' ) : __( 'the customer', 'invoicing' ) |
|
219 | + __('Failed sending %1$s notification email to %2$s.', 'invoicing'), |
|
220 | + sanitize_key($type), |
|
221 | + $email->is_admin_email() ? __('admin', 'invoicing') : __('the customer', 'invoicing') |
|
222 | 222 | ) |
223 | 223 | ); |
224 | 224 | } |
225 | 225 | |
226 | - do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
226 | + do_action('getpaid_after_send_invoice_notification', $type, $invoice, $email); |
|
227 | 227 | |
228 | 228 | return $result; |
229 | 229 | } |
@@ -234,20 +234,20 @@ discard block |
||
234 | 234 | * @param array $recipients |
235 | 235 | * @param GetPaid_Notification_Email $email |
236 | 236 | */ |
237 | - public function filter_email_recipients( $recipients, $email ) { |
|
237 | + public function filter_email_recipients($recipients, $email) { |
|
238 | 238 | |
239 | - if ( ! $email->is_admin_email() ) { |
|
239 | + if (!$email->is_admin_email()) { |
|
240 | 240 | $cc = $email->object->get_email_cc(); |
241 | - $cc_2 = get_user_meta( $email->object->get_user_id(), '_wpinv_email_cc', true ); |
|
241 | + $cc_2 = get_user_meta($email->object->get_user_id(), '_wpinv_email_cc', true); |
|
242 | 242 | |
243 | - if ( ! empty( $cc ) ) { |
|
244 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
245 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
243 | + if (!empty($cc)) { |
|
244 | + $cc = array_map('sanitize_email', wpinv_parse_list($cc)); |
|
245 | + $recipients = array_filter(array_unique(array_merge($recipients, $cc))); |
|
246 | 246 | } |
247 | 247 | |
248 | - if ( ! empty( $cc_2 ) ) { |
|
249 | - $cc_2 = array_map( 'sanitize_email', wpinv_parse_list( $cc_2 ) ); |
|
250 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc_2 ) ) ); |
|
248 | + if (!empty($cc_2)) { |
|
249 | + $cc_2 = array_map('sanitize_email', wpinv_parse_list($cc_2)); |
|
250 | + $recipients = array_filter(array_unique(array_merge($recipients, $cc_2))); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
@@ -260,17 +260,17 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @param WPInv_Invoice $invoice |
262 | 262 | */ |
263 | - public function new_invoice( $invoice ) { |
|
263 | + public function new_invoice($invoice) { |
|
264 | 264 | |
265 | 265 | // Only send this email for invoices created via the admin page. |
266 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
266 | + if (!$invoice->is_type('invoice') || $invoice->is_paid() || $this->is_payment_form_invoice($invoice->get_id())) { |
|
267 | 267 | return; |
268 | 268 | } |
269 | 269 | |
270 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
270 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
271 | 271 | $recipient = wpinv_get_admin_email(); |
272 | 272 | |
273 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
273 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
274 | 274 | |
275 | 275 | } |
276 | 276 | |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @param WPInv_Invoice $invoice |
281 | 281 | */ |
282 | - public function cancelled_invoice( $invoice ) { |
|
282 | + public function cancelled_invoice($invoice) { |
|
283 | 283 | |
284 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
284 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
285 | 285 | $recipient = $invoice->get_email(); |
286 | 286 | |
287 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
287 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -292,12 +292,12 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @param WPInv_Invoice $invoice |
294 | 294 | */ |
295 | - public function failed_invoice( $invoice ) { |
|
295 | + public function failed_invoice($invoice) { |
|
296 | 296 | |
297 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
297 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
298 | 298 | $recipient = wpinv_get_admin_email(); |
299 | 299 | |
300 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
300 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
301 | 301 | |
302 | 302 | } |
303 | 303 | |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | * |
307 | 307 | * @param WPInv_Invoice $invoice |
308 | 308 | */ |
309 | - public function onhold_invoice( $invoice ) { |
|
309 | + public function onhold_invoice($invoice) { |
|
310 | 310 | |
311 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
311 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
312 | 312 | $recipient = $invoice->get_email(); |
313 | 313 | |
314 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
314 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
315 | 315 | |
316 | 316 | } |
317 | 317 | |
@@ -320,12 +320,12 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @param WPInv_Invoice $invoice |
322 | 322 | */ |
323 | - public function processing_invoice( $invoice ) { |
|
323 | + public function processing_invoice($invoice) { |
|
324 | 324 | |
325 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
325 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
326 | 326 | $recipient = $invoice->get_email(); |
327 | 327 | |
328 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
328 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
329 | 329 | |
330 | 330 | } |
331 | 331 | |
@@ -334,17 +334,17 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @param WPInv_Invoice $invoice |
336 | 336 | */ |
337 | - public function completed_invoice( $invoice ) { |
|
337 | + public function completed_invoice($invoice) { |
|
338 | 338 | |
339 | 339 | // (Maybe) abort if it is a renewal invoice. |
340 | - if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
340 | + if ($invoice->is_renewal() && !wpinv_get_option('email_completed_invoice_renewal_active', false)) { |
|
341 | 341 | return; |
342 | 342 | } |
343 | 343 | |
344 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
344 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
345 | 345 | $recipient = $invoice->get_email(); |
346 | 346 | |
347 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
347 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
348 | 348 | |
349 | 349 | } |
350 | 350 | |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | * |
354 | 354 | * @param WPInv_Invoice $invoice |
355 | 355 | */ |
356 | - public function refunded_invoice( $invoice ) { |
|
356 | + public function refunded_invoice($invoice) { |
|
357 | 357 | |
358 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
358 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
359 | 359 | $recipient = $invoice->get_email(); |
360 | 360 | |
361 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
361 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
362 | 362 | |
363 | 363 | } |
364 | 364 | |
@@ -368,21 +368,21 @@ discard block |
||
368 | 368 | * @param WPInv_Invoice $invoice |
369 | 369 | * @param bool $force |
370 | 370 | */ |
371 | - public function user_invoice( $invoice, $force = false ) { |
|
371 | + public function user_invoice($invoice, $force = false) { |
|
372 | 372 | |
373 | - if ( ! $force && ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) { |
|
373 | + if (!$force && !empty($GLOBALS['wpinv_skip_invoice_notification'])) { |
|
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | 377 | // Only send this email for invoices created via the admin page. |
378 | - if ( ! $invoice->is_type( 'invoice' ) || ( empty( $force ) && $invoice->is_paid() ) || ( empty( $force ) && $this->is_payment_form_invoice( $invoice->get_id() ) ) ) { |
|
378 | + if (!$invoice->is_type('invoice') || (empty($force) && $invoice->is_paid()) || (empty($force) && $this->is_payment_form_invoice($invoice->get_id()))) { |
|
379 | 379 | return; |
380 | 380 | } |
381 | 381 | |
382 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
382 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
383 | 383 | $recipient = $invoice->get_email(); |
384 | 384 | |
385 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
385 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
386 | 386 | |
387 | 387 | } |
388 | 388 | |
@@ -392,11 +392,11 @@ discard block |
||
392 | 392 | * @param int $invoice |
393 | 393 | * @return bool |
394 | 394 | */ |
395 | - public function is_payment_form_invoice( $invoice ) { |
|
396 | - $created_via = get_post_meta( $invoice, 'wpinv_created_via', true ); |
|
395 | + public function is_payment_form_invoice($invoice) { |
|
396 | + $created_via = get_post_meta($invoice, 'wpinv_created_via', true); |
|
397 | 397 | $is_payment_form_invoice = 'payment_form' === $created_via || 'geodirectory' === $created_via; |
398 | - $is_payment_form_invoice = apply_filters( 'getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice ); |
|
399 | - return empty( $_GET['getpaid-admin-action'] ) && $is_payment_form_invoice; |
|
398 | + $is_payment_form_invoice = apply_filters('getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice); |
|
399 | + return empty($_GET['getpaid-admin-action']) && $is_payment_form_invoice; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
@@ -405,12 +405,12 @@ discard block |
||
405 | 405 | * @param WPInv_Invoice $invoice |
406 | 406 | * @param string $note |
407 | 407 | */ |
408 | - public function user_note( $invoice, $note ) { |
|
408 | + public function user_note($invoice, $note) { |
|
409 | 409 | |
410 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
410 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
411 | 411 | $recipient = $invoice->get_email(); |
412 | 412 | |
413 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
413 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient, array('customer_note' => $note)); |
|
414 | 414 | |
415 | 415 | } |
416 | 416 | |
@@ -419,9 +419,9 @@ discard block |
||
419 | 419 | * |
420 | 420 | * @param WPInv_Invoice $invoice |
421 | 421 | */ |
422 | - public function force_send_overdue_notice( $invoice ) { |
|
423 | - $email = new GetPaid_Notification_Email( 'overdue', $invoice ); |
|
424 | - return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() ); |
|
422 | + public function force_send_overdue_notice($invoice) { |
|
423 | + $email = new GetPaid_Notification_Email('overdue', $invoice); |
|
424 | + return $this->send_email($invoice, $email, 'overdue', $invoice->get_email()); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | /** |
@@ -432,38 +432,38 @@ discard block |
||
432 | 432 | public function overdue() { |
433 | 433 | global $wpdb; |
434 | 434 | |
435 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
435 | + $email = new GetPaid_Notification_Email(__FUNCTION__); |
|
436 | 436 | |
437 | 437 | // Fetch reminder days. |
438 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
438 | + $reminder_days = array_unique(wp_parse_id_list($email->get_option('days'))); |
|
439 | 439 | |
440 | 440 | // Abort if non is set. |
441 | - if ( empty( $reminder_days ) ) { |
|
441 | + if (empty($reminder_days)) { |
|
442 | 442 | return; |
443 | 443 | } |
444 | 444 | |
445 | 445 | // Retrieve date query. |
446 | - $date_query = $this->get_date_query( $reminder_days ); |
|
446 | + $date_query = $this->get_date_query($reminder_days); |
|
447 | 447 | |
448 | 448 | // Invoices table. |
449 | 449 | $table = $wpdb->prefix . 'getpaid_invoices'; |
450 | 450 | |
451 | 451 | // Fetch invoices. |
452 | - $invoices = $wpdb->get_col( |
|
452 | + $invoices = $wpdb->get_col( |
|
453 | 453 | "SELECT posts.ID FROM $wpdb->posts as posts |
454 | 454 | LEFT JOIN $table as invoices ON invoices.post_id = posts.ID |
455 | 455 | WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query" |
456 | 456 | ); |
457 | 457 | |
458 | - foreach ( $invoices as $invoice ) { |
|
458 | + foreach ($invoices as $invoice) { |
|
459 | 459 | |
460 | 460 | // Only send this email for invoices created via the admin page. |
461 | - if ( ! $this->is_payment_form_invoice( $invoice ) ) { |
|
462 | - $invoice = new WPInv_Invoice( $invoice ); |
|
461 | + if (!$this->is_payment_form_invoice($invoice)) { |
|
462 | + $invoice = new WPInv_Invoice($invoice); |
|
463 | 463 | $email->object = $invoice; |
464 | 464 | |
465 | - if ( $invoice->needs_payment() && ! $invoice->is_renewal() ) { |
|
466 | - $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
465 | + if ($invoice->needs_payment() && !$invoice->is_renewal()) { |
|
466 | + $this->send_email($invoice, $email, __FUNCTION__, $invoice->get_email()); |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | } |
@@ -476,14 +476,14 @@ discard block |
||
476 | 476 | * @param array $reminder_days |
477 | 477 | * @return string |
478 | 478 | */ |
479 | - public function get_date_query( $reminder_days ) { |
|
479 | + public function get_date_query($reminder_days) { |
|
480 | 480 | |
481 | 481 | $date_query = array( |
482 | 482 | 'relation' => 'OR', |
483 | 483 | ); |
484 | 484 | |
485 | - foreach ( $reminder_days as $days ) { |
|
486 | - $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) ); |
|
485 | + foreach ($reminder_days as $days) { |
|
486 | + $date = date_parse(date('Y-m-d', strtotime("-$days days", current_time('timestamp')))); |
|
487 | 487 | |
488 | 488 | $date_query[] = array( |
489 | 489 | 'year' => $date['year'], |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | |
494 | 494 | } |
495 | 495 | |
496 | - $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' ); |
|
496 | + $date_query = new WP_Date_Query($date_query, 'invoices.due_date'); |
|
497 | 497 | |
498 | 498 | return $date_query->get_sql(); |
499 | 499 |
@@ -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 | * WPInv_Ajax class. |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | * Hook in ajax handlers. |
18 | 18 | */ |
19 | 19 | public static function init() { |
20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
20 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
21 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
22 | 22 | self::add_ajax_events(); |
23 | 23 | } |
24 | 24 | |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function define_ajax() { |
29 | 29 | |
30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
30 | + if (!empty($_GET['wpinv-ajax'])) { |
|
31 | + getpaid_maybe_define_constant('DOING_AJAX', true); |
|
32 | + getpaid_maybe_define_constant('WPInv_DOING_AJAX', true); |
|
33 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
34 | + /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0); |
|
35 | 35 | } |
36 | 36 | $GLOBALS['wpdb']->hide_errors(); |
37 | 37 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * @since 1.0.18 |
45 | 45 | */ |
46 | 46 | private static function wpinv_ajax_headers() { |
47 | - if ( ! headers_sent() ) { |
|
47 | + if (!headers_sent()) { |
|
48 | 48 | send_origin_headers(); |
49 | 49 | send_nosniff_header(); |
50 | 50 | nocache_headers(); |
51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | - header( 'X-Robots-Tag: noindex' ); |
|
53 | - status_header( 200 ); |
|
51 | + header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
52 | + header('X-Robots-Tag: noindex'); |
|
53 | + status_header(200); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | public static function do_wpinv_ajax() { |
61 | 61 | global $wp_query; |
62 | 62 | |
63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
63 | + if (!empty($_GET['wpinv-ajax'])) { |
|
64 | + $wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax']))); |
|
65 | 65 | } |
66 | 66 | |
67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
67 | + $action = $wp_query->get('wpinv-ajax'); |
|
68 | 68 | |
69 | - if ( $action ) { |
|
69 | + if ($action) { |
|
70 | 70 | self::wpinv_ajax_headers(); |
71 | - $action = sanitize_text_field( $action ); |
|
72 | - do_action( 'wpinv_ajax_' . $action ); |
|
71 | + $action = sanitize_text_field($action); |
|
72 | + do_action('wpinv_ajax_' . $action); |
|
73 | 73 | wp_die(); |
74 | 74 | } |
75 | 75 | |
@@ -106,36 +106,36 @@ discard block |
||
106 | 106 | 'file_upload' => true, |
107 | 107 | ); |
108 | 108 | |
109 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
110 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
111 | - add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
109 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
110 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
111 | + add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
112 | 112 | |
113 | - if ( $nopriv ) { |
|
114 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
115 | - add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
116 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
113 | + if ($nopriv) { |
|
114 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
115 | + add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
116 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | 121 | public static function add_note() { |
122 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
122 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
123 | 123 | |
124 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
124 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
125 | 125 | die( -1 ); |
126 | 126 | } |
127 | 127 | |
128 | - $post_id = absint( $_POST['post_id'] ); |
|
129 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
130 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
128 | + $post_id = absint($_POST['post_id']); |
|
129 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
130 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
131 | 131 | |
132 | 132 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
133 | 133 | |
134 | - if ( $post_id > 0 ) { |
|
135 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
134 | + if ($post_id > 0) { |
|
135 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
136 | 136 | |
137 | - if ( $note_id > 0 && ! is_wp_error( $note_id ) ) { |
|
138 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
137 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
138 | + wpinv_get_invoice_note_line_item($note_id); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
@@ -143,16 +143,16 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | public static function delete_note() { |
146 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
146 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
147 | 147 | |
148 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
148 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
149 | 149 | die( -1 ); |
150 | 150 | } |
151 | 151 | |
152 | - $note_id = (int)$_POST['note_id']; |
|
152 | + $note_id = (int) $_POST['note_id']; |
|
153 | 153 | |
154 | - if ( $note_id > 0 ) { |
|
155 | - wp_delete_comment( $note_id, true ); |
|
154 | + if ($note_id > 0) { |
|
155 | + wp_delete_comment($note_id, true); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | die(); |
@@ -170,34 +170,34 @@ discard block |
||
170 | 170 | public static function get_billing_details() { |
171 | 171 | |
172 | 172 | // Verify nonce. |
173 | - check_ajax_referer( 'wpinv-nonce' ); |
|
173 | + check_ajax_referer('wpinv-nonce'); |
|
174 | 174 | |
175 | 175 | // Can the user manage the plugin? |
176 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
176 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
177 | 177 | die( -1 ); |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Do we have a user id? |
181 | 181 | $user_id = (int) $_GET['user_id']; |
182 | 182 | |
183 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
183 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
184 | 184 | die( -1 ); |
185 | 185 | } |
186 | 186 | |
187 | 187 | // Fetch the billing details. |
188 | - $billing_details = wpinv_get_user_address( $user_id ); |
|
189 | - $billing_details = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id ); |
|
188 | + $billing_details = wpinv_get_user_address($user_id); |
|
189 | + $billing_details = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id); |
|
190 | 190 | |
191 | 191 | // unset the user id and email. |
192 | - $to_ignore = array( 'user_id', 'email' ); |
|
192 | + $to_ignore = array('user_id', 'email'); |
|
193 | 193 | |
194 | - foreach ( $to_ignore as $key ) { |
|
195 | - if ( isset( $billing_details[ $key ] ) ) { |
|
196 | - unset( $billing_details[ $key ] ); |
|
194 | + foreach ($to_ignore as $key) { |
|
195 | + if (isset($billing_details[$key])) { |
|
196 | + unset($billing_details[$key]); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - wp_send_json_success( $billing_details ); |
|
200 | + wp_send_json_success($billing_details); |
|
201 | 201 | |
202 | 202 | } |
203 | 203 | |
@@ -207,47 +207,47 @@ discard block |
||
207 | 207 | public static function check_new_user_email() { |
208 | 208 | |
209 | 209 | // Verify nonce. |
210 | - check_ajax_referer( 'wpinv-nonce' ); |
|
210 | + check_ajax_referer('wpinv-nonce'); |
|
211 | 211 | |
212 | 212 | // Can the user manage the plugin? |
213 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
213 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
214 | 214 | die( -1 ); |
215 | 215 | } |
216 | 216 | |
217 | 217 | // We need an email address. |
218 | - if ( empty( $_GET['email'] ) ) { |
|
219 | - esc_html_e( "Provide the new user's email address", 'invoicing' ); |
|
218 | + if (empty($_GET['email'])) { |
|
219 | + esc_html_e("Provide the new user's email address", 'invoicing'); |
|
220 | 220 | exit; |
221 | 221 | } |
222 | 222 | |
223 | 223 | // Ensure the email is valid. |
224 | - $email = sanitize_email( $_GET['email'] ); |
|
225 | - if ( ! is_email( $email ) ) { |
|
226 | - esc_html_e( 'Invalid email address', 'invoicing' ); |
|
224 | + $email = sanitize_email($_GET['email']); |
|
225 | + if (!is_email($email)) { |
|
226 | + esc_html_e('Invalid email address', 'invoicing'); |
|
227 | 227 | exit; |
228 | 228 | } |
229 | 229 | |
230 | 230 | // And it does not exist. |
231 | - $id = email_exists( $email ); |
|
232 | - if ( $id ) { |
|
233 | - wp_send_json_success( compact( 'id' ) ); |
|
231 | + $id = email_exists($email); |
|
232 | + if ($id) { |
|
233 | + wp_send_json_success(compact('id')); |
|
234 | 234 | } |
235 | 235 | |
236 | - wp_send_json_success( true ); |
|
236 | + wp_send_json_success(true); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | public static function run_tool() { |
240 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
241 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
240 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
241 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
242 | 242 | die( -1 ); |
243 | 243 | } |
244 | 244 | |
245 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
245 | + $tool = sanitize_text_field($_POST['tool']); |
|
246 | 246 | |
247 | - do_action( 'wpinv_run_tool' ); |
|
247 | + do_action('wpinv_run_tool'); |
|
248 | 248 | |
249 | - if ( ! empty( $tool ) ) { |
|
250 | - do_action( 'wpinv_tool_' . $tool ); |
|
249 | + if (!empty($tool)) { |
|
250 | + do_action('wpinv_tool_' . $tool); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | global $getpaid_force_checkbox; |
259 | 259 | |
260 | 260 | // Is the request set up correctly? |
261 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) { |
|
261 | + if (empty($_GET['form']) && empty($_GET['item']) && empty($_GET['invoice'])) { |
|
262 | 262 | aui()->alert( |
263 | 263 | array( |
264 | 264 | 'type' => 'warning', |
265 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
265 | + 'content' => __('No payment form or item provided', 'invoicing'), |
|
266 | 266 | ), |
267 | 267 | true |
268 | 268 | ); |
@@ -270,29 +270,29 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | // Payment form or button? |
273 | - if ( ! empty( $_GET['form'] ) ) { |
|
274 | - $form = sanitize_text_field( urldecode( $_GET['form'] ) ); |
|
273 | + if (!empty($_GET['form'])) { |
|
274 | + $form = sanitize_text_field(urldecode($_GET['form'])); |
|
275 | 275 | |
276 | - if ( false !== strpos( $form, '|' ) ) { |
|
277 | - $form_pos = strpos( $form, '|' ); |
|
278 | - $_items = getpaid_convert_items_to_array( substr( $form, $form_pos + 1 ) ); |
|
279 | - $form = substr( $form, 0, $form_pos ); |
|
276 | + if (false !== strpos($form, '|')) { |
|
277 | + $form_pos = strpos($form, '|'); |
|
278 | + $_items = getpaid_convert_items_to_array(substr($form, $form_pos + 1)); |
|
279 | + $form = substr($form, 0, $form_pos); |
|
280 | 280 | |
281 | 281 | // Retrieve appropriate payment form. |
282 | - $payment_form = new GetPaid_Payment_Form( $form ); |
|
283 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
282 | + $payment_form = new GetPaid_Payment_Form($form); |
|
283 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
284 | 284 | |
285 | 285 | $items = array(); |
286 | 286 | $item_ids = array(); |
287 | 287 | |
288 | - foreach ( $_items as $item_id => $qty ) { |
|
289 | - if ( ! in_array( $item_id, $item_ids ) ) { |
|
290 | - $item = new GetPaid_Form_Item( $item_id ); |
|
291 | - $item->set_quantity( $qty ); |
|
288 | + foreach ($_items as $item_id => $qty) { |
|
289 | + if (!in_array($item_id, $item_ids)) { |
|
290 | + $item = new GetPaid_Form_Item($item_id); |
|
291 | + $item->set_quantity($qty); |
|
292 | 292 | |
293 | - if ( 0 == $qty ) { |
|
294 | - $item->set_allow_quantities( true ); |
|
295 | - $item->set_is_required( false ); |
|
293 | + if (0 == $qty) { |
|
294 | + $item->set_allow_quantities(true); |
|
295 | + $item->set_is_required(false); |
|
296 | 296 | $getpaid_force_checkbox = true; |
297 | 297 | } |
298 | 298 | |
@@ -301,32 +301,32 @@ discard block |
||
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
304 | - if ( ! $payment_form->is_default() ) { |
|
304 | + if (!$payment_form->is_default()) { |
|
305 | 305 | |
306 | - foreach ( $payment_form->get_items() as $item ) { |
|
307 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
306 | + foreach ($payment_form->get_items() as $item) { |
|
307 | + if (!in_array($item->get_id(), $item_ids)) { |
|
308 | 308 | $item_ids[] = $item->get_id(); |
309 | 309 | $items[] = $item; |
310 | 310 | } |
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | - $payment_form->set_items( $items ); |
|
315 | - $extra_items = esc_attr( getpaid_convert_items_to_string( $_items ) ); |
|
316 | - $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items ); |
|
314 | + $payment_form->set_items($items); |
|
315 | + $extra_items = esc_attr(getpaid_convert_items_to_string($_items)); |
|
316 | + $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items); |
|
317 | 317 | $extra_items = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />"; |
318 | 318 | $extra_items .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />"; |
319 | - $payment_form->display( $extra_items ); |
|
319 | + $payment_form->display($extra_items); |
|
320 | 320 | $getpaid_force_checkbox = false; |
321 | 321 | |
322 | 322 | } else { |
323 | - getpaid_display_payment_form( $form ); |
|
323 | + getpaid_display_payment_form($form); |
|
324 | 324 | } |
325 | -} elseif ( ! empty( $_GET['invoice'] ) ) { |
|
326 | - getpaid_display_invoice_payment_form( (int) urldecode( $_GET['invoice'] ) ); |
|
325 | +} elseif (!empty($_GET['invoice'])) { |
|
326 | + getpaid_display_invoice_payment_form((int) urldecode($_GET['invoice'])); |
|
327 | 327 | } else { |
328 | - $items = getpaid_convert_items_to_array( sanitize_text_field( urldecode( $_GET['item'] ) ) ); |
|
329 | - getpaid_display_item_payment_form( $items ); |
|
328 | + $items = getpaid_convert_items_to_array(sanitize_text_field(urldecode($_GET['item']))); |
|
329 | + getpaid_display_item_payment_form($items); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | exit; |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | public static function payment_form() { |
342 | 342 | |
343 | 343 | // ... form fields... |
344 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
345 | - esc_html_e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
344 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
345 | + esc_html_e('Error: Reload the page and try again.', 'invoicing'); |
|
346 | 346 | exit; |
347 | 347 | } |
348 | 348 | |
349 | 349 | // Process the payment form. |
350 | - $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' ); |
|
351 | - $checkout = new $checkout_class( new GetPaid_Payment_Form_Submission() ); |
|
350 | + $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout'); |
|
351 | + $checkout = new $checkout_class(new GetPaid_Payment_Form_Submission()); |
|
352 | 352 | $checkout->process_checkout(); |
353 | 353 | |
354 | 354 | exit; |
@@ -361,55 +361,55 @@ discard block |
||
361 | 361 | */ |
362 | 362 | public static function get_payment_form_states_field() { |
363 | 363 | |
364 | - if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) { |
|
364 | + if (empty($_GET['country']) || empty($_GET['form'])) { |
|
365 | 365 | exit; |
366 | 366 | } |
367 | 367 | |
368 | - $elements = getpaid_get_payment_form_elements( (int) $_GET['form'] ); |
|
368 | + $elements = getpaid_get_payment_form_elements((int) $_GET['form']); |
|
369 | 369 | |
370 | - if ( empty( $elements ) ) { |
|
370 | + if (empty($elements)) { |
|
371 | 371 | exit; |
372 | 372 | } |
373 | 373 | |
374 | 374 | $address_fields = array(); |
375 | - foreach ( $elements as $element ) { |
|
376 | - if ( 'address' === $element['type'] ) { |
|
375 | + foreach ($elements as $element) { |
|
376 | + if ('address' === $element['type']) { |
|
377 | 377 | $address_fields = $element; |
378 | 378 | break; |
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
382 | - if ( empty( $address_fields ) ) { |
|
382 | + if (empty($address_fields)) { |
|
383 | 383 | exit; |
384 | 384 | } |
385 | 385 | |
386 | - foreach ( $address_fields['fields'] as $address_field ) { |
|
386 | + foreach ($address_fields['fields'] as $address_field) { |
|
387 | 387 | |
388 | - if ( 'wpinv_state' == $address_field['name'] ) { |
|
388 | + if ('wpinv_state' == $address_field['name']) { |
|
389 | 389 | |
390 | - $wrap_class = getpaid_get_form_element_grid_class( $address_field ); |
|
391 | - $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); |
|
392 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
393 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
394 | - $value = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : ''; |
|
395 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
390 | + $wrap_class = getpaid_get_form_element_grid_class($address_field); |
|
391 | + $wrap_class = esc_attr("$wrap_class getpaid-address-field-wrapper"); |
|
392 | + $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']); |
|
393 | + $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']); |
|
394 | + $value = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : ''; |
|
395 | + $label = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']); |
|
396 | 396 | |
397 | - if ( ! empty( $address_field['required'] ) ) { |
|
397 | + if (!empty($address_field['required'])) { |
|
398 | 398 | $label .= "<span class='text-danger'> *</span>"; |
399 | 399 | } |
400 | 400 | |
401 | 401 | $html = getpaid_get_states_select_markup( |
402 | - sanitize_text_field( $_GET['country'] ), |
|
402 | + sanitize_text_field($_GET['country']), |
|
403 | 403 | $value, |
404 | 404 | $placeholder, |
405 | 405 | $label, |
406 | 406 | $description, |
407 | - ! empty( $address_field['required'] ), |
|
407 | + !empty($address_field['required']), |
|
408 | 408 | $wrap_class, |
409 | - sanitize_text_field( $_GET['name'] ) |
|
409 | + sanitize_text_field($_GET['name']) |
|
410 | 410 | ); |
411 | 411 | |
412 | - wp_send_json_success( $html ); |
|
412 | + wp_send_json_success($html); |
|
413 | 413 | exit; |
414 | 414 | |
415 | 415 | } |
@@ -424,66 +424,66 @@ discard block |
||
424 | 424 | public static function recalculate_invoice_totals() { |
425 | 425 | |
426 | 426 | // Verify nonce. |
427 | - check_ajax_referer( 'wpinv-nonce' ); |
|
427 | + check_ajax_referer('wpinv-nonce'); |
|
428 | 428 | |
429 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
429 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
430 | 430 | exit; |
431 | 431 | } |
432 | 432 | |
433 | 433 | // We need an invoice. |
434 | - if ( empty( $_POST['post_id'] ) ) { |
|
434 | + if (empty($_POST['post_id'])) { |
|
435 | 435 | exit; |
436 | 436 | } |
437 | 437 | |
438 | 438 | // Fetch the invoice. |
439 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
439 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
440 | 440 | |
441 | 441 | // Ensure it exists. |
442 | - if ( ! $invoice->get_id() ) { |
|
442 | + if (!$invoice->get_id()) { |
|
443 | 443 | exit; |
444 | 444 | } |
445 | 445 | |
446 | 446 | // Maybe set the country, state, currency. |
447 | - foreach ( array( 'country', 'state', 'currency', 'vat_number', 'discount_code' ) as $key ) { |
|
448 | - if ( isset( $_POST[ $key ] ) ) { |
|
447 | + foreach (array('country', 'state', 'currency', 'vat_number', 'discount_code') as $key) { |
|
448 | + if (isset($_POST[$key])) { |
|
449 | 449 | $method = "set_$key"; |
450 | - $invoice->$method( sanitize_text_field( $_POST[ $key ] ) ); |
|
450 | + $invoice->$method(sanitize_text_field($_POST[$key])); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
454 | 454 | // Maybe disable taxes. |
455 | - $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) ); |
|
455 | + $invoice->set_disable_taxes(!empty($_POST['taxes'])); |
|
456 | 456 | |
457 | 457 | // Discount code. |
458 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
459 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
460 | - if ( $discount->exists() ) { |
|
461 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
458 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
459 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
460 | + if ($discount->exists()) { |
|
461 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
462 | 462 | } else { |
463 | - $invoice->remove_discount( 'discount_code' ); |
|
463 | + $invoice->remove_discount('discount_code'); |
|
464 | 464 | } |
465 | 465 | } |
466 | 466 | |
467 | 467 | // Recalculate totals. |
468 | 468 | $invoice->recalculate_total(); |
469 | 469 | |
470 | - $total = wpinv_price( $invoice->get_total(), $invoice->get_currency() ); |
|
471 | - $suscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
472 | - if ( is_a( $suscriptions, 'WPInv_Subscription' ) && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) { |
|
473 | - $recurring_total = wpinv_price( $invoice->get_recurring_total(), $invoice->get_currency() ); |
|
474 | - $total .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>'; |
|
470 | + $total = wpinv_price($invoice->get_total(), $invoice->get_currency()); |
|
471 | + $suscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
472 | + if (is_a($suscriptions, 'WPInv_Subscription') && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) { |
|
473 | + $recurring_total = wpinv_price($invoice->get_recurring_total(), $invoice->get_currency()); |
|
474 | + $total .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>'; |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | $totals = array( |
478 | - 'subtotal' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
479 | - 'discount' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
480 | - 'tax' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
478 | + 'subtotal' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
479 | + 'discount' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
480 | + 'tax' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
481 | 481 | 'total' => $total, |
482 | 482 | ); |
483 | 483 | |
484 | - $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice ); |
|
484 | + $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice); |
|
485 | 485 | |
486 | - wp_send_json_success( compact( 'totals' ) ); |
|
486 | + wp_send_json_success(compact('totals')); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -492,33 +492,33 @@ discard block |
||
492 | 492 | public static function get_invoice_items() { |
493 | 493 | |
494 | 494 | // Verify nonce. |
495 | - check_ajax_referer( 'wpinv-nonce' ); |
|
495 | + check_ajax_referer('wpinv-nonce'); |
|
496 | 496 | |
497 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
497 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
498 | 498 | exit; |
499 | 499 | } |
500 | 500 | |
501 | 501 | // We need an invoice and items. |
502 | - if ( empty( $_POST['post_id'] ) ) { |
|
502 | + if (empty($_POST['post_id'])) { |
|
503 | 503 | exit; |
504 | 504 | } |
505 | 505 | |
506 | 506 | // Fetch the invoice. |
507 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
507 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
508 | 508 | |
509 | 509 | // Ensure it exists. |
510 | - if ( ! $invoice->get_id() ) { |
|
510 | + if (!$invoice->get_id()) { |
|
511 | 511 | exit; |
512 | 512 | } |
513 | 513 | |
514 | 514 | // Return an array of invoice items. |
515 | 515 | $items = array(); |
516 | 516 | |
517 | - foreach ( $invoice->get_items() as $item ) { |
|
518 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency(), $invoice->is_renewal() ); |
|
517 | + foreach ($invoice->get_items() as $item) { |
|
518 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency(), $invoice->is_renewal()); |
|
519 | 519 | } |
520 | 520 | |
521 | - wp_send_json_success( compact( 'items' ) ); |
|
521 | + wp_send_json_success(compact('items')); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -527,50 +527,50 @@ discard block |
||
527 | 527 | public static function edit_invoice_item() { |
528 | 528 | |
529 | 529 | // Verify nonce. |
530 | - check_ajax_referer( 'wpinv-nonce' ); |
|
530 | + check_ajax_referer('wpinv-nonce'); |
|
531 | 531 | |
532 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
532 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
533 | 533 | exit; |
534 | 534 | } |
535 | 535 | |
536 | 536 | // We need an invoice and item details. |
537 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) { |
|
537 | + if (empty($_POST['post_id']) || empty($_POST['data'])) { |
|
538 | 538 | exit; |
539 | 539 | } |
540 | 540 | |
541 | 541 | // Fetch the invoice. |
542 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
542 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
543 | 543 | |
544 | 544 | // Ensure it exists and its not been paid for. |
545 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
545 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
546 | 546 | exit; |
547 | 547 | } |
548 | 548 | |
549 | 549 | // Format the data. |
550 | - $data = wp_kses_post_deep( wp_unslash( wp_list_pluck( $_POST['data'], 'value', 'field' ) ) ); |
|
550 | + $data = wp_kses_post_deep(wp_unslash(wp_list_pluck($_POST['data'], 'value', 'field'))); |
|
551 | 551 | |
552 | 552 | // Ensure that we have an item id. |
553 | - if ( empty( $data['id'] ) ) { |
|
553 | + if (empty($data['id'])) { |
|
554 | 554 | exit; |
555 | 555 | } |
556 | 556 | |
557 | 557 | // Abort if the invoice does not have the specified item. |
558 | - $item = $invoice->get_item( (int) $data['id'] ); |
|
558 | + $item = $invoice->get_item((int) $data['id']); |
|
559 | 559 | |
560 | - if ( empty( $item ) ) { |
|
560 | + if (empty($item)) { |
|
561 | 561 | exit; |
562 | 562 | } |
563 | 563 | |
564 | 564 | // Update the item. |
565 | - $item->set_price( getpaid_standardize_amount( $data['price'] ) ); |
|
566 | - $item->set_name( sanitize_text_field( $data['name'] ) ); |
|
567 | - $item->set_description( wp_kses_post( $data['description'] ) ); |
|
568 | - $item->set_quantity( floatval( $data['quantity'] ) ); |
|
565 | + $item->set_price(getpaid_standardize_amount($data['price'])); |
|
566 | + $item->set_name(sanitize_text_field($data['name'])); |
|
567 | + $item->set_description(wp_kses_post($data['description'])); |
|
568 | + $item->set_quantity(floatval($data['quantity'])); |
|
569 | 569 | |
570 | 570 | // Add it to the invoice. |
571 | - $error = $invoice->add_item( $item ); |
|
571 | + $error = $invoice->add_item($item); |
|
572 | 572 | $alert = false; |
573 | - if ( is_wp_error( $error ) ) { |
|
573 | + if (is_wp_error($error)) { |
|
574 | 574 | $alert = $error->get_error_message(); |
575 | 575 | } |
576 | 576 | |
@@ -583,11 +583,11 @@ discard block |
||
583 | 583 | // Return an array of invoice items. |
584 | 584 | $items = array(); |
585 | 585 | |
586 | - foreach ( $invoice->get_items() as $item ) { |
|
587 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
586 | + foreach ($invoice->get_items() as $item) { |
|
587 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
588 | 588 | } |
589 | 589 | |
590 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
590 | + wp_send_json_success(compact('items', 'alert')); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | /** |
@@ -596,53 +596,53 @@ discard block |
||
596 | 596 | public static function create_invoice_item() { |
597 | 597 | |
598 | 598 | // Verify nonce. |
599 | - check_ajax_referer( 'wpinv-nonce' ); |
|
599 | + check_ajax_referer('wpinv-nonce'); |
|
600 | 600 | |
601 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
601 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
602 | 602 | exit; |
603 | 603 | } |
604 | 604 | |
605 | 605 | // We need an invoice and item details. |
606 | - if ( empty( $_POST['invoice_id'] ) || empty( $_POST['_wpinv_quick'] ) ) { |
|
606 | + if (empty($_POST['invoice_id']) || empty($_POST['_wpinv_quick'])) { |
|
607 | 607 | exit; |
608 | 608 | } |
609 | 609 | |
610 | 610 | // Fetch the invoice. |
611 | - $invoice = new WPInv_Invoice( intval( $_POST['invoice_id'] ) ); |
|
611 | + $invoice = new WPInv_Invoice(intval($_POST['invoice_id'])); |
|
612 | 612 | |
613 | 613 | // Ensure it exists and its not been paid for. |
614 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
614 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
615 | 615 | exit; |
616 | 616 | } |
617 | 617 | |
618 | 618 | // Format the data. |
619 | - $data = wp_kses_post_deep( wp_unslash( $_POST['_wpinv_quick'] ) ); |
|
619 | + $data = wp_kses_post_deep(wp_unslash($_POST['_wpinv_quick'])); |
|
620 | 620 | |
621 | 621 | $item = new WPInv_Item(); |
622 | - $item->set_price( getpaid_standardize_amount( $data['price'] ) ); |
|
623 | - $item->set_name( sanitize_text_field( $data['name'] ) ); |
|
624 | - $item->set_description( wp_kses_post( $data['description'] ) ); |
|
625 | - $item->set_type( sanitize_text_field( $data['type'] ) ); |
|
626 | - $item->set_vat_rule( sanitize_text_field( $data['vat_rule'] ) ); |
|
627 | - $item->set_vat_class( sanitize_text_field( $data['vat_class'] ) ); |
|
628 | - $item->set_status( 'publish' ); |
|
622 | + $item->set_price(getpaid_standardize_amount($data['price'])); |
|
623 | + $item->set_name(sanitize_text_field($data['name'])); |
|
624 | + $item->set_description(wp_kses_post($data['description'])); |
|
625 | + $item->set_type(sanitize_text_field($data['type'])); |
|
626 | + $item->set_vat_rule(sanitize_text_field($data['vat_rule'])); |
|
627 | + $item->set_vat_class(sanitize_text_field($data['vat_class'])); |
|
628 | + $item->set_status('publish'); |
|
629 | 629 | $item->save(); |
630 | 630 | |
631 | - if ( ! $item->exists() ) { |
|
632 | - $alert = __( 'Could not create invoice item. Please try again.', 'invoicing' ); |
|
633 | - wp_send_json_success( compact( 'alert' ) ); |
|
631 | + if (!$item->exists()) { |
|
632 | + $alert = __('Could not create invoice item. Please try again.', 'invoicing'); |
|
633 | + wp_send_json_success(compact('alert')); |
|
634 | 634 | } |
635 | 635 | |
636 | - $item = new GetPaid_Form_Item( $item->get_id() ); |
|
637 | - $item->set_quantity( floatval( $data['qty'] ) ); |
|
636 | + $item = new GetPaid_Form_Item($item->get_id()); |
|
637 | + $item->set_quantity(floatval($data['qty'])); |
|
638 | 638 | |
639 | 639 | // Add it to the invoice. |
640 | - $error = $invoice->add_item( $item ); |
|
640 | + $error = $invoice->add_item($item); |
|
641 | 641 | $alert = false; |
642 | 642 | |
643 | - if ( is_wp_error( $error ) ) { |
|
643 | + if (is_wp_error($error)) { |
|
644 | 644 | $alert = $error->get_error_message(); |
645 | - wp_send_json_success( compact( 'alert' ) ); |
|
645 | + wp_send_json_success(compact('alert')); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | // Update totals. |
@@ -655,9 +655,9 @@ discard block |
||
655 | 655 | $invoice->recalculate_total(); |
656 | 656 | $invoice->save(); |
657 | 657 | ob_start(); |
658 | - GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice ); |
|
658 | + GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice); |
|
659 | 659 | $row = ob_get_clean(); |
660 | - wp_send_json_success( compact( 'row' ) ); |
|
660 | + wp_send_json_success(compact('row')); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | /** |
@@ -666,33 +666,33 @@ discard block |
||
666 | 666 | public static function remove_invoice_item() { |
667 | 667 | |
668 | 668 | // Verify nonce. |
669 | - check_ajax_referer( 'wpinv-nonce' ); |
|
669 | + check_ajax_referer('wpinv-nonce'); |
|
670 | 670 | |
671 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
671 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
672 | 672 | exit; |
673 | 673 | } |
674 | 674 | |
675 | 675 | // We need an invoice and an item. |
676 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
676 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
677 | 677 | exit; |
678 | 678 | } |
679 | 679 | |
680 | 680 | // Fetch the invoice. |
681 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
681 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
682 | 682 | |
683 | 683 | // Ensure it exists and its not been paid for. |
684 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
684 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
685 | 685 | exit; |
686 | 686 | } |
687 | 687 | |
688 | 688 | // Abort if the invoice does not have the specified item. |
689 | - $item = $invoice->get_item( (int) $_POST['item_id'] ); |
|
689 | + $item = $invoice->get_item((int) $_POST['item_id']); |
|
690 | 690 | |
691 | - if ( empty( $item ) ) { |
|
691 | + if (empty($item)) { |
|
692 | 692 | exit; |
693 | 693 | } |
694 | 694 | |
695 | - $invoice->remove_item( (int) $_POST['item_id'] ); |
|
695 | + $invoice->remove_item((int) $_POST['item_id']); |
|
696 | 696 | |
697 | 697 | // Update totals. |
698 | 698 | $invoice->recalculate_total(); |
@@ -703,11 +703,11 @@ discard block |
||
703 | 703 | // Return an array of invoice items. |
704 | 704 | $items = array(); |
705 | 705 | |
706 | - foreach ( $invoice->get_items() as $item ) { |
|
707 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
706 | + foreach ($invoice->get_items() as $item) { |
|
707 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
708 | 708 | } |
709 | 709 | |
710 | - wp_send_json_success( compact( 'items' ) ); |
|
710 | + wp_send_json_success(compact('items')); |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | /** |
@@ -716,68 +716,68 @@ discard block |
||
716 | 716 | public static function recalculate_full_prices() { |
717 | 717 | |
718 | 718 | // Verify nonce. |
719 | - check_ajax_referer( 'wpinv-nonce' ); |
|
719 | + check_ajax_referer('wpinv-nonce'); |
|
720 | 720 | |
721 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
721 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
722 | 722 | exit; |
723 | 723 | } |
724 | 724 | |
725 | 725 | // We need an invoice and item. |
726 | - if ( empty( $_POST['post_id'] ) ) { |
|
726 | + if (empty($_POST['post_id'])) { |
|
727 | 727 | exit; |
728 | 728 | } |
729 | 729 | |
730 | 730 | // Fetch the invoice. |
731 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
731 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
732 | 732 | $alert = false; |
733 | 733 | |
734 | 734 | // Ensure it exists and its not been paid for. |
735 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
735 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
736 | 736 | exit; |
737 | 737 | } |
738 | 738 | |
739 | - $invoice->set_items( array() ); |
|
739 | + $invoice->set_items(array()); |
|
740 | 740 | |
741 | - if ( ! empty( $_POST['getpaid_items'] ) ) { |
|
741 | + if (!empty($_POST['getpaid_items'])) { |
|
742 | 742 | |
743 | - foreach ( wp_kses_post_deep( $_POST['getpaid_items'] ) as $item_id => $args ) { |
|
744 | - $item = new GetPaid_Form_Item( $item_id ); |
|
743 | + foreach (wp_kses_post_deep($_POST['getpaid_items']) as $item_id => $args) { |
|
744 | + $item = new GetPaid_Form_Item($item_id); |
|
745 | 745 | |
746 | - if ( $item->exists() ) { |
|
747 | - $item->set_price( getpaid_standardize_amount( $args['price'] ) ); |
|
748 | - $item->set_quantity( floatval( $args['quantity'] ) ); |
|
749 | - $item->set_name( sanitize_text_field( $args['name'] ) ); |
|
750 | - $item->set_description( wp_kses_post( $args['description'] ) ); |
|
751 | - $invoice->add_item( $item ); |
|
746 | + if ($item->exists()) { |
|
747 | + $item->set_price(getpaid_standardize_amount($args['price'])); |
|
748 | + $item->set_quantity(floatval($args['quantity'])); |
|
749 | + $item->set_name(sanitize_text_field($args['name'])); |
|
750 | + $item->set_description(wp_kses_post($args['description'])); |
|
751 | + $invoice->add_item($item); |
|
752 | 752 | } |
753 | 753 | } |
754 | 754 | } |
755 | 755 | |
756 | - $invoice->set_disable_taxes( ! empty( $_POST['disable_taxes'] ) ); |
|
756 | + $invoice->set_disable_taxes(!empty($_POST['disable_taxes'])); |
|
757 | 757 | |
758 | 758 | // Maybe set the country, state, currency. |
759 | - foreach ( array( 'wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code' ) as $key ) { |
|
760 | - if ( isset( $_POST[ $key ] ) ) { |
|
761 | - $_key = str_replace( 'wpinv_', '', $key ); |
|
759 | + foreach (array('wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code') as $key) { |
|
760 | + if (isset($_POST[$key])) { |
|
761 | + $_key = str_replace('wpinv_', '', $key); |
|
762 | 762 | $method = "set_$_key"; |
763 | - $invoice->$method( sanitize_text_field( $_POST[ $key ] ) ); |
|
763 | + $invoice->$method(sanitize_text_field($_POST[$key])); |
|
764 | 764 | } |
765 | 765 | } |
766 | 766 | |
767 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
768 | - if ( $discount->exists() ) { |
|
769 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
767 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
768 | + if ($discount->exists()) { |
|
769 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
770 | 770 | } else { |
771 | - $invoice->remove_discount( 'discount_code' ); |
|
771 | + $invoice->remove_discount('discount_code'); |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | // Save the invoice. |
775 | 775 | $invoice->recalculate_total(); |
776 | 776 | $invoice->save(); |
777 | 777 | ob_start(); |
778 | - GetPaid_Meta_Box_Invoice_Items::output( get_post( $invoice->get_id() ), $invoice ); |
|
778 | + GetPaid_Meta_Box_Invoice_Items::output(get_post($invoice->get_id()), $invoice); |
|
779 | 779 | $table = ob_get_clean(); |
780 | - wp_send_json_success( compact( 'table' ) ); |
|
780 | + wp_send_json_success(compact('table')); |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | /** |
@@ -786,42 +786,42 @@ discard block |
||
786 | 786 | public static function admin_add_invoice_item() { |
787 | 787 | |
788 | 788 | // Verify nonce. |
789 | - check_ajax_referer( 'wpinv-nonce' ); |
|
789 | + check_ajax_referer('wpinv-nonce'); |
|
790 | 790 | |
791 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
791 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
792 | 792 | exit; |
793 | 793 | } |
794 | 794 | |
795 | 795 | // We need an invoice and item. |
796 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
796 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
797 | 797 | exit; |
798 | 798 | } |
799 | 799 | |
800 | 800 | // Fetch the invoice. |
801 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
801 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
802 | 802 | $alert = false; |
803 | 803 | |
804 | 804 | // Ensure it exists and its not been paid for. |
805 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
805 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
806 | 806 | exit; |
807 | 807 | } |
808 | 808 | |
809 | 809 | // Add the item. |
810 | - $item = new GetPaid_Form_Item( (int) $_POST['item_id'] ); |
|
811 | - $error = $invoice->add_item( $item ); |
|
810 | + $item = new GetPaid_Form_Item((int) $_POST['item_id']); |
|
811 | + $error = $invoice->add_item($item); |
|
812 | 812 | |
813 | - if ( is_wp_error( $error ) ) { |
|
813 | + if (is_wp_error($error)) { |
|
814 | 814 | $alert = $error->get_error_message(); |
815 | - wp_send_json_success( compact( 'alert' ) ); |
|
815 | + wp_send_json_success(compact('alert')); |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | // Save the invoice. |
819 | 819 | $invoice->recalculate_total(); |
820 | 820 | $invoice->save(); |
821 | 821 | ob_start(); |
822 | - GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice ); |
|
822 | + GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice); |
|
823 | 823 | $row = ob_get_clean(); |
824 | - wp_send_json_success( compact( 'row' ) ); |
|
824 | + wp_send_json_success(compact('row')); |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | /** |
@@ -830,39 +830,39 @@ discard block |
||
830 | 830 | public static function add_invoice_items() { |
831 | 831 | |
832 | 832 | // Verify nonce. |
833 | - check_ajax_referer( 'wpinv-nonce' ); |
|
833 | + check_ajax_referer('wpinv-nonce'); |
|
834 | 834 | |
835 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
835 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
836 | 836 | exit; |
837 | 837 | } |
838 | 838 | |
839 | 839 | // We need an invoice and items. |
840 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) { |
|
840 | + if (empty($_POST['post_id']) || empty($_POST['items'])) { |
|
841 | 841 | exit; |
842 | 842 | } |
843 | 843 | |
844 | 844 | // Fetch the invoice. |
845 | - $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) ); |
|
845 | + $invoice = new WPInv_Invoice(intval($_POST['post_id'])); |
|
846 | 846 | $alert = false; |
847 | 847 | |
848 | 848 | // Ensure it exists and its not been paid for. |
849 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
849 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
850 | 850 | exit; |
851 | 851 | } |
852 | 852 | |
853 | 853 | // Add the items. |
854 | - foreach ( wp_kses_post_deep( wp_unslash( $_POST['items'] ) ) as $data ) { |
|
854 | + foreach (wp_kses_post_deep(wp_unslash($_POST['items'])) as $data) { |
|
855 | 855 | |
856 | - $item = new GetPaid_Form_Item( (int) $data['id'] ); |
|
856 | + $item = new GetPaid_Form_Item((int) $data['id']); |
|
857 | 857 | |
858 | - if ( is_numeric( $data['qty'] ) && (float) $data['qty'] > 0 ) { |
|
859 | - $item->set_quantity( floatval( $data['qty'] ) ); |
|
858 | + if (is_numeric($data['qty']) && (float) $data['qty'] > 0) { |
|
859 | + $item->set_quantity(floatval($data['qty'])); |
|
860 | 860 | } |
861 | 861 | |
862 | - if ( $item->get_id() > 0 ) { |
|
863 | - $error = $invoice->add_item( $item ); |
|
862 | + if ($item->get_id() > 0) { |
|
863 | + $error = $invoice->add_item($item); |
|
864 | 864 | |
865 | - if ( is_wp_error( $error ) ) { |
|
865 | + if (is_wp_error($error)) { |
|
866 | 866 | $alert = $error->get_error_message(); |
867 | 867 | } |
868 | 868 | } |
@@ -875,11 +875,11 @@ discard block |
||
875 | 875 | // Return an array of invoice items. |
876 | 876 | $items = array(); |
877 | 877 | |
878 | - foreach ( $invoice->get_items() as $item ) { |
|
879 | - $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
878 | + foreach ($invoice->get_items() as $item) { |
|
879 | + $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
880 | 880 | } |
881 | 881 | |
882 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
882 | + wp_send_json_success(compact('items', 'alert')); |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | /** |
@@ -888,15 +888,15 @@ discard block |
||
888 | 888 | public static function get_invoicing_items() { |
889 | 889 | |
890 | 890 | // Verify nonce. |
891 | - check_ajax_referer( 'wpinv-nonce' ); |
|
891 | + check_ajax_referer('wpinv-nonce'); |
|
892 | 892 | |
893 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
893 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
894 | 894 | exit; |
895 | 895 | } |
896 | 896 | |
897 | 897 | // We need a search term. |
898 | - if ( empty( $_GET['search'] ) ) { |
|
899 | - wp_send_json_success( array() ); |
|
898 | + if (empty($_GET['search'])) { |
|
899 | + wp_send_json_success(array()); |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | // Retrieve items. |
@@ -905,8 +905,8 @@ discard block |
||
905 | 905 | 'orderby' => 'title', |
906 | 906 | 'order' => 'ASC', |
907 | 907 | 'posts_per_page' => -1, |
908 | - 'post_status' => array( 'publish' ), |
|
909 | - 's' => sanitize_text_field( urldecode( $_GET['search'] ) ), |
|
908 | + 'post_status' => array('publish'), |
|
909 | + 's' => sanitize_text_field(urldecode($_GET['search'])), |
|
910 | 910 | 'meta_query' => array( |
911 | 911 | array( |
912 | 912 | 'key' => '_wpinv_type', |
@@ -916,25 +916,25 @@ discard block |
||
916 | 916 | ), |
917 | 917 | ); |
918 | 918 | |
919 | - if ( ! empty( $_GET['ignore'] ) ) { |
|
920 | - $item_args['exclude'] = wp_parse_id_list( sanitize_text_field( $_GET['ignore'] ) ); |
|
919 | + if (!empty($_GET['ignore'])) { |
|
920 | + $item_args['exclude'] = wp_parse_id_list(sanitize_text_field($_GET['ignore'])); |
|
921 | 921 | } |
922 | 922 | |
923 | - $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) ); |
|
923 | + $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args)); |
|
924 | 924 | $data = array(); |
925 | 925 | |
926 | - $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( (int) $_GET['post_id'] ) ); |
|
926 | + $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type((int) $_GET['post_id'])); |
|
927 | 927 | |
928 | - foreach ( $items as $item ) { |
|
929 | - $item = new GetPaid_Form_Item( $item ); |
|
928 | + foreach ($items as $item) { |
|
929 | + $item = new GetPaid_Form_Item($item); |
|
930 | 930 | $data[] = array( |
931 | 931 | 'id' => (int) $item->get_id(), |
932 | - 'text' => strip_tags( $item->get_name() ), |
|
933 | - 'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '', |
|
932 | + 'text' => strip_tags($item->get_name()), |
|
933 | + 'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '', |
|
934 | 934 | ); |
935 | 935 | } |
936 | 936 | |
937 | - wp_send_json_success( $data ); |
|
937 | + wp_send_json_success($data); |
|
938 | 938 | |
939 | 939 | } |
940 | 940 | |
@@ -944,37 +944,37 @@ discard block |
||
944 | 944 | public static function get_customers() { |
945 | 945 | |
946 | 946 | // Verify nonce. |
947 | - check_ajax_referer( 'wpinv-nonce' ); |
|
947 | + check_ajax_referer('wpinv-nonce'); |
|
948 | 948 | |
949 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
949 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
950 | 950 | exit; |
951 | 951 | } |
952 | 952 | |
953 | 953 | // We need a search term. |
954 | - if ( empty( $_GET['search'] ) ) { |
|
955 | - wp_send_json_success( array() ); |
|
954 | + if (empty($_GET['search'])) { |
|
955 | + wp_send_json_success(array()); |
|
956 | 956 | } |
957 | 957 | |
958 | 958 | // Retrieve customers. |
959 | 959 | |
960 | 960 | $customer_args = array( |
961 | - 'fields' => array( 'ID', 'user_email', 'display_name' ), |
|
961 | + 'fields' => array('ID', 'user_email', 'display_name'), |
|
962 | 962 | 'orderby' => 'display_name', |
963 | - 'search' => '*' . sanitize_text_field( $_GET['search'] ) . '*', |
|
964 | - 'search_columns' => array( 'user_login', 'user_email', 'display_name' ), |
|
963 | + 'search' => '*' . sanitize_text_field($_GET['search']) . '*', |
|
964 | + 'search_columns' => array('user_login', 'user_email', 'display_name'), |
|
965 | 965 | ); |
966 | 966 | |
967 | - $customers = get_users( apply_filters( 'getpaid_ajax_invoice_customers_query_args', $customer_args ) ); |
|
967 | + $customers = get_users(apply_filters('getpaid_ajax_invoice_customers_query_args', $customer_args)); |
|
968 | 968 | $data = array(); |
969 | 969 | |
970 | - foreach ( $customers as $customer ) { |
|
970 | + foreach ($customers as $customer) { |
|
971 | 971 | $data[] = array( |
972 | 972 | 'id' => (int) $customer->ID, |
973 | - 'text' => strip_tags( sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ) ), |
|
973 | + 'text' => strip_tags(sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email)), |
|
974 | 974 | ); |
975 | 975 | } |
976 | 976 | |
977 | - wp_send_json_success( $data ); |
|
977 | + wp_send_json_success($data); |
|
978 | 978 | |
979 | 979 | } |
980 | 980 | |
@@ -984,25 +984,25 @@ discard block |
||
984 | 984 | public static function get_aui_states_field() { |
985 | 985 | |
986 | 986 | // We need a country. |
987 | - if ( empty( $_GET['country'] ) ) { |
|
987 | + if (empty($_GET['country'])) { |
|
988 | 988 | exit; |
989 | 989 | } |
990 | 990 | |
991 | - $states = wpinv_get_country_states( sanitize_text_field( $_GET['country'] ) ); |
|
992 | - $state = isset( $_GET['state'] ) ? sanitize_text_field( $_GET['state'] ) : wpinv_get_default_state(); |
|
993 | - $name = isset( $_GET['name'] ) ? sanitize_text_field( $_GET['name'] ) : 'wpinv_state'; |
|
994 | - $class = isset( $_GET['class'] ) ? sanitize_text_field( $_GET['class'] ) : 'form-control-sm'; |
|
991 | + $states = wpinv_get_country_states(sanitize_text_field($_GET['country'])); |
|
992 | + $state = isset($_GET['state']) ? sanitize_text_field($_GET['state']) : wpinv_get_default_state(); |
|
993 | + $name = isset($_GET['name']) ? sanitize_text_field($_GET['name']) : 'wpinv_state'; |
|
994 | + $class = isset($_GET['class']) ? sanitize_text_field($_GET['class']) : 'form-control-sm'; |
|
995 | 995 | |
996 | - if ( empty( $states ) ) { |
|
996 | + if (empty($states)) { |
|
997 | 997 | |
998 | 998 | $html = aui()->input( |
999 | 999 | array( |
1000 | 1000 | 'type' => 'text', |
1001 | 1001 | 'id' => 'wpinv_state', |
1002 | 1002 | 'name' => $name, |
1003 | - 'label' => __( 'State', 'invoicing' ), |
|
1003 | + 'label' => __('State', 'invoicing'), |
|
1004 | 1004 | 'label_type' => 'vertical', |
1005 | - 'placeholder' => __( 'State', 'invoicing' ), |
|
1005 | + 'placeholder' => __('State', 'invoicing'), |
|
1006 | 1006 | 'class' => $class, |
1007 | 1007 | 'value' => $state, |
1008 | 1008 | ) |
@@ -1014,9 +1014,9 @@ discard block |
||
1014 | 1014 | array( |
1015 | 1015 | 'id' => 'wpinv_state', |
1016 | 1016 | 'name' => $name, |
1017 | - 'label' => __( 'State', 'invoicing' ), |
|
1017 | + 'label' => __('State', 'invoicing'), |
|
1018 | 1018 | 'label_type' => 'vertical', |
1019 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
1019 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
1020 | 1020 | 'class' => $class, |
1021 | 1021 | 'value' => $state, |
1022 | 1022 | 'options' => $states, |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | wp_send_json_success( |
1031 | 1031 | array( |
1032 | 1032 | 'html' => $html, |
1033 | - 'select' => ! empty( $states ), |
|
1033 | + 'select' => !empty($states), |
|
1034 | 1034 | ) |
1035 | 1035 | ); |
1036 | 1036 | |
@@ -1044,8 +1044,8 @@ discard block |
||
1044 | 1044 | public static function payment_form_refresh_prices() { |
1045 | 1045 | |
1046 | 1046 | // ... form fields... |
1047 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
1048 | - esc_html_e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
1047 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
1048 | + esc_html_e('Error: Reload the page and try again.', 'invoicing'); |
|
1049 | 1049 | exit; |
1050 | 1050 | } |
1051 | 1051 | |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | $submission = new GetPaid_Payment_Form_Submission(); |
1054 | 1054 | |
1055 | 1055 | // Do we have an error? |
1056 | - if ( ! empty( $submission->last_error ) ) { |
|
1056 | + if (!empty($submission->last_error)) { |
|
1057 | 1057 | wp_send_json_error( |
1058 | 1058 | array( |
1059 | 1059 | 'code' => $submission->last_error_code, |
@@ -1063,12 +1063,12 @@ discard block |
||
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | // Prepare the response. |
1066 | - $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission ); |
|
1066 | + $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission); |
|
1067 | 1067 | |
1068 | 1068 | // Filter the response. |
1069 | - $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission ); |
|
1069 | + $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission); |
|
1070 | 1070 | |
1071 | - wp_send_json_success( $response ); |
|
1071 | + wp_send_json_success($response); |
|
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | /** |
@@ -1080,63 +1080,63 @@ discard block |
||
1080 | 1080 | public static function file_upload() { |
1081 | 1081 | |
1082 | 1082 | // Check nonce. |
1083 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
1083 | + check_ajax_referer('getpaid_form_nonce'); |
|
1084 | 1084 | |
1085 | - if ( empty( $_POST['form_id'] ) || empty( $_POST['field_name'] ) || empty( $_FILES['file'] ) ) { |
|
1086 | - wp_die( esc_html_e( 'Bad Request', 'invoicing' ), 400 ); |
|
1085 | + if (empty($_POST['form_id']) || empty($_POST['field_name']) || empty($_FILES['file'])) { |
|
1086 | + wp_die(esc_html_e('Bad Request', 'invoicing'), 400); |
|
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | // Fetch form. |
1090 | - $form = new GetPaid_Payment_Form( intval( $_POST['form_id'] ) ); |
|
1090 | + $form = new GetPaid_Payment_Form(intval($_POST['form_id'])); |
|
1091 | 1091 | |
1092 | - if ( ! $form->is_active() ) { |
|
1093 | - wp_send_json_error( __( 'Payment form not active', 'invoicing' ) ); |
|
1092 | + if (!$form->is_active()) { |
|
1093 | + wp_send_json_error(__('Payment form not active', 'invoicing')); |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | // Fetch appropriate field. |
1097 | - $upload_field = current( wp_list_filter( $form->get_elements(), array( 'id' => sanitize_text_field( $_POST['field_name'] ) ) ) ); |
|
1098 | - if ( empty( $upload_field ) ) { |
|
1099 | - wp_send_json_error( __( 'Invalid upload field.', 'invoicing' ) ); |
|
1097 | + $upload_field = current(wp_list_filter($form->get_elements(), array('id' => sanitize_text_field($_POST['field_name'])))); |
|
1098 | + if (empty($upload_field)) { |
|
1099 | + wp_send_json_error(__('Invalid upload field.', 'invoicing')); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | // Prepare allowed file types. |
1103 | - $file_types = isset( $upload_field['file_types'] ) ? $upload_field['file_types'] : array( 'jpg|jpeg|jpe', 'gif', 'png' ); |
|
1103 | + $file_types = isset($upload_field['file_types']) ? $upload_field['file_types'] : array('jpg|jpeg|jpe', 'gif', 'png'); |
|
1104 | 1104 | $all_types = getpaid_get_allowed_mime_types(); |
1105 | 1105 | $mime_types = array(); |
1106 | 1106 | |
1107 | - foreach ( $file_types as $file_type ) { |
|
1108 | - if ( isset( $all_types[ $file_type ] ) ) { |
|
1109 | - $mime_types[] = $all_types[ $file_type ]; |
|
1107 | + foreach ($file_types as $file_type) { |
|
1108 | + if (isset($all_types[$file_type])) { |
|
1109 | + $mime_types[] = $all_types[$file_type]; |
|
1110 | 1110 | } |
1111 | 1111 | } |
1112 | 1112 | |
1113 | - if ( ! in_array( $_FILES['file']['type'], $mime_types ) ) { |
|
1114 | - wp_send_json_error( __( 'Unsupported file type.', 'invoicing' ) ); |
|
1113 | + if (!in_array($_FILES['file']['type'], $mime_types)) { |
|
1114 | + wp_send_json_error(__('Unsupported file type.', 'invoicing')); |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | // Upload file. |
1118 | - $file_name = explode( '.', strtolower( $_FILES['file']['name'] ) ); |
|
1119 | - $file_name = uniqid( 'getpaid-' ) . '.' . array_pop( $file_name ); |
|
1118 | + $file_name = explode('.', strtolower($_FILES['file']['name'])); |
|
1119 | + $file_name = uniqid('getpaid-') . '.' . array_pop($file_name); |
|
1120 | 1120 | |
1121 | 1121 | $uploaded = wp_upload_bits( |
1122 | 1122 | $file_name, |
1123 | 1123 | null, |
1124 | - file_get_contents( $_FILES['file']['tmp_name'] ) |
|
1124 | + file_get_contents($_FILES['file']['tmp_name']) |
|
1125 | 1125 | ); |
1126 | 1126 | |
1127 | - if ( ! empty( $uploaded['error'] ) ) { |
|
1128 | - wp_send_json_error( $uploaded['error'] ); |
|
1127 | + if (!empty($uploaded['error'])) { |
|
1128 | + wp_send_json_error($uploaded['error']); |
|
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | // Retrieve response. |
1132 | 1132 | $response = sprintf( |
1133 | 1133 | '<input type="hidden" name="%s[%s]" value="%s" />', |
1134 | - esc_attr( sanitize_text_field( $_POST['field_name'] ) ), |
|
1135 | - esc_url( $uploaded['url'] ), |
|
1136 | - esc_attr( sanitize_text_field( strtolower( $_FILES['file']['name'] ) ) ) |
|
1134 | + esc_attr(sanitize_text_field($_POST['field_name'])), |
|
1135 | + esc_url($uploaded['url']), |
|
1136 | + esc_attr(sanitize_text_field(strtolower($_FILES['file']['name']))) |
|
1137 | 1137 | ); |
1138 | 1138 | |
1139 | - wp_send_json_success( $response ); |
|
1139 | + wp_send_json_success($response); |
|
1140 | 1140 | |
1141 | 1141 | } |
1142 | 1142 |