@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Totals rows. |
13 | 13 | $cart_totals = apply_filters( |
14 | 14 | 'getpaid_payment_form_cart_table_totals', |
15 | 15 | array( |
16 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
17 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
18 | - 'fees' => __( 'Fee', 'invoicing' ), |
|
19 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
20 | - 'total' => __( 'Total', 'invoicing' ), |
|
16 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
17 | + 'tax' => __('Tax', 'invoicing'), |
|
18 | + 'fees' => __('Fee', 'invoicing'), |
|
19 | + 'discount' => __('Discount', 'invoicing'), |
|
20 | + 'total' => __('Total', 'invoicing'), |
|
21 | 21 | ), |
22 | 22 | $form |
23 | 23 | ); |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | $currency = $form->get_currency(); |
26 | 26 | $country = wpinv_get_default_country(); |
27 | 27 | |
28 | -if ( ! empty( $form->invoice ) ) { |
|
29 | - $country = $form->invoice->get_country(); |
|
28 | +if (!empty($form->invoice)) { |
|
29 | + $country = $form->invoice->get_country(); |
|
30 | 30 | } |
31 | 31 | |
32 | -if ( ! wpinv_use_taxes() && isset( $cart_totals['tax'] ) ) { |
|
33 | - unset( $cart_totals['tax'] ); |
|
32 | +if (!wpinv_use_taxes() && isset($cart_totals['tax'])) { |
|
33 | + unset($cart_totals['tax']); |
|
34 | 34 | } |
35 | 35 | |
36 | -do_action( 'getpaid_before_payment_form_cart_totals', $form, $cart_totals ); |
|
36 | +do_action('getpaid_before_payment_form_cart_totals', $form, $cart_totals); |
|
37 | 37 | |
38 | 38 | ?> |
39 | 39 | <style> |
@@ -47,26 +47,26 @@ discard block |
||
47 | 47 | <div class="row"> |
48 | 48 | <div class="col-12 offset-sm-6 col-sm-6 border-sm-left pl-sm-0"> |
49 | 49 | |
50 | - <?php foreach ( $cart_totals as $key => $label ) : ?> |
|
50 | + <?php foreach ($cart_totals as $key => $label) : ?> |
|
51 | 51 | |
52 | - <div class="getpaid-form-cart-totals-col getpaid-form-cart-totals-<?php echo esc_attr( $key ); ?> font-weight-bold py-2 px-3 <?php echo 'total' === $key ? 'bg-light' : 'border-bottom'; ?> <?php echo 'tax' === $key && wpinv_display_individual_tax_rates() ? 'getpaid-tax-template d-none' : ''; ?>"> |
|
52 | + <div class="getpaid-form-cart-totals-col getpaid-form-cart-totals-<?php echo esc_attr($key); ?> font-weight-bold py-2 px-3 <?php echo 'total' === $key ? 'bg-light' : 'border-bottom'; ?> <?php echo 'tax' === $key && wpinv_display_individual_tax_rates() ? 'getpaid-tax-template d-none' : ''; ?>"> |
|
53 | 53 | |
54 | 54 | <div class="form-row row"> |
55 | 55 | |
56 | 56 | <div class="col-8 pl-sm-0 getpaid-payment-form-line-totals-label"> |
57 | - <?php echo esc_html( $label ); ?> |
|
57 | + <?php echo esc_html($label); ?> |
|
58 | 58 | </div> |
59 | 59 | |
60 | - <div class="col-4 getpaid-payment-form-line-totals-value getpaid-form-cart-totals-total-<?php echo esc_attr( $key ); ?>"> |
|
60 | + <div class="col-4 getpaid-payment-form-line-totals-value getpaid-form-cart-totals-total-<?php echo esc_attr($key); ?>"> |
|
61 | 61 | |
62 | 62 | <?php |
63 | 63 | |
64 | 64 | // Total tax. |
65 | - if ( in_array( $key, array( 'tax', 'discount', 'subtotal', 'total', 'fees' ), true ) ) { |
|
66 | - wpinv_the_price( 0, $currency ); |
|
65 | + if (in_array($key, array('tax', 'discount', 'subtotal', 'total', 'fees'), true)) { |
|
66 | + wpinv_the_price(0, $currency); |
|
67 | 67 | } |
68 | 68 | |
69 | - do_action( "getpaid_payment_form_cart_totals_$key", $form ); |
|
69 | + do_action("getpaid_payment_form_cart_totals_$key", $form); |
|
70 | 70 | ?> |
71 | 71 | |
72 | 72 | </div> |
@@ -82,4 +82,4 @@ discard block |
||
82 | 82 | </div> |
83 | 83 | |
84 | 84 | <?php |
85 | -do_action( 'getpaid_payment_form_cart_totals', $form, $cart_totals ); |
|
85 | +do_action('getpaid_payment_form_cart_totals', $form, $cart_totals); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @var WPInv_Invoice $invoice |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | ?> |
14 | 14 | |
@@ -16,48 +16,48 @@ discard block |
||
16 | 16 | |
17 | 17 | <?php |
18 | 18 | |
19 | - $actions = array(); |
|
19 | + $actions = array(); |
|
20 | 20 | |
21 | 21 | echo sprintf( |
22 | 22 | '<a href="javascript:void(0)" class="btn btn-sm m-1 d-inline-block btn-secondary text-white invoice-action-print d-none d-lg-inline-block" onclick="window.print();">%s</a>', |
23 | 23 | sprintf( |
24 | - esc_html__( 'Print %s', 'invoicing' ), |
|
25 | - esc_html( ucfirst( $invoice->get_invoice_quote_type() ) ) |
|
24 | + esc_html__('Print %s', 'invoicing'), |
|
25 | + esc_html(ucfirst($invoice->get_invoice_quote_type())) |
|
26 | 26 | ) |
27 | 27 | ); |
28 | 28 | |
29 | - if ( is_user_logged_in() ) { |
|
29 | + if (is_user_logged_in()) { |
|
30 | 30 | |
31 | 31 | $actions[] = sprintf( |
32 | 32 | '<a href="%s" class="btn btn-sm btn-secondary text-white m-1 d-inline-block invoice-action-history">%s</a>', |
33 | - esc_url( wpinv_get_history_page_uri( $invoice->get_post_type() ) ), |
|
33 | + esc_url(wpinv_get_history_page_uri($invoice->get_post_type())), |
|
34 | 34 | sprintf( |
35 | - __( '%s History', 'invoicing' ), |
|
36 | - esc_html( ucfirst( $invoice->get_invoice_quote_type() ) ) |
|
35 | + __('%s History', 'invoicing'), |
|
36 | + esc_html(ucfirst($invoice->get_invoice_quote_type())) |
|
37 | 37 | ) |
38 | 38 | ); |
39 | 39 | |
40 | 40 | } |
41 | 41 | |
42 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
42 | + if (wpinv_current_user_can_manage_invoicing()) { |
|
43 | 43 | |
44 | 44 | $actions[] = sprintf( |
45 | 45 | '<a href="%s" class="btn btn-sm btn-secondary text-white m-1 d-inline-block invoice-action-edit">%s</a>', |
46 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
46 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
47 | 47 | sprintf( |
48 | - __( 'Edit %s', 'invoicing' ), |
|
49 | - esc_html( ucfirst( $invoice->get_invoice_quote_type() ) ) |
|
48 | + __('Edit %s', 'invoicing'), |
|
49 | + esc_html(ucfirst($invoice->get_invoice_quote_type())) |
|
50 | 50 | ) |
51 | 51 | ); |
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | - $actions = apply_filters( 'getpaid_invoice_header_right_actions_array', $actions, $invoice ); |
|
56 | - echo wp_kses_post( implode( '', $actions ) ); |
|
55 | + $actions = apply_filters('getpaid_invoice_header_right_actions_array', $actions, $invoice); |
|
56 | + echo wp_kses_post(implode('', $actions)); |
|
57 | 57 | |
58 | 58 | ?> |
59 | 59 | |
60 | - <?php do_action( 'wpinv_invoice_display_right_actions', $invoice ); ?> |
|
60 | + <?php do_action('wpinv_invoice_display_right_actions', $invoice); ?> |
|
61 | 61 | </div> |
62 | 62 | |
63 | 63 | <?php |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | <?php |
19 | 19 | |
20 | 20 | // Fires when printing the header. |
21 | - do_action( 'getpaid_invoice_header', $invoice ); |
|
21 | + do_action('getpaid_invoice_header', $invoice); |
|
22 | 22 | |
23 | 23 | // Print the opening wrapper. |
24 | 24 | echo '<div class="container bg-white getpaid-print-no-border border mt-4 mb-4 p-4 position-relative flex-grow-1">'; |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | wpinv_print_errors(); |
28 | 28 | |
29 | 29 | // Fires when printing the invoice details. |
30 | - do_action( 'getpaid_invoice_details', $invoice ); |
|
30 | + do_action('getpaid_invoice_details', $invoice); |
|
31 | 31 | |
32 | 32 | // Fires when printing the invoice line items. |
33 | - do_action( 'getpaid_invoice_line_items', $invoice ); |
|
33 | + do_action('getpaid_invoice_line_items', $invoice); |
|
34 | 34 | |
35 | 35 | // Print the closing wrapper. |
36 | 36 | echo '</div>'; |
37 | 37 | |
38 | 38 | // Fires when printing the invoice footer. |
39 | - do_action( 'getpaid_invoice_footer', $invoice ); |
|
39 | + do_action('getpaid_invoice_footer', $invoice); |
|
40 | 40 | |
41 | 41 | ?> |
42 | 42 |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @param null|string|array $query Optional. The query variables. |
99 | 99 | */ |
100 | - public function __construct( $query = null ) { |
|
101 | - if ( ! is_null( $query ) ) { |
|
102 | - $this->prepare_query( $query ); |
|
100 | + public function __construct($query = null) { |
|
101 | + if (!is_null($query)) { |
|
102 | + $this->prepare_query($query); |
|
103 | 103 | $this->query(); |
104 | 104 | } |
105 | 105 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param string|array $args Query vars, as passed to `GetPaid_Subscriptions_Query`. |
113 | 113 | * @return array Complete query variables with undefined ones filled in with defaults. |
114 | 114 | */ |
115 | - public static function fill_query_vars( $args ) { |
|
115 | + public static function fill_query_vars($args) { |
|
116 | 116 | $defaults = array( |
117 | 117 | 'include' => array(), |
118 | 118 | 'exclude' => array(), |
@@ -126,16 +126,16 @@ discard block |
||
126 | 126 | 's' => '', |
127 | 127 | ); |
128 | 128 | |
129 | - foreach ( GetPaid_Customer_Data_Store::get_database_fields() as $field => $type ) { |
|
130 | - $defaults[ $field ] = 'any'; |
|
129 | + foreach (GetPaid_Customer_Data_Store::get_database_fields() as $field => $type) { |
|
130 | + $defaults[$field] = 'any'; |
|
131 | 131 | |
132 | - if ( '%f' === $type || '%d' === $type ) { |
|
133 | - $defaults[ $field . '_min' ] = ''; |
|
134 | - $defaults[ $field . '_max' ] = ''; |
|
132 | + if ('%f' === $type || '%d' === $type) { |
|
133 | + $defaults[$field . '_min'] = ''; |
|
134 | + $defaults[$field . '_max'] = ''; |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | - return wp_parse_args( $args, $defaults ); |
|
138 | + return wp_parse_args($args, $defaults); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -145,45 +145,45 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @see self::fill_query_vars() For allowede args and their defaults. |
147 | 147 | */ |
148 | - public function prepare_query( $query = array() ) { |
|
148 | + public function prepare_query($query = array()) { |
|
149 | 149 | global $wpdb; |
150 | 150 | |
151 | - if ( empty( $this->query_vars ) || ! empty( $query ) ) { |
|
151 | + if (empty($this->query_vars) || !empty($query)) { |
|
152 | 152 | $this->query_limit = null; |
153 | - $this->query_vars = $this->fill_query_vars( $query ); |
|
153 | + $this->query_vars = $this->fill_query_vars($query); |
|
154 | 154 | } |
155 | 155 | |
156 | - if ( ! empty( $this->query_vars['fields'] ) && 'all' !== $this->query_vars['fields'] ) { |
|
157 | - $this->query_vars['fields'] = wpinv_parse_list( $this->query_vars['fields'] ); |
|
156 | + if (!empty($this->query_vars['fields']) && 'all' !== $this->query_vars['fields']) { |
|
157 | + $this->query_vars['fields'] = wpinv_parse_list($this->query_vars['fields']); |
|
158 | 158 | } |
159 | 159 | |
160 | - do_action( 'getpaid_pre_get_customers', array( &$this ) ); |
|
160 | + do_action('getpaid_pre_get_customers', array(&$this)); |
|
161 | 161 | |
162 | 162 | // Ensure that query vars are filled after 'getpaid_pre_get_customers'. |
163 | 163 | $qv = & $this->query_vars; |
164 | - $qv = $this->fill_query_vars( $qv ); |
|
164 | + $qv = $this->fill_query_vars($qv); |
|
165 | 165 | $table = $wpdb->prefix . 'getpaid_customers'; |
166 | 166 | $this->query_from = "FROM $table"; |
167 | 167 | |
168 | 168 | // Prepare query fields. |
169 | - $this->prepare_query_fields( $qv, $table ); |
|
169 | + $this->prepare_query_fields($qv, $table); |
|
170 | 170 | |
171 | 171 | // Prepare query where. |
172 | - $this->prepare_query_where( $qv, $table ); |
|
172 | + $this->prepare_query_where($qv, $table); |
|
173 | 173 | |
174 | 174 | // Prepare query order. |
175 | - $this->prepare_query_order( $qv, $table ); |
|
175 | + $this->prepare_query_order($qv, $table); |
|
176 | 176 | |
177 | 177 | // limit |
178 | - if ( isset( $qv['number'] ) && $qv['number'] > 0 ) { |
|
179 | - if ( $qv['offset'] ) { |
|
180 | - $this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['offset'], $qv['number'] ); |
|
178 | + if (isset($qv['number']) && $qv['number'] > 0) { |
|
179 | + if ($qv['offset']) { |
|
180 | + $this->query_limit = $wpdb->prepare('LIMIT %d, %d', $qv['offset'], $qv['number']); |
|
181 | 181 | } else { |
182 | - $this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] ); |
|
182 | + $this->query_limit = $wpdb->prepare('LIMIT %d, %d', $qv['number'] * ($qv['paged'] - 1), $qv['number']); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - do_action_ref_array( 'getpaid_after_customers_query', array( &$this ) ); |
|
186 | + do_action_ref_array('getpaid_after_customers_query', array(&$this)); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -194,27 +194,27 @@ discard block |
||
194 | 194 | * @param array $qv Query vars. |
195 | 195 | * @param string $table Table name. |
196 | 196 | */ |
197 | - protected function prepare_query_fields( &$qv, $table ) { |
|
197 | + protected function prepare_query_fields(&$qv, $table) { |
|
198 | 198 | |
199 | - if ( is_array( $qv['fields'] ) ) { |
|
200 | - $qv['fields'] = array_unique( $qv['fields'] ); |
|
201 | - $allowed_fields = array_keys( GetPaid_Customer_Data_Store::get_database_fields() ); |
|
199 | + if (is_array($qv['fields'])) { |
|
200 | + $qv['fields'] = array_unique($qv['fields']); |
|
201 | + $allowed_fields = array_keys(GetPaid_Customer_Data_Store::get_database_fields()); |
|
202 | 202 | |
203 | 203 | $query_fields = array(); |
204 | - foreach ( $qv['fields'] as $field ) { |
|
205 | - if ( ! in_array( $field, $allowed_fields ) ) { |
|
204 | + foreach ($qv['fields'] as $field) { |
|
205 | + if (!in_array($field, $allowed_fields)) { |
|
206 | 206 | continue; |
207 | 207 | } |
208 | 208 | |
209 | - $field = sanitize_key( $field ); |
|
209 | + $field = sanitize_key($field); |
|
210 | 210 | $query_fields[] = "$table.`$field`"; |
211 | 211 | } |
212 | - $this->query_fields = implode( ',', $query_fields ); |
|
212 | + $this->query_fields = implode(',', $query_fields); |
|
213 | 213 | } else { |
214 | 214 | $this->query_fields = "$table.*"; |
215 | 215 | } |
216 | 216 | |
217 | - if ( isset( $qv['count_total'] ) && $qv['count_total'] ) { |
|
217 | + if (isset($qv['count_total']) && $qv['count_total']) { |
|
218 | 218 | $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields; |
219 | 219 | } |
220 | 220 | |
@@ -228,55 +228,55 @@ discard block |
||
228 | 228 | * @param array $qv Query vars. |
229 | 229 | * @param string $table Table name. |
230 | 230 | */ |
231 | - protected function prepare_query_where( &$qv, $table ) { |
|
231 | + protected function prepare_query_where(&$qv, $table) { |
|
232 | 232 | global $wpdb; |
233 | 233 | $this->query_where = 'WHERE 1=1'; |
234 | 234 | |
235 | 235 | // Fields. |
236 | - foreach ( GetPaid_Customer_Data_Store::get_database_fields() as $field => $type ) { |
|
237 | - if ( 'any' !== $qv[ $field ] ) { |
|
236 | + foreach (GetPaid_Customer_Data_Store::get_database_fields() as $field => $type) { |
|
237 | + if ('any' !== $qv[$field]) { |
|
238 | 238 | |
239 | 239 | // In. |
240 | - if ( is_array( $qv[ $field ] ) ) { |
|
241 | - $in = join( ',', array_fill( 0, count( $qv[ $field ] ), $type ) ); |
|
242 | - $this->query_where .= $wpdb->prepare( " AND $table.`status` IN ( $in )", $qv[ $field ] ); |
|
243 | - } elseif ( ! empty( $qv[ $field ] ) ) { |
|
244 | - $this->query_where .= $wpdb->prepare( " AND $table.`$field` = $type", $qv[ $field ] ); |
|
240 | + if (is_array($qv[$field])) { |
|
241 | + $in = join(',', array_fill(0, count($qv[$field]), $type)); |
|
242 | + $this->query_where .= $wpdb->prepare(" AND $table.`status` IN ( $in )", $qv[$field]); |
|
243 | + } elseif (!empty($qv[$field])) { |
|
244 | + $this->query_where .= $wpdb->prepare(" AND $table.`$field` = $type", $qv[$field]); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Min/Max. |
249 | - if ( '%f' === $type || '%d' === $type ) { |
|
249 | + if ('%f' === $type || '%d' === $type) { |
|
250 | 250 | |
251 | 251 | // Min. |
252 | - if ( is_numeric( $qv[ $field . '_min' ] ) ) { |
|
253 | - $this->query_where .= $wpdb->prepare( " AND $table.`$field` >= $type", $qv[ $field . '_min' ] ); |
|
252 | + if (is_numeric($qv[$field . '_min'])) { |
|
253 | + $this->query_where .= $wpdb->prepare(" AND $table.`$field` >= $type", $qv[$field . '_min']); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | // Max. |
257 | - if ( is_numeric( $qv[ $field . '_max' ] ) ) { |
|
258 | - $this->query_where .= $wpdb->prepare( " AND $table.`$field` <= $type", $qv[ $field . '_max' ] ); |
|
257 | + if (is_numeric($qv[$field . '_max'])) { |
|
258 | + $this->query_where .= $wpdb->prepare(" AND $table.`$field` <= $type", $qv[$field . '_max']); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
263 | - if ( ! empty( $qv['include'] ) ) { |
|
264 | - $include = implode( ',', wp_parse_id_list( $qv['include'] ) ); |
|
263 | + if (!empty($qv['include'])) { |
|
264 | + $include = implode(',', wp_parse_id_list($qv['include'])); |
|
265 | 265 | $this->query_where .= " AND $table.`id` IN ($include)"; |
266 | - } elseif ( ! empty( $qv['exclude'] ) ) { |
|
267 | - $exclude = implode( ',', wp_parse_id_list( $qv['exclude'] ) ); |
|
266 | + } elseif (!empty($qv['exclude'])) { |
|
267 | + $exclude = implode(',', wp_parse_id_list($qv['exclude'])); |
|
268 | 268 | $this->query_where .= " AND $table.`id` NOT IN ($exclude)"; |
269 | 269 | } |
270 | 270 | |
271 | 271 | // Date queries are allowed for the customer creation date. |
272 | - if ( ! empty( $qv['date_created_query'] ) && is_array( $qv['date_created_query'] ) ) { |
|
273 | - $date_created_query = new WP_Date_Query( $qv['date_created_query'], "$table.date_created" ); |
|
272 | + if (!empty($qv['date_created_query']) && is_array($qv['date_created_query'])) { |
|
273 | + $date_created_query = new WP_Date_Query($qv['date_created_query'], "$table.date_created"); |
|
274 | 274 | $this->query_where .= $date_created_query->get_sql(); |
275 | 275 | } |
276 | 276 | |
277 | 277 | // Search. |
278 | - if ( ! empty( $qv['s'] ) ) { |
|
279 | - $this->query_where .= $this->get_search_sql( $qv['s'] ); |
|
278 | + if (!empty($qv['s'])) { |
|
279 | + $this->query_where .= $this->get_search_sql($qv['s']); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
@@ -290,22 +290,22 @@ discard block |
||
290 | 290 | * @param string $string The string to search for. |
291 | 291 | * @return string |
292 | 292 | */ |
293 | - protected function get_search_sql( $string ) { |
|
293 | + protected function get_search_sql($string) { |
|
294 | 294 | global $wpdb; |
295 | 295 | |
296 | 296 | $searches = array(); |
297 | - $string = trim( $string, '%' ); |
|
298 | - $like = '%' . $wpdb->esc_like( $string ) . '%'; |
|
297 | + $string = trim($string, '%'); |
|
298 | + $like = '%' . $wpdb->esc_like($string) . '%'; |
|
299 | 299 | |
300 | - foreach ( array_keys( GetPaid_Customer_Data_Store::get_database_fields() ) as $col ) { |
|
301 | - if ( 'id' === $col || 'user_id' === $col ) { |
|
302 | - $searches[] = $wpdb->prepare( "$col = %s", $string ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
|
300 | + foreach (array_keys(GetPaid_Customer_Data_Store::get_database_fields()) as $col) { |
|
301 | + if ('id' === $col || 'user_id' === $col) { |
|
302 | + $searches[] = $wpdb->prepare("$col = %s", $string); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
|
303 | 303 | } else { |
304 | - $searches[] = $wpdb->prepare( "$col LIKE %s", $like ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
|
304 | + $searches[] = $wpdb->prepare("$col LIKE %s", $like); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
|
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
308 | - return ' AND (' . implode( ' OR ', $searches ) . ')'; |
|
308 | + return ' AND (' . implode(' OR ', $searches) . ')'; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -316,24 +316,24 @@ discard block |
||
316 | 316 | * @param array $qv Query vars. |
317 | 317 | * @param string $table Table name. |
318 | 318 | */ |
319 | - protected function prepare_query_order( &$qv, $table ) { |
|
319 | + protected function prepare_query_order(&$qv, $table) { |
|
320 | 320 | |
321 | 321 | // sorting. |
322 | - $qv['order'] = isset( $qv['order'] ) ? strtoupper( $qv['order'] ) : ''; |
|
323 | - $order = $this->parse_order( $qv['order'] ); |
|
322 | + $qv['order'] = isset($qv['order']) ? strtoupper($qv['order']) : ''; |
|
323 | + $order = $this->parse_order($qv['order']); |
|
324 | 324 | |
325 | 325 | // Default order is by 'id' (latest customers). |
326 | - if ( empty( $qv['orderby'] ) ) { |
|
327 | - $qv['orderby'] = array( 'id' ); |
|
326 | + if (empty($qv['orderby'])) { |
|
327 | + $qv['orderby'] = array('id'); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | // 'orderby' values may be an array, comma- or space-separated list. |
331 | - $ordersby = array_filter( wpinv_parse_list( $qv['orderby'] ) ); |
|
331 | + $ordersby = array_filter(wpinv_parse_list($qv['orderby'])); |
|
332 | 332 | |
333 | 333 | $orderby_array = array(); |
334 | - foreach ( $ordersby as $_key => $_value ) { |
|
334 | + foreach ($ordersby as $_key => $_value) { |
|
335 | 335 | |
336 | - if ( is_int( $_key ) ) { |
|
336 | + if (is_int($_key)) { |
|
337 | 337 | // Integer key means this is a flat array of 'orderby' fields. |
338 | 338 | $_orderby = $_value; |
339 | 339 | $_order = $order; |
@@ -343,19 +343,19 @@ discard block |
||
343 | 343 | $_order = $_value; |
344 | 344 | } |
345 | 345 | |
346 | - $parsed = $this->parse_orderby( $_orderby, $table ); |
|
346 | + $parsed = $this->parse_orderby($_orderby, $table); |
|
347 | 347 | |
348 | - if ( $parsed ) { |
|
349 | - $orderby_array[] = $parsed . ' ' . $this->parse_order( $_order ); |
|
348 | + if ($parsed) { |
|
349 | + $orderby_array[] = $parsed . ' ' . $this->parse_order($_order); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
353 | 353 | // If no valid clauses were found, order by id. |
354 | - if ( empty( $orderby_array ) ) { |
|
354 | + if (empty($orderby_array)) { |
|
355 | 355 | $orderby_array[] = "id $order"; |
356 | 356 | } |
357 | 357 | |
358 | - $this->query_orderby = 'ORDER BY ' . implode( ', ', $orderby_array ); |
|
358 | + $this->query_orderby = 'ORDER BY ' . implode(', ', $orderby_array); |
|
359 | 359 | |
360 | 360 | } |
361 | 361 | |
@@ -369,33 +369,33 @@ discard block |
||
369 | 369 | public function query() { |
370 | 370 | global $wpdb; |
371 | 371 | |
372 | - $qv =& $this->query_vars; |
|
372 | + $qv = & $this->query_vars; |
|
373 | 373 | |
374 | 374 | // Return a non-null value to bypass the default GetPaid customers query and remember to set the |
375 | 375 | // total_customers property. |
376 | - $this->results = apply_filters_ref_array( 'getpaid_customers_pre_query', array( null, &$this ) ); |
|
376 | + $this->results = apply_filters_ref_array('getpaid_customers_pre_query', array(null, &$this)); |
|
377 | 377 | |
378 | - if ( null === $this->results ) { |
|
378 | + if (null === $this->results) { |
|
379 | 379 | $this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"; |
380 | 380 | |
381 | - if ( ( is_array( $qv['fields'] ) && 1 !== count( $qv['fields'] ) ) || 'all' === $qv['fields'] ) { |
|
382 | - $this->results = $wpdb->get_results( $this->request ); |
|
381 | + if ((is_array($qv['fields']) && 1 !== count($qv['fields'])) || 'all' === $qv['fields']) { |
|
382 | + $this->results = $wpdb->get_results($this->request); |
|
383 | 383 | } else { |
384 | - $this->results = $wpdb->get_col( $this->request ); |
|
384 | + $this->results = $wpdb->get_col($this->request); |
|
385 | 385 | } |
386 | 386 | |
387 | - if ( isset( $qv['count_total'] ) && $qv['count_total'] ) { |
|
388 | - $found_customers_query = apply_filters( 'getpaid_found_customers_query', 'SELECT FOUND_ROWS()', $this ); |
|
389 | - $this->total_customers = (int) $wpdb->get_var( $found_customers_query ); |
|
387 | + if (isset($qv['count_total']) && $qv['count_total']) { |
|
388 | + $found_customers_query = apply_filters('getpaid_found_customers_query', 'SELECT FOUND_ROWS()', $this); |
|
389 | + $this->total_customers = (int) $wpdb->get_var($found_customers_query); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
393 | - if ( 'all' === $qv['fields'] ) { |
|
394 | - foreach ( $this->results as $key => $customer ) { |
|
395 | - $this->set_cache( $customer->id, $customer, 'getpaid_customers' ); |
|
396 | - $this->set_cache( $customer->user_id, $customer->id, 'getpaid_customer_ids_by_user_id' ); |
|
397 | - $this->set_cache( $customer->email, $customer->id, 'getpaid_customer_ids_by_email' ); |
|
398 | - $this->results[ $key ] = new GetPaid_Customer( $customer ); |
|
393 | + if ('all' === $qv['fields']) { |
|
394 | + foreach ($this->results as $key => $customer) { |
|
395 | + $this->set_cache($customer->id, $customer, 'getpaid_customers'); |
|
396 | + $this->set_cache($customer->user_id, $customer->id, 'getpaid_customer_ids_by_user_id'); |
|
397 | + $this->set_cache($customer->email, $customer->id, 'getpaid_customer_ids_by_email'); |
|
398 | + $this->results[$key] = new GetPaid_Customer($customer); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
@@ -410,13 +410,13 @@ discard block |
||
410 | 410 | * @param integer $expire |
411 | 411 | * @return boolean |
412 | 412 | */ |
413 | - public function set_cache( $key, $data, $group = '', $expire = 0 ) { |
|
413 | + public function set_cache($key, $data, $group = '', $expire = 0) { |
|
414 | 414 | |
415 | - if ( empty( $key ) ) { |
|
415 | + if (empty($key)) { |
|
416 | 416 | return false; |
417 | 417 | } |
418 | 418 | |
419 | - wp_cache_set( $key, $data, $group, $expire ); |
|
419 | + wp_cache_set($key, $data, $group, $expire); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
@@ -427,9 +427,9 @@ discard block |
||
427 | 427 | * @param string $query_var Query variable key. |
428 | 428 | * @return mixed |
429 | 429 | */ |
430 | - public function get( $query_var ) { |
|
431 | - if ( isset( $this->query_vars[ $query_var ] ) ) { |
|
432 | - return $this->query_vars[ $query_var ]; |
|
430 | + public function get($query_var) { |
|
431 | + if (isset($this->query_vars[$query_var])) { |
|
432 | + return $this->query_vars[$query_var]; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | return null; |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * @param string $query_var Query variable key. |
444 | 444 | * @param mixed $value Query variable value. |
445 | 445 | */ |
446 | - public function set( $query_var, $value ) { |
|
447 | - $this->query_vars[ $query_var ] = $value; |
|
446 | + public function set($query_var, $value) { |
|
447 | + $this->query_vars[$query_var] = $value; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -478,16 +478,16 @@ discard block |
||
478 | 478 | * @param string $table The current table. |
479 | 479 | * @return string Value to use in the ORDER clause, if `$orderby` is valid. |
480 | 480 | */ |
481 | - protected function parse_orderby( $orderby, $table ) { |
|
481 | + protected function parse_orderby($orderby, $table) { |
|
482 | 482 | |
483 | 483 | $_orderby = ''; |
484 | - if ( in_array( $orderby, array_keys( GetPaid_Customer_Data_Store::get_database_fields() ), true ) ) { |
|
484 | + if (in_array($orderby, array_keys(GetPaid_Customer_Data_Store::get_database_fields()), true)) { |
|
485 | 485 | $_orderby = "$table.`$orderby`"; |
486 | - } elseif ( 'id' === strtolower( $orderby ) ) { |
|
486 | + } elseif ('id' === strtolower($orderby)) { |
|
487 | 487 | $_orderby = "$table.id"; |
488 | - } elseif ( 'include' === $orderby && ! empty( $this->query_vars['include'] ) ) { |
|
489 | - $include = wp_parse_id_list( $this->query_vars['include'] ); |
|
490 | - $include_sql = implode( ',', $include ); |
|
488 | + } elseif ('include' === $orderby && !empty($this->query_vars['include'])) { |
|
489 | + $include = wp_parse_id_list($this->query_vars['include']); |
|
490 | + $include_sql = implode(',', $include); |
|
491 | 491 | $_orderby = "FIELD( $table.id, $include_sql )"; |
492 | 492 | } |
493 | 493 | |
@@ -502,12 +502,12 @@ discard block |
||
502 | 502 | * @param string $order The 'order' query variable. |
503 | 503 | * @return string The sanitized 'order' query variable. |
504 | 504 | */ |
505 | - protected function parse_order( $order ) { |
|
506 | - if ( ! is_string( $order ) || empty( $order ) ) { |
|
505 | + protected function parse_order($order) { |
|
506 | + if (!is_string($order) || empty($order)) { |
|
507 | 507 | return 'DESC'; |
508 | 508 | } |
509 | 509 | |
510 | - if ( 'ASC' === strtoupper( $order ) ) { |
|
510 | + if ('ASC' === strtoupper($order)) { |
|
511 | 511 | return 'ASC'; |
512 | 512 | } else { |
513 | 513 | return 'DESC'; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 2.0.2 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * The main installer/updater class. |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @param string $upgrade_from The current invoicing version. |
27 | 27 | */ |
28 | - public function upgrade_db( $upgrade_from ) { |
|
28 | + public function upgrade_db($upgrade_from) { |
|
29 | 29 | |
30 | 30 | // Save the current invoicing version. |
31 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
31 | + update_option('wpinv_version', WPINV_VERSION); |
|
32 | 32 | |
33 | 33 | // Setup the invoice Custom Post Type. |
34 | 34 | GetPaid_Post_Types::register_post_types(); |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | // Create any missing database tables. |
49 | 49 | $method = "upgrade_from_$upgrade_from"; |
50 | 50 | |
51 | - $installed = get_option( 'gepaid_installed_on' ); |
|
51 | + $installed = get_option('gepaid_installed_on'); |
|
52 | 52 | |
53 | - if ( empty( $installed ) ) { |
|
54 | - update_option( 'gepaid_installed_on', time() ); |
|
53 | + if (empty($installed)) { |
|
54 | + update_option('gepaid_installed_on', time()); |
|
55 | 55 | } |
56 | 56 | |
57 | - if ( method_exists( $this, $method ) ) { |
|
57 | + if (method_exists($this, $method)) { |
|
58 | 58 | $this->$method(); |
59 | 59 | } |
60 | 60 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function upgrade_from_0() { |
68 | 68 | |
69 | 69 | // Save default tax rates. |
70 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
70 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -78,27 +78,27 @@ discard block |
||
78 | 78 | global $wpdb; |
79 | 79 | |
80 | 80 | // Invoices. |
81 | - $results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
82 | - if ( ! empty( $results ) ) { |
|
83 | - $wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
81 | + $results = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
82 | + if (!empty($results)) { |
|
83 | + $wpdb->query("UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
84 | 84 | |
85 | 85 | // Clean post cache |
86 | - foreach ( $results as $row ) { |
|
87 | - clean_post_cache( $row->ID ); |
|
86 | + foreach ($results as $row) { |
|
87 | + clean_post_cache($row->ID); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | 91 | // Item meta key changes |
92 | 92 | $query = 'SELECT DISTINCT post_id FROM ' . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )"; |
93 | - $results = $wpdb->get_results( $query ); |
|
93 | + $results = $wpdb->get_results($query); |
|
94 | 94 | |
95 | - if ( ! empty( $results ) ) { |
|
96 | - $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
97 | - $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
98 | - $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
95 | + if (!empty($results)) { |
|
96 | + $wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )"); |
|
97 | + $wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'"); |
|
98 | + $wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'"); |
|
99 | 99 | |
100 | - foreach ( $results as $row ) { |
|
101 | - clean_post_cache( $row->post_id ); |
|
100 | + foreach ($results as $row) { |
|
101 | + clean_post_cache($row->post_id); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * |
128 | 128 | */ |
129 | 129 | public function add_capabilities() { |
130 | - $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' ); |
|
130 | + $GLOBALS['wp_roles']->add_cap('administrator', 'manage_invoicing'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | |
143 | 143 | // Checkout page. |
144 | 144 | 'checkout_page' => array( |
145 | - 'name' => _x( 'gp-checkout', 'Page slug', 'invoicing' ), |
|
146 | - 'title' => _x( 'Checkout', 'Page title', 'invoicing' ), |
|
145 | + 'name' => _x('gp-checkout', 'Page slug', 'invoicing'), |
|
146 | + 'title' => _x('Checkout', 'Page title', 'invoicing'), |
|
147 | 147 | 'content' => ' |
148 | 148 | <!-- wp:shortcode --> |
149 | 149 | [wpinv_checkout] |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | |
155 | 155 | // Invoice history page. |
156 | 156 | 'invoice_history_page' => array( |
157 | - 'name' => _x( 'gp-invoices', 'Page slug', 'invoicing' ), |
|
158 | - 'title' => _x( 'My Invoices', 'Page title', 'invoicing' ), |
|
157 | + 'name' => _x('gp-invoices', 'Page slug', 'invoicing'), |
|
158 | + 'title' => _x('My Invoices', 'Page title', 'invoicing'), |
|
159 | 159 | 'content' => ' |
160 | 160 | <!-- wp:shortcode --> |
161 | 161 | [wpinv_history] |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | |
167 | 167 | // Success page content. |
168 | 168 | 'success_page' => array( |
169 | - 'name' => _x( 'gp-receipt', 'Page slug', 'invoicing' ), |
|
170 | - 'title' => _x( 'Payment Confirmation', 'Page title', 'invoicing' ), |
|
169 | + 'name' => _x('gp-receipt', 'Page slug', 'invoicing'), |
|
170 | + 'title' => _x('Payment Confirmation', 'Page title', 'invoicing'), |
|
171 | 171 | 'content' => ' |
172 | 172 | <!-- wp:shortcode --> |
173 | 173 | [wpinv_receipt] |
@@ -178,16 +178,16 @@ discard block |
||
178 | 178 | |
179 | 179 | // Failure page content. |
180 | 180 | 'failure_page' => array( |
181 | - 'name' => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ), |
|
182 | - 'title' => _x( 'Transaction Failed', 'Page title', 'invoicing' ), |
|
183 | - 'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ), |
|
181 | + 'name' => _x('gp-transaction-failed', 'Page slug', 'invoicing'), |
|
182 | + 'title' => _x('Transaction Failed', 'Page title', 'invoicing'), |
|
183 | + 'content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'), |
|
184 | 184 | 'parent' => 'gp-checkout', |
185 | 185 | ), |
186 | 186 | |
187 | 187 | // Subscriptions history page. |
188 | 188 | 'invoice_subscription_page' => array( |
189 | - 'name' => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ), |
|
190 | - 'title' => _x( 'My Subscriptions', 'Page title', 'invoicing' ), |
|
189 | + 'name' => _x('gp-subscriptions', 'Page slug', 'invoicing'), |
|
190 | + 'title' => _x('My Subscriptions', 'Page title', 'invoicing'), |
|
191 | 191 | 'content' => ' |
192 | 192 | <!-- wp:shortcode --> |
193 | 193 | [wpinv_subscriptions] |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function create_pages() { |
209 | 209 | |
210 | - foreach ( self::get_pages() as $key => $page ) { |
|
211 | - wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] ); |
|
210 | + foreach (self::get_pages() as $key => $page) { |
|
211 | + wpinv_create_page(esc_sql($page['name']), $key, $page['title'], $page['content'], $page['parent']); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | } |
@@ -222,32 +222,32 @@ discard block |
||
222 | 222 | |
223 | 223 | $invoices_table = $wpdb->prefix . 'getpaid_invoices'; |
224 | 224 | $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items'; |
225 | - $migrated = $wpdb->get_col( "SELECT post_id FROM $invoices_table" ); |
|
225 | + $migrated = $wpdb->get_col("SELECT post_id FROM $invoices_table"); |
|
226 | 226 | $invoices = array_unique( |
227 | 227 | get_posts( |
228 | 228 | array( |
229 | - 'post_type' => array( 'wpi_invoice', 'wpi_quote' ), |
|
229 | + 'post_type' => array('wpi_invoice', 'wpi_quote'), |
|
230 | 230 | 'posts_per_page' => -1, |
231 | 231 | 'fields' => 'ids', |
232 | - 'post_status' => array_keys( get_post_stati() ), |
|
232 | + 'post_status' => array_keys(get_post_stati()), |
|
233 | 233 | 'exclude' => (array) $migrated, |
234 | 234 | ) |
235 | 235 | ) |
236 | 236 | ); |
237 | 237 | |
238 | 238 | // Abort if we do not have any invoices. |
239 | - if ( empty( $invoices ) ) { |
|
239 | + if (empty($invoices)) { |
|
240 | 240 | return; |
241 | 241 | } |
242 | 242 | |
243 | 243 | require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php'; |
244 | 244 | |
245 | 245 | $invoice_rows = array(); |
246 | - foreach ( $invoices as $invoice ) { |
|
246 | + foreach ($invoices as $invoice) { |
|
247 | 247 | |
248 | - $invoice = new WPInv_Legacy_Invoice( $invoice ); |
|
248 | + $invoice = new WPInv_Legacy_Invoice($invoice); |
|
249 | 249 | |
250 | - if ( empty( $invoice->ID ) ) { |
|
250 | + if (empty($invoice->ID)) { |
|
251 | 251 | return; |
252 | 252 | } |
253 | 253 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | 'post_id' => $invoice->ID, |
256 | 256 | 'number' => $invoice->get_number(), |
257 | 257 | 'key' => $invoice->get_key(), |
258 | - 'type' => str_replace( 'wpi_', '', $invoice->post_type ), |
|
258 | + 'type' => str_replace('wpi_', '', $invoice->post_type), |
|
259 | 259 | 'mode' => $invoice->mode, |
260 | 260 | 'user_ip' => $invoice->get_ip(), |
261 | 261 | 'first_name' => $invoice->get_first_name(), |
@@ -284,27 +284,27 @@ discard block |
||
284 | 284 | 'custom_meta' => $invoice->payment_meta, |
285 | 285 | ); |
286 | 286 | |
287 | - foreach ( $fields as $key => $val ) { |
|
288 | - if ( is_null( $val ) ) { |
|
287 | + foreach ($fields as $key => $val) { |
|
288 | + if (is_null($val)) { |
|
289 | 289 | $val = ''; |
290 | 290 | } |
291 | - $val = maybe_serialize( $val ); |
|
292 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
291 | + $val = maybe_serialize($val); |
|
292 | + $fields[$key] = $wpdb->prepare('%s', $val); |
|
293 | 293 | } |
294 | 294 | |
295 | - $fields = implode( ', ', $fields ); |
|
295 | + $fields = implode(', ', $fields); |
|
296 | 296 | $invoice_rows[] = "($fields)"; |
297 | 297 | |
298 | 298 | $item_rows = array(); |
299 | 299 | $item_columns = array(); |
300 | - foreach ( $invoice->get_cart_details() as $details ) { |
|
300 | + foreach ($invoice->get_cart_details() as $details) { |
|
301 | 301 | $fields = array( |
302 | 302 | 'post_id' => $invoice->ID, |
303 | 303 | 'item_id' => $details['id'], |
304 | 304 | 'item_name' => $details['name'], |
305 | - 'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'], |
|
305 | + 'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'], |
|
306 | 306 | 'vat_rate' => $details['vat_rate'], |
307 | - 'vat_class' => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'], |
|
307 | + 'vat_class' => empty($details['vat_class']) ? '_standard' : $details['vat_class'], |
|
308 | 308 | 'tax' => $details['tax'], |
309 | 309 | 'item_price' => $details['item_price'], |
310 | 310 | 'custom_price' => $details['custom_price'], |
@@ -316,31 +316,31 @@ discard block |
||
316 | 316 | 'fees' => $details['fees'], |
317 | 317 | ); |
318 | 318 | |
319 | - $item_columns = array_keys( $fields ); |
|
319 | + $item_columns = array_keys($fields); |
|
320 | 320 | |
321 | - foreach ( $fields as $key => $val ) { |
|
322 | - if ( is_null( $val ) ) { |
|
321 | + foreach ($fields as $key => $val) { |
|
322 | + if (is_null($val)) { |
|
323 | 323 | $val = ''; |
324 | 324 | } |
325 | - $val = maybe_serialize( $val ); |
|
326 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
325 | + $val = maybe_serialize($val); |
|
326 | + $fields[$key] = $wpdb->prepare('%s', $val); |
|
327 | 327 | } |
328 | 328 | |
329 | - $fields = implode( ', ', $fields ); |
|
329 | + $fields = implode(', ', $fields); |
|
330 | 330 | $item_rows[] = "($fields)"; |
331 | 331 | } |
332 | 332 | |
333 | - $item_rows = implode( ', ', $item_rows ); |
|
334 | - $item_columns = implode( ', ', $item_columns ); |
|
335 | - $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" ); |
|
333 | + $item_rows = implode(', ', $item_rows); |
|
334 | + $item_columns = implode(', ', $item_columns); |
|
335 | + $wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows"); |
|
336 | 336 | } |
337 | 337 | |
338 | - if ( empty( $invoice_rows ) ) { |
|
338 | + if (empty($invoice_rows)) { |
|
339 | 339 | return; |
340 | 340 | } |
341 | 341 | |
342 | - $invoice_rows = implode( ', ', $invoice_rows ); |
|
343 | - $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" ); |
|
342 | + $invoice_rows = implode(', ', $invoice_rows); |
|
343 | + $wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows"); |
|
344 | 344 | |
345 | 345 | } |
346 | 346 | |
@@ -352,32 +352,32 @@ discard block |
||
352 | 352 | global $wpdb; |
353 | 353 | |
354 | 354 | // Fetch post_id from $wpdb->prefix . 'getpaid_invoices' where customer_id = 0 or null. |
355 | - $invoice_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->prefix}getpaid_invoices WHERE customer_id = 0 OR customer_id IS NULL" ); |
|
355 | + $invoice_ids = $wpdb->get_col("SELECT post_id FROM {$wpdb->prefix}getpaid_invoices WHERE customer_id = 0 OR customer_id IS NULL"); |
|
356 | 356 | |
357 | - foreach ( $invoice_ids as $invoice_id ) { |
|
358 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
357 | + foreach ($invoice_ids as $invoice_id) { |
|
358 | + $invoice = wpinv_get_invoice($invoice_id); |
|
359 | 359 | |
360 | - if ( empty( $invoice ) ) { |
|
360 | + if (empty($invoice)) { |
|
361 | 361 | continue; |
362 | 362 | } |
363 | 363 | |
364 | 364 | // Fetch customer from the user ID. |
365 | 365 | $user_id = $invoice->get_user_id(); |
366 | 366 | |
367 | - if ( empty( $user_id ) ) { |
|
367 | + if (empty($user_id)) { |
|
368 | 368 | continue; |
369 | 369 | } |
370 | 370 | |
371 | - $customer = getpaid_get_customer_by_user_id( $user_id ); |
|
371 | + $customer = getpaid_get_customer_by_user_id($user_id); |
|
372 | 372 | |
373 | 373 | // Create if not exists. |
374 | - if ( empty( $customer ) ) { |
|
375 | - $customer = new GetPaid_Customer( 0 ); |
|
376 | - $customer->clone_user( $user_id ); |
|
374 | + if (empty($customer)) { |
|
375 | + $customer = new GetPaid_Customer(0); |
|
376 | + $customer->clone_user($user_id); |
|
377 | 377 | $customer->save(); |
378 | 378 | } |
379 | 379 | |
380 | - $invoice->set_customer_id( $customer->get_id() ); |
|
380 | + $invoice->set_customer_id($customer->get_id()); |
|
381 | 381 | $invoice->save(); |
382 | 382 | } |
383 | 383 | |
@@ -390,12 +390,12 @@ discard block |
||
390 | 390 | public static function rename_gateways_label() { |
391 | 391 | global $wpdb; |
392 | 392 | |
393 | - foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) { |
|
393 | + foreach (array_keys(wpinv_get_payment_gateways()) as $gateway) { |
|
394 | 394 | |
395 | 395 | $wpdb->update( |
396 | 396 | $wpdb->prefix . 'getpaid_invoices', |
397 | - array( 'gateway' => $gateway ), |
|
398 | - array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ), |
|
397 | + array('gateway' => $gateway), |
|
398 | + array('gateway' => wpinv_get_gateway_admin_label($gateway)), |
|
399 | 399 | '%s', |
400 | 400 | '%s' |
401 | 401 | ); |
@@ -511,29 +511,29 @@ discard block |
||
511 | 511 | "; |
512 | 512 | |
513 | 513 | // Add address fields. |
514 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
514 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
515 | 515 | // Skip id, user_id and email. |
516 | - if ( in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) { |
|
516 | + if (in_array($field, array('id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid'), true)) { |
|
517 | 517 | continue; |
518 | 518 | } |
519 | 519 | |
520 | - $field = sanitize_key( $field ); |
|
520 | + $field = sanitize_key($field); |
|
521 | 521 | $length = 100; |
522 | 522 | $default = ''; |
523 | 523 | |
524 | 524 | // Country. |
525 | - if ( 'country' === $field ) { |
|
525 | + if ('country' === $field) { |
|
526 | 526 | $length = 2; |
527 | 527 | $default = wpinv_get_default_country(); |
528 | 528 | } |
529 | 529 | |
530 | 530 | // State. |
531 | - if ( 'state' === $field ) { |
|
531 | + if ('state' === $field) { |
|
532 | 532 | $default = wpinv_get_default_state(); |
533 | 533 | } |
534 | 534 | |
535 | 535 | // Phone, zip. |
536 | - if ( in_array( $field, array( 'phone', 'zip' ), true ) ) { |
|
536 | + if (in_array($field, array('phone', 'zip'), true)) { |
|
537 | 537 | $length = 20; |
538 | 538 | } |
539 | 539 | |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | * @return bool |
570 | 570 | */ |
571 | 571 | public static function is_db_schema_up_to_date() { |
572 | - return md5( self::get_db_schema() ) === get_option( 'getpaid_db_schema' ); |
|
572 | + return md5(self::get_db_schema()) === get_option('getpaid_db_schema'); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -587,27 +587,27 @@ discard block |
||
587 | 587 | // If invoices table exists, rename key to invoice_key. |
588 | 588 | $invoices_table = "{$wpdb->prefix}getpaid_invoices"; |
589 | 589 | |
590 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) === $invoices_table ) { |
|
591 | - $fields = $wpdb->get_results( "SHOW COLUMNS FROM {$wpdb->prefix}getpaid_invoices" ); |
|
590 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") === $invoices_table) { |
|
591 | + $fields = $wpdb->get_results("SHOW COLUMNS FROM {$wpdb->prefix}getpaid_invoices"); |
|
592 | 592 | |
593 | - foreach ( $fields as $field ) { |
|
594 | - if ( 'key' === $field->Field ) { |
|
595 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoices CHANGE `key` `invoice_key` VARCHAR(100)" ); |
|
593 | + foreach ($fields as $field) { |
|
594 | + if ('key' === $field->Field) { |
|
595 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoices CHANGE `key` `invoice_key` VARCHAR(100)"); |
|
596 | 596 | break; |
597 | 597 | } |
598 | 598 | } |
599 | 599 | } |
600 | 600 | |
601 | - dbDelta( $schema ); |
|
601 | + dbDelta($schema); |
|
602 | 602 | wp_cache_flush(); |
603 | - update_option( 'getpaid_db_schema', md5( $schema ) ); |
|
603 | + update_option('getpaid_db_schema', md5($schema)); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | /** |
607 | 607 | * Creates tables if schema is not up to date. |
608 | 608 | */ |
609 | 609 | public static function maybe_create_db_tables() { |
610 | - if ( ! self::is_db_schema_up_to_date() ) { |
|
610 | + if (!self::is_db_schema_up_to_date()) { |
|
611 | 611 | self::create_db_tables(); |
612 | 612 | } |
613 | 613 | } |
@@ -5,12 +5,12 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | // Exit if accessed directly |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if (!defined('ABSPATH')) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | 11 | |
12 | 12 | // Load WP_List_Table if not loaded |
13 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
13 | +if (!class_exists('WP_List_Table')) { |
|
14 | 14 | require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
15 | 15 | } |
16 | 16 | |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return string Column Name |
80 | 80 | */ |
81 | - public function column_default( $customer, $column_name ) { |
|
82 | - $value = esc_html( $customer->get( $column_name ) ); |
|
83 | - return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $customer ); |
|
81 | + public function column_default($customer, $column_name) { |
|
82 | + $value = esc_html($customer->get($column_name)); |
|
83 | + return apply_filters('wpinv_customers_table_column' . $column_name, $value, $customer); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return string Column Name |
94 | 94 | */ |
95 | - public function column_country( $customer ) { |
|
96 | - $country = wpinv_sanitize_country( $customer->get( 'country' ) ); |
|
97 | - if ( $country ) { |
|
98 | - $country = wpinv_country_name( $country ); |
|
95 | + public function column_country($customer) { |
|
96 | + $country = wpinv_sanitize_country($customer->get('country')); |
|
97 | + if ($country) { |
|
98 | + $country = wpinv_country_name($country); |
|
99 | 99 | } |
100 | - return esc_html( $country ); |
|
100 | + return esc_html($country); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return string Column Name |
111 | 111 | */ |
112 | - public function column_state( $customer ) { |
|
113 | - $country = wpinv_sanitize_country( $customer->get( 'country' ) ); |
|
114 | - $state = $customer->get( 'state' ); |
|
115 | - if ( $state ) { |
|
116 | - $state = wpinv_state_name( $state, $country ); |
|
112 | + public function column_state($customer) { |
|
113 | + $country = wpinv_sanitize_country($customer->get('country')); |
|
114 | + $state = $customer->get('state'); |
|
115 | + if ($state) { |
|
116 | + $state = wpinv_state_name($state, $country); |
|
117 | 117 | } |
118 | 118 | |
119 | - return esc_html( $state ); |
|
119 | + return esc_html($state); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return string Column Name |
130 | 130 | */ |
131 | - public function column_date_created( $customer ) { |
|
132 | - return getpaid_format_date_value( $customer->get( 'date_created' ) ); |
|
131 | + public function column_date_created($customer) { |
|
132 | + return getpaid_format_date_value($customer->get('date_created')); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return string Column Name |
143 | 143 | */ |
144 | - public function column_purchase_value( $customer ) { |
|
145 | - return wpinv_price( (float) $customer->get( 'purchase_value' ) ); |
|
144 | + public function column_purchase_value($customer) { |
|
145 | + return wpinv_price((float) $customer->get('purchase_value')); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @return string Column Name |
156 | 156 | */ |
157 | - public function column_purchase_count( $customer ) { |
|
158 | - $value = $customer->get( 'purchase_count' ); |
|
159 | - $url = $customer->get( 'user_id' ) ? add_query_arg( array( 'post_type' => 'wpi_invoice', 'author' => $customer->get( 'user_id' ), ), admin_url( 'edit.php' ) ) : ''; |
|
157 | + public function column_purchase_count($customer) { |
|
158 | + $value = $customer->get('purchase_count'); |
|
159 | + $url = $customer->get('user_id') ? add_query_arg(array('post_type' => 'wpi_invoice', 'author' => $customer->get('user_id'),), admin_url('edit.php')) : ''; |
|
160 | 160 | |
161 | - return ( empty( $value ) || empty( $url ) ) ? (int) $value : '<a href="' . esc_url( $url ) . '">' . absint( $value ) . '</a>'; |
|
161 | + return (empty($value) || empty($url)) ? (int) $value : '<a href="' . esc_url($url) . '">' . absint($value) . '</a>'; |
|
162 | 162 | |
163 | 163 | } |
164 | 164 | |
@@ -168,25 +168,25 @@ discard block |
||
168 | 168 | * @param GetPaid_Customer $customer customer. |
169 | 169 | * @return string |
170 | 170 | */ |
171 | - public function column_customer( $customer ) { |
|
171 | + public function column_customer($customer) { |
|
172 | 172 | |
173 | - $first_name = $customer->get( 'first_name' ); |
|
174 | - $last_name = $customer->get( 'last_name' ); |
|
175 | - $email = $customer->get( 'email' ); |
|
176 | - $avatar = get_avatar( $customer->get( 'user_id' ) ? $customer->get( 'user_id' ) : $email, 32 ); |
|
173 | + $first_name = $customer->get('first_name'); |
|
174 | + $last_name = $customer->get('last_name'); |
|
175 | + $email = $customer->get('email'); |
|
176 | + $avatar = get_avatar($customer->get('user_id') ? $customer->get('user_id') : $email, 32); |
|
177 | 177 | |
178 | 178 | // Customer view URL. |
179 | - $view_url = $customer->get( 'user_id' ) ? esc_url( add_query_arg( 'user_id', $customer->get( 'user_id' ), admin_url( 'user-edit.php' ) ) ) : false; |
|
179 | + $view_url = $customer->get('user_id') ? esc_url(add_query_arg('user_id', $customer->get('user_id'), admin_url('user-edit.php'))) : false; |
|
180 | 180 | $row_actions = $view_url ? $this->row_actions( |
181 | 181 | array( |
182 | - 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
182 | + 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __('Edit Details', 'invoicing') . '</a>', |
|
183 | 183 | ) |
184 | 184 | ) : ''; |
185 | 185 | |
186 | 186 | // Customer's name. |
187 | - $name = esc_html( trim( "$first_name $last_name" ) ); |
|
187 | + $name = esc_html(trim("$first_name $last_name")); |
|
188 | 188 | |
189 | - if ( ! empty( $name ) ) { |
|
189 | + if (!empty($name)) { |
|
190 | 190 | $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
191 | 191 | } |
192 | 192 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @return int Current page number |
204 | 204 | */ |
205 | 205 | public function get_paged() { |
206 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
206 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @since 1.0.19 |
213 | 213 | * @return void |
214 | 214 | */ |
215 | - public function bulk_actions( $which = '' ) { |
|
215 | + public function bulk_actions($which = '') { |
|
216 | 216 | return array(); |
217 | 217 | } |
218 | 218 | |
@@ -227,33 +227,33 @@ discard block |
||
227 | 227 | 'paged' => $this->get_paged(), |
228 | 228 | ); |
229 | 229 | |
230 | - foreach ( array( 'orderby', 'order', 's' ) as $field ) { |
|
231 | - if ( isset( $_GET[ $field ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
232 | - $query[ $field ] = wpinv_clean( rawurlencode_deep( $_GET[ $field ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
230 | + foreach (array('orderby', 'order', 's') as $field) { |
|
231 | + if (isset($_GET[$field])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
232 | + $query[$field] = wpinv_clean(rawurlencode_deep($_GET[$field])); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | - foreach ( GetPaid_Customer_Data_Store::get_database_fields() as $field => $type ) { |
|
236 | + foreach (GetPaid_Customer_Data_Store::get_database_fields() as $field => $type) { |
|
237 | 237 | |
238 | - if ( isset( $_GET[ $field ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
239 | - $query[ $field ] = wpinv_clean( rawurlencode_deep( $_GET[ $field ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
238 | + if (isset($_GET[$field])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
239 | + $query[$field] = wpinv_clean(rawurlencode_deep($_GET[$field])); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | // Min max. |
243 | - if ( '%f' === $type || '%d' === $type ) { |
|
243 | + if ('%f' === $type || '%d' === $type) { |
|
244 | 244 | |
245 | - if ( isset( $_GET[ $field . '_min' ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
246 | - $query[ $field . '_min' ] = floatval( $_GET[ $field . '_min' ] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
245 | + if (isset($_GET[$field . '_min'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
246 | + $query[$field . '_min'] = floatval($_GET[$field . '_min']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
247 | 247 | } |
248 | 248 | |
249 | - if ( isset( $_GET[ $field . '_max' ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
250 | - $query[ $field . '_max' ] = floatval( $_GET[ $field . '_max' ] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
249 | + if (isset($_GET[$field . '_max'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
250 | + $query[$field . '_max'] = floatval($_GET[$field . '_max']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | 255 | // Prepare class properties. |
256 | - $this->query = getpaid_get_customers( $query, 'query' ); |
|
256 | + $this->query = getpaid_get_customers($query, 'query'); |
|
257 | 257 | $this->total_count = $this->query->get_total(); |
258 | 258 | $this->items = $this->query->get_results(); |
259 | 259 | } |
@@ -269,13 +269,13 @@ discard block |
||
269 | 269 | $sortable = $this->get_sortable_columns(); |
270 | 270 | $this->prepare_query(); |
271 | 271 | |
272 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
272 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
273 | 273 | |
274 | 274 | $this->set_pagination_args( |
275 | 275 | array( |
276 | 276 | 'total_items' => $this->total_count, |
277 | 277 | 'per_page' => $this->per_page, |
278 | - 'total_pages' => ceil( $this->total_count / $this->per_page ), |
|
278 | + 'total_pages' => ceil($this->total_count / $this->per_page), |
|
279 | 279 | ) |
280 | 280 | ); |
281 | 281 | } |
@@ -287,14 +287,14 @@ discard block |
||
287 | 287 | */ |
288 | 288 | public function get_sortable_columns() { |
289 | 289 | $sortable = array( |
290 | - 'customer' => array( 'first_name', true ), |
|
290 | + 'customer' => array('first_name', true), |
|
291 | 291 | ); |
292 | 292 | |
293 | - foreach ( GetPaid_Customer_Data_Store::get_database_fields() as $field => $type ) { |
|
294 | - $sortable[ $field ] = array( $field, true ); |
|
293 | + foreach (GetPaid_Customer_Data_Store::get_database_fields() as $field => $type) { |
|
294 | + $sortable[$field] = array($field, true); |
|
295 | 295 | } |
296 | 296 | |
297 | - return apply_filters( 'manage_getpaid_customers_sortable_table_columns', $sortable ); |
|
297 | + return apply_filters('manage_getpaid_customers_sortable_table_columns', $sortable); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -304,22 +304,22 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public function get_columns() { |
306 | 306 | $columns = array( |
307 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
307 | + 'customer' => __('Customer', 'invoicing'), |
|
308 | 308 | ); |
309 | 309 | |
310 | 310 | // Add address fields. |
311 | - foreach ( getpaid_user_address_fields() as $key => $value ) { |
|
311 | + foreach (getpaid_user_address_fields() as $key => $value) { |
|
312 | 312 | |
313 | 313 | // Skip id, user_id and email. |
314 | - if ( ! in_array( $key, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid', 'first_name', 'last_name' ), true ) ) { |
|
315 | - $columns[ $key ] = $value; |
|
314 | + if (!in_array($key, array('id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid', 'first_name', 'last_name'), true)) { |
|
315 | + $columns[$key] = $value; |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | |
319 | - $columns['purchase_value'] = __( 'Total Spend', 'invoicing' ); |
|
320 | - $columns['purchase_count'] = __( 'Invoices', 'invoicing' ); |
|
321 | - $columns['date_created'] = __( 'Date created', 'invoicing' ); |
|
319 | + $columns['purchase_value'] = __('Total Spend', 'invoicing'); |
|
320 | + $columns['purchase_count'] = __('Invoices', 'invoicing'); |
|
321 | + $columns['date_created'] = __('Date created', 'invoicing'); |
|
322 | 322 | |
323 | - return apply_filters( 'manage_getpaid_customers_table_columns', $columns ); |
|
323 | + return apply_filters('manage_getpaid_customers_table_columns', $columns); |
|
324 | 324 | } |
325 | 325 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Setup menus in WP admin. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * WC_Admin_Menus Class. |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | * Hook in tabs. |
14 | 14 | */ |
15 | 15 | public function __construct() { |
16 | - add_action( 'admin_head', array( $this, 'set_admin_menu_class' ) ); |
|
17 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 ); |
|
18 | - add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 ); |
|
19 | - add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 ); |
|
20 | - add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 ); |
|
21 | - add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 ); |
|
22 | - add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 ); |
|
23 | - add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); |
|
16 | + add_action('admin_head', array($this, 'set_admin_menu_class')); |
|
17 | + add_action('admin_menu', array($this, 'admin_menu'), 10); |
|
18 | + add_action('admin_menu', array($this, 'add_customers_menu'), 18); |
|
19 | + add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40); |
|
20 | + add_action('admin_menu', array($this, 'add_addons_menu'), 100); |
|
21 | + add_action('admin_menu', array($this, 'add_settings_menu'), 60); |
|
22 | + add_action('admin_menu', array($this, 'remove_admin_submenus'), 10); |
|
23 | + add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes')); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public function set_admin_menu_class() { |
30 | 30 | global $current_screen, $parent_file, $submenu_file; |
31 | 31 | |
32 | - if ( ! empty( $current_screen->id ) && in_array( $current_screen->id, array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) { |
|
32 | + if (!empty($current_screen->id) && in_array($current_screen->id, array('wpi_discount', 'wpi_payment_form', 'wpi_invoice'))) { |
|
33 | 33 | $parent_file = 'wpinv'; |
34 | 34 | $submenu_file = 'edit.php?post_type=' . $current_screen->id; |
35 | 35 | } |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | |
39 | 39 | public function admin_menu() { |
40 | 40 | |
41 | - $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() ); |
|
41 | + $capability = apply_filters('invoicing_capability', wpinv_get_capability()); |
|
42 | 42 | add_menu_page( |
43 | - __( 'GetPaid', 'invoicing' ), |
|
44 | - __( 'GetPaid', 'invoicing' ), |
|
43 | + __('GetPaid', 'invoicing'), |
|
44 | + __('GetPaid', 'invoicing'), |
|
45 | 45 | $capability, |
46 | 46 | 'wpinv', |
47 | 47 | null, |
48 | - 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ), |
|
48 | + 'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')), |
|
49 | 49 | '54.123460' |
50 | 50 | ); |
51 | 51 | |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | public function add_customers_menu() { |
58 | 58 | add_submenu_page( |
59 | 59 | 'wpinv', |
60 | - __( 'Customers', 'invoicing' ), |
|
61 | - __( 'Customers', 'invoicing' ), |
|
60 | + __('Customers', 'invoicing'), |
|
61 | + __('Customers', 'invoicing'), |
|
62 | 62 | wpinv_get_capability(), |
63 | 63 | 'wpinv-customers', |
64 | - array( $this, 'customers_page' ) |
|
64 | + array($this, 'customers_page') |
|
65 | 65 | ); |
66 | 66 | } |
67 | 67 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | public function add_subscriptions_menu() { |
72 | 72 | add_submenu_page( |
73 | 73 | 'wpinv', |
74 | - __( 'Subscriptions', 'invoicing' ), |
|
75 | - __( 'Subscriptions', 'invoicing' ), |
|
74 | + __('Subscriptions', 'invoicing'), |
|
75 | + __('Subscriptions', 'invoicing'), |
|
76 | 76 | wpinv_get_capability(), |
77 | 77 | 'wpinv-subscriptions', |
78 | 78 | 'wpinv_subscriptions_page' |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | width: 120px; |
95 | 95 | } |
96 | 96 | </style> |
97 | - <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?> <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'download_customers' ), 'getpaid-nonce', 'getpaid-nonce' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Export', 'invoicing' ); ?></a></h1> |
|
98 | - <form method="get" style="overflow: auto; width: 100%" action=<?php echo esc_url( add_query_arg( array() ) ); ?>> |
|
97 | + <h1><?php echo esc_html(__('Customers', 'invoicing')); ?> <a href="<?php echo esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'download_customers'), 'getpaid-nonce', 'getpaid-nonce')); ?>" class="page-title-action"><?php esc_html_e('Export', 'invoicing'); ?></a></h1> |
|
98 | + <form method="get" style="overflow: auto; width: 100%" action=<?php echo esc_url(add_query_arg(array())); ?>> |
|
99 | 99 | <input type="hidden" name="page" value="wpinv-customers" /> |
100 | 100 | <?php |
101 | 101 | $table = new WPInv_Customers_Table(); |
102 | 102 | $table->prepare_items(); |
103 | - $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' ); |
|
103 | + $table->search_box(__('Search Customers', 'invoicing'), 'search-customers'); |
|
104 | 104 | $table->display(); |
105 | 105 | ?> |
106 | 106 | </form> |
@@ -114,26 +114,26 @@ discard block |
||
114 | 114 | public function add_settings_menu() { |
115 | 115 | add_submenu_page( |
116 | 116 | 'wpinv', |
117 | - __( 'Invoice Settings', 'invoicing' ), |
|
118 | - __( 'Settings', 'invoicing' ), |
|
119 | - apply_filters( 'invoicing_capability', wpinv_get_capability() ), |
|
117 | + __('Invoice Settings', 'invoicing'), |
|
118 | + __('Settings', 'invoicing'), |
|
119 | + apply_filters('invoicing_capability', wpinv_get_capability()), |
|
120 | 120 | 'wpinv-settings', |
121 | - array( $this, 'options_page' ) |
|
121 | + array($this, 'options_page') |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | |
125 | 125 | public function add_addons_menu() { |
126 | - if ( ! apply_filters( 'wpi_show_addons_page', true ) ) { |
|
126 | + if (!apply_filters('wpi_show_addons_page', true)) { |
|
127 | 127 | return; |
128 | 128 | } |
129 | 129 | |
130 | 130 | add_submenu_page( |
131 | 131 | 'wpinv', |
132 | - __( 'Invoicing extensions', 'invoicing' ), |
|
133 | - __( 'Extensions', 'invoicing' ), |
|
132 | + __('Invoicing extensions', 'invoicing'), |
|
133 | + __('Extensions', 'invoicing'), |
|
134 | 134 | 'manage_options', |
135 | 135 | 'wpi-addons', |
136 | - array( $this, 'addons_page' ) |
|
136 | + array($this, 'addons_page') |
|
137 | 137 | ); |
138 | 138 | } |
139 | 139 | |
@@ -144,29 +144,29 @@ discard block |
||
144 | 144 | |
145 | 145 | function options_page() { |
146 | 146 | |
147 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
147 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
151 | 151 | $settings_tabs = wpinv_get_settings_tabs(); |
152 | - $settings_tabs = empty( $settings_tabs ) ? array() : $settings_tabs; |
|
153 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
154 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
152 | + $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
|
153 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
154 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
155 | 155 | $key = 'main'; |
156 | 156 | |
157 | - if ( is_array( $sections ) ) { |
|
158 | - $key = key( $sections ); |
|
157 | + if (is_array($sections)) { |
|
158 | + $key = key($sections); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | add_thickbox(); |
162 | 162 | |
163 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
164 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? sanitize_text_field( $_GET['section'] ) : $key; |
|
163 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
164 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? sanitize_text_field($_GET['section']) : $key; |
|
165 | 165 | ?> |
166 | 166 | <div class="wrap"> |
167 | 167 | <h1 class="nav-tab-wrapper"> |
168 | 168 | <?php |
169 | - foreach ( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
169 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
170 | 170 | $tab_url = add_query_arg( |
171 | 171 | array( |
172 | 172 | 'settings-updated' => false, |
@@ -176,23 +176,23 @@ discard block |
||
176 | 176 | ); |
177 | 177 | |
178 | 178 | // Remove the section from the tabs so we always end up at the main section |
179 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
180 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
179 | + $tab_url = remove_query_arg('section', $tab_url); |
|
180 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
181 | 181 | |
182 | 182 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
183 | 183 | |
184 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . esc_attr( $active ) . '">'; |
|
185 | - echo esc_html( $tab_name ); |
|
184 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . esc_attr($active) . '">'; |
|
185 | + echo esc_html($tab_name); |
|
186 | 186 | echo '</a>'; |
187 | 187 | } |
188 | 188 | ?> |
189 | 189 | </h1> |
190 | 190 | <?php |
191 | - $number_of_sections = count( $sections ); |
|
191 | + $number_of_sections = count($sections); |
|
192 | 192 | $number = 0; |
193 | - if ( $number_of_sections > 1 ) { |
|
193 | + if ($number_of_sections > 1) { |
|
194 | 194 | echo '<div><ul class="subsubsub">'; |
195 | - foreach ( $sections as $section_id => $section_name ) { |
|
195 | + foreach ($sections as $section_id => $section_name) { |
|
196 | 196 | echo '<li>'; |
197 | 197 | $number++; |
198 | 198 | $tab_url = add_query_arg( |
@@ -201,16 +201,16 @@ discard block |
||
201 | 201 | 'tab' => $active_tab, |
202 | 202 | 'section' => $section_id, |
203 | 203 | ), |
204 | - admin_url( 'admin.php?page=wpinv-settings' ) |
|
204 | + admin_url('admin.php?page=wpinv-settings') |
|
205 | 205 | ); |
206 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
206 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
207 | 207 | $class = ''; |
208 | - if ( $section == $section_id ) { |
|
208 | + if ($section == $section_id) { |
|
209 | 209 | $class = 'current'; |
210 | 210 | } |
211 | - echo '<a class="' . esc_attr( $class ) . '" href="' . esc_url( $tab_url ) . '">' . esc_html( $section_name ) . '</a>'; |
|
211 | + echo '<a class="' . esc_attr($class) . '" href="' . esc_url($tab_url) . '">' . esc_html($section_name) . '</a>'; |
|
212 | 212 | |
213 | - if ( $number != $number_of_sections ) { |
|
213 | + if ($number != $number_of_sections) { |
|
214 | 214 | echo ' | '; |
215 | 215 | } |
216 | 216 | echo '</li>'; |
@@ -222,20 +222,20 @@ discard block |
||
222 | 222 | <form method="post" action="options.php"> |
223 | 223 | <table class="form-table"> |
224 | 224 | <?php |
225 | - settings_fields( 'wpinv_settings' ); |
|
225 | + settings_fields('wpinv_settings'); |
|
226 | 226 | |
227 | - if ( 'main' === $section ) { |
|
228 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
227 | + if ('main' === $section) { |
|
228 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
229 | 229 | } |
230 | 230 | |
231 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
232 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
233 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
234 | - do_action( 'getpaid_settings_tab_bottom', $active_tab, $section ); |
|
231 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section); |
|
232 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section); |
|
233 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section); |
|
234 | + do_action('getpaid_settings_tab_bottom', $active_tab, $section); |
|
235 | 235 | |
236 | 236 | // For backwards compatibility |
237 | - if ( 'main' === $section ) { |
|
238 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
237 | + if ('main' === $section) { |
|
238 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
239 | 239 | } |
240 | 240 | ?> |
241 | 241 | </table> |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | public function remove_admin_submenus() { |
250 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
250 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | |
258 | 258 | add_meta_box( |
259 | 259 | 'wpinv_endpoints_nav_link', |
260 | - __( 'GetPaid endpoints', 'invoicing' ), |
|
261 | - array( $this, 'nav_menu_links' ), |
|
260 | + __('GetPaid endpoints', 'invoicing'), |
|
261 | + array($this, 'nav_menu_links'), |
|
262 | 262 | 'nav-menus', |
263 | 263 | 'side', |
264 | 264 | 'low' |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | $endpoints = $this->get_menu_items(); |
274 | 274 | ?> |
275 | 275 | <div id="invoicing-endpoints" class="posttypediv"> |
276 | - <?php if ( ! empty( $endpoints['pages'] ) ) : ?> |
|
276 | + <?php if (!empty($endpoints['pages'])) : ?> |
|
277 | 277 | <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active"> |
278 | 278 | <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear"> |
279 | 279 | <?php |
280 | - $walker = new Walker_Nav_Menu_Checklist( array() ); |
|
281 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) ); |
|
280 | + $walker = new Walker_Nav_Menu_Checklist(array()); |
|
281 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker)); |
|
282 | 282 | ?> |
283 | 283 | </ul> |
284 | 284 | </div> |
@@ -287,11 +287,11 @@ discard block |
||
287 | 287 | <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints"> |
288 | 288 | <span class="list-controls hide-if-no-js"> |
289 | 289 | <input type="checkbox" id="invoicing-endpoints-tab" class="select-all"> |
290 | - <label for="invoicing-endpoints-tab"><?php esc_html_e( 'Select all', 'invoicing' ); ?></label> |
|
290 | + <label for="invoicing-endpoints-tab"><?php esc_html_e('Select all', 'invoicing'); ?></label> |
|
291 | 291 | </span> |
292 | 292 | |
293 | 293 | <span class="add-to-menu"> |
294 | - <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints"> |
|
294 | + <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints"> |
|
295 | 295 | <span class="spinner"></span> |
296 | 296 | </span> |
297 | 297 | </p> |
@@ -309,18 +309,18 @@ discard block |
||
309 | 309 | |
310 | 310 | $pages = array( |
311 | 311 | array( |
312 | - 'id' => wpinv_get_option( 'invoice_history_page' ), |
|
313 | - 'label' => __( 'My Invoices', 'invoicing' ), |
|
312 | + 'id' => wpinv_get_option('invoice_history_page'), |
|
313 | + 'label' => __('My Invoices', 'invoicing'), |
|
314 | 314 | ), |
315 | 315 | array( |
316 | - 'id' => wpinv_get_option( 'invoice_subscription_page' ), |
|
317 | - 'label' => __( 'My Subscriptions', 'invoicing' ), |
|
316 | + 'id' => wpinv_get_option('invoice_subscription_page'), |
|
317 | + 'label' => __('My Subscriptions', 'invoicing'), |
|
318 | 318 | ), |
319 | 319 | ); |
320 | 320 | |
321 | - foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) { |
|
321 | + foreach (apply_filters('getpaid_menu_pages', $pages) as $page) { |
|
322 | 322 | |
323 | - if ( (int) $page['id'] > 0 ) { |
|
323 | + if ((int) $page['id'] > 0) { |
|
324 | 324 | |
325 | 325 | $item = new stdClass(); |
326 | 326 | $item->object_id = (int) $page['id']; |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | $item->object = 'page'; |
329 | 329 | $item->menu_item_parent = 0; |
330 | 330 | $item->type = 'post_type'; |
331 | - $item->title = esc_html( $page['label'] ); |
|
332 | - $item->url = get_permalink( (int) $page['id'] ); |
|
331 | + $item->title = esc_html($page['label']); |
|
332 | + $item->url = get_permalink((int) $page['id']); |
|
333 | 333 | $item->target = ''; |
334 | 334 | $item->attr_title = ''; |
335 | - $item->classes = array( 'wpinv-menu-item' ); |
|
335 | + $item->classes = array('wpinv-menu-item'); |
|
336 | 336 | $item->xfn = ''; |
337 | 337 | |
338 | 338 | $items['pages'][] = $item; |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
343 | - return apply_filters( 'wpinv_menu_items', $items ); |
|
343 | + return apply_filters('wpinv_menu_items', $items); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | } |
@@ -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,62 +16,62 @@ 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 | |
@@ -87,26 +87,26 @@ discard block |
||
87 | 87 | ); |
88 | 88 | ?> |
89 | 89 | |
90 | - <div class="wpinv-items-wrap<?php echo esc_attr( $class ); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>"> |
|
90 | + <div class="wpinv-items-wrap<?php echo esc_attr($class); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>"> |
|
91 | 91 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
92 | 92 | |
93 | 93 | <thead> |
94 | 94 | <tr> |
95 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
95 | + <?php foreach ($columns as $key => $label) : ?> |
|
96 | 96 | <th class=" |
97 | 97 | <?php |
98 | - echo esc_attr( $key ); |
|
98 | + echo esc_attr($key); |
|
99 | 99 | echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : ''; |
100 | 100 | ?> |
101 | - "><?php echo wp_kses_post( $label ); ?></th> |
|
101 | + "><?php echo wp_kses_post($label); ?></th> |
|
102 | 102 | <?php endforeach; ?> |
103 | 103 | </tr> |
104 | 104 | </thead> |
105 | 105 | |
106 | 106 | <tbody class="wpinv-line-items"> |
107 | 107 | <?php |
108 | - foreach ( $invoice->get_items() as $int => $item ) { |
|
109 | - self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' ); |
|
108 | + foreach ($invoice->get_items() as $int => $item) { |
|
109 | + self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd'); |
|
110 | 110 | } |
111 | 111 | ?> |
112 | 112 | </tbody> |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | <div class="wp-clearfix"> |
124 | 124 | <label class="wpi-item-name"> |
125 | 125 | <span class="input-text-wrap"> |
126 | - <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
126 | + <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
127 | 127 | </span> |
128 | 128 | </label> |
129 | 129 | </div> |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | <div class="wp-clearfix"> |
132 | 132 | <label class="wpi-item-price"> |
133 | 133 | <span class="input-text-wrap"> |
134 | - <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' ); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
135 | - × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' ); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
134 | + <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
135 | + × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
136 | 136 | </span> |
137 | 137 | </label> |
138 | 138 | </div> |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | <div class="wp-clearfix"> |
141 | 141 | <label class="wpi-item-name"> |
142 | 142 | <span class="input-text-wrap"> |
143 | - <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' ); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
143 | + <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
144 | 144 | </span> |
145 | 145 | </label> |
146 | 146 | </div> |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | </label> |
166 | 166 | </div> |
167 | 167 | |
168 | - <?php if ( $use_taxes ) : ?> |
|
168 | + <?php if ($use_taxes) : ?> |
|
169 | 169 | <div class="wp-clearfix"> |
170 | 170 | <label class="wpi-vat-rule"> |
171 | 171 | <span class="input-text-wrap"> |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | wpinv_html_select( |
174 | 174 | array( |
175 | 175 | 'options' => array_merge( |
176 | - array( '' => __( 'Select VAT Rule', 'invoicing' ) ), |
|
176 | + array('' => __('Select VAT Rule', 'invoicing')), |
|
177 | 177 | getpaid_get_tax_rules() |
178 | 178 | ), |
179 | 179 | 'name' => '_wpinv_quick[vat_rule]', |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | wpinv_html_select( |
196 | 196 | array( |
197 | 197 | 'options' => array_merge( |
198 | - array( '' => __( 'Select VAT Class', 'invoicing' ) ), |
|
198 | + array('' => __('Select VAT Class', 'invoicing')), |
|
199 | 199 | getpaid_get_tax_classes() |
200 | 200 | ), |
201 | 201 | 'name' => '_wpinv_quick[vat_class]', |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | 'type' => 'checkbox', |
220 | 220 | 'name' => '_wpinv_quick[one-time]', |
221 | 221 | 'id' => '_wpinv_quick-one-time', |
222 | - 'label' => __( "One time item (won't be saved to regular items list)", 'invoicing' ), |
|
222 | + 'label' => __("One time item (won't be saved to regular items list)", 'invoicing'), |
|
223 | 223 | 'value' => 1, |
224 | 224 | 'no_wrap' => true, |
225 | 225 | 'checked' => false, |
@@ -243,29 +243,29 @@ discard block |
||
243 | 243 | </td> |
244 | 244 | </tr> |
245 | 245 | <tr class="totals"> |
246 | - <td colspan="<?php echo ( (int) $cols - 4 ); ?>"></td> |
|
246 | + <td colspan="<?php echo ((int) $cols - 4); ?>"></td> |
|
247 | 247 | <td colspan="4"> |
248 | 248 | <table cellspacing="0" cellpadding="0"> |
249 | 249 | <tr class="subtotal"> |
250 | - <td class="name"><?php esc_html_e( 'Sub Total:', 'invoicing' ); ?></td> |
|
251 | - <td class="total"><?php wpinv_the_price( $invoice->get_subtotal(), $invoice->get_currency() ); ?></td> |
|
250 | + <td class="name"><?php esc_html_e('Sub Total:', 'invoicing'); ?></td> |
|
251 | + <td class="total"><?php wpinv_the_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td> |
|
252 | 252 | <td class="action"></td> |
253 | 253 | </tr> |
254 | 254 | <tr class="discount"> |
255 | - <td class="name"><?php esc_html_e( 'Discount:', 'invoicing' ); ?></td> |
|
256 | - <td class="total"><?php wpinv_the_price( $invoice->get_total_discount(), $invoice->get_currency() ); ?></td> |
|
255 | + <td class="name"><?php esc_html_e('Discount:', 'invoicing'); ?></td> |
|
256 | + <td class="total"><?php wpinv_the_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td> |
|
257 | 257 | <td class="action"></td> |
258 | 258 | </tr> |
259 | - <?php if ( $use_taxes ) : ?> |
|
259 | + <?php if ($use_taxes) : ?> |
|
260 | 260 | <tr class="tax"> |
261 | - <td class="name"><?php esc_html_e( 'Tax:', 'invoicing' ); ?></td> |
|
262 | - <td class="total"><?php wpinv_the_price( $invoice->get_total_tax(), $invoice->get_currency() ); ?></td> |
|
261 | + <td class="name"><?php esc_html_e('Tax:', 'invoicing'); ?></td> |
|
262 | + <td class="total"><?php wpinv_the_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td> |
|
263 | 263 | <td class="action"></td> |
264 | 264 | </tr> |
265 | 265 | <?php endif; ?> |
266 | 266 | <tr class="total"> |
267 | - <td class="name"><?php esc_html_e( 'Total:', 'invoicing' ); ?></td> |
|
268 | - <td class="total"><?php wpinv_the_price( $invoice->get_total(), $invoice->get_currency() ); ?></td> |
|
267 | + <td class="name"><?php esc_html_e('Total:', 'invoicing'); ?></td> |
|
268 | + <td class="total"><?php wpinv_the_price($invoice->get_total(), $invoice->get_currency()); ?></td> |
|
269 | 269 | <td class="action"></td> |
270 | 270 | </tr> |
271 | 271 | </table> |
@@ -281,18 +281,18 @@ discard block |
||
281 | 281 | <div class="modal-dialog modal-dialog-centered" role="document"> |
282 | 282 | <div class="modal-content"> |
283 | 283 | <div class="modal-header"> |
284 | - <h5 class="modal-title" id="getpaid-refund-invoice-modal-label"><?php esc_html_e( 'Refund Payment', 'invoicing' ); ?></h5> |
|
285 | - <button type="button" class="close btn-close" data-bs-dismiss="modal" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>"> |
|
286 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
284 | + <h5 class="modal-title" id="getpaid-refund-invoice-modal-label"><?php esc_html_e('Refund Payment', 'invoicing'); ?></h5> |
|
285 | + <button type="button" class="close btn-close" data-bs-dismiss="modal" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>"> |
|
286 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
287 | 287 | <span aria-hidden="true">×</span> |
288 | 288 | <?php endif; ?> |
289 | 289 | </button> |
290 | 290 | </div> |
291 | 291 | <div class="modal-body"> |
292 | 292 | <p> |
293 | - <?php esc_html_e( 'Are you sure you want to refund this payment?', 'invoicing' ); ?> |
|
293 | + <?php esc_html_e('Are you sure you want to refund this payment?', 'invoicing'); ?> |
|
294 | 294 | </p> |
295 | - <?php if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) ) : ?> |
|
295 | + <?php if (getpaid_payment_gateway_supports($invoice->get_gateway(), 'refunds')) : ?> |
|
296 | 296 | <?php |
297 | 297 | aui()->input( |
298 | 298 | array( |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | 'id' => 'getpaid_refund_remote', |
302 | 302 | 'label' => sprintf( |
303 | 303 | 'Refund payment in %s', |
304 | - wpinv_get_gateway_admin_label( $invoice->get_gateway() ) |
|
304 | + wpinv_get_gateway_admin_label($invoice->get_gateway()) |
|
305 | 305 | ), |
306 | 306 | 'value' => 1, |
307 | 307 | 'class' => 'getpaid-refund-field', |
@@ -311,14 +311,14 @@ discard block |
||
311 | 311 | ?> |
312 | 312 | <?php endif; ?> |
313 | 313 | |
314 | - <?php if ( getpaid_get_invoice_subscriptions( $invoice ) ) : ?> |
|
314 | + <?php if (getpaid_get_invoice_subscriptions($invoice)) : ?> |
|
315 | 315 | <?php |
316 | 316 | aui()->input( |
317 | 317 | array( |
318 | 318 | 'type' => 'checkbox', |
319 | 319 | 'name' => 'getpaid_cancel_subscription', |
320 | 320 | 'id' => 'getpaid_cancel_subscription', |
321 | - 'label' => __( 'Cancel subscription', 'invoicing' ), |
|
321 | + 'label' => __('Cancel subscription', 'invoicing'), |
|
322 | 322 | 'value' => 1, |
323 | 323 | 'class' => 'getpaid-refund-field', |
324 | 324 | ), |
@@ -328,12 +328,12 @@ discard block |
||
328 | 328 | <?php endif; ?> |
329 | 329 | </div> |
330 | 330 | <div class="modal-footer"> |
331 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-bs-dismiss="modal" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
331 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-bs-dismiss="modal" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
332 | 332 | <a |
333 | - href="<?php echo esc_url_raw( $refund_url ); ?>" |
|
334 | - data-href="<?php echo esc_url_raw( $refund_url ); ?>" |
|
333 | + href="<?php echo esc_url_raw($refund_url); ?>" |
|
334 | + data-href="<?php echo esc_url_raw($refund_url); ?>" |
|
335 | 335 | class="btn btn-primary getpaid-refund-payment-button" |
336 | - ><?php esc_html_e( 'Refund', 'invoicing' ); ?></a> |
|
336 | + ><?php esc_html_e('Refund', 'invoicing'); ?></a> |
|
337 | 337 | <script> |
338 | 338 | // Update the refund URL when the user changes the refund options. |
339 | 339 | jQuery( function( $ ) { |
@@ -359,13 +359,13 @@ discard block |
||
359 | 359 | |
360 | 360 | <div class="wpinv-actions"> |
361 | 361 | <?php |
362 | - if ( $invoice->is_paid() ) { |
|
362 | + if ($invoice->is_paid()) { |
|
363 | 363 | |
364 | 364 | printf( |
365 | 365 | '<span class="bsui"><button type="button" class="button button-primary" data-toggle="modal" data-bs-toggle="modal" data-bs-target="#getpaid-refund-invoice-modal" data-target="#getpaid-refund-invoice-modal">%s</button></span>', |
366 | - esc_html__( 'Refund', 'invoicing' ) |
|
366 | + esc_html__('Refund', 'invoicing') |
|
367 | 367 | ); |
368 | - } elseif ( ! $invoice->is_refunded() ) { |
|
368 | + } elseif (!$invoice->is_refunded()) { |
|
369 | 369 | wpinv_item_dropdown( |
370 | 370 | array( |
371 | 371 | 'name' => 'wpinv_invoice_item', |
@@ -375,66 +375,66 @@ discard block |
||
375 | 375 | ) |
376 | 376 | ); |
377 | 377 | |
378 | - echo ' ' . '<button type="button" class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), esc_html( $invoice->get_label() ) ) . '</button>'; |
|
379 | - echo ' ' . '<button type="button" class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>'; |
|
380 | - echo ' ' . '<button type="button" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>'; |
|
378 | + echo ' ' . '<button type="button" class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), esc_html($invoice->get_label())) . '</button>'; |
|
379 | + echo ' ' . '<button type="button" class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>'; |
|
380 | + echo ' ' . '<button type="button" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>'; |
|
381 | 381 | |
382 | 382 | } |
383 | 383 | ?> |
384 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
384 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
385 | 385 | </div> |
386 | 386 | </div> |
387 | 387 | <?php |
388 | 388 | } |
389 | 389 | |
390 | - public static function output_row( $columns, $item, $invoice, $class = 'even' ) { |
|
390 | + public static function output_row($columns, $item, $invoice, $class = 'even') { |
|
391 | 391 | |
392 | 392 | ?> |
393 | - <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>"> |
|
394 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
393 | + <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>"> |
|
394 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
395 | 395 | <td class=" |
396 | 396 | <?php |
397 | - echo esc_attr( $column ); |
|
397 | + echo esc_attr($column); |
|
398 | 398 | echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : ''; |
399 | 399 | ?> |
400 | 400 | "> |
401 | 401 | <?php |
402 | - switch ( $column ) { |
|
402 | + switch ($column) { |
|
403 | 403 | case 'id': |
404 | 404 | echo (int) $item->get_id(); |
405 | 405 | break; |
406 | 406 | case 'title': |
407 | 407 | printf( |
408 | 408 | '<a href="%s" target="_blank">%s</a>', |
409 | - esc_url( get_edit_post_link( $item->get_id() ) ), |
|
410 | - esc_html( $item->get_raw_name() ) |
|
409 | + esc_url(get_edit_post_link($item->get_id())), |
|
410 | + esc_html($item->get_raw_name()) |
|
411 | 411 | ); |
412 | 412 | |
413 | - $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
414 | - if ( $summary !== '' ) { |
|
413 | + $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice); |
|
414 | + if ($summary !== '') { |
|
415 | 415 | printf( |
416 | 416 | '<span class="meta">%s</span>', |
417 | - wp_kses_post( wpautop( $summary ) ) |
|
417 | + wp_kses_post(wpautop($summary)) |
|
418 | 418 | ); |
419 | 419 | } |
420 | 420 | |
421 | 421 | printf( |
422 | 422 | '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />', |
423 | - esc_attr( $item->get_raw_name() ), |
|
423 | + esc_attr($item->get_raw_name()), |
|
424 | 424 | (int) $item->get_id() |
425 | 425 | ); |
426 | 426 | |
427 | 427 | printf( |
428 | 428 | '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>', |
429 | 429 | (int) $item->get_id(), |
430 | - esc_attr( $item->get_description() ) |
|
430 | + esc_attr($item->get_description()) |
|
431 | 431 | ); |
432 | 432 | |
433 | 433 | break; |
434 | 434 | case 'price': |
435 | 435 | printf( |
436 | 436 | '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />', |
437 | - esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ), |
|
437 | + esc_attr(getpaid_unstandardize_amount($item->get_price())), |
|
438 | 438 | (int) $item->get_id() |
439 | 439 | ); |
440 | 440 | |
@@ -442,26 +442,26 @@ discard block |
||
442 | 442 | case 'qty': |
443 | 443 | printf( |
444 | 444 | '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />', |
445 | - floatval( $item->get_quantity() ), |
|
445 | + floatval($item->get_quantity()), |
|
446 | 446 | (int) $item->get_id() |
447 | 447 | ); |
448 | 448 | |
449 | 449 | break; |
450 | 450 | case 'total': |
451 | - wpinv_the_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
451 | + wpinv_the_price($item->get_sub_total(), $invoice->get_currency()); |
|
452 | 452 | |
453 | 453 | break; |
454 | 454 | case 'tax': |
455 | - echo floatval( wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
455 | + echo floatval(wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2)) . '%'; |
|
456 | 456 | |
457 | 457 | break; |
458 | 458 | case 'action': |
459 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
459 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
460 | 460 | echo '<i class="fa fa-trash wpinv-item-remove"></i>'; |
461 | 461 | } |
462 | 462 | break; |
463 | 463 | } |
464 | - do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice ); |
|
464 | + do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice); |
|
465 | 465 | ?> |
466 | 466 | </td> |
467 | 467 | <?php endforeach; ?> |
@@ -474,10 +474,10 @@ discard block |
||
474 | 474 | * |
475 | 475 | * @param WP_Post $post |
476 | 476 | */ |
477 | - public static function output2( $post ) { |
|
477 | + public static function output2($post) { |
|
478 | 478 | |
479 | 479 | // Prepare the invoice. |
480 | - $invoice = new WPInv_Invoice( $post ); |
|
480 | + $invoice = new WPInv_Invoice($post); |
|
481 | 481 | |
482 | 482 | // Invoice items. |
483 | 483 | $items = $invoice->get_items(); |
@@ -485,28 +485,28 @@ discard block |
||
485 | 485 | $totals = array( |
486 | 486 | |
487 | 487 | 'subtotal' => array( |
488 | - 'label' => __( 'Items Subtotal', 'invoicing' ), |
|
489 | - 'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
488 | + 'label' => __('Items Subtotal', 'invoicing'), |
|
489 | + 'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
490 | 490 | ), |
491 | 491 | |
492 | 492 | 'discount' => array( |
493 | - 'label' => __( 'Total Discount', 'invoicing' ), |
|
494 | - 'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
493 | + 'label' => __('Total Discount', 'invoicing'), |
|
494 | + 'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
495 | 495 | ), |
496 | 496 | |
497 | 497 | 'tax' => array( |
498 | - 'label' => __( 'Total Tax', 'invoicing' ), |
|
499 | - 'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
498 | + 'label' => __('Total Tax', 'invoicing'), |
|
499 | + 'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
500 | 500 | ), |
501 | 501 | |
502 | 502 | 'total' => array( |
503 | - 'label' => __( 'Invoice Total', 'invoicing' ), |
|
504 | - 'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
|
503 | + 'label' => __('Invoice Total', 'invoicing'), |
|
504 | + 'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()), |
|
505 | 505 | ), |
506 | 506 | ); |
507 | 507 | |
508 | - if ( ! wpinv_use_taxes() ) { |
|
509 | - unset( $totals['tax'] ); |
|
508 | + if (!wpinv_use_taxes()) { |
|
509 | + unset($totals['tax']); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | $item_args = array( |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | 'orderby' => 'title', |
515 | 515 | 'order' => 'ASC', |
516 | 516 | 'posts_per_page' => -1, |
517 | - 'post_status' => array( 'publish' ), |
|
517 | + 'post_status' => array('publish'), |
|
518 | 518 | 'meta_query' => array( |
519 | 519 | array( |
520 | 520 | 'key' => '_wpinv_type', |
@@ -542,10 +542,10 @@ discard block |
||
542 | 542 | } |
543 | 543 | </style> |
544 | 544 | |
545 | - <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;"> |
|
545 | + <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;"> |
|
546 | 546 | |
547 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
548 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
547 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
548 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
549 | 549 | |
550 | 550 | <div class="row"> |
551 | 551 | <div class="col-12 col-sm-6"> |
@@ -554,15 +554,15 @@ discard block |
||
554 | 554 | array( |
555 | 555 | 'id' => 'wpinv_template', |
556 | 556 | 'name' => 'wpinv_template', |
557 | - 'label' => __( 'Template', 'invoicing' ), |
|
557 | + 'label' => __('Template', 'invoicing'), |
|
558 | 558 | 'label_type' => 'vertical', |
559 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
559 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
560 | 560 | 'class' => 'form-control-sm', |
561 | - 'value' => $invoice->get_template( 'edit' ), |
|
561 | + 'value' => $invoice->get_template('edit'), |
|
562 | 562 | 'options' => array( |
563 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
564 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
565 | - 'amount' => __( 'Amount Only', 'invoicing' ), |
|
563 | + 'quantity' => __('Quantity', 'invoicing'), |
|
564 | + 'hours' => __('Hours', 'invoicing'), |
|
565 | + 'amount' => __('Amount Only', 'invoicing'), |
|
566 | 566 | ), |
567 | 567 | 'data-allow-clear' => 'false', |
568 | 568 | 'select2' => true, |
@@ -579,11 +579,11 @@ discard block |
||
579 | 579 | array( |
580 | 580 | 'id' => 'wpinv_currency', |
581 | 581 | 'name' => 'wpinv_currency', |
582 | - 'label' => __( 'Currency', 'invoicing' ), |
|
582 | + 'label' => __('Currency', 'invoicing'), |
|
583 | 583 | 'label_type' => 'vertical', |
584 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
584 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
585 | 585 | 'class' => 'form-control-sm', |
586 | - 'value' => $invoice->get_currency( 'edit' ), |
|
586 | + 'value' => $invoice->get_currency('edit'), |
|
587 | 587 | 'required' => false, |
588 | 588 | 'data-allow-clear' => 'false', |
589 | 589 | 'select2' => true, |
@@ -596,24 +596,24 @@ discard block |
||
596 | 596 | </div> |
597 | 597 | </div> |
598 | 598 | |
599 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
599 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
600 | 600 | <?php endif; ?> |
601 | 601 | |
602 | 602 | <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items"> |
603 | 603 | <thead> |
604 | 604 | <tr> |
605 | - <th class="getpaid-item" colspan="2"><?php esc_html_e( 'Item', 'invoicing' ); ?></th> |
|
605 | + <th class="getpaid-item" colspan="2"><?php esc_html_e('Item', 'invoicing'); ?></th> |
|
606 | 606 | <th class="getpaid-quantity hide-if-amount text-right"> |
607 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
608 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ); ?></span> |
|
607 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
608 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing'); ?></span> |
|
609 | 609 | </th> |
610 | 610 | <th class="getpaid-price hide-if-amount text-right"> |
611 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
612 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Rate', 'invoicing' ); ?></span> |
|
611 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
612 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Rate', 'invoicing'); ?></span> |
|
613 | 613 | </th> |
614 | 614 | <th class="getpaid-item-subtotal text-right"> |
615 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
616 | - <span class="hide-if-amount"><?php esc_html_e( 'Total', 'invoicing' ); ?></span> |
|
615 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
616 | + <span class="hide-if-amount"><?php esc_html_e('Total', 'invoicing'); ?></span> |
|
617 | 617 | </th> |
618 | 618 | <th class="getpaid-item-actions hide-if-not-editable" width="70px"> </th> |
619 | 619 | </tr> |
@@ -621,8 +621,8 @@ discard block |
||
621 | 621 | <tbody class="getpaid_invoice_line_items"> |
622 | 622 | <tr class="hide-if-has-items hide-if-not-editable"> |
623 | 623 | <td colspan="2" class="pt-4 pb-4"> |
624 | - <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> |
|
625 | - <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> |
|
624 | + <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> |
|
625 | + <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> |
|
626 | 626 | </td> |
627 | 627 | <td class="hide-if-amount"> </th> |
628 | 628 | <td class="hide-if-amount"> </th> |
@@ -654,11 +654,11 @@ discard block |
||
654 | 654 | <div class="col-12 col-sm-6 offset-sm-6"> |
655 | 655 | <table class="getpaid-invoice-totals text-right w-100"> |
656 | 656 | <tbody> |
657 | - <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?> |
|
658 | - <tr class="getpaid-totals-<?php echo esc_attr( $key ); ?>"> |
|
659 | - <td class="label"><?php echo esc_html( $data['label'] ); ?>:</td> |
|
657 | + <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?> |
|
658 | + <tr class="getpaid-totals-<?php echo esc_attr($key); ?>"> |
|
659 | + <td class="label"><?php echo esc_html($data['label']); ?>:</td> |
|
660 | 660 | <td width="1%"></td> |
661 | - <td class="value"><?php echo wp_kses_post( $data['value'] ); ?></td> |
|
661 | + <td class="value"><?php echo wp_kses_post($data['value']); ?></td> |
|
662 | 662 | </tr> |
663 | 663 | <?php endforeach; ?> |
664 | 664 | </tbody> |
@@ -671,18 +671,18 @@ discard block |
||
671 | 671 | <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable"> |
672 | 672 | <div class="row"> |
673 | 673 | <div class="text-left col-12 col-sm-8"> |
674 | - <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> |
|
675 | - <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> |
|
676 | - <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?> |
|
674 | + <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> |
|
675 | + <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> |
|
676 | + <?php do_action('getpaid-invoice-items-actions', $invoice); ?> |
|
677 | 677 | </div> |
678 | 678 | <div class="text-right col-12 col-sm-4"> |
679 | - <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e( 'Recalculate Totals', 'invoicing' ); ?></button> |
|
679 | + <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e('Recalculate Totals', 'invoicing'); ?></button> |
|
680 | 680 | </div> |
681 | 681 | </div> |
682 | 682 | </div> |
683 | 683 | |
684 | 684 | <div class="getpaid-invoice-item-actions hide-if-editable"> |
685 | - <p class="description m-2 text-right text-muted"><?php esc_html_e( 'This invoice is no longer editable', 'invoicing' ); ?></p> |
|
685 | + <p class="description m-2 text-right text-muted"><?php esc_html_e('This invoice is no longer editable', 'invoicing'); ?></p> |
|
686 | 686 | </div> |
687 | 687 | |
688 | 688 | <!-- Add items to an invoice --> |
@@ -690,9 +690,9 @@ discard block |
||
690 | 690 | <div class="modal-dialog modal-dialog-centered" role="document"> |
691 | 691 | <div class="modal-content"> |
692 | 692 | <div class="modal-header"> |
693 | - <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e( 'Add Item(s)', 'invoicing' ); ?></h5> |
|
694 | - <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>"> |
|
695 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
693 | + <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e('Add Item(s)', 'invoicing'); ?></h5> |
|
694 | + <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>"> |
|
695 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
696 | 696 | <span aria-hidden="true">×</span> |
697 | 697 | <?php endif; ?> |
698 | 698 | </button> |
@@ -701,10 +701,10 @@ discard block |
||
701 | 701 | <table class="widefat"> |
702 | 702 | <thead> |
703 | 703 | <tr> |
704 | - <th class="pl-0 text-left"><?php esc_html_e( 'Item', 'invoicing' ); ?></th> |
|
704 | + <th class="pl-0 text-left"><?php esc_html_e('Item', 'invoicing'); ?></th> |
|
705 | 705 | <th class="pr-0 text-right hide-if-amount"> |
706 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
707 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ); ?></span> |
|
706 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
707 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing'); ?></span> |
|
708 | 708 | </th> |
709 | 709 | </tr> |
710 | 710 | </thead> |
@@ -712,9 +712,9 @@ discard block |
||
712 | 712 | <tr> |
713 | 713 | <td class="pl-0 text-left"> |
714 | 714 | <select class="regular-text getpaid-add-invoice-item-select"> |
715 | - <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option> |
|
716 | - <?php foreach ( get_posts( $item_args ) as $item ) : ?> |
|
717 | - <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html( $item->post_title ); ?></option> |
|
715 | + <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option> |
|
716 | + <?php foreach (get_posts($item_args) as $item) : ?> |
|
717 | + <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html($item->post_title); ?></option> |
|
718 | 718 | <?php endforeach; ?> |
719 | 719 | </select> |
720 | 720 | </td> |
@@ -726,8 +726,8 @@ discard block |
||
726 | 726 | </table> |
727 | 727 | </div> |
728 | 728 | <div class="modal-footer"> |
729 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
730 | - <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e( 'Add', 'invoicing' ); ?></button> |
|
729 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
730 | + <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e('Add', 'invoicing'); ?></button> |
|
731 | 731 | </div> |
732 | 732 | </div> |
733 | 733 | </div> |
@@ -738,9 +738,9 @@ discard block |
||
738 | 738 | <div class="modal-dialog modal-dialog-centered" role="document"> |
739 | 739 | <div class="modal-content"> |
740 | 740 | <div class="modal-header"> |
741 | - <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e( 'Create Item', 'invoicing' ); ?></h5> |
|
742 | - <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>"> |
|
743 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
741 | + <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e('Create Item', 'invoicing'); ?></h5> |
|
742 | + <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>"> |
|
743 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
744 | 744 | <span aria-hidden="true">×</span> |
745 | 745 | <?php endif; ?> |
746 | 746 | </button> |
@@ -749,27 +749,27 @@ discard block |
||
749 | 749 | <div class="getpaid-create-item-div"> |
750 | 750 | <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id"> |
751 | 751 | <label class="form-group mb-3 w-100"> |
752 | - <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span> |
|
753 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
752 | + <span><?php esc_html_e('Name', 'invoicing'); ?></span> |
|
753 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
754 | 754 | </label> |
755 | 755 | <label class="form-group mb-3 w-100"> |
756 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
757 | - <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
758 | - <input type="text" name="price" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control form-control-sm item-price"> |
|
756 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
757 | + <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
758 | + <input type="text" name="price" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control form-control-sm item-price"> |
|
759 | 759 | </label> |
760 | 760 | <label class="form-group mb-3 w-100 hide-if-amount"> |
761 | - <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
761 | + <span><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
762 | 762 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
763 | 763 | </label> |
764 | 764 | <label class="form-group mb-3 w-100"> |
765 | - <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span> |
|
766 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
765 | + <span><?php esc_html_e('Item Description', 'invoicing'); ?></span> |
|
766 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
767 | 767 | </label> |
768 | 768 | </div> |
769 | 769 | </div> |
770 | 770 | <div class="modal-footer"> |
771 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
772 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Create', 'invoicing' ); ?></button> |
|
771 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
772 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Create', 'invoicing'); ?></button> |
|
773 | 773 | </div> |
774 | 774 | </div> |
775 | 775 | </div> |
@@ -780,9 +780,9 @@ discard block |
||
780 | 780 | <div class="modal-dialog modal-dialog-centered" role="document"> |
781 | 781 | <div class="modal-content"> |
782 | 782 | <div class="modal-header"> |
783 | - <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e( 'Edit Item', 'invoicing' ); ?></h5> |
|
784 | - <button type="button" class="close close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>"> |
|
785 | - <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?> |
|
783 | + <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e('Edit Item', 'invoicing'); ?></h5> |
|
784 | + <button type="button" class="close close" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>"> |
|
785 | + <?php if (empty($GLOBALS['aui_bs5'])) : ?> |
|
786 | 786 | <span aria-hidden="true">×</span> |
787 | 787 | <?php endif; ?> |
788 | 788 | </button> |
@@ -791,27 +791,27 @@ discard block |
||
791 | 791 | <div class="getpaid-edit-item-div"> |
792 | 792 | <input type="hidden" name="id" class="form-control form-control-sm item-id"> |
793 | 793 | <label class="form-group mb-3 w-100"> |
794 | - <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span> |
|
795 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
794 | + <span><?php esc_html_e('Name', 'invoicing'); ?></span> |
|
795 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
796 | 796 | </label> |
797 | 797 | <label class="form-group mb-3 w-100"> |
798 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
799 | - <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
800 | - <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price"> |
|
798 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
799 | + <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
800 | + <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price"> |
|
801 | 801 | </label> |
802 | 802 | <label class="form-group mb-3 w-100 hide-if-amount"> |
803 | - <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
803 | + <span><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
804 | 804 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
805 | 805 | </label> |
806 | 806 | <label class="form-group mb-3 w-100"> |
807 | - <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span> |
|
808 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
807 | + <span><?php esc_html_e('Item Description', 'invoicing'); ?></span> |
|
808 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
809 | 809 | </label> |
810 | 810 | </div> |
811 | 811 | </div> |
812 | 812 | <div class="modal-footer"> |
813 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
814 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Save', 'invoicing' ); ?></button> |
|
813 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
814 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Save', 'invoicing'); ?></button> |
|
815 | 815 | </div> |
816 | 816 | </div> |
817 | 817 | </div> |
@@ -15,20 +15,20 @@ discard block |
||
15 | 15 | * @package GetPaid |
16 | 16 | */ |
17 | 17 | |
18 | -defined( 'ABSPATH' ) || exit; |
|
18 | +defined('ABSPATH') || exit; |
|
19 | 19 | |
20 | 20 | // Define constants. |
21 | -if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
21 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
22 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
23 | 23 | } |
24 | 24 | |
25 | -if ( ! defined( 'WPINV_VERSION' ) ) { |
|
26 | - define( 'WPINV_VERSION', '2.8.2' ); |
|
25 | +if (!defined('WPINV_VERSION')) { |
|
26 | + define('WPINV_VERSION', '2.8.2'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // Include the main Invoicing class. |
30 | -if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
|
31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
30 | +if (!class_exists('WPInv_Plugin', false)) { |
|
31 | + require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php'; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function getpaid() { |
41 | 41 | |
42 | - if ( empty( $GLOBALS['invoicing'] ) ) { |
|
42 | + if (empty($GLOBALS['invoicing'])) { |
|
43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
44 | 44 | } |
45 | 45 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @since 2.0.8 |
53 | 53 | */ |
54 | 54 | function getpaid_deactivation_hook() { |
55 | - update_option( 'wpinv_flush_permalinks', 1 ); |
|
55 | + update_option('wpinv_flush_permalinks', 1); |
|
56 | 56 | } |
57 | -register_deactivation_hook( __FILE__, 'getpaid_deactivation_hook' ); |
|
57 | +register_deactivation_hook(__FILE__, 'getpaid_deactivation_hook'); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @deprecated |
@@ -64,4 +64,4 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | // Kickstart the plugin. |
67 | -add_action( 'plugins_loaded', 'getpaid', -100 ); |
|
67 | +add_action('plugins_loaded', 'getpaid', -100); |