Passed
Push — master ( de43a2...6374db )
by Brian
05:18
created
includes/class-wpinv-ajax.php 1 patch
Spacing   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * WPInv_Ajax class.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	 * Hook in ajax handlers.
18 18
 	 */
19 19
 	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
20
+		add_action('init', array(__CLASS__, 'define_ajax'), 0);
21
+		add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0);
22 22
 		self::add_ajax_events();
23 23
     }
24 24
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function define_ajax() {
29 29
 
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
30
+		if (!empty($_GET['wpinv-ajax'])) {
31
+			getpaid_maybe_define_constant('DOING_AJAX', true);
32
+			getpaid_maybe_define_constant('WPInv_DOING_AJAX', true);
33
+			if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) {
34
+				/** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0);
35 35
 			}
36 36
 			$GLOBALS['wpdb']->hide_errors();
37 37
 		}
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	 * @since 1.0.18
45 45
 	 */
46 46
 	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
47
+		if (!headers_sent()) {
48 48
 			send_origin_headers();
49 49
 			send_nosniff_header();
50 50
 			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
51
+			header('Content-Type: text/html; charset=' . get_option('blog_charset'));
52
+			header('X-Robots-Tag: noindex');
53
+			status_header(200);
54 54
 		}
55 55
     }
56 56
     
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 	public static function do_wpinv_ajax() {
61 61
 		global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
63
+		if (!empty($_GET['wpinv-ajax'])) {
64
+			$wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax'])));
65 65
 		}
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+		$action = $wp_query->get('wpinv-ajax');
68 68
 
69
-		if ( $action ) {
69
+		if ($action) {
70 70
 			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
71
+			$action = sanitize_text_field($action);
72
+			do_action('wpinv_ajax_' . $action);
73 73
 			wp_die();
74 74
 		}
75 75
 
@@ -102,36 +102,36 @@  discard block
 block discarded – undo
102 102
             'ip_geolocation'              => true,
103 103
         );
104 104
 
105
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
106
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
107
-            add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
105
+        foreach ($ajax_events as $ajax_event => $nopriv) {
106
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
107
+            add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
108 108
 
109
-            if ( $nopriv ) {
110
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
111
-                add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
112
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
109
+            if ($nopriv) {
110
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
111
+                add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
112
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
113 113
             }
114 114
         }
115 115
     }
116 116
     
117 117
     public static function add_note() {
118
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
118
+        check_ajax_referer('add-invoice-note', '_nonce');
119 119
 
120
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
120
+        if (!wpinv_current_user_can_manage_invoicing()) {
121 121
             die(-1);
122 122
         }
123 123
 
124
-        $post_id   = absint( $_POST['post_id'] );
125
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
126
-        $note_type = sanitize_text_field( $_POST['note_type'] );
124
+        $post_id   = absint($_POST['post_id']);
125
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
126
+        $note_type = sanitize_text_field($_POST['note_type']);
127 127
 
128 128
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
129 129
 
130
-        if ( $post_id > 0 ) {
131
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
130
+        if ($post_id > 0) {
131
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
132 132
 
133
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
134
-                wpinv_get_invoice_note_line_item( $note_id );
133
+            if ($note_id > 0 && !is_wp_error($note_id)) {
134
+                wpinv_get_invoice_note_line_item($note_id);
135 135
             }
136 136
         }
137 137
 
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
     }
140 140
 
141 141
     public static function delete_note() {
142
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
142
+        check_ajax_referer('delete-invoice-note', '_nonce');
143 143
 
144
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
144
+        if (!wpinv_current_user_can_manage_invoicing()) {
145 145
             die(-1);
146 146
         }
147 147
 
148
-        $note_id = (int)$_POST['note_id'];
148
+        $note_id = (int) $_POST['note_id'];
149 149
 
150
-        if ( $note_id > 0 ) {
151
-            wp_delete_comment( $note_id, true );
150
+        if ($note_id > 0) {
151
+            wp_delete_comment($note_id, true);
152 152
         }
153 153
 
154 154
         die();
@@ -166,34 +166,34 @@  discard block
 block discarded – undo
166 166
     public static function get_billing_details() {
167 167
 
168 168
         // Verify nonce.
169
-        check_ajax_referer( 'wpinv-nonce' );
169
+        check_ajax_referer('wpinv-nonce');
170 170
 
171 171
         // Can the user manage the plugin?
172
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
172
+        if (!wpinv_current_user_can_manage_invoicing()) {
173 173
             die(-1);
174 174
         }
175 175
 
176 176
         // Do we have a user id?
177 177
         $user_id = $_GET['user_id'];
178 178
 
179
-        if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
179
+        if (empty($user_id) || !is_numeric($user_id)) {
180 180
             die(-1);
181 181
         }
182 182
 
183 183
         // Fetch the billing details.
184
-        $billing_details    = wpinv_get_user_address( $user_id );
185
-        $billing_details    = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id );
184
+        $billing_details    = wpinv_get_user_address($user_id);
185
+        $billing_details    = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id);
186 186
 
187 187
         // unset the user id and email.
188
-        $to_ignore = array( 'user_id', 'email' );
188
+        $to_ignore = array('user_id', 'email');
189 189
 
190
-        foreach ( $to_ignore as $key ) {
191
-            if ( isset( $billing_details[ $key ] ) ) {
192
-                unset( $billing_details[ $key ] );
190
+        foreach ($to_ignore as $key) {
191
+            if (isset($billing_details[$key])) {
192
+                unset($billing_details[$key]);
193 193
             }
194 194
         }
195 195
 
196
-        wp_send_json_success( $billing_details );
196
+        wp_send_json_success($billing_details);
197 197
 
198 198
     }
199 199
 
@@ -203,47 +203,47 @@  discard block
 block discarded – undo
203 203
     public static function check_new_user_email() {
204 204
 
205 205
         // Verify nonce.
206
-        check_ajax_referer( 'wpinv-nonce' );
206
+        check_ajax_referer('wpinv-nonce');
207 207
 
208 208
         // Can the user manage the plugin?
209
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
209
+        if (!wpinv_current_user_can_manage_invoicing()) {
210 210
             die(-1);
211 211
         }
212 212
 
213 213
         // We need an email address.
214
-        if ( empty( $_GET['email'] ) ) {
215
-            _e( "Provide the new user's email address", 'invoicing' );
214
+        if (empty($_GET['email'])) {
215
+            _e("Provide the new user's email address", 'invoicing');
216 216
             exit;
217 217
         }
218 218
 
219 219
         // Ensure the email is valid.
220
-        $email = sanitize_text_field( $_GET['email'] );
221
-        if ( ! is_email( $email ) ) {
222
-            _e( 'Invalid email address', 'invoicing' );
220
+        $email = sanitize_text_field($_GET['email']);
221
+        if (!is_email($email)) {
222
+            _e('Invalid email address', 'invoicing');
223 223
             exit;
224 224
         }
225 225
 
226 226
         // And it does not exist.
227
-        if ( email_exists( $email ) ) {
228
-            _e( 'A user with this email address already exists', 'invoicing' );
227
+        if (email_exists($email)) {
228
+            _e('A user with this email address already exists', 'invoicing');
229 229
             exit;
230 230
         }
231 231
 
232
-        wp_send_json_success( true );
232
+        wp_send_json_success(true);
233 233
     }
234 234
     
235 235
     public static function run_tool() {
236
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
237
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
236
+        check_ajax_referer('wpinv-nonce', '_nonce');
237
+        if (!wpinv_current_user_can_manage_invoicing()) {
238 238
             die(-1);
239 239
         }
240 240
         
241
-        $tool = sanitize_text_field( $_POST['tool'] );
241
+        $tool = sanitize_text_field($_POST['tool']);
242 242
         
243
-        do_action( 'wpinv_run_tool' );
243
+        do_action('wpinv_run_tool');
244 244
         
245
-        if ( !empty( $tool ) ) {
246
-            do_action( 'wpinv_tool_' . $tool );
245
+        if (!empty($tool)) {
246
+            do_action('wpinv_tool_' . $tool);
247 247
         }
248 248
     }
249 249
 
@@ -253,30 +253,30 @@  discard block
 block discarded – undo
253 253
     public static function get_payment_form() {
254 254
 
255 255
         // Check nonce.
256
-        if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'getpaid_ajax_form' ) ) {
257
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
256
+        if (!isset($_GET['nonce']) || !wp_verify_nonce($_GET['nonce'], 'getpaid_ajax_form')) {
257
+            _e('Error: Reload the page and try again.', 'invoicing');
258 258
             exit;
259 259
         }
260 260
 
261 261
         // Is the request set up correctly?
262
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
262
+		if (empty($_GET['form']) && empty($_GET['item'])) {
263 263
 			echo aui()->alert(
264 264
 				array(
265 265
 					'type'    => 'warning',
266
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
266
+					'content' => __('No payment form or item provided', 'invoicing'),
267 267
 				)
268 268
             );
269 269
             exit;
270 270
         }
271 271
 
272 272
         // Payment form or button?
273
-		if ( ! empty( $_GET['form'] ) ) {
274
-            getpaid_display_payment_form( $_GET['form'] );
275
-		} else if( ! empty( $_GET['invoice'] ) ) {
276
-		    getpaid_display_invoice_payment_form( $_GET['invoice'] );
273
+		if (!empty($_GET['form'])) {
274
+            getpaid_display_payment_form($_GET['form']);
275
+		} else if (!empty($_GET['invoice'])) {
276
+		    getpaid_display_invoice_payment_form($_GET['invoice']);
277 277
         } else {
278
-			$items = getpaid_convert_items_to_array( $_GET['item'] );
279
-		    getpaid_display_item_payment_form( $items );
278
+			$items = getpaid_convert_items_to_array($_GET['item']);
279
+		    getpaid_display_item_payment_form($items);
280 280
         }
281 281
 
282 282
         exit;
@@ -291,17 +291,17 @@  discard block
 block discarded – undo
291 291
     public static function payment_form() {
292 292
 
293 293
         // Check nonce.
294
-        check_ajax_referer( 'getpaid_form_nonce' );
294
+        check_ajax_referer('getpaid_form_nonce');
295 295
 
296 296
         // ... form fields...
297
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
298
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
297
+        if (empty($_POST['getpaid_payment_form_submission'])) {
298
+            _e('Error: Reload the page and try again.', 'invoicing');
299 299
             exit;
300 300
         }
301 301
 
302 302
         // Process the payment form.
303
-        $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' );
304
-        $checkout       = new $checkout_class( new GetPaid_Payment_Form_Submission() );
303
+        $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout');
304
+        $checkout       = new $checkout_class(new GetPaid_Payment_Form_Submission());
305 305
         $checkout->process_checkout();
306 306
 
307 307
         exit;
@@ -314,53 +314,53 @@  discard block
 block discarded – undo
314 314
      */
315 315
     public static function get_payment_form_states_field() {
316 316
 
317
-        if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) {
317
+        if (empty($_GET['country']) || empty($_GET['form'])) {
318 318
             exit;
319 319
         }
320 320
 
321
-        $elements = getpaid_get_payment_form_elements( $_GET['form'] );
321
+        $elements = getpaid_get_payment_form_elements($_GET['form']);
322 322
 
323
-        if ( empty( $elements ) ) {
323
+        if (empty($elements)) {
324 324
             exit;
325 325
         }
326 326
 
327 327
         $address_fields = array();
328
-        foreach ( $elements as $element ) {
329
-            if ( 'address' === $element['type'] ) {
328
+        foreach ($elements as $element) {
329
+            if ('address' === $element['type']) {
330 330
                 $address_fields = $element;
331 331
                 break;
332 332
             }
333 333
         }
334 334
 
335
-        if ( empty( $address_fields ) ) {
335
+        if (empty($address_fields)) {
336 336
             exit;
337 337
         }
338 338
 
339
-        foreach ( $address_fields['fields'] as $address_field ) {
339
+        foreach ($address_fields['fields'] as $address_field) {
340 340
 
341
-            if ( 'wpinv_state' == $address_field['name'] ) {
341
+            if ('wpinv_state' == $address_field['name']) {
342 342
 
343
-                $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
344
-                $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
345
-                $value       = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : '';
346
-                $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
343
+                $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
344
+                $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
345
+                $value       = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : '';
346
+                $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
347 347
 
348
-                if ( ! empty( $address_field['required'] ) ) {
348
+                if (!empty($address_field['required'])) {
349 349
                     $label .= "<span class='text-danger'> *</span>";
350 350
                 }
351 351
 
352
-                $states = wpinv_get_country_states( $_GET['country'] );
352
+                $states = wpinv_get_country_states($_GET['country']);
353 353
 
354
-                if ( ! empty( $states ) ) {
354
+                if (!empty($states)) {
355 355
 
356
-                    $html = aui()->select( array(
356
+                    $html = aui()->select(array(
357 357
                         'options'          => $states,
358 358
                         'name'             => 'wpinv_state',
359 359
                         'id'               => 'wpinv_state' . uniqid(),
360
-                        'value'            => sanitize_text_field( $value ),
360
+                        'value'            => sanitize_text_field($value),
361 361
                         'placeholder'      => $placeholder,
362
-                        'required'         => ! empty( $address_field['required'] ),
363
-                        'label'            => wp_kses_post( $label ),
362
+                        'required'         => !empty($address_field['required']),
363
+                        'label'            => wp_kses_post($label),
364 364
                         'label_type'       => 'vertical',
365 365
                         'help_text'        => $description,
366 366
                         'class'            => 'wpinv_state',
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
                             'name'       => 'wpinv_state',
374 374
                             'id'         => 'wpinv_state' . uniqid(),
375 375
                             'placeholder'=> $placeholder,
376
-                            'required'   => ! empty( $address_field['required'] ),
377
-                            'label'      => wp_kses_post( $label ),
376
+                            'required'   => !empty($address_field['required']),
377
+                            'label'      => wp_kses_post($label),
378 378
                             'label_type' => 'vertical',
379 379
                             'help_text'  => $description,
380 380
                             'value'      => $value,
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 
385 385
                 }
386 386
 
387
-                wp_send_json_success( $html );
387
+                wp_send_json_success($html);
388 388
                 exit;
389 389
 
390 390
             }
@@ -400,56 +400,56 @@  discard block
 block discarded – undo
400 400
     public static function recalculate_invoice_totals() {
401 401
 
402 402
         // Verify nonce.
403
-        check_ajax_referer( 'wpinv-nonce' );
403
+        check_ajax_referer('wpinv-nonce');
404 404
 
405
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
405
+        if (!wpinv_current_user_can_manage_invoicing()) {
406 406
             exit;
407 407
         }
408 408
 
409 409
         // We need an invoice.
410
-        if ( empty( $_POST['post_id'] ) ) {
410
+        if (empty($_POST['post_id'])) {
411 411
             exit;
412 412
         }
413 413
 
414 414
         // Fetch the invoice.
415
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
415
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
416 416
 
417 417
         // Ensure it exists.
418
-        if ( ! $invoice->get_id() ) {
418
+        if (!$invoice->get_id()) {
419 419
             exit;
420 420
         }
421 421
 
422 422
         // Maybe set the country, state, currency.
423
-        foreach ( array( 'country', 'state', 'currency' ) as $key ) {
424
-            if ( isset( $_POST[ $key ] ) ) {
423
+        foreach (array('country', 'state', 'currency') as $key) {
424
+            if (isset($_POST[$key])) {
425 425
                 $method = "set_$key";
426
-                $invoice->$method( $_POST[ $key ] );
426
+                $invoice->$method($_POST[$key]);
427 427
             }
428 428
         }
429 429
 
430 430
         // Maybe disable taxes.
431
-        $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) );
431
+        $invoice->set_disable_taxes(!empty($_POST['taxes']));
432 432
 
433 433
         // Recalculate totals.
434 434
         $invoice->recalculate_total();
435 435
 
436
-        $total = wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() );
436
+        $total = wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency());
437 437
 
438
-        if ( $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) {
439
-            $recurring_total = wpinv_price( wpinv_format_amount( $invoice->get_recurring_total() ), $invoice->get_currency() );
440
-            $total          .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>';
438
+        if ($invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) {
439
+            $recurring_total = wpinv_price(wpinv_format_amount($invoice->get_recurring_total()), $invoice->get_currency());
440
+            $total          .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>';
441 441
         }
442 442
 
443 443
         $totals = array(
444
-            'subtotal' => wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ),
445
-            'discount' => wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ),
446
-            'tax'      => wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ),
444
+            'subtotal' => wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()),
445
+            'discount' => wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()),
446
+            'tax'      => wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()),
447 447
             'total'    => $total,
448 448
         );
449 449
 
450
-        $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice );
450
+        $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice);
451 451
 
452
-        wp_send_json_success( compact( 'totals' ) );
452
+        wp_send_json_success(compact('totals'));
453 453
     }
454 454
 
455 455
     /**
@@ -458,33 +458,33 @@  discard block
 block discarded – undo
458 458
     public static function get_invoice_items() {
459 459
 
460 460
         // Verify nonce.
461
-        check_ajax_referer( 'wpinv-nonce' );
461
+        check_ajax_referer('wpinv-nonce');
462 462
 
463
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
463
+        if (!wpinv_current_user_can_manage_invoicing()) {
464 464
             exit;
465 465
         }
466 466
 
467 467
         // We need an invoice and items.
468
-        if ( empty( $_POST['post_id'] ) ) {
468
+        if (empty($_POST['post_id'])) {
469 469
             exit;
470 470
         }
471 471
 
472 472
         // Fetch the invoice.
473
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
473
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
474 474
 
475 475
         // Ensure it exists.
476
-        if ( ! $invoice->get_id() ) {
476
+        if (!$invoice->get_id()) {
477 477
             exit;
478 478
         }
479 479
 
480 480
         // Return an array of invoice items.
481 481
         $items = array();
482 482
 
483
-        foreach ( $invoice->get_items() as $item_id => $item ) {
484
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
483
+        foreach ($invoice->get_items() as $item_id => $item) {
484
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
485 485
         }
486 486
 
487
-        wp_send_json_success( compact( 'items' ) );
487
+        wp_send_json_success(compact('items'));
488 488
     }
489 489
 
490 490
     /**
@@ -493,50 +493,50 @@  discard block
 block discarded – undo
493 493
     public static function edit_invoice_item() {
494 494
 
495 495
         // Verify nonce.
496
-        check_ajax_referer( 'wpinv-nonce' );
496
+        check_ajax_referer('wpinv-nonce');
497 497
 
498
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
498
+        if (!wpinv_current_user_can_manage_invoicing()) {
499 499
             exit;
500 500
         }
501 501
 
502 502
         // We need an invoice and item details.
503
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) {
503
+        if (empty($_POST['post_id']) || empty($_POST['data'])) {
504 504
             exit;
505 505
         }
506 506
 
507 507
         // Fetch the invoice.
508
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
508
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
509 509
 
510 510
         // Ensure it exists and its not been paid for.
511
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
511
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
512 512
             exit;
513 513
         }
514 514
 
515 515
         // Format the data.
516
-        $data = wp_list_pluck( $_POST['data'], 'value', 'field' );
516
+        $data = wp_list_pluck($_POST['data'], 'value', 'field');
517 517
 
518 518
         // Ensure that we have an item id.
519
-        if ( empty( $data['id'] ) ) {
519
+        if (empty($data['id'])) {
520 520
             exit;
521 521
         }
522 522
 
523 523
         // Abort if the invoice does not have the specified item.
524
-        $item = $invoice->get_item( (int) $data['id'] );
524
+        $item = $invoice->get_item((int) $data['id']);
525 525
 
526
-        if ( empty( $item ) ) {
526
+        if (empty($item)) {
527 527
             exit;
528 528
         }
529 529
 
530 530
         // Update the item.
531
-        $item->set_price( $data['price'] );
532
-        $item->set_name( $data['name'] );
533
-        $item->set_description( $data['description'] );
534
-        $item->set_quantity( $data['quantity'] );
531
+        $item->set_price($data['price']);
532
+        $item->set_name($data['name']);
533
+        $item->set_description($data['description']);
534
+        $item->set_quantity($data['quantity']);
535 535
 
536 536
         // Add it to the invoice.
537
-        $error = $invoice->add_item( $item );
537
+        $error = $invoice->add_item($item);
538 538
         $alert = false;
539
-        if ( is_wp_error( $error ) ) {
539
+        if (is_wp_error($error)) {
540 540
             $alert = $error->get_error_message();
541 541
         }
542 542
 
@@ -549,11 +549,11 @@  discard block
 block discarded – undo
549 549
         // Return an array of invoice items.
550 550
         $items = array();
551 551
 
552
-        foreach ( $invoice->get_items() as $item_id => $item ) {
553
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
552
+        foreach ($invoice->get_items() as $item_id => $item) {
553
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
554 554
         }
555 555
 
556
-        wp_send_json_success( compact( 'items', 'alert' ) );
556
+        wp_send_json_success(compact('items', 'alert'));
557 557
     }
558 558
 
559 559
     /**
@@ -562,33 +562,33 @@  discard block
 block discarded – undo
562 562
     public static function remove_invoice_item() {
563 563
 
564 564
         // Verify nonce.
565
-        check_ajax_referer( 'wpinv-nonce' );
565
+        check_ajax_referer('wpinv-nonce');
566 566
 
567
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
567
+        if (!wpinv_current_user_can_manage_invoicing()) {
568 568
             exit;
569 569
         }
570 570
 
571 571
         // We need an invoice and an item.
572
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) {
572
+        if (empty($_POST['post_id']) || empty($_POST['item_id'])) {
573 573
             exit;
574 574
         }
575 575
 
576 576
         // Fetch the invoice.
577
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
577
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
578 578
 
579 579
         // Ensure it exists and its not been paid for.
580
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
580
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
581 581
             exit;
582 582
         }
583 583
 
584 584
         // Abort if the invoice does not have the specified item.
585
-        $item = $invoice->get_item( (int) $_POST['item_id'] );
585
+        $item = $invoice->get_item((int) $_POST['item_id']);
586 586
 
587
-        if ( empty( $item ) ) {
587
+        if (empty($item)) {
588 588
             exit;
589 589
         }
590 590
 
591
-        $invoice->remove_item( (int) $_POST['item_id'] );
591
+        $invoice->remove_item((int) $_POST['item_id']);
592 592
 
593 593
         // Update totals.
594 594
         $invoice->recalculate_total();
@@ -599,11 +599,11 @@  discard block
 block discarded – undo
599 599
         // Return an array of invoice items.
600 600
         $items = array();
601 601
 
602
-        foreach ( $invoice->get_items() as $item_id => $item ) {
603
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
602
+        foreach ($invoice->get_items() as $item_id => $item) {
603
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
604 604
         }
605 605
 
606
-        wp_send_json_success( compact( 'items' ) );
606
+        wp_send_json_success(compact('items'));
607 607
     }
608 608
 
609 609
     /**
@@ -612,39 +612,39 @@  discard block
 block discarded – undo
612 612
     public static function add_invoice_items() {
613 613
 
614 614
         // Verify nonce.
615
-        check_ajax_referer( 'wpinv-nonce' );
615
+        check_ajax_referer('wpinv-nonce');
616 616
 
617
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
617
+        if (!wpinv_current_user_can_manage_invoicing()) {
618 618
             exit;
619 619
         }
620 620
 
621 621
         // We need an invoice and items.
622
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) {
622
+        if (empty($_POST['post_id']) || empty($_POST['items'])) {
623 623
             exit;
624 624
         }
625 625
 
626 626
         // Fetch the invoice.
627
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
627
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
628 628
         $alert   = false;
629 629
 
630 630
         // Ensure it exists and its not been paid for.
631
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
631
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
632 632
             exit;
633 633
         }
634 634
 
635 635
         // Add the items.
636
-        foreach ( $_POST['items'] as $data ) {
636
+        foreach ($_POST['items'] as $data) {
637 637
 
638
-            $item = new GetPaid_Form_Item( $data[ 'id' ] );
638
+            $item = new GetPaid_Form_Item($data['id']);
639 639
 
640
-            if ( is_numeric( $data[ 'qty' ] ) && (int) $data[ 'qty' ] > 0 ) {
641
-                $item->set_quantity( $data[ 'qty' ] );
640
+            if (is_numeric($data['qty']) && (int) $data['qty'] > 0) {
641
+                $item->set_quantity($data['qty']);
642 642
             }
643 643
 
644
-            if ( $item->get_id() > 0 ) {
645
-                $error = $invoice->add_item( $item );
644
+            if ($item->get_id() > 0) {
645
+                $error = $invoice->add_item($item);
646 646
 
647
-                if ( is_wp_error( $error ) ) {
647
+                if (is_wp_error($error)) {
648 648
                     $alert = $error->get_error_message();
649 649
                 }
650 650
 
@@ -659,11 +659,11 @@  discard block
 block discarded – undo
659 659
         // Return an array of invoice items.
660 660
         $items = array();
661 661
 
662
-        foreach ( $invoice->get_items() as $item_id => $item ) {
663
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() );
662
+        foreach ($invoice->get_items() as $item_id => $item) {
663
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
664 664
         }
665 665
 
666
-        wp_send_json_success( compact( 'items', 'alert' ) );
666
+        wp_send_json_success(compact('items', 'alert'));
667 667
     }
668 668
 
669 669
     /**
@@ -672,15 +672,15 @@  discard block
 block discarded – undo
672 672
     public static function get_invoicing_items() {
673 673
 
674 674
         // Verify nonce.
675
-        check_ajax_referer( 'wpinv-nonce' );
675
+        check_ajax_referer('wpinv-nonce');
676 676
 
677
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
677
+        if (!wpinv_current_user_can_manage_invoicing()) {
678 678
             exit;
679 679
         }
680 680
 
681 681
         // We need a search term.
682
-        if ( empty( $_GET['search'] ) ) {
683
-            wp_send_json_success( array() );
682
+        if (empty($_GET['search'])) {
683
+            wp_send_json_success(array());
684 684
         }
685 685
 
686 686
         // Retrieve items.
@@ -689,8 +689,8 @@  discard block
 block discarded – undo
689 689
             'orderby'        => 'title',
690 690
             'order'          => 'ASC',
691 691
             'posts_per_page' => -1,
692
-            'post_status'    => array( 'publish' ),
693
-            's'              => trim( $_GET['search'] ),
692
+            'post_status'    => array('publish'),
693
+            's'              => trim($_GET['search']),
694 694
             'meta_query'     => array(
695 695
                 array(
696 696
                     'key'       => '_wpinv_type',
@@ -700,22 +700,22 @@  discard block
 block discarded – undo
700 700
             )
701 701
         );
702 702
 
703
-        $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) );
703
+        $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args));
704 704
         $data  = array();
705 705
 
706 706
 
707
-        $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( $_GET['post_id'] ) );
707
+        $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type($_GET['post_id']));
708 708
 
709
-        foreach ( $items as $item ) {
710
-            $item      = new GetPaid_Form_Item( $item );
709
+        foreach ($items as $item) {
710
+            $item = new GetPaid_Form_Item($item);
711 711
             $data[] = array(
712 712
                 'id'        => (int) $item->get_id(),
713
-                'text'      => strip_tags( $item->get_name() ),
714
-                'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '',
713
+                'text'      => strip_tags($item->get_name()),
714
+                'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '',
715 715
             );
716 716
         }
717 717
 
718
-        wp_send_json_success( $data );
718
+        wp_send_json_success($data);
719 719
 
720 720
     }
721 721
 
@@ -725,24 +725,24 @@  discard block
 block discarded – undo
725 725
     public static function get_aui_states_field() {
726 726
 
727 727
         // Verify nonce.
728
-        check_ajax_referer( 'wpinv-nonce' );
728
+        check_ajax_referer('wpinv-nonce');
729 729
 
730 730
         // We need a country.
731
-        if ( empty( $_GET['country'] ) ) {
731
+        if (empty($_GET['country'])) {
732 732
             exit;
733 733
         }
734 734
 
735
-        $states = wpinv_get_country_states( trim( $_GET['country'] ) );
736
-        $state  = isset( $_GET['state'] ) ? trim( $_GET['state'] ) : wpinv_get_default_state();
735
+        $states = wpinv_get_country_states(trim($_GET['country']));
736
+        $state  = isset($_GET['state']) ? trim($_GET['state']) : wpinv_get_default_state();
737 737
 
738
-        if ( empty( $states ) ) {
738
+        if (empty($states)) {
739 739
 
740 740
             $html = aui()->input(
741 741
                 array(
742 742
                     'type'        => 'text',
743 743
                     'id'          => 'wpinv_state',
744 744
                     'name'        => 'wpinv_state',
745
-                    'label'       => __( 'State', 'invoicing' ),
745
+                    'label'       => __('State', 'invoicing'),
746 746
                     'label_type'  => 'vertical',
747 747
                     'placeholder' => 'Liège',
748 748
                     'class'       => 'form-control-sm',
@@ -756,9 +756,9 @@  discard block
 block discarded – undo
756 756
                 array(
757 757
                     'id'          => 'wpinv_state',
758 758
                     'name'        => 'wpinv_state',
759
-                    'label'       => __( 'State', 'invoicing' ),
759
+                    'label'       => __('State', 'invoicing'),
760 760
                     'label_type'  => 'vertical',
761
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
761
+                    'placeholder' => __('Select a state', 'invoicing'),
762 762
                     'class'       => 'form-control-sm',
763 763
                     'value'       => $state,
764 764
                     'options'     => $states,
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
         wp_send_json_success(
773 773
             array(
774 774
                 'html'   => $html,
775
-                'select' => ! empty ( $states )
775
+                'select' => !empty ($states)
776 776
             )
777 777
         );
778 778
 
@@ -786,46 +786,46 @@  discard block
 block discarded – undo
786 786
     public static function ip_geolocation() {
787 787
 
788 788
         // Check nonce.
789
-        check_ajax_referer( 'getpaid-ip-location' );
789
+        check_ajax_referer('getpaid-ip-location');
790 790
 
791 791
         // IP address.
792
-        if ( empty( $_GET['ip'] ) || ! rest_is_ip_address( $_GET['ip'] ) ) {
793
-            _e( 'Invalid IP Address.', 'invoicing' );
792
+        if (empty($_GET['ip']) || !rest_is_ip_address($_GET['ip'])) {
793
+            _e('Invalid IP Address.', 'invoicing');
794 794
             exit;
795 795
         }
796 796
 
797 797
         // Retrieve location info.
798
-        $location = getpaid_geolocate_ip_address( $_GET['ip'] );
798
+        $location = getpaid_geolocate_ip_address($_GET['ip']);
799 799
 
800
-        if ( empty( $location ) ) {
801
-            _e( 'Unable to find geolocation for the IP Address.', 'invoicing' );
800
+        if (empty($location)) {
801
+            _e('Unable to find geolocation for the IP Address.', 'invoicing');
802 802
             exit;
803 803
         }
804 804
 
805 805
         // Sorry.
806
-        extract( $location );
806
+        extract($location);
807 807
 
808 808
         // Prepare the address.
809 809
         $content = '';
810 810
 
811
-        if ( ! empty( $location['city'] ) ) {
812
-            $content .=  $location['city']  . ', ';
811
+        if (!empty($location['city'])) {
812
+            $content .= $location['city'] . ', ';
813 813
         }
814 814
         
815
-        if ( ! empty( $location['region'] ) ) {
816
-            $content .=  $location['region']  . ', ';
815
+        if (!empty($location['region'])) {
816
+            $content .= $location['region'] . ', ';
817 817
         }
818 818
         
819
-        $content .=  $location['country'] . ' (' . $location['iso'] . ')';
819
+        $content .= $location['country'] . ' (' . $location['iso'] . ')';
820 820
 
821 821
         $location['address'] = $content;
822 822
 
823
-        $content  = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $content ) . '</p>';
824
-        $content .= '<p>'. $location['credit'] . '</p>';
823
+        $content  = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $content) . '</p>';
824
+        $content .= '<p>' . $location['credit'] . '</p>';
825 825
 
826 826
         $location['content'] = $content;
827 827
 
828
-        wpinv_get_template( 'geolocation.php', $location );
828
+        wpinv_get_template('geolocation.php', $location);
829 829
 
830 830
         exit;
831 831
     }
@@ -838,11 +838,11 @@  discard block
 block discarded – undo
838 838
     public static function payment_form_refresh_prices() {
839 839
 
840 840
         // Check nonce.
841
-        check_ajax_referer( 'getpaid_form_nonce' );
841
+        check_ajax_referer('getpaid_form_nonce');
842 842
 
843 843
         // ... form fields...
844
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
845
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
844
+        if (empty($_POST['getpaid_payment_form_submission'])) {
845
+            _e('Error: Reload the page and try again.', 'invoicing');
846 846
             exit;
847 847
         }
848 848
 
@@ -850,18 +850,18 @@  discard block
 block discarded – undo
850 850
         $submission = new GetPaid_Payment_Form_Submission();
851 851
 
852 852
         // Do we have an error?
853
-        if ( ! empty( $submission->last_error ) ) {
853
+        if (!empty($submission->last_error)) {
854 854
             echo $submission->last_error;
855 855
             exit;
856 856
         }
857 857
 
858 858
         // Prepare the response.
859
-        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission );
859
+        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission);
860 860
         
861 861
         // Filter the response.
862
-        $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission );
862
+        $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission);
863 863
 
864
-        wp_send_json_success( $response );
864
+        wp_send_json_success($response);
865 865
     }
866 866
 
867 867
 }
Please login to merge, or discard this patch.
templates/emails/invoice-item.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,67 +10,67 @@  discard block
 block discarded – undo
10 10
  * @var array $columns
11 11
  */
12 12
 
13
-defined( 'ABSPATH' ) || exit;
13
+defined('ABSPATH') || exit;
14 14
 
15 15
 ?>
16 16
 
17
-<?php do_action( 'getpaid_before_email_line_item', $invoice, $item ); ?>
17
+<?php do_action('getpaid_before_email_line_item', $invoice, $item); ?>
18 18
 
19
-<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class( $item->get_type() ); ?>">
19
+<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class($item->get_type()); ?>">
20 20
 
21
-    <?php foreach ( array_keys( $columns ) as $column ): ?>
21
+    <?php foreach (array_keys($columns) as $column): ?>
22 22
 
23
-        <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>">
23
+        <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>">
24 24
             
25 25
             <?php
26 26
 
27 27
                 // Fires before printing a line item column.
28
-                do_action( "getpaid_email_line_item_before_$column", $item, $invoice );
28
+                do_action("getpaid_email_line_item_before_$column", $item, $invoice);
29 29
 
30 30
                 // Item name.
31
-                if ( 'name' == $column ) {
31
+                if ('name' == $column) {
32 32
 
33 33
                     // Display the name.
34
-                    echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $item->get_name() ) . '</div>';
34
+                    echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($item->get_name()) . '</div>';
35 35
 
36 36
                     // And an optional description.
37 37
                     $description = $item->get_description();
38 38
 
39
-                    if ( ! empty( $description ) ) {
40
-                        $description = wp_kses_post( $description );
39
+                    if (!empty($description)) {
40
+                        $description = wp_kses_post($description);
41 41
                         echo "<p class='small'>$description</p>";
42 42
                     }
43 43
 
44 44
                     // Price help text
45
-                    $description = getpaid_item_recurring_price_help_text( $item, $invoice->get_currency() );
46
-                    if ( $description ) {
45
+                    $description = getpaid_item_recurring_price_help_text($item, $invoice->get_currency());
46
+                    if ($description) {
47 47
                         echo "<p class='small'>$description</p>";
48 48
                     }
49 49
 
50 50
                 }
51 51
 
52 52
                 // Item price.
53
-                if ( 'price' == $column ) {
53
+                if ('price' == $column) {
54 54
 
55 55
                     // Display the item price (or recurring price if this is a renewal invoice)
56 56
                     $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price();
57
-                    echo wpinv_price( $price );
57
+                    echo wpinv_price($price);
58 58
 
59 59
                 }
60 60
 
61 61
                 // Item quantity.
62
-                if ( 'quantity' == $column ) {
62
+                if ('quantity' == $column) {
63 63
                     echo (int) $item->get_quantity();
64 64
                 }
65 65
 
66 66
                 // Item sub total.
67
-                if ( 'subtotal' == $column ) {
67
+                if ('subtotal' == $column) {
68 68
                     $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total();
69
-                    echo wpinv_price( $subtotal );
69
+                    echo wpinv_price($subtotal);
70 70
                 }
71 71
 
72 72
                 // Fires when printing a line item column.
73
-                do_action( "getpaid_email_line_item_$column", $item, $invoice );
73
+                do_action("getpaid_email_line_item_$column", $item, $invoice);
74 74
 
75 75
             ?>
76 76
 
@@ -80,4 +80,4 @@  discard block
 block discarded – undo
80 80
 
81 81
 </tr>
82 82
 
83
-<?php do_action( 'getpaid_after_email_line_item', $invoice, $item ); ?>
83
+<?php do_action('getpaid_after_email_line_item', $invoice, $item); ?>
Please login to merge, or discard this patch.
templates/emails/fee-item.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,63 +10,63 @@  discard block
 block discarded – undo
10 10
  * @var array $columns
11 11
  */
12 12
 
13
-defined( 'ABSPATH' ) || exit;
13
+defined('ABSPATH') || exit;
14 14
 
15 15
 ?>
16 16
 
17
-<?php do_action( 'getpaid_before_email_fee_item', $invoice, $fee ); ?>
17
+<?php do_action('getpaid_before_email_fee_item', $invoice, $fee); ?>
18 18
 
19 19
 <tr class="wpinv_cart_item item-fee">
20 20
 
21
-    <?php foreach ( array_keys( $columns ) as $column ): ?>
21
+    <?php foreach (array_keys($columns) as $column): ?>
22 22
 
23
-        <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>">
23
+        <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>">
24 24
             
25 25
             <?php
26 26
 
27 27
                 // Fires before printing a fee item column.
28
-                do_action( "getpaid_email_fee_item_before_$column", $fee, $invoice );
28
+                do_action("getpaid_email_fee_item_before_$column", $fee, $invoice);
29 29
 
30 30
                 // Item name.
31
-                if ( 'name' == $column ) {
31
+                if ('name' == $column) {
32 32
 
33 33
                     // Display the name.
34
-                    echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $fee['name'] ) . '</div>';
34
+                    echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($fee['name']) . '</div>';
35 35
 
36 36
                     // And an optional description.
37
-                    $description = esc_html__( 'Fee', 'invoicing' );
37
+                    $description = esc_html__('Fee', 'invoicing');
38 38
                     echo "<p class='small'>$description</p>";
39 39
 
40 40
                 }
41 41
 
42 42
                 // Item price.
43
-                if ( 'price' == $column ) {
43
+                if ('price' == $column) {
44 44
 
45 45
                     // Display the item price (or recurring price if this is a renewal invoice)
46
-                    if ( $invoice->is_recurring() && $invoice->is_renewal() ) {
47
-                        echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() );
46
+                    if ($invoice->is_recurring() && $invoice->is_renewal()) {
47
+                        echo wpinv_price($fee['recurring_fee'], $invoice->get_currency());
48 48
                     } else {
49
-                        echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() );
49
+                        echo wpinv_price($fee['initial_fee'], $invoice->get_currency());
50 50
                     }
51 51
 
52 52
                 }
53 53
 
54 54
                 // Item quantity.
55
-                if ( 'quantity' == $column ) {
55
+                if ('quantity' == $column) {
56 56
                     echo "&mdash;";
57 57
                 }
58 58
 
59 59
                 // Item sub total.
60
-                if ( 'subtotal' == $column ) {
61
-                    if ( $invoice->is_recurring() && $invoice->is_renewal() ) {
62
-                        echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() );
60
+                if ('subtotal' == $column) {
61
+                    if ($invoice->is_recurring() && $invoice->is_renewal()) {
62
+                        echo wpinv_price($fee['recurring_fee'], $invoice->get_currency());
63 63
                     } else {
64
-                        echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() );
64
+                        echo wpinv_price($fee['initial_fee'], $invoice->get_currency());
65 65
                     }
66 66
                 }
67 67
 
68 68
                 // Fires when printing a line item column.
69
-                do_action( "getpaid_email_fee_item_$column", $fee, $invoice );
69
+                do_action("getpaid_email_fee_item_$column", $fee, $invoice);
70 70
 
71 71
             ?>
72 72
 
@@ -76,4 +76,4 @@  discard block
 block discarded – undo
76 76
 
77 77
 </tr>
78 78
 
79
-<?php do_action( 'getpaid_after_email_fee_item', $invoice, $fee ); ?>
79
+<?php do_action('getpaid_after_email_fee_item', $invoice, $fee); ?>
Please login to merge, or discard this patch.
templates/invoice/line-item.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -10,58 +10,58 @@  discard block
 block discarded – undo
10 10
  * @var array $columns
11 11
  */
12 12
 
13
-defined( 'ABSPATH' ) || exit;
13
+defined('ABSPATH') || exit;
14 14
 
15
-do_action( 'getpaid_before_invoice_line_item', $invoice, $item );
15
+do_action('getpaid_before_invoice_line_item', $invoice, $item);
16 16
 
17 17
 ?>
18 18
 
19
-<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo sanitize_html_class( $item->get_type() ); ?> border-bottom'>
19
+<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo sanitize_html_class($item->get_type()); ?> border-bottom'>
20 20
 
21 21
     <div class="form-row">
22 22
 
23
-        <?php foreach ( array_keys( $columns ) as $column ): ?>
23
+        <?php foreach (array_keys($columns) as $column): ?>
24 24
 
25
-            <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class( $column ); ?>">
25
+            <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class($column); ?>">
26 26
 
27 27
                 <?php
28 28
 
29 29
                     // Fires before printing a line item column.
30
-                    do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice );
30
+                    do_action("getpaid_invoice_line_item_before_$column", $item, $invoice);
31 31
 
32 32
                     // Item name.
33
-                    if ( 'name' == $column ) {
33
+                    if ('name' == $column) {
34 34
 
35 35
                         // Display the name.
36
-                        echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>';
36
+                        echo '<div class="mb-1">' . sanitize_text_field($item->get_name()) . '</div>';
37 37
 
38 38
                         // And an optional description.
39 39
                         $description = $item->get_description();
40 40
 
41
-                        if ( ! empty( $description ) ) {
42
-                            $description = wp_kses_post( $description );
41
+                        if (!empty($description)) {
42
+                            $description = wp_kses_post($description);
43 43
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
44 44
                         }
45 45
 
46 46
                         // Price help text.
47
-                        $description = getpaid_item_recurring_price_help_text( $item, $invoice->get_currency() );
48
-                        if ( $description ) {
47
+                        $description = getpaid_item_recurring_price_help_text($item, $invoice->get_currency());
48
+                        if ($description) {
49 49
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
50 50
                         }
51 51
 
52
-                        $actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice );
52
+                        $actions = apply_filters('getpaid-invoice-page-line-item-actions', array(), $item, $invoice);
53 53
 
54
-                        if ( ! empty( $actions ) ) {
54
+                        if (!empty($actions)) {
55 55
 
56
-                            $sanitized  = array();
57
-                            foreach ( $actions as $key => $action ) {
58
-                                $key         = sanitize_html_class( $key );
59
-                                $action      = wp_kses_post( $action );
56
+                            $sanitized = array();
57
+                            foreach ($actions as $key => $action) {
58
+                                $key         = sanitize_html_class($key);
59
+                                $action      = wp_kses_post($action);
60 60
                                 $sanitized[] = "<span class='$key'>$action</span>";
61 61
                             }
62 62
 
63 63
                             echo "<small class='form-text getpaid-line-item-actions'>";
64
-                            echo implode( ' | ', $sanitized );
64
+                            echo implode(' | ', $sanitized);
65 65
                             echo '</small>';
66 66
 
67 67
                         }
@@ -69,30 +69,30 @@  discard block
 block discarded – undo
69 69
                     }
70 70
 
71 71
                     // Item price.
72
-                    if ( 'price' == $column ) {
72
+                    if ('price' == $column) {
73 73
 
74 74
                         // Display the item price (or recurring price if this is a renewal invoice)
75 75
                         $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price();
76
-                        echo wpinv_price( $price );
76
+                        echo wpinv_price($price);
77 77
 
78 78
                     }
79 79
 
80 80
                     // Item quantity.
81
-                    if ( 'quantity' == $column ) {
81
+                    if ('quantity' == $column) {
82 82
                         echo (int) $item->get_quantity();
83 83
                     }
84 84
 
85 85
                     // Item sub total.
86
-                    if ( 'subtotal' == $column ) {
86
+                    if ('subtotal' == $column) {
87 87
                         $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total();
88
-                        echo wpinv_price( $subtotal );
88
+                        echo wpinv_price($subtotal);
89 89
                     }
90 90
 
91 91
                     // Fires when printing a line item column.
92
-                    do_action( "getpaid_invoice_line_item_$column", $item, $invoice );
92
+                    do_action("getpaid_invoice_line_item_$column", $item, $invoice);
93 93
 
94 94
                     // Fires after printing a line item column.
95
-                    do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice );
95
+                    do_action("getpaid_invoice_line_item_after_$column", $item, $invoice);
96 96
 
97 97
                 ?>
98 98
 
Please login to merge, or discard this patch.