Passed
Push — master ( 65b60e...ed9391 )
by Brian
10:46
created
includes/class-wpinv-ajax.php 2 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -14,70 +14,70 @@  discard block
 block discarded – undo
14 14
 class WPInv_Ajax {
15 15
 
16 16
     /**
17
-	 * Hook in ajax handlers.
18
-	 */
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 );
22
-		self::add_ajax_events();
17
+     * Hook in ajax handlers.
18
+     */
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 );
22
+        self::add_ajax_events();
23 23
     }
24 24
 
25 25
     /**
26
-	 * Set GetPaid AJAX constant and headers.
27
-	 */
28
-	public static function define_ajax() {
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 );
35
-			}
36
-			$GLOBALS['wpdb']->hide_errors();
37
-		}
26
+     * Set GetPaid AJAX constant and headers.
27
+     */
28
+    public static function define_ajax() {
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 );
35
+            }
36
+            $GLOBALS['wpdb']->hide_errors();
37
+        }
38 38
 
39 39
     }
40 40
 
41 41
     /**
42
-	 * Send headers for GetPaid Ajax Requests.
43
-	 *
44
-	 * @since 1.0.18
45
-	 */
46
-	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
48
-			send_origin_headers();
49
-			send_nosniff_header();
50
-			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
54
-		}
42
+     * Send headers for GetPaid Ajax Requests.
43
+     *
44
+     * @since 1.0.18
45
+     */
46
+    private static function wpinv_ajax_headers() {
47
+        if ( ! headers_sent() ) {
48
+            send_origin_headers();
49
+            send_nosniff_header();
50
+            nocache_headers();
51
+            header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
+            header( 'X-Robots-Tag: noindex' );
53
+            status_header( 200 );
54
+        }
55 55
     }
56 56
 
57 57
     /**
58
-	 * Check for GetPaid Ajax request and fire action.
59
-	 */
60
-	public static function do_wpinv_ajax() {
61
-		global $wp_query;
58
+     * Check for GetPaid Ajax request and fire action.
59
+     */
60
+    public static function do_wpinv_ajax() {
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'] ) ) );
65
-		}
63
+        if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
+            $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
65
+        }
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+        $action = $wp_query->get( 'wpinv-ajax' );
68 68
 
69
-		if ( $action ) {
70
-			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
73
-			wp_die();
74
-		}
69
+        if ( $action ) {
70
+            self::wpinv_ajax_headers();
71
+            $action = sanitize_text_field( $action );
72
+            do_action( 'wpinv_ajax_' . $action );
73
+            wp_die();
74
+        }
75 75
 
76 76
     }
77 77
 
78 78
     /**
79
-	 * Hook in ajax methods.
80
-	 */
79
+     * Hook in ajax methods.
80
+     */
81 81
     public static function add_ajax_events() {
82 82
 
83 83
         // array( 'event' => is_frontend )
@@ -258,11 +258,11 @@  discard block
 block discarded – undo
258 258
         global $getpaid_force_checkbox;
259 259
 
260 260
         // Is the request set up correctly?
261
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) {
262
-			aui()->alert(
263
-				array(
264
-					'type'    => 'warning',
265
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
261
+        if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) {
262
+            aui()->alert(
263
+                array(
264
+                    'type'    => 'warning',
265
+                    'content' => __( 'No payment form or item provided', 'invoicing' ),
266 266
                 ),
267 267
                 true
268 268
             );
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         }
271 271
 
272 272
         // Payment form or button?
273
-		if ( ! empty( $_GET['form'] ) ) {
273
+        if ( ! empty( $_GET['form'] ) ) {
274 274
             $form = sanitize_text_field( urldecode( $_GET['form'] ) );
275 275
 
276 276
             if ( false !== strpos( $form, '|' ) ) {
@@ -323,10 +323,10 @@  discard block
 block discarded – undo
323 323
                 getpaid_display_payment_form( $form );
324 324
             }
325 325
 } elseif ( ! empty( $_GET['invoice'] ) ) {
326
-		    getpaid_display_invoice_payment_form( (int) urldecode( $_GET['invoice'] ) );
326
+            getpaid_display_invoice_payment_form( (int) urldecode( $_GET['invoice'] ) );
327 327
         } else {
328
-			$items = getpaid_convert_items_to_array( sanitize_text_field( urldecode( $_GET['item'] ) ) );
329
-		    getpaid_display_item_payment_form( $items );
328
+            $items = getpaid_convert_items_to_array( sanitize_text_field( urldecode( $_GET['item'] ) ) );
329
+            getpaid_display_item_payment_form( $items );
330 330
         }
331 331
 
332 332
         exit;
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
         if ( is_wp_error( $error ) ) {
644 644
             $alert = $error->get_error_message();
645 645
             wp_send_json_success( compact( 'alert' ) );
646
-         }
646
+            }
647 647
 
648 648
         // Update totals.
649 649
         $invoice->recalculate_total();
@@ -1072,12 +1072,12 @@  discard block
 block discarded – undo
1072 1072
     }
1073 1073
 
1074 1074
     /**
1075
-	 * Handles file uploads.
1076
-	 *
1077
-	 * @since       1.0.0
1078
-	 * @return      void
1079
-	 */
1080
-	public static function file_upload() {
1075
+     * Handles file uploads.
1076
+     *
1077
+     * @since       1.0.0
1078
+     * @return      void
1079
+     */
1080
+    public static function file_upload() {
1081 1081
 
1082 1082
         // Check nonce.
1083 1083
         check_ajax_referer( 'getpaid_form_nonce' );
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
 
1139 1139
         wp_send_json_success( $response );
1140 1140
 
1141
-	}
1141
+    }
1142 1142
 
1143 1143
 }
1144 1144
 
Please login to merge, or discard this patch.
Spacing   +321 added lines, -321 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
 
@@ -106,36 +106,36 @@  discard block
 block discarded – undo
106 106
             'file_upload'                   => true,
107 107
         );
108 108
 
109
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
110
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
111
-            add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
109
+        foreach ($ajax_events as $ajax_event => $nopriv) {
110
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
111
+            add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
112 112
 
113
-            if ( $nopriv ) {
114
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
115
-                add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
116
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
113
+            if ($nopriv) {
114
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
115
+                add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
116
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
117 117
             }
118 118
         }
119 119
     }
120 120
 
121 121
     public static function add_note() {
122
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
122
+        check_ajax_referer('add-invoice-note', '_nonce');
123 123
 
124
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
124
+        if (!wpinv_current_user_can_manage_invoicing()) {
125 125
             die( -1 );
126 126
         }
127 127
 
128
-        $post_id   = absint( $_POST['post_id'] );
129
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
130
-        $note_type = sanitize_text_field( $_POST['note_type'] );
128
+        $post_id   = absint($_POST['post_id']);
129
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
130
+        $note_type = sanitize_text_field($_POST['note_type']);
131 131
 
132 132
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
133 133
 
134
-        if ( $post_id > 0 ) {
135
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
134
+        if ($post_id > 0) {
135
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
136 136
 
137
-            if ( $note_id > 0 && ! is_wp_error( $note_id ) ) {
138
-                wpinv_get_invoice_note_line_item( $note_id );
137
+            if ($note_id > 0 && !is_wp_error($note_id)) {
138
+                wpinv_get_invoice_note_line_item($note_id);
139 139
             }
140 140
         }
141 141
 
@@ -143,16 +143,16 @@  discard block
 block discarded – undo
143 143
     }
144 144
 
145 145
     public static function delete_note() {
146
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
146
+        check_ajax_referer('delete-invoice-note', '_nonce');
147 147
 
148
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
148
+        if (!wpinv_current_user_can_manage_invoicing()) {
149 149
             die( -1 );
150 150
         }
151 151
 
152
-        $note_id = (int)$_POST['note_id'];
152
+        $note_id = (int) $_POST['note_id'];
153 153
 
154
-        if ( $note_id > 0 ) {
155
-            wp_delete_comment( $note_id, true );
154
+        if ($note_id > 0) {
155
+            wp_delete_comment($note_id, true);
156 156
         }
157 157
 
158 158
         die();
@@ -170,34 +170,34 @@  discard block
 block discarded – undo
170 170
     public static function get_billing_details() {
171 171
 
172 172
         // Verify nonce.
173
-        check_ajax_referer( 'wpinv-nonce' );
173
+        check_ajax_referer('wpinv-nonce');
174 174
 
175 175
         // Can the user manage the plugin?
176
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
176
+        if (!wpinv_current_user_can_manage_invoicing()) {
177 177
             die( -1 );
178 178
         }
179 179
 
180 180
         // Do we have a user id?
181 181
         $user_id = (int) $_GET['user_id'];
182 182
 
183
-        if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
183
+        if (empty($user_id) || !is_numeric($user_id)) {
184 184
             die( -1 );
185 185
         }
186 186
 
187 187
         // Fetch the billing details.
188
-        $billing_details    = wpinv_get_user_address( $user_id );
189
-        $billing_details    = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id );
188
+        $billing_details    = wpinv_get_user_address($user_id);
189
+        $billing_details    = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id);
190 190
 
191 191
         // unset the user id and email.
192
-        $to_ignore = array( 'user_id', 'email' );
192
+        $to_ignore = array('user_id', 'email');
193 193
 
194
-        foreach ( $to_ignore as $key ) {
195
-            if ( isset( $billing_details[ $key ] ) ) {
196
-                unset( $billing_details[ $key ] );
194
+        foreach ($to_ignore as $key) {
195
+            if (isset($billing_details[$key])) {
196
+                unset($billing_details[$key]);
197 197
             }
198 198
         }
199 199
 
200
-        wp_send_json_success( $billing_details );
200
+        wp_send_json_success($billing_details);
201 201
 
202 202
     }
203 203
 
@@ -207,47 +207,47 @@  discard block
 block discarded – undo
207 207
     public static function check_new_user_email() {
208 208
 
209 209
         // Verify nonce.
210
-        check_ajax_referer( 'wpinv-nonce' );
210
+        check_ajax_referer('wpinv-nonce');
211 211
 
212 212
         // Can the user manage the plugin?
213
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
213
+        if (!wpinv_current_user_can_manage_invoicing()) {
214 214
             die( -1 );
215 215
         }
216 216
 
217 217
         // We need an email address.
218
-        if ( empty( $_GET['email'] ) ) {
219
-            esc_html_e( "Provide the new user's email address", 'invoicing' );
218
+        if (empty($_GET['email'])) {
219
+            esc_html_e("Provide the new user's email address", 'invoicing');
220 220
             exit;
221 221
         }
222 222
 
223 223
         // Ensure the email is valid.
224
-        $email = sanitize_email( $_GET['email'] );
225
-        if ( ! is_email( $email ) ) {
226
-            esc_html_e( 'Invalid email address', 'invoicing' );
224
+        $email = sanitize_email($_GET['email']);
225
+        if (!is_email($email)) {
226
+            esc_html_e('Invalid email address', 'invoicing');
227 227
             exit;
228 228
         }
229 229
 
230 230
         // And it does not exist.
231
-        $id = email_exists( $email );
232
-        if ( $id ) {
233
-            wp_send_json_success( compact( 'id' ) );
231
+        $id = email_exists($email);
232
+        if ($id) {
233
+            wp_send_json_success(compact('id'));
234 234
         }
235 235
 
236
-        wp_send_json_success( true );
236
+        wp_send_json_success(true);
237 237
     }
238 238
 
239 239
     public static function run_tool() {
240
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
241
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
240
+        check_ajax_referer('wpinv-nonce', '_nonce');
241
+        if (!wpinv_current_user_can_manage_invoicing()) {
242 242
             die( -1 );
243 243
         }
244 244
 
245
-        $tool = sanitize_text_field( $_POST['tool'] );
245
+        $tool = sanitize_text_field($_POST['tool']);
246 246
 
247
-        do_action( 'wpinv_run_tool' );
247
+        do_action('wpinv_run_tool');
248 248
 
249
-        if ( ! empty( $tool ) ) {
250
-            do_action( 'wpinv_tool_' . $tool );
249
+        if (!empty($tool)) {
250
+            do_action('wpinv_tool_' . $tool);
251 251
         }
252 252
     }
253 253
 
@@ -258,11 +258,11 @@  discard block
 block discarded – undo
258 258
         global $getpaid_force_checkbox;
259 259
 
260 260
         // Is the request set up correctly?
261
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) {
261
+		if (empty($_GET['form']) && empty($_GET['item']) && empty($_GET['invoice'])) {
262 262
 			aui()->alert(
263 263
 				array(
264 264
 					'type'    => 'warning',
265
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
265
+					'content' => __('No payment form or item provided', 'invoicing'),
266 266
                 ),
267 267
                 true
268 268
             );
@@ -270,29 +270,29 @@  discard block
 block discarded – undo
270 270
         }
271 271
 
272 272
         // Payment form or button?
273
-		if ( ! empty( $_GET['form'] ) ) {
274
-            $form = sanitize_text_field( urldecode( $_GET['form'] ) );
273
+		if (!empty($_GET['form'])) {
274
+            $form = sanitize_text_field(urldecode($_GET['form']));
275 275
 
276
-            if ( false !== strpos( $form, '|' ) ) {
277
-                $form_pos = strpos( $form, '|' );
278
-                $_items   = getpaid_convert_items_to_array( substr( $form, $form_pos + 1 ) );
279
-                $form     = substr( $form, 0, $form_pos );
276
+            if (false !== strpos($form, '|')) {
277
+                $form_pos = strpos($form, '|');
278
+                $_items   = getpaid_convert_items_to_array(substr($form, $form_pos + 1));
279
+                $form     = substr($form, 0, $form_pos);
280 280
 
281 281
                 // Retrieve appropriate payment form.
282
-                $payment_form = new GetPaid_Payment_Form( $form );
283
-                $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
282
+                $payment_form = new GetPaid_Payment_Form($form);
283
+                $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form());
284 284
 
285 285
                 $items    = array();
286 286
                 $item_ids = array();
287 287
 
288
-                foreach ( $_items as $item_id => $qty ) {
289
-                    if ( ! in_array( $item_id, $item_ids ) ) {
290
-                        $item = new GetPaid_Form_Item( $item_id );
291
-                        $item->set_quantity( $qty );
288
+                foreach ($_items as $item_id => $qty) {
289
+                    if (!in_array($item_id, $item_ids)) {
290
+                        $item = new GetPaid_Form_Item($item_id);
291
+                        $item->set_quantity($qty);
292 292
 
293
-                        if ( 0 == $qty ) {
294
-                            $item->set_allow_quantities( true );
295
-                            $item->set_is_required( false );
293
+                        if (0 == $qty) {
294
+                            $item->set_allow_quantities(true);
295
+                            $item->set_is_required(false);
296 296
                             $getpaid_force_checkbox = true;
297 297
                         }
298 298
 
@@ -301,32 +301,32 @@  discard block
 block discarded – undo
301 301
                     }
302 302
                 }
303 303
 
304
-                if ( ! $payment_form->is_default() ) {
304
+                if (!$payment_form->is_default()) {
305 305
 
306
-                    foreach ( $payment_form->get_items() as $item ) {
307
-                        if ( ! in_array( $item->get_id(), $item_ids ) ) {
306
+                    foreach ($payment_form->get_items() as $item) {
307
+                        if (!in_array($item->get_id(), $item_ids)) {
308 308
                             $item_ids[] = $item->get_id();
309 309
                             $items[]    = $item;
310 310
                         }
311 311
                     }
312 312
                 }
313 313
 
314
-                $payment_form->set_items( $items );
315
-                $extra_items     = esc_attr( getpaid_convert_items_to_string( $_items ) );
316
-                $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items );
314
+                $payment_form->set_items($items);
315
+                $extra_items     = esc_attr(getpaid_convert_items_to_string($_items));
316
+                $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items);
317 317
                 $extra_items     = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />";
318 318
                 $extra_items    .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />";
319
-                $payment_form->display( $extra_items );
319
+                $payment_form->display($extra_items);
320 320
                 $getpaid_force_checkbox = false;
321 321
 
322 322
             } else {
323
-                getpaid_display_payment_form( $form );
323
+                getpaid_display_payment_form($form);
324 324
             }
325
-} elseif ( ! empty( $_GET['invoice'] ) ) {
326
-		    getpaid_display_invoice_payment_form( (int) urldecode( $_GET['invoice'] ) );
325
+} elseif (!empty($_GET['invoice'])) {
326
+		    getpaid_display_invoice_payment_form((int) urldecode($_GET['invoice']));
327 327
         } else {
328
-			$items = getpaid_convert_items_to_array( sanitize_text_field( urldecode( $_GET['item'] ) ) );
329
-		    getpaid_display_item_payment_form( $items );
328
+			$items = getpaid_convert_items_to_array(sanitize_text_field(urldecode($_GET['item'])));
329
+		    getpaid_display_item_payment_form($items);
330 330
         }
331 331
 
332 332
         exit;
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
     public static function payment_form() {
342 342
 
343 343
         // ... form fields...
344
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
345
-            esc_html_e( 'Error: Reload the page and try again.', 'invoicing' );
344
+        if (empty($_POST['getpaid_payment_form_submission'])) {
345
+            esc_html_e('Error: Reload the page and try again.', 'invoicing');
346 346
             exit;
347 347
         }
348 348
 
349 349
         // Process the payment form.
350
-        $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' );
351
-        $checkout       = new $checkout_class( new GetPaid_Payment_Form_Submission() );
350
+        $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout');
351
+        $checkout       = new $checkout_class(new GetPaid_Payment_Form_Submission());
352 352
         $checkout->process_checkout();
353 353
 
354 354
         exit;
@@ -361,55 +361,55 @@  discard block
 block discarded – undo
361 361
      */
362 362
     public static function get_payment_form_states_field() {
363 363
 
364
-        if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) {
364
+        if (empty($_GET['country']) || empty($_GET['form'])) {
365 365
             exit;
366 366
         }
367 367
 
368
-        $elements = getpaid_get_payment_form_elements( (int) $_GET['form'] );
368
+        $elements = getpaid_get_payment_form_elements((int) $_GET['form']);
369 369
 
370
-        if ( empty( $elements ) ) {
370
+        if (empty($elements)) {
371 371
             exit;
372 372
         }
373 373
 
374 374
         $address_fields = array();
375
-        foreach ( $elements as $element ) {
376
-            if ( 'address' === $element['type'] ) {
375
+        foreach ($elements as $element) {
376
+            if ('address' === $element['type']) {
377 377
                 $address_fields = $element;
378 378
                 break;
379 379
             }
380 380
         }
381 381
 
382
-        if ( empty( $address_fields ) ) {
382
+        if (empty($address_fields)) {
383 383
             exit;
384 384
         }
385 385
 
386
-        foreach ( $address_fields['fields'] as $address_field ) {
386
+        foreach ($address_fields['fields'] as $address_field) {
387 387
 
388
-            if ( 'wpinv_state' == $address_field['name'] ) {
388
+            if ('wpinv_state' == $address_field['name']) {
389 389
 
390
-                $wrap_class  = getpaid_get_form_element_grid_class( $address_field );
391
-                $wrap_class  = esc_attr( "$wrap_class getpaid-address-field-wrapper" );
392
-                $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
393
-                $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
394
-                $value       = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : '';
395
-                $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
390
+                $wrap_class  = getpaid_get_form_element_grid_class($address_field);
391
+                $wrap_class  = esc_attr("$wrap_class getpaid-address-field-wrapper");
392
+                $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
393
+                $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
394
+                $value       = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : '';
395
+                $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
396 396
 
397
-                if ( ! empty( $address_field['required'] ) ) {
397
+                if (!empty($address_field['required'])) {
398 398
                     $label .= "<span class='text-danger'> *</span>";
399 399
                 }
400 400
 
401 401
                 $html = getpaid_get_states_select_markup(
402
-                    sanitize_text_field( $_GET['country'] ),
402
+                    sanitize_text_field($_GET['country']),
403 403
                     $value,
404 404
                     $placeholder,
405 405
                     $label,
406 406
                     $description,
407
-                    ! empty( $address_field['required'] ),
407
+                    !empty($address_field['required']),
408 408
                     $wrap_class,
409
-                    sanitize_text_field( $_GET['name'] )
409
+                    sanitize_text_field($_GET['name'])
410 410
                 );
411 411
 
412
-                wp_send_json_success( $html );
412
+                wp_send_json_success($html);
413 413
                 exit;
414 414
 
415 415
             }
@@ -424,66 +424,66 @@  discard block
 block discarded – undo
424 424
     public static function recalculate_invoice_totals() {
425 425
 
426 426
         // Verify nonce.
427
-        check_ajax_referer( 'wpinv-nonce' );
427
+        check_ajax_referer('wpinv-nonce');
428 428
 
429
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
429
+        if (!wpinv_current_user_can_manage_invoicing()) {
430 430
             exit;
431 431
         }
432 432
 
433 433
         // We need an invoice.
434
-        if ( empty( $_POST['post_id'] ) ) {
434
+        if (empty($_POST['post_id'])) {
435 435
             exit;
436 436
         }
437 437
 
438 438
         // Fetch the invoice.
439
-        $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) );
439
+        $invoice = new WPInv_Invoice(intval($_POST['post_id']));
440 440
 
441 441
         // Ensure it exists.
442
-        if ( ! $invoice->get_id() ) {
442
+        if (!$invoice->get_id()) {
443 443
             exit;
444 444
         }
445 445
 
446 446
         // Maybe set the country, state, currency.
447
-        foreach ( array( 'country', 'state', 'currency', 'vat_number', 'discount_code' ) as $key ) {
448
-            if ( isset( $_POST[ $key ] ) ) {
447
+        foreach (array('country', 'state', 'currency', 'vat_number', 'discount_code') as $key) {
448
+            if (isset($_POST[$key])) {
449 449
                 $method = "set_$key";
450
-                $invoice->$method( sanitize_text_field( $_POST[ $key ] ) );
450
+                $invoice->$method(sanitize_text_field($_POST[$key]));
451 451
             }
452 452
         }
453 453
 
454 454
         // Maybe disable taxes.
455
-        $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) );
455
+        $invoice->set_disable_taxes(!empty($_POST['taxes']));
456 456
 
457 457
         // Discount code.
458
-        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
459
-            $discount = new WPInv_Discount( $invoice->get_discount_code() );
460
-            if ( $discount->exists() ) {
461
-                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
458
+        if (!$invoice->is_paid() && !$invoice->is_refunded()) {
459
+            $discount = new WPInv_Discount($invoice->get_discount_code());
460
+            if ($discount->exists()) {
461
+                $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
462 462
             } else {
463
-                $invoice->remove_discount( 'discount_code' );
463
+                $invoice->remove_discount('discount_code');
464 464
             }
465 465
         }
466 466
 
467 467
         // Recalculate totals.
468 468
         $invoice->recalculate_total();
469 469
 
470
-        $total        = wpinv_price( $invoice->get_total(), $invoice->get_currency() );
471
-        $suscriptions = getpaid_get_invoice_subscriptions( $invoice );
472
-        if ( is_a( $suscriptions, 'WPInv_Subscription' ) && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) {
473
-            $recurring_total = wpinv_price( $invoice->get_recurring_total(), $invoice->get_currency() );
474
-            $total          .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>';
470
+        $total        = wpinv_price($invoice->get_total(), $invoice->get_currency());
471
+        $suscriptions = getpaid_get_invoice_subscriptions($invoice);
472
+        if (is_a($suscriptions, 'WPInv_Subscription') && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) {
473
+            $recurring_total = wpinv_price($invoice->get_recurring_total(), $invoice->get_currency());
474
+            $total          .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>';
475 475
         }
476 476
 
477 477
         $totals = array(
478
-            'subtotal' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
479
-            'discount' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
480
-            'tax'      => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
478
+            'subtotal' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
479
+            'discount' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
480
+            'tax'      => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
481 481
             'total'    => $total,
482 482
         );
483 483
 
484
-        $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice );
484
+        $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice);
485 485
 
486
-        wp_send_json_success( compact( 'totals' ) );
486
+        wp_send_json_success(compact('totals'));
487 487
     }
488 488
 
489 489
     /**
@@ -492,33 +492,33 @@  discard block
 block discarded – undo
492 492
     public static function get_invoice_items() {
493 493
 
494 494
         // Verify nonce.
495
-        check_ajax_referer( 'wpinv-nonce' );
495
+        check_ajax_referer('wpinv-nonce');
496 496
 
497
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
497
+        if (!wpinv_current_user_can_manage_invoicing()) {
498 498
             exit;
499 499
         }
500 500
 
501 501
         // We need an invoice and items.
502
-        if ( empty( $_POST['post_id'] ) ) {
502
+        if (empty($_POST['post_id'])) {
503 503
             exit;
504 504
         }
505 505
 
506 506
         // Fetch the invoice.
507
-        $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) );
507
+        $invoice = new WPInv_Invoice(intval($_POST['post_id']));
508 508
 
509 509
         // Ensure it exists.
510
-        if ( ! $invoice->get_id() ) {
510
+        if (!$invoice->get_id()) {
511 511
             exit;
512 512
         }
513 513
 
514 514
         // Return an array of invoice items.
515 515
         $items = array();
516 516
 
517
-        foreach ( $invoice->get_items() as $item ) {
518
-            $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency(), $invoice->is_renewal() );
517
+        foreach ($invoice->get_items() as $item) {
518
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency(), $invoice->is_renewal());
519 519
         }
520 520
 
521
-        wp_send_json_success( compact( 'items' ) );
521
+        wp_send_json_success(compact('items'));
522 522
     }
523 523
 
524 524
     /**
@@ -527,50 +527,50 @@  discard block
 block discarded – undo
527 527
     public static function edit_invoice_item() {
528 528
 
529 529
         // Verify nonce.
530
-        check_ajax_referer( 'wpinv-nonce' );
530
+        check_ajax_referer('wpinv-nonce');
531 531
 
532
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
532
+        if (!wpinv_current_user_can_manage_invoicing()) {
533 533
             exit;
534 534
         }
535 535
 
536 536
         // We need an invoice and item details.
537
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) {
537
+        if (empty($_POST['post_id']) || empty($_POST['data'])) {
538 538
             exit;
539 539
         }
540 540
 
541 541
         // Fetch the invoice.
542
-        $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) );
542
+        $invoice = new WPInv_Invoice(intval($_POST['post_id']));
543 543
 
544 544
         // Ensure it exists and its not been paid for.
545
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
545
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
546 546
             exit;
547 547
         }
548 548
 
549 549
         // Format the data.
550
-        $data = wp_kses_post_deep( wp_unslash( wp_list_pluck( $_POST['data'], 'value', 'field' ) ) );
550
+        $data = wp_kses_post_deep(wp_unslash(wp_list_pluck($_POST['data'], 'value', 'field')));
551 551
 
552 552
         // Ensure that we have an item id.
553
-        if ( empty( $data['id'] ) ) {
553
+        if (empty($data['id'])) {
554 554
             exit;
555 555
         }
556 556
 
557 557
         // Abort if the invoice does not have the specified item.
558
-        $item = $invoice->get_item( (int) $data['id'] );
558
+        $item = $invoice->get_item((int) $data['id']);
559 559
 
560
-        if ( empty( $item ) ) {
560
+        if (empty($item)) {
561 561
             exit;
562 562
         }
563 563
 
564 564
         // Update the item.
565
-        $item->set_price( getpaid_standardize_amount( $data['price'] ) );
566
-        $item->set_name( sanitize_text_field( $data['name'] ) );
567
-        $item->set_description( wp_kses_post( $data['description'] ) );
568
-        $item->set_quantity( floatval( $data['quantity'] ) );
565
+        $item->set_price(getpaid_standardize_amount($data['price']));
566
+        $item->set_name(sanitize_text_field($data['name']));
567
+        $item->set_description(wp_kses_post($data['description']));
568
+        $item->set_quantity(floatval($data['quantity']));
569 569
 
570 570
         // Add it to the invoice.
571
-        $error = $invoice->add_item( $item );
571
+        $error = $invoice->add_item($item);
572 572
         $alert = false;
573
-        if ( is_wp_error( $error ) ) {
573
+        if (is_wp_error($error)) {
574 574
             $alert = $error->get_error_message();
575 575
         }
576 576
 
@@ -583,11 +583,11 @@  discard block
 block discarded – undo
583 583
         // Return an array of invoice items.
584 584
         $items = array();
585 585
 
586
-        foreach ( $invoice->get_items() as $item ) {
587
-            $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() );
586
+        foreach ($invoice->get_items() as $item) {
587
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
588 588
         }
589 589
 
590
-        wp_send_json_success( compact( 'items', 'alert' ) );
590
+        wp_send_json_success(compact('items', 'alert'));
591 591
     }
592 592
 
593 593
     /**
@@ -596,53 +596,53 @@  discard block
 block discarded – undo
596 596
     public static function create_invoice_item() {
597 597
 
598 598
         // Verify nonce.
599
-        check_ajax_referer( 'wpinv-nonce' );
599
+        check_ajax_referer('wpinv-nonce');
600 600
 
601
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
601
+        if (!wpinv_current_user_can_manage_invoicing()) {
602 602
             exit;
603 603
         }
604 604
 
605 605
         // We need an invoice and item details.
606
-        if ( empty( $_POST['invoice_id'] ) || empty( $_POST['_wpinv_quick'] ) ) {
606
+        if (empty($_POST['invoice_id']) || empty($_POST['_wpinv_quick'])) {
607 607
             exit;
608 608
         }
609 609
 
610 610
         // Fetch the invoice.
611
-        $invoice = new WPInv_Invoice( intval( $_POST['invoice_id'] ) );
611
+        $invoice = new WPInv_Invoice(intval($_POST['invoice_id']));
612 612
 
613 613
         // Ensure it exists and its not been paid for.
614
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
614
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
615 615
             exit;
616 616
         }
617 617
 
618 618
         // Format the data.
619
-        $data = wp_kses_post_deep( wp_unslash( $_POST['_wpinv_quick'] ) );
619
+        $data = wp_kses_post_deep(wp_unslash($_POST['_wpinv_quick']));
620 620
 
621 621
         $item = new WPInv_Item();
622
-        $item->set_price( getpaid_standardize_amount( $data['price'] ) );
623
-        $item->set_name( sanitize_text_field( $data['name'] ) );
624
-        $item->set_description( wp_kses_post( $data['description'] ) );
625
-        $item->set_type( sanitize_text_field( $data['type'] ) );
626
-        $item->set_vat_rule( sanitize_text_field( $data['vat_rule'] ) );
627
-        $item->set_vat_class( sanitize_text_field( $data['vat_class'] ) );
628
-        $item->set_status( 'publish' );
622
+        $item->set_price(getpaid_standardize_amount($data['price']));
623
+        $item->set_name(sanitize_text_field($data['name']));
624
+        $item->set_description(wp_kses_post($data['description']));
625
+        $item->set_type(sanitize_text_field($data['type']));
626
+        $item->set_vat_rule(sanitize_text_field($data['vat_rule']));
627
+        $item->set_vat_class(sanitize_text_field($data['vat_class']));
628
+        $item->set_status('publish');
629 629
         $item->save();
630 630
 
631
-        if ( ! $item->exists() ) {
632
-            $alert = __( 'Could not create invoice item. Please try again.', 'invoicing' );
633
-            wp_send_json_success( compact( 'alert' ) );
631
+        if (!$item->exists()) {
632
+            $alert = __('Could not create invoice item. Please try again.', 'invoicing');
633
+            wp_send_json_success(compact('alert'));
634 634
         }
635 635
 
636
-        $item = new GetPaid_Form_Item( $item->get_id() );
637
-        $item->set_quantity( floatval( $data['qty'] ) );
636
+        $item = new GetPaid_Form_Item($item->get_id());
637
+        $item->set_quantity(floatval($data['qty']));
638 638
 
639 639
         // Add it to the invoice.
640
-        $error = $invoice->add_item( $item );
640
+        $error = $invoice->add_item($item);
641 641
         $alert = false;
642 642
 
643
-        if ( is_wp_error( $error ) ) {
643
+        if (is_wp_error($error)) {
644 644
             $alert = $error->get_error_message();
645
-            wp_send_json_success( compact( 'alert' ) );
645
+            wp_send_json_success(compact('alert'));
646 646
          }
647 647
 
648 648
         // Update totals.
@@ -655,9 +655,9 @@  discard block
 block discarded – undo
655 655
         $invoice->recalculate_total();
656 656
         $invoice->save();
657 657
         ob_start();
658
-        GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice );
658
+        GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice);
659 659
         $row = ob_get_clean();
660
-        wp_send_json_success( compact( 'row' ) );
660
+        wp_send_json_success(compact('row'));
661 661
     }
662 662
 
663 663
     /**
@@ -666,33 +666,33 @@  discard block
 block discarded – undo
666 666
     public static function remove_invoice_item() {
667 667
 
668 668
         // Verify nonce.
669
-        check_ajax_referer( 'wpinv-nonce' );
669
+        check_ajax_referer('wpinv-nonce');
670 670
 
671
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
671
+        if (!wpinv_current_user_can_manage_invoicing()) {
672 672
             exit;
673 673
         }
674 674
 
675 675
         // We need an invoice and an item.
676
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) {
676
+        if (empty($_POST['post_id']) || empty($_POST['item_id'])) {
677 677
             exit;
678 678
         }
679 679
 
680 680
         // Fetch the invoice.
681
-        $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) );
681
+        $invoice = new WPInv_Invoice(intval($_POST['post_id']));
682 682
 
683 683
         // Ensure it exists and its not been paid for.
684
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
684
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
685 685
             exit;
686 686
         }
687 687
 
688 688
         // Abort if the invoice does not have the specified item.
689
-        $item = $invoice->get_item( (int) $_POST['item_id'] );
689
+        $item = $invoice->get_item((int) $_POST['item_id']);
690 690
 
691
-        if ( empty( $item ) ) {
691
+        if (empty($item)) {
692 692
             exit;
693 693
         }
694 694
 
695
-        $invoice->remove_item( (int) $_POST['item_id'] );
695
+        $invoice->remove_item((int) $_POST['item_id']);
696 696
 
697 697
         // Update totals.
698 698
         $invoice->recalculate_total();
@@ -703,11 +703,11 @@  discard block
 block discarded – undo
703 703
         // Return an array of invoice items.
704 704
         $items = array();
705 705
 
706
-        foreach ( $invoice->get_items() as $item ) {
707
-            $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() );
706
+        foreach ($invoice->get_items() as $item) {
707
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
708 708
         }
709 709
 
710
-        wp_send_json_success( compact( 'items' ) );
710
+        wp_send_json_success(compact('items'));
711 711
     }
712 712
 
713 713
     /**
@@ -716,68 +716,68 @@  discard block
 block discarded – undo
716 716
     public static function recalculate_full_prices() {
717 717
 
718 718
         // Verify nonce.
719
-        check_ajax_referer( 'wpinv-nonce' );
719
+        check_ajax_referer('wpinv-nonce');
720 720
 
721
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
721
+        if (!wpinv_current_user_can_manage_invoicing()) {
722 722
             exit;
723 723
         }
724 724
 
725 725
         // We need an invoice and item.
726
-        if ( empty( $_POST['post_id'] ) ) {
726
+        if (empty($_POST['post_id'])) {
727 727
             exit;
728 728
         }
729 729
 
730 730
         // Fetch the invoice.
731
-        $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) );
731
+        $invoice = new WPInv_Invoice(intval($_POST['post_id']));
732 732
         $alert   = false;
733 733
 
734 734
         // Ensure it exists and its not been paid for.
735
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
735
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
736 736
             exit;
737 737
         }
738 738
 
739
-        $invoice->set_items( array() );
739
+        $invoice->set_items(array());
740 740
 
741
-        if ( ! empty( $_POST['getpaid_items'] ) ) {
741
+        if (!empty($_POST['getpaid_items'])) {
742 742
 
743
-            foreach ( wp_kses_post_deep( $_POST['getpaid_items'] ) as $item_id => $args ) {
744
-                $item = new GetPaid_Form_Item( $item_id );
743
+            foreach (wp_kses_post_deep($_POST['getpaid_items']) as $item_id => $args) {
744
+                $item = new GetPaid_Form_Item($item_id);
745 745
 
746
-                if ( $item->exists() ) {
747
-                    $item->set_price( getpaid_standardize_amount( $args['price'] ) );
748
-                    $item->set_quantity( floatval( $args['quantity'] ) );
749
-                    $item->set_name( sanitize_text_field( $args['name'] ) );
750
-                    $item->set_description( wp_kses_post( $args['description'] ) );
751
-                    $invoice->add_item( $item );
746
+                if ($item->exists()) {
747
+                    $item->set_price(getpaid_standardize_amount($args['price']));
748
+                    $item->set_quantity(floatval($args['quantity']));
749
+                    $item->set_name(sanitize_text_field($args['name']));
750
+                    $item->set_description(wp_kses_post($args['description']));
751
+                    $invoice->add_item($item);
752 752
                 }
753 753
             }
754 754
 }
755 755
 
756
-        $invoice->set_disable_taxes( ! empty( $_POST['disable_taxes'] ) );
756
+        $invoice->set_disable_taxes(!empty($_POST['disable_taxes']));
757 757
 
758 758
         // Maybe set the country, state, currency.
759
-        foreach ( array( 'wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code' ) as $key ) {
760
-            if ( isset( $_POST[ $key ] ) ) {
761
-                $_key   = str_replace( 'wpinv_', '', $key );
759
+        foreach (array('wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code') as $key) {
760
+            if (isset($_POST[$key])) {
761
+                $_key   = str_replace('wpinv_', '', $key);
762 762
                 $method = "set_$_key";
763
-                $invoice->$method( sanitize_text_field( $_POST[ $key ] ) );
763
+                $invoice->$method(sanitize_text_field($_POST[$key]));
764 764
             }
765 765
         }
766 766
 
767
-        $discount = new WPInv_Discount( $invoice->get_discount_code() );
768
-        if ( $discount->exists() ) {
769
-            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
767
+        $discount = new WPInv_Discount($invoice->get_discount_code());
768
+        if ($discount->exists()) {
769
+            $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
770 770
         } else {
771
-            $invoice->remove_discount( 'discount_code' );
771
+            $invoice->remove_discount('discount_code');
772 772
         }
773 773
 
774 774
         // Save the invoice.
775 775
         $invoice->recalculate_total();
776 776
         $invoice->save();
777 777
         ob_start();
778
-        GetPaid_Meta_Box_Invoice_Items::output( get_post( $invoice->get_id() ), $invoice );
778
+        GetPaid_Meta_Box_Invoice_Items::output(get_post($invoice->get_id()), $invoice);
779 779
         $table = ob_get_clean();
780
-        wp_send_json_success( compact( 'table' ) );
780
+        wp_send_json_success(compact('table'));
781 781
     }
782 782
 
783 783
     /**
@@ -786,42 +786,42 @@  discard block
 block discarded – undo
786 786
     public static function admin_add_invoice_item() {
787 787
 
788 788
         // Verify nonce.
789
-        check_ajax_referer( 'wpinv-nonce' );
789
+        check_ajax_referer('wpinv-nonce');
790 790
 
791
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
791
+        if (!wpinv_current_user_can_manage_invoicing()) {
792 792
             exit;
793 793
         }
794 794
 
795 795
         // We need an invoice and item.
796
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) {
796
+        if (empty($_POST['post_id']) || empty($_POST['item_id'])) {
797 797
             exit;
798 798
         }
799 799
 
800 800
         // Fetch the invoice.
801
-        $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) );
801
+        $invoice = new WPInv_Invoice(intval($_POST['post_id']));
802 802
         $alert   = false;
803 803
 
804 804
         // Ensure it exists and its not been paid for.
805
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
805
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
806 806
             exit;
807 807
         }
808 808
 
809 809
         // Add the item.
810
-        $item  = new GetPaid_Form_Item( (int) $_POST['item_id'] );
811
-        $error = $invoice->add_item( $item );
810
+        $item  = new GetPaid_Form_Item((int) $_POST['item_id']);
811
+        $error = $invoice->add_item($item);
812 812
 
813
-        if ( is_wp_error( $error ) ) {
813
+        if (is_wp_error($error)) {
814 814
             $alert = $error->get_error_message();
815
-            wp_send_json_success( compact( 'alert' ) );
815
+            wp_send_json_success(compact('alert'));
816 816
         }
817 817
 
818 818
         // Save the invoice.
819 819
         $invoice->recalculate_total();
820 820
         $invoice->save();
821 821
         ob_start();
822
-        GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice );
822
+        GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice);
823 823
         $row = ob_get_clean();
824
-        wp_send_json_success( compact( 'row' ) );
824
+        wp_send_json_success(compact('row'));
825 825
     }
826 826
 
827 827
     /**
@@ -830,39 +830,39 @@  discard block
 block discarded – undo
830 830
     public static function add_invoice_items() {
831 831
 
832 832
         // Verify nonce.
833
-        check_ajax_referer( 'wpinv-nonce' );
833
+        check_ajax_referer('wpinv-nonce');
834 834
 
835
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
835
+        if (!wpinv_current_user_can_manage_invoicing()) {
836 836
             exit;
837 837
         }
838 838
 
839 839
         // We need an invoice and items.
840
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) {
840
+        if (empty($_POST['post_id']) || empty($_POST['items'])) {
841 841
             exit;
842 842
         }
843 843
 
844 844
         // Fetch the invoice.
845
-        $invoice = new WPInv_Invoice( intval( $_POST['post_id'] ) );
845
+        $invoice = new WPInv_Invoice(intval($_POST['post_id']));
846 846
         $alert   = false;
847 847
 
848 848
         // Ensure it exists and its not been paid for.
849
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
849
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
850 850
             exit;
851 851
         }
852 852
 
853 853
         // Add the items.
854
-        foreach ( wp_kses_post_deep( wp_unslash( $_POST['items'] ) ) as $data ) {
854
+        foreach (wp_kses_post_deep(wp_unslash($_POST['items'])) as $data) {
855 855
 
856
-            $item = new GetPaid_Form_Item( (int) $data['id'] );
856
+            $item = new GetPaid_Form_Item((int) $data['id']);
857 857
 
858
-            if ( is_numeric( $data['qty'] ) && (float) $data['qty'] > 0 ) {
859
-                $item->set_quantity( floatval( $data['qty'] ) );
858
+            if (is_numeric($data['qty']) && (float) $data['qty'] > 0) {
859
+                $item->set_quantity(floatval($data['qty']));
860 860
             }
861 861
 
862
-            if ( $item->get_id() > 0 ) {
863
-                $error = $invoice->add_item( $item );
862
+            if ($item->get_id() > 0) {
863
+                $error = $invoice->add_item($item);
864 864
 
865
-                if ( is_wp_error( $error ) ) {
865
+                if (is_wp_error($error)) {
866 866
                     $alert = $error->get_error_message();
867 867
                 }
868 868
 }
@@ -875,11 +875,11 @@  discard block
 block discarded – undo
875 875
         // Return an array of invoice items.
876 876
         $items = array();
877 877
 
878
-        foreach ( $invoice->get_items() as $item ) {
879
-            $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() );
878
+        foreach ($invoice->get_items() as $item) {
879
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
880 880
         }
881 881
 
882
-        wp_send_json_success( compact( 'items', 'alert' ) );
882
+        wp_send_json_success(compact('items', 'alert'));
883 883
     }
884 884
 
885 885
     /**
@@ -888,15 +888,15 @@  discard block
 block discarded – undo
888 888
     public static function get_invoicing_items() {
889 889
 
890 890
         // Verify nonce.
891
-        check_ajax_referer( 'wpinv-nonce' );
891
+        check_ajax_referer('wpinv-nonce');
892 892
 
893
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
893
+        if (!wpinv_current_user_can_manage_invoicing()) {
894 894
             exit;
895 895
         }
896 896
 
897 897
         // We need a search term.
898
-        if ( empty( $_GET['search'] ) ) {
899
-            wp_send_json_success( array() );
898
+        if (empty($_GET['search'])) {
899
+            wp_send_json_success(array());
900 900
         }
901 901
 
902 902
         // Retrieve items.
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
             'orderby'        => 'title',
906 906
             'order'          => 'ASC',
907 907
             'posts_per_page' => -1,
908
-            'post_status'    => array( 'publish' ),
909
-            's'              => sanitize_text_field( urldecode( $_GET['search'] ) ),
908
+            'post_status'    => array('publish'),
909
+            's'              => sanitize_text_field(urldecode($_GET['search'])),
910 910
             'meta_query'     => array(
911 911
                 array(
912 912
                     'key'     => '_wpinv_type',
@@ -916,25 +916,25 @@  discard block
 block discarded – undo
916 916
             ),
917 917
         );
918 918
 
919
-        if ( ! empty( $_GET['ignore'] ) ) {
920
-            $item_args['exclude'] = wp_parse_id_list( sanitize_text_field( $_GET['ignore'] ) );
919
+        if (!empty($_GET['ignore'])) {
920
+            $item_args['exclude'] = wp_parse_id_list(sanitize_text_field($_GET['ignore']));
921 921
         }
922 922
 
923
-        $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) );
923
+        $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args));
924 924
         $data  = array();
925 925
 
926
-        $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( (int) $_GET['post_id'] ) );
926
+        $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type((int) $_GET['post_id']));
927 927
 
928
-        foreach ( $items as $item ) {
929
-            $item      = new GetPaid_Form_Item( $item );
928
+        foreach ($items as $item) {
929
+            $item = new GetPaid_Form_Item($item);
930 930
             $data[] = array(
931 931
                 'id'        => (int) $item->get_id(),
932
-                'text'      => strip_tags( $item->get_name() ),
933
-                'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '',
932
+                'text'      => strip_tags($item->get_name()),
933
+                'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '',
934 934
             );
935 935
         }
936 936
 
937
-        wp_send_json_success( $data );
937
+        wp_send_json_success($data);
938 938
 
939 939
     }
940 940
 
@@ -944,37 +944,37 @@  discard block
 block discarded – undo
944 944
     public static function get_customers() {
945 945
 
946 946
         // Verify nonce.
947
-        check_ajax_referer( 'wpinv-nonce' );
947
+        check_ajax_referer('wpinv-nonce');
948 948
 
949
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
949
+        if (!wpinv_current_user_can_manage_invoicing()) {
950 950
             exit;
951 951
         }
952 952
 
953 953
         // We need a search term.
954
-        if ( empty( $_GET['search'] ) ) {
955
-            wp_send_json_success( array() );
954
+        if (empty($_GET['search'])) {
955
+            wp_send_json_success(array());
956 956
         }
957 957
 
958 958
         // Retrieve customers.
959 959
 
960 960
         $customer_args = array(
961
-            'fields'         => array( 'ID', 'user_email', 'display_name' ),
961
+            'fields'         => array('ID', 'user_email', 'display_name'),
962 962
             'orderby'        => 'display_name',
963
-            'search'         => '*' . sanitize_text_field( $_GET['search'] ) . '*',
964
-            'search_columns' => array( 'user_login', 'user_email', 'display_name' ),
963
+            'search'         => '*' . sanitize_text_field($_GET['search']) . '*',
964
+            'search_columns' => array('user_login', 'user_email', 'display_name'),
965 965
         );
966 966
 
967
-        $customers = get_users( apply_filters( 'getpaid_ajax_invoice_customers_query_args', $customer_args ) );
967
+        $customers = get_users(apply_filters('getpaid_ajax_invoice_customers_query_args', $customer_args));
968 968
         $data      = array();
969 969
 
970
-        foreach ( $customers as $customer ) {
970
+        foreach ($customers as $customer) {
971 971
             $data[] = array(
972 972
                 'id'   => (int) $customer->ID,
973
-                'text' => strip_tags( sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ) ),
973
+                'text' => strip_tags(sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email)),
974 974
             );
975 975
         }
976 976
 
977
-        wp_send_json_success( $data );
977
+        wp_send_json_success($data);
978 978
 
979 979
     }
980 980
 
@@ -984,25 +984,25 @@  discard block
 block discarded – undo
984 984
     public static function get_aui_states_field() {
985 985
 
986 986
         // We need a country.
987
-        if ( empty( $_GET['country'] ) ) {
987
+        if (empty($_GET['country'])) {
988 988
             exit;
989 989
         }
990 990
 
991
-        $states = wpinv_get_country_states( sanitize_text_field( $_GET['country'] ) );
992
-        $state  = isset( $_GET['state'] ) ? sanitize_text_field( $_GET['state'] ) : wpinv_get_default_state();
993
-        $name   = isset( $_GET['name'] ) ? sanitize_text_field( $_GET['name'] ) : 'wpinv_state';
994
-        $class  = isset( $_GET['class'] ) ? sanitize_text_field( $_GET['class'] ) : 'form-control-sm';
991
+        $states = wpinv_get_country_states(sanitize_text_field($_GET['country']));
992
+        $state  = isset($_GET['state']) ? sanitize_text_field($_GET['state']) : wpinv_get_default_state();
993
+        $name   = isset($_GET['name']) ? sanitize_text_field($_GET['name']) : 'wpinv_state';
994
+        $class  = isset($_GET['class']) ? sanitize_text_field($_GET['class']) : 'form-control-sm';
995 995
 
996
-        if ( empty( $states ) ) {
996
+        if (empty($states)) {
997 997
 
998 998
             $html = aui()->input(
999 999
                 array(
1000 1000
                     'type'        => 'text',
1001 1001
                     'id'          => 'wpinv_state',
1002 1002
                     'name'        => $name,
1003
-                    'label'       => __( 'State', 'invoicing' ),
1003
+                    'label'       => __('State', 'invoicing'),
1004 1004
                     'label_type'  => 'vertical',
1005
-                    'placeholder' => __( 'State', 'invoicing' ),
1005
+                    'placeholder' => __('State', 'invoicing'),
1006 1006
                     'class'       => $class,
1007 1007
                     'value'       => $state,
1008 1008
                 )
@@ -1014,9 +1014,9 @@  discard block
 block discarded – undo
1014 1014
                 array(
1015 1015
                     'id'               => 'wpinv_state',
1016 1016
                     'name'             => $name,
1017
-                    'label'            => __( 'State', 'invoicing' ),
1017
+                    'label'            => __('State', 'invoicing'),
1018 1018
                     'label_type'       => 'vertical',
1019
-                    'placeholder'      => __( 'Select a state', 'invoicing' ),
1019
+                    'placeholder'      => __('Select a state', 'invoicing'),
1020 1020
                     'class'            => $class,
1021 1021
                     'value'            => $state,
1022 1022
                     'options'          => $states,
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
         wp_send_json_success(
1031 1031
             array(
1032 1032
                 'html'   => $html,
1033
-                'select' => ! empty( $states ),
1033
+                'select' => !empty($states),
1034 1034
             )
1035 1035
         );
1036 1036
 
@@ -1044,8 +1044,8 @@  discard block
 block discarded – undo
1044 1044
     public static function payment_form_refresh_prices() {
1045 1045
 
1046 1046
         // ... form fields...
1047
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
1048
-            esc_html_e( 'Error: Reload the page and try again.', 'invoicing' );
1047
+        if (empty($_POST['getpaid_payment_form_submission'])) {
1048
+            esc_html_e('Error: Reload the page and try again.', 'invoicing');
1049 1049
             exit;
1050 1050
         }
1051 1051
 
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
         $submission = new GetPaid_Payment_Form_Submission();
1054 1054
 
1055 1055
         // Do we have an error?
1056
-        if ( ! empty( $submission->last_error ) ) {
1056
+        if (!empty($submission->last_error)) {
1057 1057
             wp_send_json_error(
1058 1058
                 array(
1059 1059
                     'code'  => $submission->last_error_code,
@@ -1063,12 +1063,12 @@  discard block
 block discarded – undo
1063 1063
         }
1064 1064
 
1065 1065
         // Prepare the response.
1066
-        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission );
1066
+        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission);
1067 1067
 
1068 1068
         // Filter the response.
1069
-        $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission );
1069
+        $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission);
1070 1070
 
1071
-        wp_send_json_success( $response );
1071
+        wp_send_json_success($response);
1072 1072
     }
1073 1073
 
1074 1074
     /**
@@ -1080,63 +1080,63 @@  discard block
 block discarded – undo
1080 1080
 	public static function file_upload() {
1081 1081
 
1082 1082
         // Check nonce.
1083
-        check_ajax_referer( 'getpaid_form_nonce' );
1083
+        check_ajax_referer('getpaid_form_nonce');
1084 1084
 
1085
-        if ( empty( $_POST['form_id'] ) || empty( $_POST['field_name'] ) || empty( $_FILES['file'] ) ) {
1086
-            wp_die( esc_html_e( 'Bad Request', 'invoicing' ), 400 );
1085
+        if (empty($_POST['form_id']) || empty($_POST['field_name']) || empty($_FILES['file'])) {
1086
+            wp_die(esc_html_e('Bad Request', 'invoicing'), 400);
1087 1087
         }
1088 1088
 
1089 1089
         // Fetch form.
1090
-        $form = new GetPaid_Payment_Form( intval( $_POST['form_id'] ) );
1090
+        $form = new GetPaid_Payment_Form(intval($_POST['form_id']));
1091 1091
 
1092
-        if ( ! $form->is_active() ) {
1093
-            wp_send_json_error( __( 'Payment form not active', 'invoicing' ) );
1092
+        if (!$form->is_active()) {
1093
+            wp_send_json_error(__('Payment form not active', 'invoicing'));
1094 1094
         }
1095 1095
 
1096 1096
         // Fetch appropriate field.
1097
-        $upload_field = current( wp_list_filter( $form->get_elements(), array( 'id' => sanitize_text_field( $_POST['field_name'] ) ) ) );
1098
-        if ( empty( $upload_field ) ) {
1099
-            wp_send_json_error( __( 'Invalid upload field.', 'invoicing' ) );
1097
+        $upload_field = current(wp_list_filter($form->get_elements(), array('id' => sanitize_text_field($_POST['field_name']))));
1098
+        if (empty($upload_field)) {
1099
+            wp_send_json_error(__('Invalid upload field.', 'invoicing'));
1100 1100
         }
1101 1101
 
1102 1102
         // Prepare allowed file types.
1103
-        $file_types = isset( $upload_field['file_types'] ) ? $upload_field['file_types'] : array( 'jpg|jpeg|jpe', 'gif', 'png' );
1103
+        $file_types = isset($upload_field['file_types']) ? $upload_field['file_types'] : array('jpg|jpeg|jpe', 'gif', 'png');
1104 1104
         $all_types  = getpaid_get_allowed_mime_types();
1105 1105
         $mime_types = array();
1106 1106
 
1107
-        foreach ( $file_types as $file_type ) {
1108
-            if ( isset( $all_types[ $file_type ] ) ) {
1109
-                $mime_types[] = $all_types[ $file_type ];
1107
+        foreach ($file_types as $file_type) {
1108
+            if (isset($all_types[$file_type])) {
1109
+                $mime_types[] = $all_types[$file_type];
1110 1110
             }
1111 1111
         }
1112 1112
 
1113
-        if ( ! in_array( $_FILES['file']['type'], $mime_types ) ) {
1114
-            wp_send_json_error( __( 'Unsupported file type.', 'invoicing' ) );
1113
+        if (!in_array($_FILES['file']['type'], $mime_types)) {
1114
+            wp_send_json_error(__('Unsupported file type.', 'invoicing'));
1115 1115
         }
1116 1116
 
1117 1117
         // Upload file.
1118
-        $file_name = explode( '.', strtolower( $_FILES['file']['name'] ) );
1119
-        $file_name = uniqid( 'getpaid-' ) . '.' . array_pop( $file_name );
1118
+        $file_name = explode('.', strtolower($_FILES['file']['name']));
1119
+        $file_name = uniqid('getpaid-') . '.' . array_pop($file_name);
1120 1120
 
1121 1121
         $uploaded = wp_upload_bits(
1122 1122
             $file_name,
1123 1123
             null,
1124
-            file_get_contents( $_FILES['file']['tmp_name'] )
1124
+            file_get_contents($_FILES['file']['tmp_name'])
1125 1125
         );
1126 1126
 
1127
-        if ( ! empty( $uploaded['error'] ) ) {
1128
-            wp_send_json_error( $uploaded['error'] );
1127
+        if (!empty($uploaded['error'])) {
1128
+            wp_send_json_error($uploaded['error']);
1129 1129
         }
1130 1130
 
1131 1131
         // Retrieve response.
1132 1132
         $response = sprintf(
1133 1133
             '<input type="hidden" name="%s[%s]" value="%s" />',
1134
-            esc_attr( sanitize_text_field( $_POST['field_name'] ) ),
1135
-            esc_url( $uploaded['url'] ),
1136
-            esc_attr( sanitize_text_field( strtolower( $_FILES['file']['name'] ) ) )
1134
+            esc_attr(sanitize_text_field($_POST['field_name'])),
1135
+            esc_url($uploaded['url']),
1136
+            esc_attr(sanitize_text_field(strtolower($_FILES['file']['name'])))
1137 1137
         );
1138 1138
 
1139
-        wp_send_json_success( $response );
1139
+        wp_send_json_success($response);
1140 1140
 
1141 1141
 	}
1142 1142
 
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +590 added lines, -590 removed lines patch added patch discarded remove patch
@@ -14,635 +14,635 @@
 block discarded – undo
14 14
  */
15 15
 class WPInv_Plugin {
16 16
 
17
-	/**
18
-	 * GetPaid version.
19
-	 *
20
-	 * @var string
21
-	 */
22
-	public $version;
23
-
24
-	/**
25
-	 * Data container.
26
-	 *
27
-	 * @var array
28
-	 */
29
-	protected $data = array();
30
-
31
-	/**
32
-	 * Form elements instance.
33
-	 *
34
-	 * @var WPInv_Payment_Form_Elements
35
-	 */
36
-	public $form_elements;
37
-
38
-	/**
39
-	 * @var array An array of payment gateways.
40
-	 */
41
-	public $gateways;
42
-
43
-	/**
44
-	 * Class constructor.
45
-	 */
46
-	public function __construct() {
47
-		$this->define_constants();
48
-		$this->includes();
49
-		$this->init_hooks();
50
-		$this->set_properties();
51
-	}
52
-
53
-	/**
54
-	 * Sets a custom data property.
55
-	 *
56
-	 * @param string $prop The prop to set.
57
-	 * @param mixed $value The value to retrieve.
58
-	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
61
-	}
62
-
63
-	/**
64
-	 * Gets a custom data property.
65
-	 *
66
-	 * @param string $prop The prop to set.
67
-	 * @return mixed The value.
68
-	 */
69
-	public function get( $prop ) {
70
-
71
-		if ( isset( $this->data[ $prop ] ) ) {
72
-			return $this->data[ $prop ];
73
-		}
74
-
75
-		return null;
76
-	}
77
-
78
-	/**
79
-	 * Define class properties.
80
-	 */
81
-	public function set_properties() {
82
-
83
-		// Sessions.
84
-		$this->set( 'session', new WPInv_Session_Handler() );
85
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
86
-		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87
-
88
-		// Init other objects.
89
-		$this->set( 'notes', new WPInv_Notes() );
90
-		$this->set( 'api', new WPInv_API() );
91
-		$this->set( 'post_types', new GetPaid_Post_Types() );
92
-		$this->set( 'template', new GetPaid_Template() );
93
-		$this->set( 'admin', new GetPaid_Admin() );
94
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
95
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
96
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
97
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
98
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
99
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
100
-
101
-	}
102
-
103
-	 /**
104
-	 * Define plugin constants.
105
-	 */
106
-	public function define_constants() {
107
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
108
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
109
-		$this->version = WPINV_VERSION;
110
-	}
111
-
112
-	/**
113
-	 * Hook into actions and filters.
114
-	 *
115
-	 * @since 1.0.19
116
-	 */
117
-	protected function init_hooks() {
118
-		/* Internationalize the text strings used. */
119
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
120
-
121
-		// Init the plugin after WordPress inits.
122
-		add_action( 'init', array( $this, 'init' ), 1 );
123
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
124
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
125
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
126
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
127
-		add_action( 'wp_footer', array( $this, 'wp_footer' ) );
128
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
129
-		add_action( 'widgets_init', array( $this, 'register_widgets' ) );
130
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
131
-		add_filter( 'the_seo_framework_sitemap_supported_post_types', array( $this, 'exclude_invoicing_post_types' ) );
132
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
133
-
134
-		add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
17
+    /**
18
+     * GetPaid version.
19
+     *
20
+     * @var string
21
+     */
22
+    public $version;
23
+
24
+    /**
25
+     * Data container.
26
+     *
27
+     * @var array
28
+     */
29
+    protected $data = array();
30
+
31
+    /**
32
+     * Form elements instance.
33
+     *
34
+     * @var WPInv_Payment_Form_Elements
35
+     */
36
+    public $form_elements;
37
+
38
+    /**
39
+     * @var array An array of payment gateways.
40
+     */
41
+    public $gateways;
42
+
43
+    /**
44
+     * Class constructor.
45
+     */
46
+    public function __construct() {
47
+        $this->define_constants();
48
+        $this->includes();
49
+        $this->init_hooks();
50
+        $this->set_properties();
51
+    }
52
+
53
+    /**
54
+     * Sets a custom data property.
55
+     *
56
+     * @param string $prop The prop to set.
57
+     * @param mixed $value The value to retrieve.
58
+     */
59
+    public function set( $prop, $value ) {
60
+        $this->data[ $prop ] = $value;
61
+    }
62
+
63
+    /**
64
+     * Gets a custom data property.
65
+     *
66
+     * @param string $prop The prop to set.
67
+     * @return mixed The value.
68
+     */
69
+    public function get( $prop ) {
70
+
71
+        if ( isset( $this->data[ $prop ] ) ) {
72
+            return $this->data[ $prop ];
73
+        }
74
+
75
+        return null;
76
+    }
77
+
78
+    /**
79
+     * Define class properties.
80
+     */
81
+    public function set_properties() {
82
+
83
+        // Sessions.
84
+        $this->set( 'session', new WPInv_Session_Handler() );
85
+        $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
86
+        $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87
+
88
+        // Init other objects.
89
+        $this->set( 'notes', new WPInv_Notes() );
90
+        $this->set( 'api', new WPInv_API() );
91
+        $this->set( 'post_types', new GetPaid_Post_Types() );
92
+        $this->set( 'template', new GetPaid_Template() );
93
+        $this->set( 'admin', new GetPaid_Admin() );
94
+        $this->set( 'subscriptions', new WPInv_Subscriptions() );
95
+        $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
96
+        $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
97
+        $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
98
+        $this->set( 'payment_forms', new GetPaid_Payment_Forms() );
99
+        $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
100
+
101
+    }
102
+
103
+        /**
104
+         * Define plugin constants.
105
+         */
106
+    public function define_constants() {
107
+        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
108
+        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
109
+        $this->version = WPINV_VERSION;
110
+    }
111
+
112
+    /**
113
+     * Hook into actions and filters.
114
+     *
115
+     * @since 1.0.19
116
+     */
117
+    protected function init_hooks() {
118
+        /* Internationalize the text strings used. */
119
+        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
120
+
121
+        // Init the plugin after WordPress inits.
122
+        add_action( 'init', array( $this, 'init' ), 1 );
123
+        add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
124
+        add_action( 'init', array( $this, 'wpinv_actions' ) );
125
+        add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
126
+        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
127
+        add_action( 'wp_footer', array( $this, 'wp_footer' ) );
128
+        add_action( 'wp_head', array( $this, 'wp_head' ) );
129
+        add_action( 'widgets_init', array( $this, 'register_widgets' ) );
130
+        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
131
+        add_filter( 'the_seo_framework_sitemap_supported_post_types', array( $this, 'exclude_invoicing_post_types' ) );
132
+        add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
133
+
134
+        add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
135 135
         add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
136
-		add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
137
-
138
-		// Fires after registering actions.
139
-		do_action( 'wpinv_actions', $this );
140
-		do_action( 'getpaid_actions', $this );
141
-
142
-	}
143
-
144
-	public function plugins_loaded() {
145
-		/* Internationalize the text strings used. */
146
-		$this->load_textdomain();
147
-
148
-		do_action( 'wpinv_loaded' );
149
-
150
-		// Fix oxygen page builder conflict
151
-		if ( function_exists( 'ct_css_output' ) ) {
152
-			wpinv_oxygen_fix_conflict();
153
-		}
154
-	}
155
-
156
-	/**
157
-	 * Load Localisation files.
158
-	 *
159
-	 * Note: the first-loaded translation file overrides any following ones if the same translation is present.
160
-	 *
161
-	 * Locales found in:
162
-	 *      - WP_LANG_DIR/plugins/invoicing-LOCALE.mo
163
-	 *      - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo
164
-	 *
165
-	 * @since 1.0.0
166
-	 */
167
-	public function load_textdomain() {
168
-
169
-		load_plugin_textdomain(
170
-			'invoicing',
171
-			false,
172
-			plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/'
173
-		);
174
-
175
-	}
176
-
177
-	/**
178
-	 * Include required core files used in admin and on the frontend.
179
-	 */
180
-	public function includes() {
181
-
182
-		// Start with the settings.
183
-		require_once WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php';
184
-
185
-		// Packages/libraries.
186
-		require_once WPINV_PLUGIN_DIR . 'vendor/autoload.php';
187
-		require_once WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php';
188
-
189
-		// Load functions.
190
-		require_once WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php';
191
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php';
192
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php';
193
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php';
194
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php';
195
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php';
196
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php';
197
-		require_once WPINV_PLUGIN_DIR . 'includes/invoice-functions.php';
198
-		require_once WPINV_PLUGIN_DIR . 'includes/subscription-functions.php';
199
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php';
200
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php';
201
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php';
202
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php';
203
-		require_once WPINV_PLUGIN_DIR . 'includes/user-functions.php';
204
-		require_once WPINV_PLUGIN_DIR . 'includes/error-functions.php';
205
-
206
-		// Register autoloader.
207
-		try {
208
-			spl_autoload_register( array( $this, 'autoload' ), true );
209
-		} catch ( Exception $e ) {
210
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
211
-		}
212
-
213
-		require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php';
214
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php';
215
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php';
216
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php';
217
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php';
218
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php';
219
-		require_once WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php';
220
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php';
221
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php';
222
-		require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php';
223
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php';
224
-		require_once WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php';
225
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php';
226
-		require_once WPINV_PLUGIN_DIR . 'widgets/checkout.php';
227
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice-history.php';
228
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php';
229
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php';
230
-		require_once WPINV_PLUGIN_DIR . 'widgets/subscriptions.php';
231
-		require_once WPINV_PLUGIN_DIR . 'widgets/buy-item.php';
232
-		require_once WPINV_PLUGIN_DIR . 'widgets/getpaid.php';
233
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php';
234
-		require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php';
235
-
236
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
237
-			GetPaid_Post_Types_Admin::init();
238
-
239
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php';
240
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php';
241
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php';
242
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php';
243
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php';
244
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php';
245
-			// load the user class only on the users.php page
246
-			global $pagenow;
247
-			if ( $pagenow == 'users.php' ) {
248
-				new WPInv_Admin_Users();
249
-			}
250
-		}
251
-
252
-		// Register cli commands
253
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
254
-			require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php';
255
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
256
-		}
257
-
258
-	}
259
-
260
-	/**
261
-	 * Class autoloader
262
-	 *
263
-	 * @param       string $class_name The name of the class to load.
264
-	 * @access      public
265
-	 * @since       1.0.19
266
-	 * @return      void
267
-	 */
268
-	public function autoload( $class_name ) {
269
-
270
-		// Normalize the class name...
271
-		$class_name  = strtolower( $class_name );
272
-
273
-		// ... and make sure it is our class.
274
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
275
-			return;
276
-		}
277
-
278
-		// Next, prepare the file name from the class.
279
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
280
-
281
-		// Base path of the classes.
282
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
283
-
284
-		// And an array of possible locations in order of importance.
285
-		$locations = array(
286
-			"$plugin_path/includes",
287
-			"$plugin_path/includes/data-stores",
288
-			"$plugin_path/includes/gateways",
289
-			"$plugin_path/includes/payments",
290
-			"$plugin_path/includes/geolocation",
291
-			"$plugin_path/includes/reports",
292
-			"$plugin_path/includes/api",
293
-			"$plugin_path/includes/admin",
294
-			"$plugin_path/includes/admin/meta-boxes",
295
-		);
296
-
297
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
298
-
299
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
300
-				include trailingslashit( $location ) . $file_name;
301
-				break;
302
-			}
136
+        add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
137
+
138
+        // Fires after registering actions.
139
+        do_action( 'wpinv_actions', $this );
140
+        do_action( 'getpaid_actions', $this );
141
+
142
+    }
143
+
144
+    public function plugins_loaded() {
145
+        /* Internationalize the text strings used. */
146
+        $this->load_textdomain();
147
+
148
+        do_action( 'wpinv_loaded' );
149
+
150
+        // Fix oxygen page builder conflict
151
+        if ( function_exists( 'ct_css_output' ) ) {
152
+            wpinv_oxygen_fix_conflict();
153
+        }
154
+    }
155
+
156
+    /**
157
+     * Load Localisation files.
158
+     *
159
+     * Note: the first-loaded translation file overrides any following ones if the same translation is present.
160
+     *
161
+     * Locales found in:
162
+     *      - WP_LANG_DIR/plugins/invoicing-LOCALE.mo
163
+     *      - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo
164
+     *
165
+     * @since 1.0.0
166
+     */
167
+    public function load_textdomain() {
168
+
169
+        load_plugin_textdomain(
170
+            'invoicing',
171
+            false,
172
+            plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/'
173
+        );
174
+
175
+    }
176
+
177
+    /**
178
+     * Include required core files used in admin and on the frontend.
179
+     */
180
+    public function includes() {
181
+
182
+        // Start with the settings.
183
+        require_once WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php';
184
+
185
+        // Packages/libraries.
186
+        require_once WPINV_PLUGIN_DIR . 'vendor/autoload.php';
187
+        require_once WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php';
188
+
189
+        // Load functions.
190
+        require_once WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php';
191
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php';
192
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php';
193
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php';
194
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php';
195
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php';
196
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php';
197
+        require_once WPINV_PLUGIN_DIR . 'includes/invoice-functions.php';
198
+        require_once WPINV_PLUGIN_DIR . 'includes/subscription-functions.php';
199
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php';
200
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php';
201
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php';
202
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php';
203
+        require_once WPINV_PLUGIN_DIR . 'includes/user-functions.php';
204
+        require_once WPINV_PLUGIN_DIR . 'includes/error-functions.php';
205
+
206
+        // Register autoloader.
207
+        try {
208
+            spl_autoload_register( array( $this, 'autoload' ), true );
209
+        } catch ( Exception $e ) {
210
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
211
+        }
212
+
213
+        require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php';
214
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php';
215
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php';
216
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php';
217
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php';
218
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php';
219
+        require_once WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php';
220
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php';
221
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php';
222
+        require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php';
223
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php';
224
+        require_once WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php';
225
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php';
226
+        require_once WPINV_PLUGIN_DIR . 'widgets/checkout.php';
227
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice-history.php';
228
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php';
229
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php';
230
+        require_once WPINV_PLUGIN_DIR . 'widgets/subscriptions.php';
231
+        require_once WPINV_PLUGIN_DIR . 'widgets/buy-item.php';
232
+        require_once WPINV_PLUGIN_DIR . 'widgets/getpaid.php';
233
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php';
234
+        require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php';
235
+
236
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
237
+            GetPaid_Post_Types_Admin::init();
238
+
239
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php';
240
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php';
241
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php';
242
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php';
243
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php';
244
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php';
245
+            // load the user class only on the users.php page
246
+            global $pagenow;
247
+            if ( $pagenow == 'users.php' ) {
248
+                new WPInv_Admin_Users();
249
+            }
250
+        }
251
+
252
+        // Register cli commands
253
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
254
+            require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php';
255
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
256
+        }
257
+
258
+    }
259
+
260
+    /**
261
+     * Class autoloader
262
+     *
263
+     * @param       string $class_name The name of the class to load.
264
+     * @access      public
265
+     * @since       1.0.19
266
+     * @return      void
267
+     */
268
+    public function autoload( $class_name ) {
269
+
270
+        // Normalize the class name...
271
+        $class_name  = strtolower( $class_name );
272
+
273
+        // ... and make sure it is our class.
274
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
275
+            return;
276
+        }
277
+
278
+        // Next, prepare the file name from the class.
279
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
280
+
281
+        // Base path of the classes.
282
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
283
+
284
+        // And an array of possible locations in order of importance.
285
+        $locations = array(
286
+            "$plugin_path/includes",
287
+            "$plugin_path/includes/data-stores",
288
+            "$plugin_path/includes/gateways",
289
+            "$plugin_path/includes/payments",
290
+            "$plugin_path/includes/geolocation",
291
+            "$plugin_path/includes/reports",
292
+            "$plugin_path/includes/api",
293
+            "$plugin_path/includes/admin",
294
+            "$plugin_path/includes/admin/meta-boxes",
295
+        );
296
+
297
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
298
+
299
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
300
+                include trailingslashit( $location ) . $file_name;
301
+                break;
302
+            }
303 303
 }
304 304
 
305
-	}
306
-
307
-	/**
308
-	 * Inits hooks etc.
309
-	 */
310
-	public function init() {
311
-
312
-		// Fires before getpaid inits.
313
-		do_action( 'before_getpaid_init', $this );
314
-
315
-		// Maybe upgrade.
316
-		$this->maybe_upgrade_database();
317
-
318
-		// Load default gateways.
319
-		$gateways = apply_filters(
320
-			'getpaid_default_gateways',
321
-			array(
322
-				'manual'        => 'GetPaid_Manual_Gateway',
323
-				'paypal'        => 'GetPaid_Paypal_Gateway',
324
-				'worldpay'      => 'GetPaid_Worldpay_Gateway',
325
-				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
326
-				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
327
-			)
328
-		);
329
-
330
-		foreach ( $gateways as $id => $class ) {
331
-			$this->gateways[ $id ] = new $class();
332
-		}
333
-
334
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
335
-			GetPaid_Installer::rename_gateways_label();
336
-			update_option( 'wpinv_renamed_gateways', 'yes' );
337
-		}
338
-
339
-		// Fires after getpaid inits.
340
-		do_action( 'getpaid_init', $this );
341
-
342
-	}
343
-
344
-	/**
345
-	 * Checks if this is an IPN request and processes it.
346
-	 */
347
-	public function maybe_process_ipn() {
348
-
349
-		// Ensure that this is an IPN request.
350
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
351
-			return;
352
-		}
353
-
354
-		$gateway = sanitize_text_field( $_GET['wpi-gateway'] );
355
-
356
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
357
-		do_action( "wpinv_verify_{$gateway}_ipn" );
358
-		exit;
359
-
360
-	}
361
-
362
-	public function enqueue_scripts() {
363
-
364
-		// Fires before adding scripts.
365
-		do_action( 'getpaid_enqueue_scripts' );
366
-
367
-		$localize                         = array();
368
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
369
-		$localize['thousands']            = wpinv_thousands_separator();
370
-		$localize['decimals']             = wpinv_decimal_separator();
371
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
372
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
373
-		$localize['UseTaxes']             = wpinv_use_taxes();
374
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
375
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
376
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
377
-
378
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
379
-
380
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
381
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true );
382
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
383
-	}
384
-
385
-	public function wpinv_actions() {
386
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
387
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
388
-		}
389
-
390
-		if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
391
-			include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
392
-		}
393
-	}
394
-
395
-	/**
305
+    }
306
+
307
+    /**
308
+     * Inits hooks etc.
309
+     */
310
+    public function init() {
311
+
312
+        // Fires before getpaid inits.
313
+        do_action( 'before_getpaid_init', $this );
314
+
315
+        // Maybe upgrade.
316
+        $this->maybe_upgrade_database();
317
+
318
+        // Load default gateways.
319
+        $gateways = apply_filters(
320
+            'getpaid_default_gateways',
321
+            array(
322
+                'manual'        => 'GetPaid_Manual_Gateway',
323
+                'paypal'        => 'GetPaid_Paypal_Gateway',
324
+                'worldpay'      => 'GetPaid_Worldpay_Gateway',
325
+                'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
326
+                'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
327
+            )
328
+        );
329
+
330
+        foreach ( $gateways as $id => $class ) {
331
+            $this->gateways[ $id ] = new $class();
332
+        }
333
+
334
+        if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
335
+            GetPaid_Installer::rename_gateways_label();
336
+            update_option( 'wpinv_renamed_gateways', 'yes' );
337
+        }
338
+
339
+        // Fires after getpaid inits.
340
+        do_action( 'getpaid_init', $this );
341
+
342
+    }
343
+
344
+    /**
345
+     * Checks if this is an IPN request and processes it.
346
+     */
347
+    public function maybe_process_ipn() {
348
+
349
+        // Ensure that this is an IPN request.
350
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
351
+            return;
352
+        }
353
+
354
+        $gateway = sanitize_text_field( $_GET['wpi-gateway'] );
355
+
356
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
357
+        do_action( "wpinv_verify_{$gateway}_ipn" );
358
+        exit;
359
+
360
+    }
361
+
362
+    public function enqueue_scripts() {
363
+
364
+        // Fires before adding scripts.
365
+        do_action( 'getpaid_enqueue_scripts' );
366
+
367
+        $localize                         = array();
368
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
369
+        $localize['thousands']            = wpinv_thousands_separator();
370
+        $localize['decimals']             = wpinv_decimal_separator();
371
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
372
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
373
+        $localize['UseTaxes']             = wpinv_use_taxes();
374
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
375
+        $localize['loading']              = __( 'Loading...', 'invoicing' );
376
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
377
+
378
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
379
+
380
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
381
+        wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true );
382
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
383
+    }
384
+
385
+    public function wpinv_actions() {
386
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
387
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
388
+        }
389
+
390
+        if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
391
+            include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
392
+        }
393
+    }
394
+
395
+    /**
396 396
      * Fires an action after verifying that a user can fire them.
397
-	 *
398
-	 * Note: If the action is on an invoice, subscription etc, esure that the
399
-	 * current user owns the invoice/subscription.
397
+     *
398
+     * Note: If the action is on an invoice, subscription etc, esure that the
399
+     * current user owns the invoice/subscription.
400 400
      */
401 401
     public function maybe_do_authenticated_action() {
402 402
 
403
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
403
+        if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
404 404
 
405
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
406
-			$data = wp_unslash( $_REQUEST );
407
-			if ( is_user_logged_in() ) {
408
-				do_action( "getpaid_authenticated_action_$key", $data );
409
-			}
405
+            $key  = sanitize_key( $_REQUEST['getpaid-action'] );
406
+            $data = wp_unslash( $_REQUEST );
407
+            if ( is_user_logged_in() ) {
408
+                do_action( "getpaid_authenticated_action_$key", $data );
409
+            }
410 410
 
411
-			do_action( "getpaid_unauthenticated_action_$key", $data );
411
+            do_action( "getpaid_unauthenticated_action_$key", $data );
412 412
 
413
-		}
413
+        }
414 414
 
415 415
     }
416 416
 
417
-	public function pre_get_posts( $wp_query ) {
418
-
419
-		if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
420
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
421
-		}
422
-
423
-		return $wp_query;
424
-	}
425
-
426
-	/**
427
-	 * Register widgets
428
-	 *
429
-	 */
430
-	public function register_widgets() {
431
-		global $pagenow;
432
-
433
-		// Currently, UX Builder does not work particulaly well with SuperDuper.
434
-		// So we disable our widgets when editing a page with UX Builder.
435
-		if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
436
-			return;
437
-		}
438
-
439
-		$block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array();
440
-
441
-		if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) {
442
-			// don't initiate in these conditions.
443
-		} else {
444
-
445
-			// Only load allowed widgets.
446
-			$exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
447
-			$widgets = apply_filters(
448
-				'getpaid_widget_classes',
449
-				array(
450
-					'WPInv_Checkout_Widget',
451
-					'WPInv_History_Widget',
452
-					'WPInv_Receipt_Widget',
453
-					'WPInv_Subscriptions_Widget',
454
-					'WPInv_Buy_Item_Widget',
455
-					'WPInv_Messages_Widget',
456
-					'WPInv_GetPaid_Widget',
457
-					'WPInv_Invoice_Widget',
458
-				)
459
-			);
460
-
461
-			// For each widget...
462
-			foreach ( $widgets as $widget ) {
463
-
464
-				// Abort early if it is excluded for this page.
465
-				if ( in_array( $widget, $exclude ) ) {
466
-					continue;
467
-				}
468
-
469
-				// SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
470
-				if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
471
-					register_widget( $widget );
472
-				} else {
473
-					new $widget();
474
-				}
417
+    public function pre_get_posts( $wp_query ) {
418
+
419
+        if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
420
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
421
+        }
422
+
423
+        return $wp_query;
424
+    }
425
+
426
+    /**
427
+     * Register widgets
428
+     *
429
+     */
430
+    public function register_widgets() {
431
+        global $pagenow;
432
+
433
+        // Currently, UX Builder does not work particulaly well with SuperDuper.
434
+        // So we disable our widgets when editing a page with UX Builder.
435
+        if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
436
+            return;
437
+        }
438
+
439
+        $block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array();
440
+
441
+        if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) {
442
+            // don't initiate in these conditions.
443
+        } else {
444
+
445
+            // Only load allowed widgets.
446
+            $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
447
+            $widgets = apply_filters(
448
+                'getpaid_widget_classes',
449
+                array(
450
+                    'WPInv_Checkout_Widget',
451
+                    'WPInv_History_Widget',
452
+                    'WPInv_Receipt_Widget',
453
+                    'WPInv_Subscriptions_Widget',
454
+                    'WPInv_Buy_Item_Widget',
455
+                    'WPInv_Messages_Widget',
456
+                    'WPInv_GetPaid_Widget',
457
+                    'WPInv_Invoice_Widget',
458
+                )
459
+            );
460
+
461
+            // For each widget...
462
+            foreach ( $widgets as $widget ) {
463
+
464
+                // Abort early if it is excluded for this page.
465
+                if ( in_array( $widget, $exclude ) ) {
466
+                    continue;
467
+                }
468
+
469
+                // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
470
+                if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
471
+                    register_widget( $widget );
472
+                } else {
473
+                    new $widget();
474
+                }
475 475
 }
476 476
 }
477 477
 
478
-	}
478
+    }
479
+
480
+    /**
481
+     * Upgrades the database.
482
+     *
483
+     * @since 2.0.2
484
+     */
485
+    public function maybe_upgrade_database() {
486
+
487
+        $wpi_version = get_option( 'wpinv_version', 0 );
488
+
489
+        if ( $wpi_version == WPINV_VERSION ) {
490
+            return;
491
+        }
479 492
 
480
-	/**
481
-	 * Upgrades the database.
482
-	 *
483
-	 * @since 2.0.2
484
-	 */
485
-	public function maybe_upgrade_database() {
493
+        $installer = new GetPaid_Installer();
486 494
 
487
-		$wpi_version = get_option( 'wpinv_version', 0 );
495
+        if ( empty( $wpi_version ) ) {
496
+            return $installer->upgrade_db( 0 );
497
+        }
488 498
 
489
-		if ( $wpi_version == WPINV_VERSION ) {
490
-			return;
491
-		}
499
+        $upgrades  = array(
500
+            '0.0.5'  => '004',
501
+            '1.0.3'  => '102',
502
+            '2.0.0'  => '118',
503
+            '2.0.8'  => '207',
504
+            '2.6.16' => '2615',
505
+        );
492 506
 
493
-		$installer = new GetPaid_Installer();
507
+        foreach ( $upgrades as $key => $method ) {
508
+
509
+            if ( version_compare( $wpi_version, $key, '<' ) ) {
510
+                return $installer->upgrade_db( $method );
511
+            }
512
+        }
513
+
514
+    }
515
+
516
+    /**
517
+     * Flushes the permalinks if needed.
518
+     *
519
+     * @since 2.0.8
520
+     */
521
+    public function maybe_flush_permalinks() {
494 522
 
495
-		if ( empty( $wpi_version ) ) {
496
-			return $installer->upgrade_db( 0 );
497
-		}
523
+        $flush = get_option( 'wpinv_flush_permalinks', 0 );
498 524
 
499
-		$upgrades  = array(
500
-			'0.0.5'  => '004',
501
-			'1.0.3'  => '102',
502
-			'2.0.0'  => '118',
503
-			'2.0.8'  => '207',
504
-			'2.6.16' => '2615',
505
-		);
506
-
507
-		foreach ( $upgrades as $key => $method ) {
508
-
509
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
510
-				return $installer->upgrade_db( $method );
511
-			}
512
-		}
513
-
514
-	}
515
-
516
-	/**
517
-	 * Flushes the permalinks if needed.
518
-	 *
519
-	 * @since 2.0.8
520
-	 */
521
-	public function maybe_flush_permalinks() {
522
-
523
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
524
-
525
-		if ( ! empty( $flush ) ) {
526
-			flush_rewrite_rules();
527
-			delete_option( 'wpinv_flush_permalinks' );
528
-		}
529
-
530
-	}
531
-
532
-	/**
533
-	 * Remove our pages from yoast sitemaps.
534
-	 *
535
-	 * @since 1.0.19
536
-	 * @param int[] $excluded_posts_ids
537
-	 */
538
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) {
539
-
540
-		// Ensure that we have an array.
541
-		if ( ! is_array( $excluded_posts_ids ) ) {
542
-			$excluded_posts_ids = array();
543
-		}
544
-
545
-		// Prepare our pages.
546
-		$our_pages = array();
547
-
548
-		// Checkout page.
549
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
550
-
551
-		// Success page.
552
-		$our_pages[] = wpinv_get_option( 'success_page', false );
553
-
554
-		// Failure page.
555
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
556
-
557
-		// History page.
558
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
559
-
560
-		// Subscriptions page.
561
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
562
-
563
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
564
-
565
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
566
-		return array_unique( $excluded_posts_ids );
567
-
568
-	}
569
-
570
-	/**
571
-	 * Remove our pages from yoast sitemaps.
572
-	 *
573
-	 * @since 1.0.19
574
-	 * @param string[] $post_types
575
-	 */
576
-	public function exclude_invoicing_post_types( $post_types ) {
577
-
578
-		// Ensure that we have an array.
579
-		if ( ! is_array( $post_types ) ) {
580
-			$post_types = array();
581
-		}
582
-
583
-		// Remove our post types.
584
-		return array_diff( $post_types, array_keys( getpaid_get_invoice_post_types() ) );
585
-	}
586
-
587
-	/**
588
-	 * Displays additional footer code.
589
-	 *
590
-	 * @since 2.0.0
591
-	 */
592
-	public function wp_footer() {
593
-		wpinv_get_template( 'frontend-footer.php' );
594
-	}
595
-
596
-	/**
597
-	 * Displays additional header code.
598
-	 *
599
-	 * @since 2.0.0
600
-	 */
601
-	public function wp_head() {
602
-		wpinv_get_template( 'frontend-head.php' );
603
-	}
604
-
605
-	/**
606
-	 * Custom query vars.
607
-	 *
608
-	 */
609
-	public function custom_query_vars( $vars ) {
525
+        if ( ! empty( $flush ) ) {
526
+            flush_rewrite_rules();
527
+            delete_option( 'wpinv_flush_permalinks' );
528
+        }
529
+
530
+    }
531
+
532
+    /**
533
+     * Remove our pages from yoast sitemaps.
534
+     *
535
+     * @since 1.0.19
536
+     * @param int[] $excluded_posts_ids
537
+     */
538
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) {
539
+
540
+        // Ensure that we have an array.
541
+        if ( ! is_array( $excluded_posts_ids ) ) {
542
+            $excluded_posts_ids = array();
543
+        }
544
+
545
+        // Prepare our pages.
546
+        $our_pages = array();
547
+
548
+        // Checkout page.
549
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
550
+
551
+        // Success page.
552
+        $our_pages[] = wpinv_get_option( 'success_page', false );
553
+
554
+        // Failure page.
555
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
556
+
557
+        // History page.
558
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
559
+
560
+        // Subscriptions page.
561
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
562
+
563
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
564
+
565
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
566
+        return array_unique( $excluded_posts_ids );
567
+
568
+    }
569
+
570
+    /**
571
+     * Remove our pages from yoast sitemaps.
572
+     *
573
+     * @since 1.0.19
574
+     * @param string[] $post_types
575
+     */
576
+    public function exclude_invoicing_post_types( $post_types ) {
577
+
578
+        // Ensure that we have an array.
579
+        if ( ! is_array( $post_types ) ) {
580
+            $post_types = array();
581
+        }
582
+
583
+        // Remove our post types.
584
+        return array_diff( $post_types, array_keys( getpaid_get_invoice_post_types() ) );
585
+    }
586
+
587
+    /**
588
+     * Displays additional footer code.
589
+     *
590
+     * @since 2.0.0
591
+     */
592
+    public function wp_footer() {
593
+        wpinv_get_template( 'frontend-footer.php' );
594
+    }
595
+
596
+    /**
597
+     * Displays additional header code.
598
+     *
599
+     * @since 2.0.0
600
+     */
601
+    public function wp_head() {
602
+        wpinv_get_template( 'frontend-head.php' );
603
+    }
604
+
605
+    /**
606
+     * Custom query vars.
607
+     *
608
+     */
609
+    public function custom_query_vars( $vars ) {
610 610
         $vars[] = 'getpaid-ipn';
611 611
         return $vars;
612
-	}
612
+    }
613 613
 
614
-	/**
615
-	 * Add rewrite tags and rules.
616
-	 *
617
-	 */
618
-	public function add_rewrite_rule() {
614
+    /**
615
+     * Add rewrite tags and rules.
616
+     *
617
+     */
618
+    public function add_rewrite_rule() {
619 619
         $tag = 'getpaid-ipn';
620 620
         add_rewrite_tag( "%$tag%", '([^&]+)' );
621 621
         add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top' );
622
-	}
622
+    }
623 623
 
624
-	/**
625
-	 * Processes non-query string ipns.
626
-	 *
627
-	 */
628
-	public function maybe_process_new_ipn( $query ) {
624
+    /**
625
+     * Processes non-query string ipns.
626
+     *
627
+     */
628
+    public function maybe_process_new_ipn( $query ) {
629 629
 
630 630
         if ( is_admin() || ! $query->is_main_query() ) {
631 631
             return;
632 632
         }
633 633
 
634
-		$gateway = get_query_var( 'getpaid-ipn' );
634
+        $gateway = get_query_var( 'getpaid-ipn' );
635 635
 
636 636
         if ( ! empty( $gateway ) ) {
637 637
 
638
-			$gateway = sanitize_text_field( $gateway );
639
-			nocache_headers();
640
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
641
-			do_action( "wpinv_verify_{$gateway}_ipn" );
642
-			exit;
638
+            $gateway = sanitize_text_field( $gateway );
639
+            nocache_headers();
640
+            do_action( 'wpinv_verify_payment_ipn', $gateway );
641
+            do_action( "wpinv_verify_{$gateway}_ipn" );
642
+            exit;
643 643
 
644 644
         }
645 645
 
646
-	}
646
+    }
647 647
 
648 648
 }
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Main Invoicing class.
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param string $prop The prop to set.
57 57
 	 * @param mixed $value The value to retrieve.
58 58
 	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
59
+	public function set($prop, $value) {
60
+		$this->data[$prop] = $value;
61 61
 	}
62 62
 
63 63
 	/**
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 	 * @param string $prop The prop to set.
67 67
 	 * @return mixed The value.
68 68
 	 */
69
-	public function get( $prop ) {
69
+	public function get($prop) {
70 70
 
71
-		if ( isset( $this->data[ $prop ] ) ) {
72
-			return $this->data[ $prop ];
71
+		if (isset($this->data[$prop])) {
72
+			return $this->data[$prop];
73 73
 		}
74 74
 
75 75
 		return null;
@@ -81,22 +81,22 @@  discard block
 block discarded – undo
81 81
 	public function set_properties() {
82 82
 
83 83
 		// Sessions.
84
-		$this->set( 'session', new WPInv_Session_Handler() );
85
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
84
+		$this->set('session', new WPInv_Session_Handler());
85
+		$GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility.
86 86
 		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87 87
 
88 88
 		// Init other objects.
89
-		$this->set( 'notes', new WPInv_Notes() );
90
-		$this->set( 'api', new WPInv_API() );
91
-		$this->set( 'post_types', new GetPaid_Post_Types() );
92
-		$this->set( 'template', new GetPaid_Template() );
93
-		$this->set( 'admin', new GetPaid_Admin() );
94
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
95
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
96
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
97
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
98
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
99
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
89
+		$this->set('notes', new WPInv_Notes());
90
+		$this->set('api', new WPInv_API());
91
+		$this->set('post_types', new GetPaid_Post_Types());
92
+		$this->set('template', new GetPaid_Template());
93
+		$this->set('admin', new GetPaid_Admin());
94
+		$this->set('subscriptions', new WPInv_Subscriptions());
95
+		$this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails());
96
+		$this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails());
97
+		$this->set('daily_maintenace', new GetPaid_Daily_Maintenance());
98
+		$this->set('payment_forms', new GetPaid_Payment_Forms());
99
+		$this->set('maxmind', new GetPaid_MaxMind_Geolocation());
100 100
 
101 101
 	}
102 102
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * Define plugin constants.
105 105
 	 */
106 106
 	public function define_constants() {
107
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
108
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
107
+		define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
108
+		define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
109 109
 		$this->version = WPINV_VERSION;
110 110
 	}
111 111
 
@@ -116,28 +116,28 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	protected function init_hooks() {
118 118
 		/* Internationalize the text strings used. */
119
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
119
+		add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
120 120
 
121 121
 		// Init the plugin after WordPress inits.
122
-		add_action( 'init', array( $this, 'init' ), 1 );
123
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
124
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
125
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
126
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
127
-		add_action( 'wp_footer', array( $this, 'wp_footer' ) );
128
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
129
-		add_action( 'widgets_init', array( $this, 'register_widgets' ) );
130
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
131
-		add_filter( 'the_seo_framework_sitemap_supported_post_types', array( $this, 'exclude_invoicing_post_types' ) );
132
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
133
-
134
-		add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
135
-        add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
136
-		add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
122
+		add_action('init', array($this, 'init'), 1);
123
+		add_action('init', array($this, 'maybe_process_ipn'), 10);
124
+		add_action('init', array($this, 'wpinv_actions'));
125
+		add_action('init', array($this, 'maybe_do_authenticated_action'), 100);
126
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11);
127
+		add_action('wp_footer', array($this, 'wp_footer'));
128
+		add_action('wp_head', array($this, 'wp_head'));
129
+		add_action('widgets_init', array($this, 'register_widgets'));
130
+		add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
131
+		add_filter('the_seo_framework_sitemap_supported_post_types', array($this, 'exclude_invoicing_post_types'));
132
+		add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
133
+
134
+		add_filter('query_vars', array($this, 'custom_query_vars'));
135
+        add_action('init', array($this, 'add_rewrite_rule'), 10, 0);
136
+		add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1);
137 137
 
138 138
 		// Fires after registering actions.
139
-		do_action( 'wpinv_actions', $this );
140
-		do_action( 'getpaid_actions', $this );
139
+		do_action('wpinv_actions', $this);
140
+		do_action('getpaid_actions', $this);
141 141
 
142 142
 	}
143 143
 
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 		/* Internationalize the text strings used. */
146 146
 		$this->load_textdomain();
147 147
 
148
-		do_action( 'wpinv_loaded' );
148
+		do_action('wpinv_loaded');
149 149
 
150 150
 		// Fix oxygen page builder conflict
151
-		if ( function_exists( 'ct_css_output' ) ) {
151
+		if (function_exists('ct_css_output')) {
152 152
 			wpinv_oxygen_fix_conflict();
153 153
 		}
154 154
 	}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		load_plugin_textdomain(
170 170
 			'invoicing',
171 171
 			false,
172
-			plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/'
172
+			plugin_basename(dirname(WPINV_PLUGIN_FILE)) . '/languages/'
173 173
 		);
174 174
 
175 175
 	}
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
 
206 206
 		// Register autoloader.
207 207
 		try {
208
-			spl_autoload_register( array( $this, 'autoload' ), true );
209
-		} catch ( Exception $e ) {
210
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
208
+			spl_autoload_register(array($this, 'autoload'), true);
209
+		} catch (Exception $e) {
210
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
211 211
 		}
212 212
 
213 213
 		require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php';
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 		require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php';
234 234
 		require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php';
235 235
 
236
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
236
+		if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
237 237
 			GetPaid_Post_Types_Admin::init();
238 238
 
239 239
 			require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php';
@@ -244,15 +244,15 @@  discard block
 block discarded – undo
244 244
 			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php';
245 245
 			// load the user class only on the users.php page
246 246
 			global $pagenow;
247
-			if ( $pagenow == 'users.php' ) {
247
+			if ($pagenow == 'users.php') {
248 248
 				new WPInv_Admin_Users();
249 249
 			}
250 250
 		}
251 251
 
252 252
 		// Register cli commands
253
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
253
+		if (defined('WP_CLI') && WP_CLI) {
254 254
 			require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php';
255
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
255
+			WP_CLI::add_command('invoicing', 'WPInv_CLI');
256 256
 		}
257 257
 
258 258
 	}
@@ -265,21 +265,21 @@  discard block
 block discarded – undo
265 265
 	 * @since       1.0.19
266 266
 	 * @return      void
267 267
 	 */
268
-	public function autoload( $class_name ) {
268
+	public function autoload($class_name) {
269 269
 
270 270
 		// Normalize the class name...
271
-		$class_name  = strtolower( $class_name );
271
+		$class_name = strtolower($class_name);
272 272
 
273 273
 		// ... and make sure it is our class.
274
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
274
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
275 275
 			return;
276 276
 		}
277 277
 
278 278
 		// Next, prepare the file name from the class.
279
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
279
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
280 280
 
281 281
 		// Base path of the classes.
282
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
282
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
283 283
 
284 284
 		// And an array of possible locations in order of importance.
285 285
 		$locations = array(
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 			"$plugin_path/includes/admin/meta-boxes",
295 295
 		);
296 296
 
297
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
297
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
298 298
 
299
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
300
-				include trailingslashit( $location ) . $file_name;
299
+			if (file_exists(trailingslashit($location) . $file_name)) {
300
+				include trailingslashit($location) . $file_name;
301 301
 				break;
302 302
 			}
303 303
 }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	public function init() {
311 311
 
312 312
 		// Fires before getpaid inits.
313
-		do_action( 'before_getpaid_init', $this );
313
+		do_action('before_getpaid_init', $this);
314 314
 
315 315
 		// Maybe upgrade.
316 316
 		$this->maybe_upgrade_database();
@@ -327,17 +327,17 @@  discard block
 block discarded – undo
327 327
 			)
328 328
 		);
329 329
 
330
-		foreach ( $gateways as $id => $class ) {
331
-			$this->gateways[ $id ] = new $class();
330
+		foreach ($gateways as $id => $class) {
331
+			$this->gateways[$id] = new $class();
332 332
 		}
333 333
 
334
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
334
+		if ('yes' != get_option('wpinv_renamed_gateways')) {
335 335
 			GetPaid_Installer::rename_gateways_label();
336
-			update_option( 'wpinv_renamed_gateways', 'yes' );
336
+			update_option('wpinv_renamed_gateways', 'yes');
337 337
 		}
338 338
 
339 339
 		// Fires after getpaid inits.
340
-		do_action( 'getpaid_init', $this );
340
+		do_action('getpaid_init', $this);
341 341
 
342 342
 	}
343 343
 
@@ -347,14 +347,14 @@  discard block
 block discarded – undo
347 347
 	public function maybe_process_ipn() {
348 348
 
349 349
 		// Ensure that this is an IPN request.
350
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
350
+		if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
351 351
 			return;
352 352
 		}
353 353
 
354
-		$gateway = sanitize_text_field( $_GET['wpi-gateway'] );
354
+		$gateway = sanitize_text_field($_GET['wpi-gateway']);
355 355
 
356
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
357
-		do_action( "wpinv_verify_{$gateway}_ipn" );
356
+		do_action('wpinv_verify_payment_ipn', $gateway);
357
+		do_action("wpinv_verify_{$gateway}_ipn");
358 358
 		exit;
359 359
 
360 360
 	}
@@ -362,33 +362,33 @@  discard block
 block discarded – undo
362 362
 	public function enqueue_scripts() {
363 363
 
364 364
 		// Fires before adding scripts.
365
-		do_action( 'getpaid_enqueue_scripts' );
365
+		do_action('getpaid_enqueue_scripts');
366 366
 
367 367
 		$localize                         = array();
368
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
368
+		$localize['ajax_url']             = admin_url('admin-ajax.php');
369 369
 		$localize['thousands']            = wpinv_thousands_separator();
370 370
 		$localize['decimals']             = wpinv_decimal_separator();
371
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
372
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
371
+		$localize['nonce']                = wp_create_nonce('wpinv-nonce');
372
+		$localize['txtComplete']          = __('Continue', 'invoicing');
373 373
 		$localize['UseTaxes']             = wpinv_use_taxes();
374
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
375
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
376
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
374
+		$localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
375
+		$localize['loading']              = __('Loading...', 'invoicing');
376
+		$localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
377 377
 
378
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
378
+		$localize = apply_filters('wpinv_front_js_localize', $localize);
379 379
 
380
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
381
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true );
382
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
380
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
381
+		wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true);
382
+		wp_localize_script('wpinv-front-script', 'WPInv', $localize);
383 383
 	}
384 384
 
385 385
 	public function wpinv_actions() {
386
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
387
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
386
+		if (isset($_REQUEST['wpi_action'])) {
387
+			do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
388 388
 		}
389 389
 
390
-		if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
391
-			include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
390
+		if (defined('WP_ALL_IMPORT_ROOT_DIR')) {
391
+			include plugin_dir_path(__FILE__) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
392 392
 		}
393 393
 	}
394 394
 
@@ -400,24 +400,24 @@  discard block
 block discarded – undo
400 400
      */
401 401
     public function maybe_do_authenticated_action() {
402 402
 
403
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
403
+		if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
404 404
 
405
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
406
-			$data = wp_unslash( $_REQUEST );
407
-			if ( is_user_logged_in() ) {
408
-				do_action( "getpaid_authenticated_action_$key", $data );
405
+			$key  = sanitize_key($_REQUEST['getpaid-action']);
406
+			$data = wp_unslash($_REQUEST);
407
+			if (is_user_logged_in()) {
408
+				do_action("getpaid_authenticated_action_$key", $data);
409 409
 			}
410 410
 
411
-			do_action( "getpaid_unauthenticated_action_$key", $data );
411
+			do_action("getpaid_unauthenticated_action_$key", $data);
412 412
 
413 413
 		}
414 414
 
415 415
     }
416 416
 
417
-	public function pre_get_posts( $wp_query ) {
417
+	public function pre_get_posts($wp_query) {
418 418
 
419
-		if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
420
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
419
+		if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
420
+			$wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type']));
421 421
 		}
422 422
 
423 423
 		return $wp_query;
@@ -432,18 +432,18 @@  discard block
 block discarded – undo
432 432
 
433 433
 		// Currently, UX Builder does not work particulaly well with SuperDuper.
434 434
 		// So we disable our widgets when editing a page with UX Builder.
435
-		if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
435
+		if (function_exists('ux_builder_is_active') && ux_builder_is_active()) {
436 436
 			return;
437 437
 		}
438 438
 
439
-		$block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array();
439
+		$block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array();
440 440
 
441
-		if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) {
441
+		if (is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
442 442
 			// don't initiate in these conditions.
443 443
 		} else {
444 444
 
445 445
 			// Only load allowed widgets.
446
-			$exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
446
+			$exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array();
447 447
 			$widgets = apply_filters(
448 448
 				'getpaid_widget_classes',
449 449
 				array(
@@ -459,16 +459,16 @@  discard block
 block discarded – undo
459 459
 			);
460 460
 
461 461
 			// For each widget...
462
-			foreach ( $widgets as $widget ) {
462
+			foreach ($widgets as $widget) {
463 463
 
464 464
 				// Abort early if it is excluded for this page.
465
-				if ( in_array( $widget, $exclude ) ) {
465
+				if (in_array($widget, $exclude)) {
466 466
 					continue;
467 467
 				}
468 468
 
469 469
 				// SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
470
-				if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
471
-					register_widget( $widget );
470
+				if (is_subclass_of($widget, 'WP_Widget')) {
471
+					register_widget($widget);
472 472
 				} else {
473 473
 					new $widget();
474 474
 				}
@@ -484,19 +484,19 @@  discard block
 block discarded – undo
484 484
 	 */
485 485
 	public function maybe_upgrade_database() {
486 486
 
487
-		$wpi_version = get_option( 'wpinv_version', 0 );
487
+		$wpi_version = get_option('wpinv_version', 0);
488 488
 
489
-		if ( $wpi_version == WPINV_VERSION ) {
489
+		if ($wpi_version == WPINV_VERSION) {
490 490
 			return;
491 491
 		}
492 492
 
493 493
 		$installer = new GetPaid_Installer();
494 494
 
495
-		if ( empty( $wpi_version ) ) {
496
-			return $installer->upgrade_db( 0 );
495
+		if (empty($wpi_version)) {
496
+			return $installer->upgrade_db(0);
497 497
 		}
498 498
 
499
-		$upgrades  = array(
499
+		$upgrades = array(
500 500
 			'0.0.5'  => '004',
501 501
 			'1.0.3'  => '102',
502 502
 			'2.0.0'  => '118',
@@ -504,10 +504,10 @@  discard block
 block discarded – undo
504 504
 			'2.6.16' => '2615',
505 505
 		);
506 506
 
507
-		foreach ( $upgrades as $key => $method ) {
507
+		foreach ($upgrades as $key => $method) {
508 508
 
509
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
510
-				return $installer->upgrade_db( $method );
509
+			if (version_compare($wpi_version, $key, '<')) {
510
+				return $installer->upgrade_db($method);
511 511
 			}
512 512
 		}
513 513
 
@@ -520,11 +520,11 @@  discard block
 block discarded – undo
520 520
 	 */
521 521
 	public function maybe_flush_permalinks() {
522 522
 
523
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
523
+		$flush = get_option('wpinv_flush_permalinks', 0);
524 524
 
525
-		if ( ! empty( $flush ) ) {
525
+		if (!empty($flush)) {
526 526
 			flush_rewrite_rules();
527
-			delete_option( 'wpinv_flush_permalinks' );
527
+			delete_option('wpinv_flush_permalinks');
528 528
 		}
529 529
 
530 530
 	}
@@ -535,10 +535,10 @@  discard block
 block discarded – undo
535 535
 	 * @since 1.0.19
536 536
 	 * @param int[] $excluded_posts_ids
537 537
 	 */
538
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) {
538
+	public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
539 539
 
540 540
 		// Ensure that we have an array.
541
-		if ( ! is_array( $excluded_posts_ids ) ) {
541
+		if (!is_array($excluded_posts_ids)) {
542 542
 			$excluded_posts_ids = array();
543 543
 		}
544 544
 
@@ -546,24 +546,24 @@  discard block
 block discarded – undo
546 546
 		$our_pages = array();
547 547
 
548 548
 		// Checkout page.
549
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
549
+		$our_pages[] = wpinv_get_option('checkout_page', false);
550 550
 
551 551
 		// Success page.
552
-		$our_pages[] = wpinv_get_option( 'success_page', false );
552
+		$our_pages[] = wpinv_get_option('success_page', false);
553 553
 
554 554
 		// Failure page.
555
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
555
+		$our_pages[] = wpinv_get_option('failure_page', false);
556 556
 
557 557
 		// History page.
558
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
558
+		$our_pages[] = wpinv_get_option('invoice_history_page', false);
559 559
 
560 560
 		// Subscriptions page.
561
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
561
+		$our_pages[] = wpinv_get_option('invoice_subscription_page', false);
562 562
 
563
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
563
+		$our_pages   = array_map('intval', array_filter($our_pages));
564 564
 
565 565
 		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
566
-		return array_unique( $excluded_posts_ids );
566
+		return array_unique($excluded_posts_ids);
567 567
 
568 568
 	}
569 569
 
@@ -573,15 +573,15 @@  discard block
 block discarded – undo
573 573
 	 * @since 1.0.19
574 574
 	 * @param string[] $post_types
575 575
 	 */
576
-	public function exclude_invoicing_post_types( $post_types ) {
576
+	public function exclude_invoicing_post_types($post_types) {
577 577
 
578 578
 		// Ensure that we have an array.
579
-		if ( ! is_array( $post_types ) ) {
579
+		if (!is_array($post_types)) {
580 580
 			$post_types = array();
581 581
 		}
582 582
 
583 583
 		// Remove our post types.
584
-		return array_diff( $post_types, array_keys( getpaid_get_invoice_post_types() ) );
584
+		return array_diff($post_types, array_keys(getpaid_get_invoice_post_types()));
585 585
 	}
586 586
 
587 587
 	/**
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 	 * @since 2.0.0
591 591
 	 */
592 592
 	public function wp_footer() {
593
-		wpinv_get_template( 'frontend-footer.php' );
593
+		wpinv_get_template('frontend-footer.php');
594 594
 	}
595 595
 
596 596
 	/**
@@ -599,14 +599,14 @@  discard block
 block discarded – undo
599 599
 	 * @since 2.0.0
600 600
 	 */
601 601
 	public function wp_head() {
602
-		wpinv_get_template( 'frontend-head.php' );
602
+		wpinv_get_template('frontend-head.php');
603 603
 	}
604 604
 
605 605
 	/**
606 606
 	 * Custom query vars.
607 607
 	 *
608 608
 	 */
609
-	public function custom_query_vars( $vars ) {
609
+	public function custom_query_vars($vars) {
610 610
         $vars[] = 'getpaid-ipn';
611 611
         return $vars;
612 612
 	}
@@ -617,28 +617,28 @@  discard block
 block discarded – undo
617 617
 	 */
618 618
 	public function add_rewrite_rule() {
619 619
         $tag = 'getpaid-ipn';
620
-        add_rewrite_tag( "%$tag%", '([^&]+)' );
621
-        add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top' );
620
+        add_rewrite_tag("%$tag%", '([^&]+)');
621
+        add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top');
622 622
 	}
623 623
 
624 624
 	/**
625 625
 	 * Processes non-query string ipns.
626 626
 	 *
627 627
 	 */
628
-	public function maybe_process_new_ipn( $query ) {
628
+	public function maybe_process_new_ipn($query) {
629 629
 
630
-        if ( is_admin() || ! $query->is_main_query() ) {
630
+        if (is_admin() || !$query->is_main_query()) {
631 631
             return;
632 632
         }
633 633
 
634
-		$gateway = get_query_var( 'getpaid-ipn' );
634
+		$gateway = get_query_var('getpaid-ipn');
635 635
 
636
-        if ( ! empty( $gateway ) ) {
636
+        if (!empty($gateway)) {
637 637
 
638
-			$gateway = sanitize_text_field( $gateway );
638
+			$gateway = sanitize_text_field($gateway);
639 639
 			nocache_headers();
640
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
641
-			do_action( "wpinv_verify_{$gateway}_ipn" );
640
+			do_action('wpinv_verify_payment_ipn', $gateway);
641
+			do_action("wpinv_verify_{$gateway}_ipn");
642 642
 			exit;
643 643
 
644 644
         }
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-authorize-net-gateway.php 2 patches
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -13,58 +13,58 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Authorize_Net_Gateway extends GetPaid_Authorize_Net_Legacy_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'authorizenet';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array( 'subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34 34
     public $order = 4;
35 35
 
36 36
     /**
37
-	 * Endpoint for requests from Authorize.net.
38
-	 *
39
-	 * @var string
40
-	 */
41
-	protected $notify_url;
42
-
43
-	/**
44
-	 * Endpoint for requests to Authorize.net.
45
-	 *
46
-	 * @var string
47
-	 */
37
+     * Endpoint for requests from Authorize.net.
38
+     *
39
+     * @var string
40
+     */
41
+    protected $notify_url;
42
+
43
+    /**
44
+     * Endpoint for requests to Authorize.net.
45
+     *
46
+     * @var string
47
+     */
48 48
     protected $endpoint;
49 49
 
50 50
     /**
51
-	 * Currencies this gateway is allowed for.
52
-	 *
53
-	 * @var array
54
-	 */
55
-	public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
51
+     * Currencies this gateway is allowed for.
52
+     *
53
+     * @var array
54
+     */
55
+    public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
56 56
 
57 57
     /**
58
-	 * URL to view a transaction.
59
-	 *
60
-	 * @var string
61
-	 */
58
+     * URL to view a transaction.
59
+     *
60
+     * @var string
61
+     */
62 62
     public $view_transaction_url = 'https://{sandbox}authorize.net/ui/themes/sandbox/Transaction/TransactionReceipt.aspx?transid=%s';
63 63
 
64 64
     /**
65
-	 * Class constructor.
66
-	 */
67
-	public function __construct() {
65
+     * Class constructor.
66
+     */
67
+    public function __construct() {
68 68
 
69 69
         $this->title                = __( 'Credit Card / Debit Card', 'invoicing' );
70 70
         $this->method_title         = __( 'Authorize.Net', 'invoicing' );
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
     }
77 77
 
78 78
     /**
79
-	 * Displays the payment method select field.
80
-	 *
81
-	 * @param int $invoice_id 0 or invoice id.
82
-	 * @param GetPaid_Payment_Form $form Current payment form.
83
-	 */
79
+     * Displays the payment method select field.
80
+     *
81
+     * @param int $invoice_id 0 or invoice id.
82
+     * @param GetPaid_Payment_Form $form Current payment form.
83
+     */
84 84
     public function payment_fields( $invoice_id, $form ) {
85 85
 
86 86
         // Let the user select a payment method.
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
     }
92 92
 
93 93
     /**
94
-	 * Creates a customer profile.
95
-	 *
96
-	 *
97
-	 * @param WPInv_Invoice $invoice Invoice.
94
+     * Creates a customer profile.
95
+     *
96
+     *
97
+     * @param WPInv_Invoice $invoice Invoice.
98 98
      * @param array $submission_data Posted checkout fields.
99 99
      * @param bool $save Whether or not to save the payment as a token.
100 100
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
101
-	 * @return string|WP_Error Payment profile id.
102
-	 */
103
-	public function create_customer_profile( $invoice, $submission_data, $save = true ) {
101
+     * @return string|WP_Error Payment profile id.
102
+     */
103
+    public function create_customer_profile( $invoice, $submission_data, $save = true ) {
104 104
 
105 105
         // Remove non-digits from the number
106 106
         $submission_data['authorizenet']['cc_number'] = preg_replace( '/\D/', '', $submission_data['authorizenet']['cc_number'] );
@@ -182,14 +182,14 @@  discard block
 block discarded – undo
182 182
     }
183 183
 
184 184
     /**
185
-	 * Retrieves a customer profile.
186
-	 *
187
-	 *
188
-	 * @param string $profile_id profile id.
189
-	 * @return string|WP_Error Profile id.
185
+     * Retrieves a customer profile.
186
+     *
187
+     *
188
+     * @param string $profile_id profile id.
189
+     * @return string|WP_Error Profile id.
190 190
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile
191
-	 */
192
-	public function get_customer_profile( $profile_id ) {
191
+     */
192
+    public function get_customer_profile( $profile_id ) {
193 193
 
194 194
         // Generate args.
195 195
         $args = array(
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
     }
205 205
 
206 206
     /**
207
-	 * Creates a customer profile.
208
-	 *
209
-	 *
207
+     * Creates a customer profile.
208
+     *
209
+     *
210 210
      * @param string $profile_id profile id.
211
-	 * @param WPInv_Invoice $invoice Invoice.
211
+     * @param WPInv_Invoice $invoice Invoice.
212 212
      * @param array $submission_data Posted checkout fields.
213 213
      * @param bool $save Whether or not to save the payment as a token.
214 214
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
215
-	 * @return string|WP_Error Profile id.
216
-	 */
217
-	public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
215
+     * @return string|WP_Error Profile id.
216
+     */
217
+    public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
218 218
 
219 219
         // Remove non-digits from the number
220 220
         $submission_data['authorizenet']['cc_number'] = preg_replace( '/\D/', '', $submission_data['authorizenet']['cc_number'] );
@@ -302,13 +302,13 @@  discard block
 block discarded – undo
302 302
     }
303 303
 
304 304
     /**
305
-	 * Retrieves payment details from cache.
306
-	 *
307
-	 *
305
+     * Retrieves payment details from cache.
306
+     *
307
+     *
308 308
      * @param array $payment_details.
309
-	 * @return array|false Profile id.
310
-	 */
311
-	public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) {
309
+     * @return array|false Profile id.
310
+     */
311
+    public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) {
312 312
 
313 313
         $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
314 314
         $payment_details    = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY );
@@ -333,13 +333,13 @@  discard block
 block discarded – undo
333 333
     }
334 334
 
335 335
     /**
336
-	 * Securely adds payment details to cache.
337
-	 *
338
-	 *
336
+     * Securely adds payment details to cache.
337
+     *
338
+     *
339 339
      * @param array $payment_details.
340 340
      * @param string $payment_profile_id.
341
-	 */
342
-	public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) {
341
+     */
342
+    public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) {
343 343
 
344 344
         $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
345 345
         $cached_information = is_array( $cached_information ) ? $cached_information : array();
@@ -351,15 +351,15 @@  discard block
 block discarded – undo
351 351
     }
352 352
 
353 353
     /**
354
-	 * Retrieves a customer payment profile.
355
-	 *
356
-	 *
357
-	 * @param string $customer_profile_id customer profile id.
354
+     * Retrieves a customer payment profile.
355
+     *
356
+     *
357
+     * @param string $customer_profile_id customer profile id.
358 358
      * @param string $payment_profile_id payment profile id.
359
-	 * @return string|WP_Error Profile id.
359
+     * @return string|WP_Error Profile id.
360 360
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile
361
-	 */
362
-	public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
361
+     */
362
+    public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
363 363
 
364 364
         // Generate args.
365 365
         $args = array(
@@ -375,15 +375,15 @@  discard block
 block discarded – undo
375 375
     }
376 376
 
377 377
     /**
378
-	 * Charges a customer payment profile.
379
-	 *
378
+     * Charges a customer payment profile.
379
+     *
380 380
      * @param string $customer_profile_id customer profile id.
381 381
      * @param string $payment_profile_id payment profile id.
382
-	 * @param WPInv_Invoice $invoice Invoice.
382
+     * @param WPInv_Invoice $invoice Invoice.
383 383
      * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile
384
-	 * @return WP_Error|object
385
-	 */
386
-	public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
384
+     * @return WP_Error|object
385
+     */
386
+    public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
387 387
 
388 388
         // Generate args.
389 389
         $args = array(
@@ -429,41 +429,41 @@  discard block
 block discarded – undo
429 429
     }
430 430
 
431 431
     /**
432
-	 * Processes a customer charge.
433
-	 *
432
+     * Processes a customer charge.
433
+     *
434 434
      * @param stdClass $result Api response.
435
-	 * @param WPInv_Invoice $invoice Invoice.
436
-	 */
437
-	public function process_charge_response( $result, $invoice ) {
435
+     * @param WPInv_Invoice $invoice Invoice.
436
+     */
437
+    public function process_charge_response( $result, $invoice ) {
438 438
 
439 439
         wpinv_clear_errors();
440
-		$response_code = (int) $result->transactionResponse->responseCode;
440
+        $response_code = (int) $result->transactionResponse->responseCode;
441 441
 
442
-		// Succeeded.
443
-		if ( 1 == $response_code || 4 == $response_code ) {
442
+        // Succeeded.
443
+        if ( 1 == $response_code || 4 == $response_code ) {
444 444
 
445
-			// Maybe set a transaction id.
446
-			if ( ! empty( $result->transactionResponse->transId ) ) {
447
-				$invoice->set_transaction_id( $result->transactionResponse->transId );
448
-			}
445
+            // Maybe set a transaction id.
446
+            if ( ! empty( $result->transactionResponse->transId ) ) {
447
+                $invoice->set_transaction_id( $result->transactionResponse->transId );
448
+            }
449 449
 
450
-			$invoice->add_note( sprintf( __( 'Authentication code: %1$s (%2$s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true );
450
+            $invoice->add_note( sprintf( __( 'Authentication code: %1$s (%2$s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true );
451 451
 
452
-			if ( 1 == $response_code ) {
453
-				return $invoice->mark_paid();
454
-			}
452
+            if ( 1 == $response_code ) {
453
+                return $invoice->mark_paid();
454
+            }
455 455
 
456
-			$invoice->set_status( 'wpi-onhold' );
457
-        	$invoice->add_note(
456
+            $invoice->set_status( 'wpi-onhold' );
457
+            $invoice->add_note(
458 458
                 sprintf(
459 459
                     __( 'Held for review: %s', 'invoicing' ),
460 460
                     $result->transactionResponse->messages->message[0]->description
461 461
                 )
462
-			);
462
+            );
463 463
 
464
-			return $invoice->save();
464
+            return $invoice->save();
465 465
 
466
-		}
466
+        }
467 467
 
468 468
         wpinv_set_error( 'card_declined' );
469 469
 
@@ -475,13 +475,13 @@  discard block
 block discarded – undo
475 475
     }
476 476
 
477 477
     /**
478
-	 * Returns payment information.
479
-	 *
480
-	 *
481
-	 * @param array $card Card details.
482
-	 * @return array
483
-	 */
484
-	public function get_payment_information( $card ) {
478
+     * Returns payment information.
479
+     *
480
+     *
481
+     * @param array $card Card details.
482
+     * @return array
483
+     */
484
+    public function get_payment_information( $card ) {
485 485
         return array(
486 486
 
487 487
             'creditCard' => array(
@@ -494,25 +494,25 @@  discard block
 block discarded – undo
494 494
     }
495 495
 
496 496
     /**
497
-	 * Returns the customer profile meta name.
498
-	 *
499
-	 *
500
-	 * @param WPInv_Invoice $invoice Invoice.
501
-	 * @return string
502
-	 */
503
-	public function get_customer_profile_meta_name( $invoice ) {
497
+     * Returns the customer profile meta name.
498
+     *
499
+     *
500
+     * @param WPInv_Invoice $invoice Invoice.
501
+     * @return string
502
+     */
503
+    public function get_customer_profile_meta_name( $invoice ) {
504 504
         return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
505 505
     }
506 506
 
507 507
     /**
508
-	 * Validates the submitted data.
509
-	 *
510
-	 *
511
-	 * @param array $submission_data Posted checkout fields.
508
+     * Validates the submitted data.
509
+     *
510
+     *
511
+     * @param array $submission_data Posted checkout fields.
512 512
      * @param WPInv_Invoice $invoice
513
-	 * @return WP_Error|string The payment profile id
514
-	 */
515
-	public function validate_submission_data( $submission_data, $invoice ) {
513
+     * @return WP_Error|string The payment profile id
514
+     */
515
+    public function validate_submission_data( $submission_data, $invoice ) {
516 516
 
517 517
         // Validate authentication details.
518 518
         $auth = $this->get_auth_params();
@@ -544,13 +544,13 @@  discard block
 block discarded – undo
544 544
     }
545 545
 
546 546
     /**
547
-	 * Returns invoice line items.
548
-	 *
549
-	 *
550
-	 * @param WPInv_Invoice $invoice Invoice.
551
-	 * @return array
552
-	 */
553
-	public function get_line_items( $invoice ) {
547
+     * Returns invoice line items.
548
+     *
549
+     *
550
+     * @param WPInv_Invoice $invoice Invoice.
551
+     * @return array
552
+     */
553
+    public function get_line_items( $invoice ) {
554 554
         $items = array();
555 555
 
556 556
         foreach ( $invoice->get_items() as $item ) {
@@ -587,15 +587,15 @@  discard block
 block discarded – undo
587 587
     }
588 588
 
589 589
     /**
590
-	 * Process Payment.
591
-	 *
592
-	 *
593
-	 * @param WPInv_Invoice $invoice Invoice.
594
-	 * @param array $submission_data Posted checkout fields.
595
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
596
-	 * @return array
597
-	 */
598
-	public function process_payment( $invoice, $submission_data, $submission ) {
590
+     * Process Payment.
591
+     *
592
+     *
593
+     * @param WPInv_Invoice $invoice Invoice.
594
+     * @param array $submission_data Posted checkout fields.
595
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
596
+     * @return array
597
+     */
598
+    public function process_payment( $invoice, $submission_data, $submission ) {
599 599
 
600 600
         // Validate the submitted data.
601 601
         $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice );
@@ -628,45 +628,45 @@  discard block
 block discarded – undo
628 628
 
629 629
         exit;
630 630
 
631
-	}
631
+    }
632 632
 
633
-	/**
634
-	 * Processes the initial payment.
635
-	 *
633
+    /**
634
+     * Processes the initial payment.
635
+     *
636 636
      * @param WPInv_Invoice $invoice Invoice.
637
-	 */
638
-	protected function process_initial_payment( $invoice ) {
637
+     */
638
+    protected function process_initial_payment( $invoice ) {
639 639
 
640
-		$payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
640
+        $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
641 641
         $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
642
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
642
+        $result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
643 643
 
644
-		// Do we have an error?
645
-		if ( is_wp_error( $result ) ) {
646
-			wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
647
-			wpinv_send_back_to_checkout( $invoice );
648
-		}
644
+        // Do we have an error?
645
+        if ( is_wp_error( $result ) ) {
646
+            wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
647
+            wpinv_send_back_to_checkout( $invoice );
648
+        }
649 649
 
650
-		// Process the response.
651
-		$this->process_charge_response( $result, $invoice );
650
+        // Process the response.
651
+        $this->process_charge_response( $result, $invoice );
652 652
 
653
-		if ( wpinv_get_errors() ) {
654
-			wpinv_send_back_to_checkout( $invoice );
655
-		}
653
+        if ( wpinv_get_errors() ) {
654
+            wpinv_send_back_to_checkout( $invoice );
655
+        }
656 656
 
657
-	}
657
+    }
658 658
 
659 659
     /**
660
-	 * Processes recurring payments.
661
-	 *
660
+     * Processes recurring payments.
661
+     *
662 662
      * @param WPInv_Invoice $invoice Invoice.
663 663
      * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions.
664
-	 */
665
-	public function process_subscription( $invoice, $subscriptions ) {
664
+     */
665
+    public function process_subscription( $invoice, $subscriptions ) {
666 666
 
667 667
         // Check if there is an initial amount to charge.
668 668
         if ( (float) $invoice->get_total() > 0 ) {
669
-			$this->process_initial_payment( $invoice );
669
+            $this->process_initial_payment( $invoice );
670 670
         }
671 671
 
672 672
         // Activate the subscriptions.
@@ -684,36 +684,36 @@  discard block
 block discarded – undo
684 684
             }
685 685
         }
686 686
 
687
-		// Redirect to the success page.
687
+        // Redirect to the success page.
688 688
         wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
689 689
 
690 690
     }
691 691
 
692
-	/**
693
-	 * (Maybe) renews an authorize.net subscription profile.
694
-	 *
695
-	 *
692
+    /**
693
+     * (Maybe) renews an authorize.net subscription profile.
694
+     *
695
+     *
696 696
      * @param WPInv_Subscription $subscription
697
-	 */
698
-	public function maybe_renew_subscription( $subscription ) {
697
+     */
698
+    public function maybe_renew_subscription( $subscription ) {
699 699
 
700 700
         // Ensure its our subscription && it's active.
701 701
         if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
702 702
             $this->renew_subscription( $subscription );
703 703
         }
704 704
 
705
-	}
705
+    }
706 706
 
707 707
     /**
708
-	 * Renews a subscription.
709
-	 *
708
+     * Renews a subscription.
709
+     *
710 710
      * @param WPInv_Subscription $subscription
711
-	 */
712
-	public function renew_subscription( $subscription ) {
711
+     */
712
+    public function renew_subscription( $subscription ) {
713 713
 
714
-		// Generate the renewal invoice.
715
-		$new_invoice = $subscription->create_payment();
716
-		$old_invoice = $subscription->get_parent_payment();
714
+        // Generate the renewal invoice.
715
+        $new_invoice = $subscription->create_payment();
716
+        $old_invoice = $subscription->get_parent_payment();
717 717
 
718 718
         if ( empty( $new_invoice ) ) {
719 719
             $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false );
@@ -722,37 +722,37 @@  discard block
 block discarded – undo
722 722
         }
723 723
 
724 724
         // Charge the payment method.
725
-		$payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
726
-		$customer_profile   = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true );
727
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice );
728
-
729
-		// Do we have an error?
730
-		if ( is_wp_error( $result ) ) {
731
-
732
-			$old_invoice->add_note(
733
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
734
-				true,
735
-				false,
736
-				true
737
-			);
738
-			$subscription->failing();
739
-			return;
740
-
741
-		}
742
-
743
-		// Process the response.
744
-		$this->process_charge_response( $result, $new_invoice );
745
-
746
-		if ( wpinv_get_errors() ) {
747
-
748
-			$old_invoice->add_note(
749
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
750
-				true,
751
-				false,
752
-				true
753
-			);
754
-			$subscription->failing();
755
-			return;
725
+        $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
726
+        $customer_profile   = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true );
727
+        $result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice );
728
+
729
+        // Do we have an error?
730
+        if ( is_wp_error( $result ) ) {
731
+
732
+            $old_invoice->add_note(
733
+                sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
734
+                true,
735
+                false,
736
+                true
737
+            );
738
+            $subscription->failing();
739
+            return;
740
+
741
+        }
742
+
743
+        // Process the response.
744
+        $this->process_charge_response( $result, $new_invoice );
745
+
746
+        if ( wpinv_get_errors() ) {
747
+
748
+            $old_invoice->add_note(
749
+                sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
750
+                true,
751
+                false,
752
+                true
753
+            );
754
+            $subscription->failing();
755
+            return;
756 756
 
757 757
         }
758 758
 
@@ -761,13 +761,13 @@  discard block
 block discarded – undo
761 761
     }
762 762
 
763 763
     /**
764
-	 * Processes invoice addons.
765
-	 *
766
-	 * @param WPInv_Invoice $invoice
767
-	 * @param GetPaid_Form_Item[] $items
768
-	 * @return WPInv_Invoice
769
-	 */
770
-	public function process_addons( $invoice, $items ) {
764
+     * Processes invoice addons.
765
+     *
766
+     * @param WPInv_Invoice $invoice
767
+     * @param GetPaid_Form_Item[] $items
768
+     * @return WPInv_Invoice
769
+     */
770
+    public function process_addons( $invoice, $items ) {
771 771
 
772 772
         global $getpaid_authorize_addons;
773 773
 
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
         $invoice->recalculate_total();
787 787
 
788 788
         $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
789
-		$customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
789
+        $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
790 790
 
791 791
         add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 );
792 792
         $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
@@ -801,11 +801,11 @@  discard block
 block discarded – undo
801 801
     }
802 802
 
803 803
     /**
804
-	 * Processes invoice addons.
805
-	 *
804
+     * Processes invoice addons.
805
+     *
806 806
      * @param array $args
807
-	 * @return array
808
-	 */
807
+     * @return array
808
+     */
809 809
     public function filter_addons_request( $args ) {
810 810
 
811 811
         global $getpaid_authorize_addons;
@@ -839,11 +839,11 @@  discard block
 block discarded – undo
839 839
     }
840 840
 
841 841
     /**
842
-	 * Filters the gateway settings.
843
-	 *
844
-	 * @param array $admin_settings
845
-	 */
846
-	public function admin_settings( $admin_settings ) {
842
+     * Filters the gateway settings.
843
+     *
844
+     * @param array $admin_settings
845
+     */
846
+    public function admin_settings( $admin_settings ) {
847 847
 
848 848
         $currencies = sprintf(
849 849
             __( 'Supported Currencies: %s', 'invoicing' ),
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
             'readonly' => true,
884 884
         );
885 885
 
886
-		return $admin_settings;
887
-	}
886
+        return $admin_settings;
887
+    }
888 888
 
889 889
 }
Please login to merge, or discard this patch.
Spacing   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Authorize.net Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
27
+    protected $supports = array('subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @var array
54 54
 	 */
55
-	public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
55
+	public $currencies = array('USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD');
56 56
 
57 57
     /**
58 58
 	 * URL to view a transaction.
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function __construct() {
68 68
 
69
-        $this->title                = __( 'Credit Card / Debit Card', 'invoicing' );
70
-        $this->method_title         = __( 'Authorize.Net', 'invoicing' );
71
-        $this->notify_url           = getpaid_get_non_query_string_ipn_url( $this->id );
69
+        $this->title                = __('Credit Card / Debit Card', 'invoicing');
70
+        $this->method_title         = __('Authorize.Net', 'invoicing');
71
+        $this->notify_url           = getpaid_get_non_query_string_ipn_url($this->id);
72 72
 
73
-        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
74
-        add_filter( 'getpaid_authorizenet_sandbox_notice', array( $this, 'sandbox_notice' ) );
73
+        add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'));
74
+        add_filter('getpaid_authorizenet_sandbox_notice', array($this, 'sandbox_notice'));
75 75
         parent::__construct();
76 76
     }
77 77
 
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 	 * @param int $invoice_id 0 or invoice id.
82 82
 	 * @param GetPaid_Payment_Form $form Current payment form.
83 83
 	 */
84
-    public function payment_fields( $invoice_id, $form ) {
84
+    public function payment_fields($invoice_id, $form) {
85 85
 
86 86
         // Let the user select a payment method.
87 87
         $this->saved_payment_methods();
88 88
 
89 89
         // Show the credit card entry form.
90
-        $this->new_payment_method_entry( $this->get_cc_form( true ) );
90
+        $this->new_payment_method_entry($this->get_cc_form(true));
91 91
     }
92 92
 
93 93
     /**
@@ -100,79 +100,79 @@  discard block
 block discarded – undo
100 100
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
101 101
 	 * @return string|WP_Error Payment profile id.
102 102
 	 */
103
-	public function create_customer_profile( $invoice, $submission_data, $save = true ) {
103
+	public function create_customer_profile($invoice, $submission_data, $save = true) {
104 104
 
105 105
         // Remove non-digits from the number
106
-        $submission_data['authorizenet']['cc_number'] = preg_replace( '/\D/', '', $submission_data['authorizenet']['cc_number'] );
106
+        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']);
107 107
 
108 108
         // Generate args.
109 109
         $args = array(
110 110
             'createCustomerProfileRequest' => array(
111 111
                 'merchantAuthentication' => $this->get_auth_params(),
112 112
                 'profile'                => array(
113
-                    'merchantCustomerId' => getpaid_limit_length( $invoice->get_user_id(), 20 ),
114
-                    'description'        => getpaid_limit_length( $invoice->get_full_name(), 255 ),
115
-                    'email'              => getpaid_limit_length( $invoice->get_email(), 255 ),
113
+                    'merchantCustomerId' => getpaid_limit_length($invoice->get_user_id(), 20),
114
+                    'description'        => getpaid_limit_length($invoice->get_full_name(), 255),
115
+                    'email'              => getpaid_limit_length($invoice->get_email(), 255),
116 116
                     'paymentProfiles'    => array(
117 117
                         'customerType' => 'individual',
118 118
 
119 119
                         // Billing information.
120 120
                         'billTo'       => array(
121
-                            'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ),
122
-                            'lastName'  => getpaid_limit_length( $invoice->get_last_name(), 50 ),
123
-                            'address'   => getpaid_limit_length( $invoice->get_address(), 60 ),
124
-                            'city'      => getpaid_limit_length( $invoice->get_city(), 40 ),
125
-                            'state'     => getpaid_limit_length( $invoice->get_state(), 40 ),
126
-                            'zip'       => getpaid_limit_length( $invoice->get_zip(), 20 ),
127
-                            'country'   => getpaid_limit_length( $invoice->get_country(), 60 ),
121
+                            'firstName' => getpaid_limit_length($invoice->get_first_name(), 50),
122
+                            'lastName'  => getpaid_limit_length($invoice->get_last_name(), 50),
123
+                            'address'   => getpaid_limit_length($invoice->get_address(), 60),
124
+                            'city'      => getpaid_limit_length($invoice->get_city(), 40),
125
+                            'state'     => getpaid_limit_length($invoice->get_state(), 40),
126
+                            'zip'       => getpaid_limit_length($invoice->get_zip(), 20),
127
+                            'country'   => getpaid_limit_length($invoice->get_country(), 60),
128 128
                         ),
129 129
 
130 130
                         // Payment information.
131
-                        'payment'      => $this->get_payment_information( $submission_data['authorizenet'] ),
131
+                        'payment'      => $this->get_payment_information($submission_data['authorizenet']),
132 132
                     ),
133 133
                 ),
134
-                'validationMode'         => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode',
134
+                'validationMode'         => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode',
135 135
             ),
136 136
         );
137 137
 
138
-        $response = $this->post( apply_filters( 'getpaid_authorizenet_customer_profile_args', $args, $invoice ), $invoice );
138
+        $response = $this->post(apply_filters('getpaid_authorizenet_customer_profile_args', $args, $invoice), $invoice);
139 139
 
140
-        if ( is_wp_error( $response ) ) {
140
+        if (is_wp_error($response)) {
141 141
 
142 142
             // In case the payment profile already exists remotely.
143
-            if ( 'dup_payment_profile' === $response->get_error_code() ) {
144
-                $customer_profile_id = strtok( $response->get_error_message(), '.' );
145
-                update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile_id );
146
-                return strtok( '.' );
143
+            if ('dup_payment_profile' === $response->get_error_code()) {
144
+                $customer_profile_id = strtok($response->get_error_message(), '.');
145
+                update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile_id);
146
+                return strtok('.');
147 147
             }
148 148
 
149 149
             // In case the customer profile already exists remotely.
150
-            if ( 'E00039' === $response->get_error_code() ) {
151
-                $customer_profile_id = str_replace( 'A duplicate record with ID ', '', $response->get_error_message() );
152
-                $customer_profile_id = str_replace( ' already exists.', '', $customer_profile_id );
153
-                return $this->create_customer_payment_profile( trim( $customer_profile_id ), $invoice, $submission_data, $save );
150
+            if ('E00039' === $response->get_error_code()) {
151
+                $customer_profile_id = str_replace('A duplicate record with ID ', '', $response->get_error_message());
152
+                $customer_profile_id = str_replace(' already exists.', '', $customer_profile_id);
153
+                return $this->create_customer_payment_profile(trim($customer_profile_id), $invoice, $submission_data, $save);
154 154
             }
155 155
 
156 156
             return $response;
157 157
         }
158 158
 
159
-        update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId );
159
+        update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId);
160 160
 
161 161
         // Save the payment token.
162
-        if ( $save ) {
162
+        if ($save) {
163 163
             $this->save_token(
164 164
                 array(
165 165
                     'id'      => $response->customerPaymentProfileIdList[0],
166
-                    'name'    => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . '&middot;&middot;&middot;&middot;' . substr( $submission_data['authorizenet']['cc_number'], -4 ),
166
+                    'name'    => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . '&middot;&middot;&middot;&middot;' . substr($submission_data['authorizenet']['cc_number'], -4),
167 167
                     'default' => true,
168
-                    'type'    => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live',
168
+                    'type'    => $this->is_sandbox($invoice) ? 'sandbox' : 'live',
169 169
                 )
170 170
             );
171 171
         }
172 172
 
173 173
         // Add a note about the validation response.
174 174
         $invoice->add_note(
175
-            sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ),
175
+            sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]),
176 176
             false,
177 177
             false,
178 178
             true
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @return string|WP_Error Profile id.
190 190
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile
191 191
 	 */
192
-	public function get_customer_profile( $profile_id ) {
192
+	public function get_customer_profile($profile_id) {
193 193
 
194 194
         // Generate args.
195 195
         $args = array(
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             ),
200 200
         );
201 201
 
202
-        return $this->post( $args, false );
202
+        return $this->post($args, false);
203 203
 
204 204
     }
205 205
 
@@ -214,18 +214,18 @@  discard block
 block discarded – undo
214 214
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
215 215
 	 * @return string|WP_Error Profile id.
216 216
 	 */
217
-	public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
217
+	public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) {
218 218
 
219 219
         // Remove non-digits from the number
220
-        $submission_data['authorizenet']['cc_number'] = preg_replace( '/\D/', '', $submission_data['authorizenet']['cc_number'] );
220
+        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']);
221 221
 
222 222
         // Prepare card details.
223
-        $payment_information                          = $this->get_payment_information( $submission_data['authorizenet'] );
223
+        $payment_information                          = $this->get_payment_information($submission_data['authorizenet']);
224 224
 
225 225
         // Authorize.NET does not support saving the same card twice.
226
-        $cached_information                           = $this->retrieve_payment_profile_from_cache( $payment_information, $customer_profile, $invoice );
226
+        $cached_information                           = $this->retrieve_payment_profile_from_cache($payment_information, $customer_profile, $invoice);
227 227
 
228
-        if ( $cached_information ) {
228
+        if ($cached_information) {
229 229
             return $cached_information;
230 230
         }
231 231
 
@@ -238,34 +238,34 @@  discard block
 block discarded – undo
238 238
 
239 239
                     // Billing information.
240 240
                     'billTo'  => array(
241
-                        'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ),
242
-                        'lastName'  => getpaid_limit_length( $invoice->get_last_name(), 50 ),
243
-                        'address'   => getpaid_limit_length( $invoice->get_address(), 60 ),
244
-                        'city'      => getpaid_limit_length( $invoice->get_city(), 40 ),
245
-                        'state'     => getpaid_limit_length( $invoice->get_state(), 40 ),
246
-                        'zip'       => getpaid_limit_length( $invoice->get_zip(), 20 ),
247
-                        'country'   => getpaid_limit_length( $invoice->get_country(), 60 ),
241
+                        'firstName' => getpaid_limit_length($invoice->get_first_name(), 50),
242
+                        'lastName'  => getpaid_limit_length($invoice->get_last_name(), 50),
243
+                        'address'   => getpaid_limit_length($invoice->get_address(), 60),
244
+                        'city'      => getpaid_limit_length($invoice->get_city(), 40),
245
+                        'state'     => getpaid_limit_length($invoice->get_state(), 40),
246
+                        'zip'       => getpaid_limit_length($invoice->get_zip(), 20),
247
+                        'country'   => getpaid_limit_length($invoice->get_country(), 60),
248 248
                     ),
249 249
 
250 250
                     // Payment information.
251 251
                     'payment' => $payment_information,
252 252
                 ),
253
-                'validationMode'         => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode',
253
+                'validationMode'         => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode',
254 254
             ),
255 255
         );
256 256
 
257
-        $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice );
257
+        $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice);
258 258
 
259
-        if ( is_wp_error( $response ) ) {
259
+        if (is_wp_error($response)) {
260 260
 
261 261
             // In case the payment profile already exists remotely.
262
-            if ( 'dup_payment_profile' == $response->get_error_code() ) {
263
-                $customer_profile_id = strtok( $response->get_error_message(), '.' );
264
-                $payment_profile_id  = strtok( '.' );
265
-                update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile_id );
262
+            if ('dup_payment_profile' == $response->get_error_code()) {
263
+                $customer_profile_id = strtok($response->get_error_message(), '.');
264
+                $payment_profile_id  = strtok('.');
265
+                update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile_id);
266 266
 
267 267
                 // Cache payment profile id.
268
-                $this->add_payment_profile_to_cache( $payment_information, $payment_profile_id );
268
+                $this->add_payment_profile_to_cache($payment_information, $payment_profile_id);
269 269
 
270 270
                 return $payment_profile_id;
271 271
             }
@@ -274,29 +274,29 @@  discard block
 block discarded – undo
274 274
         }
275 275
 
276 276
         // Save the payment token.
277
-        if ( $save ) {
277
+        if ($save) {
278 278
             $this->save_token(
279 279
                 array(
280 280
                     'id'      => $response->customerPaymentProfileId,
281
-                    'name'    => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' &middot;&middot;&middot;&middot; ' . substr( $submission_data['authorizenet']['cc_number'], -4 ),
281
+                    'name'    => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . ' &middot;&middot;&middot;&middot; ' . substr($submission_data['authorizenet']['cc_number'], -4),
282 282
                     'default' => true,
283
-                    'type'    => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live',
283
+                    'type'    => $this->is_sandbox($invoice) ? 'sandbox' : 'live',
284 284
                 )
285 285
             );
286 286
         }
287 287
 
288 288
         // Cache payment profile id.
289
-        $this->add_payment_profile_to_cache( $payment_information, $response->customerPaymentProfileId );
289
+        $this->add_payment_profile_to_cache($payment_information, $response->customerPaymentProfileId);
290 290
 
291 291
         // Add a note about the validation response.
292 292
         $invoice->add_note(
293
-            sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ),
293
+            sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse),
294 294
             false,
295 295
             false,
296 296
             true
297 297
         );
298 298
 
299
-        update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile );
299
+        update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile);
300 300
 
301 301
         return $response->customerPaymentProfileId;
302 302
     }
@@ -308,12 +308,12 @@  discard block
 block discarded – undo
308 308
      * @param array $payment_details.
309 309
 	 * @return array|false Profile id.
310 310
 	 */
311
-	public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) {
311
+	public function retrieve_payment_profile_from_cache($payment_details, $customer_profile, $invoice) {
312 312
 
313
-        $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
314
-        $payment_details    = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY );
313
+        $cached_information = get_option('getpaid_authorize_net_cached_profiles', array());
314
+        $payment_details    = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY);
315 315
 
316
-        if ( ! is_array( $cached_information ) || ! array_key_exists( $payment_details, $cached_information ) ) {
316
+        if (!is_array($cached_information) || !array_key_exists($payment_details, $cached_information)) {
317 317
             return false;
318 318
         }
319 319
 
@@ -322,13 +322,13 @@  discard block
 block discarded – undo
322 322
             'getCustomerPaymentProfileRequest' => array(
323 323
                 'merchantAuthentication'   => $this->get_auth_params(),
324 324
                 'customerProfileId'        => $customer_profile,
325
-                'customerPaymentProfileId' => $cached_information[ $payment_details ],
325
+                'customerPaymentProfileId' => $cached_information[$payment_details],
326 326
             ),
327 327
         );
328 328
 
329
-        $response = $this->post( $args, $invoice );
329
+        $response = $this->post($args, $invoice);
330 330
 
331
-        return is_wp_error( $response ) ? false : $cached_information[ $payment_details ];
331
+        return is_wp_error($response) ? false : $cached_information[$payment_details];
332 332
 
333 333
     }
334 334
 
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
      * @param array $payment_details.
340 340
      * @param string $payment_profile_id.
341 341
 	 */
342
-	public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) {
342
+	public function add_payment_profile_to_cache($payment_details, $payment_profile_id) {
343 343
 
344
-        $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
345
-        $cached_information = is_array( $cached_information ) ? $cached_information : array();
346
-        $payment_details    = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY );
344
+        $cached_information = get_option('getpaid_authorize_net_cached_profiles', array());
345
+        $cached_information = is_array($cached_information) ? $cached_information : array();
346
+        $payment_details    = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY);
347 347
 
348
-        $cached_information[ $payment_details ] = $payment_profile_id;
349
-        update_option( 'getpaid_authorize_net_cached_profiles', $cached_information );
348
+        $cached_information[$payment_details] = $payment_profile_id;
349
+        update_option('getpaid_authorize_net_cached_profiles', $cached_information);
350 350
 
351 351
     }
352 352
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	 * @return string|WP_Error Profile id.
360 360
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile
361 361
 	 */
362
-	public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
362
+	public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) {
363 363
 
364 364
         // Generate args.
365 365
         $args = array(
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
             ),
371 371
         );
372 372
 
373
-        return $this->post( $args, false );
373
+        return $this->post($args, false);
374 374
 
375 375
     }
376 376
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
      * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile
384 384
 	 * @return WP_Error|object
385 385
 	 */
386
-	public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
386
+	public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) {
387 387
 
388 388
         // Generate args.
389 389
         $args = array(
@@ -403,28 +403,28 @@  discard block
 block discarded – undo
403 403
                         ),
404 404
                     ),
405 405
                     'order'           => array(
406
-                        'invoiceNumber' => getpaid_limit_length( $invoice->get_number(), 20 ),
406
+                        'invoiceNumber' => getpaid_limit_length($invoice->get_number(), 20),
407 407
                     ),
408
-                    'lineItems'       => array( 'lineItem' => $this->get_line_items( $invoice ) ),
408
+                    'lineItems'       => array('lineItem' => $this->get_line_items($invoice)),
409 409
                     'tax'             => array(
410 410
                         'amount' => $invoice->get_total_tax(),
411
-                        'name'   => __( 'TAX', 'invoicing' ),
411
+                        'name'   => __('TAX', 'invoicing'),
412 412
                     ),
413
-                    'poNumber'        => getpaid_limit_length( $invoice->get_number(), 25 ),
413
+                    'poNumber'        => getpaid_limit_length($invoice->get_number(), 25),
414 414
                     'customer'        => array(
415
-                        'id'    => getpaid_limit_length( $invoice->get_user_id(), 25 ),
416
-                        'email' => getpaid_limit_length( $invoice->get_email(), 25 ),
415
+                        'id'    => getpaid_limit_length($invoice->get_user_id(), 25),
416
+                        'email' => getpaid_limit_length($invoice->get_email(), 25),
417 417
                     ),
418 418
                     'customerIP'      => $invoice->get_ip(),
419 419
                 ),
420 420
             ),
421 421
         );
422 422
 
423
-        if ( 0 == $invoice->get_total_tax() ) {
424
-            unset( $args['createTransactionRequest']['transactionRequest']['tax'] );
423
+        if (0 == $invoice->get_total_tax()) {
424
+            unset($args['createTransactionRequest']['transactionRequest']['tax']);
425 425
         }
426 426
 
427
-        return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice );
427
+        return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice);
428 428
 
429 429
     }
430 430
 
@@ -434,29 +434,29 @@  discard block
 block discarded – undo
434 434
      * @param stdClass $result Api response.
435 435
 	 * @param WPInv_Invoice $invoice Invoice.
436 436
 	 */
437
-	public function process_charge_response( $result, $invoice ) {
437
+	public function process_charge_response($result, $invoice) {
438 438
 
439 439
         wpinv_clear_errors();
440 440
 		$response_code = (int) $result->transactionResponse->responseCode;
441 441
 
442 442
 		// Succeeded.
443
-		if ( 1 == $response_code || 4 == $response_code ) {
443
+		if (1 == $response_code || 4 == $response_code) {
444 444
 
445 445
 			// Maybe set a transaction id.
446
-			if ( ! empty( $result->transactionResponse->transId ) ) {
447
-				$invoice->set_transaction_id( $result->transactionResponse->transId );
446
+			if (!empty($result->transactionResponse->transId)) {
447
+				$invoice->set_transaction_id($result->transactionResponse->transId);
448 448
 			}
449 449
 
450
-			$invoice->add_note( sprintf( __( 'Authentication code: %1$s (%2$s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true );
450
+			$invoice->add_note(sprintf(__('Authentication code: %1$s (%2$s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true);
451 451
 
452
-			if ( 1 == $response_code ) {
452
+			if (1 == $response_code) {
453 453
 				return $invoice->mark_paid();
454 454
 			}
455 455
 
456
-			$invoice->set_status( 'wpi-onhold' );
456
+			$invoice->set_status('wpi-onhold');
457 457
         	$invoice->add_note(
458 458
                 sprintf(
459
-                    __( 'Held for review: %s', 'invoicing' ),
459
+                    __('Held for review: %s', 'invoicing'),
460 460
                     $result->transactionResponse->messages->message[0]->description
461 461
                 )
462 462
 			);
@@ -465,11 +465,11 @@  discard block
 block discarded – undo
465 465
 
466 466
 		}
467 467
 
468
-        wpinv_set_error( 'card_declined' );
468
+        wpinv_set_error('card_declined');
469 469
 
470
-        if ( ! empty( $result->transactionResponse->errors ) ) {
470
+        if (!empty($result->transactionResponse->errors)) {
471 471
             $errors = (object) $result->transactionResponse->errors;
472
-            wpinv_set_error( $errors->error[0]->errorCode, esc_html( $errors->error[0]->errorText ) );
472
+            wpinv_set_error($errors->error[0]->errorCode, esc_html($errors->error[0]->errorText));
473 473
         }
474 474
 
475 475
     }
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 	 * @param array $card Card details.
482 482
 	 * @return array
483 483
 	 */
484
-	public function get_payment_information( $card ) {
484
+	public function get_payment_information($card) {
485 485
         return array(
486 486
 
487 487
             'creditCard' => array(
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 	 * @param WPInv_Invoice $invoice Invoice.
501 501
 	 * @return string
502 502
 	 */
503
-	public function get_customer_profile_meta_name( $invoice ) {
504
-        return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
503
+	public function get_customer_profile_meta_name($invoice) {
504
+        return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
505 505
     }
506 506
 
507 507
     /**
@@ -512,34 +512,34 @@  discard block
 block discarded – undo
512 512
      * @param WPInv_Invoice $invoice
513 513
 	 * @return WP_Error|string The payment profile id
514 514
 	 */
515
-	public function validate_submission_data( $submission_data, $invoice ) {
515
+	public function validate_submission_data($submission_data, $invoice) {
516 516
 
517 517
         // Validate authentication details.
518 518
         $auth = $this->get_auth_params();
519 519
 
520
-        if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) {
521
-            return new WP_Error( 'invalid_settings', __( 'Please set-up your login id and transaction key before using this gateway.', 'invoicing' ) );
520
+        if (empty($auth['name']) || empty($auth['transactionKey'])) {
521
+            return new WP_Error('invalid_settings', __('Please set-up your login id and transaction key before using this gateway.', 'invoicing'));
522 522
         }
523 523
 
524 524
         // Validate the payment method.
525
-        if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) {
526
-            return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing' ) );
525
+        if (empty($submission_data['getpaid-authorizenet-payment-method'])) {
526
+            return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing'));
527 527
         }
528 528
 
529 529
         // Are we adding a new payment method?
530
-        if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) {
530
+        if ('new' != $submission_data['getpaid-authorizenet-payment-method']) {
531 531
             return $submission_data['getpaid-authorizenet-payment-method'];
532 532
         }
533 533
 
534 534
         // Retrieve the customer profile id.
535
-        $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
535
+        $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
536 536
 
537 537
         // Create payment method.
538
-        if ( empty( $profile_id ) ) {
539
-            return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) );
538
+        if (empty($profile_id)) {
539
+            return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method']));
540 540
         }
541 541
 
542
-        return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) );
542
+        return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method']));
543 543
 
544 544
     }
545 545
 
@@ -550,32 +550,32 @@  discard block
 block discarded – undo
550 550
 	 * @param WPInv_Invoice $invoice Invoice.
551 551
 	 * @return array
552 552
 	 */
553
-	public function get_line_items( $invoice ) {
553
+	public function get_line_items($invoice) {
554 554
         $items = array();
555 555
 
556
-        foreach ( $invoice->get_items() as $item ) {
556
+        foreach ($invoice->get_items() as $item) {
557 557
 
558 558
             $amount  = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price();
559 559
             $items[] = array(
560
-                'itemId'      => getpaid_limit_length( $item->get_id(), 31 ),
561
-                'name'        => getpaid_limit_length( $item->get_raw_name(), 31 ),
562
-                'description' => getpaid_limit_length( $item->get_description(), 255 ),
563
-                'quantity'    => (string) ( $invoice->get_template() == 'amount' ? 1 : $item->get_quantity() ),
560
+                'itemId'      => getpaid_limit_length($item->get_id(), 31),
561
+                'name'        => getpaid_limit_length($item->get_raw_name(), 31),
562
+                'description' => getpaid_limit_length($item->get_description(), 255),
563
+                'quantity'    => (string) ($invoice->get_template() == 'amount' ? 1 : $item->get_quantity()),
564 564
                 'unitPrice'   => (float) $amount,
565 565
                 'taxable'     => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(),
566 566
             );
567 567
 
568 568
         }
569 569
 
570
-        foreach ( $invoice->get_fees() as $fee_name => $fee ) {
570
+        foreach ($invoice->get_fees() as $fee_name => $fee) {
571 571
 
572
-            $amount  = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee'];
572
+            $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee'];
573 573
 
574
-            if ( $amount > 0 ) {
574
+            if ($amount > 0) {
575 575
                 $items[] = array(
576
-                    'itemId'      => getpaid_limit_length( $fee_name, 31 ),
577
-                    'name'        => getpaid_limit_length( $fee_name, 31 ),
578
-                    'description' => getpaid_limit_length( $fee_name, 255 ),
576
+                    'itemId'      => getpaid_limit_length($fee_name, 31),
577
+                    'name'        => getpaid_limit_length($fee_name, 31),
578
+                    'description' => getpaid_limit_length($fee_name, 255),
579 579
                     'quantity'    => '1',
580 580
                     'unitPrice'   => (float) $amount,
581 581
                     'taxable'     => false,
@@ -595,36 +595,36 @@  discard block
 block discarded – undo
595 595
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
596 596
 	 * @return array
597 597
 	 */
598
-	public function process_payment( $invoice, $submission_data, $submission ) {
598
+	public function process_payment($invoice, $submission_data, $submission) {
599 599
 
600 600
         // Validate the submitted data.
601
-        $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice );
601
+        $payment_profile_id = $this->validate_submission_data($submission_data, $invoice);
602 602
 
603 603
         // Do we have an error?
604
-        if ( is_wp_error( $payment_profile_id ) ) {
605
-            wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() );
606
-            wpinv_send_back_to_checkout( $invoice );
604
+        if (is_wp_error($payment_profile_id)) {
605
+            wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message());
606
+            wpinv_send_back_to_checkout($invoice);
607 607
         }
608 608
 
609 609
         // Save the payment method to the order.
610
-        update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id );
610
+        update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id);
611 611
 
612 612
         // Check if this is a subscription or not.
613
-        $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
614
-        if ( ! empty( $subscriptions ) ) {
615
-            $this->process_subscription( $invoice, $subscriptions );
613
+        $subscriptions = getpaid_get_invoice_subscriptions($invoice);
614
+        if (!empty($subscriptions)) {
615
+            $this->process_subscription($invoice, $subscriptions);
616 616
         }
617 617
 
618 618
         // If it is free, send to the success page.
619
-        if ( ! $invoice->needs_payment() ) {
619
+        if (!$invoice->needs_payment()) {
620 620
             $invoice->mark_paid();
621
-            wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
621
+            wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
622 622
         }
623 623
 
624 624
         // Charge the payment profile.
625
-        $this->process_initial_payment( $invoice );
625
+        $this->process_initial_payment($invoice);
626 626
 
627
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
627
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
628 628
 
629 629
         exit;
630 630
 
@@ -635,23 +635,23 @@  discard block
 block discarded – undo
635 635
 	 *
636 636
      * @param WPInv_Invoice $invoice Invoice.
637 637
 	 */
638
-	protected function process_initial_payment( $invoice ) {
638
+	protected function process_initial_payment($invoice) {
639 639
 
640
-		$payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
641
-        $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
642
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
640
+		$payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
641
+        $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
642
+		$result             = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice);
643 643
 
644 644
 		// Do we have an error?
645
-		if ( is_wp_error( $result ) ) {
646
-			wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
647
-			wpinv_send_back_to_checkout( $invoice );
645
+		if (is_wp_error($result)) {
646
+			wpinv_set_error($result->get_error_code(), $result->get_error_message());
647
+			wpinv_send_back_to_checkout($invoice);
648 648
 		}
649 649
 
650 650
 		// Process the response.
651
-		$this->process_charge_response( $result, $invoice );
651
+		$this->process_charge_response($result, $invoice);
652 652
 
653
-		if ( wpinv_get_errors() ) {
654
-			wpinv_send_back_to_checkout( $invoice );
653
+		if (wpinv_get_errors()) {
654
+			wpinv_send_back_to_checkout($invoice);
655 655
 		}
656 656
 
657 657
 	}
@@ -662,30 +662,30 @@  discard block
 block discarded – undo
662 662
      * @param WPInv_Invoice $invoice Invoice.
663 663
      * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions.
664 664
 	 */
665
-	public function process_subscription( $invoice, $subscriptions ) {
665
+	public function process_subscription($invoice, $subscriptions) {
666 666
 
667 667
         // Check if there is an initial amount to charge.
668
-        if ( (float) $invoice->get_total() > 0 ) {
669
-			$this->process_initial_payment( $invoice );
668
+        if ((float) $invoice->get_total() > 0) {
669
+			$this->process_initial_payment($invoice);
670 670
         }
671 671
 
672 672
         // Activate the subscriptions.
673
-        $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
673
+        $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions);
674 674
 
675
-        foreach ( $subscriptions as $subscription ) {
676
-            if ( $subscription->exists() ) {
677
-                $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
678
-                $expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
675
+        foreach ($subscriptions as $subscription) {
676
+            if ($subscription->exists()) {
677
+                $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
678
+                $expiry   = date('Y-m-d H:i:s', (current_time('timestamp') + $duration));
679 679
 
680
-                $subscription->set_next_renewal_date( $expiry );
681
-                $subscription->set_date_created( current_time( 'mysql' ) );
682
-                $subscription->set_profile_id( $invoice->generate_key( 'authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) );
680
+                $subscription->set_next_renewal_date($expiry);
681
+                $subscription->set_date_created(current_time('mysql'));
682
+                $subscription->set_profile_id($invoice->generate_key('authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id()));
683 683
                 $subscription->activate();
684 684
             }
685 685
         }
686 686
 
687 687
 		// Redirect to the success page.
688
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
688
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
689 689
 
690 690
     }
691 691
 
@@ -695,11 +695,11 @@  discard block
 block discarded – undo
695 695
 	 *
696 696
      * @param WPInv_Subscription $subscription
697 697
 	 */
698
-	public function maybe_renew_subscription( $subscription ) {
698
+	public function maybe_renew_subscription($subscription) {
699 699
 
700 700
         // Ensure its our subscription && it's active.
701
-        if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
702
-            $this->renew_subscription( $subscription );
701
+        if ($this->id === $subscription->get_gateway() && $subscription->has_status('active trialling')) {
702
+            $this->renew_subscription($subscription);
703 703
         }
704 704
 
705 705
 	}
@@ -709,28 +709,28 @@  discard block
 block discarded – undo
709 709
 	 *
710 710
      * @param WPInv_Subscription $subscription
711 711
 	 */
712
-	public function renew_subscription( $subscription ) {
712
+	public function renew_subscription($subscription) {
713 713
 
714 714
 		// Generate the renewal invoice.
715 715
 		$new_invoice = $subscription->create_payment();
716 716
 		$old_invoice = $subscription->get_parent_payment();
717 717
 
718
-        if ( empty( $new_invoice ) ) {
719
-            $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false );
718
+        if (empty($new_invoice)) {
719
+            $old_invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false);
720 720
             $subscription->failing();
721 721
             return;
722 722
         }
723 723
 
724 724
         // Charge the payment method.
725
-		$payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
726
-		$customer_profile   = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true );
727
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice );
725
+		$payment_profile_id = get_post_meta($old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
726
+		$customer_profile   = get_user_meta($old_invoice->get_user_id(), $this->get_customer_profile_meta_name($old_invoice), true);
727
+		$result             = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice);
728 728
 
729 729
 		// Do we have an error?
730
-		if ( is_wp_error( $result ) ) {
730
+		if (is_wp_error($result)) {
731 731
 
732 732
 			$old_invoice->add_note(
733
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
733
+				sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()),
734 734
 				true,
735 735
 				false,
736 736
 				true
@@ -741,12 +741,12 @@  discard block
 block discarded – undo
741 741
 		}
742 742
 
743 743
 		// Process the response.
744
-		$this->process_charge_response( $result, $new_invoice );
744
+		$this->process_charge_response($result, $new_invoice);
745 745
 
746
-		if ( wpinv_get_errors() ) {
746
+		if (wpinv_get_errors()) {
747 747
 
748 748
 			$old_invoice->add_note(
749
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
749
+				sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()),
750 750
 				true,
751 751
 				false,
752 752
 				true
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 
757 757
         }
758 758
 
759
-        $subscription->add_payment( array(), $new_invoice );
759
+        $subscription->add_payment(array(), $new_invoice);
760 760
         $subscription->renew();
761 761
     }
762 762
 
@@ -767,33 +767,33 @@  discard block
 block discarded – undo
767 767
 	 * @param GetPaid_Form_Item[] $items
768 768
 	 * @return WPInv_Invoice
769 769
 	 */
770
-	public function process_addons( $invoice, $items ) {
770
+	public function process_addons($invoice, $items) {
771 771
 
772 772
         global $getpaid_authorize_addons;
773 773
 
774 774
         $getpaid_authorize_addons = array();
775
-        foreach ( $items as $item ) {
775
+        foreach ($items as $item) {
776 776
 
777
-            if ( is_null( $invoice->get_item( $item->get_id() ) ) && ! is_wp_error( $invoice->add_item( $item ) ) ) {
777
+            if (is_null($invoice->get_item($item->get_id())) && !is_wp_error($invoice->add_item($item))) {
778 778
                 $getpaid_authorize_addons[] = $item;
779 779
             }
780 780
 }
781 781
 
782
-        if ( empty( $getpaid_authorize_addons ) ) {
782
+        if (empty($getpaid_authorize_addons)) {
783 783
             return;
784 784
         }
785 785
 
786 786
         $invoice->recalculate_total();
787 787
 
788
-        $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
789
-		$customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
788
+        $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
789
+		$customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
790 790
 
791
-        add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 );
792
-        $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
793
-        remove_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ) );
791
+        add_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'), 10, 2);
792
+        $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice);
793
+        remove_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'));
794 794
 
795
-        if ( is_wp_error( $result ) ) {
796
-            wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
795
+        if (is_wp_error($result)) {
796
+            wpinv_set_error($result->get_error_code(), $result->get_error_message());
797 797
             return;
798 798
         }
799 799
 
@@ -806,19 +806,19 @@  discard block
 block discarded – undo
806 806
      * @param array $args
807 807
 	 * @return array
808 808
 	 */
809
-    public function filter_addons_request( $args ) {
809
+    public function filter_addons_request($args) {
810 810
 
811 811
         global $getpaid_authorize_addons;
812 812
         $total = 0;
813 813
 
814
-        foreach ( $getpaid_authorize_addons as $addon ) {
814
+        foreach ($getpaid_authorize_addons as $addon) {
815 815
             $total += $addon->get_sub_total();
816 816
         }
817 817
 
818 818
         $args['createTransactionRequest']['transactionRequest']['amount'] = $total;
819 819
 
820
-        if ( isset( $args['createTransactionRequest']['transactionRequest']['tax'] ) ) {
821
-            unset( $args['createTransactionRequest']['transactionRequest']['tax'] );
820
+        if (isset($args['createTransactionRequest']['transactionRequest']['tax'])) {
821
+            unset($args['createTransactionRequest']['transactionRequest']['tax']);
822 822
         }
823 823
 
824 824
         return $args;
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
     public function sandbox_notice() {
832 832
 
833 833
         return sprintf(
834
-            __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %1$sAuthorize.NET Sandbox Testing Guide%2$s for more details.', 'invoicing' ),
834
+            __('SANDBOX ENABLED. You can use sandbox testing details only. See the %1$sAuthorize.NET Sandbox Testing Guide%2$s for more details.', 'invoicing'),
835 835
             '<a href="https://developer.authorize.net/hello_world/testing_guide.html">',
836 836
             '</a>'
837 837
         );
@@ -843,42 +843,42 @@  discard block
 block discarded – undo
843 843
 	 *
844 844
 	 * @param array $admin_settings
845 845
 	 */
846
-	public function admin_settings( $admin_settings ) {
846
+	public function admin_settings($admin_settings) {
847 847
 
848 848
         $currencies = sprintf(
849
-            __( 'Supported Currencies: %s', 'invoicing' ),
850
-            implode( ', ', $this->currencies )
849
+            __('Supported Currencies: %s', 'invoicing'),
850
+            implode(', ', $this->currencies)
851 851
         );
852 852
 
853 853
         $admin_settings['authorizenet_active']['desc'] .= " ($currencies)";
854
-        $admin_settings['authorizenet_desc']['std']     = __( 'Pay securely using your credit or debit card.', 'invoicing' );
854
+        $admin_settings['authorizenet_desc']['std']     = __('Pay securely using your credit or debit card.', 'invoicing');
855 855
 
856 856
         $admin_settings['authorizenet_login_id'] = array(
857 857
             'type' => 'text',
858 858
             'id'   => 'authorizenet_login_id',
859
-            'name' => __( 'API Login ID', 'invoicing' ),
860
-            'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __( 'How do I obtain my API Login ID and Transaction Key?', 'invoicing' ) . '</em></a>',
859
+            'name' => __('API Login ID', 'invoicing'),
860
+            'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __('How do I obtain my API Login ID and Transaction Key?', 'invoicing') . '</em></a>',
861 861
         );
862 862
 
863 863
         $admin_settings['authorizenet_transaction_key'] = array(
864 864
             'type' => 'text',
865 865
             'id'   => 'authorizenet_transaction_key',
866
-            'name' => __( 'Transaction Key', 'invoicing' ),
866
+            'name' => __('Transaction Key', 'invoicing'),
867 867
         );
868 868
 
869 869
         $admin_settings['authorizenet_signature_key'] = array(
870 870
             'type' => 'text',
871 871
             'id'   => 'authorizenet_signature_key',
872
-            'name' => __( 'Signature Key', 'invoicing' ),
873
-            'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
872
+            'name' => __('Signature Key', 'invoicing'),
873
+            'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
874 874
         );
875 875
 
876 876
         $admin_settings['authorizenet_ipn_url'] = array(
877 877
             'type'     => 'ipn_url',
878 878
             'id'       => 'authorizenet_ipn_url',
879
-            'name'     => __( 'Webhook URL', 'invoicing' ),
879
+            'name'     => __('Webhook URL', 'invoicing'),
880 880
             'std'      => $this->notify_url,
881
-            'desc'     => __( 'Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing' ) . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
881
+            'desc'     => __('Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing') . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
882 882
             'custom'   => 'authorizenet',
883 883
             'readonly' => true,
884 884
         );
Please login to merge, or discard this patch.
includes/class-wpinv-session-handler.php 2 patches
Indentation   +274 added lines, -274 removed lines patch added patch discarded remove patch
@@ -14,125 +14,125 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class WPInv_Session_Handler extends WPInv_Session {
16 16
 
17
-	/**
18
-	 * Cookie name used for the session.
19
-	 *
20
-	 * @var string cookie name
21
-	 */
22
-	protected $_cookie;
23
-
24
-	/**
25
-	 * Stores session expiry.
26
-	 *
27
-	 * @var int session due to expire timestamp
28
-	 */
29
-	protected $_session_expiring;
30
-
31
-	/**
32
-	 * Stores session due to expire timestamp.
33
-	 *
34
-	 * @var string session expiration timestamp
35
-	 */
36
-	protected $_session_expiration;
37
-
38
-	/**
39
-	 * True when the cookie exists.
40
-	 *
41
-	 * @var bool Based on whether a cookie exists.
42
-	 */
43
-	protected $_has_cookie = false;
44
-
45
-	/**
46
-	 * Table name for session data.
47
-	 *
48
-	 * @var string Custom session table name
49
-	 */
50
-	protected $_table;
51
-
52
-	/**
53
-	 * Constructor for the session class.
54
-	 */
55
-	public function old__construct() {
56
-
57
-	    $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
17
+    /**
18
+     * Cookie name used for the session.
19
+     *
20
+     * @var string cookie name
21
+     */
22
+    protected $_cookie;
23
+
24
+    /**
25
+     * Stores session expiry.
26
+     *
27
+     * @var int session due to expire timestamp
28
+     */
29
+    protected $_session_expiring;
30
+
31
+    /**
32
+     * Stores session due to expire timestamp.
33
+     *
34
+     * @var string session expiration timestamp
35
+     */
36
+    protected $_session_expiration;
37
+
38
+    /**
39
+     * True when the cookie exists.
40
+     *
41
+     * @var bool Based on whether a cookie exists.
42
+     */
43
+    protected $_has_cookie = false;
44
+
45
+    /**
46
+     * Table name for session data.
47
+     *
48
+     * @var string Custom session table name
49
+     */
50
+    protected $_table;
51
+
52
+    /**
53
+     * Constructor for the session class.
54
+     */
55
+    public function old__construct() {
56
+
57
+        $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
58 58
         add_action( 'init', array( $this, 'init' ), -1 );
59
-		add_action( 'wp_logout', array( $this, 'destroy_session' ) );
60
-		add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 );
61
-		add_action( 'shutdown', array( $this, 'save_data' ), 20 );
62
-
63
-	}
64
-
65
-	/**
66
-	 * Init hooks and session data.
67
-	 *
68
-	 * @since 3.3.0
69
-	 */
70
-	public function init() {
71
-		$this->init_session_cookie();
72
-
73
-		if ( ! is_user_logged_in() ) {
74
-			add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ), 10, 2 );
75
-		}
76
-	}
77
-
78
-	/**
79
-	 * Setup cookie and customer ID.
80
-	 *
81
-	 * @since 3.6.0
82
-	 */
83
-	public function init_session_cookie() {
84
-		$cookie = $this->get_session_cookie();
85
-
86
-		if ( $cookie ) {
87
-			$this->_customer_id        = $cookie[0];
88
-			$this->_session_expiration = $cookie[1];
89
-			$this->_session_expiring   = $cookie[2];
90
-			$this->_has_cookie         = true;
91
-			$this->_data               = $this->get_session_data();
92
-
93
-			// If the user logs in, update session.
94
-			if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
95
-				$this->_customer_id = get_current_user_id();
96
-				$this->_dirty       = true;
97
-				$this->save_data();
98
-				$this->set_customer_session_cookie( true );
99
-			}
100
-
101
-			// Update session if its close to expiring.
102
-			if ( time() > $this->_session_expiring ) {
103
-				$this->set_session_expiration();
104
-				$this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
105
-			}
106
-		} else {
107
-			$this->set_session_expiration();
108
-			$this->_customer_id = $this->generate_customer_id();
109
-			$this->_data        = $this->get_session_data();
110
-		}
111
-	}
112
-
113
-	/**
114
-	 * Sets the session cookie on-demand (usually after adding an item to the cart).
115
-	 *
116
-	 * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.
117
-	 *
118
-	 * Warning: Cookies will only be set if this is called before the headers are sent.
119
-	 *
120
-	 * @param bool $set Should the session cookie be set.
121
-	 */
122
-	public function set_customer_session_cookie( $set ) {
123
-		if ( $set ) {
124
-			$to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
125
-			$cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
126
-			$cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
127
-			$this->_has_cookie = true;
128
-
129
-			if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
130
-				$this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
131
-			}
132
-		}
133
-	}
134
-
135
-	public function setcookie( $name, $value, $expire = 0, $secure = false, $httponly = false ) {
59
+        add_action( 'wp_logout', array( $this, 'destroy_session' ) );
60
+        add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 );
61
+        add_action( 'shutdown', array( $this, 'save_data' ), 20 );
62
+
63
+    }
64
+
65
+    /**
66
+     * Init hooks and session data.
67
+     *
68
+     * @since 3.3.0
69
+     */
70
+    public function init() {
71
+        $this->init_session_cookie();
72
+
73
+        if ( ! is_user_logged_in() ) {
74
+            add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ), 10, 2 );
75
+        }
76
+    }
77
+
78
+    /**
79
+     * Setup cookie and customer ID.
80
+     *
81
+     * @since 3.6.0
82
+     */
83
+    public function init_session_cookie() {
84
+        $cookie = $this->get_session_cookie();
85
+
86
+        if ( $cookie ) {
87
+            $this->_customer_id        = $cookie[0];
88
+            $this->_session_expiration = $cookie[1];
89
+            $this->_session_expiring   = $cookie[2];
90
+            $this->_has_cookie         = true;
91
+            $this->_data               = $this->get_session_data();
92
+
93
+            // If the user logs in, update session.
94
+            if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
95
+                $this->_customer_id = get_current_user_id();
96
+                $this->_dirty       = true;
97
+                $this->save_data();
98
+                $this->set_customer_session_cookie( true );
99
+            }
100
+
101
+            // Update session if its close to expiring.
102
+            if ( time() > $this->_session_expiring ) {
103
+                $this->set_session_expiration();
104
+                $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
105
+            }
106
+        } else {
107
+            $this->set_session_expiration();
108
+            $this->_customer_id = $this->generate_customer_id();
109
+            $this->_data        = $this->get_session_data();
110
+        }
111
+    }
112
+
113
+    /**
114
+     * Sets the session cookie on-demand (usually after adding an item to the cart).
115
+     *
116
+     * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.
117
+     *
118
+     * Warning: Cookies will only be set if this is called before the headers are sent.
119
+     *
120
+     * @param bool $set Should the session cookie be set.
121
+     */
122
+    public function set_customer_session_cookie( $set ) {
123
+        if ( $set ) {
124
+            $to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
125
+            $cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
126
+            $cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
127
+            $this->_has_cookie = true;
128
+
129
+            if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
130
+                $this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
131
+            }
132
+        }
133
+    }
134
+
135
+    public function setcookie( $name, $value, $expire = 0, $secure = false, $httponly = false ) {
136 136
         if ( ! headers_sent() ) {
137 137
             setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) );
138 138
         } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
@@ -141,86 +141,86 @@  discard block
 block discarded – undo
141 141
         }
142 142
     }
143 143
 
144
-	/**
145
-	 * Should the session cookie be secure?
146
-	 *
147
-	 * @since 3.6.0
148
-	 * @return bool
149
-	 */
150
-	protected function use_secure_cookie() {
144
+    /**
145
+     * Should the session cookie be secure?
146
+     *
147
+     * @since 3.6.0
148
+     * @return bool
149
+     */
150
+    protected function use_secure_cookie() {
151 151
         $is_https = false !== strstr( get_option( 'home' ), 'https:' );
152
-		return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
153
-	}
154
-
155
-	/**
156
-	 * Return true if the current user has an active session, i.e. a cookie to retrieve values.
157
-	 *
158
-	 * @return bool
159
-	 */
160
-	public function has_session() {
161
-		return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
162
-	}
163
-
164
-	/**
165
-	 * Set session expiration.
166
-	 */
167
-	public function set_session_expiration() {
168
-		$this->_session_expiring   = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
169
-		$this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
170
-	}
171
-
172
-	/**
173
-	 * Generates session ids.
174
-	 *
175
-	 * @return string
176
-	 */
177
-	public function generate_customer_id() {
178
-		require_once ABSPATH . 'wp-includes/class-phpass.php';
179
-		$hasher      = new PasswordHash( 8, false );
180
-		return md5( $hasher->get_random_bytes( 32 ) );
181
-	}
182
-
183
-	/**
184
-	 * Get the session cookie, if set. Otherwise return false.
185
-	 *
186
-	 * Session cookies without a customer ID are invalid.
187
-	 *
188
-	 * @return bool|array
189
-	 */
190
-	public function get_session_cookie() {
191
-		$cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
192
-
193
-		if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
194
-			return false;
195
-		}
196
-
197
-		list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
198
-
199
-		if ( empty( $customer_id ) ) {
200
-			return false;
201
-		}
202
-
203
-		// Validate hash.
204
-		$to_hash = $customer_id . '|' . $session_expiration;
205
-		$hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
206
-
207
-		if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
208
-			return false;
209
-		}
210
-
211
-		return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
212
-	}
213
-
214
-	/**
215
-	 * Get session data.
216
-	 *
217
-	 * @return array
218
-	 */
219
-	public function get_session_data() {
220
-		return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
221
-	}
222
-
223
-	public function generate_key( $customer_id ) {
152
+        return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
153
+    }
154
+
155
+    /**
156
+     * Return true if the current user has an active session, i.e. a cookie to retrieve values.
157
+     *
158
+     * @return bool
159
+     */
160
+    public function has_session() {
161
+        return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
162
+    }
163
+
164
+    /**
165
+     * Set session expiration.
166
+     */
167
+    public function set_session_expiration() {
168
+        $this->_session_expiring   = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
169
+        $this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
170
+    }
171
+
172
+    /**
173
+     * Generates session ids.
174
+     *
175
+     * @return string
176
+     */
177
+    public function generate_customer_id() {
178
+        require_once ABSPATH . 'wp-includes/class-phpass.php';
179
+        $hasher      = new PasswordHash( 8, false );
180
+        return md5( $hasher->get_random_bytes( 32 ) );
181
+    }
182
+
183
+    /**
184
+     * Get the session cookie, if set. Otherwise return false.
185
+     *
186
+     * Session cookies without a customer ID are invalid.
187
+     *
188
+     * @return bool|array
189
+     */
190
+    public function get_session_cookie() {
191
+        $cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
192
+
193
+        if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
194
+            return false;
195
+        }
196
+
197
+        list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
198
+
199
+        if ( empty( $customer_id ) ) {
200
+            return false;
201
+        }
202
+
203
+        // Validate hash.
204
+        $to_hash = $customer_id . '|' . $session_expiration;
205
+        $hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
206
+
207
+        if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
208
+            return false;
209
+        }
210
+
211
+        return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
212
+    }
213
+
214
+    /**
215
+     * Get session data.
216
+     *
217
+     * @return array
218
+     */
219
+    public function get_session_data() {
220
+        return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
221
+    }
222
+
223
+    public function generate_key( $customer_id ) {
224 224
         if ( ! $customer_id ) {
225 225
             return;
226 226
         }
@@ -228,68 +228,68 @@  discard block
 block discarded – undo
228 228
         return 'wpi_trans_' . $customer_id;
229 229
     }
230 230
 
231
-	/**
232
-	 * Save data.
233
-	 */
234
-	public function save_data() {
235
-		// Dirty if something changed - prevents saving nothing new.
236
-		if ( $this->_dirty && $this->has_session() ) {
231
+    /**
232
+     * Save data.
233
+     */
234
+    public function save_data() {
235
+        // Dirty if something changed - prevents saving nothing new.
236
+        if ( $this->_dirty && $this->has_session() ) {
237 237
 
238 238
             set_transient( $this->generate_key( $this->_customer_id ), $this->_data, $this->_session_expiration );
239 239
 
240
-			$this->_dirty = false;
241
-		}
242
-	}
243
-
244
-	/**
245
-	 * Destroy all session data.
246
-	 */
247
-	public function destroy_session() {
248
-		$this->delete_session( $this->_customer_id );
249
-		$this->forget_session();
250
-	}
251
-
252
-	/**
253
-	 * Forget all session data without destroying it.
254
-	 */
255
-	public function forget_session() {
256
-		$this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
257
-
258
-		wpinv_empty_cart();
259
-
260
-		$this->_data        = array();
261
-		$this->_dirty       = false;
262
-		$this->_customer_id = $this->generate_customer_id();
263
-	}
264
-
265
-	/**
266
-	 * When a user is logged out, ensure they have a unique nonce by using the customer/session ID.
267
-	 *
268
-	 * @param int $uid User ID.
269
-	 * @return string
270
-	 */
271
-	public function nonce_user_logged_out( $uid ) {
272
-
273
-		// Check if one of our nonces.
274
-		if ( substr( $uid, 0, 5 ) === 'wpinv' || substr( $uid, 0, 7 ) === 'getpaid' ) {
275
-			return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
276
-		}
277
-
278
-		return $uid;
279
-	}
280
-
281
-	/**
282
-	 * Returns the session.
283
-	 *
284
-	 * @param string $customer_id Customer ID.
285
-	 * @param mixed  $default Default session value.
286
-	 * @return string|array
287
-	 */
288
-	public function get_session( $customer_id, $default = false ) {
289
-
290
-		if ( defined( 'WP_SETUP_CONFIG' ) ) {
291
-			return array();
292
-		}
240
+            $this->_dirty = false;
241
+        }
242
+    }
243
+
244
+    /**
245
+     * Destroy all session data.
246
+     */
247
+    public function destroy_session() {
248
+        $this->delete_session( $this->_customer_id );
249
+        $this->forget_session();
250
+    }
251
+
252
+    /**
253
+     * Forget all session data without destroying it.
254
+     */
255
+    public function forget_session() {
256
+        $this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
257
+
258
+        wpinv_empty_cart();
259
+
260
+        $this->_data        = array();
261
+        $this->_dirty       = false;
262
+        $this->_customer_id = $this->generate_customer_id();
263
+    }
264
+
265
+    /**
266
+     * When a user is logged out, ensure they have a unique nonce by using the customer/session ID.
267
+     *
268
+     * @param int $uid User ID.
269
+     * @return string
270
+     */
271
+    public function nonce_user_logged_out( $uid ) {
272
+
273
+        // Check if one of our nonces.
274
+        if ( substr( $uid, 0, 5 ) === 'wpinv' || substr( $uid, 0, 7 ) === 'getpaid' ) {
275
+            return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
276
+        }
277
+
278
+        return $uid;
279
+    }
280
+
281
+    /**
282
+     * Returns the session.
283
+     *
284
+     * @param string $customer_id Customer ID.
285
+     * @param mixed  $default Default session value.
286
+     * @return string|array
287
+     */
288
+    public function get_session( $customer_id, $default = false ) {
289
+
290
+        if ( defined( 'WP_SETUP_CONFIG' ) ) {
291
+            return array();
292
+        }
293 293
 
294 294
         $key = $this->generate_key( $customer_id );
295 295
         $value = get_transient( $key );
@@ -298,30 +298,30 @@  discard block
 block discarded – undo
298 298
             $value = $default;
299 299
         }
300 300
 
301
-		return maybe_unserialize( $value );
302
-	}
301
+        return maybe_unserialize( $value );
302
+    }
303 303
 
304
-	/**
305
-	 * Delete the session from the cache and database.
306
-	 *
307
-	 * @param int $customer_id Customer ID.
308
-	 */
309
-	public function delete_session( $customer_id ) {
304
+    /**
305
+     * Delete the session from the cache and database.
306
+     *
307
+     * @param int $customer_id Customer ID.
308
+     */
309
+    public function delete_session( $customer_id ) {
310 310
 
311 311
         $key = $this->generate_key( $customer_id );
312 312
 
313
-		delete_transient( $key );
314
-	}
313
+        delete_transient( $key );
314
+    }
315 315
 
316
-	/**
317
-	 * Update the session expiry timestamp.
318
-	 *
319
-	 * @param string $customer_id Customer ID.
320
-	 * @param int    $timestamp Timestamp to expire the cookie.
321
-	 */
322
-	public function update_session_timestamp( $customer_id, $timestamp ) {
316
+    /**
317
+     * Update the session expiry timestamp.
318
+     *
319
+     * @param string $customer_id Customer ID.
320
+     * @param int    $timestamp Timestamp to expire the cookie.
321
+     */
322
+    public function update_session_timestamp( $customer_id, $timestamp ) {
323 323
 
324 324
         set_transient( $this->generate_key( $customer_id ), maybe_serialize( $this->_data ), $timestamp );
325 325
 
326
-	}
326
+    }
327 327
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * Session handler class.
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function old__construct() {
56 56
 
57
-	    $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
58
-        add_action( 'init', array( $this, 'init' ), -1 );
59
-		add_action( 'wp_logout', array( $this, 'destroy_session' ) );
60
-		add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 );
61
-		add_action( 'shutdown', array( $this, 'save_data' ), 20 );
57
+	    $this->_cookie = apply_filters('wpinv_cookie', 'wpinv_session_' . COOKIEHASH);
58
+        add_action('init', array($this, 'init'), -1);
59
+		add_action('wp_logout', array($this, 'destroy_session'));
60
+		add_action('wp', array($this, 'set_customer_session_cookie'), 10);
61
+		add_action('shutdown', array($this, 'save_data'), 20);
62 62
 
63 63
 	}
64 64
 
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 	public function init() {
71 71
 		$this->init_session_cookie();
72 72
 
73
-		if ( ! is_user_logged_in() ) {
74
-			add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ), 10, 2 );
73
+		if (!is_user_logged_in()) {
74
+			add_filter('nonce_user_logged_out', array($this, 'nonce_user_logged_out'), 10, 2);
75 75
 		}
76 76
 	}
77 77
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	public function init_session_cookie() {
84 84
 		$cookie = $this->get_session_cookie();
85 85
 
86
-		if ( $cookie ) {
86
+		if ($cookie) {
87 87
 			$this->_customer_id        = $cookie[0];
88 88
 			$this->_session_expiration = $cookie[1];
89 89
 			$this->_session_expiring   = $cookie[2];
@@ -91,17 +91,17 @@  discard block
 block discarded – undo
91 91
 			$this->_data               = $this->get_session_data();
92 92
 
93 93
 			// If the user logs in, update session.
94
-			if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
94
+			if (is_user_logged_in() && get_current_user_id() != $this->_customer_id) {
95 95
 				$this->_customer_id = get_current_user_id();
96 96
 				$this->_dirty       = true;
97 97
 				$this->save_data();
98
-				$this->set_customer_session_cookie( true );
98
+				$this->set_customer_session_cookie(true);
99 99
 			}
100 100
 
101 101
 			// Update session if its close to expiring.
102
-			if ( time() > $this->_session_expiring ) {
102
+			if (time() > $this->_session_expiring) {
103 103
 				$this->set_session_expiration();
104
-				$this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
104
+				$this->update_session_timestamp($this->_customer_id, $this->_session_expiration);
105 105
 			}
106 106
 		} else {
107 107
 			$this->set_session_expiration();
@@ -119,25 +119,25 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @param bool $set Should the session cookie be set.
121 121
 	 */
122
-	public function set_customer_session_cookie( $set ) {
123
-		if ( $set ) {
122
+	public function set_customer_session_cookie($set) {
123
+		if ($set) {
124 124
 			$to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
125
-			$cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
125
+			$cookie_hash       = hash_hmac('md5', $to_hash, wp_hash($to_hash));
126 126
 			$cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
127 127
 			$this->_has_cookie = true;
128 128
 
129
-			if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
130
-				$this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
129
+			if (!isset($_COOKIE[$this->_cookie]) || $_COOKIE[$this->_cookie] !== $cookie_value) {
130
+				$this->setcookie($this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true);
131 131
 			}
132 132
 		}
133 133
 	}
134 134
 
135
-	public function setcookie( $name, $value, $expire = 0, $secure = false, $httponly = false ) {
136
-        if ( ! headers_sent() ) {
137
-            setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) );
138
-        } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
139
-            headers_sent( $file, $line );
140
-            trigger_error( "{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE ); // @codingStandardsIgnoreLine
135
+	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false) {
136
+        if (!headers_sent()) {
137
+            setcookie($name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters('wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure));
138
+        } elseif (defined('WP_DEBUG') && WP_DEBUG) {
139
+            headers_sent($file, $line);
140
+            trigger_error("{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE); // @codingStandardsIgnoreLine
141 141
         }
142 142
     }
143 143
 
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 	 * @return bool
149 149
 	 */
150 150
 	protected function use_secure_cookie() {
151
-        $is_https = false !== strstr( get_option( 'home' ), 'https:' );
152
-		return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
151
+        $is_https = false !== strstr(get_option('home'), 'https:');
152
+		return apply_filters('wpinv_session_use_secure_cookie', $is_https && is_ssl());
153 153
 	}
154 154
 
155 155
 	/**
@@ -158,15 +158,15 @@  discard block
 block discarded – undo
158 158
 	 * @return bool
159 159
 	 */
160 160
 	public function has_session() {
161
-		return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
161
+		return isset($_COOKIE[$this->_cookie]) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
162 162
 	}
163 163
 
164 164
 	/**
165 165
 	 * Set session expiration.
166 166
 	 */
167 167
 	public function set_session_expiration() {
168
-		$this->_session_expiring   = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
169
-		$this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
168
+		$this->_session_expiring   = time() + intval(apply_filters('wpinv_session_expiring', 60 * 60 * 47)); // 47 Hours.
169
+		$this->_session_expiration = time() + intval(apply_filters('wpinv_session_expiration', 60 * 60 * 48)); // 48 Hours.
170 170
 	}
171 171
 
172 172
 	/**
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	public function generate_customer_id() {
178 178
 		require_once ABSPATH . 'wp-includes/class-phpass.php';
179
-		$hasher      = new PasswordHash( 8, false );
180
-		return md5( $hasher->get_random_bytes( 32 ) );
179
+		$hasher = new PasswordHash(8, false);
180
+		return md5($hasher->get_random_bytes(32));
181 181
 	}
182 182
 
183 183
 	/**
@@ -188,27 +188,27 @@  discard block
 block discarded – undo
188 188
 	 * @return bool|array
189 189
 	 */
190 190
 	public function get_session_cookie() {
191
-		$cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
191
+		$cookie_value = isset($_COOKIE[$this->_cookie]) ? wp_unslash($_COOKIE[$this->_cookie]) : false; // @codingStandardsIgnoreLine.
192 192
 
193
-		if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
193
+		if (empty($cookie_value) || !is_string($cookie_value)) {
194 194
 			return false;
195 195
 		}
196 196
 
197
-		list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
197
+		list($customer_id, $session_expiration, $session_expiring, $cookie_hash) = explode('||', $cookie_value);
198 198
 
199
-		if ( empty( $customer_id ) ) {
199
+		if (empty($customer_id)) {
200 200
 			return false;
201 201
 		}
202 202
 
203 203
 		// Validate hash.
204 204
 		$to_hash = $customer_id . '|' . $session_expiration;
205
-		$hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
205
+		$hash    = hash_hmac('md5', $to_hash, wp_hash($to_hash));
206 206
 
207
-		if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
207
+		if (empty($cookie_hash) || !hash_equals($hash, $cookie_hash)) {
208 208
 			return false;
209 209
 		}
210 210
 
211
-		return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
211
+		return array($customer_id, $session_expiration, $session_expiring, $cookie_hash);
212 212
 	}
213 213
 
214 214
 	/**
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 	 * @return array
218 218
 	 */
219 219
 	public function get_session_data() {
220
-		return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
220
+		return $this->has_session() ? (array) $this->get_session($this->_customer_id) : array();
221 221
 	}
222 222
 
223
-	public function generate_key( $customer_id ) {
224
-        if ( ! $customer_id ) {
223
+	public function generate_key($customer_id) {
224
+        if (!$customer_id) {
225 225
             return;
226 226
         }
227 227
 
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
 	 */
234 234
 	public function save_data() {
235 235
 		// Dirty if something changed - prevents saving nothing new.
236
-		if ( $this->_dirty && $this->has_session() ) {
236
+		if ($this->_dirty && $this->has_session()) {
237 237
 
238
-            set_transient( $this->generate_key( $this->_customer_id ), $this->_data, $this->_session_expiration );
238
+            set_transient($this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration);
239 239
 
240 240
 			$this->_dirty = false;
241 241
 		}
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 * Destroy all session data.
246 246
 	 */
247 247
 	public function destroy_session() {
248
-		$this->delete_session( $this->_customer_id );
248
+		$this->delete_session($this->_customer_id);
249 249
 		$this->forget_session();
250 250
 	}
251 251
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 * Forget all session data without destroying it.
254 254
 	 */
255 255
 	public function forget_session() {
256
-		$this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
256
+		$this->setcookie($this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true);
257 257
 
258 258
 		wpinv_empty_cart();
259 259
 
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
 	 * @param int $uid User ID.
269 269
 	 * @return string
270 270
 	 */
271
-	public function nonce_user_logged_out( $uid ) {
271
+	public function nonce_user_logged_out($uid) {
272 272
 
273 273
 		// Check if one of our nonces.
274
-		if ( substr( $uid, 0, 5 ) === 'wpinv' || substr( $uid, 0, 7 ) === 'getpaid' ) {
274
+		if (substr($uid, 0, 5) === 'wpinv' || substr($uid, 0, 7) === 'getpaid') {
275 275
 			return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
276 276
 		}
277 277
 
@@ -285,20 +285,20 @@  discard block
 block discarded – undo
285 285
 	 * @param mixed  $default Default session value.
286 286
 	 * @return string|array
287 287
 	 */
288
-	public function get_session( $customer_id, $default = false ) {
288
+	public function get_session($customer_id, $default = false) {
289 289
 
290
-		if ( defined( 'WP_SETUP_CONFIG' ) ) {
290
+		if (defined('WP_SETUP_CONFIG')) {
291 291
 			return array();
292 292
 		}
293 293
 
294
-        $key = $this->generate_key( $customer_id );
295
-        $value = get_transient( $key );
294
+        $key = $this->generate_key($customer_id);
295
+        $value = get_transient($key);
296 296
 
297
-        if ( ! $value ) {
297
+        if (!$value) {
298 298
             $value = $default;
299 299
         }
300 300
 
301
-		return maybe_unserialize( $value );
301
+		return maybe_unserialize($value);
302 302
 	}
303 303
 
304 304
 	/**
@@ -306,11 +306,11 @@  discard block
 block discarded – undo
306 306
 	 *
307 307
 	 * @param int $customer_id Customer ID.
308 308
 	 */
309
-	public function delete_session( $customer_id ) {
309
+	public function delete_session($customer_id) {
310 310
 
311
-        $key = $this->generate_key( $customer_id );
311
+        $key = $this->generate_key($customer_id);
312 312
 
313
-		delete_transient( $key );
313
+		delete_transient($key);
314 314
 	}
315 315
 
316 316
 	/**
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
 	 * @param string $customer_id Customer ID.
320 320
 	 * @param int    $timestamp Timestamp to expire the cookie.
321 321
 	 */
322
-	public function update_session_timestamp( $customer_id, $timestamp ) {
322
+	public function update_session_timestamp($customer_id, $timestamp) {
323 323
 
324
-        set_transient( $this->generate_key( $customer_id ), maybe_serialize( $this->_data ), $timestamp );
324
+        set_transient($this->generate_key($customer_id), maybe_serialize($this->_data), $timestamp);
325 325
 
326 326
 	}
327 327
 }
Please login to merge, or discard this patch.
includes/admin/register-settings.php 2 patches
Indentation   +318 added lines, -318 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
  *
145 145
  */
146 146
 function wpinv_register_settings() {
147
-	do_action( 'getpaid_before_register_settings' );
147
+    do_action( 'getpaid_before_register_settings' );
148 148
 
149 149
     // Loop through all tabs.
150 150
     foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
                 $settings = $sections;
160 160
             }
161 161
 
162
-			do_action( "getpaid_register_{$tab}_{$section}" );
162
+            do_action( "getpaid_register_{$tab}_{$section}" );
163 163
 
164 164
             // Register the setting section.
165 165
             add_settings_section(
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     // Creates our settings in the options table.
181 181
     register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
182 182
 
183
-	do_action( 'getpaid_after_register_settings' );
183
+    do_action( 'getpaid_after_register_settings' );
184 184
 }
185 185
 add_action( 'admin_init', 'wpinv_register_settings' );
186 186
 
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
     $name       = isset( $option['name'] ) ? $option['name'] : '';
198 198
     $cb         = "wpinv_{$option['type']}_callback";
199 199
     $section    = "wpinv_settings_{$tab}_$section";
200
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
200
+    $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
201 201
 
202
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
203
-		$tip   = wpinv_clean( $option['desc'] );
204
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
205
-		unset( $option['desc'] );
206
-	}
202
+    if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
203
+        $tip   = wpinv_clean( $option['desc'] );
204
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
205
+        unset( $option['desc'] );
206
+    }
207 207
 
208 208
     // Loop through all tabs.
209 209
     add_settings_field(
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
             'faux'            => isset( $option['faux'] ) ? $option['faux'] : false,
231 231
             'onchange'        => isset( $option['onchange'] ) ? $option['onchange'] : '',
232 232
             'custom'          => isset( $option['custom'] ) ? $option['custom'] : '',
233
-			'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
234
-			'class'           => isset( $option['class'] ) ? $option['class'] : '',
235
-			'style'           => isset( $option['style'] ) ? $option['style'] : '',
233
+            'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
234
+            'class'           => isset( $option['class'] ) ? $option['class'] : '',
235
+            'style'           => isset( $option['style'] ) ? $option['style'] : '',
236 236
             'cols'            => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
237 237
             'rows'            => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
238 238
         )
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
  * @return array
247 247
  */
248 248
 function wpinv_get_registered_settings() {
249
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
249
+    return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
250 250
 }
251 251
 
252 252
 /**
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
  */
266 266
 function wpinv_settings_sanitize( $input = array() ) {
267 267
 
268
-	$wpinv_options = wpinv_get_options();
269
-	$raw_referrer  = wp_get_raw_referer();
268
+    $wpinv_options = wpinv_get_options();
269
+    $raw_referrer  = wp_get_raw_referer();
270 270
 
271 271
     if ( empty( $raw_referrer ) ) {
272
-		return array_merge( $wpinv_options, $input );
272
+        return array_merge( $wpinv_options, $input );
273 273
     }
274 274
 
275 275
     wp_parse_str( $raw_referrer, $referrer );
276 276
 
277
-	if ( in_array( 'gp-setup', $referrer ) ) {
278
-		return array_merge( $wpinv_options, $input );
279
-	}
277
+    if ( in_array( 'gp-setup', $referrer ) ) {
278
+        return array_merge( $wpinv_options, $input );
279
+    }
280 280
 
281 281
     $settings = wpinv_get_registered_settings();
282 282
     $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
         }
299 299
 
300 300
         // General filter
301
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
301
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
302 302
 
303
-		// Key specific filter.
304
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
303
+        // Key specific filter.
304
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
305 305
     }
306 306
 
307 307
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -344,14 +344,14 @@  discard block
 block discarded – undo
344 344
 
345 345
     foreach ( $new_rates as $rate ) {
346 346
 
347
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
348
-		$rate['name']    = sanitize_text_field( $rate['name'] );
349
-		$rate['state']   = sanitize_text_field( $rate['state'] );
350
-		$rate['country'] = sanitize_text_field( $rate['country'] );
351
-		$rate['global']  = empty( $rate['state'] );
352
-		$tax_rates[]     = $rate;
347
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
348
+        $rate['name']    = sanitize_text_field( $rate['name'] );
349
+        $rate['state']   = sanitize_text_field( $rate['state'] );
350
+        $rate['country'] = sanitize_text_field( $rate['country'] );
351
+        $rate['global']  = empty( $rate['state'] );
352
+        $tax_rates[]     = $rate;
353 353
 
354
-	}
354
+    }
355 355
 
356 356
     update_option( 'wpinv_tax_rates', $tax_rates );
357 357
 
@@ -364,21 +364,21 @@  discard block
 block discarded – undo
364 364
         return $input;
365 365
     }
366 366
 
367
-	if ( empty( $_POST['wpinv_tax_rules_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules' ) ) {
368
-		return $input;
369
-	}
367
+    if ( empty( $_POST['wpinv_tax_rules_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules' ) ) {
368
+        return $input;
369
+    }
370 370
 
371 371
     $new_rules = ! empty( $_POST['tax_rules'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rules'] ) ) : array();
372 372
     $tax_rules = array();
373 373
 
374 374
     foreach ( $new_rules as $rule ) {
375 375
 
376
-		$rule['key']      = sanitize_title_with_dashes( $rule['key'] );
377
-		$rule['label']    = sanitize_text_field( $rule['label'] );
378
-		$rule['tax_base'] = sanitize_text_field( $rule['tax_base'] );
379
-		$tax_rules[]      = $rule;
376
+        $rule['key']      = sanitize_title_with_dashes( $rule['key'] );
377
+        $rule['label']    = sanitize_text_field( $rule['label'] );
378
+        $rule['tax_base'] = sanitize_text_field( $rule['tax_base'] );
379
+        $tax_rules[]      = $rule;
380 380
 
381
-	}
381
+    }
382 382
 
383 383
     update_option( 'wpinv_tax_rules', $tax_rules );
384 384
 
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
     $tabs['general']  = __( 'General', 'invoicing' );
392 392
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
393 393
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
394
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
394
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
395 395
 
396
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
397
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
398
-	}
396
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
397
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
398
+    }
399 399
 
400 400
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
401 401
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -426,53 +426,53 @@  discard block
 block discarded – undo
426 426
         'general'      => apply_filters(
427 427
             'wpinv_settings_sections_general',
428 428
             array(
429
-				'main'             => __( 'General Settings', 'invoicing' ),
430
-				'page_section'     => __( 'Page Settings', 'invoicing' ),
431
-				'currency_section' => __( 'Currency Settings', 'invoicing' ),
432
-				'labels'           => __( 'Label Texts', 'invoicing' ),
429
+                'main'             => __( 'General Settings', 'invoicing' ),
430
+                'page_section'     => __( 'Page Settings', 'invoicing' ),
431
+                'currency_section' => __( 'Currency Settings', 'invoicing' ),
432
+                'labels'           => __( 'Label Texts', 'invoicing' ),
433 433
             )
434 434
         ),
435 435
         'gateways'     => apply_filters(
436 436
             'wpinv_settings_sections_gateways',
437 437
             array(
438
-				'main' => __( 'Gateway Settings', 'invoicing' ),
438
+                'main' => __( 'Gateway Settings', 'invoicing' ),
439 439
             )
440 440
         ),
441 441
         'taxes'        => apply_filters(
442 442
             'wpinv_settings_sections_taxes',
443 443
             array(
444
-				'main'  => __( 'Tax Settings', 'invoicing' ),
445
-				'rules' => __( 'Tax Rules', 'invoicing' ),
446
-				'rates' => __( 'Tax Rates', 'invoicing' ),
447
-				'vat'   => __( 'EU VAT Settings', 'invoicing' ),
444
+                'main'  => __( 'Tax Settings', 'invoicing' ),
445
+                'rules' => __( 'Tax Rules', 'invoicing' ),
446
+                'rates' => __( 'Tax Rates', 'invoicing' ),
447
+                'vat'   => __( 'EU VAT Settings', 'invoicing' ),
448 448
             )
449 449
         ),
450 450
         'emails'       => apply_filters(
451 451
             'wpinv_settings_sections_emails',
452 452
             array(
453
-				'main' => __( 'Email Settings', 'invoicing' ),
453
+                'main' => __( 'Email Settings', 'invoicing' ),
454 454
             )
455 455
         ),
456 456
 
457
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
457
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
458 458
 
459 459
         'privacy'      => apply_filters(
460 460
             'wpinv_settings_sections_privacy',
461 461
             array(
462
-				'main' => __( 'Privacy policy', 'invoicing' ),
462
+                'main' => __( 'Privacy policy', 'invoicing' ),
463 463
             )
464 464
         ),
465 465
         'misc'         => apply_filters(
466 466
             'wpinv_settings_sections_misc',
467 467
             array(
468
-				'main'       => __( 'Miscellaneous', 'invoicing' ),
469
-				'custom-css' => __( 'Custom CSS', 'invoicing' ),
468
+                'main'       => __( 'Miscellaneous', 'invoicing' ),
469
+                'custom-css' => __( 'Custom CSS', 'invoicing' ),
470 470
             )
471 471
         ),
472 472
         'tools'        => apply_filters(
473 473
             'wpinv_settings_sections_tools',
474 474
             array(
475
-				'main' => __( 'Diagnostic Tools', 'invoicing' ),
475
+                'main' => __( 'Diagnostic Tools', 'invoicing' ),
476 476
             )
477 477
         ),
478 478
     );
@@ -483,46 +483,46 @@  discard block
 block discarded – undo
483 483
 }
484 484
 
485 485
 function wpinv_get_pages( $with_slug = false, $default_label = null ) {
486
-	$pages_options = array();
486
+    $pages_options = array();
487 487
 
488
-	if ( $default_label !== null && $default_label !== false ) {
489
-		$pages_options = array( '' => $default_label ); // Blank option
490
-	}
488
+    if ( $default_label !== null && $default_label !== false ) {
489
+        $pages_options = array( '' => $default_label ); // Blank option
490
+    }
491 491
 
492
-	$pages = get_pages();
493
-	if ( $pages ) {
494
-		foreach ( $pages as $page ) {
495
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
492
+    $pages = get_pages();
493
+    if ( $pages ) {
494
+        foreach ( $pages as $page ) {
495
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
496 496
             $pages_options[ $page->ID ] = $title;
497
-		}
498
-	}
497
+        }
498
+    }
499 499
 
500
-	return $pages_options;
500
+    return $pages_options;
501 501
 }
502 502
 
503 503
 function wpinv_header_callback( $args ) {
504
-	if ( ! empty( $args['desc'] ) ) {
504
+    if ( ! empty( $args['desc'] ) ) {
505 505
         echo wp_kses_post( $args['desc'] );
506 506
     }
507 507
 }
508 508
 
509 509
 function wpinv_hidden_callback( $args ) {
510 510
 
511
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
512
-	$value   = wpinv_get_option( $args['id'], $std );
511
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
512
+    $value   = wpinv_get_option( $args['id'], $std );
513 513
 
514
-	if ( isset( $args['set_value'] ) ) {
515
-		$value = $args['set_value'];
516
-	}
514
+    if ( isset( $args['set_value'] ) ) {
515
+        $value = $args['set_value'];
516
+    }
517 517
 
518
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
519
-		$args['readonly'] = true;
520
-		$name  = '';
521
-	} else {
522
-		$name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
523
-	}
518
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
519
+        $args['readonly'] = true;
520
+        $name  = '';
521
+    } else {
522
+        $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
523
+    }
524 524
 
525
-	echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
525
+    echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
526 526
 
527 527
 }
528 528
 
@@ -531,12 +531,12 @@  discard block
 block discarded – undo
531 531
  */
532 532
 function wpinv_checkbox_callback( $args ) {
533 533
 
534
-	$std = isset( $args['std'] ) ? $args['std'] : '';
535
-	$std = wpinv_get_option( $args['id'], $std );
536
-	$id  = esc_attr( $args['id'] );
534
+    $std = isset( $args['std'] ) ? $args['std'] : '';
535
+    $std = wpinv_get_option( $args['id'], $std );
536
+    $id  = esc_attr( $args['id'] );
537 537
 
538
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
539
-	?>
538
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
539
+    ?>
540 540
 		<fieldset>
541 541
 			<label>
542 542
 				<input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox" />
@@ -548,75 +548,75 @@  discard block
 block discarded – undo
548 548
 
549 549
 function wpinv_multicheck_callback( $args ) {
550 550
 
551
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
552
-	$class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
551
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
552
+    $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
553 553
 
554
-	if ( ! empty( $args['options'] ) ) {
554
+    if ( ! empty( $args['options'] ) ) {
555 555
 
556
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
557
-		$value   = wpinv_get_option( $args['id'], $std );
556
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
557
+        $value   = wpinv_get_option( $args['id'], $std );
558 558
 
559
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
559
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
560 560
         foreach ( $args['options'] as $key => $option ) :
561
-			$sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
562
-			if ( in_array( $sanitize_key, $value ) ) {
563
-				$enabled = $sanitize_key;
564
-			} else {
565
-				$enabled = null;
566
-			}
567
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
568
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
569
-		endforeach;
570
-		echo '</div>';
571
-		echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
572
-	}
561
+            $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
562
+            if ( in_array( $sanitize_key, $value ) ) {
563
+                $enabled = $sanitize_key;
564
+            } else {
565
+                $enabled = null;
566
+            }
567
+            echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
568
+            echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
569
+        endforeach;
570
+        echo '</div>';
571
+        echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
572
+    }
573 573
 }
574 574
 
575 575
 function wpinv_payment_icons_callback( $args ) {
576 576
 
577 577
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
578
-	$value   = wpinv_get_option( $args['id'], false );
578
+    $value   = wpinv_get_option( $args['id'], false );
579 579
 
580
-	if ( ! empty( $args['options'] ) ) {
581
-		foreach ( $args['options'] as $key => $option ) {
580
+    if ( ! empty( $args['options'] ) ) {
581
+        foreach ( $args['options'] as $key => $option ) {
582 582
             $sanitize_key = wpinv_sanitize_key( $key );
583 583
 
584
-			if ( empty( $value ) ) {
585
-				$enabled = $option;
586
-			} else {
587
-				$enabled = null;
588
-			}
589
-
590
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
591
-
592
-				echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
593
-
594
-				if ( wpinv_string_is_image_url( $key ) ) {
595
-				echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
596
-				} else {
597
-				$card = strtolower( str_replace( ' ', '', $option ) );
598
-
599
-				if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
600
-					$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
601
-					} else {
602
-					$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
603
-					$content_dir = WP_CONTENT_DIR;
604
-
605
-					if ( function_exists( 'wp_normalize_path' ) ) {
606
-						// Replaces backslashes with forward slashes for Windows systems
607
-						$image = wp_normalize_path( $image );
608
-						$content_dir = wp_normalize_path( $content_dir );
609
-						}
610
-
611
-					$image = str_replace( $content_dir, content_url(), $image );
612
-					}
613
-
614
-				echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
615
-				}
616
-			echo wp_kses_post( $option ) . '</label>';
617
-		}
618
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
619
-	}
584
+            if ( empty( $value ) ) {
585
+                $enabled = $option;
586
+            } else {
587
+                $enabled = null;
588
+            }
589
+
590
+            echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
591
+
592
+                echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
593
+
594
+                if ( wpinv_string_is_image_url( $key ) ) {
595
+                echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
596
+                } else {
597
+                $card = strtolower( str_replace( ' ', '', $option ) );
598
+
599
+                if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
600
+                    $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
601
+                    } else {
602
+                    $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
603
+                    $content_dir = WP_CONTENT_DIR;
604
+
605
+                    if ( function_exists( 'wp_normalize_path' ) ) {
606
+                        // Replaces backslashes with forward slashes for Windows systems
607
+                        $image = wp_normalize_path( $image );
608
+                        $content_dir = wp_normalize_path( $content_dir );
609
+                        }
610
+
611
+                    $image = str_replace( $content_dir, content_url(), $image );
612
+                    }
613
+
614
+                echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
615
+                }
616
+            echo wp_kses_post( $option ) . '</label>';
617
+        }
618
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
619
+    }
620 620
 }
621 621
 
622 622
 /**
@@ -624,9 +624,9 @@  discard block
 block discarded – undo
624 624
  */
625 625
 function wpinv_radio_callback( $args ) {
626 626
 
627
-	$std = isset( $args['std'] ) ? $args['std'] : '';
628
-	$std = wpinv_get_option( $args['id'], $std );
629
-	?>
627
+    $std = isset( $args['std'] ) ? $args['std'] : '';
628
+    $std = wpinv_get_option( $args['id'], $std );
629
+    ?>
630 630
 		<fieldset>
631 631
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
632 632
 				<?php foreach ( $args['options'] as $key => $option ) : ?>
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 			</ul>
641 641
 		</fieldset>
642 642
 	<?php
643
-	getpaid_settings_description_callback( $args );
643
+    getpaid_settings_description_callback( $args );
644 644
 }
645 645
 
646 646
 /**
@@ -648,10 +648,10 @@  discard block
 block discarded – undo
648 648
  */
649 649
 function getpaid_settings_description_callback( $args ) {
650 650
 
651
-	if ( ! empty( $args['desc'] ) ) {
652
-		$description = $args['desc'];
653
-		echo wp_kses_post( "<p class='description'>$description</p>" );
654
-	}
651
+    if ( ! empty( $args['desc'] ) ) {
652
+        $description = $args['desc'];
653
+        echo wp_kses_post( "<p class='description'>$description</p>" );
654
+    }
655 655
 
656 656
 }
657 657
 
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
  */
661 661
 function wpinv_gateways_callback() {
662 662
 
663
-	?>
663
+    ?>
664 664
 		</td>
665 665
 	</tr>
666 666
 	<tr class="bsui">
@@ -674,26 +674,26 @@  discard block
 block discarded – undo
674 674
 
675 675
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
676 676
     $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
677
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
678
-	$value   = wpinv_get_option( $args['id'], $std );
677
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
678
+    $value   = wpinv_get_option( $args['id'], $std );
679 679
 
680
-	echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
680
+    echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
681 681
 
682
-	foreach ( $args['options'] as $key => $option ) :
682
+    foreach ( $args['options'] as $key => $option ) :
683 683
 
684
-		echo '<option value="' . esc_attr( $key ) . '" ';
684
+        echo '<option value="' . esc_attr( $key ) . '" ';
685 685
 
686
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
686
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
687 687
             selected( $key, $args['selected'] );
688 688
         } else {
689 689
             selected( $key, $value );
690 690
         }
691 691
 
692
-		echo '>' . esc_html( $option['admin_label'] ) . '</option>';
693
-	endforeach;
692
+        echo '>' . esc_html( $option['admin_label'] ) . '</option>';
693
+    endforeach;
694 694
 
695
-	echo '</select>';
696
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
695
+    echo '</select>';
696
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
697 697
 }
698 698
 
699 699
 /**
@@ -704,38 +704,38 @@  discard block
 block discarded – undo
704 704
  */
705 705
 function wpinv_settings_attrs_helper( $args ) {
706 706
 
707
-	$value = isset( $args['std'] ) ? $args['std'] : '';
708
-	$id    = esc_attr( $args['id'] );
709
-	$value = is_scalar( $value ) ? $value : '';
710
-
711
-	$attrs = array(
712
-		'name'     => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]",
713
-		'readonly' => ! empty( $args['faux'] ),
714
-		'value'    => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ),
715
-		'id'       => 'wpinv-settings-' . $args['id'],
716
-		'style'    => $args['style'],
717
-		'class'    => $args['class'],
718
-		'placeholder' => $args['placeholder'],
719
-		'data-placeholder' => $args['placeholder'],
720
-	);
707
+    $value = isset( $args['std'] ) ? $args['std'] : '';
708
+    $id    = esc_attr( $args['id'] );
709
+    $value = is_scalar( $value ) ? $value : '';
710
+
711
+    $attrs = array(
712
+        'name'     => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]",
713
+        'readonly' => ! empty( $args['faux'] ),
714
+        'value'    => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ),
715
+        'id'       => 'wpinv-settings-' . $args['id'],
716
+        'style'    => $args['style'],
717
+        'class'    => $args['class'],
718
+        'placeholder' => $args['placeholder'],
719
+        'data-placeholder' => $args['placeholder'],
720
+    );
721 721
 
722
-	if ( ! empty( $args['onchange'] ) ) {
723
-		$attrs['onchange'] = $args['onchange'];
724
-	}
722
+    if ( ! empty( $args['onchange'] ) ) {
723
+        $attrs['onchange'] = $args['onchange'];
724
+    }
725 725
 
726
-	foreach ( $attrs as $key => $value ) {
726
+    foreach ( $attrs as $key => $value ) {
727 727
 
728
-		if ( false === $value ) {
729
-			continue;
730
-		}
728
+        if ( false === $value ) {
729
+            continue;
730
+        }
731 731
 
732
-		if ( true === $value ) {
733
-			echo ' ' . esc_attr( $key );
734
-		} else {
735
-			echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
736
-		}
732
+        if ( true === $value ) {
733
+            echo ' ' . esc_attr( $key );
734
+        } else {
735
+            echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
736
+        }
737 737
 
738
-	}
738
+    }
739 739
 
740 740
 }
741 741
 
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
  */
745 745
 function wpinv_text_callback( $args ) {
746 746
 
747
-	?>
747
+    ?>
748 748
 		<label style="width: 100%;">
749 749
 			<input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>>
750 750
 			<?php getpaid_settings_description_callback( $args ); ?>
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
  */
759 759
 function wpinv_number_callback( $args ) {
760 760
 
761
-	?>
761
+    ?>
762 762
 		<label style="width: 100%;">
763 763
 			<input type="number" step="<?php echo esc_attr( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>>
764 764
 			<?php getpaid_settings_description_callback( $args ); ?>
@@ -770,34 +770,34 @@  discard block
 block discarded – undo
770 770
 function wpinv_textarea_callback( $args ) {
771 771
 
772 772
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
773
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
774
-	$value   = wpinv_get_option( $args['id'], $std );
773
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
774
+    $value   = wpinv_get_option( $args['id'], $std );
775 775
 
776 776
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
777 777
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
778 778
 
779
-	echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
780
-	echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
779
+    echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
780
+    echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
781 781
 
782 782
 }
783 783
 
784 784
 function wpinv_password_callback( $args ) {
785 785
 
786 786
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
787
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
788
-	$value   = wpinv_get_option( $args['id'], $std );
787
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
788
+    $value   = wpinv_get_option( $args['id'], $std );
789 789
 
790
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
791
-	echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
792
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
790
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
791
+    echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
792
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
793 793
 
794 794
 }
795 795
 
796 796
 function wpinv_missing_callback( $args ) {
797
-	printf(
798
-		esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
799
-		'<strong>' . esc_html( $args['id'] ) . '</strong>'
800
-	);
797
+    printf(
798
+        esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
799
+        '<strong>' . esc_html( $args['id'] ) . '</strong>'
800
+    );
801 801
 }
802 802
 
803 803
 /**
@@ -805,13 +805,13 @@  discard block
 block discarded – undo
805 805
  */
806 806
 function wpinv_select_callback( $args ) {
807 807
 
808
-	$desc   = wp_kses_post( $args['desc'] );
809
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
810
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
811
-	$value  = wpinv_get_option( $args['id'], $value );
812
-	$rand   = uniqid( 'random_id' );
808
+    $desc   = wp_kses_post( $args['desc'] );
809
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
810
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
811
+    $value  = wpinv_get_option( $args['id'], $value );
812
+    $rand   = uniqid( 'random_id' );
813 813
 
814
-	?>
814
+    ?>
815 815
 		<label style="width: 100%;">
816 816
 			<select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true">
817 817
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -844,50 +844,50 @@  discard block
 block discarded – undo
844 844
 function wpinv_color_select_callback( $args ) {
845 845
 
846 846
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
847
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
848
-	$value   = wpinv_get_option( $args['id'], $std );
847
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
848
+    $value   = wpinv_get_option( $args['id'], $std );
849 849
 
850
-	echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
850
+    echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
851 851
 
852
-	foreach ( $args['options'] as $option => $color ) {
853
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
854
-	}
852
+    foreach ( $args['options'] as $option => $color ) {
853
+        echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
854
+    }
855 855
 
856
-	echo '</select>';
857
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
856
+    echo '</select>';
857
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
858 858
 
859 859
 }
860 860
 
861 861
 function wpinv_rich_editor_callback( $args ) {
862
-	global $wp_version;
862
+    global $wp_version;
863 863
 
864 864
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
865 865
 
866
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
867
-	$value   = wpinv_get_option( $args['id'], $std );
866
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
867
+    $value   = wpinv_get_option( $args['id'], $std );
868 868
 
869
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
870
-		$value = $std;
871
-	}
869
+    if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
870
+        $value = $std;
871
+    }
872 872
 
873
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
873
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
874 874
 
875
-	echo '<div class="getpaid-settings-editor-input">';
876
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
877
-		wp_editor(
875
+    echo '<div class="getpaid-settings-editor-input">';
876
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
877
+        wp_editor(
878 878
             stripslashes( $value ),
879 879
             'wpinv_settings_' . esc_attr( $args['id'] ),
880 880
             array(
881
-				'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
882
-				'textarea_rows' => absint( $rows ),
883
-				'media_buttons' => false,
881
+                'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
882
+                'textarea_rows' => absint( $rows ),
883
+                'media_buttons' => false,
884 884
             )
885 885
         );
886
-	} else {
887
-		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
888
-	}
886
+    } else {
887
+        echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
888
+    }
889 889
 
890
-	echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
890
+    echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
891 891
 
892 892
 }
893 893
 
@@ -895,51 +895,51 @@  discard block
 block discarded – undo
895 895
 
896 896
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
897 897
 
898
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
899
-	$value   = wpinv_get_option( $args['id'], $std );
898
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
899
+    $value   = wpinv_get_option( $args['id'], $std );
900 900
 
901
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
902
-	echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
903
-	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>';
904
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
901
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
902
+    echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
903
+    echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>';
904
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
905 905
 
906 906
 }
907 907
 
908 908
 function wpinv_color_callback( $args ) {
909 909
 
910
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
911
-	$value       = wpinv_get_option( $args['id'], $std );
910
+    $std         = isset( $args['std'] ) ? $args['std'] : '';
911
+    $value       = wpinv_get_option( $args['id'], $std );
912 912
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
913 913
 
914
-	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
915
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
914
+    echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
915
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
916 916
 
917 917
 }
918 918
 
919 919
 function wpinv_country_states_callback( $args ) {
920 920
 
921
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
922
-	$value   = wpinv_get_option( $args['id'], $std );
921
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
922
+    $value   = wpinv_get_option( $args['id'], $std );
923 923
 
924 924
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
925 925
 
926
-	if ( isset( $args['placeholder'] ) ) {
927
-		$placeholder = $args['placeholder'];
928
-	} else {
929
-		$placeholder = '';
930
-	}
926
+    if ( isset( $args['placeholder'] ) ) {
927
+        $placeholder = $args['placeholder'];
928
+    } else {
929
+        $placeholder = '';
930
+    }
931 931
 
932
-	$states = wpinv_get_country_states();
932
+    $states = wpinv_get_country_states();
933 933
 
934
-	$class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2';
935
-	echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>';
934
+    $class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2';
935
+    echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>';
936 936
 
937
-	foreach ( $states as $option => $name ) {
938
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
939
-	}
937
+    foreach ( $states as $option => $name ) {
938
+        echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
939
+    }
940 940
 
941
-	echo '</select>';
942
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
941
+    echo '</select>';
942
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
943 943
 
944 944
 }
945 945
 
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
  */
949 949
 function wpinv_tax_rates_callback() {
950 950
 
951
-	?>
951
+    ?>
952 952
 		</td>
953 953
 	</tr>
954 954
 	<tr class="bsui">
@@ -964,9 +964,9 @@  discard block
 block discarded – undo
964 964
  */
965 965
 function wpinv_tax_rate_callback( $tax_rate, $key ) {
966 966
 
967
-	$key                      = sanitize_key( $key );
968
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
969
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
967
+    $key                      = sanitize_key( $key );
968
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
969
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
970 970
 
971 971
 }
972 972
 
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
  */
976 976
 function wpinv_tax_rules_callback() {
977 977
 
978
-	?>
978
+    ?>
979 979
 		</td>
980 980
 	</tr>
981 981
 	<tr class="bsui">
@@ -1013,14 +1013,14 @@  discard block
 block discarded – undo
1013 1013
                 <td>
1014 1014
 					<a href="
1015 1015
                     <?php
1016
-						echo esc_url(
1017
-							wp_nonce_url(
1018
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
1019
-								'getpaid-nonce',
1020
-								'getpaid-nonce'
1021
-							)
1022
-						);
1023
-					?>
1016
+                        echo esc_url(
1017
+                            wp_nonce_url(
1018
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
1019
+                                'getpaid-nonce',
1020
+                                'getpaid-nonce'
1021
+                            )
1022
+                        );
1023
+                    ?>
1024 1024
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1025 1025
                 </td>
1026 1026
             </tr>
@@ -1032,14 +1032,14 @@  discard block
 block discarded – undo
1032 1032
                 <td>
1033 1033
 					<a href="
1034 1034
                     <?php
1035
-						echo esc_url(
1036
-							wp_nonce_url(
1037
-								add_query_arg( 'getpaid-admin-action', 'refresh_permalinks' ),
1038
-								'getpaid-nonce',
1039
-								'getpaid-nonce'
1040
-							)
1041
-						);
1042
-					?>
1035
+                        echo esc_url(
1036
+                            wp_nonce_url(
1037
+                                add_query_arg( 'getpaid-admin-action', 'refresh_permalinks' ),
1038
+                                'getpaid-nonce',
1039
+                                'getpaid-nonce'
1040
+                            )
1041
+                        );
1042
+                    ?>
1043 1043
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1044 1044
                 </td>
1045 1045
             </tr>
@@ -1051,14 +1051,14 @@  discard block
 block discarded – undo
1051 1051
                 <td>
1052 1052
 					<a href="
1053 1053
                     <?php
1054
-						echo esc_url(
1055
-							wp_nonce_url(
1056
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1057
-								'getpaid-nonce',
1058
-								'getpaid-nonce'
1059
-							)
1060
-						);
1061
-					?>
1054
+                        echo esc_url(
1055
+                            wp_nonce_url(
1056
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1057
+                                'getpaid-nonce',
1058
+                                'getpaid-nonce'
1059
+                            )
1060
+                        );
1061
+                    ?>
1062 1062
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1063 1063
                 </td>
1064 1064
             </tr>
@@ -1070,14 +1070,14 @@  discard block
 block discarded – undo
1070 1070
                 <td>
1071 1071
 					<a href="
1072 1072
                     <?php
1073
-						echo esc_url(
1074
-							wp_nonce_url(
1075
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1076
-								'getpaid-nonce',
1077
-								'getpaid-nonce'
1078
-							)
1079
-						);
1080
-					?>
1073
+                        echo esc_url(
1074
+                            wp_nonce_url(
1075
+                                add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1076
+                                'getpaid-nonce',
1077
+                                'getpaid-nonce'
1078
+                            )
1079
+                        );
1080
+                    ?>
1081 1081
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1082 1082
                 </td>
1083 1083
             </tr>
@@ -1090,14 +1090,14 @@  discard block
 block discarded – undo
1090 1090
                 <td>
1091 1091
 					<a href="
1092 1092
                     <?php
1093
-						echo esc_url(
1094
-							wp_nonce_url(
1095
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1096
-								'getpaid-nonce',
1097
-								'getpaid-nonce'
1098
-							)
1099
-						);
1100
-					?>
1093
+                        echo esc_url(
1094
+                            wp_nonce_url(
1095
+                                add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1096
+                                'getpaid-nonce',
1097
+                                'getpaid-nonce'
1098
+                            )
1099
+                        );
1100
+                    ?>
1101 1101
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1102 1102
                 </td>
1103 1103
             </tr>
@@ -1110,8 +1110,8 @@  discard block
 block discarded – undo
1110 1110
                 <td>
1111 1111
 					<a href="
1112 1112
                     <?php
1113
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1114
-					?>
1113
+                        echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1114
+                    ?>
1115 1115
                     " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a>
1116 1116
                 </td>
1117 1117
             </tr>
@@ -1125,19 +1125,19 @@  discard block
 block discarded – undo
1125 1125
 
1126 1126
 
1127 1127
 function wpinv_descriptive_text_callback( $args ) {
1128
-	echo wp_kses_post( $args['desc'] );
1128
+    echo wp_kses_post( $args['desc'] );
1129 1129
 }
1130 1130
 
1131 1131
 function wpinv_raw_html_callback( $args ) {
1132
-	echo wp_kses( $args['desc'], getpaid_allowed_html() );
1132
+    echo wp_kses( $args['desc'], getpaid_allowed_html() );
1133 1133
 }
1134 1134
 
1135 1135
 function wpinv_hook_callback( $args ) {
1136
-	do_action( 'wpinv_' . $args['id'], $args );
1136
+    do_action( 'wpinv_' . $args['id'], $args );
1137 1137
 }
1138 1138
 
1139 1139
 function wpinv_set_settings_cap() {
1140
-	return wpinv_get_capability();
1140
+    return wpinv_get_capability();
1141 1141
 }
1142 1142
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1143 1143
 
@@ -1161,15 +1161,15 @@  discard block
 block discarded – undo
1161 1161
  */
1162 1162
 function wpinv_get_merge_tags_help_text( $subscription = false ) {
1163 1163
 
1164
-	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1165
-	$link = sprintf(
1166
-		'<strong><a href="%s" target="_blank">%s</a></strong>',
1167
-		$url,
1168
-		esc_html__( 'View available merge tags.', 'invoicing' )
1169
-	);
1164
+    $url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1165
+    $link = sprintf(
1166
+        '<strong><a href="%s" target="_blank">%s</a></strong>',
1167
+        $url,
1168
+        esc_html__( 'View available merge tags.', 'invoicing' )
1169
+    );
1170 1170
 
1171
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1171
+    $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1172 1172
 
1173
-	return "$description $link";
1173
+    return "$description $link";
1174 1174
 
1175 1175
 }
Please login to merge, or discard this patch.
Spacing   +386 added lines, -386 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves all default settings.
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 function wpinv_get_settings() {
17 17
     $defaults = array();
18 18
 
19
-    foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) {
19
+    foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) {
20 20
 
21
-        foreach ( array_values( $tab_settings ) as $section_settings ) {
21
+        foreach (array_values($tab_settings) as $section_settings) {
22 22
 
23
-            foreach ( $section_settings as $key => $setting ) {
24
-                if ( isset( $setting['std'] ) ) {
25
-                    $defaults[ $key ] = $setting['std'];
23
+            foreach ($section_settings as $key => $setting) {
24
+                if (isset($setting['std'])) {
25
+                    $defaults[$key] = $setting['std'];
26 26
                 }
27 27
             }
28 28
 }
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
     global $wpinv_options;
42 42
 
43 43
     // Try fetching the saved options.
44
-    if ( empty( $wpinv_options ) ) {
45
-        $wpinv_options = get_option( 'wpinv_settings' );
44
+    if (empty($wpinv_options)) {
45
+        $wpinv_options = get_option('wpinv_settings');
46 46
     }
47 47
 
48 48
     // If that fails, don't fetch the default settings to prevent a loop.
49
-    if ( ! is_array( $wpinv_options ) ) {
49
+    if (!is_array($wpinv_options)) {
50 50
         $wpinv_options = array();
51 51
     }
52 52
 
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
  * @param mixed $default The default value to use if the setting has not been set.
61 61
  * @return mixed
62 62
  */
63
-function wpinv_get_option( $key = '', $default = false ) {
63
+function wpinv_get_option($key = '', $default = false) {
64 64
 
65 65
     $options = wpinv_get_options();
66
-    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
67
-    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
66
+    $value   = isset($options[$key]) ? $options[$key] : $default;
67
+    $value   = apply_filters('wpinv_get_option', $value, $key, $default);
68 68
 
69
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
69
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
70 70
 }
71 71
 
72 72
 /**
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
  * @param array $options the new options.
76 76
  * @return bool
77 77
  */
78
-function wpinv_update_options( $options ) {
78
+function wpinv_update_options($options) {
79 79
     global $wpinv_options;
80 80
 
81 81
     // update the option.
82
-    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
82
+    if (is_array($options) && update_option('wpinv_settings', $options)) {
83 83
         $wpinv_options = $options;
84 84
         return true;
85 85
     }
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
  * @param mixed $value The setting value.
95 95
  * @return bool
96 96
  */
97
-function wpinv_update_option( $key = '', $value = false ) {
97
+function wpinv_update_option($key = '', $value = false) {
98 98
 
99 99
     // If no key, exit.
100
-    if ( empty( $key ) ) {
100
+    if (empty($key)) {
101 101
         return false;
102 102
     }
103 103
 
104 104
     // Maybe delete the option instead.
105
-    if ( is_null( $value ) ) {
106
-        return wpinv_delete_option( $key );
105
+    if (is_null($value)) {
106
+        return wpinv_delete_option($key);
107 107
     }
108 108
 
109 109
     // Prepare the new options.
110 110
     $options         = wpinv_get_options();
111
-    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
111
+    $options[$key] = apply_filters('wpinv_update_option', $value, $key);
112 112
 
113 113
     // Save the new options.
114
-    return wpinv_update_options( $options );
114
+    return wpinv_update_options($options);
115 115
 
116 116
 }
117 117
 
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
  * @param string $key the setting key.
122 122
  * @return bool
123 123
  */
124
-function wpinv_delete_option( $key = '' ) {
124
+function wpinv_delete_option($key = '') {
125 125
 
126 126
     // If no key, exit
127
-    if ( empty( $key ) ) {
127
+    if (empty($key)) {
128 128
         return false;
129 129
     }
130 130
 
131 131
     $options = wpinv_get_options();
132 132
 
133
-    if ( isset( $options[ $key ] ) ) {
134
-        unset( $options[ $key ] );
135
-        return wpinv_update_options( $options );
133
+    if (isset($options[$key])) {
134
+        unset($options[$key]);
135
+        return wpinv_update_options($options);
136 136
     }
137 137
 
138 138
     return true;
@@ -144,22 +144,22 @@  discard block
 block discarded – undo
144 144
  *
145 145
  */
146 146
 function wpinv_register_settings() {
147
-	do_action( 'getpaid_before_register_settings' );
147
+	do_action('getpaid_before_register_settings');
148 148
 
149 149
     // Loop through all tabs.
150
-    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
150
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
151 151
 
152 152
         // In each tab, loop through sections.
153
-        foreach ( $sections as $section => $settings ) {
153
+        foreach ($sections as $section => $settings) {
154 154
 
155 155
             // Check for backwards compatibility
156
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
157
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
156
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
157
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
158 158
                 $section = 'main';
159 159
                 $settings = $sections;
160 160
             }
161 161
 
162
-			do_action( "getpaid_register_{$tab}_{$section}" );
162
+			do_action("getpaid_register_{$tab}_{$section}");
163 163
 
164 164
             // Register the setting section.
165 165
             add_settings_section(
@@ -169,20 +169,20 @@  discard block
 block discarded – undo
169 169
                 'wpinv_settings_' . $tab . '_' . $section
170 170
             );
171 171
 
172
-            foreach ( $settings as $option ) {
173
-                if ( ! empty( $option['id'] ) ) {
174
-                    wpinv_register_settings_option( $tab, $section, $option );
172
+            foreach ($settings as $option) {
173
+                if (!empty($option['id'])) {
174
+                    wpinv_register_settings_option($tab, $section, $option);
175 175
                 }
176 176
             }
177 177
 }
178 178
     }
179 179
 
180 180
     // Creates our settings in the options table.
181
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
181
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
182 182
 
183
-	do_action( 'getpaid_after_register_settings' );
183
+	do_action('getpaid_after_register_settings');
184 184
 }
185
-add_action( 'admin_init', 'wpinv_register_settings' );
185
+add_action('admin_init', 'wpinv_register_settings');
186 186
 
187 187
 /**
188 188
  * Register a single settings option.
@@ -192,49 +192,49 @@  discard block
 block discarded – undo
192 192
  * @param string $option
193 193
  *
194 194
  */
195
-function wpinv_register_settings_option( $tab, $section, $option ) {
195
+function wpinv_register_settings_option($tab, $section, $option) {
196 196
 
197
-    $name       = isset( $option['name'] ) ? $option['name'] : '';
197
+    $name       = isset($option['name']) ? $option['name'] : '';
198 198
     $cb         = "wpinv_{$option['type']}_callback";
199 199
     $section    = "wpinv_settings_{$tab}_$section";
200
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
200
+	$is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page'];
201 201
 
202
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
203
-		$tip   = wpinv_clean( $option['desc'] );
202
+	if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) {
203
+		$tip   = wpinv_clean($option['desc']);
204 204
 		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
205
-		unset( $option['desc'] );
205
+		unset($option['desc']);
206 206
 	}
207 207
 
208 208
     // Loop through all tabs.
209 209
     add_settings_field(
210 210
         'wpinv_settings[' . $option['id'] . ']',
211 211
         $name,
212
-        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
212
+        function_exists($cb) ? $cb : 'wpinv_missing_callback',
213 213
         $section,
214 214
         $section,
215 215
         array(
216 216
             'section'         => $section,
217
-            'id'              => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ),
218
-            'desc'            => isset( $option['desc'] ) ? $option['desc'] : '',
217
+            'id'              => isset($option['id']) ? $option['id'] : uniqid('wpinv-'),
218
+            'desc'            => isset($option['desc']) ? $option['desc'] : '',
219 219
             'name'            => $name,
220
-            'size'            => isset( $option['size'] ) ? $option['size'] : null,
221
-            'options'         => isset( $option['options'] ) ? $option['options'] : '',
222
-            'selected'        => isset( $option['selected'] ) ? $option['selected'] : null,
223
-            'std'             => isset( $option['std'] ) ? $option['std'] : '',
224
-            'min'             => isset( $option['min'] ) ? $option['min'] : 0,
225
-            'max'             => isset( $option['max'] ) ? $option['max'] : 999999,
226
-            'step'            => isset( $option['step'] ) ? $option['step'] : 1,
227
-            'placeholder'     => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
228
-            'allow_blank'     => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
229
-            'readonly'        => isset( $option['readonly'] ) ? $option['readonly'] : false,
230
-            'faux'            => isset( $option['faux'] ) ? $option['faux'] : false,
231
-            'onchange'        => isset( $option['onchange'] ) ? $option['onchange'] : '',
232
-            'custom'          => isset( $option['custom'] ) ? $option['custom'] : '',
233
-			'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
234
-			'class'           => isset( $option['class'] ) ? $option['class'] : '',
235
-			'style'           => isset( $option['style'] ) ? $option['style'] : '',
236
-            'cols'            => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
237
-            'rows'            => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
220
+            'size'            => isset($option['size']) ? $option['size'] : null,
221
+            'options'         => isset($option['options']) ? $option['options'] : '',
222
+            'selected'        => isset($option['selected']) ? $option['selected'] : null,
223
+            'std'             => isset($option['std']) ? $option['std'] : '',
224
+            'min'             => isset($option['min']) ? $option['min'] : 0,
225
+            'max'             => isset($option['max']) ? $option['max'] : 999999,
226
+            'step'            => isset($option['step']) ? $option['step'] : 1,
227
+            'placeholder'     => isset($option['placeholder']) ? $option['placeholder'] : null,
228
+            'allow_blank'     => isset($option['allow_blank']) ? $option['allow_blank'] : true,
229
+            'readonly'        => isset($option['readonly']) ? $option['readonly'] : false,
230
+            'faux'            => isset($option['faux']) ? $option['faux'] : false,
231
+            'onchange'        => isset($option['onchange']) ? $option['onchange'] : '',
232
+            'custom'          => isset($option['custom']) ? $option['custom'] : '',
233
+			'default_content' => isset($option['default_content']) ? $option['default_content'] : '',
234
+			'class'           => isset($option['class']) ? $option['class'] : '',
235
+			'style'           => isset($option['style']) ? $option['style'] : '',
236
+            'cols'            => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
237
+            'rows'            => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
238 238
         )
239 239
     );
240 240
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
  * @return array
247 247
  */
248 248
 function wpinv_get_registered_settings() {
249
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
249
+	return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')));
250 250
 }
251 251
 
252 252
 /**
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
  * @return array
256 256
  */
257 257
 function getpaid_get_integration_settings() {
258
-    return apply_filters( 'getpaid_integration_settings', array() );
258
+    return apply_filters('getpaid_integration_settings', array());
259 259
 }
260 260
 
261 261
 /**
@@ -263,153 +263,153 @@  discard block
 block discarded – undo
263 263
  *
264 264
  * @return array
265 265
  */
266
-function wpinv_settings_sanitize( $input = array() ) {
266
+function wpinv_settings_sanitize($input = array()) {
267 267
 
268 268
 	$wpinv_options = wpinv_get_options();
269 269
 	$raw_referrer  = wp_get_raw_referer();
270 270
 
271
-    if ( empty( $raw_referrer ) ) {
272
-		return array_merge( $wpinv_options, $input );
271
+    if (empty($raw_referrer)) {
272
+		return array_merge($wpinv_options, $input);
273 273
     }
274 274
 
275
-    wp_parse_str( $raw_referrer, $referrer );
275
+    wp_parse_str($raw_referrer, $referrer);
276 276
 
277
-	if ( in_array( 'gp-setup', $referrer ) ) {
278
-		return array_merge( $wpinv_options, $input );
277
+	if (in_array('gp-setup', $referrer)) {
278
+		return array_merge($wpinv_options, $input);
279 279
 	}
280 280
 
281 281
     $settings = wpinv_get_registered_settings();
282
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
283
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
282
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
283
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
284 284
 
285 285
     $input = $input ? $input : array();
286
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
287
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
286
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
287
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
288 288
 
289 289
     // Loop through each setting being saved and pass it through a sanitization filter
290
-    foreach ( $input as $key => $value ) {
290
+    foreach ($input as $key => $value) {
291 291
 
292 292
         // Get the setting type (checkbox, select, etc)
293
-        $type = isset( $settings[ $tab ][ $section ][ $key ]['type'] ) ? $settings[ $tab ][ $section ][ $key ]['type'] : false;
293
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
294 294
 
295
-        if ( $type ) {
295
+        if ($type) {
296 296
             // Field type specific filter
297
-            $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key );
297
+            $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key);
298 298
         }
299 299
 
300 300
         // General filter
301
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
301
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
302 302
 
303 303
 		// Key specific filter.
304
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
304
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
305 305
     }
306 306
 
307 307
     // Loop through the whitelist and unset any that are empty for the tab being saved
308
-    $main_settings    = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
309
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
308
+    $main_settings    = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
309
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
310 310
 
311
-    $found_settings   = array_merge( $main_settings, $section_settings );
311
+    $found_settings   = array_merge($main_settings, $section_settings);
312 312
 
313
-    if ( ! empty( $found_settings ) ) {
314
-        foreach ( $found_settings as $key => $value ) {
313
+    if (!empty($found_settings)) {
314
+        foreach ($found_settings as $key => $value) {
315 315
 
316 316
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
317
-            if ( is_numeric( $key ) ) {
317
+            if (is_numeric($key)) {
318 318
                 $key = $value['id'];
319 319
             }
320 320
 
321
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
322
-                unset( $wpinv_options[ $key ] );
321
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
322
+                unset($wpinv_options[$key]);
323 323
             }
324 324
         }
325 325
     }
326 326
 
327 327
     // Merge our new settings with the existing
328
-    $output = array_merge( $wpinv_options, $input );
328
+    $output = array_merge($wpinv_options, $input);
329 329
 
330
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
330
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
331 331
 
332 332
     return $output;
333 333
 }
334
-add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 );
335
-add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' );
334
+add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1);
335
+add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount');
336 336
 
337
-function wpinv_settings_sanitize_tax_rates( $input ) {
338
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
337
+function wpinv_settings_sanitize_tax_rates($input) {
338
+    if (!wpinv_current_user_can_manage_invoicing()) {
339 339
         return $input;
340 340
     }
341 341
 
342
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array();
342
+    $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array();
343 343
     $tax_rates = array();
344 344
 
345
-    foreach ( $new_rates as $rate ) {
345
+    foreach ($new_rates as $rate) {
346 346
 
347
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
348
-		$rate['name']    = sanitize_text_field( $rate['name'] );
349
-		$rate['state']   = sanitize_text_field( $rate['state'] );
350
-		$rate['country'] = sanitize_text_field( $rate['country'] );
351
-		$rate['global']  = empty( $rate['state'] );
347
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
348
+		$rate['name']    = sanitize_text_field($rate['name']);
349
+		$rate['state']   = sanitize_text_field($rate['state']);
350
+		$rate['country'] = sanitize_text_field($rate['country']);
351
+		$rate['global']  = empty($rate['state']);
352 352
 		$tax_rates[]     = $rate;
353 353
 
354 354
 	}
355 355
 
356
-    update_option( 'wpinv_tax_rates', $tax_rates );
356
+    update_option('wpinv_tax_rates', $tax_rates);
357 357
 
358 358
     return $input;
359 359
 }
360
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
360
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
361 361
 
362
-function wpinv_settings_sanitize_tax_rules( $input ) {
363
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
362
+function wpinv_settings_sanitize_tax_rules($input) {
363
+    if (!wpinv_current_user_can_manage_invoicing()) {
364 364
         return $input;
365 365
     }
366 366
 
367
-	if ( empty( $_POST['wpinv_tax_rules_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules' ) ) {
367
+	if (empty($_POST['wpinv_tax_rules_nonce']) || !wp_verify_nonce($_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules')) {
368 368
 		return $input;
369 369
 	}
370 370
 
371
-    $new_rules = ! empty( $_POST['tax_rules'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rules'] ) ) : array();
371
+    $new_rules = !empty($_POST['tax_rules']) ? wp_kses_post_deep(array_values($_POST['tax_rules'])) : array();
372 372
     $tax_rules = array();
373 373
 
374
-    foreach ( $new_rules as $rule ) {
374
+    foreach ($new_rules as $rule) {
375 375
 
376
-		$rule['key']      = sanitize_title_with_dashes( $rule['key'] );
377
-		$rule['label']    = sanitize_text_field( $rule['label'] );
378
-		$rule['tax_base'] = sanitize_text_field( $rule['tax_base'] );
376
+		$rule['key']      = sanitize_title_with_dashes($rule['key']);
377
+		$rule['label']    = sanitize_text_field($rule['label']);
378
+		$rule['tax_base'] = sanitize_text_field($rule['tax_base']);
379 379
 		$tax_rules[]      = $rule;
380 380
 
381 381
 	}
382 382
 
383
-    update_option( 'wpinv_tax_rules', $tax_rules );
383
+    update_option('wpinv_tax_rules', $tax_rules);
384 384
 
385 385
     return $input;
386 386
 }
387
-add_filter( 'wpinv_settings_taxes-rules_sanitize', 'wpinv_settings_sanitize_tax_rules' );
387
+add_filter('wpinv_settings_taxes-rules_sanitize', 'wpinv_settings_sanitize_tax_rules');
388 388
 
389 389
 function wpinv_get_settings_tabs() {
390 390
     $tabs             = array();
391
-    $tabs['general']  = __( 'General', 'invoicing' );
392
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
393
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
394
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
391
+    $tabs['general']  = __('General', 'invoicing');
392
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
393
+    $tabs['taxes']    = __('Taxes', 'invoicing');
394
+	$tabs['emails'] = __('Emails', 'invoicing');
395 395
 
396
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
397
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
396
+	if (count(getpaid_get_integration_settings()) > 0) {
397
+		$tabs['integrations'] = __('Integrations', 'invoicing');
398 398
 	}
399 399
 
400
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
401
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
402
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
400
+    $tabs['privacy']  = __('Privacy', 'invoicing');
401
+    $tabs['misc']     = __('Misc', 'invoicing');
402
+    $tabs['tools']    = __('Tools', 'invoicing');
403 403
 
404
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
404
+    return apply_filters('wpinv_settings_tabs', $tabs);
405 405
 }
406 406
 
407
-function wpinv_get_settings_tab_sections( $tab = false ) {
407
+function wpinv_get_settings_tab_sections($tab = false) {
408 408
     $tabs     = false;
409 409
     $sections = wpinv_get_registered_settings_sections();
410 410
 
411
-    if ( $tab && ! empty( $sections[ $tab ] ) ) {
412
-        $tabs = $sections[ $tab ];
411
+    if ($tab && !empty($sections[$tab])) {
412
+        $tabs = $sections[$tab];
413 413
     }
414 414
 
415 415
     return $tabs;
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 function wpinv_get_registered_settings_sections() {
419 419
     static $sections = false;
420 420
 
421
-    if ( false !== $sections ) {
421
+    if (false !== $sections) {
422 422
         return $sections;
423 423
     }
424 424
 
@@ -426,231 +426,231 @@  discard block
 block discarded – undo
426 426
         'general'      => apply_filters(
427 427
             'wpinv_settings_sections_general',
428 428
             array(
429
-				'main'             => __( 'General Settings', 'invoicing' ),
430
-				'page_section'     => __( 'Page Settings', 'invoicing' ),
431
-				'currency_section' => __( 'Currency Settings', 'invoicing' ),
432
-				'labels'           => __( 'Label Texts', 'invoicing' ),
429
+				'main'             => __('General Settings', 'invoicing'),
430
+				'page_section'     => __('Page Settings', 'invoicing'),
431
+				'currency_section' => __('Currency Settings', 'invoicing'),
432
+				'labels'           => __('Label Texts', 'invoicing'),
433 433
             )
434 434
         ),
435 435
         'gateways'     => apply_filters(
436 436
             'wpinv_settings_sections_gateways',
437 437
             array(
438
-				'main' => __( 'Gateway Settings', 'invoicing' ),
438
+				'main' => __('Gateway Settings', 'invoicing'),
439 439
             )
440 440
         ),
441 441
         'taxes'        => apply_filters(
442 442
             'wpinv_settings_sections_taxes',
443 443
             array(
444
-				'main'  => __( 'Tax Settings', 'invoicing' ),
445
-				'rules' => __( 'Tax Rules', 'invoicing' ),
446
-				'rates' => __( 'Tax Rates', 'invoicing' ),
447
-				'vat'   => __( 'EU VAT Settings', 'invoicing' ),
444
+				'main'  => __('Tax Settings', 'invoicing'),
445
+				'rules' => __('Tax Rules', 'invoicing'),
446
+				'rates' => __('Tax Rates', 'invoicing'),
447
+				'vat'   => __('EU VAT Settings', 'invoicing'),
448 448
             )
449 449
         ),
450 450
         'emails'       => apply_filters(
451 451
             'wpinv_settings_sections_emails',
452 452
             array(
453
-				'main' => __( 'Email Settings', 'invoicing' ),
453
+				'main' => __('Email Settings', 'invoicing'),
454 454
             )
455 455
         ),
456 456
 
457
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
457
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
458 458
 
459 459
         'privacy'      => apply_filters(
460 460
             'wpinv_settings_sections_privacy',
461 461
             array(
462
-				'main' => __( 'Privacy policy', 'invoicing' ),
462
+				'main' => __('Privacy policy', 'invoicing'),
463 463
             )
464 464
         ),
465 465
         'misc'         => apply_filters(
466 466
             'wpinv_settings_sections_misc',
467 467
             array(
468
-				'main'       => __( 'Miscellaneous', 'invoicing' ),
469
-				'custom-css' => __( 'Custom CSS', 'invoicing' ),
468
+				'main'       => __('Miscellaneous', 'invoicing'),
469
+				'custom-css' => __('Custom CSS', 'invoicing'),
470 470
             )
471 471
         ),
472 472
         'tools'        => apply_filters(
473 473
             'wpinv_settings_sections_tools',
474 474
             array(
475
-				'main' => __( 'Diagnostic Tools', 'invoicing' ),
475
+				'main' => __('Diagnostic Tools', 'invoicing'),
476 476
             )
477 477
         ),
478 478
     );
479 479
 
480
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
480
+    $sections = apply_filters('wpinv_settings_sections', $sections);
481 481
 
482 482
     return $sections;
483 483
 }
484 484
 
485
-function wpinv_get_pages( $with_slug = false, $default_label = null ) {
485
+function wpinv_get_pages($with_slug = false, $default_label = null) {
486 486
 	$pages_options = array();
487 487
 
488
-	if ( $default_label !== null && $default_label !== false ) {
489
-		$pages_options = array( '' => $default_label ); // Blank option
488
+	if ($default_label !== null && $default_label !== false) {
489
+		$pages_options = array('' => $default_label); // Blank option
490 490
 	}
491 491
 
492 492
 	$pages = get_pages();
493
-	if ( $pages ) {
494
-		foreach ( $pages as $page ) {
493
+	if ($pages) {
494
+		foreach ($pages as $page) {
495 495
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
496
-            $pages_options[ $page->ID ] = $title;
496
+            $pages_options[$page->ID] = $title;
497 497
 		}
498 498
 	}
499 499
 
500 500
 	return $pages_options;
501 501
 }
502 502
 
503
-function wpinv_header_callback( $args ) {
504
-	if ( ! empty( $args['desc'] ) ) {
505
-        echo wp_kses_post( $args['desc'] );
503
+function wpinv_header_callback($args) {
504
+	if (!empty($args['desc'])) {
505
+        echo wp_kses_post($args['desc']);
506 506
     }
507 507
 }
508 508
 
509
-function wpinv_hidden_callback( $args ) {
509
+function wpinv_hidden_callback($args) {
510 510
 
511
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
512
-	$value   = wpinv_get_option( $args['id'], $std );
511
+	$std     = isset($args['std']) ? $args['std'] : '';
512
+	$value   = wpinv_get_option($args['id'], $std);
513 513
 
514
-	if ( isset( $args['set_value'] ) ) {
514
+	if (isset($args['set_value'])) {
515 515
 		$value = $args['set_value'];
516 516
 	}
517 517
 
518
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
518
+	if (isset($args['faux']) && true === $args['faux']) {
519 519
 		$args['readonly'] = true;
520
-		$name  = '';
520
+		$name = '';
521 521
 	} else {
522
-		$name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
522
+		$name = 'wpinv_settings[' . esc_attr($args['id']) . ']';
523 523
 	}
524 524
 
525
-	echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
525
+	echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" name="' . esc_attr($name) . '" value="' . esc_attr(stripslashes($value)) . '" />';
526 526
 
527 527
 }
528 528
 
529 529
 /**
530 530
  * Displays a checkbox settings callback.
531 531
  */
532
-function wpinv_checkbox_callback( $args ) {
532
+function wpinv_checkbox_callback($args) {
533 533
 
534
-	$std = isset( $args['std'] ) ? $args['std'] : '';
535
-	$std = wpinv_get_option( $args['id'], $std );
536
-	$id  = esc_attr( $args['id'] );
534
+	$std = isset($args['std']) ? $args['std'] : '';
535
+	$std = wpinv_get_option($args['id'], $std);
536
+	$id  = esc_attr($args['id']);
537 537
 
538
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
538
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
539 539
 	?>
540 540
 		<fieldset>
541 541
 			<label>
542
-				<input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox" />
543
-				<?php echo wp_kses_post( $args['desc'] ); ?>
542
+				<input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox" />
543
+				<?php echo wp_kses_post($args['desc']); ?>
544 544
 			</label>
545 545
 		</fieldset>
546 546
 	<?php
547 547
 }
548 548
 
549
-function wpinv_multicheck_callback( $args ) {
549
+function wpinv_multicheck_callback($args) {
550 550
 
551
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
552
-	$class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
551
+	$sanitize_id = wpinv_sanitize_key($args['id']);
552
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
553 553
 
554
-	if ( ! empty( $args['options'] ) ) {
554
+	if (!empty($args['options'])) {
555 555
 
556
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
557
-		$value   = wpinv_get_option( $args['id'], $std );
556
+		$std     = isset($args['std']) ? $args['std'] : array();
557
+		$value   = wpinv_get_option($args['id'], $std);
558 558
 
559
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
560
-        foreach ( $args['options'] as $key => $option ) :
561
-			$sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
562
-			if ( in_array( $sanitize_key, $value ) ) {
559
+		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr($sanitize_id . $class) . '">';
560
+        foreach ($args['options'] as $key => $option) :
561
+			$sanitize_key = esc_attr(wpinv_sanitize_key($key));
562
+			if (in_array($sanitize_key, $value)) {
563 563
 				$enabled = $sanitize_key;
564 564
 			} else {
565 565
 				$enabled = null;
566 566
 			}
567
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
568
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
567
+			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
568
+			echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']">' . wp_kses_post($option) . '</label></div>';
569 569
 		endforeach;
570 570
 		echo '</div>';
571
-		echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
571
+		echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
572 572
 	}
573 573
 }
574 574
 
575
-function wpinv_payment_icons_callback( $args ) {
575
+function wpinv_payment_icons_callback($args) {
576 576
 
577
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
578
-	$value   = wpinv_get_option( $args['id'], false );
577
+    $sanitize_id = wpinv_sanitize_key($args['id']);
578
+	$value = wpinv_get_option($args['id'], false);
579 579
 
580
-	if ( ! empty( $args['options'] ) ) {
581
-		foreach ( $args['options'] as $key => $option ) {
582
-            $sanitize_key = wpinv_sanitize_key( $key );
580
+	if (!empty($args['options'])) {
581
+		foreach ($args['options'] as $key => $option) {
582
+            $sanitize_key = wpinv_sanitize_key($key);
583 583
 
584
-			if ( empty( $value ) ) {
584
+			if (empty($value)) {
585 585
 				$enabled = $option;
586 586
 			} else {
587 587
 				$enabled = null;
588 588
 			}
589 589
 
590
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
590
+			echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
591 591
 
592
-				echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
592
+				echo '<input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
593 593
 
594
-				if ( wpinv_string_is_image_url( $key ) ) {
595
-				echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
594
+				if (wpinv_string_is_image_url($key)) {
595
+				echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
596 596
 				} else {
597
-				$card = strtolower( str_replace( ' ', '', $option ) );
597
+				$card = strtolower(str_replace(' ', '', $option));
598 598
 
599
-				if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
600
-					$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
599
+				if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
600
+					$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
601 601
 					} else {
602
-					$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
602
+					$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
603 603
 					$content_dir = WP_CONTENT_DIR;
604 604
 
605
-					if ( function_exists( 'wp_normalize_path' ) ) {
605
+					if (function_exists('wp_normalize_path')) {
606 606
 						// Replaces backslashes with forward slashes for Windows systems
607
-						$image = wp_normalize_path( $image );
608
-						$content_dir = wp_normalize_path( $content_dir );
607
+						$image = wp_normalize_path($image);
608
+						$content_dir = wp_normalize_path($content_dir);
609 609
 						}
610 610
 
611
-					$image = str_replace( $content_dir, content_url(), $image );
611
+					$image = str_replace($content_dir, content_url(), $image);
612 612
 					}
613 613
 
614
-				echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
614
+				echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
615 615
 				}
616
-			echo wp_kses_post( $option ) . '</label>';
616
+			echo wp_kses_post($option) . '</label>';
617 617
 		}
618
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
618
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
619 619
 	}
620 620
 }
621 621
 
622 622
 /**
623 623
  * Displays a radio settings field.
624 624
  */
625
-function wpinv_radio_callback( $args ) {
625
+function wpinv_radio_callback($args) {
626 626
 
627
-	$std = isset( $args['std'] ) ? $args['std'] : '';
628
-	$std = wpinv_get_option( $args['id'], $std );
627
+	$std = isset($args['std']) ? $args['std'] : '';
628
+	$std = wpinv_get_option($args['id'], $std);
629 629
 	?>
630 630
 		<fieldset>
631
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
632
-				<?php foreach ( $args['options'] as $key => $option ) : ?>
631
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
632
+				<?php foreach ($args['options'] as $key => $option) : ?>
633 633
 					<li>
634 634
 						<label>
635
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
636
-							<?php echo wp_kses_post( $option ); ?>
635
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
636
+							<?php echo wp_kses_post($option); ?>
637 637
 						</label>
638 638
 					</li>
639 639
 				<?php endforeach; ?>
640 640
 			</ul>
641 641
 		</fieldset>
642 642
 	<?php
643
-	getpaid_settings_description_callback( $args );
643
+	getpaid_settings_description_callback($args);
644 644
 }
645 645
 
646 646
 /**
647 647
  * Displays a description if available.
648 648
  */
649
-function getpaid_settings_description_callback( $args ) {
649
+function getpaid_settings_description_callback($args) {
650 650
 
651
-	if ( ! empty( $args['desc'] ) ) {
651
+	if (!empty($args['desc'])) {
652 652
 		$description = $args['desc'];
653
-		echo wp_kses_post( "<p class='description'>$description</p>" );
653
+		echo wp_kses_post("<p class='description'>$description</p>");
654 654
 	}
655 655
 
656 656
 }
@@ -665,35 +665,35 @@  discard block
 block discarded – undo
665 665
 	</tr>
666 666
 	<tr class="bsui">
667 667
     	<td colspan="2" class="p-0">
668
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?>
668
+			<?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?>
669 669
 
670 670
 	<?php
671 671
 }
672 672
 
673
-function wpinv_gateway_select_callback( $args ) {
673
+function wpinv_gateway_select_callback($args) {
674 674
 
675
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
676
-    $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
677
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
678
-	$value   = wpinv_get_option( $args['id'], $std );
675
+    $sanitize_id = wpinv_sanitize_key($args['id']);
676
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
677
+	$std     = isset($args['std']) ? $args['std'] : '';
678
+	$value   = wpinv_get_option($args['id'], $std);
679 679
 
680
-	echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
680
+	echo '<select name="wpinv_settings[' . esc_attr($sanitize_id) . ']"" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" class="' . esc_attr($class) . '" >';
681 681
 
682
-	foreach ( $args['options'] as $key => $option ) :
682
+	foreach ($args['options'] as $key => $option) :
683 683
 
684
-		echo '<option value="' . esc_attr( $key ) . '" ';
684
+		echo '<option value="' . esc_attr($key) . '" ';
685 685
 
686
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
687
-            selected( $key, $args['selected'] );
686
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
687
+            selected($key, $args['selected']);
688 688
         } else {
689
-            selected( $key, $value );
689
+            selected($key, $value);
690 690
         }
691 691
 
692
-		echo '>' . esc_html( $option['admin_label'] ) . '</option>';
692
+		echo '>' . esc_html($option['admin_label']) . '</option>';
693 693
 	endforeach;
694 694
 
695 695
 	echo '</select>';
696
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
696
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
697 697
 }
698 698
 
699 699
 /**
@@ -702,16 +702,16 @@  discard block
 block discarded – undo
702 702
  * @param array $args
703 703
  * @return string
704 704
  */
705
-function wpinv_settings_attrs_helper( $args ) {
705
+function wpinv_settings_attrs_helper($args) {
706 706
 
707
-	$value = isset( $args['std'] ) ? $args['std'] : '';
708
-	$id    = esc_attr( $args['id'] );
709
-	$value = is_scalar( $value ) ? $value : '';
707
+	$value = isset($args['std']) ? $args['std'] : '';
708
+	$id    = esc_attr($args['id']);
709
+	$value = is_scalar($value) ? $value : '';
710 710
 
711 711
 	$attrs = array(
712
-		'name'     => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]",
713
-		'readonly' => ! empty( $args['faux'] ),
714
-		'value'    => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ),
712
+		'name'     => !empty($args['faux']) ? false : "wpinv_settings[$id]",
713
+		'readonly' => !empty($args['faux']),
714
+		'value'    => !empty($args['faux']) ? $value : wpinv_get_option($args['id'], $value),
715 715
 		'id'       => 'wpinv-settings-' . $args['id'],
716 716
 		'style'    => $args['style'],
717 717
 		'class'    => $args['class'],
@@ -719,20 +719,20 @@  discard block
 block discarded – undo
719 719
 		'data-placeholder' => $args['placeholder'],
720 720
 	);
721 721
 
722
-	if ( ! empty( $args['onchange'] ) ) {
722
+	if (!empty($args['onchange'])) {
723 723
 		$attrs['onchange'] = $args['onchange'];
724 724
 	}
725 725
 
726
-	foreach ( $attrs as $key => $value ) {
726
+	foreach ($attrs as $key => $value) {
727 727
 
728
-		if ( false === $value ) {
728
+		if (false === $value) {
729 729
 			continue;
730 730
 		}
731 731
 
732
-		if ( true === $value ) {
733
-			echo ' ' . esc_attr( $key );
732
+		if (true === $value) {
733
+			echo ' ' . esc_attr($key);
734 734
 		} else {
735
-			echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
735
+			echo ' ' . esc_attr($key) . '="' . esc_attr($value) . '"';
736 736
 		}
737 737
 
738 738
 	}
@@ -742,12 +742,12 @@  discard block
 block discarded – undo
742 742
 /**
743 743
  * Displays a text input settings callback.
744 744
  */
745
-function wpinv_text_callback( $args ) {
745
+function wpinv_text_callback($args) {
746 746
 
747 747
 	?>
748 748
 		<label style="width: 100%;">
749
-			<input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>>
750
-			<?php getpaid_settings_description_callback( $args ); ?>
749
+			<input type="text" <?php wpinv_settings_attrs_helper($args); ?>>
750
+			<?php getpaid_settings_description_callback($args); ?>
751 751
 		</label>
752 752
 	<?php
753 753
 
@@ -756,174 +756,174 @@  discard block
 block discarded – undo
756 756
 /**
757 757
  * Displays a number input settings callback.
758 758
  */
759
-function wpinv_number_callback( $args ) {
759
+function wpinv_number_callback($args) {
760 760
 
761 761
 	?>
762 762
 		<label style="width: 100%;">
763
-			<input type="number" step="<?php echo esc_attr( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>>
764
-			<?php getpaid_settings_description_callback( $args ); ?>
763
+			<input type="number" step="<?php echo esc_attr($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php wpinv_settings_attrs_helper($args); ?>>
764
+			<?php getpaid_settings_description_callback($args); ?>
765 765
 		</label>
766 766
 	<?php
767 767
 
768 768
 }
769 769
 
770
-function wpinv_textarea_callback( $args ) {
770
+function wpinv_textarea_callback($args) {
771 771
 
772
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
773
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
774
-	$value   = wpinv_get_option( $args['id'], $std );
772
+    $sanitize_id = wpinv_sanitize_key($args['id']);
773
+	$std     = isset($args['std']) ? $args['std'] : '';
774
+	$value   = wpinv_get_option($args['id'], $std);
775 775
 
776
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
777
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
776
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
777
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
778 778
 
779
-	echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
780
-	echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
779
+	echo '<textarea class="' . esc_attr($class) . ' txtarea-' . esc_attr($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . esc_attr($args['cols']) . '" rows="' . esc_attr($args['rows']) . '" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
780
+	echo '<br /><label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
781 781
 
782 782
 }
783 783
 
784
-function wpinv_password_callback( $args ) {
784
+function wpinv_password_callback($args) {
785 785
 
786
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
787
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
788
-	$value   = wpinv_get_option( $args['id'], $std );
786
+    $sanitize_id = wpinv_sanitize_key($args['id']);
787
+	$std     = isset($args['std']) ? $args['std'] : '';
788
+	$value   = wpinv_get_option($args['id'], $std);
789 789
 
790
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
791
-	echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
792
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
790
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
791
+	echo '<input type="password" class="' . esc_attr($size) . '-text" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
792
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
793 793
 
794 794
 }
795 795
 
796
-function wpinv_missing_callback( $args ) {
796
+function wpinv_missing_callback($args) {
797 797
 	printf(
798
-		esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
799
-		'<strong>' . esc_html( $args['id'] ) . '</strong>'
798
+		esc_html__('The callback function used for the %s setting is missing.', 'invoicing'),
799
+		'<strong>' . esc_html($args['id']) . '</strong>'
800 800
 	);
801 801
 }
802 802
 
803 803
 /**
804 804
  * Displays a number input settings callback.
805 805
  */
806
-function wpinv_select_callback( $args ) {
806
+function wpinv_select_callback($args) {
807 807
 
808
-	$desc   = wp_kses_post( $args['desc'] );
809
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
810
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
811
-	$value  = wpinv_get_option( $args['id'], $value );
812
-	$rand   = uniqid( 'random_id' );
808
+	$desc   = wp_kses_post($args['desc']);
809
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
810
+	$value  = isset($args['std']) ? $args['std'] : '';
811
+	$value  = wpinv_get_option($args['id'], $value);
812
+	$rand   = uniqid('random_id');
813 813
 
814 814
 	?>
815 815
 		<label style="width: 100%;">
816
-			<select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true">
817
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
818
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo esc_html( $name ); ?></option>
816
+			<select <?php wpinv_settings_attrs_helper($args); ?> data-allow-clear="true">
817
+				<?php foreach ($args['options'] as $option => $name) : ?>
818
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo esc_html($name); ?></option>
819 819
 				<?php endforeach; ?>
820 820
 			</select>
821 821
 
822
-			<?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?>
823
-				<a href="<?php echo esc_url( get_edit_post_link( $value ) ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e( 'Edit Page', 'invoicing' ); ?></a>
822
+			<?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?>
823
+				<a href="<?php echo esc_url(get_edit_post_link($value)); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e('Edit Page', 'invoicing'); ?></a>
824 824
 			<?php endif; ?>
825 825
 
826
-			<?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?>
827
-				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo esc_attr( $rand ); ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e( 'View Default Content', 'invoicing' ); ?></a>
828
-				<div id='<?php echo esc_attr( $rand ); ?>' style='display:none;'>
826
+			<?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?>
827
+				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo esc_attr($rand); ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e('View Default Content', 'invoicing'); ?></a>
828
+				<div id='<?php echo esc_attr($rand); ?>' style='display:none;'>
829 829
 					<div>
830
-						<h3><?php esc_html_e( 'Original Content', 'invoicing' ); ?></h3>
831
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo wp_kses_post( gepaid_trim_lines( $args['default_content'] ) ); ?></textarea>
832
-						<h3><?php esc_html_e( 'Current Content', 'invoicing' ); ?></h3>
833
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : wp_kses_post( gepaid_trim_lines( $_post->post_content ) ); ?></textarea>
830
+						<h3><?php esc_html_e('Original Content', 'invoicing'); ?></h3>
831
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo wp_kses_post(gepaid_trim_lines($args['default_content'])); ?></textarea>
832
+						<h3><?php esc_html_e('Current Content', 'invoicing'); ?></h3>
833
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : wp_kses_post(gepaid_trim_lines($_post->post_content)); ?></textarea>
834 834
 					</div>
835 835
 				</div>
836 836
 			<?php endif; ?>
837 837
 
838
-			<?php echo wp_kses_post( $desc ); ?>
838
+			<?php echo wp_kses_post($desc); ?>
839 839
 		</label>
840 840
 	<?php
841 841
 
842 842
 }
843 843
 
844
-function wpinv_color_select_callback( $args ) {
844
+function wpinv_color_select_callback($args) {
845 845
 
846
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
847
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
848
-	$value   = wpinv_get_option( $args['id'], $std );
846
+    $sanitize_id = wpinv_sanitize_key($args['id']);
847
+	$std     = isset($args['std']) ? $args['std'] : '';
848
+	$value   = wpinv_get_option($args['id'], $std);
849 849
 
850
-	echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
850
+	echo '<select id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
851 851
 
852
-	foreach ( $args['options'] as $option => $color ) {
853
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
852
+	foreach ($args['options'] as $option => $color) {
853
+		echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>';
854 854
 	}
855 855
 
856 856
 	echo '</select>';
857
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
857
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
858 858
 
859 859
 }
860 860
 
861
-function wpinv_rich_editor_callback( $args ) {
861
+function wpinv_rich_editor_callback($args) {
862 862
 	global $wp_version;
863 863
 
864
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
864
+    $sanitize_id = wpinv_sanitize_key($args['id']);
865 865
 
866
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
867
-	$value   = wpinv_get_option( $args['id'], $std );
866
+	$std     = isset($args['std']) ? $args['std'] : '';
867
+	$value   = wpinv_get_option($args['id'], $std);
868 868
 
869
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
869
+	if (!empty($args['allow_blank']) && empty($value)) {
870 870
 		$value = $std;
871 871
 	}
872 872
 
873
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
873
+	$rows = isset($args['size']) ? $args['size'] : 20;
874 874
 
875 875
 	echo '<div class="getpaid-settings-editor-input">';
876
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
876
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
877 877
 		wp_editor(
878
-            stripslashes( $value ),
879
-            'wpinv_settings_' . esc_attr( $args['id'] ),
878
+            stripslashes($value),
879
+            'wpinv_settings_' . esc_attr($args['id']),
880 880
             array(
881
-				'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
882
-				'textarea_rows' => absint( $rows ),
881
+				'textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']',
882
+				'textarea_rows' => absint($rows),
883 883
 				'media_buttons' => false,
884 884
             )
885 885
         );
886 886
 	} else {
887
-		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
887
+		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>';
888 888
 	}
889 889
 
890
-	echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
890
+	echo '</div><br/><label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
891 891
 
892 892
 }
893 893
 
894
-function wpinv_upload_callback( $args ) {
894
+function wpinv_upload_callback($args) {
895 895
 
896
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
896
+    $sanitize_id = wpinv_sanitize_key($args['id']);
897 897
 
898
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
899
-	$value   = wpinv_get_option( $args['id'], $std );
898
+	$std     = isset($args['std']) ? $args['std'] : '';
899
+	$value   = wpinv_get_option($args['id'], $std);
900 900
 
901
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
902
-	echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
903
-	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>';
904
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
901
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
902
+	echo '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
903
+	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__('Upload File', 'invoicing') . '"/></span>';
904
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
905 905
 
906 906
 }
907 907
 
908
-function wpinv_color_callback( $args ) {
908
+function wpinv_color_callback($args) {
909 909
 
910
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
911
-	$value       = wpinv_get_option( $args['id'], $std );
912
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
910
+	$std         = isset($args['std']) ? $args['std'] : '';
911
+	$value       = wpinv_get_option($args['id'], $std);
912
+    $sanitize_id = wpinv_sanitize_key($args['id']);
913 913
 
914
-	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
915
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
914
+	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />';
915
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
916 916
 
917 917
 }
918 918
 
919
-function wpinv_country_states_callback( $args ) {
919
+function wpinv_country_states_callback($args) {
920 920
 
921
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
922
-	$value   = wpinv_get_option( $args['id'], $std );
921
+	$std     = isset($args['std']) ? $args['std'] : '';
922
+	$value   = wpinv_get_option($args['id'], $std);
923 923
 
924
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
924
+    $sanitize_id = wpinv_sanitize_key($args['id']);
925 925
 
926
-	if ( isset( $args['placeholder'] ) ) {
926
+	if (isset($args['placeholder'])) {
927 927
 		$placeholder = $args['placeholder'];
928 928
 	} else {
929 929
 		$placeholder = '';
@@ -931,15 +931,15 @@  discard block
 block discarded – undo
931 931
 
932 932
 	$states = wpinv_get_country_states();
933 933
 
934
-	$class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2';
935
-	echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>';
934
+	$class = empty($states) ? 'wpinv-no-states' : 'wpi_select2';
935
+	echo '<select id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="' . esc_attr($class) . '" data-placeholder="' . esc_html($placeholder) . '"/>';
936 936
 
937
-	foreach ( $states as $option => $name ) {
938
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
937
+	foreach ($states as $option => $name) {
938
+		echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>';
939 939
 	}
940 940
 
941 941
 	echo '</select>';
942
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
942
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
943 943
 
944 944
 }
945 945
 
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
 	</tr>
954 954
 	<tr class="bsui">
955 955
     	<td colspan="2" class="p-0">
956
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
956
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
957 957
 
958 958
 	<?php
959 959
 
@@ -962,11 +962,11 @@  discard block
 block discarded – undo
962 962
 /**
963 963
  * Displays a tax rate' edit row.
964 964
  */
965
-function wpinv_tax_rate_callback( $tax_rate, $key ) {
965
+function wpinv_tax_rate_callback($tax_rate, $key) {
966 966
 
967
-	$key                      = sanitize_key( $key );
968
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
969
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
967
+	$key                      = sanitize_key($key);
968
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
969
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
970 970
 
971 971
 }
972 972
 
@@ -980,177 +980,177 @@  discard block
 block discarded – undo
980 980
 	</tr>
981 981
 	<tr class="bsui">
982 982
     	<td colspan="2" class="p-0">
983
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rules-edit.php'; ?>
983
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rules-edit.php'; ?>
984 984
 
985 985
 	<?php
986 986
 
987 987
 }
988 988
 
989
-function wpinv_tools_callback( $args ) {
989
+function wpinv_tools_callback($args) {
990 990
     ?>
991 991
     </td><tr>
992 992
     <td colspan="2" class="wpinv_tools_tdbox">
993 993
     <?php
994
-    if ( $args['desc'] ) {
994
+    if ($args['desc']) {
995 995
 ?>
996
-<p><?php echo wp_kses_post( $args['desc'] ); ?></p><?php } ?>
997
-    <?php do_action( 'wpinv_tools_before' ); ?>
996
+<p><?php echo wp_kses_post($args['desc']); ?></p><?php } ?>
997
+    <?php do_action('wpinv_tools_before'); ?>
998 998
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
999 999
         <thead>
1000 1000
             <tr>
1001
-                <th scope="col" class="wpinv-th-tool"><?php esc_html_e( 'Tool', 'invoicing' ); ?></th>
1002
-                <th scope="col" class="wpinv-th-desc"><?php esc_html_e( 'Description', 'invoicing' ); ?></th>
1003
-                <th scope="col" class="wpinv-th-action"><?php esc_html_e( 'Action', 'invoicing' ); ?></th>
1001
+                <th scope="col" class="wpinv-th-tool"><?php esc_html_e('Tool', 'invoicing'); ?></th>
1002
+                <th scope="col" class="wpinv-th-desc"><?php esc_html_e('Description', 'invoicing'); ?></th>
1003
+                <th scope="col" class="wpinv-th-action"><?php esc_html_e('Action', 'invoicing'); ?></th>
1004 1004
             </tr>
1005 1005
         </thead>
1006 1006
 
1007 1007
         <tbody>
1008 1008
 			<tr>
1009
-                <td><?php esc_html_e( 'Check Pages', 'invoicing' ); ?></td>
1009
+                <td><?php esc_html_e('Check Pages', 'invoicing'); ?></td>
1010 1010
                 <td>
1011
-                    <small><?php esc_html_e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small>
1011
+                    <small><?php esc_html_e('Creates any missing GetPaid pages.', 'invoicing'); ?></small>
1012 1012
                 </td>
1013 1013
                 <td>
1014 1014
 					<a href="
1015 1015
                     <?php
1016 1016
 						echo esc_url(
1017 1017
 							wp_nonce_url(
1018
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
1018
+								add_query_arg('getpaid-admin-action', 'create_missing_pages'),
1019 1019
 								'getpaid-nonce',
1020 1020
 								'getpaid-nonce'
1021 1021
 							)
1022 1022
 						);
1023 1023
 					?>
1024
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1024
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1025 1025
                 </td>
1026 1026
             </tr>
1027 1027
 			<tr>
1028
-                <td><?php esc_html_e( 'Refresh Permalinks', 'invoicing' ); ?></td>
1028
+                <td><?php esc_html_e('Refresh Permalinks', 'invoicing'); ?></td>
1029 1029
                 <td>
1030
-                    <small><?php esc_html_e( 'Might fix the page not found error when viewing an invoice.', 'invoicing' ); ?></small>
1030
+                    <small><?php esc_html_e('Might fix the page not found error when viewing an invoice.', 'invoicing'); ?></small>
1031 1031
                 </td>
1032 1032
                 <td>
1033 1033
 					<a href="
1034 1034
                     <?php
1035 1035
 						echo esc_url(
1036 1036
 							wp_nonce_url(
1037
-								add_query_arg( 'getpaid-admin-action', 'refresh_permalinks' ),
1037
+								add_query_arg('getpaid-admin-action', 'refresh_permalinks'),
1038 1038
 								'getpaid-nonce',
1039 1039
 								'getpaid-nonce'
1040 1040
 							)
1041 1041
 						);
1042 1042
 					?>
1043
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1043
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1044 1044
                 </td>
1045 1045
             </tr>
1046 1046
 			<tr>
1047
-                <td><?php esc_html_e( 'Create Database Tables', 'invoicing' ); ?></td>
1047
+                <td><?php esc_html_e('Create Database Tables', 'invoicing'); ?></td>
1048 1048
                 <td>
1049
-                    <small><?php esc_html_e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small>
1049
+                    <small><?php esc_html_e('Run this tool to create any missing database tables.', 'invoicing'); ?></small>
1050 1050
                 </td>
1051 1051
                 <td>
1052 1052
 					<a href="
1053 1053
                     <?php
1054 1054
 						echo esc_url(
1055 1055
 							wp_nonce_url(
1056
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1056
+								add_query_arg('getpaid-admin-action', 'create_missing_tables'),
1057 1057
 								'getpaid-nonce',
1058 1058
 								'getpaid-nonce'
1059 1059
 							)
1060 1060
 						);
1061 1061
 					?>
1062
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1062
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1063 1063
                 </td>
1064 1064
             </tr>
1065 1065
 			<tr>
1066
-                <td><?php esc_html_e( 'Migrate old invoices', 'invoicing' ); ?></td>
1066
+                <td><?php esc_html_e('Migrate old invoices', 'invoicing'); ?></td>
1067 1067
                 <td>
1068
-                    <small><?php esc_html_e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small>
1068
+                    <small><?php esc_html_e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small>
1069 1069
                 </td>
1070 1070
                 <td>
1071 1071
 					<a href="
1072 1072
                     <?php
1073 1073
 						echo esc_url(
1074 1074
 							wp_nonce_url(
1075
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1075
+								add_query_arg('getpaid-admin-action', 'migrate_old_invoices'),
1076 1076
 								'getpaid-nonce',
1077 1077
 								'getpaid-nonce'
1078 1078
 							)
1079 1079
 						);
1080 1080
 					?>
1081
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1081
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1082 1082
                 </td>
1083 1083
             </tr>
1084 1084
 
1085 1085
 			<tr>
1086
-                <td><?php esc_html_e( 'Recalculate Discounts', 'invoicing' ); ?></td>
1086
+                <td><?php esc_html_e('Recalculate Discounts', 'invoicing'); ?></td>
1087 1087
                 <td>
1088
-                    <small><?php esc_html_e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small>
1088
+                    <small><?php esc_html_e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small>
1089 1089
                 </td>
1090 1090
                 <td>
1091 1091
 					<a href="
1092 1092
                     <?php
1093 1093
 						echo esc_url(
1094 1094
 							wp_nonce_url(
1095
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1095
+								add_query_arg('getpaid-admin-action', 'recalculate_discounts'),
1096 1096
 								'getpaid-nonce',
1097 1097
 								'getpaid-nonce'
1098 1098
 							)
1099 1099
 						);
1100 1100
 					?>
1101
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1101
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1102 1102
                 </td>
1103 1103
             </tr>
1104 1104
 
1105 1105
 			<tr>
1106
-                <td><?php esc_html_e( 'Set-up Wizard', 'invoicing' ); ?></td>
1106
+                <td><?php esc_html_e('Set-up Wizard', 'invoicing'); ?></td>
1107 1107
                 <td>
1108
-                    <small><?php esc_html_e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small>
1108
+                    <small><?php esc_html_e('Launch the quick set-up wizard.', 'invoicing'); ?></small>
1109 1109
                 </td>
1110 1110
                 <td>
1111 1111
 					<a href="
1112 1112
                     <?php
1113
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1113
+						echo esc_url(admin_url('index.php?page=gp-setup'));
1114 1114
 					?>
1115
-                    " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a>
1115
+                    " class="button button-primary"><?php esc_html_e('Launch', 'invoicing'); ?></a>
1116 1116
                 </td>
1117 1117
             </tr>
1118 1118
 
1119
-			<?php do_action( 'wpinv_tools_row' ); ?>
1119
+			<?php do_action('wpinv_tools_row'); ?>
1120 1120
         </tbody>
1121 1121
     </table>
1122
-    <?php do_action( 'wpinv_tools_after' ); ?>
1122
+    <?php do_action('wpinv_tools_after'); ?>
1123 1123
     <?php
1124 1124
 }
1125 1125
 
1126 1126
 
1127
-function wpinv_descriptive_text_callback( $args ) {
1128
-	echo wp_kses_post( $args['desc'] );
1127
+function wpinv_descriptive_text_callback($args) {
1128
+	echo wp_kses_post($args['desc']);
1129 1129
 }
1130 1130
 
1131
-function wpinv_raw_html_callback( $args ) {
1132
-	echo wp_kses( $args['desc'], getpaid_allowed_html() );
1131
+function wpinv_raw_html_callback($args) {
1132
+	echo wp_kses($args['desc'], getpaid_allowed_html());
1133 1133
 }
1134 1134
 
1135
-function wpinv_hook_callback( $args ) {
1136
-	do_action( 'wpinv_' . $args['id'], $args );
1135
+function wpinv_hook_callback($args) {
1136
+	do_action('wpinv_' . $args['id'], $args);
1137 1137
 }
1138 1138
 
1139 1139
 function wpinv_set_settings_cap() {
1140 1140
 	return wpinv_get_capability();
1141 1141
 }
1142
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1142
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1143 1143
 
1144 1144
 
1145
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1146
-    $old = ! empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1147
-    $new = ! empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1145
+function wpinv_on_update_settings($old_value, $value, $option) {
1146
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1147
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1148 1148
 
1149
-    if ( $old != $new ) {
1150
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1149
+    if ($old != $new) {
1150
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1151 1151
     }
1152 1152
 }
1153
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1153
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1154 1154
 
1155 1155
 /**
1156 1156
  * Returns the merge tags help text.
@@ -1159,16 +1159,16 @@  discard block
 block discarded – undo
1159 1159
  *
1160 1160
  * @return string
1161 1161
  */
1162
-function wpinv_get_merge_tags_help_text( $subscription = false ) {
1162
+function wpinv_get_merge_tags_help_text($subscription = false) {
1163 1163
 
1164 1164
 	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1165 1165
 	$link = sprintf(
1166 1166
 		'<strong><a href="%s" target="_blank">%s</a></strong>',
1167 1167
 		$url,
1168
-		esc_html__( 'View available merge tags.', 'invoicing' )
1168
+		esc_html__('View available merge tags.', 'invoicing')
1169 1169
 	);
1170 1170
 
1171
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1171
+	$description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing');
1172 1172
 
1173 1173
 	return "$description $link";
1174 1174
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-metaboxes.php 2 patches
Indentation   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -12,280 +12,280 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Metaboxes {
14 14
 
15
-	/**
16
-	 * Only save metaboxes once.
17
-	 *
18
-	 * @var boolean
19
-	 */
20
-	private static $saved_meta_boxes = false;
15
+    /**
16
+     * Only save metaboxes once.
17
+     *
18
+     * @var boolean
19
+     */
20
+    private static $saved_meta_boxes = false;
21 21
 
22 22
     /**
23
-	 * Hook in methods.
24
-	 */
25
-	public static function init() {
23
+     * Hook in methods.
24
+     */
25
+    public static function init() {
26 26
 
27
-		// Register metaboxes.
28
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 50, 2 );
27
+        // Register metaboxes.
28
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 50, 2 );
29 29
 
30
-		// Remove metaboxes.
31
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
30
+        // Remove metaboxes.
31
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
32 32
 
33
-		// Rename metaboxes.
34
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
33
+        // Rename metaboxes.
34
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
35 35
 
36
-		// Save metaboxes.
37
-		add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
38
-	}
36
+        // Save metaboxes.
37
+        add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
38
+    }
39 39
 
40
-	/**
41
-	 * Register core metaboxes.
42
-	 */
43
-	public static function add_meta_boxes( $post_type, $post ) {
40
+    /**
41
+     * Register core metaboxes.
42
+     */
43
+    public static function add_meta_boxes( $post_type, $post ) {
44 44
 
45
-		// For invoices.
46
-		self::add_invoice_meta_boxes( $post_type, $post );
45
+        // For invoices.
46
+        self::add_invoice_meta_boxes( $post_type, $post );
47 47
 
48
-		// For payment forms.
49
-		self::add_payment_form_meta_boxes( $post_type, $post );
48
+        // For payment forms.
49
+        self::add_payment_form_meta_boxes( $post_type, $post );
50 50
 
51
-		// For invoice items.
52
-		self::add_item_meta_boxes( $post_type );
51
+        // For invoice items.
52
+        self::add_item_meta_boxes( $post_type );
53 53
 
54
-		// For invoice discounts.
55
-		if ( 'wpi_discount' === $post_type ) {
56
-			add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
57
-		}
54
+        // For invoice discounts.
55
+        if ( 'wpi_discount' === $post_type ) {
56
+            add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
57
+        }
58 58
 
59
-	}
59
+    }
60 60
 
61
-	/**
62
-	 * Register core metaboxes.
63
-	 */
64
-	protected static function add_payment_form_meta_boxes( $post_type, $post ) {
61
+    /**
62
+     * Register core metaboxes.
63
+     */
64
+    protected static function add_payment_form_meta_boxes( $post_type, $post ) {
65 65
 
66
-		// For payment forms.
67
-		if ( 'wpi_payment_form' === $post_type ) {
66
+        // For payment forms.
67
+        if ( 'wpi_payment_form' === $post_type ) {
68 68
 
69
-			// Design payment form.
70
-			add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
69
+            // Design payment form.
70
+            add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
71 71
 
72
-			// Payment form information.
73
-			if ( wpinv_get_default_payment_form() !== $post->ID ) {
74
-				add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
75
-			}
72
+            // Payment form information.
73
+            if ( wpinv_get_default_payment_form() !== $post->ID ) {
74
+                add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
75
+            }
76 76
 }
77 77
 
78
-	}
79
-
80
-	/**
81
-	 * Register core metaboxes.
82
-	 */
83
-	protected static function add_item_meta_boxes( $post_type ) {
78
+    }
84 79
 
85
-		if ( 'wpi_item' === $post_type ) {
86
-
87
-			// Item details.
88
-			add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
89
-
90
-			// If taxes are enabled, register the tax metabox.
91
-			if ( wpinv_use_taxes() ) {
92
-				add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
93
-			}
80
+    /**
81
+     * Register core metaboxes.
82
+     */
83
+    protected static function add_item_meta_boxes( $post_type ) {
94 84
 
95
-			// Item info.
96
-			add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
85
+        if ( 'wpi_item' === $post_type ) {
97 86
 
98
-			// Item description.
99
-			add_meta_box( 'postexcerpt', __( 'Item Description', 'invoicing' ), 'GetPaid_Meta_Box_Description::output', 'wpi_item', 'normal' );
100
-		}
87
+            // Item details.
88
+            add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
101 89
 
102
-	}
90
+            // If taxes are enabled, register the tax metabox.
91
+            if ( wpinv_use_taxes() ) {
92
+                add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
93
+            }
103 94
 
104
-	/**
105
-	 * Register invoice metaboxes.
106
-	 */
107
-	protected static function add_invoice_meta_boxes( $post_type, $post ) {
95
+            // Item info.
96
+            add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
108 97
 
109
-		// For invoices...
110
-		if ( getpaid_is_invoice_post_type( $post_type ) ) {
111
-			$invoice = new WPInv_Invoice( $post );
98
+            // Item description.
99
+            add_meta_box( 'postexcerpt', __( 'Item Description', 'invoicing' ), 'GetPaid_Meta_Box_Description::output', 'wpi_item', 'normal' );
100
+        }
112 101
 
113
-			// Resend invoice.
114
-			if ( ! $invoice->is_draft() ) {
102
+    }
115 103
 
116
-				add_meta_box(
117
-					'wpinv-mb-resend-invoice',
118
-					sprintf(
119
-						// translators: %s is the invoice type.
120
-						__( 'Resend %s', 'invoicing' ),
121
-						ucfirst( $invoice->get_invoice_quote_type() )
122
-					),
123
-					'GetPaid_Meta_Box_Resend_Invoice::output',
124
-					$post_type,
125
-					'side',
126
-					'low'
127
-				);
104
+    /**
105
+     * Register invoice metaboxes.
106
+     */
107
+    protected static function add_invoice_meta_boxes( $post_type, $post ) {
108
+
109
+        // For invoices...
110
+        if ( getpaid_is_invoice_post_type( $post_type ) ) {
111
+            $invoice = new WPInv_Invoice( $post );
112
+
113
+            // Resend invoice.
114
+            if ( ! $invoice->is_draft() ) {
115
+
116
+                add_meta_box(
117
+                    'wpinv-mb-resend-invoice',
118
+                    sprintf(
119
+                        // translators: %s is the invoice type.
120
+                        __( 'Resend %s', 'invoicing' ),
121
+                        ucfirst( $invoice->get_invoice_quote_type() )
122
+                    ),
123
+                    'GetPaid_Meta_Box_Resend_Invoice::output',
124
+                    $post_type,
125
+                    'side',
126
+                    'low'
127
+                );
128
+
129
+            }
130
+
131
+            // Subscriptions.
132
+            $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
133
+            if ( ! empty( $subscriptions ) ) {
134
+
135
+                if ( is_array( $subscriptions ) ) {
136
+                    add_meta_box( 'wpinv-mb-subscriptions', __( 'Related Subscriptions', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced' );
137
+                } else {
138
+                    add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' );
139
+                }
140
+
141
+                if ( getpaid_count_subscription_invoices( $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id() ) > 1 ) {
142
+                    add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' );
143
+                }
144
+}
128 145
 
129
-			}
146
+            // Invoice details.
147
+            add_meta_box(
148
+                'wpinv-details',
149
+                sprintf(
150
+                    // translators: %s is the invoice type.
151
+                    __( '%s Details', 'invoicing' ),
152
+                    ucfirst( $invoice->get_invoice_quote_type() )
153
+                ),
154
+                'GetPaid_Meta_Box_Invoice_Details::output',
155
+                $post_type,
156
+                'side'
157
+            );
158
+
159
+            // Payment details.
160
+            add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' );
161
+
162
+            // Billing details.
163
+            add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' );
164
+
165
+            // Invoice items.
166
+            add_meta_box(
167
+                'wpinv-items',
168
+                sprintf(
169
+                    // translators: %s is the invoice type.
170
+                    __( '%s Items', 'invoicing' ),
171
+                    ucfirst( $invoice->get_invoice_quote_type() )
172
+                ),
173
+                'GetPaid_Meta_Box_Invoice_Items::output',
174
+                $post_type,
175
+                'normal',
176
+                'high'
177
+            );
178
+
179
+            // Invoice notes.
180
+            add_meta_box(
181
+                'wpinv-notes',
182
+                sprintf(
183
+                    // translators: %s is the invoice type.
184
+                    __( '%s Notes', 'invoicing' ),
185
+                    ucfirst( $invoice->get_invoice_quote_type() )
186
+                ),
187
+                'WPInv_Meta_Box_Notes::output',
188
+                $post_type,
189
+                'side',
190
+                'low'
191
+            );
192
+
193
+            // Shipping Address.
194
+            if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) {
195
+                add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' );
196
+            }
197
+
198
+            // Payment form information.
199
+            if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) {
200
+                add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' );
201
+            }
202
+}
130 203
 
131
-			// Subscriptions.
132
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
133
-			if ( ! empty( $subscriptions ) ) {
204
+    }
134 205
 
135
-				if ( is_array( $subscriptions ) ) {
136
-					add_meta_box( 'wpinv-mb-subscriptions', __( 'Related Subscriptions', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced' );
137
-				} else {
138
-					add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' );
139
-				}
206
+    /**
207
+     * Remove some metaboxes.
208
+     */
209
+    public static function remove_meta_boxes() {
210
+        remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
211
+        remove_meta_box( 'postexcerpt', 'wpi_item', 'normal' );
212
+    }
140 213
 
141
-				if ( getpaid_count_subscription_invoices( $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id() ) > 1 ) {
142
-					add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' );
143
-				}
144
-}
214
+    /**
215
+     * Rename other metaboxes.
216
+     */
217
+    public static function rename_meta_boxes() {
145 218
 
146
-			// Invoice details.
147
-			add_meta_box(
148
-				'wpinv-details',
149
-				sprintf(
150
-					// translators: %s is the invoice type.
151
-					__( '%s Details', 'invoicing' ),
152
-					ucfirst( $invoice->get_invoice_quote_type() )
153
-				),
154
-				'GetPaid_Meta_Box_Invoice_Details::output',
155
-				$post_type,
156
-				'side'
157
-			);
158
-
159
-			// Payment details.
160
-			add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' );
161
-
162
-			// Billing details.
163
-			add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' );
164
-
165
-			// Invoice items.
166
-			add_meta_box(
167
-				'wpinv-items',
168
-				sprintf(
169
-					// translators: %s is the invoice type.
170
-					__( '%s Items', 'invoicing' ),
171
-					ucfirst( $invoice->get_invoice_quote_type() )
172
-				),
173
-				'GetPaid_Meta_Box_Invoice_Items::output',
174
-				$post_type,
175
-				'normal',
176
-				'high'
177
-			);
178
-
179
-			// Invoice notes.
180
-			add_meta_box(
181
-				'wpinv-notes',
182
-				sprintf(
183
-					// translators: %s is the invoice type.
184
-					__( '%s Notes', 'invoicing' ),
185
-					ucfirst( $invoice->get_invoice_quote_type() )
186
-				),
187
-				'WPInv_Meta_Box_Notes::output',
188
-				$post_type,
189
-				'side',
190
-				'low'
191
-			);
192
-
193
-			// Shipping Address.
194
-			if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) {
195
-				add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' );
196
-			}
197
-
198
-			// Payment form information.
199
-			if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) {
200
-				add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' );
201
-			}
202
-}
219
+    }
203 220
 
204
-	}
205
-
206
-	/**
207
-	 * Remove some metaboxes.
208
-	 */
209
-	public static function remove_meta_boxes() {
210
-		remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
211
-		remove_meta_box( 'postexcerpt', 'wpi_item', 'normal' );
212
-	}
213
-
214
-	/**
215
-	 * Rename other metaboxes.
216
-	 */
217
-	public static function rename_meta_boxes() {
218
-
219
-	}
220
-
221
-	/**
222
-	 * Check if we're saving, then trigger an action based on the post type.
223
-	 *
224
-	 * @param  int    $post_id Post ID.
225
-	 * @param  object $post Post object.
226
-	 */
227
-	public static function save_meta_boxes( $post_id, $post ) {
228
-		$post_id = absint( $post_id );
229
-		$data    = wp_kses_post_deep( wp_unslash( $_POST ) );
230
-
231
-		// Do not save for ajax requests.
232
-		if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
233
-			return;
234
-		}
235
-
236
-		// $post_id and $post are required
237
-		if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
238
-			return;
239
-		}
240
-
241
-		// Dont' save meta boxes for revisions or autosaves.
242
-		if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
243
-			return;
244
-		}
245
-
246
-		// Check the nonce.
247
-		if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) {
248
-			return;
249
-		}
250
-
251
-		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
252
-		if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) {
253
-			return;
254
-		}
255
-
256
-		// Check user has permission to edit.
257
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
258
-			return;
259
-		}
260
-
261
-		if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
262
-
263
-			// We need this save event to run once to avoid potential endless loops.
264
-			self::$saved_meta_boxes = true;
265
-
266
-			return GetPaid_Meta_Box_Invoice_Address::save( $post_id, wp_kses_post_deep( $_POST ) );
267
-
268
-		}
269
-
270
-		// Ensure this is our post type.
271
-		$post_types_map = array(
272
-			'wpi_item'         => 'GetPaid_Meta_Box_Item_Details',
273
-			'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form',
274
-			'wpi_discount'     => 'GetPaid_Meta_Box_Discount_Details',
275
-		);
276
-
277
-		// Is this our post type?
278
-		if ( ! isset( $post_types_map[ $post->post_type ] ) ) {
279
-			return;
280
-		}
281
-
282
-		// We need this save event to run once to avoid potential endless loops.
283
-		self::$saved_meta_boxes = true;
284
-
285
-		// Save the post.
286
-		$class = $post_types_map[ $post->post_type ];
287
-		$class::save( $post_id, wp_kses_post_deep( $_POST ), $post );
288
-
289
-	}
221
+    /**
222
+     * Check if we're saving, then trigger an action based on the post type.
223
+     *
224
+     * @param  int    $post_id Post ID.
225
+     * @param  object $post Post object.
226
+     */
227
+    public static function save_meta_boxes( $post_id, $post ) {
228
+        $post_id = absint( $post_id );
229
+        $data    = wp_kses_post_deep( wp_unslash( $_POST ) );
230
+
231
+        // Do not save for ajax requests.
232
+        if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
233
+            return;
234
+        }
235
+
236
+        // $post_id and $post are required
237
+        if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
238
+            return;
239
+        }
240
+
241
+        // Dont' save meta boxes for revisions or autosaves.
242
+        if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
243
+            return;
244
+        }
245
+
246
+        // Check the nonce.
247
+        if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) {
248
+            return;
249
+        }
250
+
251
+        // Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
252
+        if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) {
253
+            return;
254
+        }
255
+
256
+        // Check user has permission to edit.
257
+        if ( ! current_user_can( 'edit_post', $post_id ) ) {
258
+            return;
259
+        }
260
+
261
+        if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
262
+
263
+            // We need this save event to run once to avoid potential endless loops.
264
+            self::$saved_meta_boxes = true;
265
+
266
+            return GetPaid_Meta_Box_Invoice_Address::save( $post_id, wp_kses_post_deep( $_POST ) );
267
+
268
+        }
269
+
270
+        // Ensure this is our post type.
271
+        $post_types_map = array(
272
+            'wpi_item'         => 'GetPaid_Meta_Box_Item_Details',
273
+            'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form',
274
+            'wpi_discount'     => 'GetPaid_Meta_Box_Discount_Details',
275
+        );
276
+
277
+        // Is this our post type?
278
+        if ( ! isset( $post_types_map[ $post->post_type ] ) ) {
279
+            return;
280
+        }
281
+
282
+        // We need this save event to run once to avoid potential endless loops.
283
+        self::$saved_meta_boxes = true;
284
+
285
+        // Save the post.
286
+        $class = $post_types_map[ $post->post_type ];
287
+        $class::save( $post_id, wp_kses_post_deep( $_POST ), $post );
288
+
289
+    }
290 290
 
291 291
 }
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Metaboxes Admin Class
@@ -25,35 +25,35 @@  discard block
 block discarded – undo
25 25
 	public static function init() {
26 26
 
27 27
 		// Register metaboxes.
28
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 50, 2 );
28
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 50, 2);
29 29
 
30 30
 		// Remove metaboxes.
31
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
31
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30);
32 32
 
33 33
 		// Rename metaboxes.
34
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
34
+		add_action('add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45);
35 35
 
36 36
 		// Save metaboxes.
37
-		add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
37
+		add_action('save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2);
38 38
 	}
39 39
 
40 40
 	/**
41 41
 	 * Register core metaboxes.
42 42
 	 */
43
-	public static function add_meta_boxes( $post_type, $post ) {
43
+	public static function add_meta_boxes($post_type, $post) {
44 44
 
45 45
 		// For invoices.
46
-		self::add_invoice_meta_boxes( $post_type, $post );
46
+		self::add_invoice_meta_boxes($post_type, $post);
47 47
 
48 48
 		// For payment forms.
49
-		self::add_payment_form_meta_boxes( $post_type, $post );
49
+		self::add_payment_form_meta_boxes($post_type, $post);
50 50
 
51 51
 		// For invoice items.
52
-		self::add_item_meta_boxes( $post_type );
52
+		self::add_item_meta_boxes($post_type);
53 53
 
54 54
 		// For invoice discounts.
55
-		if ( 'wpi_discount' === $post_type ) {
56
-			add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
55
+		if ('wpi_discount' === $post_type) {
56
+			add_meta_box('wpinv_discount_details', __('Discount Details', 'invoicing'), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high');
57 57
 		}
58 58
 
59 59
 	}
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
 	/**
62 62
 	 * Register core metaboxes.
63 63
 	 */
64
-	protected static function add_payment_form_meta_boxes( $post_type, $post ) {
64
+	protected static function add_payment_form_meta_boxes($post_type, $post) {
65 65
 
66 66
 		// For payment forms.
67
-		if ( 'wpi_payment_form' === $post_type ) {
67
+		if ('wpi_payment_form' === $post_type) {
68 68
 
69 69
 			// Design payment form.
70
-			add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
70
+			add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal');
71 71
 
72 72
 			// Payment form information.
73
-			if ( wpinv_get_default_payment_form() !== $post->ID ) {
74
-				add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
73
+			if (wpinv_get_default_payment_form() !== $post->ID) {
74
+				add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side');
75 75
 			}
76 76
 }
77 77
 
@@ -80,23 +80,23 @@  discard block
 block discarded – undo
80 80
 	/**
81 81
 	 * Register core metaboxes.
82 82
 	 */
83
-	protected static function add_item_meta_boxes( $post_type ) {
83
+	protected static function add_item_meta_boxes($post_type) {
84 84
 
85
-		if ( 'wpi_item' === $post_type ) {
85
+		if ('wpi_item' === $post_type) {
86 86
 
87 87
 			// Item details.
88
-			add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
88
+			add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high');
89 89
 
90 90
 			// If taxes are enabled, register the tax metabox.
91
-			if ( wpinv_use_taxes() ) {
92
-				add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
91
+			if (wpinv_use_taxes()) {
92
+				add_meta_box('wpinv_item_vat', __('Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high');
93 93
 			}
94 94
 
95 95
 			// Item info.
96
-			add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
96
+			add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core');
97 97
 
98 98
 			// Item description.
99
-			add_meta_box( 'postexcerpt', __( 'Item Description', 'invoicing' ), 'GetPaid_Meta_Box_Description::output', 'wpi_item', 'normal' );
99
+			add_meta_box('postexcerpt', __('Item Description', 'invoicing'), 'GetPaid_Meta_Box_Description::output', 'wpi_item', 'normal');
100 100
 		}
101 101
 
102 102
 	}
@@ -104,21 +104,21 @@  discard block
 block discarded – undo
104 104
 	/**
105 105
 	 * Register invoice metaboxes.
106 106
 	 */
107
-	protected static function add_invoice_meta_boxes( $post_type, $post ) {
107
+	protected static function add_invoice_meta_boxes($post_type, $post) {
108 108
 
109 109
 		// For invoices...
110
-		if ( getpaid_is_invoice_post_type( $post_type ) ) {
111
-			$invoice = new WPInv_Invoice( $post );
110
+		if (getpaid_is_invoice_post_type($post_type)) {
111
+			$invoice = new WPInv_Invoice($post);
112 112
 
113 113
 			// Resend invoice.
114
-			if ( ! $invoice->is_draft() ) {
114
+			if (!$invoice->is_draft()) {
115 115
 
116 116
 				add_meta_box(
117 117
 					'wpinv-mb-resend-invoice',
118 118
 					sprintf(
119 119
 						// translators: %s is the invoice type.
120
-						__( 'Resend %s', 'invoicing' ),
121
-						ucfirst( $invoice->get_invoice_quote_type() )
120
+						__('Resend %s', 'invoicing'),
121
+						ucfirst($invoice->get_invoice_quote_type())
122 122
 					),
123 123
 					'GetPaid_Meta_Box_Resend_Invoice::output',
124 124
 					$post_type,
@@ -129,17 +129,17 @@  discard block
 block discarded – undo
129 129
 			}
130 130
 
131 131
 			// Subscriptions.
132
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
133
-			if ( ! empty( $subscriptions ) ) {
132
+			$subscriptions = getpaid_get_invoice_subscriptions($invoice);
133
+			if (!empty($subscriptions)) {
134 134
 
135
-				if ( is_array( $subscriptions ) ) {
136
-					add_meta_box( 'wpinv-mb-subscriptions', __( 'Related Subscriptions', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced' );
135
+				if (is_array($subscriptions)) {
136
+					add_meta_box('wpinv-mb-subscriptions', __('Related Subscriptions', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_related', $post_type, 'advanced');
137 137
 				} else {
138
-					add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' );
138
+					add_meta_box('wpinv-mb-subscriptions', __('Subscription Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced');
139 139
 				}
140 140
 
141
-				if ( getpaid_count_subscription_invoices( $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id() ) > 1 ) {
142
-					add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' );
141
+				if (getpaid_count_subscription_invoices($invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id()) > 1) {
142
+					add_meta_box('wpinv-mb-subscription-invoices', __('Related Payments', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced');
143 143
 				}
144 144
 }
145 145
 
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 				'wpinv-details',
149 149
 				sprintf(
150 150
 					// translators: %s is the invoice type.
151
-					__( '%s Details', 'invoicing' ),
152
-					ucfirst( $invoice->get_invoice_quote_type() )
151
+					__('%s Details', 'invoicing'),
152
+					ucfirst($invoice->get_invoice_quote_type())
153 153
 				),
154 154
 				'GetPaid_Meta_Box_Invoice_Details::output',
155 155
 				$post_type,
@@ -157,18 +157,18 @@  discard block
 block discarded – undo
157 157
 			);
158 158
 
159 159
 			// Payment details.
160
-			add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' );
160
+			add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default');
161 161
 
162 162
 			// Billing details.
163
-			add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' );
163
+			add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high');
164 164
 
165 165
 			// Invoice items.
166 166
 			add_meta_box(
167 167
 				'wpinv-items',
168 168
 				sprintf(
169 169
 					// translators: %s is the invoice type.
170
-					__( '%s Items', 'invoicing' ),
171
-					ucfirst( $invoice->get_invoice_quote_type() )
170
+					__('%s Items', 'invoicing'),
171
+					ucfirst($invoice->get_invoice_quote_type())
172 172
 				),
173 173
 				'GetPaid_Meta_Box_Invoice_Items::output',
174 174
 				$post_type,
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 				'wpinv-notes',
182 182
 				sprintf(
183 183
 					// translators: %s is the invoice type.
184
-					__( '%s Notes', 'invoicing' ),
185
-					ucfirst( $invoice->get_invoice_quote_type() )
184
+					__('%s Notes', 'invoicing'),
185
+					ucfirst($invoice->get_invoice_quote_type())
186 186
 				),
187 187
 				'WPInv_Meta_Box_Notes::output',
188 188
 				$post_type,
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
 			);
192 192
 
193 193
 			// Shipping Address.
194
-			if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) {
195
-				add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' );
194
+			if (get_post_meta($invoice->get_id(), 'shipping_address', true)) {
195
+				add_meta_box('wpinv-invoice-shipping-details', __('Shipping Address', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high');
196 196
 			}
197 197
 
198 198
 			// Payment form information.
199
-			if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) {
200
-				add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' );
199
+			if (get_post_meta($invoice->get_id(), 'payment_form_data', true)) {
200
+				add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high');
201 201
 			}
202 202
 }
203 203
 
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	 * Remove some metaboxes.
208 208
 	 */
209 209
 	public static function remove_meta_boxes() {
210
-		remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
211
-		remove_meta_box( 'postexcerpt', 'wpi_item', 'normal' );
210
+		remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
211
+		remove_meta_box('postexcerpt', 'wpi_item', 'normal');
212 212
 	}
213 213
 
214 214
 	/**
@@ -224,46 +224,46 @@  discard block
 block discarded – undo
224 224
 	 * @param  int    $post_id Post ID.
225 225
 	 * @param  object $post Post object.
226 226
 	 */
227
-	public static function save_meta_boxes( $post_id, $post ) {
228
-		$post_id = absint( $post_id );
229
-		$data    = wp_kses_post_deep( wp_unslash( $_POST ) );
227
+	public static function save_meta_boxes($post_id, $post) {
228
+		$post_id = absint($post_id);
229
+		$data    = wp_kses_post_deep(wp_unslash($_POST));
230 230
 
231 231
 		// Do not save for ajax requests.
232
-		if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
232
+		if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
233 233
 			return;
234 234
 		}
235 235
 
236 236
 		// $post_id and $post are required
237
-		if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
237
+		if (empty($post_id) || empty($post) || self::$saved_meta_boxes) {
238 238
 			return;
239 239
 		}
240 240
 
241 241
 		// Dont' save meta boxes for revisions or autosaves.
242
-		if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
242
+		if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
243 243
 			return;
244 244
 		}
245 245
 
246 246
 		// Check the nonce.
247
-		if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) {
247
+		if (empty($data['getpaid_meta_nonce']) || !wp_verify_nonce($data['getpaid_meta_nonce'], 'getpaid_meta_nonce')) {
248 248
 			return;
249 249
 		}
250 250
 
251 251
 		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
252
-		if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) {
252
+		if (empty($data['post_ID']) || absint($data['post_ID']) !== $post_id) {
253 253
 			return;
254 254
 		}
255 255
 
256 256
 		// Check user has permission to edit.
257
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
257
+		if (!current_user_can('edit_post', $post_id)) {
258 258
 			return;
259 259
 		}
260 260
 
261
-		if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
261
+		if (getpaid_is_invoice_post_type($post->post_type)) {
262 262
 
263 263
 			// We need this save event to run once to avoid potential endless loops.
264 264
 			self::$saved_meta_boxes = true;
265 265
 
266
-			return GetPaid_Meta_Box_Invoice_Address::save( $post_id, wp_kses_post_deep( $_POST ) );
266
+			return GetPaid_Meta_Box_Invoice_Address::save($post_id, wp_kses_post_deep($_POST));
267 267
 
268 268
 		}
269 269
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 		);
276 276
 
277 277
 		// Is this our post type?
278
-		if ( ! isset( $post_types_map[ $post->post_type ] ) ) {
278
+		if (!isset($post_types_map[$post->post_type])) {
279 279
 			return;
280 280
 		}
281 281
 
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
 		self::$saved_meta_boxes = true;
284 284
 
285 285
 		// Save the post.
286
-		$class = $post_types_map[ $post->post_type ];
287
-		$class::save( $post_id, wp_kses_post_deep( $_POST ), $post );
286
+		$class = $post_types_map[$post->post_type];
287
+		$class::save($post_id, wp_kses_post_deep($_POST), $post);
288 288
 
289 289
 	}
290 290
 
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2661 added lines, -2661 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'              => 0,
38
-		'status'                 => 'wpi-pending',
39
-		'version'                => '',
40
-		'date_created'           => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'              => 0,
38
+        'status'                 => 'wpi-pending',
39
+        'version'                => '',
40
+        'date_created'           => null,
41 41
         'date_modified'          => null,
42 42
         'due_date'               => null,
43 43
         'completed_date'         => null,
@@ -60,17 +60,17 @@  discard block
 block discarded – undo
60 60
         'state'                  => null,
61 61
         'zip'                    => null,
62 62
         'company'                => null,
63
-		'company_id'             => null,
63
+        'company_id'             => null,
64 64
         'vat_number'             => null,
65 65
         'vat_rate'               => null,
66 66
         'address'                => null,
67 67
         'address_confirmed'      => false,
68 68
         'shipping'               => null,
69
-		'subtotal'               => 0,
69
+        'subtotal'               => 0,
70 70
         'total_discount'         => 0,
71 71
         'total_tax'              => 0,
72
-		'total_fees'             => 0,
73
-		'total'                  => 0,
72
+        'total_fees'             => 0,
73
+        'total'                  => 0,
74 74
         'fees'                   => array(),
75 75
         'discounts'              => array(),
76 76
         'taxes'                  => array(),
@@ -82,22 +82,22 @@  discard block
 block discarded – undo
82 82
         'transaction_id'         => '',
83 83
         'currency'               => '',
84 84
         'disable_taxes'          => false,
85
-		'subscription_id'        => null,
86
-		'remote_subscription_id' => null,
87
-		'is_viewed'              => false,
88
-		'email_cc'               => '',
89
-		'template'               => 'quantity', // hours, amount only
90
-		'created_via'            => null,
85
+        'subscription_id'        => null,
86
+        'remote_subscription_id' => null,
87
+        'is_viewed'              => false,
88
+        'email_cc'               => '',
89
+        'template'               => 'quantity', // hours, amount only
90
+        'created_via'            => null,
91 91
     );
92 92
 
93 93
     /**
94
-	 * Stores meta in cache for future reads.
95
-	 *
96
-	 * A group must be set to to enable caching.
97
-	 *
98
-	 * @var string
99
-	 */
100
-	protected $cache_group = 'getpaid_invoices';
94
+     * Stores meta in cache for future reads.
95
+     *
96
+     * A group must be set to to enable caching.
97
+     *
98
+     * @var string
99
+     */
100
+    protected $cache_group = 'getpaid_invoices';
101 101
 
102 102
     /**
103 103
      * Stores a reference to the original WP_Post object
@@ -111,110 +111,110 @@  discard block
 block discarded – undo
111 111
      *
112 112
      * @var int
113 113
      */
114
-	protected $recurring_item = null;
114
+    protected $recurring_item = null;
115 115
 
116
-	/**
116
+    /**
117 117
      * Stores an array of item totals.
118
-	 *
119
-	 * e.g $totals['discount'] = array(
120
-	 *      'initial'   => 10,
121
-	 *      'recurring' => 10,
122
-	 * )
118
+     *
119
+     * e.g $totals['discount'] = array(
120
+     *      'initial'   => 10,
121
+     *      'recurring' => 10,
122
+     * )
123 123
      *
124 124
      * @var array
125 125
      */
126
-	protected $totals = array();
126
+    protected $totals = array();
127 127
 
128
-	/**
128
+    /**
129 129
      * Tax rate.
130
-	 *
130
+     *
131 131
      * @var float
132 132
      */
133
-	protected $tax_rate = 0;
133
+    protected $tax_rate = 0;
134 134
 
135
-	/**
136
-	 * Stores the status transition information.
137
-	 *
138
-	 * @since 1.0.19
139
-	 * @var bool|array
140
-	 */
141
-	protected $status_transition = false;
135
+    /**
136
+     * Stores the status transition information.
137
+     *
138
+     * @since 1.0.19
139
+     * @var bool|array
140
+     */
141
+    protected $status_transition = false;
142 142
 
143 143
     /**
144
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
145
-	 *
146
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
147
-	 */
144
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
145
+     *
146
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
147
+     */
148 148
     public function __construct( $invoice = 0 ) {
149 149
 
150 150
         parent::__construct( $invoice );
151 151
 
152
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
153
-			$this->set_id( (int) $invoice );
154
-		} elseif ( $invoice instanceof self ) {
155
-			$this->set_id( $invoice->get_id() );
156
-		} elseif ( ! empty( $invoice->ID ) ) {
157
-			$this->set_id( $invoice->ID );
158
-		} elseif ( is_array( $invoice ) ) {
159
-			$this->set_props( $invoice );
160
-
161
-			if ( isset( $invoice['ID'] ) ) {
162
-				$this->set_id( $invoice['ID'] );
163
-			}
152
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
153
+            $this->set_id( (int) $invoice );
154
+        } elseif ( $invoice instanceof self ) {
155
+            $this->set_id( $invoice->get_id() );
156
+        } elseif ( ! empty( $invoice->ID ) ) {
157
+            $this->set_id( $invoice->ID );
158
+        } elseif ( is_array( $invoice ) ) {
159
+            $this->set_props( $invoice );
160
+
161
+            if ( isset( $invoice['ID'] ) ) {
162
+                $this->set_id( $invoice['ID'] );
163
+            }
164 164
 } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
165
-			$this->set_id( $invoice_id );
166
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
167
-			$this->set_id( $invoice_id );
168
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
169
-			$this->set_id( $invoice_id );
170
-		} else {
171
-			$this->set_object_read( true );
172
-		}
165
+            $this->set_id( $invoice_id );
166
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
167
+            $this->set_id( $invoice_id );
168
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
169
+            $this->set_id( $invoice_id );
170
+        } else {
171
+            $this->set_object_read( true );
172
+        }
173 173
 
174 174
         // Load the datastore.
175
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
175
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
176 176
 
177
-		if ( $this->get_id() > 0 ) {
177
+        if ( $this->get_id() > 0 ) {
178 178
             $this->post = get_post( $this->get_id() );
179 179
             $this->ID   = $this->get_id();
180
-			$this->data_store->read( $this );
180
+            $this->data_store->read( $this );
181 181
         }
182 182
 
183 183
     }
184 184
 
185 185
     /**
186
-	 * Given an invoice key/number, it returns its id.
187
-	 *
188
-	 *
189
-	 * @static
190
-	 * @param string $value The invoice key or number
191
-	 * @param string $field Either key, transaction_id or number.
192
-	 * @since 1.0.15
193
-	 * @return int
194
-	 */
195
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
186
+     * Given an invoice key/number, it returns its id.
187
+     *
188
+     *
189
+     * @static
190
+     * @param string $value The invoice key or number
191
+     * @param string $field Either key, transaction_id or number.
192
+     * @since 1.0.15
193
+     * @return int
194
+     */
195
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
196 196
         global $wpdb;
197 197
 
198
-		// Trim the value.
199
-		$value = trim( $value );
198
+        // Trim the value.
199
+        $value = trim( $value );
200 200
 
201
-		if ( empty( $value ) ) {
202
-			return 0;
203
-		}
201
+        if ( empty( $value ) ) {
202
+            return 0;
203
+        }
204 204
 
205 205
         // Valid fields.
206 206
         $fields = array( 'key', 'number', 'transaction_id' );
207 207
 
208
-		// Ensure a field has been passed.
209
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
210
-			return 0;
211
-		}
208
+        // Ensure a field has been passed.
209
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
210
+            return 0;
211
+        }
212 212
 
213
-		// Maybe retrieve from the cache.
214
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
-		if ( false !== $invoice_id ) {
216
-			return $invoice_id;
217
-		}
213
+        // Maybe retrieve from the cache.
214
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
+        if ( false !== $invoice_id ) {
216
+            return $invoice_id;
217
+        }
218 218
 
219 219
         // Fetch from the db.
220 220
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
223 223
         );
224 224
 
225
-		// Update the cache with our data
226
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
225
+        // Update the cache with our data
226
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
227 227
 
228
-		return $invoice_id;
228
+        return $invoice_id;
229 229
     }
230 230
 
231 231
     /**
@@ -251,83 +251,83 @@  discard block
 block discarded – undo
251 251
     */
252 252
 
253 253
     /**
254
-	 * Get parent invoice ID.
255
-	 *
256
-	 * @since 1.0.19
257
-	 * @param  string $context View or edit context.
258
-	 * @return int
259
-	 */
260
-	public function get_parent_id( $context = 'view' ) {
261
-		return (int) $this->get_prop( 'parent_id', $context );
254
+     * Get parent invoice ID.
255
+     *
256
+     * @since 1.0.19
257
+     * @param  string $context View or edit context.
258
+     * @return int
259
+     */
260
+    public function get_parent_id( $context = 'view' ) {
261
+        return (int) $this->get_prop( 'parent_id', $context );
262 262
     }
263 263
 
264 264
     /**
265
-	 * Get parent invoice.
266
-	 *
267
-	 * @since 1.0.19
268
-	 * @return WPInv_Invoice
269
-	 */
265
+     * Get parent invoice.
266
+     *
267
+     * @since 1.0.19
268
+     * @return WPInv_Invoice
269
+     */
270 270
     public function get_parent_payment() {
271 271
         return new WPInv_Invoice( $this->get_parent_id() );
272 272
     }
273 273
 
274 274
     /**
275
-	 * Alias for self::get_parent_payment().
276
-	 *
277
-	 * @since 1.0.19
278
-	 * @return WPInv_Invoice
279
-	 */
275
+     * Alias for self::get_parent_payment().
276
+     *
277
+     * @since 1.0.19
278
+     * @return WPInv_Invoice
279
+     */
280 280
     public function get_parent() {
281 281
         return $this->get_parent_payment();
282 282
     }
283 283
 
284 284
     /**
285
-	 * Get invoice status.
286
-	 *
287
-	 * @since 1.0.19
288
-	 * @param  string $context View or edit context.
289
-	 * @return string
290
-	 */
291
-	public function get_status( $context = 'view' ) {
292
-		return $this->get_prop( 'status', $context );
293
-	}
285
+     * Get invoice status.
286
+     *
287
+     * @since 1.0.19
288
+     * @param  string $context View or edit context.
289
+     * @return string
290
+     */
291
+    public function get_status( $context = 'view' ) {
292
+        return $this->get_prop( 'status', $context );
293
+    }
294 294
 
295
-	/**
296
-	 * Retrieves an array of possible invoice statuses.
297
-	 *
298
-	 * @since 1.0.19
299
-	 * @return array
300
-	 */
301
-	public function get_all_statuses() {
302
-		return wpinv_get_invoice_statuses( true, true, $this );
295
+    /**
296
+     * Retrieves an array of possible invoice statuses.
297
+     *
298
+     * @since 1.0.19
299
+     * @return array
300
+     */
301
+    public function get_all_statuses() {
302
+        return wpinv_get_invoice_statuses( true, true, $this );
303 303
     }
304 304
 
305 305
     /**
306
-	 * Get invoice status nice name.
307
-	 *
308
-	 * @since 1.0.19
309
-	 * @return string
310
-	 */
306
+     * Get invoice status nice name.
307
+     *
308
+     * @since 1.0.19
309
+     * @return string
310
+     */
311 311
     public function get_status_nicename() {
312
-		$statuses = $this->get_all_statuses();
312
+        $statuses = $this->get_all_statuses();
313 313
 
314 314
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
315 315
 
316 316
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
317 317
     }
318 318
 
319
-	/**
320
-	 * Retrieves the invoice status class
321
-	 *
322
-	 * @since  1.0.19
323
-	 * @return string
324
-	 */
325
-	public function get_status_class() {
326
-		$statuses = getpaid_get_invoice_status_classes();
327
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
328
-	}
319
+    /**
320
+     * Retrieves the invoice status class
321
+     *
322
+     * @since  1.0.19
323
+     * @return string
324
+     */
325
+    public function get_status_class() {
326
+        $statuses = getpaid_get_invoice_status_classes();
327
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
328
+    }
329 329
 
330
-	/**
330
+    /**
331 331
      * Retrieves the invoice status label html
332 332
      *
333 333
      * @since  1.0.0
@@ -335,263 +335,263 @@  discard block
 block discarded – undo
335 335
      */
336 336
     public function get_status_label_html() {
337 337
 
338
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
339
-		$status       = sanitize_html_class( $this->get_status() );
340
-		$class        = esc_attr( $this->get_status_class() );
341
-
342
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
343
-	}
344
-
345
-    /**
346
-	 * Get plugin version when the invoice was created.
347
-	 *
348
-	 * @since 1.0.19
349
-	 * @param  string $context View or edit context.
350
-	 * @return string
351
-	 */
352
-	public function get_version( $context = 'view' ) {
353
-		return $this->get_prop( 'version', $context );
354
-	}
355
-
356
-	/**
357
-	 * @deprecated
358
-	 */
359
-	public function get_invoice_date( $format = true ) {
360
-		$date      = getpaid_format_date( $this->get_date_completed() );
361
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
362
-		$formatted = getpaid_format_date( $date );
363
-
364
-		if ( $format ) {
365
-			return $formatted;
366
-		}
367
-
368
-		return empty( $formatted ) ? '' : $date;
369
-
370
-    }
371
-
372
-    /**
373
-	 * Get date when the invoice was created.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_date_created( $context = 'view' ) {
380
-		return $this->get_prop( 'date_created', $context );
381
-	}
382
-
383
-	/**
384
-	 * Alias for self::get_date_created().
385
-	 *
386
-	 * @since 1.0.19
387
-	 * @param  string $context View or edit context.
388
-	 * @return string
389
-	 */
390
-	public function get_created_date( $context = 'view' ) {
391
-		return $this->get_date_created( $context );
392
-    }
393
-
394
-    /**
395
-	 * Get GMT date when the invoice was created.
396
-	 *
397
-	 * @since 1.0.19
398
-	 * @param  string $context View or edit context.
399
-	 * @return string
400
-	 */
401
-	public function get_date_created_gmt( $context = 'view' ) {
338
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
339
+        $status       = sanitize_html_class( $this->get_status() );
340
+        $class        = esc_attr( $this->get_status_class() );
341
+
342
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
343
+    }
344
+
345
+    /**
346
+     * Get plugin version when the invoice was created.
347
+     *
348
+     * @since 1.0.19
349
+     * @param  string $context View or edit context.
350
+     * @return string
351
+     */
352
+    public function get_version( $context = 'view' ) {
353
+        return $this->get_prop( 'version', $context );
354
+    }
355
+
356
+    /**
357
+     * @deprecated
358
+     */
359
+    public function get_invoice_date( $format = true ) {
360
+        $date      = getpaid_format_date( $this->get_date_completed() );
361
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
362
+        $formatted = getpaid_format_date( $date );
363
+
364
+        if ( $format ) {
365
+            return $formatted;
366
+        }
367
+
368
+        return empty( $formatted ) ? '' : $date;
369
+
370
+    }
371
+
372
+    /**
373
+     * Get date when the invoice was created.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_date_created( $context = 'view' ) {
380
+        return $this->get_prop( 'date_created', $context );
381
+    }
382
+
383
+    /**
384
+     * Alias for self::get_date_created().
385
+     *
386
+     * @since 1.0.19
387
+     * @param  string $context View or edit context.
388
+     * @return string
389
+     */
390
+    public function get_created_date( $context = 'view' ) {
391
+        return $this->get_date_created( $context );
392
+    }
393
+
394
+    /**
395
+     * Get GMT date when the invoice was created.
396
+     *
397
+     * @since 1.0.19
398
+     * @param  string $context View or edit context.
399
+     * @return string
400
+     */
401
+    public function get_date_created_gmt( $context = 'view' ) {
402 402
         $date = $this->get_date_created( $context );
403 403
 
404 404
         if ( $date ) {
405 405
             $date = get_gmt_from_date( $date );
406 406
         }
407
-		return $date;
407
+        return $date;
408 408
     }
409 409
 
410 410
     /**
411
-	 * Get date when the invoice was last modified.
412
-	 *
413
-	 * @since 1.0.19
414
-	 * @param  string $context View or edit context.
415
-	 * @return string
416
-	 */
417
-	public function get_date_modified( $context = 'view' ) {
418
-		return $this->get_prop( 'date_modified', $context );
419
-	}
411
+     * Get date when the invoice was last modified.
412
+     *
413
+     * @since 1.0.19
414
+     * @param  string $context View or edit context.
415
+     * @return string
416
+     */
417
+    public function get_date_modified( $context = 'view' ) {
418
+        return $this->get_prop( 'date_modified', $context );
419
+    }
420 420
 
421
-	/**
422
-	 * Alias for self::get_date_modified().
423
-	 *
424
-	 * @since 1.0.19
425
-	 * @param  string $context View or edit context.
426
-	 * @return string
427
-	 */
428
-	public function get_modified_date( $context = 'view' ) {
429
-		return $this->get_date_modified( $context );
421
+    /**
422
+     * Alias for self::get_date_modified().
423
+     *
424
+     * @since 1.0.19
425
+     * @param  string $context View or edit context.
426
+     * @return string
427
+     */
428
+    public function get_modified_date( $context = 'view' ) {
429
+        return $this->get_date_modified( $context );
430 430
     }
431 431
 
432 432
     /**
433
-	 * Get GMT date when the invoice was last modified.
434
-	 *
435
-	 * @since 1.0.19
436
-	 * @param  string $context View or edit context.
437
-	 * @return string
438
-	 */
439
-	public function get_date_modified_gmt( $context = 'view' ) {
433
+     * Get GMT date when the invoice was last modified.
434
+     *
435
+     * @since 1.0.19
436
+     * @param  string $context View or edit context.
437
+     * @return string
438
+     */
439
+    public function get_date_modified_gmt( $context = 'view' ) {
440 440
         $date = $this->get_date_modified( $context );
441 441
 
442 442
         if ( $date ) {
443 443
             $date = get_gmt_from_date( $date );
444 444
         }
445
-		return $date;
445
+        return $date;
446 446
     }
447 447
 
448 448
     /**
449
-	 * Get the invoice due date.
450
-	 *
451
-	 * @since 1.0.19
452
-	 * @param  string $context View or edit context.
453
-	 * @return string
454
-	 */
455
-	public function get_due_date( $context = 'view' ) {
456
-		return $this->get_prop( 'due_date', $context );
449
+     * Get the invoice due date.
450
+     *
451
+     * @since 1.0.19
452
+     * @param  string $context View or edit context.
453
+     * @return string
454
+     */
455
+    public function get_due_date( $context = 'view' ) {
456
+        return $this->get_prop( 'due_date', $context );
457 457
     }
458 458
 
459 459
     /**
460
-	 * Alias for self::get_due_date().
461
-	 *
462
-	 * @since 1.0.19
463
-	 * @param  string $context View or edit context.
464
-	 * @return string
465
-	 */
466
-	public function get_date_due( $context = 'view' ) {
467
-		return $this->get_due_date( $context );
460
+     * Alias for self::get_due_date().
461
+     *
462
+     * @since 1.0.19
463
+     * @param  string $context View or edit context.
464
+     * @return string
465
+     */
466
+    public function get_date_due( $context = 'view' ) {
467
+        return $this->get_due_date( $context );
468 468
     }
469 469
 
470 470
     /**
471
-	 * Get the invoice GMT due date.
472
-	 *
473
-	 * @since 1.0.19
474
-	 * @param  string $context View or edit context.
475
-	 * @return string
476
-	 */
477
-	public function get_due_date_gmt( $context = 'view' ) {
471
+     * Get the invoice GMT due date.
472
+     *
473
+     * @since 1.0.19
474
+     * @param  string $context View or edit context.
475
+     * @return string
476
+     */
477
+    public function get_due_date_gmt( $context = 'view' ) {
478 478
         $date = $this->get_due_date( $context );
479 479
 
480 480
         if ( $date ) {
481 481
             $date = get_gmt_from_date( $date );
482 482
         }
483
-		return $date;
483
+        return $date;
484 484
     }
485 485
 
486 486
     /**
487
-	 * Alias for self::get_due_date_gmt().
488
-	 *
489
-	 * @since 1.0.19
490
-	 * @param  string $context View or edit context.
491
-	 * @return string
492
-	 */
493
-	public function get_gmt_date_due( $context = 'view' ) {
494
-		return $this->get_due_date_gmt( $context );
487
+     * Alias for self::get_due_date_gmt().
488
+     *
489
+     * @since 1.0.19
490
+     * @param  string $context View or edit context.
491
+     * @return string
492
+     */
493
+    public function get_gmt_date_due( $context = 'view' ) {
494
+        return $this->get_due_date_gmt( $context );
495 495
     }
496 496
 
497 497
     /**
498
-	 * Get date when the invoice was completed.
499
-	 *
500
-	 * @since 1.0.19
501
-	 * @param  string $context View or edit context.
502
-	 * @return string
503
-	 */
504
-	public function get_completed_date( $context = 'view' ) {
505
-		return $this->get_prop( 'completed_date', $context );
498
+     * Get date when the invoice was completed.
499
+     *
500
+     * @since 1.0.19
501
+     * @param  string $context View or edit context.
502
+     * @return string
503
+     */
504
+    public function get_completed_date( $context = 'view' ) {
505
+        return $this->get_prop( 'completed_date', $context );
506 506
     }
507 507
 
508 508
     /**
509
-	 * Alias for self::get_completed_date().
510
-	 *
511
-	 * @since 1.0.19
512
-	 * @param  string $context View or edit context.
513
-	 * @return string
514
-	 */
515
-	public function get_date_completed( $context = 'view' ) {
516
-		return $this->get_completed_date( $context );
509
+     * Alias for self::get_completed_date().
510
+     *
511
+     * @since 1.0.19
512
+     * @param  string $context View or edit context.
513
+     * @return string
514
+     */
515
+    public function get_date_completed( $context = 'view' ) {
516
+        return $this->get_completed_date( $context );
517 517
     }
518 518
 
519 519
     /**
520
-	 * Get GMT date when the invoice was was completed.
521
-	 *
522
-	 * @since 1.0.19
523
-	 * @param  string $context View or edit context.
524
-	 * @return string
525
-	 */
526
-	public function get_completed_date_gmt( $context = 'view' ) {
520
+     * Get GMT date when the invoice was was completed.
521
+     *
522
+     * @since 1.0.19
523
+     * @param  string $context View or edit context.
524
+     * @return string
525
+     */
526
+    public function get_completed_date_gmt( $context = 'view' ) {
527 527
         $date = $this->get_completed_date( $context );
528 528
 
529 529
         if ( $date ) {
530 530
             $date = get_gmt_from_date( $date );
531 531
         }
532
-		return $date;
532
+        return $date;
533 533
     }
534 534
 
535 535
     /**
536
-	 * Alias for self::get_completed_date_gmt().
537
-	 *
538
-	 * @since 1.0.19
539
-	 * @param  string $context View or edit context.
540
-	 * @return string
541
-	 */
542
-	public function get_gmt_completed_date( $context = 'view' ) {
543
-		return $this->get_completed_date_gmt( $context );
536
+     * Alias for self::get_completed_date_gmt().
537
+     *
538
+     * @since 1.0.19
539
+     * @param  string $context View or edit context.
540
+     * @return string
541
+     */
542
+    public function get_gmt_completed_date( $context = 'view' ) {
543
+        return $this->get_completed_date_gmt( $context );
544 544
     }
545 545
 
546 546
     /**
547
-	 * Get the invoice number.
548
-	 *
549
-	 * @since 1.0.19
550
-	 * @param  string $context View or edit context.
551
-	 * @return string
552
-	 */
553
-	public function get_number( $context = 'view' ) {
554
-		$number = $this->get_prop( 'number', $context );
547
+     * Get the invoice number.
548
+     *
549
+     * @since 1.0.19
550
+     * @param  string $context View or edit context.
551
+     * @return string
552
+     */
553
+    public function get_number( $context = 'view' ) {
554
+        $number = $this->get_prop( 'number', $context );
555 555
 
556
-		if ( empty( $number ) ) {
557
-			$number = $this->generate_number();
558
-			$this->set_number( $this->generate_number() );
559
-		}
556
+        if ( empty( $number ) ) {
557
+            $number = $this->generate_number();
558
+            $this->set_number( $this->generate_number() );
559
+        }
560 560
 
561
-		return $number;
561
+        return $number;
562 562
     }
563 563
 
564
-	/**
565
-	 * Set the invoice number.
566
-	 *
567
-	 * @since 1.0.19
568
-	 */
569
-	public function maybe_set_number() {
564
+    /**
565
+     * Set the invoice number.
566
+     *
567
+     * @since 1.0.19
568
+     */
569
+    public function maybe_set_number() {
570 570
         $number = $this->get_number();
571 571
 
572 572
         if ( empty( $number ) || $this->get_id() == $number ) {
573
-			$this->set_number( $this->generate_number() );
573
+            $this->set_number( $this->generate_number() );
574 574
         }
575 575
 
576
-	}
576
+    }
577 577
 
578 578
     /**
579
-	 * Get the invoice key.
580
-	 *
581
-	 * @since 1.0.19
582
-	 * @param  string $context View or edit context.
583
-	 * @return string
584
-	 */
585
-	public function get_key( $context = 'view' ) {
579
+     * Get the invoice key.
580
+     *
581
+     * @since 1.0.19
582
+     * @param  string $context View or edit context.
583
+     * @return string
584
+     */
585
+    public function get_key( $context = 'view' ) {
586 586
         return $this->get_prop( 'key', $context );
587
-	}
588
-
589
-	/**
590
-	 * Set the invoice key.
591
-	 *
592
-	 * @since 1.0.19
593
-	 */
594
-	public function maybe_set_key() {
587
+    }
588
+
589
+    /**
590
+     * Set the invoice key.
591
+     *
592
+     * @since 1.0.19
593
+     */
594
+    public function maybe_set_key() {
595 595
         $key = $this->get_key();
596 596
 
597 597
         if ( empty( $key ) ) {
@@ -602,140 +602,140 @@  discard block
 block discarded – undo
602 602
     }
603 603
 
604 604
     /**
605
-	 * Get the invoice type.
606
-	 *
607
-	 * @since 1.0.19
608
-	 * @param  string $context View or edit context.
609
-	 * @return string
610
-	 */
611
-	public function get_type( $context = 'view' ) {
605
+     * Get the invoice type.
606
+     *
607
+     * @since 1.0.19
608
+     * @param  string $context View or edit context.
609
+     * @return string
610
+     */
611
+    public function get_type( $context = 'view' ) {
612 612
         return $this->get_prop( 'type', $context );
613
-	}
614
-
615
-	/**
616
-	 * Returns the post type name.
617
-	 *
618
-	 * @since 1.0.19
619
-	 * @return string
620
-	 */
621
-	public function get_invoice_quote_type() {
613
+    }
614
+
615
+    /**
616
+     * Returns the post type name.
617
+     *
618
+     * @since 1.0.19
619
+     * @return string
620
+     */
621
+    public function get_invoice_quote_type() {
622 622
         return getpaid_get_post_type_label( $this->get_post_type(), false );
623 623
     }
624 624
 
625 625
     /**
626
-	 * Get the invoice post type label.
627
-	 *
628
-	 * @since 1.0.19
629
-	 * @param  string $context View or edit context.
630
-	 * @return string
631
-	 */
632
-	public function get_label( $context = 'view' ) {
626
+     * Get the invoice post type label.
627
+     *
628
+     * @since 1.0.19
629
+     * @param  string $context View or edit context.
630
+     * @return string
631
+     */
632
+    public function get_label( $context = 'view' ) {
633 633
         return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
634
-	}
635
-
636
-	/**
637
-	 * Get the invoice post type.
638
-	 *
639
-	 * @since 1.0.19
640
-	 * @param  string $context View or edit context.
641
-	 * @return string
642
-	 */
643
-	public function get_post_type( $context = 'view' ) {
634
+    }
635
+
636
+    /**
637
+     * Get the invoice post type.
638
+     *
639
+     * @since 1.0.19
640
+     * @param  string $context View or edit context.
641
+     * @return string
642
+     */
643
+    public function get_post_type( $context = 'view' ) {
644 644
         return $this->get_prop( 'post_type', $context );
645 645
     }
646 646
 
647 647
     /**
648
-	 * Get the invoice mode.
649
-	 *
650
-	 * @since 1.0.19
651
-	 * @param  string $context View or edit context.
652
-	 * @return string
653
-	 */
654
-	public function get_mode( $context = 'view' ) {
648
+     * Get the invoice mode.
649
+     *
650
+     * @since 1.0.19
651
+     * @param  string $context View or edit context.
652
+     * @return string
653
+     */
654
+    public function get_mode( $context = 'view' ) {
655 655
         return $this->get_prop( 'mode', $context );
656 656
     }
657 657
 
658 658
     /**
659
-	 * Get the invoice path.
660
-	 *
661
-	 * @since 1.0.19
662
-	 * @param  string $context View or edit context.
663
-	 * @return string
664
-	 */
665
-	public function get_path( $context = 'view' ) {
659
+     * Get the invoice path.
660
+     *
661
+     * @since 1.0.19
662
+     * @param  string $context View or edit context.
663
+     * @return string
664
+     */
665
+    public function get_path( $context = 'view' ) {
666 666
         $path   = $this->get_prop( 'path', $context );
667
-		$prefix = $this->get_type();
667
+        $prefix = $this->get_type();
668 668
 
669
-		if ( 0 !== strpos( $path, $prefix ) ) {
670
-			$path = sanitize_title( $prefix . '-' . $this->get_id() );
671
-			$this->set_path( $path );
672
-		}
669
+        if ( 0 !== strpos( $path, $prefix ) ) {
670
+            $path = sanitize_title( $prefix . '-' . $this->get_id() );
671
+            $this->set_path( $path );
672
+        }
673 673
 
674
-		return $path;
674
+        return $path;
675 675
     }
676 676
 
677 677
     /**
678
-	 * Get the invoice name/title.
679
-	 *
680
-	 * @since 1.0.19
681
-	 * @param  string $context View or edit context.
682
-	 * @return string
683
-	 */
684
-	public function get_name( $context = 'view' ) {
678
+     * Get the invoice name/title.
679
+     *
680
+     * @since 1.0.19
681
+     * @param  string $context View or edit context.
682
+     * @return string
683
+     */
684
+    public function get_name( $context = 'view' ) {
685 685
         return $this->get_prop( 'title', $context );
686 686
     }
687 687
 
688 688
     /**
689
-	 * Alias of self::get_name().
690
-	 *
691
-	 * @since 1.0.19
692
-	 * @param  string $context View or edit context.
693
-	 * @return string
694
-	 */
695
-	public function get_title( $context = 'view' ) {
696
-		return $this->get_name( $context );
689
+     * Alias of self::get_name().
690
+     *
691
+     * @since 1.0.19
692
+     * @param  string $context View or edit context.
693
+     * @return string
694
+     */
695
+    public function get_title( $context = 'view' ) {
696
+        return $this->get_name( $context );
697 697
     }
698 698
 
699 699
     /**
700
-	 * Get the invoice description.
701
-	 *
702
-	 * @since 1.0.19
703
-	 * @param  string $context View or edit context.
704
-	 * @return string
705
-	 */
706
-	public function get_description( $context = 'view' ) {
707
-		return $this->get_prop( 'description', $context );
700
+     * Get the invoice description.
701
+     *
702
+     * @since 1.0.19
703
+     * @param  string $context View or edit context.
704
+     * @return string
705
+     */
706
+    public function get_description( $context = 'view' ) {
707
+        return $this->get_prop( 'description', $context );
708 708
     }
709 709
 
710 710
     /**
711
-	 * Alias of self::get_description().
712
-	 *
713
-	 * @since 1.0.19
714
-	 * @param  string $context View or edit context.
715
-	 * @return string
716
-	 */
717
-	public function get_excerpt( $context = 'view' ) {
718
-		return $this->get_description( $context );
711
+     * Alias of self::get_description().
712
+     *
713
+     * @since 1.0.19
714
+     * @param  string $context View or edit context.
715
+     * @return string
716
+     */
717
+    public function get_excerpt( $context = 'view' ) {
718
+        return $this->get_description( $context );
719 719
     }
720 720
 
721 721
     /**
722
-	 * Alias of self::get_description().
723
-	 *
724
-	 * @since 1.0.19
725
-	 * @param  string $context View or edit context.
726
-	 * @return string
727
-	 */
728
-	public function get_summary( $context = 'view' ) {
729
-		return $this->get_description( $context );
722
+     * Alias of self::get_description().
723
+     *
724
+     * @since 1.0.19
725
+     * @param  string $context View or edit context.
726
+     * @return string
727
+     */
728
+    public function get_summary( $context = 'view' ) {
729
+        return $this->get_description( $context );
730 730
     }
731 731
 
732 732
     /**
733
-	 * Returns the user info.
734
-	 *
735
-	 * @since 1.0.19
733
+     * Returns the user info.
734
+     *
735
+     * @since 1.0.19
736 736
      * @param  string $context View or edit context.
737
-	 * @return array
738
-	 */
737
+     * @return array
738
+     */
739 739
     public function get_user_info( $context = 'view' ) {
740 740
 
741 741
         $user_info = array(
@@ -750,683 +750,683 @@  discard block
 block discarded – undo
750 750
             'state'      => $this->get_state( $context ),
751 751
             'zip'        => $this->get_zip( $context ),
752 752
             'company'    => $this->get_company( $context ),
753
-			'company_id' => $this->get_company_id( $context ),
753
+            'company_id' => $this->get_company_id( $context ),
754 754
             'vat_number' => $this->get_vat_number( $context ),
755 755
             'discount'   => $this->get_discount_code( $context ),
756
-		);
756
+        );
757 757
 
758
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
758
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
759 759
 
760 760
     }
761 761
 
762 762
     /**
763
-	 * Get the customer id.
764
-	 *
765
-	 * @since 1.0.19
766
-	 * @param  string $context View or edit context.
767
-	 * @return int
768
-	 */
769
-	public function get_author( $context = 'view' ) {
770
-		return (int) $this->get_prop( 'author', $context );
763
+     * Get the customer id.
764
+     *
765
+     * @since 1.0.19
766
+     * @param  string $context View or edit context.
767
+     * @return int
768
+     */
769
+    public function get_author( $context = 'view' ) {
770
+        return (int) $this->get_prop( 'author', $context );
771 771
     }
772 772
 
773 773
     /**
774
-	 * Alias of self::get_author().
775
-	 *
776
-	 * @since 1.0.19
777
-	 * @param  string $context View or edit context.
778
-	 * @return int
779
-	 */
780
-	public function get_user_id( $context = 'view' ) {
781
-		return $this->get_author( $context );
774
+     * Alias of self::get_author().
775
+     *
776
+     * @since 1.0.19
777
+     * @param  string $context View or edit context.
778
+     * @return int
779
+     */
780
+    public function get_user_id( $context = 'view' ) {
781
+        return $this->get_author( $context );
782 782
     }
783 783
 
784
-     /**
785
-	 * Alias of self::get_author().
786
-	 *
787
-	 * @since 1.0.19
788
-	 * @param  string $context View or edit context.
789
-	 * @return int
790
-	 */
791
-	public function get_customer_id( $context = 'view' ) {
792
-		return $this->get_author( $context );
784
+        /**
785
+         * Alias of self::get_author().
786
+         *
787
+         * @since 1.0.19
788
+         * @param  string $context View or edit context.
789
+         * @return int
790
+         */
791
+    public function get_customer_id( $context = 'view' ) {
792
+        return $this->get_author( $context );
793 793
     }
794 794
 
795 795
     /**
796
-	 * Get the customer's ip.
797
-	 *
798
-	 * @since 1.0.19
799
-	 * @param  string $context View or edit context.
800
-	 * @return string
801
-	 */
802
-	public function get_ip( $context = 'view' ) {
803
-		return $this->get_prop( 'user_ip', $context );
796
+     * Get the customer's ip.
797
+     *
798
+     * @since 1.0.19
799
+     * @param  string $context View or edit context.
800
+     * @return string
801
+     */
802
+    public function get_ip( $context = 'view' ) {
803
+        return $this->get_prop( 'user_ip', $context );
804 804
     }
805 805
 
806 806
     /**
807
-	 * Alias of self::get_ip().
808
-	 *
809
-	 * @since 1.0.19
810
-	 * @param  string $context View or edit context.
811
-	 * @return string
812
-	 */
813
-	public function get_user_ip( $context = 'view' ) {
814
-		return $this->get_ip( $context );
807
+     * Alias of self::get_ip().
808
+     *
809
+     * @since 1.0.19
810
+     * @param  string $context View or edit context.
811
+     * @return string
812
+     */
813
+    public function get_user_ip( $context = 'view' ) {
814
+        return $this->get_ip( $context );
815 815
     }
816 816
 
817
-     /**
818
-	 * Alias of self::get_ip().
819
-	 *
820
-	 * @since 1.0.19
821
-	 * @param  string $context View or edit context.
822
-	 * @return string
823
-	 */
824
-	public function get_customer_ip( $context = 'view' ) {
825
-		return $this->get_ip( $context );
817
+        /**
818
+         * Alias of self::get_ip().
819
+         *
820
+         * @since 1.0.19
821
+         * @param  string $context View or edit context.
822
+         * @return string
823
+         */
824
+    public function get_customer_ip( $context = 'view' ) {
825
+        return $this->get_ip( $context );
826 826
     }
827 827
 
828 828
     /**
829
-	 * Get the customer's first name.
830
-	 *
831
-	 * @since 1.0.19
832
-	 * @param  string $context View or edit context.
833
-	 * @return string
834
-	 */
835
-	public function get_first_name( $context = 'view' ) {
836
-		return $this->get_prop( 'first_name', $context );
829
+     * Get the customer's first name.
830
+     *
831
+     * @since 1.0.19
832
+     * @param  string $context View or edit context.
833
+     * @return string
834
+     */
835
+    public function get_first_name( $context = 'view' ) {
836
+        return $this->get_prop( 'first_name', $context );
837 837
     }
838 838
 
839 839
     /**
840
-	 * Alias of self::get_first_name().
841
-	 *
842
-	 * @since 1.0.19
843
-	 * @param  string $context View or edit context.
844
-	 * @return string
845
-	 */
846
-	public function get_user_first_name( $context = 'view' ) {
847
-		return $this->get_first_name( $context );
840
+     * Alias of self::get_first_name().
841
+     *
842
+     * @since 1.0.19
843
+     * @param  string $context View or edit context.
844
+     * @return string
845
+     */
846
+    public function get_user_first_name( $context = 'view' ) {
847
+        return $this->get_first_name( $context );
848 848
     }
849 849
 
850
-     /**
851
-	 * Alias of self::get_first_name().
852
-	 *
853
-	 * @since 1.0.19
854
-	 * @param  string $context View or edit context.
855
-	 * @return string
856
-	 */
857
-	public function get_customer_first_name( $context = 'view' ) {
858
-		return $this->get_first_name( $context );
850
+        /**
851
+         * Alias of self::get_first_name().
852
+         *
853
+         * @since 1.0.19
854
+         * @param  string $context View or edit context.
855
+         * @return string
856
+         */
857
+    public function get_customer_first_name( $context = 'view' ) {
858
+        return $this->get_first_name( $context );
859 859
     }
860 860
 
861 861
     /**
862
-	 * Get the customer's last name.
863
-	 *
864
-	 * @since 1.0.19
865
-	 * @param  string $context View or edit context.
866
-	 * @return string
867
-	 */
868
-	public function get_last_name( $context = 'view' ) {
869
-		return $this->get_prop( 'last_name', $context );
862
+     * Get the customer's last name.
863
+     *
864
+     * @since 1.0.19
865
+     * @param  string $context View or edit context.
866
+     * @return string
867
+     */
868
+    public function get_last_name( $context = 'view' ) {
869
+        return $this->get_prop( 'last_name', $context );
870 870
     }
871 871
 
872 872
     /**
873
-	 * Alias of self::get_last_name().
874
-	 *
875
-	 * @since 1.0.19
876
-	 * @param  string $context View or edit context.
877
-	 * @return string
878
-	 */
879
-	public function get_user_last_name( $context = 'view' ) {
880
-		return $this->get_last_name( $context );
873
+     * Alias of self::get_last_name().
874
+     *
875
+     * @since 1.0.19
876
+     * @param  string $context View or edit context.
877
+     * @return string
878
+     */
879
+    public function get_user_last_name( $context = 'view' ) {
880
+        return $this->get_last_name( $context );
881 881
     }
882 882
 
883 883
     /**
884
-	 * Alias of self::get_last_name().
885
-	 *
886
-	 * @since 1.0.19
887
-	 * @param  string $context View or edit context.
888
-	 * @return string
889
-	 */
890
-	public function get_customer_last_name( $context = 'view' ) {
891
-		return $this->get_last_name( $context );
884
+     * Alias of self::get_last_name().
885
+     *
886
+     * @since 1.0.19
887
+     * @param  string $context View or edit context.
888
+     * @return string
889
+     */
890
+    public function get_customer_last_name( $context = 'view' ) {
891
+        return $this->get_last_name( $context );
892 892
     }
893 893
 
894 894
     /**
895
-	 * Get the customer's full name.
896
-	 *
897
-	 * @since 1.0.19
898
-	 * @param  string $context View or edit context.
899
-	 * @return string
900
-	 */
901
-	public function get_full_name( $context = 'view' ) {
902
-		$name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
895
+     * Get the customer's full name.
896
+     *
897
+     * @since 1.0.19
898
+     * @param  string $context View or edit context.
899
+     * @return string
900
+     */
901
+    public function get_full_name( $context = 'view' ) {
902
+        $name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
903 903
 
904
-		if ( ! $name ) {
905
-			$user = get_userdata( $this->get_author( $context ) );
904
+        if ( ! $name ) {
905
+            $user = get_userdata( $this->get_author( $context ) );
906 906
 
907
-			if ( $user ) {
908
-				$name = $user->display_name;
909
-			}
910
-		}
907
+            if ( $user ) {
908
+                $name = $user->display_name;
909
+            }
910
+        }
911 911
 
912
-		if ( ! $name ) {
913
-			$name = $this->get_email( $context );
914
-		}
912
+        if ( ! $name ) {
913
+            $name = $this->get_email( $context );
914
+        }
915 915
 
916
-		return apply_filters( 'wpinv_invoice_user_full_name', $name, $this );
916
+        return apply_filters( 'wpinv_invoice_user_full_name', $name, $this );
917 917
     }
918 918
 
919 919
     /**
920
-	 * Alias of self::get_full_name().
921
-	 *
922
-	 * @since 1.0.19
923
-	 * @param  string $context View or edit context.
924
-	 * @return string
925
-	 */
926
-	public function get_user_full_name( $context = 'view' ) {
927
-		return $this->get_full_name( $context );
920
+     * Alias of self::get_full_name().
921
+     *
922
+     * @since 1.0.19
923
+     * @param  string $context View or edit context.
924
+     * @return string
925
+     */
926
+    public function get_user_full_name( $context = 'view' ) {
927
+        return $this->get_full_name( $context );
928 928
     }
929 929
 
930 930
     /**
931
-	 * Alias of self::get_full_name().
932
-	 *
933
-	 * @since 1.0.19
934
-	 * @param  string $context View or edit context.
935
-	 * @return string
936
-	 */
937
-	public function get_customer_full_name( $context = 'view' ) {
938
-		return $this->get_full_name( $context );
931
+     * Alias of self::get_full_name().
932
+     *
933
+     * @since 1.0.19
934
+     * @param  string $context View or edit context.
935
+     * @return string
936
+     */
937
+    public function get_customer_full_name( $context = 'view' ) {
938
+        return $this->get_full_name( $context );
939 939
     }
940 940
 
941 941
     /**
942
-	 * Get the customer's phone number.
943
-	 *
944
-	 * @since 1.0.19
945
-	 * @param  string $context View or edit context.
946
-	 * @return string
947
-	 */
948
-	public function get_phone( $context = 'view' ) {
949
-		return $this->get_prop( 'phone', $context );
942
+     * Get the customer's phone number.
943
+     *
944
+     * @since 1.0.19
945
+     * @param  string $context View or edit context.
946
+     * @return string
947
+     */
948
+    public function get_phone( $context = 'view' ) {
949
+        return $this->get_prop( 'phone', $context );
950 950
     }
951 951
 
952 952
     /**
953
-	 * Alias of self::get_phone().
954
-	 *
955
-	 * @since 1.0.19
956
-	 * @param  string $context View or edit context.
957
-	 * @return string
958
-	 */
959
-	public function get_phone_number( $context = 'view' ) {
960
-		return $this->get_phone( $context );
953
+     * Alias of self::get_phone().
954
+     *
955
+     * @since 1.0.19
956
+     * @param  string $context View or edit context.
957
+     * @return string
958
+     */
959
+    public function get_phone_number( $context = 'view' ) {
960
+        return $this->get_phone( $context );
961 961
     }
962 962
 
963 963
     /**
964
-	 * Alias of self::get_phone().
965
-	 *
966
-	 * @since 1.0.19
967
-	 * @param  string $context View or edit context.
968
-	 * @return string
969
-	 */
970
-	public function get_user_phone( $context = 'view' ) {
971
-		return $this->get_phone( $context );
964
+     * Alias of self::get_phone().
965
+     *
966
+     * @since 1.0.19
967
+     * @param  string $context View or edit context.
968
+     * @return string
969
+     */
970
+    public function get_user_phone( $context = 'view' ) {
971
+        return $this->get_phone( $context );
972 972
     }
973 973
 
974 974
     /**
975
-	 * Alias of self::get_phone().
976
-	 *
977
-	 * @since 1.0.19
978
-	 * @param  string $context View or edit context.
979
-	 * @return string
980
-	 */
981
-	public function get_customer_phone( $context = 'view' ) {
982
-		return $this->get_phone( $context );
975
+     * Alias of self::get_phone().
976
+     *
977
+     * @since 1.0.19
978
+     * @param  string $context View or edit context.
979
+     * @return string
980
+     */
981
+    public function get_customer_phone( $context = 'view' ) {
982
+        return $this->get_phone( $context );
983 983
     }
984 984
 
985 985
     /**
986
-	 * Get the customer's email address.
987
-	 *
988
-	 * @since 1.0.19
989
-	 * @param  string $context View or edit context.
990
-	 * @return string
991
-	 */
992
-	public function get_email( $context = 'view' ) {
993
-		return $this->get_prop( 'email', $context );
986
+     * Get the customer's email address.
987
+     *
988
+     * @since 1.0.19
989
+     * @param  string $context View or edit context.
990
+     * @return string
991
+     */
992
+    public function get_email( $context = 'view' ) {
993
+        return $this->get_prop( 'email', $context );
994 994
     }
995 995
 
996 996
     /**
997
-	 * Alias of self::get_email().
998
-	 *
999
-	 * @since 1.0.19
1000
-	 * @param  string $context View or edit context.
1001
-	 * @return string
1002
-	 */
1003
-	public function get_email_address( $context = 'view' ) {
1004
-		return $this->get_email( $context );
997
+     * Alias of self::get_email().
998
+     *
999
+     * @since 1.0.19
1000
+     * @param  string $context View or edit context.
1001
+     * @return string
1002
+     */
1003
+    public function get_email_address( $context = 'view' ) {
1004
+        return $this->get_email( $context );
1005 1005
     }
1006 1006
 
1007 1007
     /**
1008
-	 * Alias of self::get_email().
1009
-	 *
1010
-	 * @since 1.0.19
1011
-	 * @param  string $context View or edit context.
1012
-	 * @return string
1013
-	 */
1014
-	public function get_user_email( $context = 'view' ) {
1015
-		return $this->get_email( $context );
1008
+     * Alias of self::get_email().
1009
+     *
1010
+     * @since 1.0.19
1011
+     * @param  string $context View or edit context.
1012
+     * @return string
1013
+     */
1014
+    public function get_user_email( $context = 'view' ) {
1015
+        return $this->get_email( $context );
1016 1016
     }
1017 1017
 
1018 1018
     /**
1019
-	 * Alias of self::get_email().
1020
-	 *
1021
-	 * @since 1.0.19
1022
-	 * @param  string $context View or edit context.
1023
-	 * @return string
1024
-	 */
1025
-	public function get_customer_email( $context = 'view' ) {
1026
-		return $this->get_email( $context );
1019
+     * Alias of self::get_email().
1020
+     *
1021
+     * @since 1.0.19
1022
+     * @param  string $context View or edit context.
1023
+     * @return string
1024
+     */
1025
+    public function get_customer_email( $context = 'view' ) {
1026
+        return $this->get_email( $context );
1027 1027
     }
1028 1028
 
1029 1029
     /**
1030
-	 * Get the customer's country.
1031
-	 *
1032
-	 * @since 1.0.19
1033
-	 * @param  string $context View or edit context.
1034
-	 * @return string
1035
-	 */
1036
-	public function get_country( $context = 'view' ) {
1037
-		$country = $this->get_prop( 'country', $context );
1038
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1030
+     * Get the customer's country.
1031
+     *
1032
+     * @since 1.0.19
1033
+     * @param  string $context View or edit context.
1034
+     * @return string
1035
+     */
1036
+    public function get_country( $context = 'view' ) {
1037
+        $country = $this->get_prop( 'country', $context );
1038
+        return empty( $country ) ? wpinv_get_default_country() : $country;
1039 1039
     }
1040 1040
 
1041 1041
     /**
1042
-	 * Alias of self::get_country().
1043
-	 *
1044
-	 * @since 1.0.19
1045
-	 * @param  string $context View or edit context.
1046
-	 * @return string
1047
-	 */
1048
-	public function get_user_country( $context = 'view' ) {
1049
-		return $this->get_country( $context );
1042
+     * Alias of self::get_country().
1043
+     *
1044
+     * @since 1.0.19
1045
+     * @param  string $context View or edit context.
1046
+     * @return string
1047
+     */
1048
+    public function get_user_country( $context = 'view' ) {
1049
+        return $this->get_country( $context );
1050 1050
     }
1051 1051
 
1052 1052
     /**
1053
-	 * Alias of self::get_country().
1054
-	 *
1055
-	 * @since 1.0.19
1056
-	 * @param  string $context View or edit context.
1057
-	 * @return string
1058
-	 */
1059
-	public function get_customer_country( $context = 'view' ) {
1060
-		return $this->get_country( $context );
1053
+     * Alias of self::get_country().
1054
+     *
1055
+     * @since 1.0.19
1056
+     * @param  string $context View or edit context.
1057
+     * @return string
1058
+     */
1059
+    public function get_customer_country( $context = 'view' ) {
1060
+        return $this->get_country( $context );
1061 1061
     }
1062 1062
 
1063 1063
     /**
1064
-	 * Get the customer's state.
1065
-	 *
1066
-	 * @since 1.0.19
1067
-	 * @param  string $context View or edit context.
1068
-	 * @return string
1069
-	 */
1070
-	public function get_state( $context = 'view' ) {
1071
-		$state = $this->get_prop( 'state', $context );
1072
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1064
+     * Get the customer's state.
1065
+     *
1066
+     * @since 1.0.19
1067
+     * @param  string $context View or edit context.
1068
+     * @return string
1069
+     */
1070
+    public function get_state( $context = 'view' ) {
1071
+        $state = $this->get_prop( 'state', $context );
1072
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1073 1073
     }
1074 1074
 
1075 1075
     /**
1076
-	 * Alias of self::get_state().
1077
-	 *
1078
-	 * @since 1.0.19
1079
-	 * @param  string $context View or edit context.
1080
-	 * @return string
1081
-	 */
1082
-	public function get_user_state( $context = 'view' ) {
1083
-		return $this->get_state( $context );
1076
+     * Alias of self::get_state().
1077
+     *
1078
+     * @since 1.0.19
1079
+     * @param  string $context View or edit context.
1080
+     * @return string
1081
+     */
1082
+    public function get_user_state( $context = 'view' ) {
1083
+        return $this->get_state( $context );
1084 1084
     }
1085 1085
 
1086 1086
     /**
1087
-	 * Alias of self::get_state().
1088
-	 *
1089
-	 * @since 1.0.19
1090
-	 * @param  string $context View or edit context.
1091
-	 * @return string
1092
-	 */
1093
-	public function get_customer_state( $context = 'view' ) {
1094
-		return $this->get_state( $context );
1087
+     * Alias of self::get_state().
1088
+     *
1089
+     * @since 1.0.19
1090
+     * @param  string $context View or edit context.
1091
+     * @return string
1092
+     */
1093
+    public function get_customer_state( $context = 'view' ) {
1094
+        return $this->get_state( $context );
1095 1095
     }
1096 1096
 
1097 1097
     /**
1098
-	 * Get the customer's city.
1099
-	 *
1100
-	 * @since 1.0.19
1101
-	 * @param  string $context View or edit context.
1102
-	 * @return string
1103
-	 */
1104
-	public function get_city( $context = 'view' ) {
1105
-		return $this->get_prop( 'city', $context );
1098
+     * Get the customer's city.
1099
+     *
1100
+     * @since 1.0.19
1101
+     * @param  string $context View or edit context.
1102
+     * @return string
1103
+     */
1104
+    public function get_city( $context = 'view' ) {
1105
+        return $this->get_prop( 'city', $context );
1106 1106
     }
1107 1107
 
1108 1108
     /**
1109
-	 * Alias of self::get_city().
1110
-	 *
1111
-	 * @since 1.0.19
1112
-	 * @param  string $context View or edit context.
1113
-	 * @return string
1114
-	 */
1115
-	public function get_user_city( $context = 'view' ) {
1116
-		return $this->get_city( $context );
1109
+     * Alias of self::get_city().
1110
+     *
1111
+     * @since 1.0.19
1112
+     * @param  string $context View or edit context.
1113
+     * @return string
1114
+     */
1115
+    public function get_user_city( $context = 'view' ) {
1116
+        return $this->get_city( $context );
1117 1117
     }
1118 1118
 
1119 1119
     /**
1120
-	 * Alias of self::get_city().
1121
-	 *
1122
-	 * @since 1.0.19
1123
-	 * @param  string $context View or edit context.
1124
-	 * @return string
1125
-	 */
1126
-	public function get_customer_city( $context = 'view' ) {
1127
-		return $this->get_city( $context );
1120
+     * Alias of self::get_city().
1121
+     *
1122
+     * @since 1.0.19
1123
+     * @param  string $context View or edit context.
1124
+     * @return string
1125
+     */
1126
+    public function get_customer_city( $context = 'view' ) {
1127
+        return $this->get_city( $context );
1128 1128
     }
1129 1129
 
1130 1130
     /**
1131
-	 * Get the customer's zip.
1132
-	 *
1133
-	 * @since 1.0.19
1134
-	 * @param  string $context View or edit context.
1135
-	 * @return string
1136
-	 */
1137
-	public function get_zip( $context = 'view' ) {
1138
-		return $this->get_prop( 'zip', $context );
1131
+     * Get the customer's zip.
1132
+     *
1133
+     * @since 1.0.19
1134
+     * @param  string $context View or edit context.
1135
+     * @return string
1136
+     */
1137
+    public function get_zip( $context = 'view' ) {
1138
+        return $this->get_prop( 'zip', $context );
1139 1139
     }
1140 1140
 
1141 1141
     /**
1142
-	 * Alias of self::get_zip().
1143
-	 *
1144
-	 * @since 1.0.19
1145
-	 * @param  string $context View or edit context.
1146
-	 * @return string
1147
-	 */
1148
-	public function get_user_zip( $context = 'view' ) {
1149
-		return $this->get_zip( $context );
1142
+     * Alias of self::get_zip().
1143
+     *
1144
+     * @since 1.0.19
1145
+     * @param  string $context View or edit context.
1146
+     * @return string
1147
+     */
1148
+    public function get_user_zip( $context = 'view' ) {
1149
+        return $this->get_zip( $context );
1150 1150
     }
1151 1151
 
1152 1152
     /**
1153
-	 * Alias of self::get_zip().
1154
-	 *
1155
-	 * @since 1.0.19
1156
-	 * @param  string $context View or edit context.
1157
-	 * @return string
1158
-	 */
1159
-	public function get_customer_zip( $context = 'view' ) {
1160
-		return $this->get_zip( $context );
1153
+     * Alias of self::get_zip().
1154
+     *
1155
+     * @since 1.0.19
1156
+     * @param  string $context View or edit context.
1157
+     * @return string
1158
+     */
1159
+    public function get_customer_zip( $context = 'view' ) {
1160
+        return $this->get_zip( $context );
1161 1161
     }
1162 1162
 
1163 1163
     /**
1164
-	 * Get the customer's company.
1165
-	 *
1166
-	 * @since 1.0.19
1167
-	 * @param  string $context View or edit context.
1168
-	 * @return string
1169
-	 */
1170
-	public function get_company( $context = 'view' ) {
1171
-		return $this->get_prop( 'company', $context );
1164
+     * Get the customer's company.
1165
+     *
1166
+     * @since 1.0.19
1167
+     * @param  string $context View or edit context.
1168
+     * @return string
1169
+     */
1170
+    public function get_company( $context = 'view' ) {
1171
+        return $this->get_prop( 'company', $context );
1172 1172
     }
1173 1173
 
1174 1174
     /**
1175
-	 * Alias of self::get_company().
1176
-	 *
1177
-	 * @since 1.0.19
1178
-	 * @param  string $context View or edit context.
1179
-	 * @return string
1180
-	 */
1181
-	public function get_user_company( $context = 'view' ) {
1182
-		return $this->get_company( $context );
1175
+     * Alias of self::get_company().
1176
+     *
1177
+     * @since 1.0.19
1178
+     * @param  string $context View or edit context.
1179
+     * @return string
1180
+     */
1181
+    public function get_user_company( $context = 'view' ) {
1182
+        return $this->get_company( $context );
1183
+    }
1184
+
1185
+    /**
1186
+     * Alias of self::get_company().
1187
+     *
1188
+     * @since 1.0.19
1189
+     * @param  string $context View or edit context.
1190
+     * @return string
1191
+     */
1192
+    public function get_customer_company( $context = 'view' ) {
1193
+        return $this->get_company( $context );
1183 1194
     }
1184 1195
 
1185 1196
     /**
1186
-	 * Alias of self::get_company().
1187
-	 *
1188
-	 * @since 1.0.19
1189
-	 * @param  string $context View or edit context.
1190
-	 * @return string
1191
-	 */
1192
-	public function get_customer_company( $context = 'view' ) {
1193
-		return $this->get_company( $context );
1197
+     * Get the customer's company id.
1198
+     *
1199
+     * @since 1.0.19
1200
+     * @param  string $context View or edit context.
1201
+     * @return string
1202
+     */
1203
+    public function get_company_id( $context = 'view' ) {
1204
+        return $this->get_prop( 'company_id', $context );
1205
+    }
1206
+
1207
+    /**
1208
+     * Get the customer's vat number.
1209
+     *
1210
+     * @since 1.0.19
1211
+     * @param  string $context View or edit context.
1212
+     * @return string
1213
+     */
1214
+    public function get_vat_number( $context = 'view' ) {
1215
+        return $this->get_prop( 'vat_number', $context );
1194 1216
     }
1195 1217
 
1196
-	/**
1197
-	 * Get the customer's company id.
1198
-	 *
1199
-	 * @since 1.0.19
1200
-	 * @param  string $context View or edit context.
1201
-	 * @return string
1202
-	 */
1203
-	public function get_company_id( $context = 'view' ) {
1204
-		return $this->get_prop( 'company_id', $context );
1218
+    /**
1219
+     * Alias of self::get_vat_number().
1220
+     *
1221
+     * @since 1.0.19
1222
+     * @param  string $context View or edit context.
1223
+     * @return string
1224
+     */
1225
+    public function get_user_vat_number( $context = 'view' ) {
1226
+        return $this->get_vat_number( $context );
1205 1227
     }
1206 1228
 
1207 1229
     /**
1208
-	 * Get the customer's vat number.
1209
-	 *
1210
-	 * @since 1.0.19
1211
-	 * @param  string $context View or edit context.
1212
-	 * @return string
1213
-	 */
1214
-	public function get_vat_number( $context = 'view' ) {
1215
-		return $this->get_prop( 'vat_number', $context );
1230
+     * Alias of self::get_vat_number().
1231
+     *
1232
+     * @since 1.0.19
1233
+     * @param  string $context View or edit context.
1234
+     * @return string
1235
+     */
1236
+    public function get_customer_vat_number( $context = 'view' ) {
1237
+        return $this->get_vat_number( $context );
1216 1238
     }
1217 1239
 
1218 1240
     /**
1219
-	 * Alias of self::get_vat_number().
1220
-	 *
1221
-	 * @since 1.0.19
1222
-	 * @param  string $context View or edit context.
1223
-	 * @return string
1224
-	 */
1225
-	public function get_user_vat_number( $context = 'view' ) {
1226
-		return $this->get_vat_number( $context );
1241
+     * Get the customer's vat rate.
1242
+     *
1243
+     * @since 1.0.19
1244
+     * @param  string $context View or edit context.
1245
+     * @return string
1246
+     */
1247
+    public function get_vat_rate( $context = 'view' ) {
1248
+        return $this->get_prop( 'vat_rate', $context );
1227 1249
     }
1228 1250
 
1229 1251
     /**
1230
-	 * Alias of self::get_vat_number().
1231
-	 *
1232
-	 * @since 1.0.19
1233
-	 * @param  string $context View or edit context.
1234
-	 * @return string
1235
-	 */
1236
-	public function get_customer_vat_number( $context = 'view' ) {
1237
-		return $this->get_vat_number( $context );
1252
+     * Alias of self::get_vat_rate().
1253
+     *
1254
+     * @since 1.0.19
1255
+     * @param  string $context View or edit context.
1256
+     * @return string
1257
+     */
1258
+    public function get_user_vat_rate( $context = 'view' ) {
1259
+        return $this->get_vat_rate( $context );
1238 1260
     }
1239 1261
 
1240
-    /**
1241
-	 * Get the customer's vat rate.
1242
-	 *
1243
-	 * @since 1.0.19
1244
-	 * @param  string $context View or edit context.
1245
-	 * @return string
1246
-	 */
1247
-	public function get_vat_rate( $context = 'view' ) {
1248
-		return $this->get_prop( 'vat_rate', $context );
1249
-    }
1250
-
1251
-    /**
1252
-	 * Alias of self::get_vat_rate().
1253
-	 *
1254
-	 * @since 1.0.19
1255
-	 * @param  string $context View or edit context.
1256
-	 * @return string
1257
-	 */
1258
-	public function get_user_vat_rate( $context = 'view' ) {
1259
-		return $this->get_vat_rate( $context );
1260
-    }
1261
-
1262
-    /**
1263
-	 * Alias of self::get_vat_rate().
1264
-	 *
1265
-	 * @since 1.0.19
1266
-	 * @param  string $context View or edit context.
1267
-	 * @return string
1268
-	 */
1269
-	public function get_customer_vat_rate( $context = 'view' ) {
1270
-		return $this->get_vat_rate( $context );
1271
-    }
1272
-
1273
-    /**
1274
-	 * Get the customer's address.
1275
-	 *
1276
-	 * @since 1.0.19
1277
-	 * @param  string $context View or edit context.
1278
-	 * @return string
1279
-	 */
1280
-	public function get_address( $context = 'view' ) {
1281
-		return $this->get_prop( 'address', $context );
1282
-    }
1283
-
1284
-    /**
1285
-	 * Alias of self::get_address().
1286
-	 *
1287
-	 * @since 1.0.19
1288
-	 * @param  string $context View or edit context.
1289
-	 * @return string
1290
-	 */
1291
-	public function get_user_address( $context = 'view' ) {
1292
-		return $this->get_address( $context );
1293
-    }
1294
-
1295
-    /**
1296
-	 * Alias of self::get_address().
1297
-	 *
1298
-	 * @since 1.0.19
1299
-	 * @param  string $context View or edit context.
1300
-	 * @return string
1301
-	 */
1302
-	public function get_customer_address( $context = 'view' ) {
1303
-		return $this->get_address( $context );
1304
-    }
1305
-
1306
-    /**
1307
-	 * Get whether the customer has viewed the invoice or not.
1308
-	 *
1309
-	 * @since 1.0.19
1310
-	 * @param  string $context View or edit context.
1311
-	 * @return bool
1312
-	 */
1313
-	public function get_is_viewed( $context = 'view' ) {
1314
-		return (bool) $this->get_prop( 'is_viewed', $context );
1315
-	}
1316
-
1317
-	/**
1318
-	 * Get other recipients for invoice communications.
1319
-	 *
1320
-	 * @since 1.0.19
1321
-	 * @param  string $context View or edit context.
1322
-	 * @return bool
1323
-	 */
1324
-	public function get_email_cc( $context = 'view' ) {
1325
-		return $this->get_prop( 'email_cc', $context );
1326
-	}
1327
-
1328
-	/**
1329
-	 * Get invoice template.
1330
-	 *
1331
-	 * @since 1.0.19
1332
-	 * @param  string $context View or edit context.
1333
-	 * @return bool
1334
-	 */
1335
-	public function get_template( $context = 'view' ) {
1336
-		return $this->get_prop( 'template', $context );
1337
-	}
1338
-
1339
-	/**
1340
-	 * Get invoice source.
1341
-	 *
1342
-	 * @since 1.0.19
1343
-	 * @param  string $context View or edit context.
1344
-	 * @return bool
1345
-	 */
1346
-	public function get_created_via( $context = 'view' ) {
1347
-		return $this->get_prop( 'created_via', $context );
1348
-	}
1349
-
1350
-	/**
1351
-	 * Get whether the customer has confirmed their address.
1352
-	 *
1353
-	 * @since 1.0.19
1354
-	 * @param  string $context View or edit context.
1355
-	 * @return bool
1356
-	 */
1357
-	public function get_address_confirmed( $context = 'view' ) {
1358
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1359
-    }
1360
-
1361
-    /**
1362
-	 * Alias of self::get_address_confirmed().
1363
-	 *
1364
-	 * @since 1.0.19
1365
-	 * @param  string $context View or edit context.
1366
-	 * @return bool
1367
-	 */
1368
-	public function get_user_address_confirmed( $context = 'view' ) {
1369
-		return $this->get_address_confirmed( $context );
1370
-    }
1371
-
1372
-    /**
1373
-	 * Alias of self::get_address().
1374
-	 *
1375
-	 * @since 1.0.19
1376
-	 * @param  string $context View or edit context.
1377
-	 * @return bool
1378
-	 */
1379
-	public function get_customer_address_confirmed( $context = 'view' ) {
1380
-		return $this->get_address_confirmed( $context );
1381
-    }
1382
-
1383
-	/**
1384
-	 * Get the shipping address.
1385
-	 *
1386
-	 * @since 1.0.19
1387
-	 * @return array|false
1388
-	 */
1389
-	public function get_shipping_address() {
1390
-
1391
-		$shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1392
-		return is_array( $shipping_address ) ? $shipping_address : false;
1393
-    }
1394
-
1395
-	/**
1396
-	 * Check if the invoice has a shipping address.
1397
-	 */
1398
-	public function has_shipping_address() {
1399
-		return false !== $this->get_shipping_address();
1400
-    }
1401
-
1402
-	/**
1403
-	 * Get the shipping amount.
1404
-	 *
1405
-	 * @since 1.0.19
1406
-	 * @param  string $context View or edit context.
1407
-	 * @return float
1408
-	 */
1409
-	public function get_shipping( $context = 'view' ) {
1410
-
1411
-		if ( $context = 'view' ) {
1412
-			return floatval( $this->get_prop( 'shipping', $context ) );
1413
-		}
1414
-
1415
-		return $this->get_prop( 'shipping', $context );
1416
-    }
1417
-
1418
-	public function has_shipping() {
1419
-		return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' );
1420
-    }
1421
-
1422
-    /**
1423
-	 * Get the invoice subtotal.
1424
-	 *
1425
-	 * @since 1.0.19
1426
-	 * @param  string $context View or edit context.
1427
-	 * @return float
1428
-	 */
1429
-	public function get_subtotal( $context = 'view' ) {
1262
+    /**
1263
+     * Alias of self::get_vat_rate().
1264
+     *
1265
+     * @since 1.0.19
1266
+     * @param  string $context View or edit context.
1267
+     * @return string
1268
+     */
1269
+    public function get_customer_vat_rate( $context = 'view' ) {
1270
+        return $this->get_vat_rate( $context );
1271
+    }
1272
+
1273
+    /**
1274
+     * Get the customer's address.
1275
+     *
1276
+     * @since 1.0.19
1277
+     * @param  string $context View or edit context.
1278
+     * @return string
1279
+     */
1280
+    public function get_address( $context = 'view' ) {
1281
+        return $this->get_prop( 'address', $context );
1282
+    }
1283
+
1284
+    /**
1285
+     * Alias of self::get_address().
1286
+     *
1287
+     * @since 1.0.19
1288
+     * @param  string $context View or edit context.
1289
+     * @return string
1290
+     */
1291
+    public function get_user_address( $context = 'view' ) {
1292
+        return $this->get_address( $context );
1293
+    }
1294
+
1295
+    /**
1296
+     * Alias of self::get_address().
1297
+     *
1298
+     * @since 1.0.19
1299
+     * @param  string $context View or edit context.
1300
+     * @return string
1301
+     */
1302
+    public function get_customer_address( $context = 'view' ) {
1303
+        return $this->get_address( $context );
1304
+    }
1305
+
1306
+    /**
1307
+     * Get whether the customer has viewed the invoice or not.
1308
+     *
1309
+     * @since 1.0.19
1310
+     * @param  string $context View or edit context.
1311
+     * @return bool
1312
+     */
1313
+    public function get_is_viewed( $context = 'view' ) {
1314
+        return (bool) $this->get_prop( 'is_viewed', $context );
1315
+    }
1316
+
1317
+    /**
1318
+     * Get other recipients for invoice communications.
1319
+     *
1320
+     * @since 1.0.19
1321
+     * @param  string $context View or edit context.
1322
+     * @return bool
1323
+     */
1324
+    public function get_email_cc( $context = 'view' ) {
1325
+        return $this->get_prop( 'email_cc', $context );
1326
+    }
1327
+
1328
+    /**
1329
+     * Get invoice template.
1330
+     *
1331
+     * @since 1.0.19
1332
+     * @param  string $context View or edit context.
1333
+     * @return bool
1334
+     */
1335
+    public function get_template( $context = 'view' ) {
1336
+        return $this->get_prop( 'template', $context );
1337
+    }
1338
+
1339
+    /**
1340
+     * Get invoice source.
1341
+     *
1342
+     * @since 1.0.19
1343
+     * @param  string $context View or edit context.
1344
+     * @return bool
1345
+     */
1346
+    public function get_created_via( $context = 'view' ) {
1347
+        return $this->get_prop( 'created_via', $context );
1348
+    }
1349
+
1350
+    /**
1351
+     * Get whether the customer has confirmed their address.
1352
+     *
1353
+     * @since 1.0.19
1354
+     * @param  string $context View or edit context.
1355
+     * @return bool
1356
+     */
1357
+    public function get_address_confirmed( $context = 'view' ) {
1358
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1359
+    }
1360
+
1361
+    /**
1362
+     * Alias of self::get_address_confirmed().
1363
+     *
1364
+     * @since 1.0.19
1365
+     * @param  string $context View or edit context.
1366
+     * @return bool
1367
+     */
1368
+    public function get_user_address_confirmed( $context = 'view' ) {
1369
+        return $this->get_address_confirmed( $context );
1370
+    }
1371
+
1372
+    /**
1373
+     * Alias of self::get_address().
1374
+     *
1375
+     * @since 1.0.19
1376
+     * @param  string $context View or edit context.
1377
+     * @return bool
1378
+     */
1379
+    public function get_customer_address_confirmed( $context = 'view' ) {
1380
+        return $this->get_address_confirmed( $context );
1381
+    }
1382
+
1383
+    /**
1384
+     * Get the shipping address.
1385
+     *
1386
+     * @since 1.0.19
1387
+     * @return array|false
1388
+     */
1389
+    public function get_shipping_address() {
1390
+
1391
+        $shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1392
+        return is_array( $shipping_address ) ? $shipping_address : false;
1393
+    }
1394
+
1395
+    /**
1396
+     * Check if the invoice has a shipping address.
1397
+     */
1398
+    public function has_shipping_address() {
1399
+        return false !== $this->get_shipping_address();
1400
+    }
1401
+
1402
+    /**
1403
+     * Get the shipping amount.
1404
+     *
1405
+     * @since 1.0.19
1406
+     * @param  string $context View or edit context.
1407
+     * @return float
1408
+     */
1409
+    public function get_shipping( $context = 'view' ) {
1410
+
1411
+        if ( $context = 'view' ) {
1412
+            return floatval( $this->get_prop( 'shipping', $context ) );
1413
+        }
1414
+
1415
+        return $this->get_prop( 'shipping', $context );
1416
+    }
1417
+
1418
+    public function has_shipping() {
1419
+        return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' );
1420
+    }
1421
+
1422
+    /**
1423
+     * Get the invoice subtotal.
1424
+     *
1425
+     * @since 1.0.19
1426
+     * @param  string $context View or edit context.
1427
+     * @return float
1428
+     */
1429
+    public function get_subtotal( $context = 'view' ) {
1430 1430
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1431 1431
 
1432 1432
         // Backwards compatibility.
@@ -1438,198 +1438,198 @@  discard block
 block discarded – undo
1438 1438
     }
1439 1439
 
1440 1440
     /**
1441
-	 * Get the invoice discount total.
1442
-	 *
1443
-	 * @since 1.0.19
1444
-	 * @param  string $context View or edit context.
1445
-	 * @return float
1446
-	 */
1447
-	public function get_total_discount( $context = 'view' ) {
1448
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1441
+     * Get the invoice discount total.
1442
+     *
1443
+     * @since 1.0.19
1444
+     * @param  string $context View or edit context.
1445
+     * @return float
1446
+     */
1447
+    public function get_total_discount( $context = 'view' ) {
1448
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1449 1449
     }
1450 1450
 
1451 1451
     /**
1452
-	 * Get the invoice tax total.
1453
-	 *
1454
-	 * @since 1.0.19
1455
-	 * @param  string $context View or edit context.
1456
-	 * @return float
1457
-	 */
1458
-	public function get_total_tax( $context = 'view' ) {
1459
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1460
-	}
1452
+     * Get the invoice tax total.
1453
+     *
1454
+     * @since 1.0.19
1455
+     * @param  string $context View or edit context.
1456
+     * @return float
1457
+     */
1458
+    public function get_total_tax( $context = 'view' ) {
1459
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1460
+    }
1461 1461
 
1462
-	/**
1463
-	 * @deprecated
1464
-	 */
1465
-	public function get_final_tax( $currency = false ) {
1466
-		$tax = $this->get_total_tax();
1462
+    /**
1463
+     * @deprecated
1464
+     */
1465
+    public function get_final_tax( $currency = false ) {
1466
+        $tax = $this->get_total_tax();
1467 1467
 
1468 1468
         if ( $currency ) {
1469
-			return wpinv_price( $tax, $this->get_currency() );
1469
+            return wpinv_price( $tax, $this->get_currency() );
1470 1470
         }
1471 1471
 
1472 1472
         return $tax;
1473 1473
     }
1474 1474
 
1475 1475
     /**
1476
-	 * Get the invoice fees total.
1477
-	 *
1478
-	 * @since 1.0.19
1479
-	 * @param  string $context View or edit context.
1480
-	 * @return float
1481
-	 */
1482
-	public function get_total_fees( $context = 'view' ) {
1483
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1476
+     * Get the invoice fees total.
1477
+     *
1478
+     * @since 1.0.19
1479
+     * @param  string $context View or edit context.
1480
+     * @return float
1481
+     */
1482
+    public function get_total_fees( $context = 'view' ) {
1483
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1484
+    }
1485
+
1486
+    /**
1487
+     * Alias for self::get_total_fees().
1488
+     *
1489
+     * @since 1.0.19
1490
+     * @param  string $context View or edit context.
1491
+     * @return float
1492
+     */
1493
+    public function get_fees_total( $context = 'view' ) {
1494
+        return $this->get_total_fees( $context );
1484 1495
     }
1485 1496
 
1486 1497
     /**
1487
-	 * Alias for self::get_total_fees().
1488
-	 *
1489
-	 * @since 1.0.19
1490
-	 * @param  string $context View or edit context.
1491
-	 * @return float
1492
-	 */
1493
-	public function get_fees_total( $context = 'view' ) {
1494
-		return $this->get_total_fees( $context );
1498
+     * Get the invoice total.
1499
+     *
1500
+     * @since 1.0.19
1501
+     * @return float
1502
+     */
1503
+    public function get_total( $context = 'view' ) {
1504
+        $total = $this->get_prop( 'total', $context );
1505
+
1506
+        if ( $this->has_shipping() && $context == 'view' ) {
1507
+            $total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1508
+        }
1509
+
1510
+        return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1495 1511
     }
1496 1512
 
1497 1513
     /**
1498
-	 * Get the invoice total.
1499
-	 *
1500
-	 * @since 1.0.19
1514
+     * Retrieves the non-recurring total of items.
1515
+     *
1516
+     * @since 2.3.0
1501 1517
      * @return float
1502
-	 */
1503
-	public function get_total( $context = 'view' ) {
1504
-		$total = $this->get_prop( 'total', $context );
1505
-
1506
-		if ( $this->has_shipping() && $context == 'view' ) {
1507
-			$total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1508
-		}
1509
-
1510
-		return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1511
-	}
1512
-
1513
-	/**
1514
-	 * Retrieves the non-recurring total of items.
1515
-	 *
1516
-	 * @since 2.3.0
1517
-	 * @return float
1518
-	 */
1519
-	public function get_non_recurring_total() {
1520
-
1521
-		$subtotal = 0;
1522
-		foreach ( $this->get_items() as $item ) {
1523
-			if ( ! $item->is_recurring() ) {
1524
-				$subtotal += $item->get_sub_total();
1525
-			}
1526
-		}
1527
-
1528
-		foreach ( $this->get_fees() as $fee ) {
1529
-			if ( empty( $fee['recurring_fee'] ) ) {
1530
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1531
-			}
1532
-		}
1533
-
1534
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1518
+     */
1519
+    public function get_non_recurring_total() {
1520
+
1521
+        $subtotal = 0;
1522
+        foreach ( $this->get_items() as $item ) {
1523
+            if ( ! $item->is_recurring() ) {
1524
+                $subtotal += $item->get_sub_total();
1525
+            }
1526
+        }
1527
+
1528
+        foreach ( $this->get_fees() as $fee ) {
1529
+            if ( empty( $fee['recurring_fee'] ) ) {
1530
+                $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1531
+            }
1532
+        }
1533
+
1534
+        $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1535 1535
         return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1536 1536
 
1537 1537
     }
1538 1538
 
1539
-	/**
1540
-	 * Get the invoice totals.
1541
-	 *
1542
-	 * @since 1.0.19
1539
+    /**
1540
+     * Get the invoice totals.
1541
+     *
1542
+     * @since 1.0.19
1543 1543
      * @return array
1544
-	 */
1545
-	public function get_totals() {
1546
-		return $this->totals;
1544
+     */
1545
+    public function get_totals() {
1546
+        return $this->totals;
1547 1547
     }
1548 1548
 
1549 1549
     /**
1550
-	 * Get the initial invoice total.
1551
-	 *
1552
-	 * @since 1.0.19
1550
+     * Get the initial invoice total.
1551
+     *
1552
+     * @since 1.0.19
1553 1553
      * @param  string $context View or edit context.
1554 1554
      * @return float
1555
-	 */
1555
+     */
1556 1556
     public function get_initial_total() {
1557 1557
 
1558
-		if ( empty( $this->totals ) ) {
1559
-			$this->recalculate_total();
1560
-		}
1558
+        if ( empty( $this->totals ) ) {
1559
+            $this->recalculate_total();
1560
+        }
1561 1561
 
1562
-		$tax      = $this->totals['tax']['initial'];
1563
-		$fee      = $this->totals['fee']['initial'];
1564
-		$discount = $this->totals['discount']['initial'];
1565
-		$subtotal = $this->totals['subtotal']['initial'];
1566
-		$total    = $tax + $fee - $discount + $subtotal;
1562
+        $tax      = $this->totals['tax']['initial'];
1563
+        $fee      = $this->totals['fee']['initial'];
1564
+        $discount = $this->totals['discount']['initial'];
1565
+        $subtotal = $this->totals['subtotal']['initial'];
1566
+        $total    = $tax + $fee - $discount + $subtotal;
1567 1567
 
1568
-		if ( 0 > $total ) {
1569
-			$total = 0;
1570
-		}
1568
+        if ( 0 > $total ) {
1569
+            $total = 0;
1570
+        }
1571 1571
 
1572
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1572
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1573 1573
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1574
-	}
1574
+    }
1575 1575
 
1576
-	/**
1577
-	 * Get the recurring invoice total.
1578
-	 *
1579
-	 * @since 1.0.19
1576
+    /**
1577
+     * Get the recurring invoice total.
1578
+     *
1579
+     * @since 1.0.19
1580 1580
      * @param  string $context View or edit context.
1581 1581
      * @return float
1582
-	 */
1582
+     */
1583 1583
     public function get_recurring_total() {
1584 1584
 
1585
-		if ( empty( $this->totals ) ) {
1586
-			$this->recalculate_total();
1587
-		}
1585
+        if ( empty( $this->totals ) ) {
1586
+            $this->recalculate_total();
1587
+        }
1588 1588
 
1589
-		$tax      = $this->totals['tax']['recurring'];
1590
-		$fee      = $this->totals['fee']['recurring'];
1591
-		$discount = $this->totals['discount']['recurring'];
1592
-		$subtotal = $this->totals['subtotal']['recurring'];
1593
-		$total    = $tax + $fee - $discount + $subtotal;
1589
+        $tax      = $this->totals['tax']['recurring'];
1590
+        $fee      = $this->totals['fee']['recurring'];
1591
+        $discount = $this->totals['discount']['recurring'];
1592
+        $subtotal = $this->totals['subtotal']['recurring'];
1593
+        $total    = $tax + $fee - $discount + $subtotal;
1594 1594
 
1595
-		if ( 0 > $total ) {
1596
-			$total = 0;
1597
-		}
1595
+        if ( 0 > $total ) {
1596
+            $total = 0;
1597
+        }
1598 1598
 
1599
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1599
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1600 1600
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1601
-	}
1601
+    }
1602 1602
 
1603
-	/**
1604
-	 * Returns recurring payment details.
1605
-	 *
1606
-	 * @since 1.0.19
1603
+    /**
1604
+     * Returns recurring payment details.
1605
+     *
1606
+     * @since 1.0.19
1607 1607
      * @param  string $field Optionally provide a field to return.
1608
-	 * @param string $currency Whether to include the currency.
1608
+     * @param string $currency Whether to include the currency.
1609 1609
      * @return float|string
1610
-	 */
1610
+     */
1611 1611
     public function get_recurring_details( $field = '', $currency = false ) {
1612 1612
 
1613
-		// Maybe recalculate totals.
1614
-		if ( empty( $this->totals ) ) {
1615
-			$this->recalculate_total();
1616
-		}
1613
+        // Maybe recalculate totals.
1614
+        if ( empty( $this->totals ) ) {
1615
+            $this->recalculate_total();
1616
+        }
1617 1617
 
1618
-		// Prepare recurring totals.
1618
+        // Prepare recurring totals.
1619 1619
         $data = apply_filters(
1620
-			'wpinv_get_invoice_recurring_details',
1621
-			array(
1622
-				'cart_details' => $this->get_cart_details(),
1623
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1624
-				'discount'     => $this->totals['discount']['recurring'],
1625
-				'tax'          => $this->totals['tax']['recurring'],
1626
-				'fee'          => $this->totals['fee']['recurring'],
1627
-				'total'        => $this->get_recurring_total(),
1628
-			),
1629
-			$this,
1630
-			$field,
1631
-			$currency
1632
-		);
1620
+            'wpinv_get_invoice_recurring_details',
1621
+            array(
1622
+                'cart_details' => $this->get_cart_details(),
1623
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1624
+                'discount'     => $this->totals['discount']['recurring'],
1625
+                'tax'          => $this->totals['tax']['recurring'],
1626
+                'fee'          => $this->totals['fee']['recurring'],
1627
+                'total'        => $this->get_recurring_total(),
1628
+            ),
1629
+            $this,
1630
+            $field,
1631
+            $currency
1632
+        );
1633 1633
 
1634 1634
         if ( isset( $data[ $field ] ) ) {
1635 1635
             return ( $currency ? wpinv_price( $data[ $field ], $this->get_currency() ) : $data[ $field ] );
@@ -1639,166 +1639,166 @@  discard block
 block discarded – undo
1639 1639
     }
1640 1640
 
1641 1641
     /**
1642
-	 * Get the invoice fees.
1643
-	 *
1644
-	 * @since 1.0.19
1645
-	 * @param  string $context View or edit context.
1646
-	 * @return array
1647
-	 */
1648
-	public function get_fees( $context = 'view' ) {
1649
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1642
+     * Get the invoice fees.
1643
+     *
1644
+     * @since 1.0.19
1645
+     * @param  string $context View or edit context.
1646
+     * @return array
1647
+     */
1648
+    public function get_fees( $context = 'view' ) {
1649
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1650 1650
     }
1651 1651
 
1652 1652
     /**
1653
-	 * Get the invoice discounts.
1654
-	 *
1655
-	 * @since 1.0.19
1656
-	 * @param  string $context View or edit context.
1657
-	 * @return array
1658
-	 */
1659
-	public function get_discounts( $context = 'view' ) {
1660
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1653
+     * Get the invoice discounts.
1654
+     *
1655
+     * @since 1.0.19
1656
+     * @param  string $context View or edit context.
1657
+     * @return array
1658
+     */
1659
+    public function get_discounts( $context = 'view' ) {
1660
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1661 1661
     }
1662 1662
 
1663 1663
     /**
1664
-	 * Get the invoice taxes.
1665
-	 *
1666
-	 * @since 1.0.19
1667
-	 * @param  string $context View or edit context.
1668
-	 * @return array
1669
-	 */
1670
-	public function get_taxes( $context = 'view' ) {
1671
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1664
+     * Get the invoice taxes.
1665
+     *
1666
+     * @since 1.0.19
1667
+     * @param  string $context View or edit context.
1668
+     * @return array
1669
+     */
1670
+    public function get_taxes( $context = 'view' ) {
1671
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1672 1672
     }
1673 1673
 
1674 1674
     /**
1675
-	 * Get the invoice items.
1676
-	 *
1677
-	 * @since 1.0.19
1678
-	 * @param  string $context View or edit context.
1679
-	 * @return GetPaid_Form_Item[]
1680
-	 */
1681
-	public function get_items( $context = 'view' ) {
1675
+     * Get the invoice items.
1676
+     *
1677
+     * @since 1.0.19
1678
+     * @param  string $context View or edit context.
1679
+     * @return GetPaid_Form_Item[]
1680
+     */
1681
+    public function get_items( $context = 'view' ) {
1682 1682
         return $this->get_prop( 'items', $context );
1683
-	}
1683
+    }
1684 1684
 
1685
-	/**
1686
-	 * Get the invoice item ids.
1687
-	 *
1688
-	 * @since 1.0.19
1689
-	 * @return string
1690
-	 */
1691
-	public function get_item_ids() {
1692
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1685
+    /**
1686
+     * Get the invoice item ids.
1687
+     *
1688
+     * @since 1.0.19
1689
+     * @return string
1690
+     */
1691
+    public function get_item_ids() {
1692
+        return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1693 1693
     }
1694 1694
 
1695 1695
     /**
1696
-	 * Get the invoice's payment form.
1697
-	 *
1698
-	 * @since 1.0.19
1699
-	 * @param  string $context View or edit context.
1700
-	 * @return int
1701
-	 */
1702
-	public function get_payment_form( $context = 'view' ) {
1703
-		return intval( $this->get_prop( 'payment_form', $context ) );
1696
+     * Get the invoice's payment form.
1697
+     *
1698
+     * @since 1.0.19
1699
+     * @param  string $context View or edit context.
1700
+     * @return int
1701
+     */
1702
+    public function get_payment_form( $context = 'view' ) {
1703
+        return intval( $this->get_prop( 'payment_form', $context ) );
1704 1704
     }
1705 1705
 
1706 1706
     /**
1707
-	 * Get the invoice's submission id.
1708
-	 *
1709
-	 * @since 1.0.19
1710
-	 * @param  string $context View or edit context.
1711
-	 * @return string
1712
-	 */
1713
-	public function get_submission_id( $context = 'view' ) {
1714
-		return $this->get_prop( 'submission_id', $context );
1707
+     * Get the invoice's submission id.
1708
+     *
1709
+     * @since 1.0.19
1710
+     * @param  string $context View or edit context.
1711
+     * @return string
1712
+     */
1713
+    public function get_submission_id( $context = 'view' ) {
1714
+        return $this->get_prop( 'submission_id', $context );
1715 1715
     }
1716 1716
 
1717 1717
     /**
1718
-	 * Get the invoice's discount code.
1719
-	 *
1720
-	 * @since 1.0.19
1721
-	 * @param  string $context View or edit context.
1722
-	 * @return string
1723
-	 */
1724
-	public function get_discount_code( $context = 'view' ) {
1725
-		return $this->get_prop( 'discount_code', $context );
1718
+     * Get the invoice's discount code.
1719
+     *
1720
+     * @since 1.0.19
1721
+     * @param  string $context View or edit context.
1722
+     * @return string
1723
+     */
1724
+    public function get_discount_code( $context = 'view' ) {
1725
+        return $this->get_prop( 'discount_code', $context );
1726 1726
     }
1727 1727
 
1728 1728
     /**
1729
-	 * Get the invoice's gateway.
1730
-	 *
1731
-	 * @since 1.0.19
1732
-	 * @param  string $context View or edit context.
1733
-	 * @return string
1734
-	 */
1735
-	public function get_gateway( $context = 'view' ) {
1736
-		return $this->get_prop( 'gateway', $context );
1729
+     * Get the invoice's gateway.
1730
+     *
1731
+     * @since 1.0.19
1732
+     * @param  string $context View or edit context.
1733
+     * @return string
1734
+     */
1735
+    public function get_gateway( $context = 'view' ) {
1736
+        return $this->get_prop( 'gateway', $context );
1737 1737
     }
1738 1738
 
1739 1739
     /**
1740
-	 * Get the invoice's gateway display title.
1741
-	 *
1742
-	 * @since 1.0.19
1743
-	 * @return string
1744
-	 */
1740
+     * Get the invoice's gateway display title.
1741
+     *
1742
+     * @since 1.0.19
1743
+     * @return string
1744
+     */
1745 1745
     public function get_gateway_title() {
1746 1746
         $title = wpinv_get_gateway_checkout_label( $this->get_gateway() );
1747 1747
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1748 1748
     }
1749 1749
 
1750 1750
     /**
1751
-	 * Get the invoice's transaction id.
1752
-	 *
1753
-	 * @since 1.0.19
1754
-	 * @param  string $context View or edit context.
1755
-	 * @return string
1756
-	 */
1757
-	public function get_transaction_id( $context = 'view' ) {
1758
-		return $this->get_prop( 'transaction_id', $context );
1751
+     * Get the invoice's transaction id.
1752
+     *
1753
+     * @since 1.0.19
1754
+     * @param  string $context View or edit context.
1755
+     * @return string
1756
+     */
1757
+    public function get_transaction_id( $context = 'view' ) {
1758
+        return $this->get_prop( 'transaction_id', $context );
1759 1759
     }
1760 1760
 
1761 1761
     /**
1762
-	 * Get the invoice's currency.
1763
-	 *
1764
-	 * @since 1.0.19
1765
-	 * @param  string $context View or edit context.
1766
-	 * @return string
1767
-	 */
1768
-	public function get_currency( $context = 'view' ) {
1762
+     * Get the invoice's currency.
1763
+     *
1764
+     * @since 1.0.19
1765
+     * @param  string $context View or edit context.
1766
+     * @return string
1767
+     */
1768
+    public function get_currency( $context = 'view' ) {
1769 1769
         $currency = $this->get_prop( 'currency', $context );
1770 1770
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1771 1771
     }
1772 1772
 
1773 1773
     /**
1774
-	 * Checks if we are charging taxes for this invoice.
1775
-	 *
1776
-	 * @since 1.0.19
1777
-	 * @param  string $context View or edit context.
1778
-	 * @return bool
1779
-	 */
1780
-	public function get_disable_taxes( $context = 'view' ) {
1774
+     * Checks if we are charging taxes for this invoice.
1775
+     *
1776
+     * @since 1.0.19
1777
+     * @param  string $context View or edit context.
1778
+     * @return bool
1779
+     */
1780
+    public function get_disable_taxes( $context = 'view' ) {
1781 1781
         return (bool) $this->get_prop( 'disable_taxes', $context );
1782 1782
     }
1783 1783
 
1784 1784
     /**
1785
-	 * Retrieves the subscription id for an invoice.
1786
-	 *
1787
-	 * @since 1.0.19
1788
-	 * @param  string $context View or edit context.
1789
-	 * @return int
1790
-	 */
1785
+     * Retrieves the subscription id for an invoice.
1786
+     *
1787
+     * @since 1.0.19
1788
+     * @param  string $context View or edit context.
1789
+     * @return int
1790
+     */
1791 1791
     public function get_subscription_id( $context = 'view' ) {
1792
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1793
-	}
1794
-
1795
-	/**
1796
-	 * Retrieves the remote subscription id for an invoice.
1797
-	 *
1798
-	 * @since 1.0.19
1799
-	 * @param  string $context View or edit context.
1800
-	 * @return int
1801
-	 */
1792
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1793
+    }
1794
+
1795
+    /**
1796
+     * Retrieves the remote subscription id for an invoice.
1797
+     *
1798
+     * @since 1.0.19
1799
+     * @param  string $context View or edit context.
1800
+     * @return int
1801
+     */
1802 1802
     public function get_remote_subscription_id( $context = 'view' ) {
1803 1803
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1804 1804
 
@@ -1811,12 +1811,12 @@  discard block
 block discarded – undo
1811 1811
     }
1812 1812
 
1813 1813
     /**
1814
-	 * Retrieves the payment meta for an invoice.
1815
-	 *
1816
-	 * @since 1.0.19
1817
-	 * @param  string $context View or edit context.
1818
-	 * @return array
1819
-	 */
1814
+     * Retrieves the payment meta for an invoice.
1815
+     *
1816
+     * @since 1.0.19
1817
+     * @param  string $context View or edit context.
1818
+     * @return array
1819
+     */
1820 1820
     public function get_payment_meta( $context = 'view' ) {
1821 1821
 
1822 1822
         return array(
@@ -1836,31 +1836,31 @@  discard block
 block discarded – undo
1836 1836
     }
1837 1837
 
1838 1838
     /**
1839
-	 * Retrieves the cart details for an invoice.
1840
-	 *
1841
-	 * @since 1.0.19
1842
-	 * @return array
1843
-	 */
1839
+     * Retrieves the cart details for an invoice.
1840
+     *
1841
+     * @since 1.0.19
1842
+     * @return array
1843
+     */
1844 1844
     public function get_cart_details() {
1845 1845
         $items        = $this->get_items();
1846 1846
         $cart_details = array();
1847 1847
 
1848 1848
         foreach ( $items as $item ) {
1849
-			$item->invoice_id = $this->get_id();
1849
+            $item->invoice_id = $this->get_id();
1850 1850
             $cart_details[]   = $item->prepare_data_for_saving();
1851 1851
         }
1852 1852
 
1853 1853
         return $cart_details;
1854
-	}
1854
+    }
1855 1855
 
1856
-	/**
1857
-	 * Retrieves the recurring item.
1858
-	 *
1859
-	 * @return null|GetPaid_Form_Item|int
1860
-	 */
1861
-	public function get_recurring( $object = false ) {
1856
+    /**
1857
+     * Retrieves the recurring item.
1858
+     *
1859
+     * @return null|GetPaid_Form_Item|int
1860
+     */
1861
+    public function get_recurring( $object = false ) {
1862 1862
 
1863
-		// Are we returning an object?
1863
+        // Are we returning an object?
1864 1864
         if ( $object ) {
1865 1865
             return $this->get_item( $this->recurring_item );
1866 1866
         }
@@ -1868,130 +1868,130 @@  discard block
 block discarded – undo
1868 1868
         return $this->recurring_item;
1869 1869
     }
1870 1870
 
1871
-	/**
1872
-	 * Retrieves the subscription name.
1873
-	 *
1874
-	 * @since 1.0.19
1875
-	 * @return string
1876
-	 */
1877
-	public function get_subscription_name() {
1871
+    /**
1872
+     * Retrieves the subscription name.
1873
+     *
1874
+     * @since 1.0.19
1875
+     * @return string
1876
+     */
1877
+    public function get_subscription_name() {
1878 1878
 
1879
-		// Retrieve the recurring name
1879
+        // Retrieve the recurring name
1880 1880
         $item = $this->get_recurring( true );
1881 1881
 
1882
-		// Abort if it does not exist.
1882
+        // Abort if it does not exist.
1883 1883
         if ( empty( $item ) ) {
1884 1884
             return '';
1885 1885
         }
1886 1886
 
1887
-		// Return the item name.
1887
+        // Return the item name.
1888 1888
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1889
-	}
1890
-
1891
-	/**
1892
-	 * Retrieves the view url.
1893
-	 *
1894
-	 * @since 1.0.19
1895
-	 * @return string
1896
-	 */
1897
-	public function get_view_url() {
1889
+    }
1890
+
1891
+    /**
1892
+     * Retrieves the view url.
1893
+     *
1894
+     * @since 1.0.19
1895
+     * @return string
1896
+     */
1897
+    public function get_view_url() {
1898 1898
         $invoice_url = get_permalink( $this->get_id() );
1899
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1899
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1900 1900
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1901
-	}
1901
+    }
1902 1902
 
1903
-	/**
1904
-	 * Retrieves the payment url.
1905
-	 *
1906
-	 * @since 1.0.19
1907
-	 * @return string
1908
-	 */
1909
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1903
+    /**
1904
+     * Retrieves the payment url.
1905
+     *
1906
+     * @since 1.0.19
1907
+     * @return string
1908
+     */
1909
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1910 1910
 
1911
-		// Retrieve the checkout url.
1911
+        // Retrieve the checkout url.
1912 1912
         $pay_url = wpinv_get_checkout_uri();
1913 1913
 
1914
-		// Maybe force ssl.
1914
+        // Maybe force ssl.
1915 1915
         if ( is_ssl() ) {
1916 1916
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1917 1917
         }
1918 1918
 
1919
-		// Add the invoice key.
1920
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1919
+        // Add the invoice key.
1920
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1921 1921
 
1922
-		// (Maybe?) add a secret
1922
+        // (Maybe?) add a secret
1923 1923
         if ( $secret ) {
1924 1924
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1925 1925
         }
1926 1926
 
1927 1927
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1928
-	}
1928
+    }
1929 1929
 
1930
-	/**
1931
-	 * Retrieves the receipt url.
1932
-	 *
1933
-	 * @since 1.0.19
1934
-	 * @return string
1935
-	 */
1936
-	public function get_receipt_url() {
1930
+    /**
1931
+     * Retrieves the receipt url.
1932
+     *
1933
+     * @since 1.0.19
1934
+     * @return string
1935
+     */
1936
+    public function get_receipt_url() {
1937 1937
 
1938
-		// Retrieve the checkout url.
1938
+        // Retrieve the checkout url.
1939 1939
         $receipt_url = wpinv_get_success_page_uri();
1940 1940
 
1941
-		// Maybe force ssl.
1941
+        // Maybe force ssl.
1942 1942
         if ( is_ssl() ) {
1943 1943
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1944 1944
         }
1945 1945
 
1946
-		// Add the invoice key.
1947
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1946
+        // Add the invoice key.
1947
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1948 1948
 
1949 1949
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1950
-	}
1951
-
1952
-	/**
1953
-	 * Retrieves the remote transaction url.
1954
-	 *
1955
-	 * @since 1.6.0
1956
-	 * @return string
1957
-	 */
1958
-	public function get_transaction_url() {
1959
-		return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1960
-	}
1961
-
1962
-	/**
1963
-	 * Retrieves the default status.
1964
-	 *
1965
-	 * @since 1.0.19
1966
-	 * @return string
1967
-	 */
1968
-	public function get_default_status() {
1969
-
1970
-		$type   = $this->get_type();
1971
-		$status = "wpi-$type-pending";
1972
-		return str_replace( '-invoice', '', $status );
1973
-
1974
-	}
1975
-
1976
-    /**
1977
-	 * Magic method for accessing invoice properties.
1978
-	 *
1979
-	 * @since 1.0.15
1980
-	 * @access public
1981
-	 *
1982
-	 * @param string $key Discount data to retrieve
1983
-	 * @param  string $context View or edit context.
1984
-	 * @return mixed Value of the given invoice property (if set).
1985
-	 */
1986
-	public function get( $key, $context = 'view' ) {
1987
-		$method = "get_$key";
1988
-
1989
-		if ( is_callable( array( $this, $method ) ) ) {
1990
-			return $this->$method( $context );
1991
-		}
1950
+    }
1951
+
1952
+    /**
1953
+     * Retrieves the remote transaction url.
1954
+     *
1955
+     * @since 1.6.0
1956
+     * @return string
1957
+     */
1958
+    public function get_transaction_url() {
1959
+        return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1960
+    }
1961
+
1962
+    /**
1963
+     * Retrieves the default status.
1964
+     *
1965
+     * @since 1.0.19
1966
+     * @return string
1967
+     */
1968
+    public function get_default_status() {
1969
+
1970
+        $type   = $this->get_type();
1971
+        $status = "wpi-$type-pending";
1972
+        return str_replace( '-invoice', '', $status );
1973
+
1974
+    }
1975
+
1976
+    /**
1977
+     * Magic method for accessing invoice properties.
1978
+     *
1979
+     * @since 1.0.15
1980
+     * @access public
1981
+     *
1982
+     * @param string $key Discount data to retrieve
1983
+     * @param  string $context View or edit context.
1984
+     * @return mixed Value of the given invoice property (if set).
1985
+     */
1986
+    public function get( $key, $context = 'view' ) {
1987
+        $method = "get_$key";
1988
+
1989
+        if ( is_callable( array( $this, $method ) ) ) {
1990
+            return $this->$method( $context );
1991
+        }
1992 1992
 
1993 1993
         return $this->get_prop( $key, $context );
1994
-	}
1994
+    }
1995 1995
 
1996 1996
     /*
1997 1997
 	|--------------------------------------------------------------------------
@@ -2004,129 +2004,129 @@  discard block
 block discarded – undo
2004 2004
     */
2005 2005
 
2006 2006
     /**
2007
-	 * Magic method for setting invoice properties.
2008
-	 *
2009
-	 * @since 1.0.19
2010
-	 * @access public
2011
-	 *
2012
-	 * @param string $key Discount data to retrieve
2013
-	 * @param  mixed $value new value.
2014
-	 * @return mixed Value of the given invoice property (if set).
2015
-	 */
2016
-	public function set( $key, $value ) {
2007
+     * Magic method for setting invoice properties.
2008
+     *
2009
+     * @since 1.0.19
2010
+     * @access public
2011
+     *
2012
+     * @param string $key Discount data to retrieve
2013
+     * @param  mixed $value new value.
2014
+     * @return mixed Value of the given invoice property (if set).
2015
+     */
2016
+    public function set( $key, $value ) {
2017 2017
 
2018 2018
         $setter = "set_$key";
2019 2019
         if ( is_callable( array( $this, $setter ) ) ) {
2020 2020
             $this->{$setter}( $value );
2021 2021
         }
2022 2022
 
2023
-	}
2024
-
2025
-	/**
2026
-	 * Sets item status.
2027
-	 *
2028
-	 * @since 1.0.19
2029
-	 * @param string $new_status    New status.
2030
-	 * @param string $note          Optional note to add.
2031
-	 * @param bool   $manual_update Is this a manual status change?.
2032
-	 * @return array details of change.
2033
-	 */
2034
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
2035
-		$old_status = $this->get_status();
2036
-
2037
-		$statuses = $this->get_all_statuses();
2038
-
2039
-		if ( isset( $statuses['draft'] ) ) {
2040
-			unset( $statuses['draft'] );
2041
-		}
2042
-
2043
-		$this->set_prop( 'status', $new_status );
2044
-
2045
-		// If setting the status, ensure it's set to a valid status.
2046
-		if ( true === $this->object_read ) {
2047
-
2048
-			// Only allow valid new status.
2049
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
2050
-				$new_status = $this->get_default_status();
2051
-			}
2052
-
2053
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2054
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2055
-				$old_status = $this->get_default_status();
2056
-			}
2057
-
2058
-			// Paid - Renewal (i.e when duplicating a parent invoice )
2059
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2060
-				$old_status = 'wpi-pending';
2061
-			}
2062
-
2063
-			if ( $old_status !== $new_status ) {
2064
-				$this->status_transition = array(
2065
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2066
-					'to'     => $new_status,
2067
-					'note'   => $note,
2068
-					'manual' => (bool) $manual_update,
2069
-				);
2070
-
2071
-				if ( $manual_update ) {
2072
-					do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status );
2073
-				}
2074
-
2075
-				$this->maybe_set_date_paid();
2076
-
2077
-			}
2078
-		}
2079
-
2080
-		return array(
2081
-			'from' => $old_status,
2082
-			'to'   => $new_status,
2083
-		);
2084
-	}
2085
-
2086
-	/**
2087
-	 * Maybe set date paid.
2088
-	 *
2089
-	 * Sets the date paid variable when transitioning to the payment complete
2090
-	 * order status.
2091
-	 *
2092
-	 * @since 1.0.19
2093
-	 */
2094
-	public function maybe_set_date_paid() {
2095
-
2096
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2097
-			$this->set_date_completed( current_time( 'mysql' ) );
2098
-		}
2099
-	}
2100
-
2101
-    /**
2102
-	 * Set parent invoice ID.
2103
-	 *
2104
-	 * @since 1.0.19
2105
-	 */
2106
-	public function set_parent_id( $value ) {
2107
-		if ( $value && ( $value === $this->get_id() ) ) {
2108
-			return;
2109
-		}
2110
-		$this->set_prop( 'parent_id', absint( $value ) );
2111
-    }
2112
-
2113
-    /**
2114
-	 * Set plugin version when the invoice was created.
2115
-	 *
2116
-	 * @since 1.0.19
2117
-	 */
2118
-	public function set_version( $value ) {
2119
-		$this->set_prop( 'version', $value );
2120
-    }
2121
-
2122
-    /**
2123
-	 * Set date when the invoice was created.
2124
-	 *
2125
-	 * @since 1.0.19
2126
-	 * @param string $value Value to set.
2023
+    }
2024
+
2025
+    /**
2026
+     * Sets item status.
2027
+     *
2028
+     * @since 1.0.19
2029
+     * @param string $new_status    New status.
2030
+     * @param string $note          Optional note to add.
2031
+     * @param bool   $manual_update Is this a manual status change?.
2032
+     * @return array details of change.
2033
+     */
2034
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
2035
+        $old_status = $this->get_status();
2036
+
2037
+        $statuses = $this->get_all_statuses();
2038
+
2039
+        if ( isset( $statuses['draft'] ) ) {
2040
+            unset( $statuses['draft'] );
2041
+        }
2042
+
2043
+        $this->set_prop( 'status', $new_status );
2044
+
2045
+        // If setting the status, ensure it's set to a valid status.
2046
+        if ( true === $this->object_read ) {
2047
+
2048
+            // Only allow valid new status.
2049
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
2050
+                $new_status = $this->get_default_status();
2051
+            }
2052
+
2053
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2054
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2055
+                $old_status = $this->get_default_status();
2056
+            }
2057
+
2058
+            // Paid - Renewal (i.e when duplicating a parent invoice )
2059
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2060
+                $old_status = 'wpi-pending';
2061
+            }
2062
+
2063
+            if ( $old_status !== $new_status ) {
2064
+                $this->status_transition = array(
2065
+                    'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2066
+                    'to'     => $new_status,
2067
+                    'note'   => $note,
2068
+                    'manual' => (bool) $manual_update,
2069
+                );
2070
+
2071
+                if ( $manual_update ) {
2072
+                    do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status );
2073
+                }
2074
+
2075
+                $this->maybe_set_date_paid();
2076
+
2077
+            }
2078
+        }
2079
+
2080
+        return array(
2081
+            'from' => $old_status,
2082
+            'to'   => $new_status,
2083
+        );
2084
+    }
2085
+
2086
+    /**
2087
+     * Maybe set date paid.
2088
+     *
2089
+     * Sets the date paid variable when transitioning to the payment complete
2090
+     * order status.
2091
+     *
2092
+     * @since 1.0.19
2093
+     */
2094
+    public function maybe_set_date_paid() {
2095
+
2096
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2097
+            $this->set_date_completed( current_time( 'mysql' ) );
2098
+        }
2099
+    }
2100
+
2101
+    /**
2102
+     * Set parent invoice ID.
2103
+     *
2104
+     * @since 1.0.19
2105
+     */
2106
+    public function set_parent_id( $value ) {
2107
+        if ( $value && ( $value === $this->get_id() ) ) {
2108
+            return;
2109
+        }
2110
+        $this->set_prop( 'parent_id', absint( $value ) );
2111
+    }
2112
+
2113
+    /**
2114
+     * Set plugin version when the invoice was created.
2115
+     *
2116
+     * @since 1.0.19
2117
+     */
2118
+    public function set_version( $value ) {
2119
+        $this->set_prop( 'version', $value );
2120
+    }
2121
+
2122
+    /**
2123
+     * Set date when the invoice was created.
2124
+     *
2125
+     * @since 1.0.19
2126
+     * @param string $value Value to set.
2127 2127
      * @return bool Whether or not the date was set.
2128
-	 */
2129
-	public function set_date_created( $value ) {
2128
+     */
2129
+    public function set_date_created( $value ) {
2130 2130
         $date = strtotime( $value );
2131 2131
 
2132 2132
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2134,19 +2134,19 @@  discard block
 block discarded – undo
2134 2134
             return true;
2135 2135
         }
2136 2136
 
2137
-		$this->set_prop( 'date_created', '' );
2138
-		return false;
2137
+        $this->set_prop( 'date_created', '' );
2138
+        return false;
2139 2139
 
2140 2140
     }
2141 2141
 
2142 2142
     /**
2143
-	 * Set date invoice due date.
2144
-	 *
2145
-	 * @since 1.0.19
2146
-	 * @param string $value Value to set.
2143
+     * Set date invoice due date.
2144
+     *
2145
+     * @since 1.0.19
2146
+     * @param string $value Value to set.
2147 2147
      * @return bool Whether or not the date was set.
2148
-	 */
2149
-	public function set_due_date( $value ) {
2148
+     */
2149
+    public function set_due_date( $value ) {
2150 2150
         $date = strtotime( $value );
2151 2151
 
2152 2152
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2154,29 +2154,29 @@  discard block
 block discarded – undo
2154 2154
             return true;
2155 2155
         }
2156 2156
 
2157
-		$this->set_prop( 'due_date', '' );
2157
+        $this->set_prop( 'due_date', '' );
2158 2158
         return false;
2159 2159
 
2160 2160
     }
2161 2161
 
2162 2162
     /**
2163
-	 * Alias of self::set_due_date().
2164
-	 *
2165
-	 * @since 1.0.19
2166
-	 * @param  string $value New name.
2167
-	 */
2168
-	public function set_date_due( $value ) {
2169
-		$this->set_due_date( $value );
2163
+     * Alias of self::set_due_date().
2164
+     *
2165
+     * @since 1.0.19
2166
+     * @param  string $value New name.
2167
+     */
2168
+    public function set_date_due( $value ) {
2169
+        $this->set_due_date( $value );
2170 2170
     }
2171 2171
 
2172 2172
     /**
2173
-	 * Set date invoice was completed.
2174
-	 *
2175
-	 * @since 1.0.19
2176
-	 * @param string $value Value to set.
2173
+     * Set date invoice was completed.
2174
+     *
2175
+     * @since 1.0.19
2176
+     * @param string $value Value to set.
2177 2177
      * @return bool Whether or not the date was set.
2178
-	 */
2179
-	public function set_completed_date( $value ) {
2178
+     */
2179
+    public function set_completed_date( $value ) {
2180 2180
         $date = strtotime( $value );
2181 2181
 
2182 2182
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2184,29 +2184,29 @@  discard block
 block discarded – undo
2184 2184
             return true;
2185 2185
         }
2186 2186
 
2187
-		$this->set_prop( 'completed_date', '' );
2187
+        $this->set_prop( 'completed_date', '' );
2188 2188
         return false;
2189 2189
 
2190 2190
     }
2191 2191
 
2192 2192
     /**
2193
-	 * Alias of self::set_completed_date().
2194
-	 *
2195
-	 * @since 1.0.19
2196
-	 * @param  string $value New name.
2197
-	 */
2198
-	public function set_date_completed( $value ) {
2199
-		$this->set_completed_date( $value );
2193
+     * Alias of self::set_completed_date().
2194
+     *
2195
+     * @since 1.0.19
2196
+     * @param  string $value New name.
2197
+     */
2198
+    public function set_date_completed( $value ) {
2199
+        $this->set_completed_date( $value );
2200 2200
     }
2201 2201
 
2202 2202
     /**
2203
-	 * Set date when the invoice was last modified.
2204
-	 *
2205
-	 * @since 1.0.19
2206
-	 * @param string $value Value to set.
2203
+     * Set date when the invoice was last modified.
2204
+     *
2205
+     * @since 1.0.19
2206
+     * @param string $value Value to set.
2207 2207
      * @return bool Whether or not the date was set.
2208
-	 */
2209
-	public function set_date_modified( $value ) {
2208
+     */
2209
+    public function set_date_modified( $value ) {
2210 2210
         $date = strtotime( $value );
2211 2211
 
2212 2212
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2214,813 +2214,813 @@  discard block
 block discarded – undo
2214 2214
             return true;
2215 2215
         }
2216 2216
 
2217
-		$this->set_prop( 'date_modified', '' );
2217
+        $this->set_prop( 'date_modified', '' );
2218 2218
         return false;
2219 2219
 
2220 2220
     }
2221 2221
 
2222 2222
     /**
2223
-	 * Set the invoice number.
2224
-	 *
2225
-	 * @since 1.0.19
2226
-	 * @param  string $value New number.
2227
-	 */
2228
-	public function set_number( $value ) {
2223
+     * Set the invoice number.
2224
+     *
2225
+     * @since 1.0.19
2226
+     * @param  string $value New number.
2227
+     */
2228
+    public function set_number( $value ) {
2229 2229
         $number = sanitize_text_field( $value );
2230
-		$this->set_prop( 'number', $number );
2230
+        $this->set_prop( 'number', $number );
2231 2231
     }
2232 2232
 
2233 2233
     /**
2234
-	 * Set the invoice type.
2235
-	 *
2236
-	 * @since 1.0.19
2237
-	 * @param  string $value Type.
2238
-	 */
2239
-	public function set_type( $value ) {
2234
+     * Set the invoice type.
2235
+     *
2236
+     * @since 1.0.19
2237
+     * @param  string $value Type.
2238
+     */
2239
+    public function set_type( $value ) {
2240 2240
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2241
-		$this->set_prop( 'type', $type );
2242
-	}
2241
+        $this->set_prop( 'type', $type );
2242
+    }
2243 2243
 
2244 2244
     /**
2245
-	 * Set the invoice post type.
2246
-	 *
2247
-	 * @since 1.0.19
2248
-	 * @param  string $value Post type.
2249
-	 */
2250
-	public function set_post_type( $value ) {
2245
+     * Set the invoice post type.
2246
+     *
2247
+     * @since 1.0.19
2248
+     * @param  string $value Post type.
2249
+     */
2250
+    public function set_post_type( $value ) {
2251 2251
         if ( getpaid_is_invoice_post_type( $value ) ) {
2252
-			$this->set_type( $value );
2252
+            $this->set_type( $value );
2253 2253
             $this->set_prop( 'post_type', $value );
2254 2254
         }
2255 2255
     }
2256 2256
 
2257 2257
     /**
2258
-	 * Set the invoice key.
2259
-	 *
2260
-	 * @since 1.0.19
2261
-	 * @param  string $value New key.
2262
-	 */
2263
-	public function set_key( $value ) {
2258
+     * Set the invoice key.
2259
+     *
2260
+     * @since 1.0.19
2261
+     * @param  string $value New key.
2262
+     */
2263
+    public function set_key( $value ) {
2264 2264
         $key = sanitize_text_field( $value );
2265
-		$this->set_prop( 'key', $key );
2265
+        $this->set_prop( 'key', $key );
2266 2266
     }
2267 2267
 
2268 2268
     /**
2269
-	 * Set the invoice mode.
2270
-	 *
2271
-	 * @since 1.0.19
2272
-	 * @param  string $value mode.
2273
-	 */
2274
-	public function set_mode( $value ) {
2269
+     * Set the invoice mode.
2270
+     *
2271
+     * @since 1.0.19
2272
+     * @param  string $value mode.
2273
+     */
2274
+    public function set_mode( $value ) {
2275 2275
         if ( in_array( $value, array( 'live', 'test' ) ) ) {
2276 2276
             $this->set_prop( 'mode', $value );
2277 2277
         }
2278 2278
     }
2279 2279
 
2280 2280
     /**
2281
-	 * Set the invoice path.
2282
-	 *
2283
-	 * @since 1.0.19
2284
-	 * @param  string $value path.
2285
-	 */
2286
-	public function set_path( $value ) {
2281
+     * Set the invoice path.
2282
+     *
2283
+     * @since 1.0.19
2284
+     * @param  string $value path.
2285
+     */
2286
+    public function set_path( $value ) {
2287 2287
         $this->set_prop( 'path', $value );
2288 2288
     }
2289 2289
 
2290 2290
     /**
2291
-	 * Set the invoice name.
2292
-	 *
2293
-	 * @since 1.0.19
2294
-	 * @param  string $value New name.
2295
-	 */
2296
-	public function set_name( $value ) {
2291
+     * Set the invoice name.
2292
+     *
2293
+     * @since 1.0.19
2294
+     * @param  string $value New name.
2295
+     */
2296
+    public function set_name( $value ) {
2297 2297
         $name = sanitize_text_field( $value );
2298
-		$this->set_prop( 'name', $name );
2298
+        $this->set_prop( 'name', $name );
2299 2299
     }
2300 2300
 
2301 2301
     /**
2302
-	 * Alias of self::set_name().
2303
-	 *
2304
-	 * @since 1.0.19
2305
-	 * @param  string $value New name.
2306
-	 */
2307
-	public function set_title( $value ) {
2308
-		$this->set_name( $value );
2302
+     * Alias of self::set_name().
2303
+     *
2304
+     * @since 1.0.19
2305
+     * @param  string $value New name.
2306
+     */
2307
+    public function set_title( $value ) {
2308
+        $this->set_name( $value );
2309 2309
     }
2310 2310
 
2311 2311
     /**
2312
-	 * Set the invoice description.
2313
-	 *
2314
-	 * @since 1.0.19
2315
-	 * @param  string $value New description.
2316
-	 */
2317
-	public function set_description( $value ) {
2312
+     * Set the invoice description.
2313
+     *
2314
+     * @since 1.0.19
2315
+     * @param  string $value New description.
2316
+     */
2317
+    public function set_description( $value ) {
2318 2318
         $description = wp_kses_post( $value );
2319
-		$this->set_prop( 'description', $description );
2319
+        $this->set_prop( 'description', $description );
2320
+    }
2321
+
2322
+    /**
2323
+     * Alias of self::set_description().
2324
+     *
2325
+     * @since 1.0.19
2326
+     * @param  string $value New description.
2327
+     */
2328
+    public function set_excerpt( $value ) {
2329
+        $this->set_description( $value );
2330
+    }
2331
+
2332
+    /**
2333
+     * Alias of self::set_description().
2334
+     *
2335
+     * @since 1.0.19
2336
+     * @param  string $value New description.
2337
+     */
2338
+    public function set_summary( $value ) {
2339
+        $this->set_description( $value );
2340
+    }
2341
+
2342
+    /**
2343
+     * Set the receiver of the invoice.
2344
+     *
2345
+     * @since 1.0.19
2346
+     * @param  int $value New author.
2347
+     */
2348
+    public function set_author( $value ) {
2349
+        $user = get_user_by( 'id', (int) $value );
2350
+
2351
+        if ( $user && $user->ID ) {
2352
+            $this->set_prop( 'author', $user->ID );
2353
+            $this->set_prop( 'email', $user->user_email );
2354
+        }
2355
+
2356
+    }
2357
+
2358
+    /**
2359
+     * Alias of self::set_author().
2360
+     *
2361
+     * @since 1.0.19
2362
+     * @param  int $value New user id.
2363
+     */
2364
+    public function set_user_id( $value ) {
2365
+        $this->set_author( $value );
2366
+    }
2367
+
2368
+    /**
2369
+     * Alias of self::set_author().
2370
+     *
2371
+     * @since 1.0.19
2372
+     * @param  int $value New user id.
2373
+     */
2374
+    public function set_customer_id( $value ) {
2375
+        $this->set_author( $value );
2376
+    }
2377
+
2378
+    /**
2379
+     * Set the customer's ip.
2380
+     *
2381
+     * @since 1.0.19
2382
+     * @param  string $value ip address.
2383
+     */
2384
+    public function set_ip( $value ) {
2385
+        $this->set_prop( 'ip', $value );
2386
+    }
2387
+
2388
+    /**
2389
+     * Alias of self::set_ip().
2390
+     *
2391
+     * @since 1.0.19
2392
+     * @param  string $value ip address.
2393
+     */
2394
+    public function set_user_ip( $value ) {
2395
+        $this->set_ip( $value );
2396
+    }
2397
+
2398
+    /**
2399
+     * Set the customer's first name.
2400
+     *
2401
+     * @since 1.0.19
2402
+     * @param  string $value first name.
2403
+     */
2404
+    public function set_first_name( $value ) {
2405
+        $this->set_prop( 'first_name', $value );
2406
+    }
2407
+
2408
+    /**
2409
+     * Alias of self::set_first_name().
2410
+     *
2411
+     * @since 1.0.19
2412
+     * @param  string $value first name.
2413
+     */
2414
+    public function set_user_first_name( $value ) {
2415
+        $this->set_first_name( $value );
2416
+    }
2417
+
2418
+    /**
2419
+     * Alias of self::set_first_name().
2420
+     *
2421
+     * @since 1.0.19
2422
+     * @param  string $value first name.
2423
+     */
2424
+    public function set_customer_first_name( $value ) {
2425
+        $this->set_first_name( $value );
2426
+    }
2427
+
2428
+    /**
2429
+     * Set the customer's last name.
2430
+     *
2431
+     * @since 1.0.19
2432
+     * @param  string $value last name.
2433
+     */
2434
+    public function set_last_name( $value ) {
2435
+        $this->set_prop( 'last_name', $value );
2436
+    }
2437
+
2438
+    /**
2439
+     * Alias of self::set_last_name().
2440
+     *
2441
+     * @since 1.0.19
2442
+     * @param  string $value last name.
2443
+     */
2444
+    public function set_user_last_name( $value ) {
2445
+        $this->set_last_name( $value );
2446
+    }
2447
+
2448
+    /**
2449
+     * Alias of self::set_last_name().
2450
+     *
2451
+     * @since 1.0.19
2452
+     * @param  string $value last name.
2453
+     */
2454
+    public function set_customer_last_name( $value ) {
2455
+        $this->set_last_name( $value );
2456
+    }
2457
+
2458
+    /**
2459
+     * Set the customer's phone number.
2460
+     *
2461
+     * @since 1.0.19
2462
+     * @param  string $value phone.
2463
+     */
2464
+    public function set_phone( $value ) {
2465
+        $this->set_prop( 'phone', $value );
2320 2466
     }
2321 2467
 
2322 2468
     /**
2323
-	 * Alias of self::set_description().
2324
-	 *
2325
-	 * @since 1.0.19
2326
-	 * @param  string $value New description.
2327
-	 */
2328
-	public function set_excerpt( $value ) {
2329
-		$this->set_description( $value );
2469
+     * Alias of self::set_phone().
2470
+     *
2471
+     * @since 1.0.19
2472
+     * @param  string $value phone.
2473
+     */
2474
+    public function set_user_phone( $value ) {
2475
+        $this->set_phone( $value );
2330 2476
     }
2331 2477
 
2332 2478
     /**
2333
-	 * Alias of self::set_description().
2334
-	 *
2335
-	 * @since 1.0.19
2336
-	 * @param  string $value New description.
2337
-	 */
2338
-	public function set_summary( $value ) {
2339
-		$this->set_description( $value );
2479
+     * Alias of self::set_phone().
2480
+     *
2481
+     * @since 1.0.19
2482
+     * @param  string $value phone.
2483
+     */
2484
+    public function set_customer_phone( $value ) {
2485
+        $this->set_phone( $value );
2340 2486
     }
2341 2487
 
2342 2488
     /**
2343
-	 * Set the receiver of the invoice.
2344
-	 *
2345
-	 * @since 1.0.19
2346
-	 * @param  int $value New author.
2347
-	 */
2348
-	public function set_author( $value ) {
2349
-		$user = get_user_by( 'id', (int) $value );
2489
+     * Alias of self::set_phone().
2490
+     *
2491
+     * @since 1.0.19
2492
+     * @param  string $value phone.
2493
+     */
2494
+    public function set_phone_number( $value ) {
2495
+        $this->set_phone( $value );
2496
+    }
2350 2497
 
2351
-		if ( $user && $user->ID ) {
2352
-			$this->set_prop( 'author', $user->ID );
2353
-			$this->set_prop( 'email', $user->user_email );
2354
-		}
2498
+    /**
2499
+     * Set the customer's email address.
2500
+     *
2501
+     * @since 1.0.19
2502
+     * @param  string $value email address.
2503
+     */
2504
+    public function set_email( $value ) {
2505
+        $this->set_prop( 'email', $value );
2506
+    }
2355 2507
 
2508
+    /**
2509
+     * Alias of self::set_email().
2510
+     *
2511
+     * @since 1.0.19
2512
+     * @param  string $value email address.
2513
+     */
2514
+    public function set_user_email( $value ) {
2515
+        $this->set_email( $value );
2356 2516
     }
2357 2517
 
2358 2518
     /**
2359
-	 * Alias of self::set_author().
2360
-	 *
2361
-	 * @since 1.0.19
2362
-	 * @param  int $value New user id.
2363
-	 */
2364
-	public function set_user_id( $value ) {
2365
-		$this->set_author( $value );
2519
+     * Alias of self::set_email().
2520
+     *
2521
+     * @since 1.0.19
2522
+     * @param  string $value email address.
2523
+     */
2524
+    public function set_email_address( $value ) {
2525
+        $this->set_email( $value );
2366 2526
     }
2367 2527
 
2368 2528
     /**
2369
-	 * Alias of self::set_author().
2370
-	 *
2371
-	 * @since 1.0.19
2372
-	 * @param  int $value New user id.
2373
-	 */
2374
-	public function set_customer_id( $value ) {
2375
-		$this->set_author( $value );
2529
+     * Alias of self::set_email().
2530
+     *
2531
+     * @since 1.0.19
2532
+     * @param  string $value email address.
2533
+     */
2534
+    public function set_customer_email( $value ) {
2535
+        $this->set_email( $value );
2376 2536
     }
2377 2537
 
2378 2538
     /**
2379
-	 * Set the customer's ip.
2380
-	 *
2381
-	 * @since 1.0.19
2382
-	 * @param  string $value ip address.
2383
-	 */
2384
-	public function set_ip( $value ) {
2385
-		$this->set_prop( 'ip', $value );
2539
+     * Set the customer's country.
2540
+     *
2541
+     * @since 1.0.19
2542
+     * @param  string $value country.
2543
+     */
2544
+    public function set_country( $value ) {
2545
+        $this->set_prop( 'country', $value );
2386 2546
     }
2387 2547
 
2388 2548
     /**
2389
-	 * Alias of self::set_ip().
2390
-	 *
2391
-	 * @since 1.0.19
2392
-	 * @param  string $value ip address.
2393
-	 */
2394
-	public function set_user_ip( $value ) {
2395
-		$this->set_ip( $value );
2549
+     * Alias of self::set_country().
2550
+     *
2551
+     * @since 1.0.19
2552
+     * @param  string $value country.
2553
+     */
2554
+    public function set_user_country( $value ) {
2555
+        $this->set_country( $value );
2396 2556
     }
2397 2557
 
2398 2558
     /**
2399
-	 * Set the customer's first name.
2400
-	 *
2401
-	 * @since 1.0.19
2402
-	 * @param  string $value first name.
2403
-	 */
2404
-	public function set_first_name( $value ) {
2405
-		$this->set_prop( 'first_name', $value );
2559
+     * Alias of self::set_country().
2560
+     *
2561
+     * @since 1.0.19
2562
+     * @param  string $value country.
2563
+     */
2564
+    public function set_customer_country( $value ) {
2565
+        $this->set_country( $value );
2406 2566
     }
2407 2567
 
2408 2568
     /**
2409
-	 * Alias of self::set_first_name().
2410
-	 *
2411
-	 * @since 1.0.19
2412
-	 * @param  string $value first name.
2413
-	 */
2414
-	public function set_user_first_name( $value ) {
2415
-		$this->set_first_name( $value );
2569
+     * Set the customer's state.
2570
+     *
2571
+     * @since 1.0.19
2572
+     * @param  string $value state.
2573
+     */
2574
+    public function set_state( $value ) {
2575
+        $this->set_prop( 'state', $value );
2416 2576
     }
2417 2577
 
2418 2578
     /**
2419
-	 * Alias of self::set_first_name().
2420
-	 *
2421
-	 * @since 1.0.19
2422
-	 * @param  string $value first name.
2423
-	 */
2424
-	public function set_customer_first_name( $value ) {
2425
-		$this->set_first_name( $value );
2579
+     * Alias of self::set_state().
2580
+     *
2581
+     * @since 1.0.19
2582
+     * @param  string $value state.
2583
+     */
2584
+    public function set_user_state( $value ) {
2585
+        $this->set_state( $value );
2426 2586
     }
2427 2587
 
2428 2588
     /**
2429
-	 * Set the customer's last name.
2430
-	 *
2431
-	 * @since 1.0.19
2432
-	 * @param  string $value last name.
2433
-	 */
2434
-	public function set_last_name( $value ) {
2435
-		$this->set_prop( 'last_name', $value );
2589
+     * Alias of self::set_state().
2590
+     *
2591
+     * @since 1.0.19
2592
+     * @param  string $value state.
2593
+     */
2594
+    public function set_customer_state( $value ) {
2595
+        $this->set_state( $value );
2436 2596
     }
2437 2597
 
2438 2598
     /**
2439
-	 * Alias of self::set_last_name().
2440
-	 *
2441
-	 * @since 1.0.19
2442
-	 * @param  string $value last name.
2443
-	 */
2444
-	public function set_user_last_name( $value ) {
2445
-		$this->set_last_name( $value );
2599
+     * Set the customer's city.
2600
+     *
2601
+     * @since 1.0.19
2602
+     * @param  string $value city.
2603
+     */
2604
+    public function set_city( $value ) {
2605
+        $this->set_prop( 'city', $value );
2446 2606
     }
2447 2607
 
2448 2608
     /**
2449
-	 * Alias of self::set_last_name().
2450
-	 *
2451
-	 * @since 1.0.19
2452
-	 * @param  string $value last name.
2453
-	 */
2454
-	public function set_customer_last_name( $value ) {
2455
-		$this->set_last_name( $value );
2609
+     * Alias of self::set_city().
2610
+     *
2611
+     * @since 1.0.19
2612
+     * @param  string $value city.
2613
+     */
2614
+    public function set_user_city( $value ) {
2615
+        $this->set_city( $value );
2456 2616
     }
2457 2617
 
2458 2618
     /**
2459
-	 * Set the customer's phone number.
2460
-	 *
2461
-	 * @since 1.0.19
2462
-	 * @param  string $value phone.
2463
-	 */
2464
-	public function set_phone( $value ) {
2465
-		$this->set_prop( 'phone', $value );
2619
+     * Alias of self::set_city().
2620
+     *
2621
+     * @since 1.0.19
2622
+     * @param  string $value city.
2623
+     */
2624
+    public function set_customer_city( $value ) {
2625
+        $this->set_city( $value );
2466 2626
     }
2467 2627
 
2468 2628
     /**
2469
-	 * Alias of self::set_phone().
2470
-	 *
2471
-	 * @since 1.0.19
2472
-	 * @param  string $value phone.
2473
-	 */
2474
-	public function set_user_phone( $value ) {
2475
-		$this->set_phone( $value );
2629
+     * Set the customer's zip code.
2630
+     *
2631
+     * @since 1.0.19
2632
+     * @param  string $value zip.
2633
+     */
2634
+    public function set_zip( $value ) {
2635
+        $this->set_prop( 'zip', $value );
2476 2636
     }
2477 2637
 
2478 2638
     /**
2479
-	 * Alias of self::set_phone().
2480
-	 *
2481
-	 * @since 1.0.19
2482
-	 * @param  string $value phone.
2483
-	 */
2484
-	public function set_customer_phone( $value ) {
2485
-		$this->set_phone( $value );
2639
+     * Alias of self::set_zip().
2640
+     *
2641
+     * @since 1.0.19
2642
+     * @param  string $value zip.
2643
+     */
2644
+    public function set_user_zip( $value ) {
2645
+        $this->set_zip( $value );
2486 2646
     }
2487 2647
 
2488 2648
     /**
2489
-	 * Alias of self::set_phone().
2490
-	 *
2491
-	 * @since 1.0.19
2492
-	 * @param  string $value phone.
2493
-	 */
2494
-	public function set_phone_number( $value ) {
2495
-		$this->set_phone( $value );
2649
+     * Alias of self::set_zip().
2650
+     *
2651
+     * @since 1.0.19
2652
+     * @param  string $value zip.
2653
+     */
2654
+    public function set_customer_zip( $value ) {
2655
+        $this->set_zip( $value );
2496 2656
     }
2497 2657
 
2498 2658
     /**
2499
-	 * Set the customer's email address.
2500
-	 *
2501
-	 * @since 1.0.19
2502
-	 * @param  string $value email address.
2503
-	 */
2504
-	public function set_email( $value ) {
2505
-		$this->set_prop( 'email', $value );
2659
+     * Set the customer's company.
2660
+     *
2661
+     * @since 1.0.19
2662
+     * @param  string $value company.
2663
+     */
2664
+    public function set_company( $value ) {
2665
+        $this->set_prop( 'company', $value );
2506 2666
     }
2507 2667
 
2508 2668
     /**
2509
-	 * Alias of self::set_email().
2510
-	 *
2511
-	 * @since 1.0.19
2512
-	 * @param  string $value email address.
2513
-	 */
2514
-	public function set_user_email( $value ) {
2515
-		$this->set_email( $value );
2669
+     * Alias of self::set_company().
2670
+     *
2671
+     * @since 1.0.19
2672
+     * @param  string $value company.
2673
+     */
2674
+    public function set_user_company( $value ) {
2675
+        $this->set_company( $value );
2516 2676
     }
2517 2677
 
2518 2678
     /**
2519
-	 * Alias of self::set_email().
2520
-	 *
2521
-	 * @since 1.0.19
2522
-	 * @param  string $value email address.
2523
-	 */
2524
-	public function set_email_address( $value ) {
2525
-		$this->set_email( $value );
2679
+     * Alias of self::set_company().
2680
+     *
2681
+     * @since 1.0.19
2682
+     * @param  string $value company.
2683
+     */
2684
+    public function set_customer_company( $value ) {
2685
+        $this->set_company( $value );
2526 2686
     }
2527 2687
 
2528 2688
     /**
2529
-	 * Alias of self::set_email().
2530
-	 *
2531
-	 * @since 1.0.19
2532
-	 * @param  string $value email address.
2533
-	 */
2534
-	public function set_customer_email( $value ) {
2535
-		$this->set_email( $value );
2689
+     * Set the customer's company id.
2690
+     *
2691
+     * @since 1.0.19
2692
+     * @param  string $value company id.
2693
+     */
2694
+    public function set_company_id( $value ) {
2695
+        $this->set_prop( 'company_id', $value );
2536 2696
     }
2537 2697
 
2538 2698
     /**
2539
-	 * Set the customer's country.
2540
-	 *
2541
-	 * @since 1.0.19
2542
-	 * @param  string $value country.
2543
-	 */
2544
-	public function set_country( $value ) {
2545
-		$this->set_prop( 'country', $value );
2699
+     * Set the customer's var number.
2700
+     *
2701
+     * @since 1.0.19
2702
+     * @param  string $value var number.
2703
+     */
2704
+    public function set_vat_number( $value ) {
2705
+        $this->set_prop( 'vat_number', $value );
2546 2706
     }
2547 2707
 
2548 2708
     /**
2549
-	 * Alias of self::set_country().
2550
-	 *
2551
-	 * @since 1.0.19
2552
-	 * @param  string $value country.
2553
-	 */
2554
-	public function set_user_country( $value ) {
2555
-		$this->set_country( $value );
2709
+     * Alias of self::set_vat_number().
2710
+     *
2711
+     * @since 1.0.19
2712
+     * @param  string $value var number.
2713
+     */
2714
+    public function set_user_vat_number( $value ) {
2715
+        $this->set_vat_number( $value );
2556 2716
     }
2557 2717
 
2558 2718
     /**
2559
-	 * Alias of self::set_country().
2560
-	 *
2561
-	 * @since 1.0.19
2562
-	 * @param  string $value country.
2563
-	 */
2564
-	public function set_customer_country( $value ) {
2565
-		$this->set_country( $value );
2719
+     * Alias of self::set_vat_number().
2720
+     *
2721
+     * @since 1.0.19
2722
+     * @param  string $value var number.
2723
+     */
2724
+    public function set_customer_vat_number( $value ) {
2725
+        $this->set_vat_number( $value );
2566 2726
     }
2567 2727
 
2568 2728
     /**
2569
-	 * Set the customer's state.
2570
-	 *
2571
-	 * @since 1.0.19
2572
-	 * @param  string $value state.
2573
-	 */
2574
-	public function set_state( $value ) {
2575
-		$this->set_prop( 'state', $value );
2729
+     * Set the customer's vat rate.
2730
+     *
2731
+     * @since 1.0.19
2732
+     * @param  string $value var rate.
2733
+     */
2734
+    public function set_vat_rate( $value ) {
2735
+        $this->set_prop( 'vat_rate', $value );
2576 2736
     }
2577 2737
 
2578 2738
     /**
2579
-	 * Alias of self::set_state().
2580
-	 *
2581
-	 * @since 1.0.19
2582
-	 * @param  string $value state.
2583
-	 */
2584
-	public function set_user_state( $value ) {
2585
-		$this->set_state( $value );
2739
+     * Alias of self::set_vat_rate().
2740
+     *
2741
+     * @since 1.0.19
2742
+     * @param  string $value var number.
2743
+     */
2744
+    public function set_user_vat_rate( $value ) {
2745
+        $this->set_vat_rate( $value );
2586 2746
     }
2587 2747
 
2588 2748
     /**
2589
-	 * Alias of self::set_state().
2590
-	 *
2591
-	 * @since 1.0.19
2592
-	 * @param  string $value state.
2593
-	 */
2594
-	public function set_customer_state( $value ) {
2595
-		$this->set_state( $value );
2749
+     * Alias of self::set_vat_rate().
2750
+     *
2751
+     * @since 1.0.19
2752
+     * @param  string $value var number.
2753
+     */
2754
+    public function set_customer_vat_rate( $value ) {
2755
+        $this->set_vat_rate( $value );
2596 2756
     }
2597 2757
 
2598 2758
     /**
2599
-	 * Set the customer's city.
2600
-	 *
2601
-	 * @since 1.0.19
2602
-	 * @param  string $value city.
2603
-	 */
2604
-	public function set_city( $value ) {
2605
-		$this->set_prop( 'city', $value );
2759
+     * Set the customer's address.
2760
+     *
2761
+     * @since 1.0.19
2762
+     * @param  string $value address.
2763
+     */
2764
+    public function set_address( $value ) {
2765
+        $this->set_prop( 'address', $value );
2606 2766
     }
2607 2767
 
2608 2768
     /**
2609
-	 * Alias of self::set_city().
2610
-	 *
2611
-	 * @since 1.0.19
2612
-	 * @param  string $value city.
2613
-	 */
2614
-	public function set_user_city( $value ) {
2615
-		$this->set_city( $value );
2769
+     * Alias of self::set_address().
2770
+     *
2771
+     * @since 1.0.19
2772
+     * @param  string $value address.
2773
+     */
2774
+    public function set_user_address( $value ) {
2775
+        $this->set_address( $value );
2616 2776
     }
2617 2777
 
2618 2778
     /**
2619
-	 * Alias of self::set_city().
2620
-	 *
2621
-	 * @since 1.0.19
2622
-	 * @param  string $value city.
2623
-	 */
2624
-	public function set_customer_city( $value ) {
2625
-		$this->set_city( $value );
2779
+     * Alias of self::set_address().
2780
+     *
2781
+     * @since 1.0.19
2782
+     * @param  string $value address.
2783
+     */
2784
+    public function set_customer_address( $value ) {
2785
+        $this->set_address( $value );
2626 2786
     }
2627 2787
 
2628 2788
     /**
2629
-	 * Set the customer's zip code.
2630
-	 *
2631
-	 * @since 1.0.19
2632
-	 * @param  string $value zip.
2633
-	 */
2634
-	public function set_zip( $value ) {
2635
-		$this->set_prop( 'zip', $value );
2789
+     * Set whether the customer has viewed the invoice or not.
2790
+     *
2791
+     * @since 1.0.19
2792
+     * @param  int|bool $value confirmed.
2793
+     */
2794
+    public function set_is_viewed( $value ) {
2795
+        $this->set_prop( 'is_viewed', $value );
2636 2796
     }
2637 2797
 
2638 2798
     /**
2639
-	 * Alias of self::set_zip().
2640
-	 *
2641
-	 * @since 1.0.19
2642
-	 * @param  string $value zip.
2643
-	 */
2644
-	public function set_user_zip( $value ) {
2645
-		$this->set_zip( $value );
2799
+     * Set extra email recipients.
2800
+     *
2801
+     * @since 1.0.19
2802
+     * @param  string $value email recipients.
2803
+     */
2804
+    public function set_email_cc( $value ) {
2805
+        $this->set_prop( 'email_cc', $value );
2646 2806
     }
2647 2807
 
2648 2808
     /**
2649
-	 * Alias of self::set_zip().
2650
-	 *
2651
-	 * @since 1.0.19
2652
-	 * @param  string $value zip.
2653
-	 */
2654
-	public function set_customer_zip( $value ) {
2655
-		$this->set_zip( $value );
2809
+     * Set the invoice template.
2810
+     *
2811
+     * @since 1.0.19
2812
+     * @param  string $value template.
2813
+     */
2814
+    public function set_template( $value ) {
2815
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2816
+            $this->set_prop( 'template', $value );
2817
+        }
2656 2818
     }
2657 2819
 
2658 2820
     /**
2659
-	 * Set the customer's company.
2660
-	 *
2661
-	 * @since 1.0.19
2662
-	 * @param  string $value company.
2663
-	 */
2664
-	public function set_company( $value ) {
2665
-		$this->set_prop( 'company', $value );
2821
+     * Set the invoice source.
2822
+     *
2823
+     * @since 1.0.19
2824
+     * @param  string $value source.
2825
+     * @deprecated
2826
+     */
2827
+    public function created_via( $value ) {
2828
+        $this->set_created_via( sanitize_text_field( $value ) );
2666 2829
     }
2667 2830
 
2668 2831
     /**
2669
-	 * Alias of self::set_company().
2670
-	 *
2671
-	 * @since 1.0.19
2672
-	 * @param  string $value company.
2673
-	 */
2674
-	public function set_user_company( $value ) {
2675
-		$this->set_company( $value );
2832
+     * Set the invoice source.
2833
+     *
2834
+     * @since 1.0.19
2835
+     * @param  string $value source.
2836
+     */
2837
+    public function set_created_via( $value ) {
2838
+        $this->set_prop( 'created_via', sanitize_text_field( $value ) );
2676 2839
     }
2677 2840
 
2678 2841
     /**
2679
-	 * Alias of self::set_company().
2680
-	 *
2681
-	 * @since 1.0.19
2682
-	 * @param  string $value company.
2683
-	 */
2684
-	public function set_customer_company( $value ) {
2685
-		$this->set_company( $value );
2686
-    }
2687
-
2688
-	/**
2689
-	 * Set the customer's company id.
2690
-	 *
2691
-	 * @since 1.0.19
2692
-	 * @param  string $value company id.
2693
-	 */
2694
-	public function set_company_id( $value ) {
2695
-		$this->set_prop( 'company_id', $value );
2842
+     * Set the customer's address confirmed status.
2843
+     *
2844
+     * @since 1.0.19
2845
+     * @param  int|bool $value confirmed.
2846
+     */
2847
+    public function set_address_confirmed( $value ) {
2848
+        $this->set_prop( 'address_confirmed', $value );
2696 2849
     }
2697 2850
 
2698 2851
     /**
2699
-	 * Set the customer's var number.
2700
-	 *
2701
-	 * @since 1.0.19
2702
-	 * @param  string $value var number.
2703
-	 */
2704
-	public function set_vat_number( $value ) {
2705
-		$this->set_prop( 'vat_number', $value );
2852
+     * Alias of self::set_address_confirmed().
2853
+     *
2854
+     * @since 1.0.19
2855
+     * @param  int|bool $value confirmed.
2856
+     */
2857
+    public function set_user_address_confirmed( $value ) {
2858
+        $this->set_address_confirmed( $value );
2706 2859
     }
2707 2860
 
2708 2861
     /**
2709
-	 * Alias of self::set_vat_number().
2710
-	 *
2711
-	 * @since 1.0.19
2712
-	 * @param  string $value var number.
2713
-	 */
2714
-	public function set_user_vat_number( $value ) {
2715
-		$this->set_vat_number( $value );
2862
+     * Alias of self::set_address_confirmed().
2863
+     *
2864
+     * @since 1.0.19
2865
+     * @param  int|bool $value confirmed.
2866
+     */
2867
+    public function set_customer_address_confirmed( $value ) {
2868
+        $this->set_address_confirmed( $value );
2716 2869
     }
2717 2870
 
2718 2871
     /**
2719
-	 * Alias of self::set_vat_number().
2720
-	 *
2721
-	 * @since 1.0.19
2722
-	 * @param  string $value var number.
2723
-	 */
2724
-	public function set_customer_vat_number( $value ) {
2725
-		$this->set_vat_number( $value );
2872
+     * Set the shipping fee
2873
+     *
2874
+     * @since 1.0.19
2875
+     * @param  float $value shipping amount.
2876
+     */
2877
+    public function set_shipping( $value ) {
2878
+
2879
+        if ( ! is_numeric( $value ) ) {
2880
+            return $this->set_prop( 'shipping', null );
2881
+        }
2882
+
2883
+        $this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2726 2884
     }
2727 2885
 
2728 2886
     /**
2729
-	 * Set the customer's vat rate.
2730
-	 *
2731
-	 * @since 1.0.19
2732
-	 * @param  string $value var rate.
2733
-	 */
2734
-	public function set_vat_rate( $value ) {
2735
-		$this->set_prop( 'vat_rate', $value );
2887
+     * Set the invoice sub total.
2888
+     *
2889
+     * @since 1.0.19
2890
+     * @param  float $value sub total.
2891
+     */
2892
+    public function set_subtotal( $value ) {
2893
+        $this->set_prop( 'subtotal', max( 0, $value ) );
2736 2894
     }
2737 2895
 
2738
-    /**
2739
-	 * Alias of self::set_vat_rate().
2740
-	 *
2741
-	 * @since 1.0.19
2742
-	 * @param  string $value var number.
2743
-	 */
2744
-	public function set_user_vat_rate( $value ) {
2745
-		$this->set_vat_rate( $value );
2746
-    }
2747
-
2748
-    /**
2749
-	 * Alias of self::set_vat_rate().
2750
-	 *
2751
-	 * @since 1.0.19
2752
-	 * @param  string $value var number.
2753
-	 */
2754
-	public function set_customer_vat_rate( $value ) {
2755
-		$this->set_vat_rate( $value );
2756
-    }
2757
-
2758
-    /**
2759
-	 * Set the customer's address.
2760
-	 *
2761
-	 * @since 1.0.19
2762
-	 * @param  string $value address.
2763
-	 */
2764
-	public function set_address( $value ) {
2765
-		$this->set_prop( 'address', $value );
2766
-    }
2767
-
2768
-    /**
2769
-	 * Alias of self::set_address().
2770
-	 *
2771
-	 * @since 1.0.19
2772
-	 * @param  string $value address.
2773
-	 */
2774
-	public function set_user_address( $value ) {
2775
-		$this->set_address( $value );
2776
-    }
2777
-
2778
-    /**
2779
-	 * Alias of self::set_address().
2780
-	 *
2781
-	 * @since 1.0.19
2782
-	 * @param  string $value address.
2783
-	 */
2784
-	public function set_customer_address( $value ) {
2785
-		$this->set_address( $value );
2786
-    }
2787
-
2788
-    /**
2789
-	 * Set whether the customer has viewed the invoice or not.
2790
-	 *
2791
-	 * @since 1.0.19
2792
-	 * @param  int|bool $value confirmed.
2793
-	 */
2794
-	public function set_is_viewed( $value ) {
2795
-		$this->set_prop( 'is_viewed', $value );
2796
-	}
2797
-
2798
-	/**
2799
-	 * Set extra email recipients.
2800
-	 *
2801
-	 * @since 1.0.19
2802
-	 * @param  string $value email recipients.
2803
-	 */
2804
-	public function set_email_cc( $value ) {
2805
-		$this->set_prop( 'email_cc', $value );
2806
-	}
2807
-
2808
-	/**
2809
-	 * Set the invoice template.
2810
-	 *
2811
-	 * @since 1.0.19
2812
-	 * @param  string $value template.
2813
-	 */
2814
-	public function set_template( $value ) {
2815
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2816
-			$this->set_prop( 'template', $value );
2817
-		}
2818
-	}
2819
-
2820
-	/**
2821
-	 * Set the invoice source.
2822
-	 *
2823
-	 * @since 1.0.19
2824
-	 * @param  string $value source.
2825
-	 * @deprecated
2826
-	 */
2827
-	public function created_via( $value ) {
2828
-		$this->set_created_via( sanitize_text_field( $value ) );
2829
-	}
2830
-
2831
-	/**
2832
-	 * Set the invoice source.
2833
-	 *
2834
-	 * @since 1.0.19
2835
-	 * @param  string $value source.
2836
-	 */
2837
-	public function set_created_via( $value ) {
2838
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2839
-	}
2840
-
2841
-	/**
2842
-	 * Set the customer's address confirmed status.
2843
-	 *
2844
-	 * @since 1.0.19
2845
-	 * @param  int|bool $value confirmed.
2846
-	 */
2847
-	public function set_address_confirmed( $value ) {
2848
-		$this->set_prop( 'address_confirmed', $value );
2849
-    }
2850
-
2851
-    /**
2852
-	 * Alias of self::set_address_confirmed().
2853
-	 *
2854
-	 * @since 1.0.19
2855
-	 * @param  int|bool $value confirmed.
2856
-	 */
2857
-	public function set_user_address_confirmed( $value ) {
2858
-		$this->set_address_confirmed( $value );
2859
-    }
2860
-
2861
-    /**
2862
-	 * Alias of self::set_address_confirmed().
2863
-	 *
2864
-	 * @since 1.0.19
2865
-	 * @param  int|bool $value confirmed.
2866
-	 */
2867
-	public function set_customer_address_confirmed( $value ) {
2868
-		$this->set_address_confirmed( $value );
2869
-    }
2870
-
2871
-    /**
2872
-	 * Set the shipping fee
2873
-	 *
2874
-	 * @since 1.0.19
2875
-	 * @param  float $value shipping amount.
2876
-	 */
2877
-	public function set_shipping( $value ) {
2878
-
2879
-		if ( ! is_numeric( $value ) ) {
2880
-			return $this->set_prop( 'shipping', null );
2881
-		}
2882
-
2883
-		$this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2884
-	}
2885
-
2886
-	/**
2887
-	 * Set the invoice sub total.
2888
-	 *
2889
-	 * @since 1.0.19
2890
-	 * @param  float $value sub total.
2891
-	 */
2892
-	public function set_subtotal( $value ) {
2893
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2894
-	}
2895
-
2896
-	/**
2897
-	 * Set the invoice total.
2898
-	 *
2899
-	 * @since 1.0.19
2900
-	 * @param  float $value sub total.
2901
-	 */
2902
-	public function set_total( $value ) {
2903
-		$this->set_prop( 'total', max( 0, $value ) );
2896
+    /**
2897
+     * Set the invoice total.
2898
+     *
2899
+     * @since 1.0.19
2900
+     * @param  float $value sub total.
2901
+     */
2902
+    public function set_total( $value ) {
2903
+        $this->set_prop( 'total', max( 0, $value ) );
2904 2904
     }
2905 2905
 
2906 2906
     /**
2907
-	 * Set the invoice discount amount.
2908
-	 *
2909
-	 * @since 1.0.19
2910
-	 * @param  float $value discount total.
2911
-	 */
2912
-	public function set_total_discount( $value ) {
2913
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2907
+     * Set the invoice discount amount.
2908
+     *
2909
+     * @since 1.0.19
2910
+     * @param  float $value discount total.
2911
+     */
2912
+    public function set_total_discount( $value ) {
2913
+        $this->set_prop( 'total_discount', max( 0, $value ) );
2914 2914
     }
2915 2915
 
2916 2916
     /**
2917
-	 * Alias of self::set_total_discount().
2918
-	 *
2919
-	 * @since 1.0.19
2920
-	 * @param  float $value discount total.
2921
-	 */
2922
-	public function set_discount( $value ) {
2923
-		$this->set_total_discount( $value );
2917
+     * Alias of self::set_total_discount().
2918
+     *
2919
+     * @since 1.0.19
2920
+     * @param  float $value discount total.
2921
+     */
2922
+    public function set_discount( $value ) {
2923
+        $this->set_total_discount( $value );
2924 2924
     }
2925 2925
 
2926 2926
     /**
2927
-	 * Set the invoice tax amount.
2928
-	 *
2929
-	 * @since 1.0.19
2930
-	 * @param  float $value tax total.
2931
-	 */
2932
-	public function set_total_tax( $value ) {
2933
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2927
+     * Set the invoice tax amount.
2928
+     *
2929
+     * @since 1.0.19
2930
+     * @param  float $value tax total.
2931
+     */
2932
+    public function set_total_tax( $value ) {
2933
+        $this->set_prop( 'total_tax', max( 0, $value ) );
2934 2934
     }
2935 2935
 
2936 2936
     /**
2937
-	 * Alias of self::set_total_tax().
2938
-	 *
2939
-	 * @since 1.0.19
2940
-	 * @param  float $value tax total.
2941
-	 */
2942
-	public function set_tax_total( $value ) {
2943
-		$this->set_total_tax( $value );
2937
+     * Alias of self::set_total_tax().
2938
+     *
2939
+     * @since 1.0.19
2940
+     * @param  float $value tax total.
2941
+     */
2942
+    public function set_tax_total( $value ) {
2943
+        $this->set_total_tax( $value );
2944 2944
     }
2945 2945
 
2946 2946
     /**
2947
-	 * Set the invoice fees amount.
2948
-	 *
2949
-	 * @since 1.0.19
2950
-	 * @param  float $value fees total.
2951
-	 */
2952
-	public function set_total_fees( $value ) {
2953
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2947
+     * Set the invoice fees amount.
2948
+     *
2949
+     * @since 1.0.19
2950
+     * @param  float $value fees total.
2951
+     */
2952
+    public function set_total_fees( $value ) {
2953
+        $this->set_prop( 'total_fees', max( 0, $value ) );
2954 2954
     }
2955 2955
 
2956 2956
     /**
2957
-	 * Alias of self::set_total_fees().
2958
-	 *
2959
-	 * @since 1.0.19
2960
-	 * @param  float $value fees total.
2961
-	 */
2962
-	public function set_fees_total( $value ) {
2963
-		$this->set_total_fees( $value );
2957
+     * Alias of self::set_total_fees().
2958
+     *
2959
+     * @since 1.0.19
2960
+     * @param  float $value fees total.
2961
+     */
2962
+    public function set_fees_total( $value ) {
2963
+        $this->set_total_fees( $value );
2964 2964
     }
2965 2965
 
2966 2966
     /**
2967
-	 * Set the invoice fees.
2968
-	 *
2969
-	 * @since 1.0.19
2970
-	 * @param  array $value fees.
2971
-	 */
2972
-	public function set_fees( $value ) {
2967
+     * Set the invoice fees.
2968
+     *
2969
+     * @since 1.0.19
2970
+     * @param  array $value fees.
2971
+     */
2972
+    public function set_fees( $value ) {
2973 2973
 
2974
-		if ( ! is_array( $value ) ) {
2975
-			$value = array();
2976
-		}
2974
+        if ( ! is_array( $value ) ) {
2975
+            $value = array();
2976
+        }
2977 2977
 
2978
-		$this->set_prop( 'fees', $value );
2978
+        $this->set_prop( 'fees', $value );
2979 2979
 
2980 2980
     }
2981 2981
 
2982 2982
     /**
2983
-	 * Set the invoice taxes.
2984
-	 *
2985
-	 * @since 1.0.19
2986
-	 * @param  array $value taxes.
2987
-	 */
2988
-	public function set_taxes( $value ) {
2983
+     * Set the invoice taxes.
2984
+     *
2985
+     * @since 1.0.19
2986
+     * @param  array $value taxes.
2987
+     */
2988
+    public function set_taxes( $value ) {
2989 2989
 
2990
-		if ( ! is_array( $value ) ) {
2991
-			$value = array();
2992
-		}
2990
+        if ( ! is_array( $value ) ) {
2991
+            $value = array();
2992
+        }
2993 2993
 
2994
-		$this->set_prop( 'taxes', $value );
2994
+        $this->set_prop( 'taxes', $value );
2995 2995
 
2996 2996
     }
2997 2997
 
2998 2998
     /**
2999
-	 * Set the invoice discounts.
3000
-	 *
3001
-	 * @since 1.0.19
3002
-	 * @param  array $value discounts.
3003
-	 */
3004
-	public function set_discounts( $value ) {
2999
+     * Set the invoice discounts.
3000
+     *
3001
+     * @since 1.0.19
3002
+     * @param  array $value discounts.
3003
+     */
3004
+    public function set_discounts( $value ) {
3005 3005
 
3006
-		if ( ! is_array( $value ) ) {
3007
-			$value = array();
3008
-		}
3006
+        if ( ! is_array( $value ) ) {
3007
+            $value = array();
3008
+        }
3009 3009
 
3010
-		$this->set_prop( 'discounts', $value );
3010
+        $this->set_prop( 'discounts', $value );
3011 3011
     }
3012 3012
 
3013 3013
     /**
3014
-	 * Set the invoice items.
3015
-	 *
3016
-	 * @since 1.0.19
3017
-	 * @param  GetPaid_Form_Item[] $value items.
3018
-	 */
3019
-	public function set_items( $value ) {
3014
+     * Set the invoice items.
3015
+     *
3016
+     * @since 1.0.19
3017
+     * @param  GetPaid_Form_Item[] $value items.
3018
+     */
3019
+    public function set_items( $value ) {
3020 3020
 
3021 3021
         // Remove existing items.
3022 3022
         $this->set_prop( 'items', array() );
3023
-		$this->recurring_item = null;
3023
+        $this->recurring_item = null;
3024 3024
 
3025 3025
         // Ensure that we have an array.
3026 3026
         if ( ! is_array( $value ) ) {
@@ -3034,95 +3034,95 @@  discard block
 block discarded – undo
3034 3034
     }
3035 3035
 
3036 3036
     /**
3037
-	 * Set the payment form.
3038
-	 *
3039
-	 * @since 1.0.19
3040
-	 * @param  int $value payment form.
3041
-	 */
3042
-	public function set_payment_form( $value ) {
3043
-		$this->set_prop( 'payment_form', $value );
3037
+     * Set the payment form.
3038
+     *
3039
+     * @since 1.0.19
3040
+     * @param  int $value payment form.
3041
+     */
3042
+    public function set_payment_form( $value ) {
3043
+        $this->set_prop( 'payment_form', $value );
3044 3044
     }
3045 3045
 
3046 3046
     /**
3047
-	 * Set the submission id.
3048
-	 *
3049
-	 * @since 1.0.19
3050
-	 * @param  string $value submission id.
3051
-	 */
3052
-	public function set_submission_id( $value ) {
3053
-		$this->set_prop( 'submission_id', $value );
3047
+     * Set the submission id.
3048
+     *
3049
+     * @since 1.0.19
3050
+     * @param  string $value submission id.
3051
+     */
3052
+    public function set_submission_id( $value ) {
3053
+        $this->set_prop( 'submission_id', $value );
3054 3054
     }
3055 3055
 
3056 3056
     /**
3057
-	 * Set the discount code.
3058
-	 *
3059
-	 * @since 1.0.19
3060
-	 * @param  string $value discount code.
3061
-	 */
3062
-	public function set_discount_code( $value ) {
3063
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3057
+     * Set the discount code.
3058
+     *
3059
+     * @since 1.0.19
3060
+     * @param  string $value discount code.
3061
+     */
3062
+    public function set_discount_code( $value ) {
3063
+        $this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3064 3064
     }
3065 3065
 
3066 3066
     /**
3067
-	 * Set the gateway.
3068
-	 *
3069
-	 * @since 1.0.19
3070
-	 * @param  string $value gateway.
3071
-	 */
3072
-	public function set_gateway( $value ) {
3073
-		$this->set_prop( 'gateway', $value );
3067
+     * Set the gateway.
3068
+     *
3069
+     * @since 1.0.19
3070
+     * @param  string $value gateway.
3071
+     */
3072
+    public function set_gateway( $value ) {
3073
+        $this->set_prop( 'gateway', $value );
3074 3074
     }
3075 3075
 
3076 3076
     /**
3077
-	 * Set the transaction id.
3078
-	 *
3079
-	 * @since 1.0.19
3080
-	 * @param  string $value transaction id.
3081
-	 */
3082
-	public function set_transaction_id( $value ) {
3083
-		if ( ! empty( $value ) ) {
3084
-			$this->set_prop( 'transaction_id', $value );
3085
-		}
3077
+     * Set the transaction id.
3078
+     *
3079
+     * @since 1.0.19
3080
+     * @param  string $value transaction id.
3081
+     */
3082
+    public function set_transaction_id( $value ) {
3083
+        if ( ! empty( $value ) ) {
3084
+            $this->set_prop( 'transaction_id', $value );
3085
+        }
3086 3086
     }
3087 3087
 
3088 3088
     /**
3089
-	 * Set the currency id.
3090
-	 *
3091
-	 * @since 1.0.19
3092
-	 * @param  string $value currency id.
3093
-	 */
3094
-	public function set_currency( $value ) {
3095
-		$this->set_prop( 'currency', $value );
3089
+     * Set the currency id.
3090
+     *
3091
+     * @since 1.0.19
3092
+     * @param  string $value currency id.
3093
+     */
3094
+    public function set_currency( $value ) {
3095
+        $this->set_prop( 'currency', $value );
3096 3096
     }
3097 3097
 
3098
-	/**
3099
-	 * Set whether to disable taxes.
3100
-	 *
3101
-	 * @since 1.0.19
3102
-	 * @param  bool $value value.
3103
-	 */
3104
-	public function set_disable_taxes( $value ) {
3105
-		$this->set_prop( 'disable_taxes', (bool) $value );
3106
-	}
3098
+    /**
3099
+     * Set whether to disable taxes.
3100
+     *
3101
+     * @since 1.0.19
3102
+     * @param  bool $value value.
3103
+     */
3104
+    public function set_disable_taxes( $value ) {
3105
+        $this->set_prop( 'disable_taxes', (bool) $value );
3106
+    }
3107 3107
 
3108 3108
     /**
3109
-	 * Set the subscription id.
3110
-	 *
3111
-	 * @since 1.0.19
3112
-	 * @param  string $value subscription id.
3113
-	 */
3114
-	public function set_subscription_id( $value ) {
3115
-		$this->set_prop( 'subscription_id', $value );
3116
-	}
3109
+     * Set the subscription id.
3110
+     *
3111
+     * @since 1.0.19
3112
+     * @param  string $value subscription id.
3113
+     */
3114
+    public function set_subscription_id( $value ) {
3115
+        $this->set_prop( 'subscription_id', $value );
3116
+    }
3117 3117
 
3118
-	/**
3119
-	 * Set the remote subscription id.
3120
-	 *
3121
-	 * @since 1.0.19
3122
-	 * @param  string $value subscription id.
3123
-	 */
3124
-	public function set_remote_subscription_id( $value ) {
3125
-		$this->set_prop( 'remote_subscription_id', $value );
3118
+    /**
3119
+     * Set the remote subscription id.
3120
+     *
3121
+     * @since 1.0.19
3122
+     * @param  string $value subscription id.
3123
+     */
3124
+    public function set_remote_subscription_id( $value ) {
3125
+        $this->set_prop( 'remote_subscription_id', $value );
3126 3126
     }
3127 3127
 
3128 3128
     /*
@@ -3161,24 +3161,24 @@  discard block
 block discarded – undo
3161 3161
      */
3162 3162
     public function is_taxable() {
3163 3163
         return ! $this->get_disable_taxes();
3164
-	}
3164
+    }
3165 3165
 
3166
-	/**
3167
-	 * @deprecated
3168
-	 */
3169
-	public function has_vat() {
3166
+    /**
3167
+     * @deprecated
3168
+     */
3169
+    public function has_vat() {
3170 3170
         return $this->is_taxable();
3171
-	}
3171
+    }
3172 3172
 
3173
-	/**
3174
-	 * Checks to see if the invoice requires payment.
3175
-	 */
3176
-	public function is_free() {
3173
+    /**
3174
+     * Checks to see if the invoice requires payment.
3175
+     */
3176
+    public function is_free() {
3177 3177
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3178 3178
 
3179
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3180
-			$is_free = false;
3181
-		}
3179
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3180
+            $is_free = false;
3181
+        }
3182 3182
 
3183 3183
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3184 3184
     }
@@ -3189,46 +3189,46 @@  discard block
 block discarded – undo
3189 3189
     public function is_paid() {
3190 3190
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3191 3191
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3192
-	}
3192
+    }
3193 3193
 
3194
-	/**
3194
+    /**
3195 3195
      * Checks if the invoice needs payment.
3196 3196
      */
3197
-	public function needs_payment() {
3198
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3197
+    public function needs_payment() {
3198
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3199 3199
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3200 3200
     }
3201 3201
 
3202
-	/**
3202
+    /**
3203 3203
      * Checks if the invoice is refunded.
3204 3204
      */
3205
-	public function is_refunded() {
3205
+    public function is_refunded() {
3206 3206
         $is_refunded = $this->has_status( 'wpi-refunded' );
3207 3207
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3208
-	}
3208
+    }
3209 3209
 
3210
-	/**
3210
+    /**
3211 3211
      * Checks if the invoice is held.
3212 3212
      */
3213
-	public function is_held() {
3213
+    public function is_held() {
3214 3214
         $is_held = $this->has_status( 'wpi-onhold' );
3215 3215
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3216
-	}
3216
+    }
3217 3217
 
3218
-	/**
3218
+    /**
3219 3219
      * Checks if the invoice is due.
3220 3220
      */
3221
-	public function is_due() {
3222
-		$due_date = $this->get_due_date();
3223
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3224
-	}
3221
+    public function is_due() {
3222
+        $due_date = $this->get_due_date();
3223
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3224
+    }
3225 3225
 
3226
-	/**
3226
+    /**
3227 3227
      * Checks if the invoice is draft.
3228 3228
      */
3229
-	public function is_draft() {
3229
+    public function is_draft() {
3230 3230
         return $this->has_status( 'draft, auto-draft' );
3231
-	}
3231
+    }
3232 3232
 
3233 3233
     /**
3234 3234
      * Checks if the invoice has a given status.
@@ -3236,9 +3236,9 @@  discard block
 block discarded – undo
3236 3236
     public function has_status( $status ) {
3237 3237
         $status = wpinv_parse_list( $status );
3238 3238
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3239
-	}
3239
+    }
3240 3240
 
3241
-	/**
3241
+    /**
3242 3242
      * Checks if the invoice is of a given type.
3243 3243
      */
3244 3244
     public function is_type( $type ) {
@@ -3261,25 +3261,25 @@  discard block
 block discarded – undo
3261 3261
      */
3262 3262
     public function has_free_trial() {
3263 3263
         return $this->is_recurring() && 0 == $this->get_initial_total();
3264
-	}
3264
+    }
3265 3265
 
3266
-	/**
3266
+    /**
3267 3267
      * @deprecated
3268 3268
      */
3269 3269
     public function is_free_trial() {
3270 3270
         $this->has_free_trial();
3271 3271
     }
3272 3272
 
3273
-	/**
3273
+    /**
3274 3274
      * Check if the initial payment if 0.
3275 3275
      *
3276 3276
      */
3277
-	public function is_initial_free() {
3277
+    public function is_initial_free() {
3278 3278
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3279 3279
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3280 3280
     }
3281 3281
 
3282
-	/**
3282
+    /**
3283 3283
      * Check if the recurring item has a free trial.
3284 3284
      *
3285 3285
      */
@@ -3292,21 +3292,21 @@  discard block
 block discarded – undo
3292 3292
 
3293 3293
         $item = $this->get_recurring( true );
3294 3294
         return $item->has_free_trial();
3295
-	}
3295
+    }
3296 3296
 
3297
-	/**
3297
+    /**
3298 3298
      * Check if the free trial is a result of a discount.
3299 3299
      */
3300 3300
     public function is_free_trial_from_discount() {
3301
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3302
-	}
3301
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3302
+    }
3303 3303
 
3304
-	/**
3304
+    /**
3305 3305
      * @deprecated
3306 3306
      */
3307 3307
     public function discount_first_payment_only() {
3308 3308
 
3309
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3309
+        $discount = wpinv_get_discount_obj( $this->get_discount_code() );
3310 3310
         if ( ! $discount->exists() || ! $this->is_recurring() ) {
3311 3311
             return true;
3312 3312
         }
@@ -3331,146 +3331,146 @@  discard block
 block discarded – undo
3331 3331
      */
3332 3332
     public function add_item( $item ) {
3333 3333
 
3334
-		if ( is_array( $item ) ) {
3335
-			$item = $this->process_array_item( $item );
3336
-		}
3334
+        if ( is_array( $item ) ) {
3335
+            $item = $this->process_array_item( $item );
3336
+        }
3337 3337
 
3338
-		if ( is_numeric( $item ) ) {
3339
-			$item = new GetPaid_Form_Item( $item );
3340
-		}
3338
+        if ( is_numeric( $item ) ) {
3339
+            $item = new GetPaid_Form_Item( $item );
3340
+        }
3341 3341
 
3342 3342
         // Make sure that it is available for purchase.
3343
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3344
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3343
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3344
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3345 3345
         }
3346 3346
 
3347 3347
         // Do we have a recurring item?
3348
-		if ( $item->is_recurring() ) {
3349
-			$this->recurring_item = $item->get_id();
3348
+        if ( $item->is_recurring() ) {
3349
+            $this->recurring_item = $item->get_id();
3350 3350
         }
3351 3351
 
3352 3352
         // Invoice id.
3353 3353
         $item->invoice_id = (int) $this->get_id();
3354 3354
 
3355
-		// Remove duplicates.
3356
-		$this->remove_item( $item->get_id() );
3355
+        // Remove duplicates.
3356
+        $this->remove_item( $item->get_id() );
3357 3357
 
3358
-		if ( 0 == $item->get_quantity() ) {
3359
-			return;
3360
-		}
3358
+        if ( 0 == $item->get_quantity() ) {
3359
+            return;
3360
+        }
3361 3361
 
3362
-		// Retrieve all items.
3362
+        // Retrieve all items.
3363 3363
         $items   = $this->get_items();
3364 3364
 
3365
-		// Add new item.
3365
+        // Add new item.
3366 3366
         $items[] = $item;
3367 3367
 
3368 3368
         $this->set_prop( 'items', $items );
3369 3369
 
3370
-		return true;
3371
-	}
3370
+        return true;
3371
+    }
3372 3372
 
3373
-	/**
3374
-	 * Converts an array to an item.
3375
-	 *
3376
-	 * @since 1.0.19
3377
-	 * @return GetPaid_Form_Item
3378
-	 */
3379
-	protected function process_array_item( $array ) {
3373
+    /**
3374
+     * Converts an array to an item.
3375
+     *
3376
+     * @since 1.0.19
3377
+     * @return GetPaid_Form_Item
3378
+     */
3379
+    protected function process_array_item( $array ) {
3380 3380
 
3381
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3382
-		$item    = new GetPaid_Form_Item( $item_id );
3381
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3382
+        $item    = new GetPaid_Form_Item( $item_id );
3383 3383
 
3384
-		// Set item data.
3385
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3386
-			if ( isset( $array[ "item_$key" ] ) ) {
3387
-				$method = "set_$key";
3388
-				$item->$method( $array[ "item_$key" ] );
3389
-			}
3390
-		}
3384
+        // Set item data.
3385
+        foreach ( array( 'name', 'price', 'description' ) as $key ) {
3386
+            if ( isset( $array[ "item_$key" ] ) ) {
3387
+                $method = "set_$key";
3388
+                $item->$method( $array[ "item_$key" ] );
3389
+            }
3390
+        }
3391 3391
 
3392
-		if ( isset( $array['quantity'] ) ) {
3393
-			$item->set_quantity( $array['quantity'] );
3394
-		}
3392
+        if ( isset( $array['quantity'] ) ) {
3393
+            $item->set_quantity( $array['quantity'] );
3394
+        }
3395 3395
 
3396
-		// Set item meta.
3397
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3398
-			$item->set_item_meta( $array['meta'] );
3399
-		}
3396
+        // Set item meta.
3397
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3398
+            $item->set_item_meta( $array['meta'] );
3399
+        }
3400 3400
 
3401
-		return $item;
3401
+        return $item;
3402 3402
 
3403
-	}
3403
+    }
3404 3404
 
3405 3405
     /**
3406
-	 * Retrieves a specific item.
3407
-	 *
3408
-	 * @since 1.0.19
3409
-	 * @return GetPaid_Form_Item|null
3410
-	 */
3411
-	public function get_item( $item_id ) {
3406
+     * Retrieves a specific item.
3407
+     *
3408
+     * @since 1.0.19
3409
+     * @return GetPaid_Form_Item|null
3410
+     */
3411
+    public function get_item( $item_id ) {
3412 3412
 
3413
-		foreach ( $this->get_items() as $item ) {
3414
-			if ( (int) $item_id == $item->get_id() ) {
3415
-				return $item;
3416
-			}
3417
-		}
3413
+        foreach ( $this->get_items() as $item ) {
3414
+            if ( (int) $item_id == $item->get_id() ) {
3415
+                return $item;
3416
+            }
3417
+        }
3418 3418
 
3419
-		return null;
3419
+        return null;
3420 3420
     }
3421 3421
 
3422 3422
     /**
3423
-	 * Removes a specific item.
3424
-	 *
3425
-	 * @since 1.0.19
3426
-	 */
3427
-	public function remove_item( $item_id ) {
3428
-		$items   = $this->get_items();
3429
-		$item_id = (int) $item_id;
3423
+     * Removes a specific item.
3424
+     *
3425
+     * @since 1.0.19
3426
+     */
3427
+    public function remove_item( $item_id ) {
3428
+        $items   = $this->get_items();
3429
+        $item_id = (int) $item_id;
3430 3430
 
3431
-		foreach ( $items as $index => $item ) {
3432
-			if ( (int) $item_id == $item->get_id() ) {
3433
-				unset( $items[ $index ] );
3434
-				$this->set_prop( 'items', $items );
3431
+        foreach ( $items as $index => $item ) {
3432
+            if ( (int) $item_id == $item->get_id() ) {
3433
+                unset( $items[ $index ] );
3434
+                $this->set_prop( 'items', $items );
3435 3435
 
3436
-				if ( $item_id == $this->recurring_item ) {
3437
-					$this->recurring_item = null;
3438
-				}
3436
+                if ( $item_id == $this->recurring_item ) {
3437
+                    $this->recurring_item = null;
3438
+                }
3439 3439
 }
3440
-		}
3440
+        }
3441 3441
 
3442 3442
     }
3443 3443
 
3444 3444
     /**
3445
-	 * Adds a fee to the invoice.
3446
-	 *
3447
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3448
-	 * @since 1.0.19
3449
-	 */
3445
+     * Adds a fee to the invoice.
3446
+     *
3447
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3448
+     * @since 1.0.19
3449
+     */
3450 3450
     public function add_fee( $fee ) {
3451 3451
 
3452
-		$fees                 = $this->get_fees();
3453
-		$fees[ $fee['name'] ] = $fee;
3454
-		$this->set_prop( 'fees', $fees );
3452
+        $fees                 = $this->get_fees();
3453
+        $fees[ $fee['name'] ] = $fee;
3454
+        $this->set_prop( 'fees', $fees );
3455 3455
 
3456 3456
     }
3457 3457
 
3458 3458
     /**
3459
-	 * Retrieves a specific fee.
3460
-	 *
3461
-	 * @since 1.0.19
3462
-	 */
3463
-	public function get_fee( $fee ) {
3459
+     * Retrieves a specific fee.
3460
+     *
3461
+     * @since 1.0.19
3462
+     */
3463
+    public function get_fee( $fee ) {
3464 3464
         $fees = $this->get_fees();
3465
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3465
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3466 3466
     }
3467 3467
 
3468 3468
     /**
3469
-	 * Removes a specific fee.
3470
-	 *
3471
-	 * @since 1.0.19
3472
-	 */
3473
-	public function remove_fee( $fee ) {
3469
+     * Removes a specific fee.
3470
+     *
3471
+     * @since 1.0.19
3472
+     */
3473
+    public function remove_fee( $fee ) {
3474 3474
         $fees = $this->get_fees();
3475 3475
         if ( isset( $fees[ $fee ] ) ) {
3476 3476
             unset( $fees[ $fee ] );
@@ -3478,55 +3478,55 @@  discard block
 block discarded – undo
3478 3478
         }
3479 3479
     }
3480 3480
 
3481
-	/**
3482
-	 * Adds a discount to the invoice.
3483
-	 *
3484
-	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3485
-	 * @since 1.0.19
3486
-	 */
3487
-	public function add_discount( $discount ) {
3481
+    /**
3482
+     * Adds a discount to the invoice.
3483
+     *
3484
+     * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3485
+     * @since 1.0.19
3486
+     */
3487
+    public function add_discount( $discount ) {
3488 3488
 
3489
-		$discounts = $this->get_discounts();
3490
-		$discounts[ $discount['name'] ] = $discount;
3491
-		$this->set_prop( 'discounts', $discounts );
3489
+        $discounts = $this->get_discounts();
3490
+        $discounts[ $discount['name'] ] = $discount;
3491
+        $this->set_prop( 'discounts', $discounts );
3492 3492
 
3493
-	}
3493
+    }
3494 3494
 
3495 3495
     /**
3496
-	 * Retrieves a specific discount.
3497
-	 *
3498
-	 * @since 1.0.19
3499
-	 * @return float
3500
-	 */
3501
-	public function get_discount( $discount = false ) {
3496
+     * Retrieves a specific discount.
3497
+     *
3498
+     * @since 1.0.19
3499
+     * @return float
3500
+     */
3501
+    public function get_discount( $discount = false ) {
3502 3502
 
3503
-		// Backwards compatibilty.
3504
-		if ( empty( $discount ) ) {
3505
-			return $this->get_total_discount();
3506
-		}
3503
+        // Backwards compatibilty.
3504
+        if ( empty( $discount ) ) {
3505
+            return $this->get_total_discount();
3506
+        }
3507 3507
 
3508 3508
         $discounts = $this->get_discounts();
3509
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3509
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3510 3510
     }
3511 3511
 
3512 3512
     /**
3513
-	 * Removes a specific discount.
3514
-	 *
3515
-	 * @since 1.0.19
3516
-	 */
3517
-	public function remove_discount( $discount ) {
3513
+     * Removes a specific discount.
3514
+     *
3515
+     * @since 1.0.19
3516
+     */
3517
+    public function remove_discount( $discount ) {
3518 3518
         $discounts = $this->get_discounts();
3519 3519
         if ( isset( $discounts[ $discount ] ) ) {
3520 3520
             unset( $discounts[ $discount ] );
3521 3521
             $this->set_prop( 'discounts', $discounts );
3522 3522
         }
3523 3523
 
3524
-		if ( 'discount_code' == $discount ) {
3525
-			foreach ( $this->get_items() as $item ) {
3526
-				$item->item_discount           = 0;
3527
-				$item->recurring_item_discount = 0;
3528
-			}
3529
-		}
3524
+        if ( 'discount_code' == $discount ) {
3525
+            foreach ( $this->get_items() as $item ) {
3526
+                $item->item_discount           = 0;
3527
+                $item->recurring_item_discount = 0;
3528
+            }
3529
+        }
3530 3530
 
3531 3531
     }
3532 3532
 
@@ -3539,34 +3539,34 @@  discard block
 block discarded – undo
3539 3539
         if ( $this->is_taxable() ) {
3540 3540
 
3541 3541
             $taxes                 = $this->get_taxes();
3542
-			$taxes[ $tax['name'] ] = $tax;
3543
-			$this->set_prop( 'taxes', $tax );
3542
+            $taxes[ $tax['name'] ] = $tax;
3543
+            $this->set_prop( 'taxes', $tax );
3544 3544
 
3545 3545
         }
3546 3546
     }
3547 3547
 
3548 3548
     /**
3549
-	 * Retrieves a specific tax.
3550
-	 *
3551
-	 * @since 1.0.19
3552
-	 */
3553
-	public function get_tax( $tax = null ) {
3549
+     * Retrieves a specific tax.
3550
+     *
3551
+     * @since 1.0.19
3552
+     */
3553
+    public function get_tax( $tax = null ) {
3554 3554
 
3555
-		// Backwards compatility.
3556
-		if ( empty( $tax ) ) {
3557
-			return $this->get_total_tax();
3558
-		}
3555
+        // Backwards compatility.
3556
+        if ( empty( $tax ) ) {
3557
+            return $this->get_total_tax();
3558
+        }
3559 3559
 
3560 3560
         $taxes = $this->get_taxes();
3561
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3561
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3562 3562
     }
3563 3563
 
3564 3564
     /**
3565
-	 * Removes a specific tax.
3566
-	 *
3567
-	 * @since 1.0.19
3568
-	 */
3569
-	public function remove_tax( $tax ) {
3565
+     * Removes a specific tax.
3566
+     *
3567
+     * @since 1.0.19
3568
+     */
3569
+    public function remove_tax( $tax ) {
3570 3570
         $taxes = $this->get_taxes();
3571 3571
         if ( isset( $taxes[ $tax ] ) ) {
3572 3572
             unset( $taxes[ $tax ] );
@@ -3575,184 +3575,184 @@  discard block
 block discarded – undo
3575 3575
     }
3576 3576
 
3577 3577
     /**
3578
-	 * Recalculates the invoice subtotal.
3579
-	 *
3580
-	 * @since 1.0.19
3581
-	 * @return float The recalculated subtotal
3582
-	 */
3583
-	public function recalculate_subtotal() {
3578
+     * Recalculates the invoice subtotal.
3579
+     *
3580
+     * @since 1.0.19
3581
+     * @return float The recalculated subtotal
3582
+     */
3583
+    public function recalculate_subtotal() {
3584 3584
         $items     = $this->get_items();
3585
-		$subtotal  = 0;
3586
-		$recurring = 0;
3585
+        $subtotal  = 0;
3586
+        $recurring = 0;
3587 3587
 
3588 3588
         foreach ( $items as $item ) {
3589
-			$subtotal  += $item->get_sub_total( 'edit' );
3590
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3589
+            $subtotal  += $item->get_sub_total( 'edit' );
3590
+            $recurring += $item->get_recurring_sub_total( 'edit' );
3591 3591
         }
3592 3592
 
3593
-		if ( wpinv_prices_include_tax() ) {
3594
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3595
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3596
-		}
3593
+        if ( wpinv_prices_include_tax() ) {
3594
+            $subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3595
+            $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3596
+        }
3597 3597
 
3598
-		$current = $this->is_renewal() ? $recurring : $subtotal;
3599
-		$this->set_subtotal( $current );
3598
+        $current = $this->is_renewal() ? $recurring : $subtotal;
3599
+        $this->set_subtotal( $current );
3600 3600
 
3601
-		$this->totals['subtotal'] = array(
3602
-			'initial'   => $subtotal,
3603
-			'recurring' => $recurring,
3604
-		);
3601
+        $this->totals['subtotal'] = array(
3602
+            'initial'   => $subtotal,
3603
+            'recurring' => $recurring,
3604
+        );
3605 3605
 
3606 3606
         return $current;
3607 3607
     }
3608 3608
 
3609 3609
     /**
3610
-	 * Recalculates the invoice discount total.
3611
-	 *
3612
-	 * @since 1.0.19
3613
-	 * @return float The recalculated discount
3614
-	 */
3615
-	public function recalculate_total_discount() {
3610
+     * Recalculates the invoice discount total.
3611
+     *
3612
+     * @since 1.0.19
3613
+     * @return float The recalculated discount
3614
+     */
3615
+    public function recalculate_total_discount() {
3616 3616
         $discounts = $this->get_discounts();
3617
-		$discount  = 0;
3618
-		$recurring = 0;
3617
+        $discount  = 0;
3618
+        $recurring = 0;
3619 3619
 
3620 3620
         foreach ( $discounts as $data ) {
3621
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3622
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3623
-		}
3621
+            $discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3622
+            $recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3623
+        }
3624 3624
 
3625
-		$current = $this->is_renewal() ? $recurring : $discount;
3625
+        $current = $this->is_renewal() ? $recurring : $discount;
3626 3626
 
3627
-		$this->set_total_discount( $current );
3627
+        $this->set_total_discount( $current );
3628 3628
 
3629
-		$this->totals['discount'] = array(
3630
-			'initial'   => $discount,
3631
-			'recurring' => $recurring,
3632
-		);
3629
+        $this->totals['discount'] = array(
3630
+            'initial'   => $discount,
3631
+            'recurring' => $recurring,
3632
+        );
3633 3633
 
3634
-		return $current;
3634
+        return $current;
3635 3635
 
3636 3636
     }
3637 3637
 
3638 3638
     /**
3639
-	 * Recalculates the invoice tax total.
3640
-	 *
3641
-	 * @since 1.0.19
3642
-	 * @return float The recalculated tax
3643
-	 */
3644
-	public function recalculate_total_tax() {
3639
+     * Recalculates the invoice tax total.
3640
+     *
3641
+     * @since 1.0.19
3642
+     * @return float The recalculated tax
3643
+     */
3644
+    public function recalculate_total_tax() {
3645 3645
 
3646
-		// Maybe disable taxes.
3647
-		$vat_number = $this->get_vat_number();
3648
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3646
+        // Maybe disable taxes.
3647
+        $vat_number = $this->get_vat_number();
3648
+        $skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3649 3649
 
3650
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3651
-			$skip_tax = false;
3652
-		}
3650
+        if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3651
+            $skip_tax = false;
3652
+        }
3653 3653
 
3654
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) {
3654
+        if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) {
3655 3655
 
3656
-			$this->totals['tax'] = array(
3657
-				'initial'   => 0,
3658
-				'recurring' => 0,
3659
-			);
3656
+            $this->totals['tax'] = array(
3657
+                'initial'   => 0,
3658
+                'recurring' => 0,
3659
+            );
3660 3660
 
3661
-			$this->tax_rate = 0;
3661
+            $this->tax_rate = 0;
3662 3662
 
3663
-			$this->set_taxes( array() );
3664
-			$current = 0;
3665
-		} else {
3663
+            $this->set_taxes( array() );
3664
+            $current = 0;
3665
+        } else {
3666 3666
 
3667
-			$item_taxes = array();
3667
+            $item_taxes = array();
3668 3668
 
3669
-			foreach ( $this->get_items() as $item ) {
3670
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3671
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3672
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3673
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3674
-				foreach ( $taxes as $name => $amount ) {
3675
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3676
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3669
+            foreach ( $this->get_items() as $item ) {
3670
+                $rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3671
+                $rates    = getpaid_filter_item_tax_rates( $item, $rates );
3672
+                $taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3673
+                $r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3674
+                foreach ( $taxes as $name => $amount ) {
3675
+                    $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3676
+                    $tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3677 3677
 
3678
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3679
-						$item_taxes[ $name ] = $tax;
3680
-						continue;
3681
-					}
3678
+                    if ( ! isset( $item_taxes[ $name ] ) ) {
3679
+                        $item_taxes[ $name ] = $tax;
3680
+                        continue;
3681
+                    }
3682 3682
 
3683
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3684
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3683
+                    $item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3684
+                    $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3685 3685
 
3686
-				}
3687
-			}
3686
+                }
3687
+            }
3688 3688
 
3689
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3690
-			$this->set_taxes( $item_taxes );
3689
+            $item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3690
+            $this->set_taxes( $item_taxes );
3691 3691
 
3692
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3693
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3692
+            $initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3693
+            $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3694 3694
 
3695
-			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3695
+            $current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3696 3696
 
3697
-			$this->totals['tax'] = array(
3698
-				'initial'   => $initial_tax,
3699
-				'recurring' => $recurring_tax,
3700
-			);
3697
+            $this->totals['tax'] = array(
3698
+                'initial'   => $initial_tax,
3699
+                'recurring' => $recurring_tax,
3700
+            );
3701 3701
 
3702
-		}
3702
+        }
3703 3703
 
3704
-		$this->set_total_tax( $current );
3704
+        $this->set_total_tax( $current );
3705 3705
 
3706
-		return $current;
3706
+        return $current;
3707 3707
 
3708 3708
     }
3709 3709
 
3710 3710
     /**
3711
-	 * Recalculates the invoice fees total.
3712
-	 *
3713
-	 * @since 1.0.19
3714
-	 * @return float The recalculated fee
3715
-	 */
3716
-	public function recalculate_total_fees() {
3717
-		$fees      = $this->get_fees();
3718
-		$fee       = 0;
3719
-		$recurring = 0;
3711
+     * Recalculates the invoice fees total.
3712
+     *
3713
+     * @since 1.0.19
3714
+     * @return float The recalculated fee
3715
+     */
3716
+    public function recalculate_total_fees() {
3717
+        $fees      = $this->get_fees();
3718
+        $fee       = 0;
3719
+        $recurring = 0;
3720 3720
 
3721 3721
         foreach ( $fees as $data ) {
3722
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3723
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3724
-		}
3722
+            $fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3723
+            $recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3724
+        }
3725 3725
 
3726
-		$current = $this->is_renewal() ? $recurring : $fee;
3727
-		$this->set_total_fees( $current );
3726
+        $current = $this->is_renewal() ? $recurring : $fee;
3727
+        $this->set_total_fees( $current );
3728 3728
 
3729
-		$this->totals['fee'] = array(
3730
-			'initial'   => $fee,
3731
-			'recurring' => $recurring,
3732
-		);
3729
+        $this->totals['fee'] = array(
3730
+            'initial'   => $fee,
3731
+            'recurring' => $recurring,
3732
+        );
3733 3733
 
3734 3734
         $this->set_total_fees( $fee );
3735 3735
         return $current;
3736 3736
     }
3737 3737
 
3738 3738
     /**
3739
-	 * Recalculates the invoice total.
3740
-	 *
3741
-	 * @since 1.0.19
3739
+     * Recalculates the invoice total.
3740
+     *
3741
+     * @since 1.0.19
3742 3742
      * @return float The invoice total
3743
-	 */
3744
-	public function recalculate_total() {
3743
+     */
3744
+    public function recalculate_total() {
3745 3745
         $this->recalculate_total_fees();
3746 3746
         $this->recalculate_total_discount();
3747
-		$this->recalculate_total_tax();
3748
-		$this->recalculate_subtotal();
3749
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3750
-		return $this->get_total();
3751
-	}
3752
-
3753
-	/**
3754
-	 * @deprecated
3755
-	 */
3747
+        $this->recalculate_total_tax();
3748
+        $this->recalculate_subtotal();
3749
+        $this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3750
+        return $this->get_total();
3751
+    }
3752
+
3753
+    /**
3754
+     * @deprecated
3755
+     */
3756 3756
     public function recalculate_totals() {
3757 3757
         $this->recalculate_total();
3758 3758
         $this->save( true );
@@ -3766,22 +3766,22 @@  discard block
 block discarded – undo
3766 3766
         return $this->get_data();
3767 3767
     }
3768 3768
 
3769
-	/**
3769
+    /**
3770 3770
      * Adds a system note to an invoice.
3771 3771
      *
3772 3772
      * @param string $note The note being added.
3773
-	 * @return int|false The new note's ID on success, false on failure.
3773
+     * @return int|false The new note's ID on success, false on failure.
3774 3774
      *
3775 3775
      */
3776 3776
     public function add_system_note( $note ) {
3777
-		return $this->add_note( $note, false, false, true );
3778
-	}
3777
+        return $this->add_note( $note, false, false, true );
3778
+    }
3779 3779
 
3780 3780
     /**
3781 3781
      * Adds a note to an invoice.
3782 3782
      *
3783 3783
      * @param string $note The note being added.
3784
-	 * @return int|false The new note's ID on success, false on failure.
3784
+     * @return int|false The new note's ID on success, false on failure.
3785 3785
      *
3786 3786
      */
3787 3787
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3791,21 +3791,21 @@  discard block
 block discarded – undo
3791 3791
             return false;
3792 3792
         }
3793 3793
 
3794
-		$author       = 'System';
3795
-		$author_email = '[email protected]';
3794
+        $author       = 'System';
3795
+        $author_email = '[email protected]';
3796 3796
 
3797
-		// If this is an admin comment or it has been added by the user.
3798
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3799
-			$user         = get_user_by( 'id', get_current_user_id() );
3797
+        // If this is an admin comment or it has been added by the user.
3798
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3799
+            $user         = get_user_by( 'id', get_current_user_id() );
3800 3800
             $author       = $user->display_name;
3801 3801
             $author_email = $user->user_email;
3802
-		}
3802
+        }
3803 3803
 
3804
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3804
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3805 3805
 
3806
-	}
3806
+    }
3807 3807
 
3808
-	/**
3808
+    /**
3809 3809
      * Generates a unique key for the invoice.
3810 3810
      */
3811 3811
     public function generate_key( $string = '' ) {
@@ -3825,113 +3825,113 @@  discard block
 block discarded – undo
3825 3825
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3826 3826
         }
3827 3827
 
3828
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3829
-
3830
-	}
3831
-
3832
-	/**
3833
-	 * Handle the status transition.
3834
-	 */
3835
-	protected function status_transition() {
3836
-		$status_transition = $this->status_transition;
3837
-
3838
-		// Reset status transition variable.
3839
-		$this->status_transition = false;
3840
-
3841
-		if ( $status_transition ) {
3842
-			try {
3843
-
3844
-				// Fire a hook for the status change.
3845
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3846
-
3847
-				// @deprecated this is deprecated and will be removed in the future.
3848
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3849
-
3850
-				if ( ! empty( $status_transition['from'] ) ) {
3851
-
3852
-					/* translators: 1: old invoice status 2: new invoice status */
3853
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) );
3854
-
3855
-					// Fire another hook.
3856
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3857
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3828
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3858 3829
 
3859
-					// @deprecated this is deprecated and will be removed in the future.
3860
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3861
-
3862
-					// Note the transition occurred.
3863
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3864
-
3865
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3866
-					if (
3867
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3868
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3869
-					) {
3870
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3871
-					}
3872
-
3873
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3874
-					if (
3875
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3876
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3877
-					) {
3878
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3879
-					}
3880
-				} else {
3881
-					/* translators: %s: new invoice status */
3882
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) );
3883
-
3884
-					// Note the transition occurred.
3885
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3830
+    }
3886 3831
 
3887
-				}
3888
-			} catch ( Exception $e ) {
3889
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3890
-			}
3891
-		}
3892
-	}
3832
+    /**
3833
+     * Handle the status transition.
3834
+     */
3835
+    protected function status_transition() {
3836
+        $status_transition = $this->status_transition;
3837
+
3838
+        // Reset status transition variable.
3839
+        $this->status_transition = false;
3840
+
3841
+        if ( $status_transition ) {
3842
+            try {
3843
+
3844
+                // Fire a hook for the status change.
3845
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3846
+
3847
+                // @deprecated this is deprecated and will be removed in the future.
3848
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3849
+
3850
+                if ( ! empty( $status_transition['from'] ) ) {
3851
+
3852
+                    /* translators: 1: old invoice status 2: new invoice status */
3853
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) );
3854
+
3855
+                    // Fire another hook.
3856
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3857
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3858
+
3859
+                    // @deprecated this is deprecated and will be removed in the future.
3860
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3861
+
3862
+                    // Note the transition occurred.
3863
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3864
+
3865
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3866
+                    if (
3867
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3868
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3869
+                    ) {
3870
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3871
+                    }
3872
+
3873
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3874
+                    if (
3875
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3876
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3877
+                    ) {
3878
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3879
+                    }
3880
+                } else {
3881
+                    /* translators: %s: new invoice status */
3882
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) );
3883
+
3884
+                    // Note the transition occurred.
3885
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3886
+
3887
+                }
3888
+            } catch ( Exception $e ) {
3889
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3890
+            }
3891
+        }
3892
+    }
3893 3893
 
3894
-	/**
3895
-	 * Updates an invoice status.
3896
-	 */
3897
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3894
+    /**
3895
+     * Updates an invoice status.
3896
+     */
3897
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3898 3898
 
3899
-		// Fires before updating a status.
3900
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3899
+        // Fires before updating a status.
3900
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3901 3901
 
3902
-		// Update the status.
3903
-		$this->set_status( $new_status, $note, $manual );
3902
+        // Update the status.
3903
+        $this->set_status( $new_status, $note, $manual );
3904 3904
 
3905
-		// Save the order.
3906
-		return $this->save();
3905
+        // Save the order.
3906
+        return $this->save();
3907 3907
 
3908
-	}
3908
+    }
3909 3909
 
3910
-	/**
3911
-	 * @deprecated
3912
-	 */
3913
-	public function refresh_item_ids() {
3910
+    /**
3911
+     * @deprecated
3912
+     */
3913
+    public function refresh_item_ids() {
3914 3914
         $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3915 3915
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3916
-	}
3916
+    }
3917 3917
 
3918
-	/**
3919
-	 * @deprecated
3920
-	 */
3921
-	public function update_items( $temp = false ) {
3918
+    /**
3919
+     * @deprecated
3920
+     */
3921
+    public function update_items( $temp = false ) {
3922 3922
 
3923
-		$this->set_items( $this->get_items() );
3923
+        $this->set_items( $this->get_items() );
3924 3924
 
3925
-		if ( ! $temp ) {
3926
-			$this->save();
3927
-		}
3925
+        if ( ! $temp ) {
3926
+            $this->save();
3927
+        }
3928 3928
 
3929 3929
         return $this;
3930
-	}
3930
+    }
3931 3931
 
3932
-	/**
3933
-	 * @deprecated
3934
-	 */
3932
+    /**
3933
+     * @deprecated
3934
+     */
3935 3935
     public function validate_discount() {
3936 3936
 
3937 3937
         $discount_code = $this->get_discount_code();
@@ -3947,101 +3947,101 @@  discard block
 block discarded – undo
3947 3947
 
3948 3948
     }
3949 3949
 
3950
-	/**
3951
-	 * Refunds an invoice.
3952
-	 */
3950
+    /**
3951
+     * Refunds an invoice.
3952
+     */
3953 3953
     public function refund() {
3954
-		$this->set_status( 'wpi-refunded' );
3954
+        $this->set_status( 'wpi-refunded' );
3955 3955
         $this->save();
3956
-	}
3956
+    }
3957 3957
 
3958
-	/**
3959
-	 * Marks an invoice as paid.
3960
-	 *
3961
-	 * @param string $transaction_id
3962
-	 */
3958
+    /**
3959
+     * Marks an invoice as paid.
3960
+     *
3961
+     * @param string $transaction_id
3962
+     */
3963 3963
     public function mark_paid( $transaction_id = null, $note = '' ) {
3964 3964
 
3965
-		// Set the transaction id.
3966
-		if ( empty( $transaction_id ) ) {
3967
-			$transaction_id = $this->generate_key( 'trans_' );
3968
-		}
3965
+        // Set the transaction id.
3966
+        if ( empty( $transaction_id ) ) {
3967
+            $transaction_id = $this->generate_key( 'trans_' );
3968
+        }
3969 3969
 
3970
-		if ( ! $this->get_transaction_id() ) {
3971
-			$this->set_transaction_id( $transaction_id );
3972
-		}
3970
+        if ( ! $this->get_transaction_id() ) {
3971
+            $this->set_transaction_id( $transaction_id );
3972
+        }
3973 3973
 
3974
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3975
-			return $this->save();
3976
-		}
3974
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3975
+            return $this->save();
3976
+        }
3977 3977
 
3978
-		// Set the completed date.
3979
-		$this->set_date_completed( current_time( 'mysql' ) );
3978
+        // Set the completed date.
3979
+        $this->set_date_completed( current_time( 'mysql' ) );
3980 3980
 
3981
-		// Set the new status.
3982
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3983
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
3981
+        // Set the new status.
3982
+        $gateway = sanitize_text_field( $this->get_gateway_title() );
3983
+        if ( $this->is_renewal() || ! $this->is_parent() ) {
3984 3984
 
3985
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3986
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3985
+            $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3986
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3987 3987
 
3988
-			if ( 'none' == $this->get_gateway() ) {
3989
-				$_note = $note;
3990
-			}
3988
+            if ( 'none' == $this->get_gateway() ) {
3989
+                $_note = $note;
3990
+            }
3991 3991
 
3992
-			$this->set_status( 'wpi-renewal', $_note );
3992
+            $this->set_status( 'wpi-renewal', $_note );
3993 3993
 
3994
-		} else {
3994
+        } else {
3995 3995
 
3996
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3997
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3996
+            $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3997
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3998 3998
 
3999
-			if ( 'none' == $this->get_gateway() ) {
4000
-				$_note = $note;
4001
-			}
3999
+            if ( 'none' == $this->get_gateway() ) {
4000
+                $_note = $note;
4001
+            }
4002 4002
 
4003
-			$this->set_status( 'publish', $_note );
4003
+            $this->set_status( 'publish', $_note );
4004 4004
 
4005
-		}
4005
+        }
4006 4006
 
4007
-		// Set checkout mode.
4008
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
4009
-		$this->set_mode( $mode );
4007
+        // Set checkout mode.
4008
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
4009
+        $this->set_mode( $mode );
4010 4010
 
4011
-		// Save the invoice.
4011
+        // Save the invoice.
4012 4012
         $this->save();
4013
-	}
4014
-
4015
-	/**
4016
-	 * Save data to the database.
4017
-	 *
4018
-	 * @since 1.0.19
4019
-	 * @return int invoice ID
4020
-	 */
4021
-	public function save() {
4022
-		$this->maybe_set_date_paid();
4023
-		$this->maybe_set_key();
4024
-		parent::save();
4025
-		$this->clear_cache();
4026
-		$this->status_transition();
4027
-		return $this->get_id();
4028
-	}
4029
-
4030
-	/**
4013
+    }
4014
+
4015
+    /**
4016
+     * Save data to the database.
4017
+     *
4018
+     * @since 1.0.19
4019
+     * @return int invoice ID
4020
+     */
4021
+    public function save() {
4022
+        $this->maybe_set_date_paid();
4023
+        $this->maybe_set_key();
4024
+        parent::save();
4025
+        $this->clear_cache();
4026
+        $this->status_transition();
4027
+        return $this->get_id();
4028
+    }
4029
+
4030
+    /**
4031 4031
      * Clears the subscription's cache.
4032 4032
      */
4033 4033
     public function clear_cache() {
4034
-		if ( $this->get_key() ) {
4035
-			wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4036
-		}
4037
-
4038
-		if ( $this->get_number() ) {
4039
-			wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4040
-		}
4041
-
4042
-		if ( $this->get_transaction_id() ) {
4043
-			wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4044
-		}
4045
-	}
4034
+        if ( $this->get_key() ) {
4035
+            wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4036
+        }
4037
+
4038
+        if ( $this->get_number() ) {
4039
+            wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4040
+        }
4041
+
4042
+        if ( $this->get_transaction_id() ) {
4043
+            wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4044
+        }
4045
+    }
4046 4046
 
4047 4047
 }
Please login to merge, or discard this patch.
Spacing   +817 added lines, -817 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
  * Invoice class.
@@ -145,39 +145,39 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
147 147
 	 */
148
-    public function __construct( $invoice = 0 ) {
148
+    public function __construct($invoice = 0) {
149 149
 
150
-        parent::__construct( $invoice );
150
+        parent::__construct($invoice);
151 151
 
152
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
153
-			$this->set_id( (int) $invoice );
154
-		} elseif ( $invoice instanceof self ) {
155
-			$this->set_id( $invoice->get_id() );
156
-		} elseif ( ! empty( $invoice->ID ) ) {
157
-			$this->set_id( $invoice->ID );
158
-		} elseif ( is_array( $invoice ) ) {
159
-			$this->set_props( $invoice );
152
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) {
153
+			$this->set_id((int) $invoice);
154
+		} elseif ($invoice instanceof self) {
155
+			$this->set_id($invoice->get_id());
156
+		} elseif (!empty($invoice->ID)) {
157
+			$this->set_id($invoice->ID);
158
+		} elseif (is_array($invoice)) {
159
+			$this->set_props($invoice);
160 160
 
161
-			if ( isset( $invoice['ID'] ) ) {
162
-				$this->set_id( $invoice['ID'] );
161
+			if (isset($invoice['ID'])) {
162
+				$this->set_id($invoice['ID']);
163 163
 			}
164
-} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
165
-			$this->set_id( $invoice_id );
166
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
167
-			$this->set_id( $invoice_id );
168
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
169
-			$this->set_id( $invoice_id );
164
+} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
165
+			$this->set_id($invoice_id);
166
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
167
+			$this->set_id($invoice_id);
168
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
169
+			$this->set_id($invoice_id);
170 170
 		} else {
171
-			$this->set_object_read( true );
171
+			$this->set_object_read(true);
172 172
 		}
173 173
 
174 174
         // Load the datastore.
175
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
175
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
176 176
 
177
-		if ( $this->get_id() > 0 ) {
178
-            $this->post = get_post( $this->get_id() );
177
+		if ($this->get_id() > 0) {
178
+            $this->post = get_post($this->get_id());
179 179
             $this->ID   = $this->get_id();
180
-			$this->data_store->read( $this );
180
+			$this->data_store->read($this);
181 181
         }
182 182
 
183 183
     }
@@ -192,38 +192,38 @@  discard block
 block discarded – undo
192 192
 	 * @since 1.0.15
193 193
 	 * @return int
194 194
 	 */
195
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
195
+	public static function get_invoice_id_by_field($value, $field = 'key') {
196 196
         global $wpdb;
197 197
 
198 198
 		// Trim the value.
199
-		$value = trim( $value );
199
+		$value = trim($value);
200 200
 
201
-		if ( empty( $value ) ) {
201
+		if (empty($value)) {
202 202
 			return 0;
203 203
 		}
204 204
 
205 205
         // Valid fields.
206
-        $fields = array( 'key', 'number', 'transaction_id' );
206
+        $fields = array('key', 'number', 'transaction_id');
207 207
 
208 208
 		// Ensure a field has been passed.
209
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
209
+		if (empty($field) || !in_array($field, $fields)) {
210 210
 			return 0;
211 211
 		}
212 212
 
213 213
 		// Maybe retrieve from the cache.
214
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
-		if ( false !== $invoice_id ) {
214
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
215
+		if (false !== $invoice_id) {
216 216
 			return $invoice_id;
217 217
 		}
218 218
 
219 219
         // Fetch from the db.
220 220
         $table       = $wpdb->prefix . 'getpaid_invoices';
221 221
         $invoice_id  = (int) $wpdb->get_var(
222
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
222
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
223 223
         );
224 224
 
225 225
 		// Update the cache with our data
226
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
226
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
227 227
 
228 228
 		return $invoice_id;
229 229
     }
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
     /**
232 232
      * Checks if an invoice key is set.
233 233
      */
234
-    public function _isset( $key ) {
235
-        return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" );
234
+    public function _isset($key) {
235
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
236 236
     }
237 237
 
238 238
     /*
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 	 * @param  string $context View or edit context.
258 258
 	 * @return int
259 259
 	 */
260
-	public function get_parent_id( $context = 'view' ) {
261
-		return (int) $this->get_prop( 'parent_id', $context );
260
+	public function get_parent_id($context = 'view') {
261
+		return (int) $this->get_prop('parent_id', $context);
262 262
     }
263 263
 
264 264
     /**
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 * @return WPInv_Invoice
269 269
 	 */
270 270
     public function get_parent_payment() {
271
-        return new WPInv_Invoice( $this->get_parent_id() );
271
+        return new WPInv_Invoice($this->get_parent_id());
272 272
     }
273 273
 
274 274
     /**
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
 	 * @param  string $context View or edit context.
289 289
 	 * @return string
290 290
 	 */
291
-	public function get_status( $context = 'view' ) {
292
-		return $this->get_prop( 'status', $context );
291
+	public function get_status($context = 'view') {
292
+		return $this->get_prop('status', $context);
293 293
 	}
294 294
 
295 295
 	/**
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @return array
300 300
 	 */
301 301
 	public function get_all_statuses() {
302
-		return wpinv_get_invoice_statuses( true, true, $this );
302
+		return wpinv_get_invoice_statuses(true, true, $this);
303 303
     }
304 304
 
305 305
     /**
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
     public function get_status_nicename() {
312 312
 		$statuses = $this->get_all_statuses();
313 313
 
314
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
314
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
315 315
 
316
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
316
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
317 317
     }
318 318
 
319 319
 	/**
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 */
325 325
 	public function get_status_class() {
326 326
 		$statuses = getpaid_get_invoice_status_classes();
327
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
327
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark';
328 328
 	}
329 329
 
330 330
 	/**
@@ -335,9 +335,9 @@  discard block
 block discarded – undo
335 335
      */
336 336
     public function get_status_label_html() {
337 337
 
338
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
339
-		$status       = sanitize_html_class( $this->get_status() );
340
-		$class        = esc_attr( $this->get_status_class() );
338
+		$status_label = sanitize_text_field($this->get_status_nicename());
339
+		$status       = sanitize_html_class($this->get_status());
340
+		$class        = esc_attr($this->get_status_class());
341 341
 
342 342
 		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
343 343
 	}
@@ -349,23 +349,23 @@  discard block
 block discarded – undo
349 349
 	 * @param  string $context View or edit context.
350 350
 	 * @return string
351 351
 	 */
352
-	public function get_version( $context = 'view' ) {
353
-		return $this->get_prop( 'version', $context );
352
+	public function get_version($context = 'view') {
353
+		return $this->get_prop('version', $context);
354 354
 	}
355 355
 
356 356
 	/**
357 357
 	 * @deprecated
358 358
 	 */
359
-	public function get_invoice_date( $format = true ) {
360
-		$date      = getpaid_format_date( $this->get_date_completed() );
361
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
362
-		$formatted = getpaid_format_date( $date );
359
+	public function get_invoice_date($format = true) {
360
+		$date      = getpaid_format_date($this->get_date_completed());
361
+		$date      = empty($date) ? $this->get_date_created() : $this->get_date_completed();
362
+		$formatted = getpaid_format_date($date);
363 363
 
364
-		if ( $format ) {
364
+		if ($format) {
365 365
 			return $formatted;
366 366
 		}
367 367
 
368
-		return empty( $formatted ) ? '' : $date;
368
+		return empty($formatted) ? '' : $date;
369 369
 
370 370
     }
371 371
 
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * @param  string $context View or edit context.
377 377
 	 * @return string
378 378
 	 */
379
-	public function get_date_created( $context = 'view' ) {
380
-		return $this->get_prop( 'date_created', $context );
379
+	public function get_date_created($context = 'view') {
380
+		return $this->get_prop('date_created', $context);
381 381
 	}
382 382
 
383 383
 	/**
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 	 * @param  string $context View or edit context.
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_created_date( $context = 'view' ) {
391
-		return $this->get_date_created( $context );
390
+	public function get_created_date($context = 'view') {
391
+		return $this->get_date_created($context);
392 392
     }
393 393
 
394 394
     /**
@@ -398,11 +398,11 @@  discard block
 block discarded – undo
398 398
 	 * @param  string $context View or edit context.
399 399
 	 * @return string
400 400
 	 */
401
-	public function get_date_created_gmt( $context = 'view' ) {
402
-        $date = $this->get_date_created( $context );
401
+	public function get_date_created_gmt($context = 'view') {
402
+        $date = $this->get_date_created($context);
403 403
 
404
-        if ( $date ) {
405
-            $date = get_gmt_from_date( $date );
404
+        if ($date) {
405
+            $date = get_gmt_from_date($date);
406 406
         }
407 407
 		return $date;
408 408
     }
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
 	 * @param  string $context View or edit context.
415 415
 	 * @return string
416 416
 	 */
417
-	public function get_date_modified( $context = 'view' ) {
418
-		return $this->get_prop( 'date_modified', $context );
417
+	public function get_date_modified($context = 'view') {
418
+		return $this->get_prop('date_modified', $context);
419 419
 	}
420 420
 
421 421
 	/**
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
 	 * @param  string $context View or edit context.
426 426
 	 * @return string
427 427
 	 */
428
-	public function get_modified_date( $context = 'view' ) {
429
-		return $this->get_date_modified( $context );
428
+	public function get_modified_date($context = 'view') {
429
+		return $this->get_date_modified($context);
430 430
     }
431 431
 
432 432
     /**
@@ -436,11 +436,11 @@  discard block
 block discarded – undo
436 436
 	 * @param  string $context View or edit context.
437 437
 	 * @return string
438 438
 	 */
439
-	public function get_date_modified_gmt( $context = 'view' ) {
440
-        $date = $this->get_date_modified( $context );
439
+	public function get_date_modified_gmt($context = 'view') {
440
+        $date = $this->get_date_modified($context);
441 441
 
442
-        if ( $date ) {
443
-            $date = get_gmt_from_date( $date );
442
+        if ($date) {
443
+            $date = get_gmt_from_date($date);
444 444
         }
445 445
 		return $date;
446 446
     }
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
 	 * @param  string $context View or edit context.
453 453
 	 * @return string
454 454
 	 */
455
-	public function get_due_date( $context = 'view' ) {
456
-		return $this->get_prop( 'due_date', $context );
455
+	public function get_due_date($context = 'view') {
456
+		return $this->get_prop('due_date', $context);
457 457
     }
458 458
 
459 459
     /**
@@ -463,8 +463,8 @@  discard block
 block discarded – undo
463 463
 	 * @param  string $context View or edit context.
464 464
 	 * @return string
465 465
 	 */
466
-	public function get_date_due( $context = 'view' ) {
467
-		return $this->get_due_date( $context );
466
+	public function get_date_due($context = 'view') {
467
+		return $this->get_due_date($context);
468 468
     }
469 469
 
470 470
     /**
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
 	 * @param  string $context View or edit context.
475 475
 	 * @return string
476 476
 	 */
477
-	public function get_due_date_gmt( $context = 'view' ) {
478
-        $date = $this->get_due_date( $context );
477
+	public function get_due_date_gmt($context = 'view') {
478
+        $date = $this->get_due_date($context);
479 479
 
480
-        if ( $date ) {
481
-            $date = get_gmt_from_date( $date );
480
+        if ($date) {
481
+            $date = get_gmt_from_date($date);
482 482
         }
483 483
 		return $date;
484 484
     }
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 	 * @param  string $context View or edit context.
491 491
 	 * @return string
492 492
 	 */
493
-	public function get_gmt_date_due( $context = 'view' ) {
494
-		return $this->get_due_date_gmt( $context );
493
+	public function get_gmt_date_due($context = 'view') {
494
+		return $this->get_due_date_gmt($context);
495 495
     }
496 496
 
497 497
     /**
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	 * @param  string $context View or edit context.
502 502
 	 * @return string
503 503
 	 */
504
-	public function get_completed_date( $context = 'view' ) {
505
-		return $this->get_prop( 'completed_date', $context );
504
+	public function get_completed_date($context = 'view') {
505
+		return $this->get_prop('completed_date', $context);
506 506
     }
507 507
 
508 508
     /**
@@ -512,8 +512,8 @@  discard block
 block discarded – undo
512 512
 	 * @param  string $context View or edit context.
513 513
 	 * @return string
514 514
 	 */
515
-	public function get_date_completed( $context = 'view' ) {
516
-		return $this->get_completed_date( $context );
515
+	public function get_date_completed($context = 'view') {
516
+		return $this->get_completed_date($context);
517 517
     }
518 518
 
519 519
     /**
@@ -523,11 +523,11 @@  discard block
 block discarded – undo
523 523
 	 * @param  string $context View or edit context.
524 524
 	 * @return string
525 525
 	 */
526
-	public function get_completed_date_gmt( $context = 'view' ) {
527
-        $date = $this->get_completed_date( $context );
526
+	public function get_completed_date_gmt($context = 'view') {
527
+        $date = $this->get_completed_date($context);
528 528
 
529
-        if ( $date ) {
530
-            $date = get_gmt_from_date( $date );
529
+        if ($date) {
530
+            $date = get_gmt_from_date($date);
531 531
         }
532 532
 		return $date;
533 533
     }
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
 	 * @param  string $context View or edit context.
540 540
 	 * @return string
541 541
 	 */
542
-	public function get_gmt_completed_date( $context = 'view' ) {
543
-		return $this->get_completed_date_gmt( $context );
542
+	public function get_gmt_completed_date($context = 'view') {
543
+		return $this->get_completed_date_gmt($context);
544 544
     }
545 545
 
546 546
     /**
@@ -550,12 +550,12 @@  discard block
 block discarded – undo
550 550
 	 * @param  string $context View or edit context.
551 551
 	 * @return string
552 552
 	 */
553
-	public function get_number( $context = 'view' ) {
554
-		$number = $this->get_prop( 'number', $context );
553
+	public function get_number($context = 'view') {
554
+		$number = $this->get_prop('number', $context);
555 555
 
556
-		if ( empty( $number ) ) {
556
+		if (empty($number)) {
557 557
 			$number = $this->generate_number();
558
-			$this->set_number( $this->generate_number() );
558
+			$this->set_number($this->generate_number());
559 559
 		}
560 560
 
561 561
 		return $number;
@@ -569,8 +569,8 @@  discard block
 block discarded – undo
569 569
 	public function maybe_set_number() {
570 570
         $number = $this->get_number();
571 571
 
572
-        if ( empty( $number ) || $this->get_id() == $number ) {
573
-			$this->set_number( $this->generate_number() );
572
+        if (empty($number) || $this->get_id() == $number) {
573
+			$this->set_number($this->generate_number());
574 574
         }
575 575
 
576 576
 	}
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 	 * @param  string $context View or edit context.
583 583
 	 * @return string
584 584
 	 */
585
-	public function get_key( $context = 'view' ) {
586
-        return $this->get_prop( 'key', $context );
585
+	public function get_key($context = 'view') {
586
+        return $this->get_prop('key', $context);
587 587
 	}
588 588
 
589 589
 	/**
@@ -594,9 +594,9 @@  discard block
 block discarded – undo
594 594
 	public function maybe_set_key() {
595 595
         $key = $this->get_key();
596 596
 
597
-        if ( empty( $key ) ) {
598
-            $key = $this->generate_key( $this->get_type() . '_' );
599
-            $this->set_key( $key );
597
+        if (empty($key)) {
598
+            $key = $this->generate_key($this->get_type() . '_');
599
+            $this->set_key($key);
600 600
         }
601 601
 
602 602
     }
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
 	 * @param  string $context View or edit context.
609 609
 	 * @return string
610 610
 	 */
611
-	public function get_type( $context = 'view' ) {
612
-        return $this->get_prop( 'type', $context );
611
+	public function get_type($context = 'view') {
612
+        return $this->get_prop('type', $context);
613 613
 	}
614 614
 
615 615
 	/**
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 	 * @return string
620 620
 	 */
621 621
 	public function get_invoice_quote_type() {
622
-        return getpaid_get_post_type_label( $this->get_post_type(), false );
622
+        return getpaid_get_post_type_label($this->get_post_type(), false);
623 623
     }
624 624
 
625 625
     /**
@@ -629,8 +629,8 @@  discard block
 block discarded – undo
629 629
 	 * @param  string $context View or edit context.
630 630
 	 * @return string
631 631
 	 */
632
-	public function get_label( $context = 'view' ) {
633
-        return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
632
+	public function get_label($context = 'view') {
633
+        return getpaid_get_post_type_label($this->get_post_type($context), false);
634 634
 	}
635 635
 
636 636
 	/**
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
 	 * @param  string $context View or edit context.
641 641
 	 * @return string
642 642
 	 */
643
-	public function get_post_type( $context = 'view' ) {
644
-        return $this->get_prop( 'post_type', $context );
643
+	public function get_post_type($context = 'view') {
644
+        return $this->get_prop('post_type', $context);
645 645
     }
646 646
 
647 647
     /**
@@ -651,8 +651,8 @@  discard block
 block discarded – undo
651 651
 	 * @param  string $context View or edit context.
652 652
 	 * @return string
653 653
 	 */
654
-	public function get_mode( $context = 'view' ) {
655
-        return $this->get_prop( 'mode', $context );
654
+	public function get_mode($context = 'view') {
655
+        return $this->get_prop('mode', $context);
656 656
     }
657 657
 
658 658
     /**
@@ -662,13 +662,13 @@  discard block
 block discarded – undo
662 662
 	 * @param  string $context View or edit context.
663 663
 	 * @return string
664 664
 	 */
665
-	public function get_path( $context = 'view' ) {
666
-        $path   = $this->get_prop( 'path', $context );
665
+	public function get_path($context = 'view') {
666
+        $path = $this->get_prop('path', $context);
667 667
 		$prefix = $this->get_type();
668 668
 
669
-		if ( 0 !== strpos( $path, $prefix ) ) {
670
-			$path = sanitize_title( $prefix . '-' . $this->get_id() );
671
-			$this->set_path( $path );
669
+		if (0 !== strpos($path, $prefix)) {
670
+			$path = sanitize_title($prefix . '-' . $this->get_id());
671
+			$this->set_path($path);
672 672
 		}
673 673
 
674 674
 		return $path;
@@ -681,8 +681,8 @@  discard block
 block discarded – undo
681 681
 	 * @param  string $context View or edit context.
682 682
 	 * @return string
683 683
 	 */
684
-	public function get_name( $context = 'view' ) {
685
-        return $this->get_prop( 'title', $context );
684
+	public function get_name($context = 'view') {
685
+        return $this->get_prop('title', $context);
686 686
     }
687 687
 
688 688
     /**
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
 	 * @param  string $context View or edit context.
693 693
 	 * @return string
694 694
 	 */
695
-	public function get_title( $context = 'view' ) {
696
-		return $this->get_name( $context );
695
+	public function get_title($context = 'view') {
696
+		return $this->get_name($context);
697 697
     }
698 698
 
699 699
     /**
@@ -703,8 +703,8 @@  discard block
 block discarded – undo
703 703
 	 * @param  string $context View or edit context.
704 704
 	 * @return string
705 705
 	 */
706
-	public function get_description( $context = 'view' ) {
707
-		return $this->get_prop( 'description', $context );
706
+	public function get_description($context = 'view') {
707
+		return $this->get_prop('description', $context);
708 708
     }
709 709
 
710 710
     /**
@@ -714,8 +714,8 @@  discard block
 block discarded – undo
714 714
 	 * @param  string $context View or edit context.
715 715
 	 * @return string
716 716
 	 */
717
-	public function get_excerpt( $context = 'view' ) {
718
-		return $this->get_description( $context );
717
+	public function get_excerpt($context = 'view') {
718
+		return $this->get_description($context);
719 719
     }
720 720
 
721 721
     /**
@@ -725,8 +725,8 @@  discard block
 block discarded – undo
725 725
 	 * @param  string $context View or edit context.
726 726
 	 * @return string
727 727
 	 */
728
-	public function get_summary( $context = 'view' ) {
729
-		return $this->get_description( $context );
728
+	public function get_summary($context = 'view') {
729
+		return $this->get_description($context);
730 730
     }
731 731
 
732 732
     /**
@@ -736,26 +736,26 @@  discard block
 block discarded – undo
736 736
      * @param  string $context View or edit context.
737 737
 	 * @return array
738 738
 	 */
739
-    public function get_user_info( $context = 'view' ) {
739
+    public function get_user_info($context = 'view') {
740 740
 
741 741
         $user_info = array(
742
-            'user_id'    => $this->get_user_id( $context ),
743
-            'email'      => $this->get_email( $context ),
744
-            'first_name' => $this->get_first_name( $context ),
745
-            'last_name'  => $this->get_last_name( $context ),
746
-            'address'    => $this->get_address( $context ),
747
-            'phone'      => $this->get_phone( $context ),
748
-            'city'       => $this->get_city( $context ),
749
-            'country'    => $this->get_country( $context ),
750
-            'state'      => $this->get_state( $context ),
751
-            'zip'        => $this->get_zip( $context ),
752
-            'company'    => $this->get_company( $context ),
753
-			'company_id' => $this->get_company_id( $context ),
754
-            'vat_number' => $this->get_vat_number( $context ),
755
-            'discount'   => $this->get_discount_code( $context ),
742
+            'user_id'    => $this->get_user_id($context),
743
+            'email'      => $this->get_email($context),
744
+            'first_name' => $this->get_first_name($context),
745
+            'last_name'  => $this->get_last_name($context),
746
+            'address'    => $this->get_address($context),
747
+            'phone'      => $this->get_phone($context),
748
+            'city'       => $this->get_city($context),
749
+            'country'    => $this->get_country($context),
750
+            'state'      => $this->get_state($context),
751
+            'zip'        => $this->get_zip($context),
752
+            'company'    => $this->get_company($context),
753
+			'company_id' => $this->get_company_id($context),
754
+            'vat_number' => $this->get_vat_number($context),
755
+            'discount'   => $this->get_discount_code($context),
756 756
 		);
757 757
 
758
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
758
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
759 759
 
760 760
     }
761 761
 
@@ -766,8 +766,8 @@  discard block
 block discarded – undo
766 766
 	 * @param  string $context View or edit context.
767 767
 	 * @return int
768 768
 	 */
769
-	public function get_author( $context = 'view' ) {
770
-		return (int) $this->get_prop( 'author', $context );
769
+	public function get_author($context = 'view') {
770
+		return (int) $this->get_prop('author', $context);
771 771
     }
772 772
 
773 773
     /**
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
 	 * @param  string $context View or edit context.
778 778
 	 * @return int
779 779
 	 */
780
-	public function get_user_id( $context = 'view' ) {
781
-		return $this->get_author( $context );
780
+	public function get_user_id($context = 'view') {
781
+		return $this->get_author($context);
782 782
     }
783 783
 
784 784
      /**
@@ -788,8 +788,8 @@  discard block
 block discarded – undo
788 788
 	 * @param  string $context View or edit context.
789 789
 	 * @return int
790 790
 	 */
791
-	public function get_customer_id( $context = 'view' ) {
792
-		return $this->get_author( $context );
791
+	public function get_customer_id($context = 'view') {
792
+		return $this->get_author($context);
793 793
     }
794 794
 
795 795
     /**
@@ -799,8 +799,8 @@  discard block
 block discarded – undo
799 799
 	 * @param  string $context View or edit context.
800 800
 	 * @return string
801 801
 	 */
802
-	public function get_ip( $context = 'view' ) {
803
-		return $this->get_prop( 'user_ip', $context );
802
+	public function get_ip($context = 'view') {
803
+		return $this->get_prop('user_ip', $context);
804 804
     }
805 805
 
806 806
     /**
@@ -810,8 +810,8 @@  discard block
 block discarded – undo
810 810
 	 * @param  string $context View or edit context.
811 811
 	 * @return string
812 812
 	 */
813
-	public function get_user_ip( $context = 'view' ) {
814
-		return $this->get_ip( $context );
813
+	public function get_user_ip($context = 'view') {
814
+		return $this->get_ip($context);
815 815
     }
816 816
 
817 817
      /**
@@ -821,8 +821,8 @@  discard block
 block discarded – undo
821 821
 	 * @param  string $context View or edit context.
822 822
 	 * @return string
823 823
 	 */
824
-	public function get_customer_ip( $context = 'view' ) {
825
-		return $this->get_ip( $context );
824
+	public function get_customer_ip($context = 'view') {
825
+		return $this->get_ip($context);
826 826
     }
827 827
 
828 828
     /**
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
 	 * @param  string $context View or edit context.
833 833
 	 * @return string
834 834
 	 */
835
-	public function get_first_name( $context = 'view' ) {
836
-		return $this->get_prop( 'first_name', $context );
835
+	public function get_first_name($context = 'view') {
836
+		return $this->get_prop('first_name', $context);
837 837
     }
838 838
 
839 839
     /**
@@ -843,8 +843,8 @@  discard block
 block discarded – undo
843 843
 	 * @param  string $context View or edit context.
844 844
 	 * @return string
845 845
 	 */
846
-	public function get_user_first_name( $context = 'view' ) {
847
-		return $this->get_first_name( $context );
846
+	public function get_user_first_name($context = 'view') {
847
+		return $this->get_first_name($context);
848 848
     }
849 849
 
850 850
      /**
@@ -854,8 +854,8 @@  discard block
 block discarded – undo
854 854
 	 * @param  string $context View or edit context.
855 855
 	 * @return string
856 856
 	 */
857
-	public function get_customer_first_name( $context = 'view' ) {
858
-		return $this->get_first_name( $context );
857
+	public function get_customer_first_name($context = 'view') {
858
+		return $this->get_first_name($context);
859 859
     }
860 860
 
861 861
     /**
@@ -865,8 +865,8 @@  discard block
 block discarded – undo
865 865
 	 * @param  string $context View or edit context.
866 866
 	 * @return string
867 867
 	 */
868
-	public function get_last_name( $context = 'view' ) {
869
-		return $this->get_prop( 'last_name', $context );
868
+	public function get_last_name($context = 'view') {
869
+		return $this->get_prop('last_name', $context);
870 870
     }
871 871
 
872 872
     /**
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
 	 * @param  string $context View or edit context.
877 877
 	 * @return string
878 878
 	 */
879
-	public function get_user_last_name( $context = 'view' ) {
880
-		return $this->get_last_name( $context );
879
+	public function get_user_last_name($context = 'view') {
880
+		return $this->get_last_name($context);
881 881
     }
882 882
 
883 883
     /**
@@ -887,8 +887,8 @@  discard block
 block discarded – undo
887 887
 	 * @param  string $context View or edit context.
888 888
 	 * @return string
889 889
 	 */
890
-	public function get_customer_last_name( $context = 'view' ) {
891
-		return $this->get_last_name( $context );
890
+	public function get_customer_last_name($context = 'view') {
891
+		return $this->get_last_name($context);
892 892
     }
893 893
 
894 894
     /**
@@ -898,22 +898,22 @@  discard block
 block discarded – undo
898 898
 	 * @param  string $context View or edit context.
899 899
 	 * @return string
900 900
 	 */
901
-	public function get_full_name( $context = 'view' ) {
902
-		$name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
901
+	public function get_full_name($context = 'view') {
902
+		$name = trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
903 903
 
904
-		if ( ! $name ) {
905
-			$user = get_userdata( $this->get_author( $context ) );
904
+		if (!$name) {
905
+			$user = get_userdata($this->get_author($context));
906 906
 
907
-			if ( $user ) {
907
+			if ($user) {
908 908
 				$name = $user->display_name;
909 909
 			}
910 910
 		}
911 911
 
912
-		if ( ! $name ) {
913
-			$name = $this->get_email( $context );
912
+		if (!$name) {
913
+			$name = $this->get_email($context);
914 914
 		}
915 915
 
916
-		return apply_filters( 'wpinv_invoice_user_full_name', $name, $this );
916
+		return apply_filters('wpinv_invoice_user_full_name', $name, $this);
917 917
     }
918 918
 
919 919
     /**
@@ -923,8 +923,8 @@  discard block
 block discarded – undo
923 923
 	 * @param  string $context View or edit context.
924 924
 	 * @return string
925 925
 	 */
926
-	public function get_user_full_name( $context = 'view' ) {
927
-		return $this->get_full_name( $context );
926
+	public function get_user_full_name($context = 'view') {
927
+		return $this->get_full_name($context);
928 928
     }
929 929
 
930 930
     /**
@@ -934,8 +934,8 @@  discard block
 block discarded – undo
934 934
 	 * @param  string $context View or edit context.
935 935
 	 * @return string
936 936
 	 */
937
-	public function get_customer_full_name( $context = 'view' ) {
938
-		return $this->get_full_name( $context );
937
+	public function get_customer_full_name($context = 'view') {
938
+		return $this->get_full_name($context);
939 939
     }
940 940
 
941 941
     /**
@@ -945,8 +945,8 @@  discard block
 block discarded – undo
945 945
 	 * @param  string $context View or edit context.
946 946
 	 * @return string
947 947
 	 */
948
-	public function get_phone( $context = 'view' ) {
949
-		return $this->get_prop( 'phone', $context );
948
+	public function get_phone($context = 'view') {
949
+		return $this->get_prop('phone', $context);
950 950
     }
951 951
 
952 952
     /**
@@ -956,8 +956,8 @@  discard block
 block discarded – undo
956 956
 	 * @param  string $context View or edit context.
957 957
 	 * @return string
958 958
 	 */
959
-	public function get_phone_number( $context = 'view' ) {
960
-		return $this->get_phone( $context );
959
+	public function get_phone_number($context = 'view') {
960
+		return $this->get_phone($context);
961 961
     }
962 962
 
963 963
     /**
@@ -967,8 +967,8 @@  discard block
 block discarded – undo
967 967
 	 * @param  string $context View or edit context.
968 968
 	 * @return string
969 969
 	 */
970
-	public function get_user_phone( $context = 'view' ) {
971
-		return $this->get_phone( $context );
970
+	public function get_user_phone($context = 'view') {
971
+		return $this->get_phone($context);
972 972
     }
973 973
 
974 974
     /**
@@ -978,8 +978,8 @@  discard block
 block discarded – undo
978 978
 	 * @param  string $context View or edit context.
979 979
 	 * @return string
980 980
 	 */
981
-	public function get_customer_phone( $context = 'view' ) {
982
-		return $this->get_phone( $context );
981
+	public function get_customer_phone($context = 'view') {
982
+		return $this->get_phone($context);
983 983
     }
984 984
 
985 985
     /**
@@ -989,8 +989,8 @@  discard block
 block discarded – undo
989 989
 	 * @param  string $context View or edit context.
990 990
 	 * @return string
991 991
 	 */
992
-	public function get_email( $context = 'view' ) {
993
-		return $this->get_prop( 'email', $context );
992
+	public function get_email($context = 'view') {
993
+		return $this->get_prop('email', $context);
994 994
     }
995 995
 
996 996
     /**
@@ -1000,8 +1000,8 @@  discard block
 block discarded – undo
1000 1000
 	 * @param  string $context View or edit context.
1001 1001
 	 * @return string
1002 1002
 	 */
1003
-	public function get_email_address( $context = 'view' ) {
1004
-		return $this->get_email( $context );
1003
+	public function get_email_address($context = 'view') {
1004
+		return $this->get_email($context);
1005 1005
     }
1006 1006
 
1007 1007
     /**
@@ -1011,8 +1011,8 @@  discard block
 block discarded – undo
1011 1011
 	 * @param  string $context View or edit context.
1012 1012
 	 * @return string
1013 1013
 	 */
1014
-	public function get_user_email( $context = 'view' ) {
1015
-		return $this->get_email( $context );
1014
+	public function get_user_email($context = 'view') {
1015
+		return $this->get_email($context);
1016 1016
     }
1017 1017
 
1018 1018
     /**
@@ -1022,8 +1022,8 @@  discard block
 block discarded – undo
1022 1022
 	 * @param  string $context View or edit context.
1023 1023
 	 * @return string
1024 1024
 	 */
1025
-	public function get_customer_email( $context = 'view' ) {
1026
-		return $this->get_email( $context );
1025
+	public function get_customer_email($context = 'view') {
1026
+		return $this->get_email($context);
1027 1027
     }
1028 1028
 
1029 1029
     /**
@@ -1033,9 +1033,9 @@  discard block
 block discarded – undo
1033 1033
 	 * @param  string $context View or edit context.
1034 1034
 	 * @return string
1035 1035
 	 */
1036
-	public function get_country( $context = 'view' ) {
1037
-		$country = $this->get_prop( 'country', $context );
1038
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1036
+	public function get_country($context = 'view') {
1037
+		$country = $this->get_prop('country', $context);
1038
+		return empty($country) ? wpinv_get_default_country() : $country;
1039 1039
     }
1040 1040
 
1041 1041
     /**
@@ -1045,8 +1045,8 @@  discard block
 block discarded – undo
1045 1045
 	 * @param  string $context View or edit context.
1046 1046
 	 * @return string
1047 1047
 	 */
1048
-	public function get_user_country( $context = 'view' ) {
1049
-		return $this->get_country( $context );
1048
+	public function get_user_country($context = 'view') {
1049
+		return $this->get_country($context);
1050 1050
     }
1051 1051
 
1052 1052
     /**
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
 	 * @param  string $context View or edit context.
1057 1057
 	 * @return string
1058 1058
 	 */
1059
-	public function get_customer_country( $context = 'view' ) {
1060
-		return $this->get_country( $context );
1059
+	public function get_customer_country($context = 'view') {
1060
+		return $this->get_country($context);
1061 1061
     }
1062 1062
 
1063 1063
     /**
@@ -1067,9 +1067,9 @@  discard block
 block discarded – undo
1067 1067
 	 * @param  string $context View or edit context.
1068 1068
 	 * @return string
1069 1069
 	 */
1070
-	public function get_state( $context = 'view' ) {
1071
-		$state = $this->get_prop( 'state', $context );
1072
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1070
+	public function get_state($context = 'view') {
1071
+		$state = $this->get_prop('state', $context);
1072
+		return empty($state) ? wpinv_get_default_state() : $state;
1073 1073
     }
1074 1074
 
1075 1075
     /**
@@ -1079,8 +1079,8 @@  discard block
 block discarded – undo
1079 1079
 	 * @param  string $context View or edit context.
1080 1080
 	 * @return string
1081 1081
 	 */
1082
-	public function get_user_state( $context = 'view' ) {
1083
-		return $this->get_state( $context );
1082
+	public function get_user_state($context = 'view') {
1083
+		return $this->get_state($context);
1084 1084
     }
1085 1085
 
1086 1086
     /**
@@ -1090,8 +1090,8 @@  discard block
 block discarded – undo
1090 1090
 	 * @param  string $context View or edit context.
1091 1091
 	 * @return string
1092 1092
 	 */
1093
-	public function get_customer_state( $context = 'view' ) {
1094
-		return $this->get_state( $context );
1093
+	public function get_customer_state($context = 'view') {
1094
+		return $this->get_state($context);
1095 1095
     }
1096 1096
 
1097 1097
     /**
@@ -1101,8 +1101,8 @@  discard block
 block discarded – undo
1101 1101
 	 * @param  string $context View or edit context.
1102 1102
 	 * @return string
1103 1103
 	 */
1104
-	public function get_city( $context = 'view' ) {
1105
-		return $this->get_prop( 'city', $context );
1104
+	public function get_city($context = 'view') {
1105
+		return $this->get_prop('city', $context);
1106 1106
     }
1107 1107
 
1108 1108
     /**
@@ -1112,8 +1112,8 @@  discard block
 block discarded – undo
1112 1112
 	 * @param  string $context View or edit context.
1113 1113
 	 * @return string
1114 1114
 	 */
1115
-	public function get_user_city( $context = 'view' ) {
1116
-		return $this->get_city( $context );
1115
+	public function get_user_city($context = 'view') {
1116
+		return $this->get_city($context);
1117 1117
     }
1118 1118
 
1119 1119
     /**
@@ -1123,8 +1123,8 @@  discard block
 block discarded – undo
1123 1123
 	 * @param  string $context View or edit context.
1124 1124
 	 * @return string
1125 1125
 	 */
1126
-	public function get_customer_city( $context = 'view' ) {
1127
-		return $this->get_city( $context );
1126
+	public function get_customer_city($context = 'view') {
1127
+		return $this->get_city($context);
1128 1128
     }
1129 1129
 
1130 1130
     /**
@@ -1134,8 +1134,8 @@  discard block
 block discarded – undo
1134 1134
 	 * @param  string $context View or edit context.
1135 1135
 	 * @return string
1136 1136
 	 */
1137
-	public function get_zip( $context = 'view' ) {
1138
-		return $this->get_prop( 'zip', $context );
1137
+	public function get_zip($context = 'view') {
1138
+		return $this->get_prop('zip', $context);
1139 1139
     }
1140 1140
 
1141 1141
     /**
@@ -1145,8 +1145,8 @@  discard block
 block discarded – undo
1145 1145
 	 * @param  string $context View or edit context.
1146 1146
 	 * @return string
1147 1147
 	 */
1148
-	public function get_user_zip( $context = 'view' ) {
1149
-		return $this->get_zip( $context );
1148
+	public function get_user_zip($context = 'view') {
1149
+		return $this->get_zip($context);
1150 1150
     }
1151 1151
 
1152 1152
     /**
@@ -1156,8 +1156,8 @@  discard block
 block discarded – undo
1156 1156
 	 * @param  string $context View or edit context.
1157 1157
 	 * @return string
1158 1158
 	 */
1159
-	public function get_customer_zip( $context = 'view' ) {
1160
-		return $this->get_zip( $context );
1159
+	public function get_customer_zip($context = 'view') {
1160
+		return $this->get_zip($context);
1161 1161
     }
1162 1162
 
1163 1163
     /**
@@ -1167,8 +1167,8 @@  discard block
 block discarded – undo
1167 1167
 	 * @param  string $context View or edit context.
1168 1168
 	 * @return string
1169 1169
 	 */
1170
-	public function get_company( $context = 'view' ) {
1171
-		return $this->get_prop( 'company', $context );
1170
+	public function get_company($context = 'view') {
1171
+		return $this->get_prop('company', $context);
1172 1172
     }
1173 1173
 
1174 1174
     /**
@@ -1178,8 +1178,8 @@  discard block
 block discarded – undo
1178 1178
 	 * @param  string $context View or edit context.
1179 1179
 	 * @return string
1180 1180
 	 */
1181
-	public function get_user_company( $context = 'view' ) {
1182
-		return $this->get_company( $context );
1181
+	public function get_user_company($context = 'view') {
1182
+		return $this->get_company($context);
1183 1183
     }
1184 1184
 
1185 1185
     /**
@@ -1189,8 +1189,8 @@  discard block
 block discarded – undo
1189 1189
 	 * @param  string $context View or edit context.
1190 1190
 	 * @return string
1191 1191
 	 */
1192
-	public function get_customer_company( $context = 'view' ) {
1193
-		return $this->get_company( $context );
1192
+	public function get_customer_company($context = 'view') {
1193
+		return $this->get_company($context);
1194 1194
     }
1195 1195
 
1196 1196
 	/**
@@ -1200,8 +1200,8 @@  discard block
 block discarded – undo
1200 1200
 	 * @param  string $context View or edit context.
1201 1201
 	 * @return string
1202 1202
 	 */
1203
-	public function get_company_id( $context = 'view' ) {
1204
-		return $this->get_prop( 'company_id', $context );
1203
+	public function get_company_id($context = 'view') {
1204
+		return $this->get_prop('company_id', $context);
1205 1205
     }
1206 1206
 
1207 1207
     /**
@@ -1211,8 +1211,8 @@  discard block
 block discarded – undo
1211 1211
 	 * @param  string $context View or edit context.
1212 1212
 	 * @return string
1213 1213
 	 */
1214
-	public function get_vat_number( $context = 'view' ) {
1215
-		return $this->get_prop( 'vat_number', $context );
1214
+	public function get_vat_number($context = 'view') {
1215
+		return $this->get_prop('vat_number', $context);
1216 1216
     }
1217 1217
 
1218 1218
     /**
@@ -1222,8 +1222,8 @@  discard block
 block discarded – undo
1222 1222
 	 * @param  string $context View or edit context.
1223 1223
 	 * @return string
1224 1224
 	 */
1225
-	public function get_user_vat_number( $context = 'view' ) {
1226
-		return $this->get_vat_number( $context );
1225
+	public function get_user_vat_number($context = 'view') {
1226
+		return $this->get_vat_number($context);
1227 1227
     }
1228 1228
 
1229 1229
     /**
@@ -1233,8 +1233,8 @@  discard block
 block discarded – undo
1233 1233
 	 * @param  string $context View or edit context.
1234 1234
 	 * @return string
1235 1235
 	 */
1236
-	public function get_customer_vat_number( $context = 'view' ) {
1237
-		return $this->get_vat_number( $context );
1236
+	public function get_customer_vat_number($context = 'view') {
1237
+		return $this->get_vat_number($context);
1238 1238
     }
1239 1239
 
1240 1240
     /**
@@ -1244,8 +1244,8 @@  discard block
 block discarded – undo
1244 1244
 	 * @param  string $context View or edit context.
1245 1245
 	 * @return string
1246 1246
 	 */
1247
-	public function get_vat_rate( $context = 'view' ) {
1248
-		return $this->get_prop( 'vat_rate', $context );
1247
+	public function get_vat_rate($context = 'view') {
1248
+		return $this->get_prop('vat_rate', $context);
1249 1249
     }
1250 1250
 
1251 1251
     /**
@@ -1255,8 +1255,8 @@  discard block
 block discarded – undo
1255 1255
 	 * @param  string $context View or edit context.
1256 1256
 	 * @return string
1257 1257
 	 */
1258
-	public function get_user_vat_rate( $context = 'view' ) {
1259
-		return $this->get_vat_rate( $context );
1258
+	public function get_user_vat_rate($context = 'view') {
1259
+		return $this->get_vat_rate($context);
1260 1260
     }
1261 1261
 
1262 1262
     /**
@@ -1266,8 +1266,8 @@  discard block
 block discarded – undo
1266 1266
 	 * @param  string $context View or edit context.
1267 1267
 	 * @return string
1268 1268
 	 */
1269
-	public function get_customer_vat_rate( $context = 'view' ) {
1270
-		return $this->get_vat_rate( $context );
1269
+	public function get_customer_vat_rate($context = 'view') {
1270
+		return $this->get_vat_rate($context);
1271 1271
     }
1272 1272
 
1273 1273
     /**
@@ -1277,8 +1277,8 @@  discard block
 block discarded – undo
1277 1277
 	 * @param  string $context View or edit context.
1278 1278
 	 * @return string
1279 1279
 	 */
1280
-	public function get_address( $context = 'view' ) {
1281
-		return $this->get_prop( 'address', $context );
1280
+	public function get_address($context = 'view') {
1281
+		return $this->get_prop('address', $context);
1282 1282
     }
1283 1283
 
1284 1284
     /**
@@ -1288,8 +1288,8 @@  discard block
 block discarded – undo
1288 1288
 	 * @param  string $context View or edit context.
1289 1289
 	 * @return string
1290 1290
 	 */
1291
-	public function get_user_address( $context = 'view' ) {
1292
-		return $this->get_address( $context );
1291
+	public function get_user_address($context = 'view') {
1292
+		return $this->get_address($context);
1293 1293
     }
1294 1294
 
1295 1295
     /**
@@ -1299,8 +1299,8 @@  discard block
 block discarded – undo
1299 1299
 	 * @param  string $context View or edit context.
1300 1300
 	 * @return string
1301 1301
 	 */
1302
-	public function get_customer_address( $context = 'view' ) {
1303
-		return $this->get_address( $context );
1302
+	public function get_customer_address($context = 'view') {
1303
+		return $this->get_address($context);
1304 1304
     }
1305 1305
 
1306 1306
     /**
@@ -1310,8 +1310,8 @@  discard block
 block discarded – undo
1310 1310
 	 * @param  string $context View or edit context.
1311 1311
 	 * @return bool
1312 1312
 	 */
1313
-	public function get_is_viewed( $context = 'view' ) {
1314
-		return (bool) $this->get_prop( 'is_viewed', $context );
1313
+	public function get_is_viewed($context = 'view') {
1314
+		return (bool) $this->get_prop('is_viewed', $context);
1315 1315
 	}
1316 1316
 
1317 1317
 	/**
@@ -1321,8 +1321,8 @@  discard block
 block discarded – undo
1321 1321
 	 * @param  string $context View or edit context.
1322 1322
 	 * @return bool
1323 1323
 	 */
1324
-	public function get_email_cc( $context = 'view' ) {
1325
-		return $this->get_prop( 'email_cc', $context );
1324
+	public function get_email_cc($context = 'view') {
1325
+		return $this->get_prop('email_cc', $context);
1326 1326
 	}
1327 1327
 
1328 1328
 	/**
@@ -1332,8 +1332,8 @@  discard block
 block discarded – undo
1332 1332
 	 * @param  string $context View or edit context.
1333 1333
 	 * @return bool
1334 1334
 	 */
1335
-	public function get_template( $context = 'view' ) {
1336
-		return $this->get_prop( 'template', $context );
1335
+	public function get_template($context = 'view') {
1336
+		return $this->get_prop('template', $context);
1337 1337
 	}
1338 1338
 
1339 1339
 	/**
@@ -1343,8 +1343,8 @@  discard block
 block discarded – undo
1343 1343
 	 * @param  string $context View or edit context.
1344 1344
 	 * @return bool
1345 1345
 	 */
1346
-	public function get_created_via( $context = 'view' ) {
1347
-		return $this->get_prop( 'created_via', $context );
1346
+	public function get_created_via($context = 'view') {
1347
+		return $this->get_prop('created_via', $context);
1348 1348
 	}
1349 1349
 
1350 1350
 	/**
@@ -1354,8 +1354,8 @@  discard block
 block discarded – undo
1354 1354
 	 * @param  string $context View or edit context.
1355 1355
 	 * @return bool
1356 1356
 	 */
1357
-	public function get_address_confirmed( $context = 'view' ) {
1358
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1357
+	public function get_address_confirmed($context = 'view') {
1358
+		return (bool) $this->get_prop('address_confirmed', $context);
1359 1359
     }
1360 1360
 
1361 1361
     /**
@@ -1365,8 +1365,8 @@  discard block
 block discarded – undo
1365 1365
 	 * @param  string $context View or edit context.
1366 1366
 	 * @return bool
1367 1367
 	 */
1368
-	public function get_user_address_confirmed( $context = 'view' ) {
1369
-		return $this->get_address_confirmed( $context );
1368
+	public function get_user_address_confirmed($context = 'view') {
1369
+		return $this->get_address_confirmed($context);
1370 1370
     }
1371 1371
 
1372 1372
     /**
@@ -1376,8 +1376,8 @@  discard block
 block discarded – undo
1376 1376
 	 * @param  string $context View or edit context.
1377 1377
 	 * @return bool
1378 1378
 	 */
1379
-	public function get_customer_address_confirmed( $context = 'view' ) {
1380
-		return $this->get_address_confirmed( $context );
1379
+	public function get_customer_address_confirmed($context = 'view') {
1380
+		return $this->get_address_confirmed($context);
1381 1381
     }
1382 1382
 
1383 1383
 	/**
@@ -1388,8 +1388,8 @@  discard block
 block discarded – undo
1388 1388
 	 */
1389 1389
 	public function get_shipping_address() {
1390 1390
 
1391
-		$shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1392
-		return is_array( $shipping_address ) ? $shipping_address : false;
1391
+		$shipping_address = get_post_meta($this->get_id(), 'shipping_address', true);
1392
+		return is_array($shipping_address) ? $shipping_address : false;
1393 1393
     }
1394 1394
 
1395 1395
 	/**
@@ -1406,17 +1406,17 @@  discard block
 block discarded – undo
1406 1406
 	 * @param  string $context View or edit context.
1407 1407
 	 * @return float
1408 1408
 	 */
1409
-	public function get_shipping( $context = 'view' ) {
1409
+	public function get_shipping($context = 'view') {
1410 1410
 
1411
-		if ( $context = 'view' ) {
1412
-			return floatval( $this->get_prop( 'shipping', $context ) );
1411
+		if ($context = 'view') {
1412
+			return floatval($this->get_prop('shipping', $context));
1413 1413
 		}
1414 1414
 
1415
-		return $this->get_prop( 'shipping', $context );
1415
+		return $this->get_prop('shipping', $context);
1416 1416
     }
1417 1417
 
1418 1418
 	public function has_shipping() {
1419
-		return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' );
1419
+		return defined('GETPAID_SHIPPING_CALCULATOR_VERSION') && null !== $this->get_prop('shipping', 'edit');
1420 1420
     }
1421 1421
 
1422 1422
     /**
@@ -1426,12 +1426,12 @@  discard block
 block discarded – undo
1426 1426
 	 * @param  string $context View or edit context.
1427 1427
 	 * @return float
1428 1428
 	 */
1429
-	public function get_subtotal( $context = 'view' ) {
1430
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1429
+	public function get_subtotal($context = 'view') {
1430
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1431 1431
 
1432 1432
         // Backwards compatibility.
1433
-        if ( is_bool( $context ) && $context ) {
1434
-            return wpinv_price( $subtotal, $this->get_currency() );
1433
+        if (is_bool($context) && $context) {
1434
+            return wpinv_price($subtotal, $this->get_currency());
1435 1435
         }
1436 1436
 
1437 1437
         return $subtotal;
@@ -1444,8 +1444,8 @@  discard block
 block discarded – undo
1444 1444
 	 * @param  string $context View or edit context.
1445 1445
 	 * @return float
1446 1446
 	 */
1447
-	public function get_total_discount( $context = 'view' ) {
1448
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1447
+	public function get_total_discount($context = 'view') {
1448
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context)));
1449 1449
     }
1450 1450
 
1451 1451
     /**
@@ -1455,18 +1455,18 @@  discard block
 block discarded – undo
1455 1455
 	 * @param  string $context View or edit context.
1456 1456
 	 * @return float
1457 1457
 	 */
1458
-	public function get_total_tax( $context = 'view' ) {
1459
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1458
+	public function get_total_tax($context = 'view') {
1459
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context)));
1460 1460
 	}
1461 1461
 
1462 1462
 	/**
1463 1463
 	 * @deprecated
1464 1464
 	 */
1465
-	public function get_final_tax( $currency = false ) {
1465
+	public function get_final_tax($currency = false) {
1466 1466
 		$tax = $this->get_total_tax();
1467 1467
 
1468
-        if ( $currency ) {
1469
-			return wpinv_price( $tax, $this->get_currency() );
1468
+        if ($currency) {
1469
+			return wpinv_price($tax, $this->get_currency());
1470 1470
         }
1471 1471
 
1472 1472
         return $tax;
@@ -1479,8 +1479,8 @@  discard block
 block discarded – undo
1479 1479
 	 * @param  string $context View or edit context.
1480 1480
 	 * @return float
1481 1481
 	 */
1482
-	public function get_total_fees( $context = 'view' ) {
1483
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1482
+	public function get_total_fees($context = 'view') {
1483
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context)));
1484 1484
     }
1485 1485
 
1486 1486
     /**
@@ -1490,8 +1490,8 @@  discard block
 block discarded – undo
1490 1490
 	 * @param  string $context View or edit context.
1491 1491
 	 * @return float
1492 1492
 	 */
1493
-	public function get_fees_total( $context = 'view' ) {
1494
-		return $this->get_total_fees( $context );
1493
+	public function get_fees_total($context = 'view') {
1494
+		return $this->get_total_fees($context);
1495 1495
     }
1496 1496
 
1497 1497
     /**
@@ -1500,14 +1500,14 @@  discard block
 block discarded – undo
1500 1500
 	 * @since 1.0.19
1501 1501
      * @return float
1502 1502
 	 */
1503
-	public function get_total( $context = 'view' ) {
1504
-		$total = $this->get_prop( 'total', $context );
1503
+	public function get_total($context = 'view') {
1504
+		$total = $this->get_prop('total', $context);
1505 1505
 
1506
-		if ( $this->has_shipping() && $context == 'view' ) {
1507
-			$total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1506
+		if ($this->has_shipping() && $context == 'view') {
1507
+			$total = $this->get_prop('total', $context) + $this->get_shipping($context);
1508 1508
 		}
1509 1509
 
1510
-		return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1510
+		return wpinv_round_amount(wpinv_sanitize_amount($total));
1511 1511
 	}
1512 1512
 
1513 1513
 	/**
@@ -1519,20 +1519,20 @@  discard block
 block discarded – undo
1519 1519
 	public function get_non_recurring_total() {
1520 1520
 
1521 1521
 		$subtotal = 0;
1522
-		foreach ( $this->get_items() as $item ) {
1523
-			if ( ! $item->is_recurring() ) {
1522
+		foreach ($this->get_items() as $item) {
1523
+			if (!$item->is_recurring()) {
1524 1524
 				$subtotal += $item->get_sub_total();
1525 1525
 			}
1526 1526
 		}
1527 1527
 
1528
-		foreach ( $this->get_fees() as $fee ) {
1529
-			if ( empty( $fee['recurring_fee'] ) ) {
1530
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1528
+		foreach ($this->get_fees() as $fee) {
1529
+			if (empty($fee['recurring_fee'])) {
1530
+				$subtotal += wpinv_sanitize_amount($fee['initial_fee']);
1531 1531
 			}
1532 1532
 		}
1533 1533
 
1534
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1535
-        return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1534
+		$subtotal = wpinv_round_amount(wpinv_sanitize_amount($subtotal));
1535
+        return apply_filters('wpinv_get_non_recurring_invoice_total', $subtotal, $this);
1536 1536
 
1537 1537
     }
1538 1538
 
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
 	 */
1556 1556
     public function get_initial_total() {
1557 1557
 
1558
-		if ( empty( $this->totals ) ) {
1558
+		if (empty($this->totals)) {
1559 1559
 			$this->recalculate_total();
1560 1560
 		}
1561 1561
 
@@ -1565,12 +1565,12 @@  discard block
 block discarded – undo
1565 1565
 		$subtotal = $this->totals['subtotal']['initial'];
1566 1566
 		$total    = $tax + $fee - $discount + $subtotal;
1567 1567
 
1568
-		if ( 0 > $total ) {
1568
+		if (0 > $total) {
1569 1569
 			$total = 0;
1570 1570
 		}
1571 1571
 
1572
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1573
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1572
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1573
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1574 1574
 	}
1575 1575
 
1576 1576
 	/**
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
 	 */
1583 1583
     public function get_recurring_total() {
1584 1584
 
1585
-		if ( empty( $this->totals ) ) {
1585
+		if (empty($this->totals)) {
1586 1586
 			$this->recalculate_total();
1587 1587
 		}
1588 1588
 
@@ -1592,12 +1592,12 @@  discard block
 block discarded – undo
1592 1592
 		$subtotal = $this->totals['subtotal']['recurring'];
1593 1593
 		$total    = $tax + $fee - $discount + $subtotal;
1594 1594
 
1595
-		if ( 0 > $total ) {
1595
+		if (0 > $total) {
1596 1596
 			$total = 0;
1597 1597
 		}
1598 1598
 
1599
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1600
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1599
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1600
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1601 1601
 	}
1602 1602
 
1603 1603
 	/**
@@ -1608,10 +1608,10 @@  discard block
 block discarded – undo
1608 1608
 	 * @param string $currency Whether to include the currency.
1609 1609
      * @return float|string
1610 1610
 	 */
1611
-    public function get_recurring_details( $field = '', $currency = false ) {
1611
+    public function get_recurring_details($field = '', $currency = false) {
1612 1612
 
1613 1613
 		// Maybe recalculate totals.
1614
-		if ( empty( $this->totals ) ) {
1614
+		if (empty($this->totals)) {
1615 1615
 			$this->recalculate_total();
1616 1616
 		}
1617 1617
 
@@ -1631,8 +1631,8 @@  discard block
 block discarded – undo
1631 1631
 			$currency
1632 1632
 		);
1633 1633
 
1634
-        if ( isset( $data[ $field ] ) ) {
1635
-            return ( $currency ? wpinv_price( $data[ $field ], $this->get_currency() ) : $data[ $field ] );
1634
+        if (isset($data[$field])) {
1635
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1636 1636
         }
1637 1637
 
1638 1638
         return $data;
@@ -1645,8 +1645,8 @@  discard block
 block discarded – undo
1645 1645
 	 * @param  string $context View or edit context.
1646 1646
 	 * @return array
1647 1647
 	 */
1648
-	public function get_fees( $context = 'view' ) {
1649
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1648
+	public function get_fees($context = 'view') {
1649
+		return wpinv_parse_list($this->get_prop('fees', $context));
1650 1650
     }
1651 1651
 
1652 1652
     /**
@@ -1656,8 +1656,8 @@  discard block
 block discarded – undo
1656 1656
 	 * @param  string $context View or edit context.
1657 1657
 	 * @return array
1658 1658
 	 */
1659
-	public function get_discounts( $context = 'view' ) {
1660
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1659
+	public function get_discounts($context = 'view') {
1660
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1661 1661
     }
1662 1662
 
1663 1663
     /**
@@ -1667,8 +1667,8 @@  discard block
 block discarded – undo
1667 1667
 	 * @param  string $context View or edit context.
1668 1668
 	 * @return array
1669 1669
 	 */
1670
-	public function get_taxes( $context = 'view' ) {
1671
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1670
+	public function get_taxes($context = 'view') {
1671
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1672 1672
     }
1673 1673
 
1674 1674
     /**
@@ -1678,8 +1678,8 @@  discard block
 block discarded – undo
1678 1678
 	 * @param  string $context View or edit context.
1679 1679
 	 * @return GetPaid_Form_Item[]
1680 1680
 	 */
1681
-	public function get_items( $context = 'view' ) {
1682
-        return $this->get_prop( 'items', $context );
1681
+	public function get_items($context = 'view') {
1682
+        return $this->get_prop('items', $context);
1683 1683
 	}
1684 1684
 
1685 1685
 	/**
@@ -1689,7 +1689,7 @@  discard block
 block discarded – undo
1689 1689
 	 * @return string
1690 1690
 	 */
1691 1691
 	public function get_item_ids() {
1692
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1692
+		return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id'));
1693 1693
     }
1694 1694
 
1695 1695
     /**
@@ -1699,8 +1699,8 @@  discard block
 block discarded – undo
1699 1699
 	 * @param  string $context View or edit context.
1700 1700
 	 * @return int
1701 1701
 	 */
1702
-	public function get_payment_form( $context = 'view' ) {
1703
-		return intval( $this->get_prop( 'payment_form', $context ) );
1702
+	public function get_payment_form($context = 'view') {
1703
+		return intval($this->get_prop('payment_form', $context));
1704 1704
     }
1705 1705
 
1706 1706
     /**
@@ -1710,8 +1710,8 @@  discard block
 block discarded – undo
1710 1710
 	 * @param  string $context View or edit context.
1711 1711
 	 * @return string
1712 1712
 	 */
1713
-	public function get_submission_id( $context = 'view' ) {
1714
-		return $this->get_prop( 'submission_id', $context );
1713
+	public function get_submission_id($context = 'view') {
1714
+		return $this->get_prop('submission_id', $context);
1715 1715
     }
1716 1716
 
1717 1717
     /**
@@ -1721,8 +1721,8 @@  discard block
 block discarded – undo
1721 1721
 	 * @param  string $context View or edit context.
1722 1722
 	 * @return string
1723 1723
 	 */
1724
-	public function get_discount_code( $context = 'view' ) {
1725
-		return $this->get_prop( 'discount_code', $context );
1724
+	public function get_discount_code($context = 'view') {
1725
+		return $this->get_prop('discount_code', $context);
1726 1726
     }
1727 1727
 
1728 1728
     /**
@@ -1732,8 +1732,8 @@  discard block
 block discarded – undo
1732 1732
 	 * @param  string $context View or edit context.
1733 1733
 	 * @return string
1734 1734
 	 */
1735
-	public function get_gateway( $context = 'view' ) {
1736
-		return $this->get_prop( 'gateway', $context );
1735
+	public function get_gateway($context = 'view') {
1736
+		return $this->get_prop('gateway', $context);
1737 1737
     }
1738 1738
 
1739 1739
     /**
@@ -1743,8 +1743,8 @@  discard block
 block discarded – undo
1743 1743
 	 * @return string
1744 1744
 	 */
1745 1745
     public function get_gateway_title() {
1746
-        $title = wpinv_get_gateway_checkout_label( $this->get_gateway() );
1747
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1746
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1747
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1748 1748
     }
1749 1749
 
1750 1750
     /**
@@ -1754,8 +1754,8 @@  discard block
 block discarded – undo
1754 1754
 	 * @param  string $context View or edit context.
1755 1755
 	 * @return string
1756 1756
 	 */
1757
-	public function get_transaction_id( $context = 'view' ) {
1758
-		return $this->get_prop( 'transaction_id', $context );
1757
+	public function get_transaction_id($context = 'view') {
1758
+		return $this->get_prop('transaction_id', $context);
1759 1759
     }
1760 1760
 
1761 1761
     /**
@@ -1765,9 +1765,9 @@  discard block
 block discarded – undo
1765 1765
 	 * @param  string $context View or edit context.
1766 1766
 	 * @return string
1767 1767
 	 */
1768
-	public function get_currency( $context = 'view' ) {
1769
-        $currency = $this->get_prop( 'currency', $context );
1770
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1768
+	public function get_currency($context = 'view') {
1769
+        $currency = $this->get_prop('currency', $context);
1770
+        return empty($currency) ? wpinv_get_currency() : $currency;
1771 1771
     }
1772 1772
 
1773 1773
     /**
@@ -1777,8 +1777,8 @@  discard block
 block discarded – undo
1777 1777
 	 * @param  string $context View or edit context.
1778 1778
 	 * @return bool
1779 1779
 	 */
1780
-	public function get_disable_taxes( $context = 'view' ) {
1781
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1780
+	public function get_disable_taxes($context = 'view') {
1781
+        return (bool) $this->get_prop('disable_taxes', $context);
1782 1782
     }
1783 1783
 
1784 1784
     /**
@@ -1788,8 +1788,8 @@  discard block
 block discarded – undo
1788 1788
 	 * @param  string $context View or edit context.
1789 1789
 	 * @return int
1790 1790
 	 */
1791
-    public function get_subscription_id( $context = 'view' ) {
1792
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1791
+    public function get_subscription_id($context = 'view') {
1792
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1793 1793
 	}
1794 1794
 
1795 1795
 	/**
@@ -1799,12 +1799,12 @@  discard block
 block discarded – undo
1799 1799
 	 * @param  string $context View or edit context.
1800 1800
 	 * @return int
1801 1801
 	 */
1802
-    public function get_remote_subscription_id( $context = 'view' ) {
1803
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1802
+    public function get_remote_subscription_id($context = 'view') {
1803
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1804 1804
 
1805
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1805
+        if (empty($subscription_id) && $this->is_renewal()) {
1806 1806
             $parent = $this->get_parent();
1807
-            return $parent->get_remote_subscription_id( $context );
1807
+            return $parent->get_remote_subscription_id($context);
1808 1808
         }
1809 1809
 
1810 1810
         return $subscription_id;
@@ -1817,20 +1817,20 @@  discard block
 block discarded – undo
1817 1817
 	 * @param  string $context View or edit context.
1818 1818
 	 * @return array
1819 1819
 	 */
1820
-    public function get_payment_meta( $context = 'view' ) {
1820
+    public function get_payment_meta($context = 'view') {
1821 1821
 
1822 1822
         return array(
1823
-            'price'        => $this->get_total( $context ),
1824
-            'date'         => $this->get_date_created( $context ),
1825
-            'user_email'   => $this->get_email( $context ),
1826
-            'invoice_key'  => $this->get_key( $context ),
1827
-            'currency'     => $this->get_currency( $context ),
1828
-            'items'        => $this->get_items( $context ),
1829
-            'user_info'    => $this->get_user_info( $context ),
1823
+            'price'        => $this->get_total($context),
1824
+            'date'         => $this->get_date_created($context),
1825
+            'user_email'   => $this->get_email($context),
1826
+            'invoice_key'  => $this->get_key($context),
1827
+            'currency'     => $this->get_currency($context),
1828
+            'items'        => $this->get_items($context),
1829
+            'user_info'    => $this->get_user_info($context),
1830 1830
             'cart_details' => $this->get_cart_details(),
1831
-            'status'       => $this->get_status( $context ),
1832
-            'fees'         => $this->get_fees( $context ),
1833
-            'taxes'        => $this->get_taxes( $context ),
1831
+            'status'       => $this->get_status($context),
1832
+            'fees'         => $this->get_fees($context),
1833
+            'taxes'        => $this->get_taxes($context),
1834 1834
         );
1835 1835
 
1836 1836
     }
@@ -1845,9 +1845,9 @@  discard block
 block discarded – undo
1845 1845
         $items        = $this->get_items();
1846 1846
         $cart_details = array();
1847 1847
 
1848
-        foreach ( $items as $item ) {
1848
+        foreach ($items as $item) {
1849 1849
 			$item->invoice_id = $this->get_id();
1850
-            $cart_details[]   = $item->prepare_data_for_saving();
1850
+            $cart_details[] = $item->prepare_data_for_saving();
1851 1851
         }
1852 1852
 
1853 1853
         return $cart_details;
@@ -1858,11 +1858,11 @@  discard block
 block discarded – undo
1858 1858
 	 *
1859 1859
 	 * @return null|GetPaid_Form_Item|int
1860 1860
 	 */
1861
-	public function get_recurring( $object = false ) {
1861
+	public function get_recurring($object = false) {
1862 1862
 
1863 1863
 		// Are we returning an object?
1864
-        if ( $object ) {
1865
-            return $this->get_item( $this->recurring_item );
1864
+        if ($object) {
1865
+            return $this->get_item($this->recurring_item);
1866 1866
         }
1867 1867
 
1868 1868
         return $this->recurring_item;
@@ -1877,15 +1877,15 @@  discard block
 block discarded – undo
1877 1877
 	public function get_subscription_name() {
1878 1878
 
1879 1879
 		// Retrieve the recurring name
1880
-        $item = $this->get_recurring( true );
1880
+        $item = $this->get_recurring(true);
1881 1881
 
1882 1882
 		// Abort if it does not exist.
1883
-        if ( empty( $item ) ) {
1883
+        if (empty($item)) {
1884 1884
             return '';
1885 1885
         }
1886 1886
 
1887 1887
 		// Return the item name.
1888
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1888
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1889 1889
 	}
1890 1890
 
1891 1891
 	/**
@@ -1895,9 +1895,9 @@  discard block
 block discarded – undo
1895 1895
 	 * @return string
1896 1896
 	 */
1897 1897
 	public function get_view_url() {
1898
-        $invoice_url = get_permalink( $this->get_id() );
1899
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1900
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1898
+        $invoice_url = get_permalink($this->get_id());
1899
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1900
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1901 1901
 	}
1902 1902
 
1903 1903
 	/**
@@ -1906,25 +1906,25 @@  discard block
 block discarded – undo
1906 1906
 	 * @since 1.0.19
1907 1907
 	 * @return string
1908 1908
 	 */
1909
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1909
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1910 1910
 
1911 1911
 		// Retrieve the checkout url.
1912 1912
         $pay_url = wpinv_get_checkout_uri();
1913 1913
 
1914 1914
 		// Maybe force ssl.
1915
-        if ( is_ssl() ) {
1916
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1915
+        if (is_ssl()) {
1916
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1917 1917
         }
1918 1918
 
1919 1919
 		// Add the invoice key.
1920
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1920
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1921 1921
 
1922 1922
 		// (Maybe?) add a secret
1923
-        if ( $secret ) {
1924
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1923
+        if ($secret) {
1924
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1925 1925
         }
1926 1926
 
1927
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1927
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1928 1928
 	}
1929 1929
 
1930 1930
 	/**
@@ -1939,14 +1939,14 @@  discard block
 block discarded – undo
1939 1939
         $receipt_url = wpinv_get_success_page_uri();
1940 1940
 
1941 1941
 		// Maybe force ssl.
1942
-        if ( is_ssl() ) {
1943
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1942
+        if (is_ssl()) {
1943
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1944 1944
         }
1945 1945
 
1946 1946
 		// Add the invoice key.
1947
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1947
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1948 1948
 
1949
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1949
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1950 1950
 	}
1951 1951
 
1952 1952
 	/**
@@ -1956,7 +1956,7 @@  discard block
 block discarded – undo
1956 1956
 	 * @return string
1957 1957
 	 */
1958 1958
 	public function get_transaction_url() {
1959
-		return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1959
+		return apply_filters('getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this);
1960 1960
 	}
1961 1961
 
1962 1962
 	/**
@@ -1969,7 +1969,7 @@  discard block
 block discarded – undo
1969 1969
 
1970 1970
 		$type   = $this->get_type();
1971 1971
 		$status = "wpi-$type-pending";
1972
-		return str_replace( '-invoice', '', $status );
1972
+		return str_replace('-invoice', '', $status);
1973 1973
 
1974 1974
 	}
1975 1975
 
@@ -1983,14 +1983,14 @@  discard block
 block discarded – undo
1983 1983
 	 * @param  string $context View or edit context.
1984 1984
 	 * @return mixed Value of the given invoice property (if set).
1985 1985
 	 */
1986
-	public function get( $key, $context = 'view' ) {
1986
+	public function get($key, $context = 'view') {
1987 1987
 		$method = "get_$key";
1988 1988
 
1989
-		if ( is_callable( array( $this, $method ) ) ) {
1990
-			return $this->$method( $context );
1989
+		if (is_callable(array($this, $method))) {
1990
+			return $this->$method($context);
1991 1991
 		}
1992 1992
 
1993
-        return $this->get_prop( $key, $context );
1993
+        return $this->get_prop($key, $context);
1994 1994
 	}
1995 1995
 
1996 1996
     /*
@@ -2013,11 +2013,11 @@  discard block
 block discarded – undo
2013 2013
 	 * @param  mixed $value new value.
2014 2014
 	 * @return mixed Value of the given invoice property (if set).
2015 2015
 	 */
2016
-	public function set( $key, $value ) {
2016
+	public function set($key, $value) {
2017 2017
 
2018 2018
         $setter = "set_$key";
2019
-        if ( is_callable( array( $this, $setter ) ) ) {
2020
-            $this->{$setter}( $value );
2019
+        if (is_callable(array($this, $setter))) {
2020
+            $this->{$setter}($value);
2021 2021
         }
2022 2022
 
2023 2023
 	}
@@ -2031,45 +2031,45 @@  discard block
 block discarded – undo
2031 2031
 	 * @param bool   $manual_update Is this a manual status change?.
2032 2032
 	 * @return array details of change.
2033 2033
 	 */
2034
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
2034
+	public function set_status($new_status, $note = '', $manual_update = false) {
2035 2035
 		$old_status = $this->get_status();
2036 2036
 
2037 2037
 		$statuses = $this->get_all_statuses();
2038 2038
 
2039
-		if ( isset( $statuses['draft'] ) ) {
2040
-			unset( $statuses['draft'] );
2039
+		if (isset($statuses['draft'])) {
2040
+			unset($statuses['draft']);
2041 2041
 		}
2042 2042
 
2043
-		$this->set_prop( 'status', $new_status );
2043
+		$this->set_prop('status', $new_status);
2044 2044
 
2045 2045
 		// If setting the status, ensure it's set to a valid status.
2046
-		if ( true === $this->object_read ) {
2046
+		if (true === $this->object_read) {
2047 2047
 
2048 2048
 			// Only allow valid new status.
2049
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
2049
+			if (!array_key_exists($new_status, $statuses)) {
2050 2050
 				$new_status = $this->get_default_status();
2051 2051
 			}
2052 2052
 
2053 2053
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2054
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2054
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
2055 2055
 				$old_status = $this->get_default_status();
2056 2056
 			}
2057 2057
 
2058 2058
 			// Paid - Renewal (i.e when duplicating a parent invoice )
2059
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2059
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
2060 2060
 				$old_status = 'wpi-pending';
2061 2061
 			}
2062 2062
 
2063
-			if ( $old_status !== $new_status ) {
2063
+			if ($old_status !== $new_status) {
2064 2064
 				$this->status_transition = array(
2065
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2065
+					'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
2066 2066
 					'to'     => $new_status,
2067 2067
 					'note'   => $note,
2068 2068
 					'manual' => (bool) $manual_update,
2069 2069
 				);
2070 2070
 
2071
-				if ( $manual_update ) {
2072
-					do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status );
2071
+				if ($manual_update) {
2072
+					do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
2073 2073
 				}
2074 2074
 
2075 2075
 				$this->maybe_set_date_paid();
@@ -2093,8 +2093,8 @@  discard block
 block discarded – undo
2093 2093
 	 */
2094 2094
 	public function maybe_set_date_paid() {
2095 2095
 
2096
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2097
-			$this->set_date_completed( current_time( 'mysql' ) );
2096
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
2097
+			$this->set_date_completed(current_time('mysql'));
2098 2098
 		}
2099 2099
 	}
2100 2100
 
@@ -2103,11 +2103,11 @@  discard block
 block discarded – undo
2103 2103
 	 *
2104 2104
 	 * @since 1.0.19
2105 2105
 	 */
2106
-	public function set_parent_id( $value ) {
2107
-		if ( $value && ( $value === $this->get_id() ) ) {
2106
+	public function set_parent_id($value) {
2107
+		if ($value && ($value === $this->get_id())) {
2108 2108
 			return;
2109 2109
 		}
2110
-		$this->set_prop( 'parent_id', absint( $value ) );
2110
+		$this->set_prop('parent_id', absint($value));
2111 2111
     }
2112 2112
 
2113 2113
     /**
@@ -2115,8 +2115,8 @@  discard block
 block discarded – undo
2115 2115
 	 *
2116 2116
 	 * @since 1.0.19
2117 2117
 	 */
2118
-	public function set_version( $value ) {
2119
-		$this->set_prop( 'version', $value );
2118
+	public function set_version($value) {
2119
+		$this->set_prop('version', $value);
2120 2120
     }
2121 2121
 
2122 2122
     /**
@@ -2126,15 +2126,15 @@  discard block
 block discarded – undo
2126 2126
 	 * @param string $value Value to set.
2127 2127
      * @return bool Whether or not the date was set.
2128 2128
 	 */
2129
-	public function set_date_created( $value ) {
2130
-        $date = strtotime( $value );
2129
+	public function set_date_created($value) {
2130
+        $date = strtotime($value);
2131 2131
 
2132
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2133
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
2132
+        if ($date && $value !== '0000-00-00 00:00:00') {
2133
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
2134 2134
             return true;
2135 2135
         }
2136 2136
 
2137
-		$this->set_prop( 'date_created', '' );
2137
+		$this->set_prop('date_created', '');
2138 2138
 		return false;
2139 2139
 
2140 2140
     }
@@ -2146,15 +2146,15 @@  discard block
 block discarded – undo
2146 2146
 	 * @param string $value Value to set.
2147 2147
      * @return bool Whether or not the date was set.
2148 2148
 	 */
2149
-	public function set_due_date( $value ) {
2150
-        $date = strtotime( $value );
2149
+	public function set_due_date($value) {
2150
+        $date = strtotime($value);
2151 2151
 
2152
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2153
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
2152
+        if ($date && $value !== '0000-00-00 00:00:00') {
2153
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
2154 2154
             return true;
2155 2155
         }
2156 2156
 
2157
-		$this->set_prop( 'due_date', '' );
2157
+		$this->set_prop('due_date', '');
2158 2158
         return false;
2159 2159
 
2160 2160
     }
@@ -2165,8 +2165,8 @@  discard block
 block discarded – undo
2165 2165
 	 * @since 1.0.19
2166 2166
 	 * @param  string $value New name.
2167 2167
 	 */
2168
-	public function set_date_due( $value ) {
2169
-		$this->set_due_date( $value );
2168
+	public function set_date_due($value) {
2169
+		$this->set_due_date($value);
2170 2170
     }
2171 2171
 
2172 2172
     /**
@@ -2176,15 +2176,15 @@  discard block
 block discarded – undo
2176 2176
 	 * @param string $value Value to set.
2177 2177
      * @return bool Whether or not the date was set.
2178 2178
 	 */
2179
-	public function set_completed_date( $value ) {
2180
-        $date = strtotime( $value );
2179
+	public function set_completed_date($value) {
2180
+        $date = strtotime($value);
2181 2181
 
2182
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2183
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2182
+        if ($date && $value !== '0000-00-00 00:00:00') {
2183
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2184 2184
             return true;
2185 2185
         }
2186 2186
 
2187
-		$this->set_prop( 'completed_date', '' );
2187
+		$this->set_prop('completed_date', '');
2188 2188
         return false;
2189 2189
 
2190 2190
     }
@@ -2195,8 +2195,8 @@  discard block
 block discarded – undo
2195 2195
 	 * @since 1.0.19
2196 2196
 	 * @param  string $value New name.
2197 2197
 	 */
2198
-	public function set_date_completed( $value ) {
2199
-		$this->set_completed_date( $value );
2198
+	public function set_date_completed($value) {
2199
+		$this->set_completed_date($value);
2200 2200
     }
2201 2201
 
2202 2202
     /**
@@ -2206,15 +2206,15 @@  discard block
 block discarded – undo
2206 2206
 	 * @param string $value Value to set.
2207 2207
      * @return bool Whether or not the date was set.
2208 2208
 	 */
2209
-	public function set_date_modified( $value ) {
2210
-        $date = strtotime( $value );
2209
+	public function set_date_modified($value) {
2210
+        $date = strtotime($value);
2211 2211
 
2212
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2213
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2212
+        if ($date && $value !== '0000-00-00 00:00:00') {
2213
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2214 2214
             return true;
2215 2215
         }
2216 2216
 
2217
-		$this->set_prop( 'date_modified', '' );
2217
+		$this->set_prop('date_modified', '');
2218 2218
         return false;
2219 2219
 
2220 2220
     }
@@ -2225,9 +2225,9 @@  discard block
 block discarded – undo
2225 2225
 	 * @since 1.0.19
2226 2226
 	 * @param  string $value New number.
2227 2227
 	 */
2228
-	public function set_number( $value ) {
2229
-        $number = sanitize_text_field( $value );
2230
-		$this->set_prop( 'number', $number );
2228
+	public function set_number($value) {
2229
+        $number = sanitize_text_field($value);
2230
+		$this->set_prop('number', $number);
2231 2231
     }
2232 2232
 
2233 2233
     /**
@@ -2236,9 +2236,9 @@  discard block
 block discarded – undo
2236 2236
 	 * @since 1.0.19
2237 2237
 	 * @param  string $value Type.
2238 2238
 	 */
2239
-	public function set_type( $value ) {
2240
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2241
-		$this->set_prop( 'type', $type );
2239
+	public function set_type($value) {
2240
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2241
+		$this->set_prop('type', $type);
2242 2242
 	}
2243 2243
 
2244 2244
     /**
@@ -2247,10 +2247,10 @@  discard block
 block discarded – undo
2247 2247
 	 * @since 1.0.19
2248 2248
 	 * @param  string $value Post type.
2249 2249
 	 */
2250
-	public function set_post_type( $value ) {
2251
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2252
-			$this->set_type( $value );
2253
-            $this->set_prop( 'post_type', $value );
2250
+	public function set_post_type($value) {
2251
+        if (getpaid_is_invoice_post_type($value)) {
2252
+			$this->set_type($value);
2253
+            $this->set_prop('post_type', $value);
2254 2254
         }
2255 2255
     }
2256 2256
 
@@ -2260,9 +2260,9 @@  discard block
 block discarded – undo
2260 2260
 	 * @since 1.0.19
2261 2261
 	 * @param  string $value New key.
2262 2262
 	 */
2263
-	public function set_key( $value ) {
2264
-        $key = sanitize_text_field( $value );
2265
-		$this->set_prop( 'key', $key );
2263
+	public function set_key($value) {
2264
+        $key = sanitize_text_field($value);
2265
+		$this->set_prop('key', $key);
2266 2266
     }
2267 2267
 
2268 2268
     /**
@@ -2271,9 +2271,9 @@  discard block
 block discarded – undo
2271 2271
 	 * @since 1.0.19
2272 2272
 	 * @param  string $value mode.
2273 2273
 	 */
2274
-	public function set_mode( $value ) {
2275
-        if ( in_array( $value, array( 'live', 'test' ) ) ) {
2276
-            $this->set_prop( 'mode', $value );
2274
+	public function set_mode($value) {
2275
+        if (in_array($value, array('live', 'test'))) {
2276
+            $this->set_prop('mode', $value);
2277 2277
         }
2278 2278
     }
2279 2279
 
@@ -2283,8 +2283,8 @@  discard block
 block discarded – undo
2283 2283
 	 * @since 1.0.19
2284 2284
 	 * @param  string $value path.
2285 2285
 	 */
2286
-	public function set_path( $value ) {
2287
-        $this->set_prop( 'path', $value );
2286
+	public function set_path($value) {
2287
+        $this->set_prop('path', $value);
2288 2288
     }
2289 2289
 
2290 2290
     /**
@@ -2293,9 +2293,9 @@  discard block
 block discarded – undo
2293 2293
 	 * @since 1.0.19
2294 2294
 	 * @param  string $value New name.
2295 2295
 	 */
2296
-	public function set_name( $value ) {
2297
-        $name = sanitize_text_field( $value );
2298
-		$this->set_prop( 'name', $name );
2296
+	public function set_name($value) {
2297
+        $name = sanitize_text_field($value);
2298
+		$this->set_prop('name', $name);
2299 2299
     }
2300 2300
 
2301 2301
     /**
@@ -2304,8 +2304,8 @@  discard block
 block discarded – undo
2304 2304
 	 * @since 1.0.19
2305 2305
 	 * @param  string $value New name.
2306 2306
 	 */
2307
-	public function set_title( $value ) {
2308
-		$this->set_name( $value );
2307
+	public function set_title($value) {
2308
+		$this->set_name($value);
2309 2309
     }
2310 2310
 
2311 2311
     /**
@@ -2314,9 +2314,9 @@  discard block
 block discarded – undo
2314 2314
 	 * @since 1.0.19
2315 2315
 	 * @param  string $value New description.
2316 2316
 	 */
2317
-	public function set_description( $value ) {
2318
-        $description = wp_kses_post( $value );
2319
-		$this->set_prop( 'description', $description );
2317
+	public function set_description($value) {
2318
+        $description = wp_kses_post($value);
2319
+		$this->set_prop('description', $description);
2320 2320
     }
2321 2321
 
2322 2322
     /**
@@ -2325,8 +2325,8 @@  discard block
 block discarded – undo
2325 2325
 	 * @since 1.0.19
2326 2326
 	 * @param  string $value New description.
2327 2327
 	 */
2328
-	public function set_excerpt( $value ) {
2329
-		$this->set_description( $value );
2328
+	public function set_excerpt($value) {
2329
+		$this->set_description($value);
2330 2330
     }
2331 2331
 
2332 2332
     /**
@@ -2335,8 +2335,8 @@  discard block
 block discarded – undo
2335 2335
 	 * @since 1.0.19
2336 2336
 	 * @param  string $value New description.
2337 2337
 	 */
2338
-	public function set_summary( $value ) {
2339
-		$this->set_description( $value );
2338
+	public function set_summary($value) {
2339
+		$this->set_description($value);
2340 2340
     }
2341 2341
 
2342 2342
     /**
@@ -2345,12 +2345,12 @@  discard block
 block discarded – undo
2345 2345
 	 * @since 1.0.19
2346 2346
 	 * @param  int $value New author.
2347 2347
 	 */
2348
-	public function set_author( $value ) {
2349
-		$user = get_user_by( 'id', (int) $value );
2348
+	public function set_author($value) {
2349
+		$user = get_user_by('id', (int) $value);
2350 2350
 
2351
-		if ( $user && $user->ID ) {
2352
-			$this->set_prop( 'author', $user->ID );
2353
-			$this->set_prop( 'email', $user->user_email );
2351
+		if ($user && $user->ID) {
2352
+			$this->set_prop('author', $user->ID);
2353
+			$this->set_prop('email', $user->user_email);
2354 2354
 		}
2355 2355
 
2356 2356
     }
@@ -2361,8 +2361,8 @@  discard block
 block discarded – undo
2361 2361
 	 * @since 1.0.19
2362 2362
 	 * @param  int $value New user id.
2363 2363
 	 */
2364
-	public function set_user_id( $value ) {
2365
-		$this->set_author( $value );
2364
+	public function set_user_id($value) {
2365
+		$this->set_author($value);
2366 2366
     }
2367 2367
 
2368 2368
     /**
@@ -2371,8 +2371,8 @@  discard block
 block discarded – undo
2371 2371
 	 * @since 1.0.19
2372 2372
 	 * @param  int $value New user id.
2373 2373
 	 */
2374
-	public function set_customer_id( $value ) {
2375
-		$this->set_author( $value );
2374
+	public function set_customer_id($value) {
2375
+		$this->set_author($value);
2376 2376
     }
2377 2377
 
2378 2378
     /**
@@ -2381,8 +2381,8 @@  discard block
 block discarded – undo
2381 2381
 	 * @since 1.0.19
2382 2382
 	 * @param  string $value ip address.
2383 2383
 	 */
2384
-	public function set_ip( $value ) {
2385
-		$this->set_prop( 'ip', $value );
2384
+	public function set_ip($value) {
2385
+		$this->set_prop('ip', $value);
2386 2386
     }
2387 2387
 
2388 2388
     /**
@@ -2391,8 +2391,8 @@  discard block
 block discarded – undo
2391 2391
 	 * @since 1.0.19
2392 2392
 	 * @param  string $value ip address.
2393 2393
 	 */
2394
-	public function set_user_ip( $value ) {
2395
-		$this->set_ip( $value );
2394
+	public function set_user_ip($value) {
2395
+		$this->set_ip($value);
2396 2396
     }
2397 2397
 
2398 2398
     /**
@@ -2401,8 +2401,8 @@  discard block
 block discarded – undo
2401 2401
 	 * @since 1.0.19
2402 2402
 	 * @param  string $value first name.
2403 2403
 	 */
2404
-	public function set_first_name( $value ) {
2405
-		$this->set_prop( 'first_name', $value );
2404
+	public function set_first_name($value) {
2405
+		$this->set_prop('first_name', $value);
2406 2406
     }
2407 2407
 
2408 2408
     /**
@@ -2411,8 +2411,8 @@  discard block
 block discarded – undo
2411 2411
 	 * @since 1.0.19
2412 2412
 	 * @param  string $value first name.
2413 2413
 	 */
2414
-	public function set_user_first_name( $value ) {
2415
-		$this->set_first_name( $value );
2414
+	public function set_user_first_name($value) {
2415
+		$this->set_first_name($value);
2416 2416
     }
2417 2417
 
2418 2418
     /**
@@ -2421,8 +2421,8 @@  discard block
 block discarded – undo
2421 2421
 	 * @since 1.0.19
2422 2422
 	 * @param  string $value first name.
2423 2423
 	 */
2424
-	public function set_customer_first_name( $value ) {
2425
-		$this->set_first_name( $value );
2424
+	public function set_customer_first_name($value) {
2425
+		$this->set_first_name($value);
2426 2426
     }
2427 2427
 
2428 2428
     /**
@@ -2431,8 +2431,8 @@  discard block
 block discarded – undo
2431 2431
 	 * @since 1.0.19
2432 2432
 	 * @param  string $value last name.
2433 2433
 	 */
2434
-	public function set_last_name( $value ) {
2435
-		$this->set_prop( 'last_name', $value );
2434
+	public function set_last_name($value) {
2435
+		$this->set_prop('last_name', $value);
2436 2436
     }
2437 2437
 
2438 2438
     /**
@@ -2441,8 +2441,8 @@  discard block
 block discarded – undo
2441 2441
 	 * @since 1.0.19
2442 2442
 	 * @param  string $value last name.
2443 2443
 	 */
2444
-	public function set_user_last_name( $value ) {
2445
-		$this->set_last_name( $value );
2444
+	public function set_user_last_name($value) {
2445
+		$this->set_last_name($value);
2446 2446
     }
2447 2447
 
2448 2448
     /**
@@ -2451,8 +2451,8 @@  discard block
 block discarded – undo
2451 2451
 	 * @since 1.0.19
2452 2452
 	 * @param  string $value last name.
2453 2453
 	 */
2454
-	public function set_customer_last_name( $value ) {
2455
-		$this->set_last_name( $value );
2454
+	public function set_customer_last_name($value) {
2455
+		$this->set_last_name($value);
2456 2456
     }
2457 2457
 
2458 2458
     /**
@@ -2461,8 +2461,8 @@  discard block
 block discarded – undo
2461 2461
 	 * @since 1.0.19
2462 2462
 	 * @param  string $value phone.
2463 2463
 	 */
2464
-	public function set_phone( $value ) {
2465
-		$this->set_prop( 'phone', $value );
2464
+	public function set_phone($value) {
2465
+		$this->set_prop('phone', $value);
2466 2466
     }
2467 2467
 
2468 2468
     /**
@@ -2471,8 +2471,8 @@  discard block
 block discarded – undo
2471 2471
 	 * @since 1.0.19
2472 2472
 	 * @param  string $value phone.
2473 2473
 	 */
2474
-	public function set_user_phone( $value ) {
2475
-		$this->set_phone( $value );
2474
+	public function set_user_phone($value) {
2475
+		$this->set_phone($value);
2476 2476
     }
2477 2477
 
2478 2478
     /**
@@ -2481,8 +2481,8 @@  discard block
 block discarded – undo
2481 2481
 	 * @since 1.0.19
2482 2482
 	 * @param  string $value phone.
2483 2483
 	 */
2484
-	public function set_customer_phone( $value ) {
2485
-		$this->set_phone( $value );
2484
+	public function set_customer_phone($value) {
2485
+		$this->set_phone($value);
2486 2486
     }
2487 2487
 
2488 2488
     /**
@@ -2491,8 +2491,8 @@  discard block
 block discarded – undo
2491 2491
 	 * @since 1.0.19
2492 2492
 	 * @param  string $value phone.
2493 2493
 	 */
2494
-	public function set_phone_number( $value ) {
2495
-		$this->set_phone( $value );
2494
+	public function set_phone_number($value) {
2495
+		$this->set_phone($value);
2496 2496
     }
2497 2497
 
2498 2498
     /**
@@ -2501,8 +2501,8 @@  discard block
 block discarded – undo
2501 2501
 	 * @since 1.0.19
2502 2502
 	 * @param  string $value email address.
2503 2503
 	 */
2504
-	public function set_email( $value ) {
2505
-		$this->set_prop( 'email', $value );
2504
+	public function set_email($value) {
2505
+		$this->set_prop('email', $value);
2506 2506
     }
2507 2507
 
2508 2508
     /**
@@ -2511,8 +2511,8 @@  discard block
 block discarded – undo
2511 2511
 	 * @since 1.0.19
2512 2512
 	 * @param  string $value email address.
2513 2513
 	 */
2514
-	public function set_user_email( $value ) {
2515
-		$this->set_email( $value );
2514
+	public function set_user_email($value) {
2515
+		$this->set_email($value);
2516 2516
     }
2517 2517
 
2518 2518
     /**
@@ -2521,8 +2521,8 @@  discard block
 block discarded – undo
2521 2521
 	 * @since 1.0.19
2522 2522
 	 * @param  string $value email address.
2523 2523
 	 */
2524
-	public function set_email_address( $value ) {
2525
-		$this->set_email( $value );
2524
+	public function set_email_address($value) {
2525
+		$this->set_email($value);
2526 2526
     }
2527 2527
 
2528 2528
     /**
@@ -2531,8 +2531,8 @@  discard block
 block discarded – undo
2531 2531
 	 * @since 1.0.19
2532 2532
 	 * @param  string $value email address.
2533 2533
 	 */
2534
-	public function set_customer_email( $value ) {
2535
-		$this->set_email( $value );
2534
+	public function set_customer_email($value) {
2535
+		$this->set_email($value);
2536 2536
     }
2537 2537
 
2538 2538
     /**
@@ -2541,8 +2541,8 @@  discard block
 block discarded – undo
2541 2541
 	 * @since 1.0.19
2542 2542
 	 * @param  string $value country.
2543 2543
 	 */
2544
-	public function set_country( $value ) {
2545
-		$this->set_prop( 'country', $value );
2544
+	public function set_country($value) {
2545
+		$this->set_prop('country', $value);
2546 2546
     }
2547 2547
 
2548 2548
     /**
@@ -2551,8 +2551,8 @@  discard block
 block discarded – undo
2551 2551
 	 * @since 1.0.19
2552 2552
 	 * @param  string $value country.
2553 2553
 	 */
2554
-	public function set_user_country( $value ) {
2555
-		$this->set_country( $value );
2554
+	public function set_user_country($value) {
2555
+		$this->set_country($value);
2556 2556
     }
2557 2557
 
2558 2558
     /**
@@ -2561,8 +2561,8 @@  discard block
 block discarded – undo
2561 2561
 	 * @since 1.0.19
2562 2562
 	 * @param  string $value country.
2563 2563
 	 */
2564
-	public function set_customer_country( $value ) {
2565
-		$this->set_country( $value );
2564
+	public function set_customer_country($value) {
2565
+		$this->set_country($value);
2566 2566
     }
2567 2567
 
2568 2568
     /**
@@ -2571,8 +2571,8 @@  discard block
 block discarded – undo
2571 2571
 	 * @since 1.0.19
2572 2572
 	 * @param  string $value state.
2573 2573
 	 */
2574
-	public function set_state( $value ) {
2575
-		$this->set_prop( 'state', $value );
2574
+	public function set_state($value) {
2575
+		$this->set_prop('state', $value);
2576 2576
     }
2577 2577
 
2578 2578
     /**
@@ -2581,8 +2581,8 @@  discard block
 block discarded – undo
2581 2581
 	 * @since 1.0.19
2582 2582
 	 * @param  string $value state.
2583 2583
 	 */
2584
-	public function set_user_state( $value ) {
2585
-		$this->set_state( $value );
2584
+	public function set_user_state($value) {
2585
+		$this->set_state($value);
2586 2586
     }
2587 2587
 
2588 2588
     /**
@@ -2591,8 +2591,8 @@  discard block
 block discarded – undo
2591 2591
 	 * @since 1.0.19
2592 2592
 	 * @param  string $value state.
2593 2593
 	 */
2594
-	public function set_customer_state( $value ) {
2595
-		$this->set_state( $value );
2594
+	public function set_customer_state($value) {
2595
+		$this->set_state($value);
2596 2596
     }
2597 2597
 
2598 2598
     /**
@@ -2601,8 +2601,8 @@  discard block
 block discarded – undo
2601 2601
 	 * @since 1.0.19
2602 2602
 	 * @param  string $value city.
2603 2603
 	 */
2604
-	public function set_city( $value ) {
2605
-		$this->set_prop( 'city', $value );
2604
+	public function set_city($value) {
2605
+		$this->set_prop('city', $value);
2606 2606
     }
2607 2607
 
2608 2608
     /**
@@ -2611,8 +2611,8 @@  discard block
 block discarded – undo
2611 2611
 	 * @since 1.0.19
2612 2612
 	 * @param  string $value city.
2613 2613
 	 */
2614
-	public function set_user_city( $value ) {
2615
-		$this->set_city( $value );
2614
+	public function set_user_city($value) {
2615
+		$this->set_city($value);
2616 2616
     }
2617 2617
 
2618 2618
     /**
@@ -2621,8 +2621,8 @@  discard block
 block discarded – undo
2621 2621
 	 * @since 1.0.19
2622 2622
 	 * @param  string $value city.
2623 2623
 	 */
2624
-	public function set_customer_city( $value ) {
2625
-		$this->set_city( $value );
2624
+	public function set_customer_city($value) {
2625
+		$this->set_city($value);
2626 2626
     }
2627 2627
 
2628 2628
     /**
@@ -2631,8 +2631,8 @@  discard block
 block discarded – undo
2631 2631
 	 * @since 1.0.19
2632 2632
 	 * @param  string $value zip.
2633 2633
 	 */
2634
-	public function set_zip( $value ) {
2635
-		$this->set_prop( 'zip', $value );
2634
+	public function set_zip($value) {
2635
+		$this->set_prop('zip', $value);
2636 2636
     }
2637 2637
 
2638 2638
     /**
@@ -2641,8 +2641,8 @@  discard block
 block discarded – undo
2641 2641
 	 * @since 1.0.19
2642 2642
 	 * @param  string $value zip.
2643 2643
 	 */
2644
-	public function set_user_zip( $value ) {
2645
-		$this->set_zip( $value );
2644
+	public function set_user_zip($value) {
2645
+		$this->set_zip($value);
2646 2646
     }
2647 2647
 
2648 2648
     /**
@@ -2651,8 +2651,8 @@  discard block
 block discarded – undo
2651 2651
 	 * @since 1.0.19
2652 2652
 	 * @param  string $value zip.
2653 2653
 	 */
2654
-	public function set_customer_zip( $value ) {
2655
-		$this->set_zip( $value );
2654
+	public function set_customer_zip($value) {
2655
+		$this->set_zip($value);
2656 2656
     }
2657 2657
 
2658 2658
     /**
@@ -2661,8 +2661,8 @@  discard block
 block discarded – undo
2661 2661
 	 * @since 1.0.19
2662 2662
 	 * @param  string $value company.
2663 2663
 	 */
2664
-	public function set_company( $value ) {
2665
-		$this->set_prop( 'company', $value );
2664
+	public function set_company($value) {
2665
+		$this->set_prop('company', $value);
2666 2666
     }
2667 2667
 
2668 2668
     /**
@@ -2671,8 +2671,8 @@  discard block
 block discarded – undo
2671 2671
 	 * @since 1.0.19
2672 2672
 	 * @param  string $value company.
2673 2673
 	 */
2674
-	public function set_user_company( $value ) {
2675
-		$this->set_company( $value );
2674
+	public function set_user_company($value) {
2675
+		$this->set_company($value);
2676 2676
     }
2677 2677
 
2678 2678
     /**
@@ -2681,8 +2681,8 @@  discard block
 block discarded – undo
2681 2681
 	 * @since 1.0.19
2682 2682
 	 * @param  string $value company.
2683 2683
 	 */
2684
-	public function set_customer_company( $value ) {
2685
-		$this->set_company( $value );
2684
+	public function set_customer_company($value) {
2685
+		$this->set_company($value);
2686 2686
     }
2687 2687
 
2688 2688
 	/**
@@ -2691,8 +2691,8 @@  discard block
 block discarded – undo
2691 2691
 	 * @since 1.0.19
2692 2692
 	 * @param  string $value company id.
2693 2693
 	 */
2694
-	public function set_company_id( $value ) {
2695
-		$this->set_prop( 'company_id', $value );
2694
+	public function set_company_id($value) {
2695
+		$this->set_prop('company_id', $value);
2696 2696
     }
2697 2697
 
2698 2698
     /**
@@ -2701,8 +2701,8 @@  discard block
 block discarded – undo
2701 2701
 	 * @since 1.0.19
2702 2702
 	 * @param  string $value var number.
2703 2703
 	 */
2704
-	public function set_vat_number( $value ) {
2705
-		$this->set_prop( 'vat_number', $value );
2704
+	public function set_vat_number($value) {
2705
+		$this->set_prop('vat_number', $value);
2706 2706
     }
2707 2707
 
2708 2708
     /**
@@ -2711,8 +2711,8 @@  discard block
 block discarded – undo
2711 2711
 	 * @since 1.0.19
2712 2712
 	 * @param  string $value var number.
2713 2713
 	 */
2714
-	public function set_user_vat_number( $value ) {
2715
-		$this->set_vat_number( $value );
2714
+	public function set_user_vat_number($value) {
2715
+		$this->set_vat_number($value);
2716 2716
     }
2717 2717
 
2718 2718
     /**
@@ -2721,8 +2721,8 @@  discard block
 block discarded – undo
2721 2721
 	 * @since 1.0.19
2722 2722
 	 * @param  string $value var number.
2723 2723
 	 */
2724
-	public function set_customer_vat_number( $value ) {
2725
-		$this->set_vat_number( $value );
2724
+	public function set_customer_vat_number($value) {
2725
+		$this->set_vat_number($value);
2726 2726
     }
2727 2727
 
2728 2728
     /**
@@ -2731,8 +2731,8 @@  discard block
 block discarded – undo
2731 2731
 	 * @since 1.0.19
2732 2732
 	 * @param  string $value var rate.
2733 2733
 	 */
2734
-	public function set_vat_rate( $value ) {
2735
-		$this->set_prop( 'vat_rate', $value );
2734
+	public function set_vat_rate($value) {
2735
+		$this->set_prop('vat_rate', $value);
2736 2736
     }
2737 2737
 
2738 2738
     /**
@@ -2741,8 +2741,8 @@  discard block
 block discarded – undo
2741 2741
 	 * @since 1.0.19
2742 2742
 	 * @param  string $value var number.
2743 2743
 	 */
2744
-	public function set_user_vat_rate( $value ) {
2745
-		$this->set_vat_rate( $value );
2744
+	public function set_user_vat_rate($value) {
2745
+		$this->set_vat_rate($value);
2746 2746
     }
2747 2747
 
2748 2748
     /**
@@ -2751,8 +2751,8 @@  discard block
 block discarded – undo
2751 2751
 	 * @since 1.0.19
2752 2752
 	 * @param  string $value var number.
2753 2753
 	 */
2754
-	public function set_customer_vat_rate( $value ) {
2755
-		$this->set_vat_rate( $value );
2754
+	public function set_customer_vat_rate($value) {
2755
+		$this->set_vat_rate($value);
2756 2756
     }
2757 2757
 
2758 2758
     /**
@@ -2761,8 +2761,8 @@  discard block
 block discarded – undo
2761 2761
 	 * @since 1.0.19
2762 2762
 	 * @param  string $value address.
2763 2763
 	 */
2764
-	public function set_address( $value ) {
2765
-		$this->set_prop( 'address', $value );
2764
+	public function set_address($value) {
2765
+		$this->set_prop('address', $value);
2766 2766
     }
2767 2767
 
2768 2768
     /**
@@ -2771,8 +2771,8 @@  discard block
 block discarded – undo
2771 2771
 	 * @since 1.0.19
2772 2772
 	 * @param  string $value address.
2773 2773
 	 */
2774
-	public function set_user_address( $value ) {
2775
-		$this->set_address( $value );
2774
+	public function set_user_address($value) {
2775
+		$this->set_address($value);
2776 2776
     }
2777 2777
 
2778 2778
     /**
@@ -2781,8 +2781,8 @@  discard block
 block discarded – undo
2781 2781
 	 * @since 1.0.19
2782 2782
 	 * @param  string $value address.
2783 2783
 	 */
2784
-	public function set_customer_address( $value ) {
2785
-		$this->set_address( $value );
2784
+	public function set_customer_address($value) {
2785
+		$this->set_address($value);
2786 2786
     }
2787 2787
 
2788 2788
     /**
@@ -2791,8 +2791,8 @@  discard block
 block discarded – undo
2791 2791
 	 * @since 1.0.19
2792 2792
 	 * @param  int|bool $value confirmed.
2793 2793
 	 */
2794
-	public function set_is_viewed( $value ) {
2795
-		$this->set_prop( 'is_viewed', $value );
2794
+	public function set_is_viewed($value) {
2795
+		$this->set_prop('is_viewed', $value);
2796 2796
 	}
2797 2797
 
2798 2798
 	/**
@@ -2801,8 +2801,8 @@  discard block
 block discarded – undo
2801 2801
 	 * @since 1.0.19
2802 2802
 	 * @param  string $value email recipients.
2803 2803
 	 */
2804
-	public function set_email_cc( $value ) {
2805
-		$this->set_prop( 'email_cc', $value );
2804
+	public function set_email_cc($value) {
2805
+		$this->set_prop('email_cc', $value);
2806 2806
 	}
2807 2807
 
2808 2808
 	/**
@@ -2811,9 +2811,9 @@  discard block
 block discarded – undo
2811 2811
 	 * @since 1.0.19
2812 2812
 	 * @param  string $value template.
2813 2813
 	 */
2814
-	public function set_template( $value ) {
2815
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2816
-			$this->set_prop( 'template', $value );
2814
+	public function set_template($value) {
2815
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2816
+			$this->set_prop('template', $value);
2817 2817
 		}
2818 2818
 	}
2819 2819
 
@@ -2824,8 +2824,8 @@  discard block
 block discarded – undo
2824 2824
 	 * @param  string $value source.
2825 2825
 	 * @deprecated
2826 2826
 	 */
2827
-	public function created_via( $value ) {
2828
-		$this->set_created_via( sanitize_text_field( $value ) );
2827
+	public function created_via($value) {
2828
+		$this->set_created_via(sanitize_text_field($value));
2829 2829
 	}
2830 2830
 
2831 2831
 	/**
@@ -2834,8 +2834,8 @@  discard block
 block discarded – undo
2834 2834
 	 * @since 1.0.19
2835 2835
 	 * @param  string $value source.
2836 2836
 	 */
2837
-	public function set_created_via( $value ) {
2838
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2837
+	public function set_created_via($value) {
2838
+		$this->set_prop('created_via', sanitize_text_field($value));
2839 2839
 	}
2840 2840
 
2841 2841
 	/**
@@ -2844,8 +2844,8 @@  discard block
 block discarded – undo
2844 2844
 	 * @since 1.0.19
2845 2845
 	 * @param  int|bool $value confirmed.
2846 2846
 	 */
2847
-	public function set_address_confirmed( $value ) {
2848
-		$this->set_prop( 'address_confirmed', $value );
2847
+	public function set_address_confirmed($value) {
2848
+		$this->set_prop('address_confirmed', $value);
2849 2849
     }
2850 2850
 
2851 2851
     /**
@@ -2854,8 +2854,8 @@  discard block
 block discarded – undo
2854 2854
 	 * @since 1.0.19
2855 2855
 	 * @param  int|bool $value confirmed.
2856 2856
 	 */
2857
-	public function set_user_address_confirmed( $value ) {
2858
-		$this->set_address_confirmed( $value );
2857
+	public function set_user_address_confirmed($value) {
2858
+		$this->set_address_confirmed($value);
2859 2859
     }
2860 2860
 
2861 2861
     /**
@@ -2864,8 +2864,8 @@  discard block
 block discarded – undo
2864 2864
 	 * @since 1.0.19
2865 2865
 	 * @param  int|bool $value confirmed.
2866 2866
 	 */
2867
-	public function set_customer_address_confirmed( $value ) {
2868
-		$this->set_address_confirmed( $value );
2867
+	public function set_customer_address_confirmed($value) {
2868
+		$this->set_address_confirmed($value);
2869 2869
     }
2870 2870
 
2871 2871
     /**
@@ -2874,13 +2874,13 @@  discard block
 block discarded – undo
2874 2874
 	 * @since 1.0.19
2875 2875
 	 * @param  float $value shipping amount.
2876 2876
 	 */
2877
-	public function set_shipping( $value ) {
2877
+	public function set_shipping($value) {
2878 2878
 
2879
-		if ( ! is_numeric( $value ) ) {
2880
-			return $this->set_prop( 'shipping', null );
2879
+		if (!is_numeric($value)) {
2880
+			return $this->set_prop('shipping', null);
2881 2881
 		}
2882 2882
 
2883
-		$this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2883
+		$this->set_prop('shipping', max(0, floatval($value)));
2884 2884
 	}
2885 2885
 
2886 2886
 	/**
@@ -2889,8 +2889,8 @@  discard block
 block discarded – undo
2889 2889
 	 * @since 1.0.19
2890 2890
 	 * @param  float $value sub total.
2891 2891
 	 */
2892
-	public function set_subtotal( $value ) {
2893
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2892
+	public function set_subtotal($value) {
2893
+		$this->set_prop('subtotal', max(0, $value));
2894 2894
 	}
2895 2895
 
2896 2896
 	/**
@@ -2899,8 +2899,8 @@  discard block
 block discarded – undo
2899 2899
 	 * @since 1.0.19
2900 2900
 	 * @param  float $value sub total.
2901 2901
 	 */
2902
-	public function set_total( $value ) {
2903
-		$this->set_prop( 'total', max( 0, $value ) );
2902
+	public function set_total($value) {
2903
+		$this->set_prop('total', max(0, $value));
2904 2904
     }
2905 2905
 
2906 2906
     /**
@@ -2909,8 +2909,8 @@  discard block
 block discarded – undo
2909 2909
 	 * @since 1.0.19
2910 2910
 	 * @param  float $value discount total.
2911 2911
 	 */
2912
-	public function set_total_discount( $value ) {
2913
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2912
+	public function set_total_discount($value) {
2913
+		$this->set_prop('total_discount', max(0, $value));
2914 2914
     }
2915 2915
 
2916 2916
     /**
@@ -2919,8 +2919,8 @@  discard block
 block discarded – undo
2919 2919
 	 * @since 1.0.19
2920 2920
 	 * @param  float $value discount total.
2921 2921
 	 */
2922
-	public function set_discount( $value ) {
2923
-		$this->set_total_discount( $value );
2922
+	public function set_discount($value) {
2923
+		$this->set_total_discount($value);
2924 2924
     }
2925 2925
 
2926 2926
     /**
@@ -2929,8 +2929,8 @@  discard block
 block discarded – undo
2929 2929
 	 * @since 1.0.19
2930 2930
 	 * @param  float $value tax total.
2931 2931
 	 */
2932
-	public function set_total_tax( $value ) {
2933
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2932
+	public function set_total_tax($value) {
2933
+		$this->set_prop('total_tax', max(0, $value));
2934 2934
     }
2935 2935
 
2936 2936
     /**
@@ -2939,8 +2939,8 @@  discard block
 block discarded – undo
2939 2939
 	 * @since 1.0.19
2940 2940
 	 * @param  float $value tax total.
2941 2941
 	 */
2942
-	public function set_tax_total( $value ) {
2943
-		$this->set_total_tax( $value );
2942
+	public function set_tax_total($value) {
2943
+		$this->set_total_tax($value);
2944 2944
     }
2945 2945
 
2946 2946
     /**
@@ -2949,8 +2949,8 @@  discard block
 block discarded – undo
2949 2949
 	 * @since 1.0.19
2950 2950
 	 * @param  float $value fees total.
2951 2951
 	 */
2952
-	public function set_total_fees( $value ) {
2953
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2952
+	public function set_total_fees($value) {
2953
+		$this->set_prop('total_fees', max(0, $value));
2954 2954
     }
2955 2955
 
2956 2956
     /**
@@ -2959,8 +2959,8 @@  discard block
 block discarded – undo
2959 2959
 	 * @since 1.0.19
2960 2960
 	 * @param  float $value fees total.
2961 2961
 	 */
2962
-	public function set_fees_total( $value ) {
2963
-		$this->set_total_fees( $value );
2962
+	public function set_fees_total($value) {
2963
+		$this->set_total_fees($value);
2964 2964
     }
2965 2965
 
2966 2966
     /**
@@ -2969,13 +2969,13 @@  discard block
 block discarded – undo
2969 2969
 	 * @since 1.0.19
2970 2970
 	 * @param  array $value fees.
2971 2971
 	 */
2972
-	public function set_fees( $value ) {
2972
+	public function set_fees($value) {
2973 2973
 
2974
-		if ( ! is_array( $value ) ) {
2974
+		if (!is_array($value)) {
2975 2975
 			$value = array();
2976 2976
 		}
2977 2977
 
2978
-		$this->set_prop( 'fees', $value );
2978
+		$this->set_prop('fees', $value);
2979 2979
 
2980 2980
     }
2981 2981
 
@@ -2985,13 +2985,13 @@  discard block
 block discarded – undo
2985 2985
 	 * @since 1.0.19
2986 2986
 	 * @param  array $value taxes.
2987 2987
 	 */
2988
-	public function set_taxes( $value ) {
2988
+	public function set_taxes($value) {
2989 2989
 
2990
-		if ( ! is_array( $value ) ) {
2990
+		if (!is_array($value)) {
2991 2991
 			$value = array();
2992 2992
 		}
2993 2993
 
2994
-		$this->set_prop( 'taxes', $value );
2994
+		$this->set_prop('taxes', $value);
2995 2995
 
2996 2996
     }
2997 2997
 
@@ -3001,13 +3001,13 @@  discard block
 block discarded – undo
3001 3001
 	 * @since 1.0.19
3002 3002
 	 * @param  array $value discounts.
3003 3003
 	 */
3004
-	public function set_discounts( $value ) {
3004
+	public function set_discounts($value) {
3005 3005
 
3006
-		if ( ! is_array( $value ) ) {
3006
+		if (!is_array($value)) {
3007 3007
 			$value = array();
3008 3008
 		}
3009 3009
 
3010
-		$this->set_prop( 'discounts', $value );
3010
+		$this->set_prop('discounts', $value);
3011 3011
     }
3012 3012
 
3013 3013
     /**
@@ -3016,19 +3016,19 @@  discard block
 block discarded – undo
3016 3016
 	 * @since 1.0.19
3017 3017
 	 * @param  GetPaid_Form_Item[] $value items.
3018 3018
 	 */
3019
-	public function set_items( $value ) {
3019
+	public function set_items($value) {
3020 3020
 
3021 3021
         // Remove existing items.
3022
-        $this->set_prop( 'items', array() );
3022
+        $this->set_prop('items', array());
3023 3023
 		$this->recurring_item = null;
3024 3024
 
3025 3025
         // Ensure that we have an array.
3026
-        if ( ! is_array( $value ) ) {
3026
+        if (!is_array($value)) {
3027 3027
             return;
3028 3028
         }
3029 3029
 
3030
-        foreach ( $value as $item ) {
3031
-            $this->add_item( $item );
3030
+        foreach ($value as $item) {
3031
+            $this->add_item($item);
3032 3032
         }
3033 3033
 
3034 3034
     }
@@ -3039,8 +3039,8 @@  discard block
 block discarded – undo
3039 3039
 	 * @since 1.0.19
3040 3040
 	 * @param  int $value payment form.
3041 3041
 	 */
3042
-	public function set_payment_form( $value ) {
3043
-		$this->set_prop( 'payment_form', $value );
3042
+	public function set_payment_form($value) {
3043
+		$this->set_prop('payment_form', $value);
3044 3044
     }
3045 3045
 
3046 3046
     /**
@@ -3049,8 +3049,8 @@  discard block
 block discarded – undo
3049 3049
 	 * @since 1.0.19
3050 3050
 	 * @param  string $value submission id.
3051 3051
 	 */
3052
-	public function set_submission_id( $value ) {
3053
-		$this->set_prop( 'submission_id', $value );
3052
+	public function set_submission_id($value) {
3053
+		$this->set_prop('submission_id', $value);
3054 3054
     }
3055 3055
 
3056 3056
     /**
@@ -3059,8 +3059,8 @@  discard block
 block discarded – undo
3059 3059
 	 * @since 1.0.19
3060 3060
 	 * @param  string $value discount code.
3061 3061
 	 */
3062
-	public function set_discount_code( $value ) {
3063
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3062
+	public function set_discount_code($value) {
3063
+		$this->set_prop('discount_code', sanitize_text_field($value));
3064 3064
     }
3065 3065
 
3066 3066
     /**
@@ -3069,8 +3069,8 @@  discard block
 block discarded – undo
3069 3069
 	 * @since 1.0.19
3070 3070
 	 * @param  string $value gateway.
3071 3071
 	 */
3072
-	public function set_gateway( $value ) {
3073
-		$this->set_prop( 'gateway', $value );
3072
+	public function set_gateway($value) {
3073
+		$this->set_prop('gateway', $value);
3074 3074
     }
3075 3075
 
3076 3076
     /**
@@ -3079,9 +3079,9 @@  discard block
 block discarded – undo
3079 3079
 	 * @since 1.0.19
3080 3080
 	 * @param  string $value transaction id.
3081 3081
 	 */
3082
-	public function set_transaction_id( $value ) {
3083
-		if ( ! empty( $value ) ) {
3084
-			$this->set_prop( 'transaction_id', $value );
3082
+	public function set_transaction_id($value) {
3083
+		if (!empty($value)) {
3084
+			$this->set_prop('transaction_id', $value);
3085 3085
 		}
3086 3086
     }
3087 3087
 
@@ -3091,8 +3091,8 @@  discard block
 block discarded – undo
3091 3091
 	 * @since 1.0.19
3092 3092
 	 * @param  string $value currency id.
3093 3093
 	 */
3094
-	public function set_currency( $value ) {
3095
-		$this->set_prop( 'currency', $value );
3094
+	public function set_currency($value) {
3095
+		$this->set_prop('currency', $value);
3096 3096
     }
3097 3097
 
3098 3098
 	/**
@@ -3101,8 +3101,8 @@  discard block
 block discarded – undo
3101 3101
 	 * @since 1.0.19
3102 3102
 	 * @param  bool $value value.
3103 3103
 	 */
3104
-	public function set_disable_taxes( $value ) {
3105
-		$this->set_prop( 'disable_taxes', (bool) $value );
3104
+	public function set_disable_taxes($value) {
3105
+		$this->set_prop('disable_taxes', (bool) $value);
3106 3106
 	}
3107 3107
 
3108 3108
     /**
@@ -3111,8 +3111,8 @@  discard block
 block discarded – undo
3111 3111
 	 * @since 1.0.19
3112 3112
 	 * @param  string $value subscription id.
3113 3113
 	 */
3114
-	public function set_subscription_id( $value ) {
3115
-		$this->set_prop( 'subscription_id', $value );
3114
+	public function set_subscription_id($value) {
3115
+		$this->set_prop('subscription_id', $value);
3116 3116
 	}
3117 3117
 
3118 3118
 	/**
@@ -3121,8 +3121,8 @@  discard block
 block discarded – undo
3121 3121
 	 * @since 1.0.19
3122 3122
 	 * @param  string $value subscription id.
3123 3123
 	 */
3124
-	public function set_remote_subscription_id( $value ) {
3125
-		$this->set_prop( 'remote_subscription_id', $value );
3124
+	public function set_remote_subscription_id($value) {
3125
+		$this->set_prop('remote_subscription_id', $value);
3126 3126
     }
3127 3127
 
3128 3128
     /*
@@ -3139,28 +3139,28 @@  discard block
 block discarded – undo
3139 3139
      */
3140 3140
     public function is_parent() {
3141 3141
         $parent = $this->get_parent_id();
3142
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
3142
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
3143 3143
     }
3144 3144
 
3145 3145
     /**
3146 3146
      * Checks if this is a renewal invoice.
3147 3147
      */
3148 3148
     public function is_renewal() {
3149
-        return $this->is_recurring() && ! $this->is_parent();
3149
+        return $this->is_recurring() && !$this->is_parent();
3150 3150
     }
3151 3151
 
3152 3152
     /**
3153 3153
      * Checks if this is a recurring invoice.
3154 3154
      */
3155 3155
     public function is_recurring() {
3156
-        return ! empty( $this->recurring_item );
3156
+        return !empty($this->recurring_item);
3157 3157
     }
3158 3158
 
3159 3159
     /**
3160 3160
      * Checks if this is a taxable invoice.
3161 3161
      */
3162 3162
     public function is_taxable() {
3163
-        return ! $this->get_disable_taxes();
3163
+        return !$this->get_disable_taxes();
3164 3164
 	}
3165 3165
 
3166 3166
 	/**
@@ -3174,45 +3174,45 @@  discard block
 block discarded – undo
3174 3174
 	 * Checks to see if the invoice requires payment.
3175 3175
 	 */
3176 3176
 	public function is_free() {
3177
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3177
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
3178 3178
 
3179
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3179
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
3180 3180
 			$is_free = false;
3181 3181
 		}
3182 3182
 
3183
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3183
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
3184 3184
     }
3185 3185
 
3186 3186
     /**
3187 3187
      * Checks if the invoice is paid.
3188 3188
      */
3189 3189
     public function is_paid() {
3190
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3191
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3190
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
3191
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
3192 3192
 	}
3193 3193
 
3194 3194
 	/**
3195 3195
      * Checks if the invoice needs payment.
3196 3196
      */
3197 3197
 	public function needs_payment() {
3198
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3199
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3198
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
3199
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
3200 3200
     }
3201 3201
 
3202 3202
 	/**
3203 3203
      * Checks if the invoice is refunded.
3204 3204
      */
3205 3205
 	public function is_refunded() {
3206
-        $is_refunded = $this->has_status( 'wpi-refunded' );
3207
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3206
+        $is_refunded = $this->has_status('wpi-refunded');
3207
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
3208 3208
 	}
3209 3209
 
3210 3210
 	/**
3211 3211
      * Checks if the invoice is held.
3212 3212
      */
3213 3213
 	public function is_held() {
3214
-        $is_held = $this->has_status( 'wpi-onhold' );
3215
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3214
+        $is_held = $this->has_status('wpi-onhold');
3215
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
3216 3216
 	}
3217 3217
 
3218 3218
 	/**
@@ -3220,30 +3220,30 @@  discard block
 block discarded – undo
3220 3220
      */
3221 3221
 	public function is_due() {
3222 3222
 		$due_date = $this->get_due_date();
3223
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3223
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3224 3224
 	}
3225 3225
 
3226 3226
 	/**
3227 3227
      * Checks if the invoice is draft.
3228 3228
      */
3229 3229
 	public function is_draft() {
3230
-        return $this->has_status( 'draft, auto-draft' );
3230
+        return $this->has_status('draft, auto-draft');
3231 3231
 	}
3232 3232
 
3233 3233
     /**
3234 3234
      * Checks if the invoice has a given status.
3235 3235
      */
3236
-    public function has_status( $status ) {
3237
-        $status = wpinv_parse_list( $status );
3238
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3236
+    public function has_status($status) {
3237
+        $status = wpinv_parse_list($status);
3238
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3239 3239
 	}
3240 3240
 
3241 3241
 	/**
3242 3242
      * Checks if the invoice is of a given type.
3243 3243
      */
3244
-    public function is_type( $type ) {
3245
-        $type = wpinv_parse_list( $type );
3246
-        return in_array( $this->get_type(), $type );
3244
+    public function is_type($type) {
3245
+        $type = wpinv_parse_list($type);
3246
+        return in_array($this->get_type(), $type);
3247 3247
     }
3248 3248
 
3249 3249
     /**
@@ -3275,8 +3275,8 @@  discard block
 block discarded – undo
3275 3275
      *
3276 3276
      */
3277 3277
 	public function is_initial_free() {
3278
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3279
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3278
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3279
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3280 3280
     }
3281 3281
 
3282 3282
 	/**
@@ -3286,11 +3286,11 @@  discard block
 block discarded – undo
3286 3286
     public function item_has_free_trial() {
3287 3287
 
3288 3288
         // Ensure we have a recurring item.
3289
-        if ( ! $this->is_recurring() ) {
3289
+        if (!$this->is_recurring()) {
3290 3290
             return false;
3291 3291
         }
3292 3292
 
3293
-        $item = $this->get_recurring( true );
3293
+        $item = $this->get_recurring(true);
3294 3294
         return $item->has_free_trial();
3295 3295
 	}
3296 3296
 
@@ -3298,7 +3298,7 @@  discard block
 block discarded – undo
3298 3298
      * Check if the free trial is a result of a discount.
3299 3299
      */
3300 3300
     public function is_free_trial_from_discount() {
3301
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3301
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3302 3302
 	}
3303 3303
 
3304 3304
 	/**
@@ -3306,12 +3306,12 @@  discard block
 block discarded – undo
3306 3306
      */
3307 3307
     public function discount_first_payment_only() {
3308 3308
 
3309
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3310
-        if ( ! $discount->exists() || ! $this->is_recurring() ) {
3309
+		$discount = wpinv_get_discount_obj($this->get_discount_code());
3310
+        if (!$discount->exists() || !$this->is_recurring()) {
3311 3311
             return true;
3312 3312
         }
3313 3313
 
3314
-        return ! $discount->get_is_recurring();
3314
+        return !$discount->get_is_recurring();
3315 3315
     }
3316 3316
 
3317 3317
     /*
@@ -3329,23 +3329,23 @@  discard block
 block discarded – undo
3329 3329
      * @param GetPaid_Form_Item|array $item
3330 3330
      * @return WP_Error|Bool
3331 3331
      */
3332
-    public function add_item( $item ) {
3332
+    public function add_item($item) {
3333 3333
 
3334
-		if ( is_array( $item ) ) {
3335
-			$item = $this->process_array_item( $item );
3334
+		if (is_array($item)) {
3335
+			$item = $this->process_array_item($item);
3336 3336
 		}
3337 3337
 
3338
-		if ( is_numeric( $item ) ) {
3339
-			$item = new GetPaid_Form_Item( $item );
3338
+		if (is_numeric($item)) {
3339
+			$item = new GetPaid_Form_Item($item);
3340 3340
 		}
3341 3341
 
3342 3342
         // Make sure that it is available for purchase.
3343
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3344
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3343
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3344
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3345 3345
         }
3346 3346
 
3347 3347
         // Do we have a recurring item?
3348
-		if ( $item->is_recurring() ) {
3348
+		if ($item->is_recurring()) {
3349 3349
 			$this->recurring_item = $item->get_id();
3350 3350
         }
3351 3351
 
@@ -3353,9 +3353,9 @@  discard block
 block discarded – undo
3353 3353
         $item->invoice_id = (int) $this->get_id();
3354 3354
 
3355 3355
 		// Remove duplicates.
3356
-		$this->remove_item( $item->get_id() );
3356
+		$this->remove_item($item->get_id());
3357 3357
 
3358
-		if ( 0 == $item->get_quantity() ) {
3358
+		if (0 == $item->get_quantity()) {
3359 3359
 			return;
3360 3360
 		}
3361 3361
 
@@ -3365,7 +3365,7 @@  discard block
 block discarded – undo
3365 3365
 		// Add new item.
3366 3366
         $items[] = $item;
3367 3367
 
3368
-        $this->set_prop( 'items', $items );
3368
+        $this->set_prop('items', $items);
3369 3369
 
3370 3370
 		return true;
3371 3371
 	}
@@ -3376,26 +3376,26 @@  discard block
 block discarded – undo
3376 3376
 	 * @since 1.0.19
3377 3377
 	 * @return GetPaid_Form_Item
3378 3378
 	 */
3379
-	protected function process_array_item( $array ) {
3379
+	protected function process_array_item($array) {
3380 3380
 
3381
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3382
-		$item    = new GetPaid_Form_Item( $item_id );
3381
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3382
+		$item    = new GetPaid_Form_Item($item_id);
3383 3383
 
3384 3384
 		// Set item data.
3385
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3386
-			if ( isset( $array[ "item_$key" ] ) ) {
3385
+		foreach (array('name', 'price', 'description') as $key) {
3386
+			if (isset($array["item_$key"])) {
3387 3387
 				$method = "set_$key";
3388
-				$item->$method( $array[ "item_$key" ] );
3388
+				$item->$method($array["item_$key"]);
3389 3389
 			}
3390 3390
 		}
3391 3391
 
3392
-		if ( isset( $array['quantity'] ) ) {
3393
-			$item->set_quantity( $array['quantity'] );
3392
+		if (isset($array['quantity'])) {
3393
+			$item->set_quantity($array['quantity']);
3394 3394
 		}
3395 3395
 
3396 3396
 		// Set item meta.
3397
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3398
-			$item->set_item_meta( $array['meta'] );
3397
+		if (isset($array['meta']) && is_array($array['meta'])) {
3398
+			$item->set_item_meta($array['meta']);
3399 3399
 		}
3400 3400
 
3401 3401
 		return $item;
@@ -3408,10 +3408,10 @@  discard block
 block discarded – undo
3408 3408
 	 * @since 1.0.19
3409 3409
 	 * @return GetPaid_Form_Item|null
3410 3410
 	 */
3411
-	public function get_item( $item_id ) {
3411
+	public function get_item($item_id) {
3412 3412
 
3413
-		foreach ( $this->get_items() as $item ) {
3414
-			if ( (int) $item_id == $item->get_id() ) {
3413
+		foreach ($this->get_items() as $item) {
3414
+			if ((int) $item_id == $item->get_id()) {
3415 3415
 				return $item;
3416 3416
 			}
3417 3417
 		}
@@ -3424,16 +3424,16 @@  discard block
 block discarded – undo
3424 3424
 	 *
3425 3425
 	 * @since 1.0.19
3426 3426
 	 */
3427
-	public function remove_item( $item_id ) {
3427
+	public function remove_item($item_id) {
3428 3428
 		$items   = $this->get_items();
3429 3429
 		$item_id = (int) $item_id;
3430 3430
 
3431
-		foreach ( $items as $index => $item ) {
3432
-			if ( (int) $item_id == $item->get_id() ) {
3433
-				unset( $items[ $index ] );
3434
-				$this->set_prop( 'items', $items );
3431
+		foreach ($items as $index => $item) {
3432
+			if ((int) $item_id == $item->get_id()) {
3433
+				unset($items[$index]);
3434
+				$this->set_prop('items', $items);
3435 3435
 
3436
-				if ( $item_id == $this->recurring_item ) {
3436
+				if ($item_id == $this->recurring_item) {
3437 3437
 					$this->recurring_item = null;
3438 3438
 				}
3439 3439
 }
@@ -3447,11 +3447,11 @@  discard block
 block discarded – undo
3447 3447
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3448 3448
 	 * @since 1.0.19
3449 3449
 	 */
3450
-    public function add_fee( $fee ) {
3450
+    public function add_fee($fee) {
3451 3451
 
3452 3452
 		$fees                 = $this->get_fees();
3453
-		$fees[ $fee['name'] ] = $fee;
3454
-		$this->set_prop( 'fees', $fees );
3453
+		$fees[$fee['name']] = $fee;
3454
+		$this->set_prop('fees', $fees);
3455 3455
 
3456 3456
     }
3457 3457
 
@@ -3460,9 +3460,9 @@  discard block
 block discarded – undo
3460 3460
 	 *
3461 3461
 	 * @since 1.0.19
3462 3462
 	 */
3463
-	public function get_fee( $fee ) {
3463
+	public function get_fee($fee) {
3464 3464
         $fees = $this->get_fees();
3465
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3465
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3466 3466
     }
3467 3467
 
3468 3468
     /**
@@ -3470,11 +3470,11 @@  discard block
 block discarded – undo
3470 3470
 	 *
3471 3471
 	 * @since 1.0.19
3472 3472
 	 */
3473
-	public function remove_fee( $fee ) {
3473
+	public function remove_fee($fee) {
3474 3474
         $fees = $this->get_fees();
3475
-        if ( isset( $fees[ $fee ] ) ) {
3476
-            unset( $fees[ $fee ] );
3477
-            $this->set_prop( 'fees', $fees );
3475
+        if (isset($fees[$fee])) {
3476
+            unset($fees[$fee]);
3477
+            $this->set_prop('fees', $fees);
3478 3478
         }
3479 3479
     }
3480 3480
 
@@ -3484,11 +3484,11 @@  discard block
 block discarded – undo
3484 3484
 	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3485 3485
 	 * @since 1.0.19
3486 3486
 	 */
3487
-	public function add_discount( $discount ) {
3487
+	public function add_discount($discount) {
3488 3488
 
3489 3489
 		$discounts = $this->get_discounts();
3490
-		$discounts[ $discount['name'] ] = $discount;
3491
-		$this->set_prop( 'discounts', $discounts );
3490
+		$discounts[$discount['name']] = $discount;
3491
+		$this->set_prop('discounts', $discounts);
3492 3492
 
3493 3493
 	}
3494 3494
 
@@ -3498,15 +3498,15 @@  discard block
 block discarded – undo
3498 3498
 	 * @since 1.0.19
3499 3499
 	 * @return float
3500 3500
 	 */
3501
-	public function get_discount( $discount = false ) {
3501
+	public function get_discount($discount = false) {
3502 3502
 
3503 3503
 		// Backwards compatibilty.
3504
-		if ( empty( $discount ) ) {
3504
+		if (empty($discount)) {
3505 3505
 			return $this->get_total_discount();
3506 3506
 		}
3507 3507
 
3508 3508
         $discounts = $this->get_discounts();
3509
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3509
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3510 3510
     }
3511 3511
 
3512 3512
     /**
@@ -3514,15 +3514,15 @@  discard block
 block discarded – undo
3514 3514
 	 *
3515 3515
 	 * @since 1.0.19
3516 3516
 	 */
3517
-	public function remove_discount( $discount ) {
3517
+	public function remove_discount($discount) {
3518 3518
         $discounts = $this->get_discounts();
3519
-        if ( isset( $discounts[ $discount ] ) ) {
3520
-            unset( $discounts[ $discount ] );
3521
-            $this->set_prop( 'discounts', $discounts );
3519
+        if (isset($discounts[$discount])) {
3520
+            unset($discounts[$discount]);
3521
+            $this->set_prop('discounts', $discounts);
3522 3522
         }
3523 3523
 
3524
-		if ( 'discount_code' == $discount ) {
3525
-			foreach ( $this->get_items() as $item ) {
3524
+		if ('discount_code' == $discount) {
3525
+			foreach ($this->get_items() as $item) {
3526 3526
 				$item->item_discount           = 0;
3527 3527
 				$item->recurring_item_discount = 0;
3528 3528
 			}
@@ -3535,12 +3535,12 @@  discard block
 block discarded – undo
3535 3535
      *
3536 3536
      * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
3537 3537
      */
3538
-    public function add_tax( $tax ) {
3539
-        if ( $this->is_taxable() ) {
3538
+    public function add_tax($tax) {
3539
+        if ($this->is_taxable()) {
3540 3540
 
3541
-            $taxes                 = $this->get_taxes();
3542
-			$taxes[ $tax['name'] ] = $tax;
3543
-			$this->set_prop( 'taxes', $tax );
3541
+            $taxes = $this->get_taxes();
3542
+			$taxes[$tax['name']] = $tax;
3543
+			$this->set_prop('taxes', $tax);
3544 3544
 
3545 3545
         }
3546 3546
     }
@@ -3550,15 +3550,15 @@  discard block
 block discarded – undo
3550 3550
 	 *
3551 3551
 	 * @since 1.0.19
3552 3552
 	 */
3553
-	public function get_tax( $tax = null ) {
3553
+	public function get_tax($tax = null) {
3554 3554
 
3555 3555
 		// Backwards compatility.
3556
-		if ( empty( $tax ) ) {
3556
+		if (empty($tax)) {
3557 3557
 			return $this->get_total_tax();
3558 3558
 		}
3559 3559
 
3560 3560
         $taxes = $this->get_taxes();
3561
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3561
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3562 3562
     }
3563 3563
 
3564 3564
     /**
@@ -3566,11 +3566,11 @@  discard block
 block discarded – undo
3566 3566
 	 *
3567 3567
 	 * @since 1.0.19
3568 3568
 	 */
3569
-	public function remove_tax( $tax ) {
3569
+	public function remove_tax($tax) {
3570 3570
         $taxes = $this->get_taxes();
3571
-        if ( isset( $taxes[ $tax ] ) ) {
3572
-            unset( $taxes[ $tax ] );
3573
-            $this->set_prop( 'taxes', $taxes );
3571
+        if (isset($taxes[$tax])) {
3572
+            unset($taxes[$tax]);
3573
+            $this->set_prop('taxes', $taxes);
3574 3574
         }
3575 3575
     }
3576 3576
 
@@ -3581,22 +3581,22 @@  discard block
 block discarded – undo
3581 3581
 	 * @return float The recalculated subtotal
3582 3582
 	 */
3583 3583
 	public function recalculate_subtotal() {
3584
-        $items     = $this->get_items();
3584
+        $items = $this->get_items();
3585 3585
 		$subtotal  = 0;
3586 3586
 		$recurring = 0;
3587 3587
 
3588
-        foreach ( $items as $item ) {
3589
-			$subtotal  += $item->get_sub_total( 'edit' );
3590
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3588
+        foreach ($items as $item) {
3589
+			$subtotal  += $item->get_sub_total('edit');
3590
+			$recurring += $item->get_recurring_sub_total('edit');
3591 3591
         }
3592 3592
 
3593
-		if ( wpinv_prices_include_tax() ) {
3594
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3595
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3593
+		if (wpinv_prices_include_tax()) {
3594
+			$subtotal  = max(0, $subtotal - $this->totals['tax']['initial']);
3595
+			$recurring = max(0, $recurring - $this->totals['tax']['recurring']);
3596 3596
 		}
3597 3597
 
3598 3598
 		$current = $this->is_renewal() ? $recurring : $subtotal;
3599
-		$this->set_subtotal( $current );
3599
+		$this->set_subtotal($current);
3600 3600
 
3601 3601
 		$this->totals['subtotal'] = array(
3602 3602
 			'initial'   => $subtotal,
@@ -3617,14 +3617,14 @@  discard block
 block discarded – undo
3617 3617
 		$discount  = 0;
3618 3618
 		$recurring = 0;
3619 3619
 
3620
-        foreach ( $discounts as $data ) {
3621
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3622
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3620
+        foreach ($discounts as $data) {
3621
+			$discount  += wpinv_sanitize_amount($data['initial_discount']);
3622
+			$recurring += wpinv_sanitize_amount($data['recurring_discount']);
3623 3623
 		}
3624 3624
 
3625 3625
 		$current = $this->is_renewal() ? $recurring : $discount;
3626 3626
 
3627
-		$this->set_total_discount( $current );
3627
+		$this->set_total_discount($current);
3628 3628
 
3629 3629
 		$this->totals['discount'] = array(
3630 3630
 			'initial'   => $discount,
@@ -3645,13 +3645,13 @@  discard block
 block discarded – undo
3645 3645
 
3646 3646
 		// Maybe disable taxes.
3647 3647
 		$vat_number = $this->get_vat_number();
3648
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3648
+		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number);
3649 3649
 
3650
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3650
+		if (wpinv_is_base_country($this->get_country()) && 'vat_too' === wpinv_get_option('vat_same_country_rule', 'vat_too')) {
3651 3651
 			$skip_tax = false;
3652 3652
 		}
3653 3653
 
3654
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) {
3654
+		if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) {
3655 3655
 
3656 3656
 			$this->totals['tax'] = array(
3657 3657
 				'initial'   => 0,
@@ -3660,37 +3660,37 @@  discard block
 block discarded – undo
3660 3660
 
3661 3661
 			$this->tax_rate = 0;
3662 3662
 
3663
-			$this->set_taxes( array() );
3663
+			$this->set_taxes(array());
3664 3664
 			$current = 0;
3665 3665
 		} else {
3666 3666
 
3667 3667
 			$item_taxes = array();
3668 3668
 
3669
-			foreach ( $this->get_items() as $item ) {
3670
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3671
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3672
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3673
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3674
-				foreach ( $taxes as $name => $amount ) {
3675
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3676
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3677
-
3678
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3679
-						$item_taxes[ $name ] = $tax;
3669
+			foreach ($this->get_items() as $item) {
3670
+				$rates    = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state());
3671
+				$rates    = getpaid_filter_item_tax_rates($item, $rates);
3672
+				$taxes    = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates);
3673
+				$r_taxes  = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates);
3674
+				foreach ($taxes as $name => $amount) {
3675
+					$recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0;
3676
+					$tax       = getpaid_prepare_item_tax($item, $name, $amount, $recurring);
3677
+
3678
+					if (!isset($item_taxes[$name])) {
3679
+						$item_taxes[$name] = $tax;
3680 3680
 						continue;
3681 3681
 					}
3682 3682
 
3683
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3684
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3683
+					$item_taxes[$name]['initial_tax']   += $tax['initial_tax'];
3684
+					$item_taxes[$name]['recurring_tax'] += $tax['recurring_tax'];
3685 3685
 
3686 3686
 				}
3687 3687
 			}
3688 3688
 
3689
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3690
-			$this->set_taxes( $item_taxes );
3689
+			$item_taxes = array_replace($this->get_taxes(), $item_taxes);
3690
+			$this->set_taxes($item_taxes);
3691 3691
 
3692
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3693
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3692
+			$initial_tax   = array_sum(wp_list_pluck($item_taxes, 'initial_tax'));
3693
+			$recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax'));
3694 3694
 
3695 3695
 			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3696 3696
 
@@ -3701,7 +3701,7 @@  discard block
 block discarded – undo
3701 3701
 
3702 3702
 		}
3703 3703
 
3704
-		$this->set_total_tax( $current );
3704
+		$this->set_total_tax($current);
3705 3705
 
3706 3706
 		return $current;
3707 3707
 
@@ -3718,20 +3718,20 @@  discard block
 block discarded – undo
3718 3718
 		$fee       = 0;
3719 3719
 		$recurring = 0;
3720 3720
 
3721
-        foreach ( $fees as $data ) {
3722
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3723
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3721
+        foreach ($fees as $data) {
3722
+			$fee       += wpinv_sanitize_amount($data['initial_fee']);
3723
+			$recurring += wpinv_sanitize_amount($data['recurring_fee']);
3724 3724
 		}
3725 3725
 
3726 3726
 		$current = $this->is_renewal() ? $recurring : $fee;
3727
-		$this->set_total_fees( $current );
3727
+		$this->set_total_fees($current);
3728 3728
 
3729 3729
 		$this->totals['fee'] = array(
3730 3730
 			'initial'   => $fee,
3731 3731
 			'recurring' => $recurring,
3732 3732
 		);
3733 3733
 
3734
-        $this->set_total_fees( $fee );
3734
+        $this->set_total_fees($fee);
3735 3735
         return $current;
3736 3736
     }
3737 3737
 
@@ -3746,7 +3746,7 @@  discard block
 block discarded – undo
3746 3746
         $this->recalculate_total_discount();
3747 3747
 		$this->recalculate_total_tax();
3748 3748
 		$this->recalculate_subtotal();
3749
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3749
+		$this->set_total($this->get_total_tax('edit') + $this->get_total_fees('edit') + $this->get_subtotal('edit') - $this->get_total_discount('edit'));
3750 3750
 		return $this->get_total();
3751 3751
 	}
3752 3752
 
@@ -3755,7 +3755,7 @@  discard block
 block discarded – undo
3755 3755
 	 */
3756 3756
     public function recalculate_totals() {
3757 3757
         $this->recalculate_total();
3758
-        $this->save( true );
3758
+        $this->save(true);
3759 3759
         return $this;
3760 3760
     }
3761 3761
 
@@ -3773,8 +3773,8 @@  discard block
 block discarded – undo
3773 3773
 	 * @return int|false The new note's ID on success, false on failure.
3774 3774
      *
3775 3775
      */
3776
-    public function add_system_note( $note ) {
3777
-		return $this->add_note( $note, false, false, true );
3776
+    public function add_system_note($note) {
3777
+		return $this->add_note($note, false, false, true);
3778 3778
 	}
3779 3779
 
3780 3780
     /**
@@ -3784,10 +3784,10 @@  discard block
 block discarded – undo
3784 3784
 	 * @return int|false The new note's ID on success, false on failure.
3785 3785
      *
3786 3786
      */
3787
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3787
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3788 3788
 
3789 3789
         // Bail if no note specified or this invoice is not yet saved.
3790
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3790
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3791 3791
             return false;
3792 3792
         }
3793 3793
 
@@ -3795,23 +3795,23 @@  discard block
 block discarded – undo
3795 3795
 		$author_email = '[email protected]';
3796 3796
 
3797 3797
 		// If this is an admin comment or it has been added by the user.
3798
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3799
-			$user         = get_user_by( 'id', get_current_user_id() );
3798
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3799
+			$user = get_user_by('id', get_current_user_id());
3800 3800
             $author       = $user->display_name;
3801 3801
             $author_email = $user->user_email;
3802 3802
 		}
3803 3803
 
3804
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3804
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3805 3805
 
3806 3806
 	}
3807 3807
 
3808 3808
 	/**
3809 3809
      * Generates a unique key for the invoice.
3810 3810
      */
3811
-    public function generate_key( $string = '' ) {
3812
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3811
+    public function generate_key($string = '') {
3812
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3813 3813
         return strtolower(
3814
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3814
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3815 3815
         );
3816 3816
     }
3817 3817
 
@@ -3821,11 +3821,11 @@  discard block
 block discarded – undo
3821 3821
     public function generate_number() {
3822 3822
         $number = $this->get_id();
3823 3823
 
3824
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3825
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3824
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3825
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3826 3826
         }
3827 3827
 
3828
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3828
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3829 3829
 
3830 3830
 	}
3831 3831
 
@@ -3838,55 +3838,55 @@  discard block
 block discarded – undo
3838 3838
 		// Reset status transition variable.
3839 3839
 		$this->status_transition = false;
3840 3840
 
3841
-		if ( $status_transition ) {
3841
+		if ($status_transition) {
3842 3842
 			try {
3843 3843
 
3844 3844
 				// Fire a hook for the status change.
3845
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3845
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3846 3846
 
3847 3847
 				// @deprecated this is deprecated and will be removed in the future.
3848
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3848
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3849 3849
 
3850
-				if ( ! empty( $status_transition['from'] ) ) {
3850
+				if (!empty($status_transition['from'])) {
3851 3851
 
3852 3852
 					/* translators: 1: old invoice status 2: new invoice status */
3853
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) );
3853
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this));
3854 3854
 
3855 3855
 					// Fire another hook.
3856
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3857
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3856
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3857
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3858 3858
 
3859 3859
 					// @deprecated this is deprecated and will be removed in the future.
3860
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3860
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3861 3861
 
3862 3862
 					// Note the transition occurred.
3863
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3863
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']);
3864 3864
 
3865 3865
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3866 3866
 					if (
3867
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3868
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3867
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3868
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3869 3869
 					) {
3870
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3870
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3871 3871
 					}
3872 3872
 
3873 3873
 					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3874 3874
 					if (
3875
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3876
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3875
+						in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3876
+						&& in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3877 3877
 					) {
3878
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3878
+						do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition);
3879 3879
 					}
3880 3880
 				} else {
3881 3881
 					/* translators: %s: new invoice status */
3882
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) );
3882
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this));
3883 3883
 
3884 3884
 					// Note the transition occurred.
3885
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3885
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3886 3886
 
3887 3887
 				}
3888
-			} catch ( Exception $e ) {
3889
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3888
+			} catch (Exception $e) {
3889
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3890 3890
 			}
3891 3891
 		}
3892 3892
 	}
@@ -3894,13 +3894,13 @@  discard block
 block discarded – undo
3894 3894
 	/**
3895 3895
 	 * Updates an invoice status.
3896 3896
 	 */
3897
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3897
+	public function update_status($new_status = false, $note = '', $manual = false) {
3898 3898
 
3899 3899
 		// Fires before updating a status.
3900
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3900
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3901 3901
 
3902 3902
 		// Update the status.
3903
-		$this->set_status( $new_status, $note, $manual );
3903
+		$this->set_status($new_status, $note, $manual);
3904 3904
 
3905 3905
 		// Save the order.
3906 3906
 		return $this->save();
@@ -3911,18 +3911,18 @@  discard block
 block discarded – undo
3911 3911
 	 * @deprecated
3912 3912
 	 */
3913 3913
 	public function refresh_item_ids() {
3914
-        $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3915
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3914
+        $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id')));
3915
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3916 3916
 	}
3917 3917
 
3918 3918
 	/**
3919 3919
 	 * @deprecated
3920 3920
 	 */
3921
-	public function update_items( $temp = false ) {
3921
+	public function update_items($temp = false) {
3922 3922
 
3923
-		$this->set_items( $this->get_items() );
3923
+		$this->set_items($this->get_items());
3924 3924
 
3925
-		if ( ! $temp ) {
3925
+		if (!$temp) {
3926 3926
 			$this->save();
3927 3927
 		}
3928 3928
 
@@ -3936,11 +3936,11 @@  discard block
 block discarded – undo
3936 3936
 
3937 3937
         $discount_code = $this->get_discount_code();
3938 3938
 
3939
-        if ( empty( $discount_code ) ) {
3939
+        if (empty($discount_code)) {
3940 3940
             return false;
3941 3941
         }
3942 3942
 
3943
-        $discount = wpinv_get_discount_obj( $discount_code );
3943
+        $discount = wpinv_get_discount_obj($discount_code);
3944 3944
 
3945 3945
         // Ensure it is active.
3946 3946
         return $discount->exists();
@@ -3951,7 +3951,7 @@  discard block
 block discarded – undo
3951 3951
 	 * Refunds an invoice.
3952 3952
 	 */
3953 3953
     public function refund() {
3954
-		$this->set_status( 'wpi-refunded' );
3954
+		$this->set_status('wpi-refunded');
3955 3955
         $this->save();
3956 3956
 	}
3957 3957
 
@@ -3960,53 +3960,53 @@  discard block
 block discarded – undo
3960 3960
 	 *
3961 3961
 	 * @param string $transaction_id
3962 3962
 	 */
3963
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3963
+    public function mark_paid($transaction_id = null, $note = '') {
3964 3964
 
3965 3965
 		// Set the transaction id.
3966
-		if ( empty( $transaction_id ) ) {
3967
-			$transaction_id = $this->generate_key( 'trans_' );
3966
+		if (empty($transaction_id)) {
3967
+			$transaction_id = $this->generate_key('trans_');
3968 3968
 		}
3969 3969
 
3970
-		if ( ! $this->get_transaction_id() ) {
3971
-			$this->set_transaction_id( $transaction_id );
3970
+		if (!$this->get_transaction_id()) {
3971
+			$this->set_transaction_id($transaction_id);
3972 3972
 		}
3973 3973
 
3974
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3974
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3975 3975
 			return $this->save();
3976 3976
 		}
3977 3977
 
3978 3978
 		// Set the completed date.
3979
-		$this->set_date_completed( current_time( 'mysql' ) );
3979
+		$this->set_date_completed(current_time('mysql'));
3980 3980
 
3981 3981
 		// Set the new status.
3982
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3983
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
3982
+		$gateway = sanitize_text_field($this->get_gateway_title());
3983
+		if ($this->is_renewal() || !$this->is_parent()) {
3984 3984
 
3985
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3986
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3985
+			$_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway);
3986
+			$_note = $_note . empty($note) ? '' : " ($note)";
3987 3987
 
3988
-			if ( 'none' == $this->get_gateway() ) {
3988
+			if ('none' == $this->get_gateway()) {
3989 3989
 				$_note = $note;
3990 3990
 			}
3991 3991
 
3992
-			$this->set_status( 'wpi-renewal', $_note );
3992
+			$this->set_status('wpi-renewal', $_note);
3993 3993
 
3994 3994
 		} else {
3995 3995
 
3996
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3997
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3996
+			$_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway);
3997
+			$_note = $_note . empty($note) ? '' : " ($note)";
3998 3998
 
3999
-			if ( 'none' == $this->get_gateway() ) {
3999
+			if ('none' == $this->get_gateway()) {
4000 4000
 				$_note = $note;
4001 4001
 			}
4002 4002
 
4003
-			$this->set_status( 'publish', $_note );
4003
+			$this->set_status('publish', $_note);
4004 4004
 
4005 4005
 		}
4006 4006
 
4007 4007
 		// Set checkout mode.
4008
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
4009
-		$this->set_mode( $mode );
4008
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
4009
+		$this->set_mode($mode);
4010 4010
 
4011 4011
 		// Save the invoice.
4012 4012
         $this->save();
@@ -4031,16 +4031,16 @@  discard block
 block discarded – undo
4031 4031
      * Clears the subscription's cache.
4032 4032
      */
4033 4033
     public function clear_cache() {
4034
-		if ( $this->get_key() ) {
4035
-			wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4034
+		if ($this->get_key()) {
4035
+			wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
4036 4036
 		}
4037 4037
 
4038
-		if ( $this->get_number() ) {
4039
-			wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4038
+		if ($this->get_number()) {
4039
+			wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
4040 4040
 		}
4041 4041
 
4042
-		if ( $this->get_transaction_id() ) {
4043
-			wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4042
+		if ($this->get_transaction_id()) {
4043
+			wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
4044 4044
 		}
4045 4045
 	}
4046 4046
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-address.php 2 patches
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -16,84 +16,84 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class GetPaid_Meta_Box_Invoice_Address {
18 18
 
19
-	/**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
24
-	public static function output( $post ) {
25
-
26
-		// Prepare the invoice.
27
-		$invoice  = new WPInv_Invoice( $post );
28
-		$customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id();
29
-		$customer = new WP_User( $customer );
30
-		$display  = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email );
31
-		wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
32
-
33
-		// Address fields.
34
-		$address_fields = array(
35
-			'first_name' => array(
36
-				'label' => __( 'First Name', 'invoicing' ),
37
-				'type'  => 'text',
38
-			),
39
-			'last_name'  => array(
40
-				'label' => __( 'Last Name', 'invoicing' ),
41
-				'type'  => 'text',
42
-			),
43
-			'company'    => array(
44
-				'label' => __( 'Company', 'invoicing' ),
45
-				'type'  => 'text',
46
-				'class' => 'getpaid-recalculate-prices-on-change',
47
-			),
48
-			'vat_number' => array(
49
-				'label' => __( 'VAT Number', 'invoicing' ),
50
-				'type'  => 'text',
51
-			),
52
-			'address'    => array(
53
-				'label' => __( 'Address', 'invoicing' ),
54
-				'type'  => 'text',
55
-			),
56
-			'city'       => array(
57
-				'label' => __( 'City', 'invoicing' ),
58
-				'type'  => 'text',
59
-			),
60
-			'country'    => array(
61
-				'label'       => __( 'Country', 'invoicing' ),
62
-				'type'        => 'select',
63
-				'class'       => 'getpaid-recalculate-prices-on-change',
64
-				'options'     => wpinv_get_country_list(),
65
-				'placeholder' => __( 'Choose a country', 'invoicing' ),
66
-			),
67
-			'state'      => array(
68
-				'label' => __( 'State', 'invoicing' ),
69
-				'type'  => 'text',
70
-				'class' => 'getpaid-recalculate-prices-on-change',
71
-			),
72
-			'zip'        => array(
73
-				'label' => __( 'Zip', 'invoicing' ),
74
-				'type'  => 'text',
75
-			),
76
-			'phone'      => array(
77
-				'label' => __( 'Phone', 'invoicing' ),
78
-				'type'  => 'text',
79
-			),
80
-		);
81
-
82
-		$states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
83
-
84
-		if ( ! empty( $states ) ) {
85
-			$address_fields['state']['type']        = 'select';
86
-			$address_fields['state']['options']     = $states;
87
-			$address_fields['state']['placeholder'] = __( 'Choose a state', 'invoicing' );
88
-		}
89
-
90
-		// Maybe remove the VAT field.
91
-		if ( ! wpinv_use_taxes() ) {
92
-			unset( $address_fields['vat_number'] );
93
-		}
94
-
95
-		$address_fields = apply_filters( 'getpaid_admin_edit_invoice_address_fields', $address_fields, $invoice );
96
-		?>
19
+    /**
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24
+    public static function output( $post ) {
25
+
26
+        // Prepare the invoice.
27
+        $invoice  = new WPInv_Invoice( $post );
28
+        $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id();
29
+        $customer = new WP_User( $customer );
30
+        $display  = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email );
31
+        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
32
+
33
+        // Address fields.
34
+        $address_fields = array(
35
+            'first_name' => array(
36
+                'label' => __( 'First Name', 'invoicing' ),
37
+                'type'  => 'text',
38
+            ),
39
+            'last_name'  => array(
40
+                'label' => __( 'Last Name', 'invoicing' ),
41
+                'type'  => 'text',
42
+            ),
43
+            'company'    => array(
44
+                'label' => __( 'Company', 'invoicing' ),
45
+                'type'  => 'text',
46
+                'class' => 'getpaid-recalculate-prices-on-change',
47
+            ),
48
+            'vat_number' => array(
49
+                'label' => __( 'VAT Number', 'invoicing' ),
50
+                'type'  => 'text',
51
+            ),
52
+            'address'    => array(
53
+                'label' => __( 'Address', 'invoicing' ),
54
+                'type'  => 'text',
55
+            ),
56
+            'city'       => array(
57
+                'label' => __( 'City', 'invoicing' ),
58
+                'type'  => 'text',
59
+            ),
60
+            'country'    => array(
61
+                'label'       => __( 'Country', 'invoicing' ),
62
+                'type'        => 'select',
63
+                'class'       => 'getpaid-recalculate-prices-on-change',
64
+                'options'     => wpinv_get_country_list(),
65
+                'placeholder' => __( 'Choose a country', 'invoicing' ),
66
+            ),
67
+            'state'      => array(
68
+                'label' => __( 'State', 'invoicing' ),
69
+                'type'  => 'text',
70
+                'class' => 'getpaid-recalculate-prices-on-change',
71
+            ),
72
+            'zip'        => array(
73
+                'label' => __( 'Zip', 'invoicing' ),
74
+                'type'  => 'text',
75
+            ),
76
+            'phone'      => array(
77
+                'label' => __( 'Phone', 'invoicing' ),
78
+                'type'  => 'text',
79
+            ),
80
+        );
81
+
82
+        $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
83
+
84
+        if ( ! empty( $states ) ) {
85
+            $address_fields['state']['type']        = 'select';
86
+            $address_fields['state']['options']     = $states;
87
+            $address_fields['state']['placeholder'] = __( 'Choose a state', 'invoicing' );
88
+        }
89
+
90
+        // Maybe remove the VAT field.
91
+        if ( ! wpinv_use_taxes() ) {
92
+            unset( $address_fields['vat_number'] );
93
+        }
94
+
95
+        $address_fields = apply_filters( 'getpaid_admin_edit_invoice_address_fields', $address_fields, $invoice );
96
+        ?>
97 97
 
98 98
 		<style>
99 99
 			#wpinv-address label {
@@ -118,19 +118,19 @@  discard block
 block discarded – undo
118 118
 							<div id="getpaid-invoice-email-wrapper" class="d-none">
119 119
 								<input type="hidden" id="getpaid-invoice-create-new-user" name="wpinv_new_user" value="" />
120 120
 								<?php
121
-									aui()->input(
122
-										array(
123
-											'type'        => 'text',
124
-											'id'          => 'getpaid-invoice-new-user-email',
125
-											'name'        => 'wpinv_email',
126
-											'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
127
-											'label_type'  => 'vertical',
128
-											'placeholder' => '[email protected]',
129
-											'class'       => 'form-control-sm',
130
-										),
131
-										true
132
-									);
133
-								?>
121
+                                    aui()->input(
122
+                                        array(
123
+                                            'type'        => 'text',
124
+                                            'id'          => 'getpaid-invoice-new-user-email',
125
+                                            'name'        => 'wpinv_email',
126
+                                            'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
127
+                                            'label_type'  => 'vertical',
128
+                                            'placeholder' => '[email protected]',
129
+                                            'class'       => 'form-control-sm',
130
+                                        ),
131
+                                        true
132
+                                    );
133
+                                ?>
134 134
 							</div>
135 135
 						</div>
136 136
 						<div class="col-12 col-sm-6 form-group mb-3 mt-sm-4">
@@ -154,39 +154,39 @@  discard block
 block discarded – undo
154 154
 							<div class="col-12 col-sm-6 getpaid-invoice-address-field__<?php echo esc_attr( $key ); ?>--wrapper">
155 155
 								<?php
156 156
 
157
-									if ( 'select' === $field['type'] ) {
158
-										aui()->select(
159
-											array(
160
-												'id'               => 'wpinv_' . $key,
161
-												'name'             => 'wpinv_' . $key,
162
-												'label'            => $field['label'],
163
-												'label_type'       => 'vertical',
164
-												'placeholder'      => isset( $field['placeholder'] ) ? $field['placeholder'] : '',
165
-												'class'            => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ),
166
-												'value'            => $invoice->get( $key, 'edit' ),
167
-												'options'          => $field['options'],
168
-												'data-allow-clear' => 'false',
169
-												'select2'          => true,
170
-											),
171
-											true
172
-										);
173
-									} else {
174
-										aui()->input(
175
-											array(
176
-												'type'        => $field['type'],
177
-												'id'          => 'wpinv_' . $key,
178
-												'name'        => 'wpinv_' . $key,
179
-												'label'       => $field['label'],
180
-												'label_type'  => 'vertical',
181
-												'placeholder' => isset( $field['placeholder'] ) ? $field['placeholder'] : '',
182
-												'class'       => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ),
183
-												'value'       => $invoice->get( $key, 'edit' ),
184
-											),
185
-											true
186
-										);
187
-									}
188
-
189
-								?>
157
+                                    if ( 'select' === $field['type'] ) {
158
+                                        aui()->select(
159
+                                            array(
160
+                                                'id'               => 'wpinv_' . $key,
161
+                                                'name'             => 'wpinv_' . $key,
162
+                                                'label'            => $field['label'],
163
+                                                'label_type'       => 'vertical',
164
+                                                'placeholder'      => isset( $field['placeholder'] ) ? $field['placeholder'] : '',
165
+                                                'class'            => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ),
166
+                                                'value'            => $invoice->get( $key, 'edit' ),
167
+                                                'options'          => $field['options'],
168
+                                                'data-allow-clear' => 'false',
169
+                                                'select2'          => true,
170
+                                            ),
171
+                                            true
172
+                                        );
173
+                                    } else {
174
+                                        aui()->input(
175
+                                            array(
176
+                                                'type'        => $field['type'],
177
+                                                'id'          => 'wpinv_' . $key,
178
+                                                'name'        => 'wpinv_' . $key,
179
+                                                'label'       => $field['label'],
180
+                                                'label_type'  => 'vertical',
181
+                                                'placeholder' => isset( $field['placeholder'] ) ? $field['placeholder'] : '',
182
+                                                'class'       => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ),
183
+                                                'value'       => $invoice->get( $key, 'edit' ),
184
+                                            ),
185
+                                            true
186
+                                        );
187
+                                    }
188
+
189
+                                ?>
190 190
 							</div>
191 191
 						<?php endforeach; ?>
192 192
 					</div>
@@ -197,49 +197,49 @@  discard block
 block discarded – undo
197 197
 						<div class="row">
198 198
 							<div class="col-12 col-sm-6">
199 199
 								<?php
200
-									aui()->select(
201
-										array(
202
-											'id'          => 'wpinv_template',
203
-											'name'        => 'wpinv_template',
204
-											'label'       => __( 'Template', 'invoicing' ),
205
-											'label_type'  => 'vertical',
206
-											'placeholder' => __( 'Choose a template', 'invoicing' ),
207
-											'class'       => 'form-control-sm',
208
-											'value'       => $invoice->get_template( 'edit' ),
209
-											'options'     => array(
210
-												'quantity' => __( 'Quantity', 'invoicing' ),
211
-												'hours'    => __( 'Hours', 'invoicing' ),
212
-												//'amount'   => __( 'Amount Only', 'invoicing' ),
213
-											),
214
-											'data-allow-clear' => 'false',
215
-											'select2'     => true,
216
-										),
217
-										true
218
-									);
219
-								?>
200
+                                    aui()->select(
201
+                                        array(
202
+                                            'id'          => 'wpinv_template',
203
+                                            'name'        => 'wpinv_template',
204
+                                            'label'       => __( 'Template', 'invoicing' ),
205
+                                            'label_type'  => 'vertical',
206
+                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
207
+                                            'class'       => 'form-control-sm',
208
+                                            'value'       => $invoice->get_template( 'edit' ),
209
+                                            'options'     => array(
210
+                                                'quantity' => __( 'Quantity', 'invoicing' ),
211
+                                                'hours'    => __( 'Hours', 'invoicing' ),
212
+                                                //'amount'   => __( 'Amount Only', 'invoicing' ),
213
+                                            ),
214
+                                            'data-allow-clear' => 'false',
215
+                                            'select2'     => true,
216
+                                        ),
217
+                                        true
218
+                                    );
219
+                                ?>
220 220
 							</div>
221 221
 							<div class="col-12 col-sm-6">
222 222
 								<?php
223 223
 
224
-									// Set currency.
225
-									aui()->select(
226
-										array(
227
-											'id'          => 'wpinv_currency',
228
-											'name'        => 'wpinv_currency',
229
-											'label'       => __( 'Currency', 'invoicing' ),
230
-											'label_type'  => 'vertical',
231
-											'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
232
-											'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
233
-											'value'       => $invoice->get_currency( 'edit' ),
234
-											'required'    => false,
235
-											'data-allow-clear' => 'false',
236
-											'select2'     => true,
237
-											'options'     => wpinv_get_currencies(),
238
-										),
239
-										true
240
-									);
241
-
242
-								?>
224
+                                    // Set currency.
225
+                                    aui()->select(
226
+                                        array(
227
+                                            'id'          => 'wpinv_currency',
228
+                                            'name'        => 'wpinv_currency',
229
+                                            'label'       => __( 'Currency', 'invoicing' ),
230
+                                            'label_type'  => 'vertical',
231
+                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
232
+                                            'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
233
+                                            'value'       => $invoice->get_currency( 'edit' ),
234
+                                            'required'    => false,
235
+                                            'data-allow-clear' => 'false',
236
+                                            'select2'     => true,
237
+                                            'options'     => wpinv_get_currencies(),
238
+                                        ),
239
+                                        true
240
+                                    );
241
+
242
+                                ?>
243 243
 							</div>
244 244
 						</div>
245 245
 
@@ -249,119 +249,119 @@  discard block
 block discarded – undo
249 249
 					<div class="row">
250 250
 						<div class="col-12 col-sm-6">
251 251
 							<?php
252
-								aui()->input(
253
-									array(
254
-										'type'        => 'text',
255
-										'id'          => 'wpinv_company_id',
256
-										'name'        => 'wpinv_company_id',
257
-										'label'       => __( 'Company ID', 'invoicing' ),
258
-										'label_type'  => 'vertical',
259
-										'placeholder' => '',
260
-										'class'       => 'form-control-sm',
261
-										'value'       => $invoice->get_company_id( 'edit' ),
262
-									),
263
-									true
264
-								);
265
-							?>
252
+                                aui()->input(
253
+                                    array(
254
+                                        'type'        => 'text',
255
+                                        'id'          => 'wpinv_company_id',
256
+                                        'name'        => 'wpinv_company_id',
257
+                                        'label'       => __( 'Company ID', 'invoicing' ),
258
+                                        'label_type'  => 'vertical',
259
+                                        'placeholder' => '',
260
+                                        'class'       => 'form-control-sm',
261
+                                        'value'       => $invoice->get_company_id( 'edit' ),
262
+                                    ),
263
+                                    true
264
+                                );
265
+                            ?>
266 266
 						</div>
267 267
 					</div>
268 268
 
269 269
 					<?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?>
270 270
 			</div>
271 271
 		<?php
272
-	}
273
-
274
-	/**
275
-	 * Save meta box data.
276
-	 *
277
-	 * @param int $post_id
278
-	 */
279
-	public static function save( $post_id ) {
280
-
281
-		// Prepare the invoice.
282
-		$invoice = new WPInv_Invoice( $post_id );
283
-
284
-		// Load new data.
285
-		$invoice->set_props(
286
-			array(
287
-				'template'       => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
288
-				'email_cc'       => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
289
-				'disable_taxes'  => ! empty( $_POST['disable_taxes'] ),
290
-				'currency'       => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null,
291
-				'gateway'        => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null,
292
-				'address'        => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null,
293
-				'vat_number'     => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null,
294
-				'company'        => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null,
295
-				'company_id'     => isset( $_POST['wpinv_company_id'] ) ? wpinv_clean( $_POST['wpinv_company_id'] ) : null,
296
-				'zip'            => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null,
297
-				'state'          => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null,
298
-				'city'           => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null,
299
-				'country'        => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null,
300
-				'phone'          => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null,
301
-				'first_name'     => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null,
302
-				'last_name'      => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null,
303
-				'author'         => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null,
304
-				'date_created'   => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null,
305
-				'date_completed' => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null,
306
-				'due_date'       => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
307
-				'number'         => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
308
-				'status'         => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
309
-			)
310
-		);
311
-
312
-		// Discount code.
313
-		if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
314
-
315
-			if ( isset( $_POST['wpinv_discount_code'] ) ) {
316
-				$invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) );
317
-			}
318
-
319
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
320
-			if ( $discount->exists() ) {
321
-				$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
322
-			} else {
323
-				$invoice->remove_discount( 'discount_code' );
324
-			}
325
-
326
-			// Recalculate totals.
327
-			$invoice->recalculate_total();
328
-
329
-		}
330
-
331
-		// If we're creating a new user...
332
-		if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) {
333
-
334
-			// Attempt to create the user.
335
-			$user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ), $invoice->get_first_name() . $invoice->get_last_name() );
336
-
337
-			// If successful, update the invoice author.
338
-			if ( is_numeric( $user ) ) {
339
-				$invoice->set_author( $user );
340
-			} else {
341
-				wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
342
-			}
343
-		}
344
-
345
-		// Do not send new invoice notifications.
346
-		$GLOBALS['wpinv_skip_invoice_notification'] = true;
347
-
348
-		// Save the invoice.
349
-		$invoice->save();
350
-
351
-		// Undo do not send new invoice notifications.
352
-		$GLOBALS['wpinv_skip_invoice_notification'] = false;
353
-
354
-		// (Maybe) send new user notification.
355
-		$should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
356
-		if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
357
-			wp_send_new_user_notifications( $user, 'user' );
358
-		}
359
-
360
-		if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) {
361
-			getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true );
362
-		}
363
-
364
-		// Fires after an invoice is saved.
365
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
366
-	}
272
+    }
273
+
274
+    /**
275
+     * Save meta box data.
276
+     *
277
+     * @param int $post_id
278
+     */
279
+    public static function save( $post_id ) {
280
+
281
+        // Prepare the invoice.
282
+        $invoice = new WPInv_Invoice( $post_id );
283
+
284
+        // Load new data.
285
+        $invoice->set_props(
286
+            array(
287
+                'template'       => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
288
+                'email_cc'       => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
289
+                'disable_taxes'  => ! empty( $_POST['disable_taxes'] ),
290
+                'currency'       => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null,
291
+                'gateway'        => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null,
292
+                'address'        => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null,
293
+                'vat_number'     => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null,
294
+                'company'        => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null,
295
+                'company_id'     => isset( $_POST['wpinv_company_id'] ) ? wpinv_clean( $_POST['wpinv_company_id'] ) : null,
296
+                'zip'            => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null,
297
+                'state'          => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null,
298
+                'city'           => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null,
299
+                'country'        => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null,
300
+                'phone'          => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null,
301
+                'first_name'     => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null,
302
+                'last_name'      => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null,
303
+                'author'         => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null,
304
+                'date_created'   => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null,
305
+                'date_completed' => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null,
306
+                'due_date'       => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
307
+                'number'         => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
308
+                'status'         => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
309
+            )
310
+        );
311
+
312
+        // Discount code.
313
+        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
314
+
315
+            if ( isset( $_POST['wpinv_discount_code'] ) ) {
316
+                $invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) );
317
+            }
318
+
319
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
320
+            if ( $discount->exists() ) {
321
+                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
322
+            } else {
323
+                $invoice->remove_discount( 'discount_code' );
324
+            }
325
+
326
+            // Recalculate totals.
327
+            $invoice->recalculate_total();
328
+
329
+        }
330
+
331
+        // If we're creating a new user...
332
+        if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) {
333
+
334
+            // Attempt to create the user.
335
+            $user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ), $invoice->get_first_name() . $invoice->get_last_name() );
336
+
337
+            // If successful, update the invoice author.
338
+            if ( is_numeric( $user ) ) {
339
+                $invoice->set_author( $user );
340
+            } else {
341
+                wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
342
+            }
343
+        }
344
+
345
+        // Do not send new invoice notifications.
346
+        $GLOBALS['wpinv_skip_invoice_notification'] = true;
347
+
348
+        // Save the invoice.
349
+        $invoice->save();
350
+
351
+        // Undo do not send new invoice notifications.
352
+        $GLOBALS['wpinv_skip_invoice_notification'] = false;
353
+
354
+        // (Maybe) send new user notification.
355
+        $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
356
+        if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
357
+            wp_send_new_user_notifications( $user, 'user' );
358
+        }
359
+
360
+        if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) {
361
+            getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true );
362
+        }
363
+
364
+        // Fires after an invoice is saved.
365
+        do_action( 'wpinv_invoice_metabox_saved', $invoice );
366
+    }
367 367
 }
Please login to merge, or discard this patch.
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
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
 
@@ -21,78 +21,78 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-	public static function output( $post ) {
24
+	public static function output($post) {
25 25
 
26 26
 		// Prepare the invoice.
27
-		$invoice  = new WPInv_Invoice( $post );
28
-		$customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id();
29
-		$customer = new WP_User( $customer );
30
-		$display  = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email );
31
-		wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
27
+		$invoice  = new WPInv_Invoice($post);
28
+		$customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id();
29
+		$customer = new WP_User($customer);
30
+		$display  = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email);
31
+		wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
32 32
 
33 33
 		// Address fields.
34 34
 		$address_fields = array(
35 35
 			'first_name' => array(
36
-				'label' => __( 'First Name', 'invoicing' ),
36
+				'label' => __('First Name', 'invoicing'),
37 37
 				'type'  => 'text',
38 38
 			),
39 39
 			'last_name'  => array(
40
-				'label' => __( 'Last Name', 'invoicing' ),
40
+				'label' => __('Last Name', 'invoicing'),
41 41
 				'type'  => 'text',
42 42
 			),
43 43
 			'company'    => array(
44
-				'label' => __( 'Company', 'invoicing' ),
44
+				'label' => __('Company', 'invoicing'),
45 45
 				'type'  => 'text',
46 46
 				'class' => 'getpaid-recalculate-prices-on-change',
47 47
 			),
48 48
 			'vat_number' => array(
49
-				'label' => __( 'VAT Number', 'invoicing' ),
49
+				'label' => __('VAT Number', 'invoicing'),
50 50
 				'type'  => 'text',
51 51
 			),
52 52
 			'address'    => array(
53
-				'label' => __( 'Address', 'invoicing' ),
53
+				'label' => __('Address', 'invoicing'),
54 54
 				'type'  => 'text',
55 55
 			),
56 56
 			'city'       => array(
57
-				'label' => __( 'City', 'invoicing' ),
57
+				'label' => __('City', 'invoicing'),
58 58
 				'type'  => 'text',
59 59
 			),
60 60
 			'country'    => array(
61
-				'label'       => __( 'Country', 'invoicing' ),
61
+				'label'       => __('Country', 'invoicing'),
62 62
 				'type'        => 'select',
63 63
 				'class'       => 'getpaid-recalculate-prices-on-change',
64 64
 				'options'     => wpinv_get_country_list(),
65
-				'placeholder' => __( 'Choose a country', 'invoicing' ),
65
+				'placeholder' => __('Choose a country', 'invoicing'),
66 66
 			),
67 67
 			'state'      => array(
68
-				'label' => __( 'State', 'invoicing' ),
68
+				'label' => __('State', 'invoicing'),
69 69
 				'type'  => 'text',
70 70
 				'class' => 'getpaid-recalculate-prices-on-change',
71 71
 			),
72 72
 			'zip'        => array(
73
-				'label' => __( 'Zip', 'invoicing' ),
73
+				'label' => __('Zip', 'invoicing'),
74 74
 				'type'  => 'text',
75 75
 			),
76 76
 			'phone'      => array(
77
-				'label' => __( 'Phone', 'invoicing' ),
77
+				'label' => __('Phone', 'invoicing'),
78 78
 				'type'  => 'text',
79 79
 			),
80 80
 		);
81 81
 
82
-		$states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
82
+		$states = wpinv_get_country_states($invoice->get_country('edit'));
83 83
 
84
-		if ( ! empty( $states ) ) {
84
+		if (!empty($states)) {
85 85
 			$address_fields['state']['type']        = 'select';
86 86
 			$address_fields['state']['options']     = $states;
87
-			$address_fields['state']['placeholder'] = __( 'Choose a state', 'invoicing' );
87
+			$address_fields['state']['placeholder'] = __('Choose a state', 'invoicing');
88 88
 		}
89 89
 
90 90
 		// Maybe remove the VAT field.
91
-		if ( ! wpinv_use_taxes() ) {
92
-			unset( $address_fields['vat_number'] );
91
+		if (!wpinv_use_taxes()) {
92
+			unset($address_fields['vat_number']);
93 93
 		}
94 94
 
95
-		$address_fields = apply_filters( 'getpaid_admin_edit_invoice_address_fields', $address_fields, $invoice );
95
+		$address_fields = apply_filters('getpaid_admin_edit_invoice_address_fields', $address_fields, $invoice);
96 96
 		?>
97 97
 
98 98
 		<style>
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 						<div class="col-12 col-sm-6">
107 107
 							<div id="getpaid-invoice-user-id-wrapper" class="form-group mb-3">
108 108
 								<div>
109
-									<label for="post_author_override"><?php esc_html_e( 'Customer', 'invoicing' ); ?></label>
109
+									<label for="post_author_override"><?php esc_html_e('Customer', 'invoicing'); ?></label>
110 110
 								</div>
111 111
 								<div>
112
-									<select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>">
113
-										<option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html( $display ); ?> </option>)
112
+									<select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>">
113
+										<option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html($display); ?> </option>)
114 114
 									</select>
115 115
 								</div>
116 116
 							</div>
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 											'type'        => 'text',
124 124
 											'id'          => 'getpaid-invoice-new-user-email',
125 125
 											'name'        => 'wpinv_email',
126
-											'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
126
+											'label'       => __('Email', 'invoicing') . '<span class="required">*</span>',
127 127
 											'label_type'  => 'vertical',
128 128
 											'placeholder' => '[email protected]',
129 129
 											'class'       => 'form-control-sm',
@@ -134,36 +134,36 @@  discard block
 block discarded – undo
134 134
 							</div>
135 135
 						</div>
136 136
 						<div class="col-12 col-sm-6 form-group mb-3 mt-sm-4">
137
-							<?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
137
+							<?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
138 138
 								<a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)">
139 139
 									<i aria-hidden="true" class="fa fa-refresh"></i>
140
-									<?php esc_html_e( 'Fill User Details', 'invoicing' ); ?>
140
+									<?php esc_html_e('Fill User Details', 'invoicing'); ?>
141 141
 								</a>
142 142
 								<a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)">
143 143
 									<i aria-hidden="true" class="fa fa-plus"></i>
144
-									<?php esc_html_e( 'Add New User', 'invoicing' ); ?>
144
+									<?php esc_html_e('Add New User', 'invoicing'); ?>
145 145
 								</a>
146 146
 								<a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)">
147 147
 									<i aria-hidden="true" class="fa fa-close"></i>
148
-									<?php esc_html_e( 'Cancel', 'invoicing' ); ?>
148
+									<?php esc_html_e('Cancel', 'invoicing'); ?>
149 149
 								</a>
150 150
 							<?php endif; ?>
151 151
 						</div>
152 152
 
153
-						<?php foreach ( $address_fields as $key => $field ) : ?>
154
-							<div class="col-12 col-sm-6 getpaid-invoice-address-field__<?php echo esc_attr( $key ); ?>--wrapper">
153
+						<?php foreach ($address_fields as $key => $field) : ?>
154
+							<div class="col-12 col-sm-6 getpaid-invoice-address-field__<?php echo esc_attr($key); ?>--wrapper">
155 155
 								<?php
156 156
 
157
-									if ( 'select' === $field['type'] ) {
157
+									if ('select' === $field['type']) {
158 158
 										aui()->select(
159 159
 											array(
160 160
 												'id'               => 'wpinv_' . $key,
161 161
 												'name'             => 'wpinv_' . $key,
162 162
 												'label'            => $field['label'],
163 163
 												'label_type'       => 'vertical',
164
-												'placeholder'      => isset( $field['placeholder'] ) ? $field['placeholder'] : '',
165
-												'class'            => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ),
166
-												'value'            => $invoice->get( $key, 'edit' ),
164
+												'placeholder'      => isset($field['placeholder']) ? $field['placeholder'] : '',
165
+												'class'            => 'form-control-sm ' . (isset($field['class']) ? $field['class'] : ''),
166
+												'value'            => $invoice->get($key, 'edit'),
167 167
 												'options'          => $field['options'],
168 168
 												'data-allow-clear' => 'false',
169 169
 												'select2'          => true,
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
 												'name'        => 'wpinv_' . $key,
179 179
 												'label'       => $field['label'],
180 180
 												'label_type'  => 'vertical',
181
-												'placeholder' => isset( $field['placeholder'] ) ? $field['placeholder'] : '',
182
-												'class'       => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ),
183
-												'value'       => $invoice->get( $key, 'edit' ),
181
+												'placeholder' => isset($field['placeholder']) ? $field['placeholder'] : '',
182
+												'class'       => 'form-control-sm ' . (isset($field['class']) ? $field['class'] : ''),
183
+												'value'       => $invoice->get($key, 'edit'),
184 184
 											),
185 185
 											true
186 186
 										);
@@ -191,8 +191,8 @@  discard block
 block discarded – undo
191 191
 						<?php endforeach; ?>
192 192
 					</div>
193 193
 
194
-					<?php if ( ! apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) : ?>
195
-						<?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
194
+					<?php if (!apply_filters('getpaid_use_new_invoice_items_metabox', false)) : ?>
195
+						<?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
196 196
 
197 197
 						<div class="row">
198 198
 							<div class="col-12 col-sm-6">
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
 										array(
202 202
 											'id'          => 'wpinv_template',
203 203
 											'name'        => 'wpinv_template',
204
-											'label'       => __( 'Template', 'invoicing' ),
204
+											'label'       => __('Template', 'invoicing'),
205 205
 											'label_type'  => 'vertical',
206
-											'placeholder' => __( 'Choose a template', 'invoicing' ),
206
+											'placeholder' => __('Choose a template', 'invoicing'),
207 207
 											'class'       => 'form-control-sm',
208
-											'value'       => $invoice->get_template( 'edit' ),
208
+											'value'       => $invoice->get_template('edit'),
209 209
 											'options'     => array(
210
-												'quantity' => __( 'Quantity', 'invoicing' ),
211
-												'hours'    => __( 'Hours', 'invoicing' ),
210
+												'quantity' => __('Quantity', 'invoicing'),
211
+												'hours'    => __('Hours', 'invoicing'),
212 212
 												//'amount'   => __( 'Amount Only', 'invoicing' ),
213 213
 											),
214 214
 											'data-allow-clear' => 'false',
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
 										array(
227 227
 											'id'          => 'wpinv_currency',
228 228
 											'name'        => 'wpinv_currency',
229
-											'label'       => __( 'Currency', 'invoicing' ),
229
+											'label'       => __('Currency', 'invoicing'),
230 230
 											'label_type'  => 'vertical',
231
-											'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
231
+											'placeholder' => __('Select Invoice Currency', 'invoicing'),
232 232
 											'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
233
-											'value'       => $invoice->get_currency( 'edit' ),
233
+											'value'       => $invoice->get_currency('edit'),
234 234
 											'required'    => false,
235 235
 											'data-allow-clear' => 'false',
236 236
 											'select2'     => true,
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 							</div>
244 244
 						</div>
245 245
 
246
-						<?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
246
+						<?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
247 247
 					<?php endif; ?>
248 248
 
249 249
 					<div class="row">
@@ -254,11 +254,11 @@  discard block
 block discarded – undo
254 254
 										'type'        => 'text',
255 255
 										'id'          => 'wpinv_company_id',
256 256
 										'name'        => 'wpinv_company_id',
257
-										'label'       => __( 'Company ID', 'invoicing' ),
257
+										'label'       => __('Company ID', 'invoicing'),
258 258
 										'label_type'  => 'vertical',
259 259
 										'placeholder' => '',
260 260
 										'class'       => 'form-control-sm',
261
-										'value'       => $invoice->get_company_id( 'edit' ),
261
+										'value'       => $invoice->get_company_id('edit'),
262 262
 									),
263 263
 									true
264 264
 								);
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 						</div>
267 267
 					</div>
268 268
 
269
-					<?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?>
269
+					<?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?>
270 270
 			</div>
271 271
 		<?php
272 272
 	}
@@ -276,51 +276,51 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @param int $post_id
278 278
 	 */
279
-	public static function save( $post_id ) {
279
+	public static function save($post_id) {
280 280
 
281 281
 		// Prepare the invoice.
282
-		$invoice = new WPInv_Invoice( $post_id );
282
+		$invoice = new WPInv_Invoice($post_id);
283 283
 
284 284
 		// Load new data.
285 285
 		$invoice->set_props(
286 286
 			array(
287
-				'template'       => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
288
-				'email_cc'       => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
289
-				'disable_taxes'  => ! empty( $_POST['disable_taxes'] ),
290
-				'currency'       => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null,
291
-				'gateway'        => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null,
292
-				'address'        => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null,
293
-				'vat_number'     => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null,
294
-				'company'        => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null,
295
-				'company_id'     => isset( $_POST['wpinv_company_id'] ) ? wpinv_clean( $_POST['wpinv_company_id'] ) : null,
296
-				'zip'            => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null,
297
-				'state'          => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null,
298
-				'city'           => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null,
299
-				'country'        => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null,
300
-				'phone'          => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null,
301
-				'first_name'     => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null,
302
-				'last_name'      => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null,
303
-				'author'         => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null,
304
-				'date_created'   => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null,
305
-				'date_completed' => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null,
306
-				'due_date'       => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
307
-				'number'         => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
308
-				'status'         => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
287
+				'template'       => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null,
288
+				'email_cc'       => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null,
289
+				'disable_taxes'  => !empty($_POST['disable_taxes']),
290
+				'currency'       => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null,
291
+				'gateway'        => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null,
292
+				'address'        => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null,
293
+				'vat_number'     => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null,
294
+				'company'        => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null,
295
+				'company_id'     => isset($_POST['wpinv_company_id']) ? wpinv_clean($_POST['wpinv_company_id']) : null,
296
+				'zip'            => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null,
297
+				'state'          => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null,
298
+				'city'           => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null,
299
+				'country'        => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null,
300
+				'phone'          => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null,
301
+				'first_name'     => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null,
302
+				'last_name'      => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null,
303
+				'author'         => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null,
304
+				'date_created'   => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null,
305
+				'date_completed' => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null,
306
+				'due_date'       => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null,
307
+				'number'         => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null,
308
+				'status'         => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null,
309 309
 			)
310 310
 		);
311 311
 
312 312
 		// Discount code.
313
-		if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
313
+		if (!$invoice->is_paid() && !$invoice->is_refunded()) {
314 314
 
315
-			if ( isset( $_POST['wpinv_discount_code'] ) ) {
316
-				$invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) );
315
+			if (isset($_POST['wpinv_discount_code'])) {
316
+				$invoice->set_discount_code(wpinv_clean($_POST['wpinv_discount_code']));
317 317
 			}
318 318
 
319
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
320
-			if ( $discount->exists() ) {
321
-				$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
319
+			$discount = new WPInv_Discount($invoice->get_discount_code());
320
+			if ($discount->exists()) {
321
+				$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
322 322
 			} else {
323
-				$invoice->remove_discount( 'discount_code' );
323
+				$invoice->remove_discount('discount_code');
324 324
 			}
325 325
 
326 326
 			// Recalculate totals.
@@ -329,16 +329,16 @@  discard block
 block discarded – undo
329 329
 		}
330 330
 
331 331
 		// If we're creating a new user...
332
-		if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) {
332
+		if (!empty($_POST['wpinv_new_user']) && is_email(stripslashes($_POST['wpinv_email']))) {
333 333
 
334 334
 			// Attempt to create the user.
335
-			$user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ), $invoice->get_first_name() . $invoice->get_last_name() );
335
+			$user = wpinv_create_user(sanitize_email(stripslashes($_POST['wpinv_email'])), $invoice->get_first_name() . $invoice->get_last_name());
336 336
 
337 337
 			// If successful, update the invoice author.
338
-			if ( is_numeric( $user ) ) {
339
-				$invoice->set_author( $user );
338
+			if (is_numeric($user)) {
339
+				$invoice->set_author($user);
340 340
 			} else {
341
-				wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
341
+				wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__);
342 342
 			}
343 343
 		}
344 344
 
@@ -352,16 +352,16 @@  discard block
 block discarded – undo
352 352
 		$GLOBALS['wpinv_skip_invoice_notification'] = false;
353 353
 
354 354
 		// (Maybe) send new user notification.
355
-		$should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
356
-		if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
357
-			wp_send_new_user_notifications( $user, 'user' );
355
+		$should_send_notification = wpinv_get_option('disable_new_user_emails');
356
+		if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) {
357
+			wp_send_new_user_notifications($user, 'user');
358 358
 		}
359 359
 
360
-		if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) {
361
-			getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true );
360
+		if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) {
361
+			getpaid()->get('invoice_emails')->user_invoice($invoice, true);
362 362
 		}
363 363
 
364 364
 		// Fires after an invoice is saved.
365
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
365
+		do_action('wpinv_invoice_metabox_saved', $invoice);
366 366
 	}
367 367
 }
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway.php 2 patches
Indentation   +366 added lines, -366 removed lines patch added patch discarded remove patch
@@ -13,97 +13,97 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Paypal_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'paypal';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34 34
     public $order = 1;
35 35
 
36 36
     /**
37
-	 * Stores line items to send to PayPal.
38
-	 *
39
-	 * @var array
40
-	 */
37
+     * Stores line items to send to PayPal.
38
+     *
39
+     * @var array
40
+     */
41 41
     protected $line_items = array();
42 42
 
43 43
     /**
44
-	 * Endpoint for requests from PayPal.
45
-	 *
46
-	 * @var string
47
-	 */
48
-	protected $notify_url;
49
-
50
-	/**
51
-	 * Endpoint for requests to PayPal.
52
-	 *
53
-	 * @var string
54
-	 */
44
+     * Endpoint for requests from PayPal.
45
+     *
46
+     * @var string
47
+     */
48
+    protected $notify_url;
49
+
50
+    /**
51
+     * Endpoint for requests to PayPal.
52
+     *
53
+     * @var string
54
+     */
55 55
     protected $endpoint;
56 56
 
57 57
     /**
58
-	 * Currencies this gateway is allowed for.
59
-	 *
60
-	 * @var array
61
-	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
58
+     * Currencies this gateway is allowed for.
59
+     *
60
+     * @var array
61
+     */
62
+    public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
63 63
 
64 64
     /**
65
-	 * URL to view a transaction.
66
-	 *
67
-	 * @var string
68
-	 */
65
+     * URL to view a transaction.
66
+     *
67
+     * @var string
68
+     */
69 69
     public $view_transaction_url = 'https://www.{sandbox}paypal.com/activity/payment/%s';
70 70
 
71 71
     /**
72
-	 * URL to view a subscription.
73
-	 *
74
-	 * @var string
75
-	 */
76
-	public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
72
+     * URL to view a subscription.
73
+     *
74
+     * @var string
75
+     */
76
+    public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
77 77
 
78 78
     /**
79
-	 * Class constructor.
80
-	 */
81
-	public function __construct() {
79
+     * Class constructor.
80
+     */
81
+    public function __construct() {
82 82
 
83 83
         $this->title                = __( 'PayPal Standard', 'invoicing' );
84 84
         $this->method_title         = __( 'PayPal Standard', 'invoicing' );
85 85
         $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' );
86 86
         $this->notify_url           = wpinv_get_ipn_url( $this->id );
87 87
 
88
-		add_filter( 'wpinv_subscription_cancel_url', array( $this, 'filter_cancel_subscription_url' ), 10, 2 );
89
-		add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
88
+        add_filter( 'wpinv_subscription_cancel_url', array( $this, 'filter_cancel_subscription_url' ), 10, 2 );
89
+        add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
90 90
         add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
91
-		add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
92
-		add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
93
-		add_action( 'wpinv_paypal_connect', array( $this, 'display_connect_buttons' ) );
94
-		parent::__construct();
91
+        add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
92
+        add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
93
+        add_action( 'wpinv_paypal_connect', array( $this, 'display_connect_buttons' ) );
94
+        parent::__construct();
95 95
     }
96 96
 
97 97
     /**
98
-	 * Process Payment.
99
-	 *
100
-	 *
101
-	 * @param WPInv_Invoice $invoice Invoice.
102
-	 * @param array $submission_data Posted checkout fields.
103
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
104
-	 * @return array
105
-	 */
106
-	public function process_payment( $invoice, $submission_data, $submission ) {
98
+     * Process Payment.
99
+     *
100
+     *
101
+     * @param WPInv_Invoice $invoice Invoice.
102
+     * @param array $submission_data Posted checkout fields.
103
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
104
+     * @return array
105
+     */
106
+    public function process_payment( $invoice, $submission_data, $submission ) {
107 107
 
108 108
         // Get redirect url.
109 109
         $paypal_redirect = $this->get_request_url( $invoice );
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
     }
127 127
 
128 128
     /**
129
-	 * Get the PayPal request URL for an invoice.
130
-	 *
131
-	 * @param  WPInv_Invoice $invoice Invoice object.
132
-	 * @return string
133
-	 */
134
-	public function get_request_url( $invoice ) {
129
+     * Get the PayPal request URL for an invoice.
130
+     *
131
+     * @param  WPInv_Invoice $invoice Invoice object.
132
+     * @return string
133
+     */
134
+    public function get_request_url( $invoice ) {
135 135
 
136 136
         // Endpoint for this request
137
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
137
+        $this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
138 138
 
139 139
         // Retrieve paypal args.
140 140
         $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
@@ -147,45 +147,45 @@  discard block
 block discarded – undo
147 147
 
148 148
         return add_query_arg( $paypal_args, $this->endpoint );
149 149
 
150
-	}
150
+    }
151 151
 
152 152
     /**
153
-	 * Get PayPal Args for passing to PP.
154
-	 *
155
-	 * @param  WPInv_Invoice $invoice Invoice object.
156
-	 * @return array
157
-	 */
158
-	protected function get_paypal_args( $invoice ) {
153
+     * Get PayPal Args for passing to PP.
154
+     *
155
+     * @param  WPInv_Invoice $invoice Invoice object.
156
+     * @return array
157
+     */
158
+    protected function get_paypal_args( $invoice ) {
159 159
 
160 160
         // Whether or not to send the line items as one item.
161
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
162
-
163
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
164
-			$force_one_line_item = true;
165
-		}
166
-
167
-		$paypal_args = apply_filters(
168
-			'getpaid_paypal_args',
169
-			array_merge(
170
-				$this->get_transaction_args( $invoice ),
171
-				$this->get_line_item_args( $invoice, $force_one_line_item )
172
-			),
173
-			$invoice
174
-		);
175
-
176
-		return $this->fix_request_length( $invoice, $paypal_args );
161
+        $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
162
+
163
+        if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
164
+            $force_one_line_item = true;
165
+        }
166
+
167
+        $paypal_args = apply_filters(
168
+            'getpaid_paypal_args',
169
+            array_merge(
170
+                $this->get_transaction_args( $invoice ),
171
+                $this->get_line_item_args( $invoice, $force_one_line_item )
172
+            ),
173
+            $invoice
174
+        );
175
+
176
+        return $this->fix_request_length( $invoice, $paypal_args );
177 177
     }
178 178
 
179 179
     /**
180
-	 * Get transaction args for paypal request.
181
-	 *
182
-	 * @param WPInv_Invoice $invoice Invoice object.
183
-	 * @return array
184
-	 */
185
-	protected function get_transaction_args( $invoice ) {
186
-
187
-		$email = $this->is_sandbox( $invoice ) ? wpinv_get_option( 'paypal_sandbox_email', wpinv_get_option( 'paypal_email', '' ) ) : wpinv_get_option( 'paypal_email', '' );
188
-		return array(
180
+     * Get transaction args for paypal request.
181
+     *
182
+     * @param WPInv_Invoice $invoice Invoice object.
183
+     * @return array
184
+     */
185
+    protected function get_transaction_args( $invoice ) {
186
+
187
+        $email = $this->is_sandbox( $invoice ) ? wpinv_get_option( 'paypal_sandbox_email', wpinv_get_option( 'paypal_email', '' ) ) : wpinv_get_option( 'paypal_email', '' );
188
+        return array(
189 189
             'cmd'           => '_cart',
190 190
             'business'      => $email,
191 191
             'no_shipping'   => '1',
@@ -210,16 +210,16 @@  discard block
 block discarded – undo
210 210
     }
211 211
 
212 212
     /**
213
-	 * Get line item args for paypal request.
214
-	 *
215
-	 * @param  WPInv_Invoice $invoice Invoice object.
216
-	 * @param  bool     $force_one_line_item Create only one item for this invoice.
217
-	 * @return array
218
-	 */
219
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
213
+     * Get line item args for paypal request.
214
+     *
215
+     * @param  WPInv_Invoice $invoice Invoice object.
216
+     * @param  bool     $force_one_line_item Create only one item for this invoice.
217
+     * @return array
218
+     */
219
+    protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
220 220
 
221 221
         // Maybe send invoice as a single item.
222
-		if ( $force_one_line_item ) {
222
+        if ( $force_one_line_item ) {
223 223
             return $this->get_line_item_args_single_item( $invoice );
224 224
         }
225 225
 
@@ -239,129 +239,129 @@  discard block
 block discarded – undo
239 239
             $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
240 240
         }
241 241
 
242
-		return array_merge( $line_item_args, $this->get_line_items() );
242
+        return array_merge( $line_item_args, $this->get_line_items() );
243 243
 
244 244
     }
245 245
 
246 246
     /**
247
-	 * Get line item args for paypal request as a single line item.
248
-	 *
249
-	 * @param  WPInv_Invoice $invoice Invoice object.
250
-	 * @return array
251
-	 */
252
-	protected function get_line_item_args_single_item( $invoice ) {
253
-		$this->delete_line_items();
247
+     * Get line item args for paypal request as a single line item.
248
+     *
249
+     * @param  WPInv_Invoice $invoice Invoice object.
250
+     * @return array
251
+     */
252
+    protected function get_line_item_args_single_item( $invoice ) {
253
+        $this->delete_line_items();
254 254
 
255 255
         $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
256
-		$this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
256
+        $this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
257 257
 
258
-		return $this->get_line_items();
258
+        return $this->get_line_items();
259 259
     }
260 260
 
261 261
     /**
262
-	 * Return all line items.
263
-	 */
264
-	protected function get_line_items() {
265
-		return $this->line_items;
266
-	}
262
+     * Return all line items.
263
+     */
264
+    protected function get_line_items() {
265
+        return $this->line_items;
266
+    }
267 267
 
268 268
     /**
269
-	 * Remove all line items.
270
-	 */
271
-	protected function delete_line_items() {
272
-		$this->line_items = array();
269
+     * Remove all line items.
270
+     */
271
+    protected function delete_line_items() {
272
+        $this->line_items = array();
273 273
     }
274 274
 
275 275
     /**
276
-	 * Prepare line items to send to paypal.
277
-	 *
278
-	 * @param  WPInv_Invoice $invoice Invoice object.
279
-	 */
280
-	protected function prepare_line_items( $invoice ) {
281
-		$this->delete_line_items();
282
-
283
-		// Items.
284
-		foreach ( $invoice->get_items() as $item ) {
285
-			$amount   = $item->get_price();
286
-			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
287
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
276
+     * Prepare line items to send to paypal.
277
+     *
278
+     * @param  WPInv_Invoice $invoice Invoice object.
279
+     */
280
+    protected function prepare_line_items( $invoice ) {
281
+        $this->delete_line_items();
282
+
283
+        // Items.
284
+        foreach ( $invoice->get_items() as $item ) {
285
+            $amount   = $item->get_price();
286
+            $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
287
+            $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
288 288
         }
289 289
 
290 290
         // Fees.
291
-		foreach ( $invoice->get_fees() as $fee => $data ) {
291
+        foreach ( $invoice->get_fees() as $fee => $data ) {
292 292
             $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) );
293 293
         }
294 294
 
295 295
     }
296 296
 
297 297
     /**
298
-	 * Add PayPal Line Item.
299
-	 *
300
-	 * @param  string $item_name Item name.
301
-	 * @param  float    $quantity Item quantity.
302
-	 * @param  float  $amount Amount.
303
-	 * @param  string $item_number Item number.
304
-	 */
305
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
306
-		$index = ( count( $this->line_items ) / 4 ) + 1;
307
-
308
-		$item = apply_filters(
309
-			'getpaid_paypal_line_item',
310
-			array(
311
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
312
-				'quantity'    => (float) $quantity,
313
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
314
-				'item_number' => $item_number,
315
-			),
316
-			$item_name,
317
-			$quantity,
318
-			$amount,
319
-			$item_number
320
-		);
321
-
322
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
298
+     * Add PayPal Line Item.
299
+     *
300
+     * @param  string $item_name Item name.
301
+     * @param  float    $quantity Item quantity.
302
+     * @param  float  $amount Amount.
303
+     * @param  string $item_number Item number.
304
+     */
305
+    protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
306
+        $index = ( count( $this->line_items ) / 4 ) + 1;
307
+
308
+        $item = apply_filters(
309
+            'getpaid_paypal_line_item',
310
+            array(
311
+                'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
312
+                'quantity'    => (float) $quantity,
313
+                'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
314
+                'item_number' => $item_number,
315
+            ),
316
+            $item_name,
317
+            $quantity,
318
+            $amount,
319
+            $item_number
320
+        );
321
+
322
+        $this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
323 323
         $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
324 324
 
325 325
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
326
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
327
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
326
+        $this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
327
+        $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
328 328
     }
329 329
 
330 330
     /**
331
-	 * If the default request with line items is too long, generate a new one with only one line item.
332
-	 *
333
-	 * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
334
-	 *
335
-	 * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
336
-	 * @param array    $paypal_args Arguments sent to Paypal in the request.
337
-	 * @return array
338
-	 */
339
-	protected function fix_request_length( $invoice, $paypal_args ) {
340
-		$max_paypal_length = 2083;
341
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
342
-
343
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
344
-			return $paypal_args;
345
-		}
346
-
347
-		return apply_filters(
348
-			'getpaid_paypal_args',
349
-			array_merge(
350
-				$this->get_transaction_args( $invoice ),
351
-				$this->get_line_item_args( $invoice, true )
352
-			),
353
-			$invoice
354
-		);
331
+     * If the default request with line items is too long, generate a new one with only one line item.
332
+     *
333
+     * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
334
+     *
335
+     * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
336
+     * @param array    $paypal_args Arguments sent to Paypal in the request.
337
+     * @return array
338
+     */
339
+    protected function fix_request_length( $invoice, $paypal_args ) {
340
+        $max_paypal_length = 2083;
341
+        $query_candidate   = http_build_query( $paypal_args, '', '&' );
342
+
343
+        if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
344
+            return $paypal_args;
345
+        }
346
+
347
+        return apply_filters(
348
+            'getpaid_paypal_args',
349
+            array_merge(
350
+                $this->get_transaction_args( $invoice ),
351
+                $this->get_line_item_args( $invoice, true )
352
+            ),
353
+            $invoice
354
+        );
355 355
 
356 356
     }
357 357
 
358 358
     /**
359
-	 * Processes recurring invoices.
360
-	 *
361
-	 * @param  array $paypal_args PayPal args.
362
-	 * @param  WPInv_Invoice    $invoice Invoice object.
363
-	 */
364
-	public function process_subscription( $paypal_args, $invoice ) {
359
+     * Processes recurring invoices.
360
+     *
361
+     * @param  array $paypal_args PayPal args.
362
+     * @param  WPInv_Invoice    $invoice Invoice object.
363
+     */
364
+    public function process_subscription( $paypal_args, $invoice ) {
365 365
 
366 366
         // Make sure this is a subscription.
367 367
         if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) {
@@ -382,21 +382,21 @@  discard block
 block discarded – undo
382 382
         $recurring_amount       = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 );
383 383
         $subscription_item      = $invoice->get_recurring( true );
384 384
 
385
-		// Convert 365 days to 1 year.
386
-		if ( 'D' == $period && 365 == $interval ) {
387
-			$period = 'Y';
388
-			$interval = 1;
389
-		}
385
+        // Convert 365 days to 1 year.
386
+        if ( 'D' == $period && 365 == $interval ) {
387
+            $period = 'Y';
388
+            $interval = 1;
389
+        }
390 390
 
391 391
         if ( $subscription_item->has_free_trial() ) {
392 392
 
393 393
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
394 394
 
395
-			// Trial period length.
396
-			$paypal_args['p1'] = $subscription_item->get_trial_interval();
395
+            // Trial period length.
396
+            $paypal_args['p1'] = $subscription_item->get_trial_interval();
397 397
 
398
-			// Trial period.
399
-			$paypal_args['t1'] = $subscription_item->get_trial_period();
398
+            // Trial period.
399
+            $paypal_args['t1'] = $subscription_item->get_trial_period();
400 400
 
401 401
         } elseif ( $initial_amount != $recurring_amount ) {
402 402
 
@@ -419,40 +419,40 @@  discard block
 block discarded – undo
419 419
         }
420 420
 
421 421
         // We have a recurring payment
422
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
422
+        if ( ! isset( $param_number ) || 1 == $param_number ) {
423 423
 
424
-			// Subscription price
425
-			$paypal_args['a3'] = $recurring_amount;
424
+            // Subscription price
425
+            $paypal_args['a3'] = $recurring_amount;
426 426
 
427
-			// Subscription duration
428
-			$paypal_args['p3'] = $interval;
427
+            // Subscription duration
428
+            $paypal_args['p3'] = $interval;
429 429
 
430
-			// Subscription period
431
-			$paypal_args['t3'] = $period;
430
+            // Subscription period
431
+            $paypal_args['t3'] = $period;
432 432
 
433 433
         }
434 434
 
435 435
         // Recurring payments
436
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
436
+        if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
437 437
 
438
-			// Non-recurring payments
439
-			$paypal_args['src'] = 0;
438
+            // Non-recurring payments
439
+            $paypal_args['src'] = 0;
440 440
 
441
-		} else {
441
+        } else {
442 442
 
443
-			$paypal_args['src'] = 1;
443
+            $paypal_args['src'] = 1;
444 444
 
445
-			if ( $bill_times > 0 ) {
445
+            if ( $bill_times > 0 ) {
446 446
 
447
-				// An initial period is being used to charge a sign-up fee
448
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
449
-					$bill_times--;
450
-				}
447
+                // An initial period is being used to charge a sign-up fee
448
+                if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
449
+                    $bill_times--;
450
+                }
451 451
 
452 452
                 // Make sure it's not over the max of 52
453 453
                 $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
454 454
 
455
-			}
455
+            }
456 456
         }
457 457
 
458 458
         // Force return URL so that order description & instructions display
@@ -467,19 +467,19 @@  discard block
 block discarded – undo
467 467
 }
468 468
 
469 469
         return apply_filters(
470
-			'getpaid_paypal_subscription_args',
471
-			$paypal_args,
472
-			$invoice
470
+            'getpaid_paypal_subscription_args',
471
+            $paypal_args,
472
+            $invoice
473 473
         );
474 474
 
475 475
     }
476 476
 
477 477
     /**
478
-	 * Processes ipns and marks payments as complete.
479
-	 *
480
-	 * @return void
481
-	 */
482
-	public function verify_ipn() {
478
+     * Processes ipns and marks payments as complete.
479
+     *
480
+     * @return void
481
+     */
482
+    public function verify_ipn() {
483 483
         new GetPaid_Paypal_Gateway_IPN_Handler( $this );
484 484
     }
485 485
 
@@ -489,19 +489,19 @@  discard block
 block discarded – undo
489 489
     public function sandbox_notice() {
490 490
 
491 491
         return sprintf(
492
-			__( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %1$sPayPal Sandbox Testing Guide%2$s for more details.', 'invoicing' ),
493
-			'<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
494
-			'</a>'
495
-		);
492
+            __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %1$sPayPal Sandbox Testing Guide%2$s for more details.', 'invoicing' ),
493
+            '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
494
+            '</a>'
495
+        );
496 496
 
497 497
     }
498 498
 
499
-	/**
500
-	 * Filters the gateway settings.
501
-	 *
502
-	 * @param array $admin_settings
503
-	 */
504
-	public function admin_settings( $admin_settings ) {
499
+    /**
500
+     * Filters the gateway settings.
501
+     *
502
+     * @param array $admin_settings
503
+     */
504
+    public function admin_settings( $admin_settings ) {
505 505
 
506 506
         $currencies = sprintf(
507 507
             __( 'Supported Currencies: %s', 'invoicing' ),
@@ -511,31 +511,31 @@  discard block
 block discarded – undo
511 511
         $admin_settings['paypal_active']['desc'] .= " ($currencies)";
512 512
         $admin_settings['paypal_desc']['std']     = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
513 513
 
514
-		// Access tokens.
515
-		$live_email      = wpinv_get_option( 'paypal_email' );
516
-		$sandbox_email   = wpinv_get_option( 'paypal_sandbox_email' );
514
+        // Access tokens.
515
+        $live_email      = wpinv_get_option( 'paypal_email' );
516
+        $sandbox_email   = wpinv_get_option( 'paypal_sandbox_email' );
517 517
 
518
-		$admin_settings['paypal_connect'] = array(
519
-			'type' => 'hook',
520
-			'id'   => 'paypal_connect',
521
-			'name' => __( 'Connect to PayPal', 'invoicing' ),
522
-		);
518
+        $admin_settings['paypal_connect'] = array(
519
+            'type' => 'hook',
520
+            'id'   => 'paypal_connect',
521
+            'name' => __( 'Connect to PayPal', 'invoicing' ),
522
+        );
523 523
 
524 524
         $admin_settings['paypal_email'] = array(
525 525
             'type'  => 'text',
526
-			'class' => 'live-auth-data',
526
+            'class' => 'live-auth-data',
527 527
             'id'    => 'paypal_email',
528 528
             'name'  => __( 'Live Email Address', 'invoicing' ),
529 529
             'desc'  => __( 'The email address of your PayPal account.', 'invoicing' ),
530 530
         );
531 531
 
532
-		$admin_settings['paypal_sandbox_email'] = array(
532
+        $admin_settings['paypal_sandbox_email'] = array(
533 533
             'type'  => 'text',
534
-			'class' => 'sandbox-auth-data',
534
+            'class' => 'sandbox-auth-data',
535 535
             'id'    => 'paypal_sandbox_email',
536 536
             'name'  => __( 'Sandbox Email Address', 'invoicing' ),
537 537
             'desc'  => __( 'The email address of your sandbox PayPal account.', 'invoicing' ),
538
-			'std'   => wpinv_get_option( 'paypal_email', '' ),
538
+            'std'   => wpinv_get_option( 'paypal_email', '' ),
539 539
         );
540 540
 
541 541
         $admin_settings['paypal_ipn_url'] = array(
@@ -547,57 +547,57 @@  discard block
 block discarded – undo
547 547
             'readonly' => true,
548 548
         );
549 549
 
550
-		return $admin_settings;
551
-	}
552
-
553
-	/**
554
-	 * Retrieves the URL to cancel a subscription.
555
-	 *
556
-	 * @param string $url
557
-	 * @param WPInv_Subscription $subscription
558
-	 */
559
-	public function filter_cancel_subscription_url( $url, $subscription ) {
560
-
561
-		if ( $this->id !== $subscription->get_gateway() ) {
562
-			return $url;
563
-		}
564
-
565
-		// Get the PayPal profile ID.
566
-		$profile_id = $subscription->get_profile_id();
567
-
568
-		// Bail if no profile ID.
569
-		if ( empty( $profile_id ) ) {
570
-			return $url;
571
-		}
572
-
573
-		$cancel_url = 'https://www.paypal.com/myaccount/autopay/connect/%s/cancel';
574
-		if ( $this->is_sandbox( $subscription->get_parent_payment() ) ) {
575
-			$cancel_url = 'https://www.sandbox.paypal.com/myaccount/autopay/connect/%s/cancel';
576
-		}
577
-
578
-		return sprintf( $cancel_url, $profile_id );
579
-	}
580
-
581
-	/**
582
-	 * Retrieves the PayPal connect URL when using the setup wizzard.
583
-	 *
584
-	 *
550
+        return $admin_settings;
551
+    }
552
+
553
+    /**
554
+     * Retrieves the URL to cancel a subscription.
555
+     *
556
+     * @param string $url
557
+     * @param WPInv_Subscription $subscription
558
+     */
559
+    public function filter_cancel_subscription_url( $url, $subscription ) {
560
+
561
+        if ( $this->id !== $subscription->get_gateway() ) {
562
+            return $url;
563
+        }
564
+
565
+        // Get the PayPal profile ID.
566
+        $profile_id = $subscription->get_profile_id();
567
+
568
+        // Bail if no profile ID.
569
+        if ( empty( $profile_id ) ) {
570
+            return $url;
571
+        }
572
+
573
+        $cancel_url = 'https://www.paypal.com/myaccount/autopay/connect/%s/cancel';
574
+        if ( $this->is_sandbox( $subscription->get_parent_payment() ) ) {
575
+            $cancel_url = 'https://www.sandbox.paypal.com/myaccount/autopay/connect/%s/cancel';
576
+        }
577
+
578
+        return sprintf( $cancel_url, $profile_id );
579
+    }
580
+
581
+    /**
582
+     * Retrieves the PayPal connect URL when using the setup wizzard.
583
+     *
584
+     *
585 585
      * @param array $data
586 586
      * @return string
587
-	 */
588
-	public static function maybe_get_connect_url( $url = '', $data = array() ) {
589
-		return self::get_connect_url( false, urldecode( $data['redirect'] ) );
590
-	}
591
-
592
-	/**
593
-	 * Retrieves the PayPal connect URL.
594
-	 *
595
-	 *
587
+     */
588
+    public static function maybe_get_connect_url( $url = '', $data = array() ) {
589
+        return self::get_connect_url( false, urldecode( $data['redirect'] ) );
590
+    }
591
+
592
+    /**
593
+     * Retrieves the PayPal connect URL.
594
+     *
595
+     *
596 596
      * @param bool $is_sandbox
597
-	 * @param string $redirect
597
+     * @param string $redirect
598 598
      * @return string
599
-	 */
600
-	public static function get_connect_url( $is_sandbox, $redirect = '' ) {
599
+     */
600
+    public static function get_connect_url( $is_sandbox, $redirect = '' ) {
601 601
 
602 602
         $redirect_url = add_query_arg(
603 603
             array(
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
                 'tab'                  => 'gateways',
608 608
                 'section'              => 'paypal',
609 609
                 'getpaid-nonce'        => wp_create_nonce( 'getpaid-nonce' ),
610
-				'redirect'             => urlencode( $redirect ),
610
+                'redirect'             => urlencode( $redirect ),
611 611
             ),
612 612
             admin_url( 'admin.php' )
613 613
         );
@@ -622,12 +622,12 @@  discard block
 block discarded – undo
622 622
 
623 623
     }
624 624
 
625
-	/**
626
-	 * Generates settings page js.
627
-	 *
625
+    /**
626
+     * Generates settings page js.
627
+     *
628 628
      * @return void
629
-	 */
630
-	public static function display_connect_buttons() {
629
+     */
630
+    public static function display_connect_buttons() {
631 631
 
632 632
         ?>
633 633
 			<div class="wpinv-paypal-connect-live">
@@ -669,70 +669,70 @@  discard block
 block discarded – undo
669 669
         <?php
670 670
     }
671 671
 
672
-	/**
673
-	 * Connects to PayPal.
674
-	 *
675
-	 * @param array $data Connection data.
676
-	 * @return void
677
-	 */
678
-	public function connect_paypal( $data ) {
679
-
680
-		$sandbox      = $this->is_sandbox();
681
-		$data         = wp_unslash( $data );
682
-		$access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
683
-
684
-		if ( isset( $data['live_mode'] ) ) {
685
-			$sandbox = empty( $data['live_mode'] );
686
-		}
687
-
688
-		wpinv_update_option( 'paypal_sandbox', (int) $sandbox );
689
-		wpinv_update_option( 'paypal_active', 1 );
690
-
691
-		if ( ! empty( $data['error_description'] ) ) {
692
-			getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
693
-		} else {
694
-
695
-			// Retrieve the user info.
696
-			$user_info = wp_remote_get(
697
-				! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
698
-				array(
699
-
700
-					'headers' => array(
701
-						'Authorization' => 'Bearer ' . $access_token,
702
-						'Content-type'  => 'application/json',
703
-					),
704
-
705
-				)
706
-			);
707
-
708
-			if ( is_wp_error( $user_info ) ) {
709
-				getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
710
-			} else {
711
-
712
-				// Create application.
713
-				$user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
714
-
715
-				if ( $sandbox ) {
716
-					wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
717
-					wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
718
-					set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
719
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) );
720
-				} else {
721
-					wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
722
-					wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
723
-					set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
724
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) );
725
-				}
672
+    /**
673
+     * Connects to PayPal.
674
+     *
675
+     * @param array $data Connection data.
676
+     * @return void
677
+     */
678
+    public function connect_paypal( $data ) {
679
+
680
+        $sandbox      = $this->is_sandbox();
681
+        $data         = wp_unslash( $data );
682
+        $access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
683
+
684
+        if ( isset( $data['live_mode'] ) ) {
685
+            $sandbox = empty( $data['live_mode'] );
686
+        }
687
+
688
+        wpinv_update_option( 'paypal_sandbox', (int) $sandbox );
689
+        wpinv_update_option( 'paypal_active', 1 );
690
+
691
+        if ( ! empty( $data['error_description'] ) ) {
692
+            getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
693
+        } else {
694
+
695
+            // Retrieve the user info.
696
+            $user_info = wp_remote_get(
697
+                ! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
698
+                array(
699
+
700
+                    'headers' => array(
701
+                        'Authorization' => 'Bearer ' . $access_token,
702
+                        'Content-type'  => 'application/json',
703
+                    ),
704
+
705
+                )
706
+            );
707
+
708
+            if ( is_wp_error( $user_info ) ) {
709
+                getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
710
+            } else {
711
+
712
+                // Create application.
713
+                $user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
714
+
715
+                if ( $sandbox ) {
716
+                    wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
717
+                    wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
718
+                    set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
719
+                    getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) );
720
+                } else {
721
+                    wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
722
+                    wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
723
+                    set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
724
+                    getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) );
725
+                }
726 726
 }
727 727
 }
728 728
 
729
-		$redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
729
+        $redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
730 730
 
731
-		if ( isset( $data['step'] ) ) {
732
-			$redirect = add_query_arg( 'step', $data['step'], $redirect );
733
-		}
734
-		wp_redirect( $redirect );
735
-		exit;
736
-	}
731
+        if ( isset( $data['step'] ) ) {
732
+            $redirect = add_query_arg( 'step', $data['step'], $redirect );
733
+        }
734
+        wp_redirect( $redirect );
735
+        exit;
736
+    }
737 737
 
738 738
 }
Please login to merge, or discard this patch.
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Paypal Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group' );
27
+    protected $supports = array('subscription', 'sandbox', 'single_subscription_group');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @var array
61 61
 	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
62
+	public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR');
63 63
 
64 64
     /**
65 65
 	 * URL to view a transaction.
@@ -80,17 +80,17 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function __construct() {
82 82
 
83
-        $this->title                = __( 'PayPal Standard', 'invoicing' );
84
-        $this->method_title         = __( 'PayPal Standard', 'invoicing' );
85
-        $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' );
86
-        $this->notify_url           = wpinv_get_ipn_url( $this->id );
87
-
88
-		add_filter( 'wpinv_subscription_cancel_url', array( $this, 'filter_cancel_subscription_url' ), 10, 2 );
89
-		add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
90
-        add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
91
-		add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
92
-		add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
93
-		add_action( 'wpinv_paypal_connect', array( $this, 'display_connect_buttons' ) );
83
+        $this->title                = __('PayPal Standard', 'invoicing');
84
+        $this->method_title         = __('PayPal Standard', 'invoicing');
85
+        $this->checkout_button_text = __('Proceed to PayPal', 'invoicing');
86
+        $this->notify_url           = wpinv_get_ipn_url($this->id);
87
+
88
+		add_filter('wpinv_subscription_cancel_url', array($this, 'filter_cancel_subscription_url'), 10, 2);
89
+		add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2);
90
+        add_filter('getpaid_paypal_sandbox_notice', array($this, 'sandbox_notice'));
91
+		add_filter('getpaid_get_paypal_connect_url', array($this, 'maybe_get_connect_url'), 10, 2);
92
+		add_action('getpaid_authenticated_admin_action_connect_paypal', array($this, 'connect_paypal'));
93
+		add_action('wpinv_paypal_connect', array($this, 'display_connect_buttons'));
94 94
 		parent::__construct();
95 95
     }
96 96
 
@@ -103,16 +103,16 @@  discard block
 block discarded – undo
103 103
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
104 104
 	 * @return array
105 105
 	 */
106
-	public function process_payment( $invoice, $submission_data, $submission ) {
106
+	public function process_payment($invoice, $submission_data, $submission) {
107 107
 
108 108
         // Get redirect url.
109
-        $paypal_redirect = $this->get_request_url( $invoice );
109
+        $paypal_redirect = $this->get_request_url($invoice);
110 110
 
111 111
         // Add a note about the request url.
112 112
         $invoice->add_note(
113 113
             sprintf(
114
-                __( 'Redirecting to PayPal: %s', 'invoicing' ),
115
-                esc_url( $paypal_redirect )
114
+                __('Redirecting to PayPal: %s', 'invoicing'),
115
+                esc_url($paypal_redirect)
116 116
             ),
117 117
             false,
118 118
             false,
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         );
121 121
 
122 122
         // Redirect to PayPal
123
-        wp_redirect( $paypal_redirect );
123
+        wp_redirect($paypal_redirect);
124 124
         exit;
125 125
 
126 126
     }
@@ -131,21 +131,21 @@  discard block
 block discarded – undo
131 131
 	 * @param  WPInv_Invoice $invoice Invoice object.
132 132
 	 * @return string
133 133
 	 */
134
-	public function get_request_url( $invoice ) {
134
+	public function get_request_url($invoice) {
135 135
 
136 136
         // Endpoint for this request
137
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
137
+		$this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
138 138
 
139 139
         // Retrieve paypal args.
140
-        $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
140
+        $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode');
141 141
 
142
-        if ( $invoice->is_recurring() ) {
142
+        if ($invoice->is_recurring()) {
143 143
             $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US';
144 144
         } else {
145 145
             $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US';
146 146
         }
147 147
 
148
-        return add_query_arg( $paypal_args, $this->endpoint );
148
+        return add_query_arg($paypal_args, $this->endpoint);
149 149
 
150 150
 	}
151 151
 
@@ -155,25 +155,25 @@  discard block
 block discarded – undo
155 155
 	 * @param  WPInv_Invoice $invoice Invoice object.
156 156
 	 * @return array
157 157
 	 */
158
-	protected function get_paypal_args( $invoice ) {
158
+	protected function get_paypal_args($invoice) {
159 159
 
160 160
         // Whether or not to send the line items as one item.
161
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
161
+		$force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', true, $invoice);
162 162
 
163
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
163
+		if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) {
164 164
 			$force_one_line_item = true;
165 165
 		}
166 166
 
167 167
 		$paypal_args = apply_filters(
168 168
 			'getpaid_paypal_args',
169 169
 			array_merge(
170
-				$this->get_transaction_args( $invoice ),
171
-				$this->get_line_item_args( $invoice, $force_one_line_item )
170
+				$this->get_transaction_args($invoice),
171
+				$this->get_line_item_args($invoice, $force_one_line_item)
172 172
 			),
173 173
 			$invoice
174 174
 		);
175 175
 
176
-		return $this->fix_request_length( $invoice, $paypal_args );
176
+		return $this->fix_request_length($invoice, $paypal_args);
177 177
     }
178 178
 
179 179
     /**
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
 	 * @param WPInv_Invoice $invoice Invoice object.
183 183
 	 * @return array
184 184
 	 */
185
-	protected function get_transaction_args( $invoice ) {
185
+	protected function get_transaction_args($invoice) {
186 186
 
187
-		$email = $this->is_sandbox( $invoice ) ? wpinv_get_option( 'paypal_sandbox_email', wpinv_get_option( 'paypal_email', '' ) ) : wpinv_get_option( 'paypal_email', '' );
187
+		$email = $this->is_sandbox($invoice) ? wpinv_get_option('paypal_sandbox_email', wpinv_get_option('paypal_email', '')) : wpinv_get_option('paypal_email', '');
188 188
 		return array(
189 189
             'cmd'           => '_cart',
190 190
             'business'      => $email,
@@ -195,16 +195,16 @@  discard block
 block discarded – undo
195 195
             'rm'            => is_ssl() ? 2 : 1,
196 196
             'upload'        => 1,
197 197
             'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal
198
-            'return'        => esc_url_raw( $this->get_return_url( $invoice ) ),
199
-            'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ),
200
-            'notify_url'    => getpaid_limit_length( $this->notify_url, 255 ),
201
-            'invoice'       => getpaid_limit_length( $invoice->get_number(), 127 ),
198
+            'return'        => esc_url_raw($this->get_return_url($invoice)),
199
+            'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()),
200
+            'notify_url'    => getpaid_limit_length($this->notify_url, 255),
201
+            'invoice'       => getpaid_limit_length($invoice->get_number(), 127),
202 202
             'custom'        => $invoice->get_id(),
203
-            'first_name'    => getpaid_limit_length( $invoice->get_first_name(), 32 ),
204
-            'last_name'     => getpaid_limit_length( $invoice->get_last_name(), 64 ),
205
-            'country'       => getpaid_limit_length( $invoice->get_country(), 2 ),
206
-            'email'         => getpaid_limit_length( $invoice->get_email(), 127 ),
207
-            'cbt'           => get_bloginfo( 'name' ),
203
+            'first_name'    => getpaid_limit_length($invoice->get_first_name(), 32),
204
+            'last_name'     => getpaid_limit_length($invoice->get_last_name(), 64),
205
+            'country'       => getpaid_limit_length($invoice->get_country(), 2),
206
+            'email'         => getpaid_limit_length($invoice->get_email(), 127),
207
+            'cbt'           => get_bloginfo('name'),
208 208
         );
209 209
 
210 210
     }
@@ -216,30 +216,30 @@  discard block
 block discarded – undo
216 216
 	 * @param  bool     $force_one_line_item Create only one item for this invoice.
217 217
 	 * @return array
218 218
 	 */
219
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
219
+	protected function get_line_item_args($invoice, $force_one_line_item = false) {
220 220
 
221 221
         // Maybe send invoice as a single item.
222
-		if ( $force_one_line_item ) {
223
-            return $this->get_line_item_args_single_item( $invoice );
222
+		if ($force_one_line_item) {
223
+            return $this->get_line_item_args_single_item($invoice);
224 224
         }
225 225
 
226 226
         // Send each line item individually.
227 227
         $line_item_args = array();
228 228
 
229 229
         // Prepare line items.
230
-        $this->prepare_line_items( $invoice );
230
+        $this->prepare_line_items($invoice);
231 231
 
232 232
         // Add taxes to the cart
233
-        if ( wpinv_use_taxes() && $invoice->is_taxable() ) {
234
-            $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 );
233
+        if (wpinv_use_taxes() && $invoice->is_taxable()) {
234
+            $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2);
235 235
         }
236 236
 
237 237
         // Add discount.
238
-        if ( $invoice->get_total_discount() > 0 ) {
239
-            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
238
+        if ($invoice->get_total_discount() > 0) {
239
+            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2);
240 240
         }
241 241
 
242
-		return array_merge( $line_item_args, $this->get_line_items() );
242
+		return array_merge($line_item_args, $this->get_line_items());
243 243
 
244 244
     }
245 245
 
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
 	 * @param  WPInv_Invoice $invoice Invoice object.
250 250
 	 * @return array
251 251
 	 */
252
-	protected function get_line_item_args_single_item( $invoice ) {
252
+	protected function get_line_item_args_single_item($invoice) {
253 253
 		$this->delete_line_items();
254 254
 
255
-        $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
256
-		$this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
255
+        $item_name = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number());
256
+		$this->add_line_item($item_name, 1, wpinv_round_amount((float) $invoice->get_total(), 2, true), $invoice->get_id());
257 257
 
258 258
 		return $this->get_line_items();
259 259
     }
@@ -277,19 +277,19 @@  discard block
 block discarded – undo
277 277
 	 *
278 278
 	 * @param  WPInv_Invoice $invoice Invoice object.
279 279
 	 */
280
-	protected function prepare_line_items( $invoice ) {
280
+	protected function prepare_line_items($invoice) {
281 281
 		$this->delete_line_items();
282 282
 
283 283
 		// Items.
284
-		foreach ( $invoice->get_items() as $item ) {
284
+		foreach ($invoice->get_items() as $item) {
285 285
 			$amount   = $item->get_price();
286 286
 			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
287
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
287
+			$this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id());
288 288
         }
289 289
 
290 290
         // Fees.
291
-		foreach ( $invoice->get_fees() as $fee => $data ) {
292
-            $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) );
291
+		foreach ($invoice->get_fees() as $fee => $data) {
292
+            $this->add_line_item($fee, 1, wpinv_sanitize_amount($data['initial_fee']));
293 293
         }
294 294
 
295 295
     }
@@ -302,15 +302,15 @@  discard block
 block discarded – undo
302 302
 	 * @param  float  $amount Amount.
303 303
 	 * @param  string $item_number Item number.
304 304
 	 */
305
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
306
-		$index = ( count( $this->line_items ) / 4 ) + 1;
305
+	protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') {
306
+		$index = (count($this->line_items) / 4) + 1;
307 307
 
308 308
 		$item = apply_filters(
309 309
 			'getpaid_paypal_line_item',
310 310
 			array(
311
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
311
+				'item_name'   => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'),
312 312
 				'quantity'    => (float) $quantity,
313
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
313
+				'amount'      => wpinv_sanitize_amount((float) $amount, 2),
314 314
 				'item_number' => $item_number,
315 315
 			),
316 316
 			$item_name,
@@ -319,12 +319,12 @@  discard block
 block discarded – undo
319 319
 			$item_number
320 320
 		);
321 321
 
322
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
323
-        $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
322
+		$this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127);
323
+        $this->line_items['quantity_' . $index] = $item['quantity'];
324 324
 
325 325
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
326
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
327
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
326
+		$this->line_items['amount_' . $index]      = $item['amount'] * $item['quantity'];
327
+		$this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127);
328 328
     }
329 329
 
330 330
     /**
@@ -336,19 +336,19 @@  discard block
 block discarded – undo
336 336
 	 * @param array    $paypal_args Arguments sent to Paypal in the request.
337 337
 	 * @return array
338 338
 	 */
339
-	protected function fix_request_length( $invoice, $paypal_args ) {
339
+	protected function fix_request_length($invoice, $paypal_args) {
340 340
 		$max_paypal_length = 2083;
341
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
341
+		$query_candidate   = http_build_query($paypal_args, '', '&');
342 342
 
343
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
343
+		if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) {
344 344
 			return $paypal_args;
345 345
 		}
346 346
 
347 347
 		return apply_filters(
348 348
 			'getpaid_paypal_args',
349 349
 			array_merge(
350
-				$this->get_transaction_args( $invoice ),
351
-				$this->get_line_item_args( $invoice, true )
350
+				$this->get_transaction_args($invoice),
351
+				$this->get_line_item_args($invoice, true)
352 352
 			),
353 353
 			$invoice
354 354
 		);
@@ -361,10 +361,10 @@  discard block
 block discarded – undo
361 361
 	 * @param  array $paypal_args PayPal args.
362 362
 	 * @param  WPInv_Invoice    $invoice Invoice object.
363 363
 	 */
364
-	public function process_subscription( $paypal_args, $invoice ) {
364
+	public function process_subscription($paypal_args, $invoice) {
365 365
 
366 366
         // Make sure this is a subscription.
367
-        if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) {
367
+        if (!$invoice->is_recurring() || !$subscription = getpaid_get_invoice_subscription($invoice)) {
368 368
             return $paypal_args;
369 369
         }
370 370
 
@@ -372,23 +372,23 @@  discard block
 block discarded – undo
372 372
         $paypal_args['cmd'] = '_xclick-subscriptions';
373 373
 
374 374
         // Subscription name.
375
-        $paypal_args['item_name'] = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
375
+        $paypal_args['item_name'] = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number());
376 376
 
377 377
         // Get subscription args.
378
-        $period                 = strtoupper( substr( $subscription->get_period(), 0, 1 ) );
378
+        $period                 = strtoupper(substr($subscription->get_period(), 0, 1));
379 379
         $interval               = (int) $subscription->get_frequency();
380 380
         $bill_times             = (int) $subscription->get_bill_times();
381
-        $initial_amount         = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 );
382
-        $recurring_amount       = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 );
383
-        $subscription_item      = $invoice->get_recurring( true );
381
+        $initial_amount         = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2);
382
+        $recurring_amount       = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2);
383
+        $subscription_item      = $invoice->get_recurring(true);
384 384
 
385 385
 		// Convert 365 days to 1 year.
386
-		if ( 'D' == $period && 365 == $interval ) {
386
+		if ('D' == $period && 365 == $interval) {
387 387
 			$period = 'Y';
388 388
 			$interval = 1;
389 389
 		}
390 390
 
391
-        if ( $subscription_item->has_free_trial() ) {
391
+        if ($subscription_item->has_free_trial()) {
392 392
 
393 393
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
394 394
 
@@ -398,28 +398,28 @@  discard block
 block discarded – undo
398 398
 			// Trial period.
399 399
 			$paypal_args['t1'] = $subscription_item->get_trial_period();
400 400
 
401
-        } elseif ( $initial_amount != $recurring_amount ) {
401
+        } elseif ($initial_amount != $recurring_amount) {
402 402
 
403 403
             // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period.
404 404
 
405
-            if ( 1 == $bill_times ) {
405
+            if (1 == $bill_times) {
406 406
                 $param_number = 3;
407 407
             } else {
408 408
                 $param_number = 1;
409 409
             }
410 410
 
411
-            $paypal_args[ 'a' . $param_number ] = $initial_amount ? $initial_amount : 0;
411
+            $paypal_args['a' . $param_number] = $initial_amount ? $initial_amount : 0;
412 412
 
413 413
             // Sign Up interval
414
-            $paypal_args[ 'p' . $param_number ] = $interval;
414
+            $paypal_args['p' . $param_number] = $interval;
415 415
 
416 416
             // Sign Up unit of duration
417
-            $paypal_args[ 't' . $param_number ] = $period;
417
+            $paypal_args['t' . $param_number] = $period;
418 418
 
419 419
         }
420 420
 
421 421
         // We have a recurring payment
422
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
422
+		if (!isset($param_number) || 1 == $param_number) {
423 423
 
424 424
 			// Subscription price
425 425
 			$paypal_args['a3'] = $recurring_amount;
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
         }
434 434
 
435 435
         // Recurring payments
436
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
436
+		if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) {
437 437
 
438 438
 			// Non-recurring payments
439 439
 			$paypal_args['src'] = 0;
@@ -442,15 +442,15 @@  discard block
 block discarded – undo
442 442
 
443 443
 			$paypal_args['src'] = 1;
444 444
 
445
-			if ( $bill_times > 0 ) {
445
+			if ($bill_times > 0) {
446 446
 
447 447
 				// An initial period is being used to charge a sign-up fee
448
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
448
+				if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) {
449 449
 					$bill_times--;
450 450
 				}
451 451
 
452 452
                 // Make sure it's not over the max of 52
453
-                $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
453
+                $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
454 454
 
455 455
 			}
456 456
         }
@@ -459,10 +459,10 @@  discard block
 block discarded – undo
459 459
         $paypal_args['rm'] = 2;
460 460
 
461 461
         // Get rid of redudant items.
462
-        foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) {
462
+        foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) {
463 463
 
464
-            if ( isset( $paypal_args[ $arg ] ) ) {
465
-                unset( $paypal_args[ $arg ] );
464
+            if (isset($paypal_args[$arg])) {
465
+                unset($paypal_args[$arg]);
466 466
             }
467 467
 }
468 468
 
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 	 * @return void
481 481
 	 */
482 482
 	public function verify_ipn() {
483
-        new GetPaid_Paypal_Gateway_IPN_Handler( $this );
483
+        new GetPaid_Paypal_Gateway_IPN_Handler($this);
484 484
     }
485 485
 
486 486
     /**
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
     public function sandbox_notice() {
490 490
 
491 491
         return sprintf(
492
-			__( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %1$sPayPal Sandbox Testing Guide%2$s for more details.', 'invoicing' ),
492
+			__('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %1$sPayPal Sandbox Testing Guide%2$s for more details.', 'invoicing'),
493 493
 			'<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
494 494
 			'</a>'
495 495
 		);
@@ -501,49 +501,49 @@  discard block
 block discarded – undo
501 501
 	 *
502 502
 	 * @param array $admin_settings
503 503
 	 */
504
-	public function admin_settings( $admin_settings ) {
504
+	public function admin_settings($admin_settings) {
505 505
 
506 506
         $currencies = sprintf(
507
-            __( 'Supported Currencies: %s', 'invoicing' ),
508
-            implode( ', ', $this->currencies )
507
+            __('Supported Currencies: %s', 'invoicing'),
508
+            implode(', ', $this->currencies)
509 509
         );
510 510
 
511 511
         $admin_settings['paypal_active']['desc'] .= " ($currencies)";
512
-        $admin_settings['paypal_desc']['std']     = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
512
+        $admin_settings['paypal_desc']['std']     = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
513 513
 
514 514
 		// Access tokens.
515
-		$live_email      = wpinv_get_option( 'paypal_email' );
516
-		$sandbox_email   = wpinv_get_option( 'paypal_sandbox_email' );
515
+		$live_email      = wpinv_get_option('paypal_email');
516
+		$sandbox_email   = wpinv_get_option('paypal_sandbox_email');
517 517
 
518 518
 		$admin_settings['paypal_connect'] = array(
519 519
 			'type' => 'hook',
520 520
 			'id'   => 'paypal_connect',
521
-			'name' => __( 'Connect to PayPal', 'invoicing' ),
521
+			'name' => __('Connect to PayPal', 'invoicing'),
522 522
 		);
523 523
 
524 524
         $admin_settings['paypal_email'] = array(
525 525
             'type'  => 'text',
526 526
 			'class' => 'live-auth-data',
527 527
             'id'    => 'paypal_email',
528
-            'name'  => __( 'Live Email Address', 'invoicing' ),
529
-            'desc'  => __( 'The email address of your PayPal account.', 'invoicing' ),
528
+            'name'  => __('Live Email Address', 'invoicing'),
529
+            'desc'  => __('The email address of your PayPal account.', 'invoicing'),
530 530
         );
531 531
 
532 532
 		$admin_settings['paypal_sandbox_email'] = array(
533 533
             'type'  => 'text',
534 534
 			'class' => 'sandbox-auth-data',
535 535
             'id'    => 'paypal_sandbox_email',
536
-            'name'  => __( 'Sandbox Email Address', 'invoicing' ),
537
-            'desc'  => __( 'The email address of your sandbox PayPal account.', 'invoicing' ),
538
-			'std'   => wpinv_get_option( 'paypal_email', '' ),
536
+            'name'  => __('Sandbox Email Address', 'invoicing'),
537
+            'desc'  => __('The email address of your sandbox PayPal account.', 'invoicing'),
538
+			'std'   => wpinv_get_option('paypal_email', ''),
539 539
         );
540 540
 
541 541
         $admin_settings['paypal_ipn_url'] = array(
542 542
             'type'     => 'ipn_url',
543 543
             'id'       => 'paypal_ipn_url',
544
-            'name'     => __( 'IPN Url', 'invoicing' ),
544
+            'name'     => __('IPN Url', 'invoicing'),
545 545
             'std'      => $this->notify_url,
546
-            'desc'     => __( "If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing' ) . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
546
+            'desc'     => __("If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing') . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
547 547
             'readonly' => true,
548 548
         );
549 549
 
@@ -556,9 +556,9 @@  discard block
 block discarded – undo
556 556
 	 * @param string $url
557 557
 	 * @param WPInv_Subscription $subscription
558 558
 	 */
559
-	public function filter_cancel_subscription_url( $url, $subscription ) {
559
+	public function filter_cancel_subscription_url($url, $subscription) {
560 560
 
561
-		if ( $this->id !== $subscription->get_gateway() ) {
561
+		if ($this->id !== $subscription->get_gateway()) {
562 562
 			return $url;
563 563
 		}
564 564
 
@@ -566,16 +566,16 @@  discard block
 block discarded – undo
566 566
 		$profile_id = $subscription->get_profile_id();
567 567
 
568 568
 		// Bail if no profile ID.
569
-		if ( empty( $profile_id ) ) {
569
+		if (empty($profile_id)) {
570 570
 			return $url;
571 571
 		}
572 572
 
573 573
 		$cancel_url = 'https://www.paypal.com/myaccount/autopay/connect/%s/cancel';
574
-		if ( $this->is_sandbox( $subscription->get_parent_payment() ) ) {
574
+		if ($this->is_sandbox($subscription->get_parent_payment())) {
575 575
 			$cancel_url = 'https://www.sandbox.paypal.com/myaccount/autopay/connect/%s/cancel';
576 576
 		}
577 577
 
578
-		return sprintf( $cancel_url, $profile_id );
578
+		return sprintf($cancel_url, $profile_id);
579 579
 	}
580 580
 
581 581
 	/**
@@ -585,8 +585,8 @@  discard block
 block discarded – undo
585 585
      * @param array $data
586 586
      * @return string
587 587
 	 */
588
-	public static function maybe_get_connect_url( $url = '', $data = array() ) {
589
-		return self::get_connect_url( false, urldecode( $data['redirect'] ) );
588
+	public static function maybe_get_connect_url($url = '', $data = array()) {
589
+		return self::get_connect_url(false, urldecode($data['redirect']));
590 590
 	}
591 591
 
592 592
 	/**
@@ -597,25 +597,25 @@  discard block
 block discarded – undo
597 597
 	 * @param string $redirect
598 598
      * @return string
599 599
 	 */
600
-	public static function get_connect_url( $is_sandbox, $redirect = '' ) {
600
+	public static function get_connect_url($is_sandbox, $redirect = '') {
601 601
 
602 602
         $redirect_url = add_query_arg(
603 603
             array(
604 604
                 'getpaid-admin-action' => 'connect_paypal',
605 605
                 'page'                 => 'wpinv-settings',
606
-                'live_mode'            => (int) empty( $is_sandbox ),
606
+                'live_mode'            => (int) empty($is_sandbox),
607 607
                 'tab'                  => 'gateways',
608 608
                 'section'              => 'paypal',
609
-                'getpaid-nonce'        => wp_create_nonce( 'getpaid-nonce' ),
610
-				'redirect'             => urlencode( $redirect ),
609
+                'getpaid-nonce'        => wp_create_nonce('getpaid-nonce'),
610
+				'redirect'             => urlencode($redirect),
611 611
             ),
612
-            admin_url( 'admin.php' )
612
+            admin_url('admin.php')
613 613
         );
614 614
 
615 615
         return add_query_arg(
616 616
             array(
617
-                'live_mode'    => (int) empty( $is_sandbox ),
618
-                'redirect_url' => urlencode( str_replace( '&amp;', '&', $redirect_url ) ),
617
+                'live_mode'    => (int) empty($is_sandbox),
618
+                'redirect_url' => urlencode(str_replace('&amp;', '&', $redirect_url)),
619 619
             ),
620 620
             'https://ayecode.io/oauth/paypal'
621 621
         );
@@ -631,10 +631,10 @@  discard block
 block discarded – undo
631 631
 
632 632
         ?>
633 633
 			<div class="wpinv-paypal-connect-live">
634
-				<a class="button button-primary" href="<?php echo esc_url( self::get_connect_url( false ) ); ?>"><?php esc_html_e( 'Connect to PayPal', 'invoicing' ); ?></a>
634
+				<a class="button button-primary" href="<?php echo esc_url(self::get_connect_url(false)); ?>"><?php esc_html_e('Connect to PayPal', 'invoicing'); ?></a>
635 635
 			</div>
636 636
 			<div class="wpinv-paypal-connect-sandbox">
637
-				<a class="button button-primary" href="<?php echo esc_url( self::get_connect_url( true ) ); ?>"><?php esc_html_e( 'Connect to PayPal Sandbox', 'invoicing' ); ?></a>
637
+				<a class="button button-primary" href="<?php echo esc_url(self::get_connect_url(true)); ?>"><?php esc_html_e('Connect to PayPal Sandbox', 'invoicing'); ?></a>
638 638
 			</div>
639 639
 
640 640
             <script>
@@ -675,26 +675,26 @@  discard block
 block discarded – undo
675 675
 	 * @param array $data Connection data.
676 676
 	 * @return void
677 677
 	 */
678
-	public function connect_paypal( $data ) {
678
+	public function connect_paypal($data) {
679 679
 
680 680
 		$sandbox      = $this->is_sandbox();
681
-		$data         = wp_unslash( $data );
682
-		$access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
681
+		$data         = wp_unslash($data);
682
+		$access_token = empty($data['access_token']) ? '' : sanitize_text_field($data['access_token']);
683 683
 
684
-		if ( isset( $data['live_mode'] ) ) {
685
-			$sandbox = empty( $data['live_mode'] );
684
+		if (isset($data['live_mode'])) {
685
+			$sandbox = empty($data['live_mode']);
686 686
 		}
687 687
 
688
-		wpinv_update_option( 'paypal_sandbox', (int) $sandbox );
689
-		wpinv_update_option( 'paypal_active', 1 );
688
+		wpinv_update_option('paypal_sandbox', (int) $sandbox);
689
+		wpinv_update_option('paypal_active', 1);
690 690
 
691
-		if ( ! empty( $data['error_description'] ) ) {
692
-			getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
691
+		if (!empty($data['error_description'])) {
692
+			getpaid_admin()->show_error(wp_kses_post(urldecode($data['error_description'])));
693 693
 		} else {
694 694
 
695 695
 			// Retrieve the user info.
696 696
 			$user_info = wp_remote_get(
697
-				! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
697
+				!$sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
698 698
 				array(
699 699
 
700 700
 					'headers' => array(
@@ -705,33 +705,33 @@  discard block
 block discarded – undo
705 705
 				)
706 706
 			);
707 707
 
708
-			if ( is_wp_error( $user_info ) ) {
709
-				getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
708
+			if (is_wp_error($user_info)) {
709
+				getpaid_admin()->show_error(wp_kses_post($user_info->get_error_message()));
710 710
 			} else {
711 711
 
712 712
 				// Create application.
713
-				$user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
713
+				$user_info = json_decode(wp_remote_retrieve_body($user_info));
714 714
 
715
-				if ( $sandbox ) {
716
-					wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
717
-					wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
718
-					set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
719
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) );
715
+				if ($sandbox) {
716
+					wpinv_update_option('paypal_sandbox_email', sanitize_email($user_info->emails[0]->value));
717
+					wpinv_update_option('paypal_sandbox_refresh_token', sanitize_text_field(urldecode($data['refresh_token'])));
718
+					set_transient('getpaid_paypal_sandbox_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']);
719
+					getpaid_admin()->show_success(__('Successfully connected your PayPal sandbox account', 'invoicing'));
720 720
 				} else {
721
-					wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
722
-					wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
723
-					set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
724
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) );
721
+					wpinv_update_option('paypal_email', sanitize_email($user_info->emails[0]->value));
722
+					wpinv_update_option('paypal_refresh_token', sanitize_text_field(urldecode($data['refresh_token'])));
723
+					set_transient('getpaid_paypal_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']);
724
+					getpaid_admin()->show_success(__('Successfully connected your PayPal account', 'invoicing'));
725 725
 				}
726 726
 }
727 727
 }
728 728
 
729
-		$redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
729
+		$redirect = empty($data['redirect']) ? admin_url('admin.php?page=wpinv-settings&tab=gateways&section=paypal') : urldecode($data['redirect']);
730 730
 
731
-		if ( isset( $data['step'] ) ) {
732
-			$redirect = add_query_arg( 'step', $data['step'], $redirect );
731
+		if (isset($data['step'])) {
732
+			$redirect = add_query_arg('step', $data['step'], $redirect);
733 733
 		}
734
-		wp_redirect( $redirect );
734
+		wp_redirect($redirect);
735 735
 		exit;
736 736
 	}
737 737
 
Please login to merge, or discard this patch.