Passed
Push — master ( eba4be...60f62d )
by Brian
09:36 queued 04:47
created
includes/class-wpinv-ajax.php 2 patches
Indentation   +58 added lines, -58 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 )
@@ -577,24 +577,24 @@  discard block
 block discarded – undo
577 577
         }
578 578
 
579 579
         // Is the request set up correctly?
580
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
581
-			echo aui()->alert(
582
-				array(
583
-					'type'    => 'warning',
584
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
585
-				)
580
+        if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
581
+            echo aui()->alert(
582
+                array(
583
+                    'type'    => 'warning',
584
+                    'content' => __( 'No payment form or item provided', 'invoicing' ),
585
+                )
586 586
             );
587 587
             exit;
588 588
         }
589 589
 
590 590
         // Payment form or button?
591
-		if ( ! empty( $_GET['form'] ) ) {
591
+        if ( ! empty( $_GET['form'] ) ) {
592 592
             echo getpaid_display_payment_form( $_GET['form'] );
593
-		} else if( $_GET['invoice'] ) {
594
-		    echo getpaid_display_invoice_payment_form( $_GET['invoice'] );
593
+        } else if( $_GET['invoice'] ) {
594
+            echo getpaid_display_invoice_payment_form( $_GET['invoice'] );
595 595
         } else {
596
-			$items = getpaid_convert_items_to_array( $_GET['item'] );
597
-		    echo getpaid_display_item_payment_form( $items );
596
+            $items = getpaid_convert_items_to_array( $_GET['item'] );
597
+            echo getpaid_display_item_payment_form( $items );
598 598
         }
599 599
         
600 600
         exit;
Please login to merge, or discard this patch.
Spacing   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * WPInv_Ajax class.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	 * Hook in ajax handlers.
18 18
 	 */
19 19
 	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
20
+		add_action('init', array(__CLASS__, 'define_ajax'), 0);
21
+		add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0);
22 22
 		self::add_ajax_events();
23 23
     }
24 24
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function define_ajax() {
29 29
 
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
30
+		if (!empty($_GET['wpinv-ajax'])) {
31
+			getpaid_maybe_define_constant('DOING_AJAX', true);
32
+			getpaid_maybe_define_constant('WPInv_DOING_AJAX', true);
33
+			if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) {
34
+				/** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0);
35 35
 			}
36 36
 			$GLOBALS['wpdb']->hide_errors();
37 37
 		}
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	 * @since 1.0.18
45 45
 	 */
46 46
 	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
47
+		if (!headers_sent()) {
48 48
 			send_origin_headers();
49 49
 			send_nosniff_header();
50 50
 			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
51
+			header('Content-Type: text/html; charset=' . get_option('blog_charset'));
52
+			header('X-Robots-Tag: noindex');
53
+			status_header(200);
54 54
 		}
55 55
     }
56 56
     
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 	public static function do_wpinv_ajax() {
61 61
 		global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
63
+		if (!empty($_GET['wpinv-ajax'])) {
64
+			$wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax'])));
65 65
 		}
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+		$action = $wp_query->get('wpinv-ajax');
68 68
 
69
-		if ( $action ) {
69
+		if ($action) {
70 70
 			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
71
+			$action = sanitize_text_field($action);
72
+			do_action('wpinv_ajax_' . $action);
73 73
 			wp_die();
74 74
 		}
75 75
 
@@ -102,36 +102,36 @@  discard block
 block discarded – undo
102 102
             'payment_form_refresh_prices' => true,
103 103
         );
104 104
 
105
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
106
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
107
-            add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
105
+        foreach ($ajax_events as $ajax_event => $nopriv) {
106
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
107
+            add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
108 108
 
109
-            if ( $nopriv ) {
110
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
111
-                add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
112
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
109
+            if ($nopriv) {
110
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
111
+                add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
112
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
113 113
             }
114 114
         }
115 115
     }
116 116
     
117 117
     public static function add_note() {
118
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
118
+        check_ajax_referer('add-invoice-note', '_nonce');
119 119
 
120
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
120
+        if (!wpinv_current_user_can_manage_invoicing()) {
121 121
             die(-1);
122 122
         }
123 123
 
124
-        $post_id   = absint( $_POST['post_id'] );
125
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
126
-        $note_type = sanitize_text_field( $_POST['note_type'] );
124
+        $post_id   = absint($_POST['post_id']);
125
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
126
+        $note_type = sanitize_text_field($_POST['note_type']);
127 127
 
128 128
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
129 129
 
130
-        if ( $post_id > 0 ) {
131
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
130
+        if ($post_id > 0) {
131
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
132 132
 
133
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
134
-                wpinv_get_invoice_note_line_item( $note_id );
133
+            if ($note_id > 0 && !is_wp_error($note_id)) {
134
+                wpinv_get_invoice_note_line_item($note_id);
135 135
             }
136 136
         }
137 137
 
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
     }
140 140
 
141 141
     public static function delete_note() {
142
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
142
+        check_ajax_referer('delete-invoice-note', '_nonce');
143 143
 
144
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
144
+        if (!wpinv_current_user_can_manage_invoicing()) {
145 145
             die(-1);
146 146
         }
147 147
 
148
-        $note_id = (int)$_POST['note_id'];
148
+        $note_id = (int) $_POST['note_id'];
149 149
 
150
-        if ( $note_id > 0 ) {
151
-            wp_delete_comment( $note_id, true );
150
+        if ($note_id > 0) {
151
+            wp_delete_comment($note_id, true);
152 152
         }
153 153
 
154 154
         die();
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
     }
162 162
     
163 163
     public static function checkout() {
164
-        if ( ! defined( 'WPINV_CHECKOUT' ) ) {
165
-            define( 'WPINV_CHECKOUT', true );
164
+        if (!defined('WPINV_CHECKOUT')) {
165
+            define('WPINV_CHECKOUT', true);
166 166
         }
167 167
 
168 168
         wpinv_process_checkout();
@@ -175,34 +175,34 @@  discard block
 block discarded – undo
175 175
     public static function get_billing_details() {
176 176
 
177 177
         // Verify nonce.
178
-        check_ajax_referer( 'wpinv-nonce' );
178
+        check_ajax_referer('wpinv-nonce');
179 179
 
180 180
         // Can the user manage the plugin?
181
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
181
+        if (!wpinv_current_user_can_manage_invoicing()) {
182 182
             die(-1);
183 183
         }
184 184
 
185 185
         // Do we have a user id?
186 186
         $user_id = $_GET['user_id'];
187 187
 
188
-        if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
188
+        if (empty($user_id) || !is_numeric($user_id)) {
189 189
             die(-1);
190 190
         }
191 191
 
192 192
         // Fetch the billing details.
193
-        $billing_details    = wpinv_get_user_address( $user_id );
194
-        $billing_details    = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id );
193
+        $billing_details    = wpinv_get_user_address($user_id);
194
+        $billing_details    = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id);
195 195
 
196 196
         // unset the user id and email.
197
-        $to_ignore = array( 'user_id', 'email' );
197
+        $to_ignore = array('user_id', 'email');
198 198
 
199
-        foreach ( $to_ignore as $key ) {
200
-            if ( isset( $billing_details[ $key ] ) ) {
201
-                unset( $billing_details[ $key ] );
199
+        foreach ($to_ignore as $key) {
200
+            if (isset($billing_details[$key])) {
201
+                unset($billing_details[$key]);
202 202
             }
203 203
         }
204 204
 
205
-        wp_send_json_success( $billing_details );
205
+        wp_send_json_success($billing_details);
206 206
 
207 207
     }
208 208
 
@@ -212,47 +212,47 @@  discard block
 block discarded – undo
212 212
     public static function check_new_user_email() {
213 213
 
214 214
         // Verify nonce.
215
-        check_ajax_referer( 'wpinv-nonce' );
215
+        check_ajax_referer('wpinv-nonce');
216 216
 
217 217
         // Can the user manage the plugin?
218
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
218
+        if (!wpinv_current_user_can_manage_invoicing()) {
219 219
             die(-1);
220 220
         }
221 221
 
222 222
         // We need an email address.
223
-        if ( empty( $_GET['email'] ) ) {
224
-            _e( "Provide the new user's email address", 'invoicing' );
223
+        if (empty($_GET['email'])) {
224
+            _e("Provide the new user's email address", 'invoicing');
225 225
             exit;
226 226
         }
227 227
 
228 228
         // Ensure the email is valid.
229
-        $email = sanitize_text_field( $_GET['email'] );
230
-        if ( ! is_email( $email ) ) {
231
-            _e( 'Invalid email address', 'invoicing' );
229
+        $email = sanitize_text_field($_GET['email']);
230
+        if (!is_email($email)) {
231
+            _e('Invalid email address', 'invoicing');
232 232
             exit;
233 233
         }
234 234
 
235 235
         // And it does not exist.
236
-        if ( email_exists( $email ) ) {
237
-            _e( 'A user with this email address already exists', 'invoicing' );
236
+        if (email_exists($email)) {
237
+            _e('A user with this email address already exists', 'invoicing');
238 238
             exit;
239 239
         }
240 240
 
241
-        wp_send_json_success( true );
241
+        wp_send_json_success(true);
242 242
     }
243 243
     
244 244
     public static function run_tool() {
245
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
246
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
245
+        check_ajax_referer('wpinv-nonce', '_nonce');
246
+        if (!wpinv_current_user_can_manage_invoicing()) {
247 247
             die(-1);
248 248
         }
249 249
         
250
-        $tool = sanitize_text_field( $_POST['tool'] );
250
+        $tool = sanitize_text_field($_POST['tool']);
251 251
         
252
-        do_action( 'wpinv_run_tool' );
252
+        do_action('wpinv_run_tool');
253 253
         
254
-        if ( !empty( $tool ) ) {
255
-            do_action( 'wpinv_tool_' . $tool );
254
+        if (!empty($tool)) {
255
+            do_action('wpinv_tool_' . $tool);
256 256
         }
257 257
     }
258 258
 
@@ -262,30 +262,30 @@  discard block
 block discarded – undo
262 262
     public static function get_payment_form() {
263 263
 
264 264
         // Check nonce.
265
-        if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'getpaid_ajax_form' ) ) {
266
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
265
+        if (!isset($_GET['nonce']) || !wp_verify_nonce($_GET['nonce'], 'getpaid_ajax_form')) {
266
+            _e('Error: Reload the page and try again.', 'invoicing');
267 267
             exit;
268 268
         }
269 269
 
270 270
         // Is the request set up correctly?
271
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
271
+		if (empty($_GET['form']) && empty($_GET['item'])) {
272 272
 			echo aui()->alert(
273 273
 				array(
274 274
 					'type'    => 'warning',
275
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
275
+					'content' => __('No payment form or item provided', 'invoicing'),
276 276
 				)
277 277
             );
278 278
             exit;
279 279
         }
280 280
 
281 281
         // Payment form or button?
282
-		if ( ! empty( $_GET['form'] ) ) {
283
-            echo getpaid_display_payment_form( $_GET['form'] );
284
-		} else if( $_GET['invoice'] ) {
285
-		    echo getpaid_display_invoice_payment_form( $_GET['invoice'] );
282
+		if (!empty($_GET['form'])) {
283
+            echo getpaid_display_payment_form($_GET['form']);
284
+		} else if ($_GET['invoice']) {
285
+		    echo getpaid_display_invoice_payment_form($_GET['invoice']);
286 286
         } else {
287
-			$items = getpaid_convert_items_to_array( $_GET['item'] );
288
-		    echo getpaid_display_item_payment_form( $items );
287
+			$items = getpaid_convert_items_to_array($_GET['item']);
288
+		    echo getpaid_display_item_payment_form($items);
289 289
         }
290 290
         
291 291
         exit;
@@ -301,11 +301,11 @@  discard block
 block discarded – undo
301 301
         global $invoicing, $wpi_checkout_id, $cart_total;
302 302
 
303 303
         // Check nonce.
304
-        check_ajax_referer( 'getpaid_form_nonce' );
304
+        check_ajax_referer('getpaid_form_nonce');
305 305
 
306 306
         // ... form fields...
307
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
308
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
307
+        if (empty($_POST['getpaid_payment_form_submission'])) {
308
+            _e('Error: Reload the page and try again.', 'invoicing');
309 309
             exit;
310 310
         }
311 311
 
@@ -313,25 +313,25 @@  discard block
 block discarded – undo
313 313
         $submission = new GetPaid_Payment_Form_Submission();
314 314
 
315 315
         // Do we have an error?
316
-        if ( ! empty( $submission->last_error ) ) {
316
+        if (!empty($submission->last_error)) {
317 317
             echo $submission->last_error;
318 318
             exit;
319 319
         }
320 320
 
321 321
         // We need a billing email.
322
-        if ( ! $submission->has_billing_email() || ! is_email( $submission->get_billing_email() ) ) {
323
-            wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
322
+        if (!$submission->has_billing_email() || !is_email($submission->get_billing_email())) {
323
+            wp_send_json_error(__('Provide a valid billing email.', 'invoicing'));
324 324
         }
325 325
 
326 326
         // Prepare items.
327 327
         $items            = $submission->get_items();
328 328
         $prepared_items   = array();
329 329
 
330
-        if ( ! empty( $items ) ) {
330
+        if (!empty($items)) {
331 331
 
332
-            foreach( $items as $item_id => $item ) {
332
+            foreach ($items as $item_id => $item) {
333 333
 
334
-                if ( $item->can_purchase() ) {
334
+                if ($item->can_purchase()) {
335 335
                     $prepared_items[] = array(
336 336
                         'id'           => $item_id,
337 337
                         'item_price'   => $item->get_price(),
@@ -345,90 +345,90 @@  discard block
 block discarded – undo
345 345
 
346 346
         }
347 347
 
348
-        if ( empty( $prepared_items ) ) {
349
-            wp_send_json_error( __( 'You have not selected any items.', 'invoicing' ) );
348
+        if (empty($prepared_items)) {
349
+            wp_send_json_error(__('You have not selected any items.', 'invoicing'));
350 350
         }
351 351
 
352
-        if ( $submission->has_recurring && 1 != count( $prepared_items ) ) {
353
-            wp_send_json_error( __( 'Recurring items should be bought individually.', 'invoicing' ) );
352
+        if ($submission->has_recurring && 1 != count($prepared_items)) {
353
+            wp_send_json_error(__('Recurring items should be bought individually.', 'invoicing'));
354 354
         }
355 355
 
356 356
         // Prepare the submission details.
357 357
         $prepared = array(
358
-            'billing_email'                    => sanitize_email( $submission->get_billing_email() ),
359
-            __( 'Billing Email', 'invoicing' ) => sanitize_email( $submission->get_billing_email() ),
360
-            __( 'Form Id', 'invoicing' )       => absint( $submission->payment_form->get_id() ),
358
+            'billing_email'                    => sanitize_email($submission->get_billing_email()),
359
+            __('Billing Email', 'invoicing') => sanitize_email($submission->get_billing_email()),
360
+            __('Form Id', 'invoicing')       => absint($submission->payment_form->get_id()),
361 361
         );
362 362
 
363 363
         // Address fields.
364 364
         $address_fields = array();
365 365
 
366 366
         // Add discount code.
367
-        if ( $submission->has_discount_code() ) {
368
-            $address_fields['discount'] = array( $submission->get_discount_code() );
367
+        if ($submission->has_discount_code()) {
368
+            $address_fields['discount'] = array($submission->get_discount_code());
369 369
         }
370 370
 
371 371
         // Are all required fields provided?
372 372
         $data = $submission->get_data();
373 373
 
374
-        foreach ( $submission->payment_form->get_elements() as $field ) {
374
+        foreach ($submission->payment_form->get_elements() as $field) {
375 375
 
376
-            if ( ! empty( $field['premade'] ) ) {
376
+            if (!empty($field['premade'])) {
377 377
                 continue;
378 378
             }
379 379
 
380
-            if ( ! $submission->is_required_field_set( $field ) ) {
381
-                wp_send_json_error( __( 'Fill all required fields.', 'invoicing' ) );
380
+            if (!$submission->is_required_field_set($field)) {
381
+                wp_send_json_error(__('Fill all required fields.', 'invoicing'));
382 382
             }
383 383
 
384
-            if ( $field['type'] == 'address' ) {
384
+            if ($field['type'] == 'address') {
385 385
 
386
-                foreach ( $field['fields'] as $address_field ) {
386
+                foreach ($field['fields'] as $address_field) {
387 387
 
388
-                    if ( empty( $address_field['visible'] ) ) {
388
+                    if (empty($address_field['visible'])) {
389 389
                         continue;
390 390
                     }
391 391
 
392
-                    if ( ! empty( $address_field['required'] ) && empty( $data[ $address_field['name'] ] ) ) {
393
-                        wp_send_json_error( __( 'Some required fields have not been filled.', 'invoicing' ) );
392
+                    if (!empty($address_field['required']) && empty($data[$address_field['name']])) {
393
+                        wp_send_json_error(__('Some required fields have not been filled.', 'invoicing'));
394 394
                     }
395 395
 
396
-                    if ( isset( $data[ $address_field['name'] ] ) ) {
397
-                        $label = str_replace( 'wpinv_', '', $address_field['name'] );
398
-                        $address_fields[ $label ] = wpinv_clean( $data[ $address_field['name'] ] );
396
+                    if (isset($data[$address_field['name']])) {
397
+                        $label = str_replace('wpinv_', '', $address_field['name']);
398
+                        $address_fields[$label] = wpinv_clean($data[$address_field['name']]);
399 399
                     }
400 400
 
401 401
                 }
402 402
 
403
-            } else if ( isset( $data[ $field['id'] ] ) ) {
403
+            } else if (isset($data[$field['id']])) {
404 404
                 $label = $field['id'];
405 405
 
406
-                if ( isset( $field['label'] ) ) {
406
+                if (isset($field['label'])) {
407 407
                     $label = $field['label'];
408 408
                 }
409 409
 
410
-                $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] );
410
+                $prepared[wpinv_clean($label)] = wpinv_clean($data[$field['id']]);
411 411
             }
412 412
 
413 413
         }
414 414
 
415 415
         // (Maybe) create the user.
416
-        $user = get_user_by( 'email', $prepared['billing_email'] );
416
+        $user = get_user_by('email', $prepared['billing_email']);
417 417
 
418
-        if ( empty( $user ) ) {
419
-            $user = wpinv_create_user( $prepared['billing_email'] );
418
+        if (empty($user)) {
419
+            $user = wpinv_create_user($prepared['billing_email']);
420 420
         }
421 421
 
422
-        if ( is_wp_error( $user ) ) {
423
-            wp_send_json_error( $user->get_error_message() );
422
+        if (is_wp_error($user)) {
423
+            wp_send_json_error($user->get_error_message());
424 424
         }
425 425
 
426
-        if ( is_numeric( $user ) ) {
427
-            $user = get_user_by( 'id', $user );
426
+        if (is_numeric($user)) {
427
+            $user = get_user_by('id', $user);
428 428
         }
429 429
 
430 430
         // Create the invoice.
431
-        if ( ! $submission->has_invoice() ) {
431
+        if (!$submission->has_invoice()) {
432 432
 
433 433
             $invoice = wpinv_insert_invoice(
434 434
                 array(
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 
446 446
             $invoice = $submission->get_invoice();
447 447
 
448
-            if ( $invoice->is_paid() ) {
449
-                wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
448
+            if ($invoice->is_paid()) {
449
+                wp_send_json_error(__('This invoice has already been paid for.', 'invoicing'));
450 450
             }
451 451
 
452 452
             $invoice = wpinv_update_invoice(
@@ -461,34 +461,34 @@  discard block
 block discarded – undo
461 461
 
462 462
         }
463 463
 
464
-        if ( is_wp_error( $invoice ) ) {
465
-            wp_send_json_error( $invoice->get_error_message() );
464
+        if (is_wp_error($invoice)) {
465
+            wp_send_json_error($invoice->get_error_message());
466 466
         }
467 467
 
468
-        if ( empty( $invoice ) ) {
469
-            wp_send_json_error( __( 'Could not create your invoice.', 'invoicing' ) );
468
+        if (empty($invoice)) {
469
+            wp_send_json_error(__('Could not create your invoice.', 'invoicing'));
470 470
         }
471 471
 
472
-        unset( $prepared['billing_email'] );
473
-        update_post_meta( $invoice->ID, 'payment_form_data', $prepared );
472
+        unset($prepared['billing_email']);
473
+        update_post_meta($invoice->ID, 'payment_form_data', $prepared);
474 474
 
475 475
         $wpi_checkout_id = $invoice->ID;
476 476
         $cart_total = wpinv_price(
477 477
             wpinv_format_amount(
478
-                wpinv_get_cart_total( $invoice->get_cart_details(), NULL, $invoice ) ),
478
+                wpinv_get_cart_total($invoice->get_cart_details(), NULL, $invoice) ),
479 479
                 $invoice->get_currency()
480 480
         );
481 481
 
482 482
         $data                   = array();
483 483
         $data['invoice_id']     = $invoice->ID;
484
-        $data['cart_discounts'] = $invoice->get_discounts( true );
484
+        $data['cart_discounts'] = $invoice->get_discounts(true);
485 485
 
486
-        wpinv_set_checkout_session( $data );
487
-        add_filter( 'wp_redirect', array( $invoicing->form_elements, 'send_redirect_response' ) );
488
-        add_action( 'wpinv_pre_send_back_to_checkout', array( $invoicing->form_elements, 'checkout_error' ) );
486
+        wpinv_set_checkout_session($data);
487
+        add_filter('wp_redirect', array($invoicing->form_elements, 'send_redirect_response'));
488
+        add_action('wpinv_pre_send_back_to_checkout', array($invoicing->form_elements, 'checkout_error'));
489 489
         
490
-        if ( ! defined( 'WPINV_CHECKOUT' ) ) {
491
-            define( 'WPINV_CHECKOUT', true );
490
+        if (!defined('WPINV_CHECKOUT')) {
491
+            define('WPINV_CHECKOUT', true);
492 492
         }
493 493
 
494 494
         wpinv_process_checkout();
@@ -506,51 +506,51 @@  discard block
 block discarded – undo
506 506
     public static function get_payment_form_states_field() {
507 507
         global $invoicing;
508 508
 
509
-        if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) {
509
+        if (empty($_GET['country']) || empty($_GET['form'])) {
510 510
             exit;
511 511
         }
512 512
 
513
-        $elements = $invoicing->form_elements->get_form_elements( $_GET['form'] );
513
+        $elements = $invoicing->form_elements->get_form_elements($_GET['form']);
514 514
 
515
-        if ( empty( $elements ) ) {
515
+        if (empty($elements)) {
516 516
             exit;
517 517
         }
518 518
 
519 519
         $address_fields = array();
520
-        foreach ( $elements as $element ) {
521
-            if ( 'address' === $element['type'] ) {
520
+        foreach ($elements as $element) {
521
+            if ('address' === $element['type']) {
522 522
                 $address_fields = $element;
523 523
                 break;
524 524
             }
525 525
         }
526 526
 
527
-        if ( empty( $address_fields ) ) {
527
+        if (empty($address_fields)) {
528 528
             exit;
529 529
         }
530 530
 
531
-        foreach( $address_fields['fields'] as $address_field ) {
531
+        foreach ($address_fields['fields'] as $address_field) {
532 532
 
533
-            if ( 'wpinv_state' == $address_field['name'] ) {
533
+            if ('wpinv_state' == $address_field['name']) {
534 534
 
535 535
                 $label = $address_field['label'];
536 536
 
537
-                if ( ! empty( $address_field['required'] ) ) {
537
+                if (!empty($address_field['required'])) {
538 538
                     $label .= "<span class='text-danger'> *</span>";
539 539
                 }
540 540
 
541
-                $states = wpinv_get_country_states( $_GET['country'] );
541
+                $states = wpinv_get_country_states($_GET['country']);
542 542
 
543
-                if ( ! empty( $states ) ) {
543
+                if (!empty($states)) {
544 544
 
545 545
                     $html = aui()->select(
546 546
                             array(
547 547
                                 'options'          => $states,
548
-                                'name'             => esc_attr( $address_field['name'] ),
549
-                                'id'               => esc_attr( $address_field['name'] ),
550
-                                'placeholder'      => esc_attr( $address_field['placeholder'] ),
548
+                                'name'             => esc_attr($address_field['name']),
549
+                                'id'               => esc_attr($address_field['name']),
550
+                                'placeholder'      => esc_attr($address_field['placeholder']),
551 551
                                 'required'         => (bool) $address_field['required'],
552 552
                                 'no_wrap'          => true,
553
-                                'label'            => wp_kses_post( $label ),
553
+                                'label'            => wp_kses_post($label),
554 554
                                 'select2'          => false,
555 555
                             )
556 556
                         );
@@ -559,10 +559,10 @@  discard block
 block discarded – undo
559 559
 
560 560
                     $html = aui()->input(
561 561
                             array(
562
-                                'name'       => esc_attr( $address_field['name'] ),
563
-                                'id'         => esc_attr( $address_field['name'] ),
562
+                                'name'       => esc_attr($address_field['name']),
563
+                                'id'         => esc_attr($address_field['name']),
564 564
                                 'required'   => (bool) $address_field['required'],
565
-                                'label'      => wp_kses_post( $label ),
565
+                                'label'      => wp_kses_post($label),
566 566
                                 'no_wrap'    => true,
567 567
                                 'type'       => 'text',
568 568
                             )
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 
571 571
                 }
572 572
 
573
-                wp_send_json_success( str_replace( 'sr-only', '', $html ) );
573
+                wp_send_json_success(str_replace('sr-only', '', $html));
574 574
                 exit;
575 575
 
576 576
             }
@@ -586,49 +586,49 @@  discard block
 block discarded – undo
586 586
     public static function recalculate_invoice_totals() {
587 587
 
588 588
         // Verify nonce.
589
-        check_ajax_referer( 'wpinv-nonce' );
589
+        check_ajax_referer('wpinv-nonce');
590 590
 
591
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
591
+        if (!wpinv_current_user_can_manage_invoicing()) {
592 592
             exit;
593 593
         }
594 594
 
595 595
         // We need an invoice.
596
-        if ( empty( $_POST['post_id'] ) ) {
596
+        if (empty($_POST['post_id'])) {
597 597
             exit;
598 598
         }
599 599
 
600 600
         // Fetch the invoice.
601
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
601
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
602 602
 
603 603
         // Ensure it exists.
604
-        if ( ! $invoice->get_id() ) {
604
+        if (!$invoice->get_id()) {
605 605
             exit;
606 606
         }
607 607
 
608 608
         // Maybe set the country, state, currency.
609
-        foreach ( array( 'country', 'state', 'currency' ) as $key ) {
610
-            if ( isset( $_POST[ $key ] ) ) {
609
+        foreach (array('country', 'state', 'currency') as $key) {
610
+            if (isset($_POST[$key])) {
611 611
                 $method = "set_$key";
612
-                $invoice->$method( $_POST[ $key ] );
612
+                $invoice->$method($_POST[$key]);
613 613
             }
614 614
         }
615 615
 
616 616
         // Maybe disable taxes.
617
-        $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) );
617
+        $invoice->set_disable_taxes(!empty($_POST['taxes']));
618 618
 
619 619
         // Recalculate totals.
620 620
         $invoice->recalculate_total();
621 621
 
622 622
         $totals = array(
623
-            'subtotal' => wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ) ),
624
-            'discount' => wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ) ),
625
-            'tax'      => wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ) ),
626
-            'total'    => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ),
623
+            'subtotal' => wpinv_price(wpinv_format_amount($invoice->get_subtotal())),
624
+            'discount' => wpinv_price(wpinv_format_amount($invoice->get_total_discount())),
625
+            'tax'      => wpinv_price(wpinv_format_amount($invoice->get_total_tax())),
626
+            'total'    => wpinv_price(wpinv_format_amount($invoice->get_total())),
627 627
         );
628 628
 
629
-        $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice );
629
+        $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice);
630 630
 
631
-        wp_send_json_success( compact( 'totals' ) );
631
+        wp_send_json_success(compact('totals'));
632 632
     }
633 633
 
634 634
     /**
@@ -637,33 +637,33 @@  discard block
 block discarded – undo
637 637
     public static function get_invoice_items() {
638 638
 
639 639
         // Verify nonce.
640
-        check_ajax_referer( 'wpinv-nonce' );
640
+        check_ajax_referer('wpinv-nonce');
641 641
 
642
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
642
+        if (!wpinv_current_user_can_manage_invoicing()) {
643 643
             exit;
644 644
         }
645 645
 
646 646
         // We need an invoice and items.
647
-        if ( empty( $_POST['post_id'] ) ) {
647
+        if (empty($_POST['post_id'])) {
648 648
             exit;
649 649
         }
650 650
 
651 651
         // Fetch the invoice.
652
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
652
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
653 653
 
654 654
         // Ensure it exists.
655
-        if ( ! $invoice->get_id() ) {
655
+        if (!$invoice->get_id()) {
656 656
             exit;
657 657
         }
658 658
 
659 659
         // Return an array of invoice items.
660 660
         $items = array();
661 661
 
662
-        foreach ( $invoice->get_items() as $item_id => $item ) {
663
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax();
662
+        foreach ($invoice->get_items() as $item_id => $item) {
663
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax();
664 664
         }
665 665
 
666
-        wp_send_json_success( compact( 'items' ) );
666
+        wp_send_json_success(compact('items'));
667 667
     }
668 668
 
669 669
     /**
@@ -672,48 +672,48 @@  discard block
 block discarded – undo
672 672
     public static function edit_invoice_item() {
673 673
 
674 674
         // Verify nonce.
675
-        check_ajax_referer( 'wpinv-nonce' );
675
+        check_ajax_referer('wpinv-nonce');
676 676
 
677
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
677
+        if (!wpinv_current_user_can_manage_invoicing()) {
678 678
             exit;
679 679
         }
680 680
 
681 681
         // We need an invoice and item details.
682
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) {
682
+        if (empty($_POST['post_id']) || empty($_POST['data'])) {
683 683
             exit;
684 684
         }
685 685
 
686 686
         // Fetch the invoice.
687
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
687
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
688 688
 
689 689
         // Ensure it exists and its not been paid for.
690
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
690
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
691 691
             exit;
692 692
         }
693 693
 
694 694
         // Format the data.
695
-        $data = wp_list_pluck( $_POST['data'], 'value', 'field' );
695
+        $data = wp_list_pluck($_POST['data'], 'value', 'field');
696 696
 
697 697
         // Ensure that we have an item id.
698
-        if ( empty( $data['id'] ) ) {
698
+        if (empty($data['id'])) {
699 699
             exit;
700 700
         }
701 701
 
702 702
         // Abort if the invoice does not have the specified item.
703
-        $item = $invoice->get_item( (int) $data['id'] );
703
+        $item = $invoice->get_item((int) $data['id']);
704 704
 
705
-        if ( empty( $item ) ) {
705
+        if (empty($item)) {
706 706
             exit;
707 707
         }
708 708
 
709 709
         // Update the item.
710
-        $item->set_price( $data['price'] );
711
-        $item->set_name( $data['name'] );
712
-        $item->set_description( $data['description'] );
713
-        $item->set_quantity( $data['quantity'] );
710
+        $item->set_price($data['price']);
711
+        $item->set_name($data['name']);
712
+        $item->set_description($data['description']);
713
+        $item->set_quantity($data['quantity']);
714 714
 
715 715
         // Add it to the invoice.
716
-        $invoice->add_item( $item );
716
+        $invoice->add_item($item);
717 717
 
718 718
         // Update totals.
719 719
         $invoice->recalculate_total();
@@ -724,11 +724,11 @@  discard block
 block discarded – undo
724 724
         // Return an array of invoice items.
725 725
         $items = array();
726 726
 
727
-        foreach ( $invoice->get_items() as $item_id => $item ) {
728
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax();
727
+        foreach ($invoice->get_items() as $item_id => $item) {
728
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax();
729 729
         }
730 730
 
731
-        wp_send_json_success( compact( 'items' ) );
731
+        wp_send_json_success(compact('items'));
732 732
     }
733 733
     /**
734 734
      * Adds a items to an invoice.
@@ -736,38 +736,38 @@  discard block
 block discarded – undo
736 736
     public static function add_invoice_items() {
737 737
 
738 738
         // Verify nonce.
739
-        check_ajax_referer( 'wpinv-nonce' );
739
+        check_ajax_referer('wpinv-nonce');
740 740
 
741
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
741
+        if (!wpinv_current_user_can_manage_invoicing()) {
742 742
             exit;
743 743
         }
744 744
 
745 745
         // We need an invoice and items.
746
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) {
746
+        if (empty($_POST['post_id']) || empty($_POST['items'])) {
747 747
             exit;
748 748
         }
749 749
 
750 750
         // Fetch the invoice.
751
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
751
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
752 752
         $alert   = false;
753 753
 
754 754
         // Ensure it exists and its not been paid for.
755
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
755
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
756 756
             exit;
757 757
         }
758 758
 
759 759
         // Add the items.
760
-        foreach ( $_POST['items'] as $data ) {
760
+        foreach ($_POST['items'] as $data) {
761 761
 
762
-            $item = new GetPaid_Form_Item( $data[ 'id' ] );
762
+            $item = new GetPaid_Form_Item($data['id']);
763 763
 
764
-            if ( is_numeric( $data[ 'qty' ] ) && (int) $data[ 'qty' ] > 0 ) {
765
-                $item->set_quantity( $data[ 'qty' ] );
764
+            if (is_numeric($data['qty']) && (int) $data['qty'] > 0) {
765
+                $item->set_quantity($data['qty']);
766 766
             }
767 767
 
768
-            if ( $item->get_id() > 0 ) {
769
-                if ( ! $invoice->add_item( $item ) ) {
770
-                    $alert = __( 'An invoice can only contain one recurring item', 'invoicing' );
768
+            if ($item->get_id() > 0) {
769
+                if (!$invoice->add_item($item)) {
770
+                    $alert = __('An invoice can only contain one recurring item', 'invoicing');
771 771
                 }
772 772
             }
773 773
 
@@ -780,11 +780,11 @@  discard block
 block discarded – undo
780 780
         // Return an array of invoice items.
781 781
         $items = array();
782 782
 
783
-        foreach ( $invoice->get_items() as $item_id => $item ) {
784
-            $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax();
783
+        foreach ($invoice->get_items() as $item_id => $item) {
784
+            $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax();
785 785
         }
786 786
 
787
-        wp_send_json_success( compact( 'items', 'alert' ) );
787
+        wp_send_json_success(compact('items', 'alert'));
788 788
     }
789 789
 
790 790
     /**
@@ -793,15 +793,15 @@  discard block
 block discarded – undo
793 793
     public static function get_invoicing_items() {
794 794
 
795 795
         // Verify nonce.
796
-        check_ajax_referer( 'wpinv-nonce' );
796
+        check_ajax_referer('wpinv-nonce');
797 797
 
798
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
798
+        if (!wpinv_current_user_can_manage_invoicing()) {
799 799
             exit;
800 800
         }
801 801
 
802 802
         // We need a search term.
803
-        if ( empty( $_GET['search'] ) ) {
804
-            wp_send_json_success( array() );
803
+        if (empty($_GET['search'])) {
804
+            wp_send_json_success(array());
805 805
         }
806 806
 
807 807
         // Retrieve items.
@@ -810,8 +810,8 @@  discard block
 block discarded – undo
810 810
             'orderby'        => 'title',
811 811
             'order'          => 'ASC',
812 812
             'posts_per_page' => -1,
813
-            'post_status'    => array( 'publish' ),
814
-            's'              => trim( $_GET['search'] ),
813
+            'post_status'    => array('publish'),
814
+            's'              => trim($_GET['search']),
815 815
             'meta_query'     => array(
816 816
                 array(
817 817
                     'key'       => '_wpinv_type',
@@ -821,18 +821,18 @@  discard block
 block discarded – undo
821 821
             )
822 822
         );
823 823
 
824
-        $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) );
824
+        $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args));
825 825
         $data  = array();
826 826
 
827
-        foreach ( $items as $item ) {
828
-            $item      = new GetPaid_Form_Item( $item );
827
+        foreach ($items as $item) {
828
+            $item = new GetPaid_Form_Item($item);
829 829
             $data[] = array(
830 830
                 'id'   => $item->get_id(),
831 831
                 'text' => $item->get_name()
832 832
             );
833 833
         }
834 834
 
835
-        wp_send_json_success( $data );
835
+        wp_send_json_success($data);
836 836
 
837 837
     }
838 838
 
@@ -842,24 +842,24 @@  discard block
 block discarded – undo
842 842
     public static function get_aui_states_field() {
843 843
 
844 844
         // Verify nonce.
845
-        check_ajax_referer( 'wpinv-nonce' );
845
+        check_ajax_referer('wpinv-nonce');
846 846
 
847 847
         // We need a country.
848
-        if ( empty( $_GET['country'] ) ) {
848
+        if (empty($_GET['country'])) {
849 849
             exit;
850 850
         }
851 851
 
852
-        $states = wpinv_get_country_states( trim( $_GET['country'] ) );
853
-        $state  = isset( $_GET['state'] ) ? trim( $_GET['state'] ) : wpinv_get_default_state();
852
+        $states = wpinv_get_country_states(trim($_GET['country']));
853
+        $state  = isset($_GET['state']) ? trim($_GET['state']) : wpinv_get_default_state();
854 854
 
855
-        if ( empty( $states ) ) {
855
+        if (empty($states)) {
856 856
 
857 857
             $html = aui()->input(
858 858
                 array(
859 859
                     'type'        => 'text',
860 860
                     'id'          => 'wpinv_state',
861 861
                     'name'        => 'wpinv_state',
862
-                    'label'       => __( 'State', 'invoicing' ),
862
+                    'label'       => __('State', 'invoicing'),
863 863
                     'label_type'  => 'vertical',
864 864
                     'placeholder' => 'Liège',
865 865
                     'class'       => 'form-control-sm',
@@ -873,9 +873,9 @@  discard block
 block discarded – undo
873 873
                 array(
874 874
                     'id'          => 'wpinv_state',
875 875
                     'name'        => 'wpinv_state',
876
-                    'label'       => __( 'State', 'invoicing' ),
876
+                    'label'       => __('State', 'invoicing'),
877 877
                     'label_type'  => 'vertical',
878
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
878
+                    'placeholder' => __('Select a state', 'invoicing'),
879 879
                     'class'       => 'form-control-sm',
880 880
                     'value'       => $state,
881 881
                     'options'     => $states,
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
         wp_send_json_success(
890 890
             array(
891 891
                 'html'   => $html,
892
-                'select' => ! empty ( $states )
892
+                'select' => !empty ($states)
893 893
             )
894 894
         );
895 895
 
@@ -903,11 +903,11 @@  discard block
 block discarded – undo
903 903
     public static function payment_form_refresh_prices() {
904 904
 
905 905
         // Check nonce.
906
-        check_ajax_referer( 'getpaid_form_nonce' );
906
+        check_ajax_referer('getpaid_form_nonce');
907 907
 
908 908
         // ... form fields...
909
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
910
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
909
+        if (empty($_POST['getpaid_payment_form_submission'])) {
910
+            _e('Error: Reload the page and try again.', 'invoicing');
911 911
             exit;
912 912
         }
913 913
 
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
         $submission = new GetPaid_Payment_Form_Submission();
916 916
 
917 917
         // Do we have an error?
918
-        if ( ! empty( $submission->last_error ) ) {
918
+        if (!empty($submission->last_error)) {
919 919
             echo $submission->last_error;
920 920
             exit;
921 921
         }
@@ -926,38 +926,38 @@  discard block
 block discarded – undo
926 926
             'has_recurring' => $submission->has_recurring,
927 927
             'is_free'       => $submission->get_payment_details(),
928 928
             'totals'        => array(
929
-                'subtotal'  => wpinv_price( wpinv_format_amount( $submission->subtotal_amount ), $submission->get_currency() ),
930
-                'discount'  => wpinv_price( wpinv_format_amount( $submission->get_total_discount() ), $submission->get_currency() ),
931
-                'fees'      => wpinv_price( wpinv_format_amount( $submission->get_total_fees() ), $submission->get_currency() ),
932
-                'tax'       => wpinv_price( wpinv_format_amount( $submission->get_total_tax() ), $submission->get_currency() ),
933
-                'total'     => wpinv_price( wpinv_format_amount( $submission->get_total() ), $submission->get_currency() ),
929
+                'subtotal'  => wpinv_price(wpinv_format_amount($submission->subtotal_amount), $submission->get_currency()),
930
+                'discount'  => wpinv_price(wpinv_format_amount($submission->get_total_discount()), $submission->get_currency()),
931
+                'fees'      => wpinv_price(wpinv_format_amount($submission->get_total_fees()), $submission->get_currency()),
932
+                'tax'       => wpinv_price(wpinv_format_amount($submission->get_total_tax()), $submission->get_currency()),
933
+                'total'     => wpinv_price(wpinv_format_amount($submission->get_total()), $submission->get_currency()),
934 934
             ),
935 935
         );
936 936
 
937 937
         // Add items.
938 938
         $items = $submission->get_items();
939
-        if ( ! empty( $items ) ) {
939
+        if (!empty($items)) {
940 940
             $result['items'] = array();
941 941
 
942
-            foreach( $items as $item_id => $item ) {
943
-                $result['items']["$item_id"] = wpinv_price( wpinv_format_amount( $item->get_price() * $item->get_quantity() ) );
942
+            foreach ($items as $item_id => $item) {
943
+                $result['items']["$item_id"] = wpinv_price(wpinv_format_amount($item->get_price() * $item->get_quantity()));
944 944
             }
945 945
         }
946 946
 
947 947
         // Add invoice.
948
-        if ( $submission->has_invoice() ) {
948
+        if ($submission->has_invoice()) {
949 949
             $result['invoice'] = $submission->get_invoice()->ID;
950 950
         }
951 951
 
952 952
         // Add discount code.
953
-        if ( $submission->has_discount_code() ) {
953
+        if ($submission->has_discount_code()) {
954 954
             $result['discount_code'] = $submission->get_discount_code();
955 955
         }
956 956
 
957 957
         // Filter the result.
958
-        $result = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $result, $submission );
958
+        $result = apply_filters('getpaid_payment_form_ajax_refresh_prices', $result, $submission);
959 959
 
960
-        wp_send_json_success( $result );
960
+        wp_send_json_success($result);
961 961
     }
962 962
 
963 963
     /**
@@ -968,53 +968,53 @@  discard block
 block discarded – undo
968 968
     public static function buy_items() {
969 969
         $user_id = get_current_user_id();
970 970
 
971
-        if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page
972
-            wp_send_json( array(
973
-                'success' => wp_login_url( wp_get_referer() )
974
-            ) );
971
+        if (empty($user_id)) { // If not logged in then lets redirect to the login page
972
+            wp_send_json(array(
973
+                'success' => wp_login_url(wp_get_referer())
974
+            ));
975 975
         } else {
976 976
             // Only check nonce if logged in as it could be cached when logged out.
977
-            if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) {
978
-                wp_send_json( array(
979
-                    'error' => __( 'Security checks failed.', 'invoicing' )
980
-                ) );
977
+            if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) {
978
+                wp_send_json(array(
979
+                    'error' => __('Security checks failed.', 'invoicing')
980
+                ));
981 981
                 wp_die();
982 982
             }
983 983
 
984 984
             // allow to set a custom price through post_id
985 985
             $items = $_POST['items'];
986
-            $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0;
987
-            $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0;
986
+            $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0;
987
+            $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0;
988 988
 
989 989
             $cart_items = array();
990
-            if ( $items ) {
991
-                $items = explode( ',', $items );
990
+            if ($items) {
991
+                $items = explode(',', $items);
992 992
 
993
-                foreach( $items as $item ) {
993
+                foreach ($items as $item) {
994 994
                     $item_id = $item;
995 995
                     $quantity = 1;
996 996
 
997
-                    if ( strpos( $item, '|' ) !== false ) {
998
-                        $item_parts = explode( '|', $item );
997
+                    if (strpos($item, '|') !== false) {
998
+                        $item_parts = explode('|', $item);
999 999
                         $item_id = $item_parts[0];
1000 1000
                         $quantity = $item_parts[1];
1001 1001
                     }
1002 1002
 
1003
-                    if ( $item_id && $quantity ) {
1003
+                    if ($item_id && $quantity) {
1004 1004
                         $cart_items_arr = array(
1005
-                            'id'            => (int)$item_id,
1006
-                            'quantity'      => (int)$quantity
1005
+                            'id'            => (int) $item_id,
1006
+                            'quantity'      => (int) $quantity
1007 1007
                         );
1008 1008
 
1009 1009
                         // If there is a related post id then add it to meta
1010
-                        if ( $related_post_id ) {
1010
+                        if ($related_post_id) {
1011 1011
                             $cart_items_arr['meta'] = array(
1012 1012
                                 'post_id'   => $related_post_id
1013 1013
                             );
1014 1014
                         }
1015 1015
 
1016 1016
                         // If there is a custom price then set it.
1017
-                        if ( $custom_item_price ) {
1017
+                        if ($custom_item_price) {
1018 1018
                             $cart_items_arr['custom_price'] = $custom_item_price;
1019 1019
                         }
1020 1020
 
@@ -1030,37 +1030,37 @@  discard block
 block discarded – undo
1030 1030
              * @param int $related_post_id The related post id if any.
1031 1031
              * @since 1.0.0
1032 1032
              */
1033
-            $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id );
1033
+            $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id);
1034 1034
 
1035 1035
             // Make sure its not in the cart already, if it is then redirect to checkout.
1036 1036
             $cart_invoice = wpinv_get_invoice_cart();
1037 1037
 
1038
-            if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) {
1039
-                wp_send_json( array(
1038
+            if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) {
1039
+                wp_send_json(array(
1040 1040
                     'success' =>  $cart_invoice->get_checkout_payment_url()
1041
-                ) );
1041
+                ));
1042 1042
                 wp_die();
1043 1043
             }
1044 1044
 
1045 1045
             // Check if user has invoice with same items waiting to be paid.
1046
-            $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' );
1047
-            if ( !empty( $user_invoices ) ) {
1048
-                foreach( $user_invoices as $user_invoice ) {
1046
+            $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending');
1047
+            if (!empty($user_invoices)) {
1048
+                foreach ($user_invoices as $user_invoice) {
1049 1049
                     $user_cart_details = array();
1050
-                    $invoice  = wpinv_get_invoice( $user_invoice->ID );
1050
+                    $invoice = wpinv_get_invoice($user_invoice->ID);
1051 1051
                     $cart_details = $invoice->get_cart_details();
1052 1052
 
1053
-                    if ( !empty( $cart_details ) ) {
1054
-                        foreach ( $cart_details as $invoice_item ) {
1053
+                    if (!empty($cart_details)) {
1054
+                        foreach ($cart_details as $invoice_item) {
1055 1055
                             $ii_arr = array();
1056
-                            $ii_arr['id'] = (int)$invoice_item['id'];
1057
-                            $ii_arr['quantity'] = (int)$invoice_item['quantity'];
1056
+                            $ii_arr['id'] = (int) $invoice_item['id'];
1057
+                            $ii_arr['quantity'] = (int) $invoice_item['quantity'];
1058 1058
 
1059
-                            if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) {
1059
+                            if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) {
1060 1060
                                 $ii_arr['meta'] = $invoice_item['meta'];
1061 1061
                             }
1062 1062
 
1063
-                            if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) {
1063
+                            if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) {
1064 1064
                                 $ii_arr['custom_price'] = $invoice_item['custom_price'];
1065 1065
                             }
1066 1066
 
@@ -1068,17 +1068,17 @@  discard block
 block discarded – undo
1068 1068
                         }
1069 1069
                     }
1070 1070
 
1071
-                    if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) {
1072
-                        wp_send_json( array(
1071
+                    if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) {
1072
+                        wp_send_json(array(
1073 1073
                             'success' =>  $invoice->get_checkout_payment_url()
1074
-                        ) );
1074
+                        ));
1075 1075
                         wp_die();
1076 1076
                     }
1077 1077
                 }
1078 1078
             }
1079 1079
 
1080 1080
             // Create invoice and send user to checkout
1081
-            if ( !empty( $cart_items ) ) {
1081
+            if (!empty($cart_items)) {
1082 1082
                 $invoice_data = array(
1083 1083
                     'status'        =>  'wpi-pending',
1084 1084
                     'created_via'   =>  'wpi',
@@ -1086,21 +1086,21 @@  discard block
 block discarded – undo
1086 1086
                     'cart_details'  =>  $cart_items,
1087 1087
                 );
1088 1088
 
1089
-                $invoice = wpinv_insert_invoice( $invoice_data, true );
1089
+                $invoice = wpinv_insert_invoice($invoice_data, true);
1090 1090
 
1091
-                if ( !empty( $invoice ) && isset( $invoice->ID ) ) {
1092
-                    wp_send_json( array(
1091
+                if (!empty($invoice) && isset($invoice->ID)) {
1092
+                    wp_send_json(array(
1093 1093
                         'success' =>  $invoice->get_checkout_payment_url()
1094
-                    ) );
1094
+                    ));
1095 1095
                 } else {
1096
-                    wp_send_json( array(
1097
-                        'error' => __( 'Invoice failed to create', 'invoicing' )
1098
-                    ) );
1096
+                    wp_send_json(array(
1097
+                        'error' => __('Invoice failed to create', 'invoicing')
1098
+                    ));
1099 1099
                 }
1100 1100
             } else {
1101
-                wp_send_json( array(
1102
-                    'error' => __( 'Items not valid.', 'invoicing' )
1103
-                ) );
1101
+                wp_send_json(array(
1102
+                    'error' => __('Items not valid.', 'invoicing')
1103
+                ));
1104 1104
             }
1105 1105
         }
1106 1106
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-resend-invoice.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  */
7 7
 
8 8
 if ( ! defined( 'ABSPATH' ) ) {
9
-	exit; // Exit if accessed directly
9
+    exit; // Exit if accessed directly
10 10
 }
11 11
 
12 12
 /**
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
 class GetPaid_Meta_Box_Resend_Invoice {
16 16
 
17 17
     /**
18
-	 * Output the metabox.
19
-	 *
20
-	 * @param WP_Post $post
21
-	 */
18
+     * Output the metabox.
19
+     *
20
+     * @param WP_Post $post
21
+     */
22 22
     public static function output( $post ) {
23 23
 
24 24
         // Fetch the invoice.
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if (!defined('ABSPATH')) {
9 9
 	exit; // Exit if accessed directly
10 10
 }
11 11
 
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @param WP_Post $post
21 21
 	 */
22
-    public static function output( $post ) {
22
+    public static function output($post) {
23 23
 
24 24
         // Fetch the invoice.
25
-        $invoice = new WPInv_Invoice( $post );
25
+        $invoice = new WPInv_Invoice($post);
26 26
 
27
-        do_action( 'wpinv_metabox_resend_invoice_before', $invoice );
27
+        do_action('wpinv_metabox_resend_invoice_before', $invoice);
28 28
 
29 29
         $email_url = esc_url(
30 30
             add_query_arg(
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
             )
47 47
         );
48 48
         ?>
49
-            <p class="wpi-meta-row wpi-resend-info"><?php _e( "This will send a copy of the invoice to the customer's email address.", 'invoicing' ); ?></p>
50
-            <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo $email_url; ?>" class="button button-secondary"><?php _e( 'Resend Invoice', 'invoicing' ); ?></a></p>
51
-            <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo $reminder_url; ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p>
49
+            <p class="wpi-meta-row wpi-resend-info"><?php _e("This will send a copy of the invoice to the customer's email address.", 'invoicing'); ?></p>
50
+            <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo $email_url; ?>" class="button button-secondary"><?php _e('Resend Invoice', 'invoicing'); ?></a></p>
51
+            <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo $reminder_url; ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p>
52 52
         <?php
53 53
 
54
-        do_action( 'wpinv_metabox_resend_invoice_after', $invoice );
54
+        do_action('wpinv_metabox_resend_invoice_after', $invoice);
55 55
 
56 56
     }
57 57
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-subscription.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  */
7 7
 
8 8
 if ( ! defined( 'ABSPATH' ) ) {
9
-	exit; // Exit if accessed directly
9
+    exit; // Exit if accessed directly
10 10
 }
11 11
 
12 12
 /**
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
 class GetPaid_Meta_Box_Invoice_Subscription {
16 16
 
17 17
     /**
18
-	 * Output the metabox.
19
-	 *
20
-	 * @param WP_Post $post
21
-	 */
18
+     * Output the metabox.
19
+     *
20
+     * @param WP_Post $post
21
+     */
22 22
     public static function output( $post ) {
23 23
 
24 24
         //Fetch the invoice.
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if (!defined('ABSPATH')) {
9 9
 	exit; // Exit if accessed directly
10 10
 }
11 11
 
@@ -19,27 +19,27 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @param WP_Post $post
21 21
 	 */
22
-    public static function output( $post ) {
22
+    public static function output($post) {
23 23
 
24 24
         //Fetch the invoice.
25
-        $invoice = new WPInv_Invoice( $post );
25
+        $invoice = new WPInv_Invoice($post);
26 26
 
27 27
         // Ensure that it is recurring.
28
-        if ( ! $invoice->is_recurring() ) {
28
+        if (!$invoice->is_recurring()) {
29 29
             return;
30 30
         }
31 31
 
32 32
         // Fetch the subscription.
33
-        $subscription = wpinv_get_subscription( $invoice );
33
+        $subscription = wpinv_get_subscription($invoice);
34 34
 
35 35
         ?>
36
-            <?php if ( empty( $subscription ) ): ?>
36
+            <?php if (empty($subscription)): ?>
37 37
                 <p class="wpi-meta-row">
38 38
                     <?php
39 39
                         echo
40 40
                             wp_sprintf(
41
-                                __( 'A new subscription will be created when the customer checks out and pays the invoice. %sView all subscriptions%s', 'invoicing' ),
42
-                                '<a href="' . admin_url( 'admin.php?page=wpinv-subscriptions' ).'">',
41
+                                __('A new subscription will be created when the customer checks out and pays the invoice. %sView all subscriptions%s', 'invoicing'),
42
+                                '<a href="' . admin_url('admin.php?page=wpinv-subscriptions') . '">',
43 43
                                 '</a>'
44 44
                             );
45 45
                     ?>
@@ -48,30 +48,30 @@  discard block
 block discarded – undo
48 48
                 return; // If no subscription.
49 49
                 endif;
50 50
 
51
-                $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period, $subscription->frequency );
52
-                $billing   = wpinv_price(wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency;
53
-                $initial   = wpinv_price(wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) );
54
-                $exipired  = strtotime( $subscription->expiration, current_time( 'timestamp' ) ) < current_time( 'timestamp' );
51
+                $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency);
52
+                $billing   = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency;
53
+                $initial   = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id));
54
+                $exipired  = strtotime($subscription->expiration, current_time('timestamp')) < current_time('timestamp');
55 55
             ?>
56 56
 
57
-            <p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . esc_attr( $subscription->status ); ?>">
57
+            <p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . esc_attr($subscription->status); ?>">
58 58
                 <?php echo $invoice->is_renewal() ? _e('Renewal Invoice', 'invoicing') : _e('Recurring Invoice', 'invoicing'); ?>
59 59
             </p>
60 60
 
61
-            <?php if ( ! empty( $subscription->id ) ) : ?>
61
+            <?php if (!empty($subscription->id)) : ?>
62 62
                 <p class="wpi-meta-row wpi-sub-id">
63
-                    <label><?php _e( 'Subscription ID:', 'invoicing' ); ?></label>
64
-                    <a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a>
63
+                    <label><?php _e('Subscription ID:', 'invoicing'); ?></label>
64
+                    <a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a>
65 65
                 </p>
66 66
             <?php endif; ?>
67 67
 
68 68
             <p class="wpi-meta-row wpi-bill-cycle">
69
-                <label><?php _e( 'Billing Cycle:', 'invoicing'); ?> </label>
69
+                <label><?php _e('Billing Cycle:', 'invoicing'); ?> </label>
70 70
                 <?php
71 71
 
72
-                    if ( $subscription->recurring_amount != $subscription->initial_amount ) {
72
+                    if ($subscription->recurring_amount != $subscription->initial_amount) {
73 73
                         printf(
74
-                            _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ),
74
+                            _x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'),
75 75
                             $initial,
76 76
                             $billing
77 77
                         );
@@ -83,38 +83,38 @@  discard block
 block discarded – undo
83 83
             </p>
84 84
 
85 85
             <p class="wpi-meta-row wpi-billed-times">
86
-                <label><?php _e( 'Times Billed:', 'invoicing' ); ?></label>
87
-                <?php echo $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times ); ?>
86
+                <label><?php _e('Times Billed:', 'invoicing'); ?></label>
87
+                <?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? 'Until Cancelled' : $subscription->bill_times); ?>
88 88
             </p>
89 89
 
90 90
             <p class="wpi-meta-row wpi-start-date">
91
-                <label><?php _e( 'Start Date:', 'invoicing' ); ?></label>
92
-                <?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->created, current_time( 'timestamp' ) ) ); ?>
91
+                <label><?php _e('Start Date:', 'invoicing'); ?></label>
92
+                <?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?>
93 93
             </p>
94 94
 
95 95
             <p class="wpi-meta-row wpi-end-date">
96
-                <label><?php echo $exipired ? __( 'Expired On:', 'invoicing' ) : __( 'Renews On:', 'invoicing' ); ?></label>
97
-                <?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration, current_time( 'timestamp' ) ) ); ?>
96
+                <label><?php echo $exipired ? __('Expired On:', 'invoicing') : __('Renews On:', 'invoicing'); ?></label>
97
+                <?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?>
98 98
             </p>
99 99
 
100
-            <?php if ( $subscription->status ) { ?>
100
+            <?php if ($subscription->status) { ?>
101 101
                 <p class="wpi-meta-row wpi-sub-status">
102
-                    <label><?php _e( 'Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?>
102
+                    <label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?>
103 103
                 </p>
104 104
             <?php } ?>
105 105
 
106
-            <?php if ( $invoice->is_renewal() ) { ?>
106
+            <?php if ($invoice->is_renewal()) { ?>
107 107
                 <p class="wpi-meta-row wpi-invoice-parent">
108
-                    <label><?php _e( 'Parent Invoice:', 'invoicing'); ?></label>
108
+                    <label><?php _e('Parent Invoice:', 'invoicing'); ?></label>
109 109
                     <?php
110 110
                         $parent = $invoice->get_parent_payment();
111 111
 
112
-                        if ( $parent->get_id() ) {
113
-                            $parent_url = esc_url( get_edit_post_link( $parent->get_id() ) );
112
+                        if ($parent->get_id()) {
113
+                            $parent_url = esc_url(get_edit_post_link($parent->get_id()));
114 114
                             $parent_id  = $parent->get_number();
115 115
                             echo "<a href='$parent_url'>$parent_id</a>";
116 116
                         } else {
117
-                            echo '<del>' . __( 'Deleted', 'invoicing' ) . '</del>';
117
+                            echo '<del>' . __('Deleted', 'invoicing') . '</del>';
118 118
                         }
119 119
                     ?>
120 120
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-payment-form.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit; // Exit if accessed directly
10
+    exit; // Exit if accessed directly
11 11
 }
12 12
 
13 13
 /**
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
 class GetPaid_Meta_Box_Payment_Form {
17 17
 
18 18
     /**
19
-	 * Output the metabox.
20
-	 *
21
-	 * @param WP_Post $post
22
-	 */
19
+     * Output the metabox.
20
+     *
21
+     * @param WP_Post $post
22
+     */
23 23
     public static function output( $post ) {
24 24
         ?>
25 25
         <div id="wpinv-form-builder" class="bsui">
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
     }
83 83
 
84 84
     /**
85
-	 * Save meta box data.
86
-	 *
87
-	 * @param int $post_id
88
-	 */
89
-	public static function save( $post_id ) {
85
+     * Save meta box data.
86
+     *
87
+     * @param int $post_id
88
+     */
89
+    public static function save( $post_id ) {
90 90
 
91 91
         // Prepare the form.
92 92
         $form = new GetPaid_Payment_Form( $post_id );
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit; // Exit if accessed directly
11 11
 }
12 12
 
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param WP_Post $post
22 22
 	 */
23
-    public static function output( $post ) {
23
+    public static function output($post) {
24 24
         ?>
25 25
         <div id="wpinv-form-builder" class="bsui">
26 26
             <div class="row">
27 27
                 <div class="col-sm-4">
28 28
 
29 29
                     <!-- Builder tabs -->
30
-                    <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e( 'Go Back', 'invoicing' ); ?></button>
30
+                    <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e('Go Back', 'invoicing'); ?></button>
31 31
 
32 32
                     <!-- Builder tab content -->
33 33
                     <div class="mt-4">
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
                         <!-- Available builder elements -->
36 36
                         <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'">
37 37
                             <div class="wpinv-form-builder-add-field-types">
38
-                                <small class='form-text text-muted'><?php _e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small>
38
+                                <small class='form-text text-muted'><?php _e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small>
39 39
                                 <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable">
40 40
                                     <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }">
41 41
                                         <button class="button btn">
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
                         <!-- Edit an element -->
51 51
                         <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 16px;">
52 52
                             <div class="wpinv-form-builder-edit-field-wrapper">
53
-                                <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?>
53
+                                <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?>
54 54
                                 <div>
55
-                                    <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e( 'Delete Element', 'invoicing' ); ?></button>
55
+                                    <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e('Delete Element', 'invoicing'); ?></button>
56 56
                                 </div>
57 57
                             </div>
58 58
                         </div>
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 
62 62
                 </div>
63 63
                 <div class="col-sm-8 border-left">
64
-                    <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small>
65
-                    <p class='form-text text-muted' v-if='! form_elements.length'><?php _e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p>
64
+                    <small class='form-text text-muted' v-if='form_elements.length'><?php _e('Click on any element to edit or delete it.', 'invoicing'); ?></small>
65
+                    <p class='form-text text-muted' v-if='! form_elements.length'><?php _e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p>
66 66
 
67 67
                     <draggable class="section bsui" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 16px;">
68 68
                         <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="{ active: active_form_element==form_element &&  active_tab=='edit_item' }" @click="active_tab = 'edit_item'; active_form_element = form_element">
69
-                            <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?>
69
+                            <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?>
70 70
                         </div>
71 71
                     </draggable>
72 72
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         </div>
79 79
         <?php
80 80
 
81
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
81
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
82 82
     }
83 83
 
84 84
     /**
@@ -86,49 +86,49 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @param int $post_id
88 88
 	 */
89
-	public static function save( $post_id ) {
89
+	public static function save($post_id) {
90 90
 
91 91
         // Prepare the form.
92
-        $form = new GetPaid_Payment_Form( $post_id );
92
+        $form = new GetPaid_Payment_Form($post_id);
93 93
 
94 94
         // Fetch form items.
95
-        $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true );
95
+        $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true);
96 96
 
97 97
         // Ensure that we have an array...
98
-        if ( empty( $form_items ) ) {
98
+        if (empty($form_items)) {
99 99
             $form_items = array();
100 100
         }
101 101
 
102 102
         // ... and that new items are saved to the db.
103
-        $form_items = self::maybe_save_items( $form_items );
103
+        $form_items = self::maybe_save_items($form_items);
104 104
 
105 105
         // Add it to the form.
106
-        $form->set_items( $form_items );
106
+        $form->set_items($form_items);
107 107
 
108 108
         // Save form elements.
109
-        $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true );
110
-        if ( empty( $form_elements ) ) {
109
+        $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true);
110
+        if (empty($form_elements)) {
111 111
             $form_elements = array();
112 112
         }
113 113
 
114
-        $form->set_elements( $form_elements );
114
+        $form->set_elements($form_elements);
115 115
 
116 116
         // Persist data to the datastore.
117 117
         $form->save();
118
-        do_action( 'getpaid_payment_form_metabox_save', $post_id, $form );
118
+        do_action('getpaid_payment_form_metabox_save', $post_id, $form);
119 119
 
120 120
     }
121 121
 
122 122
     /**
123 123
      * Saves unsaved form items.
124 124
      */
125
-    public static function maybe_save_items( $items ) {
125
+    public static function maybe_save_items($items) {
126 126
 
127 127
         $saved = array();
128 128
 
129
-        foreach( $items as $item ) {
129
+        foreach ($items as $item) {
130 130
 
131
-            if ( is_numeric( $item['id'] ) ) {
131
+            if (is_numeric($item['id'])) {
132 132
                 $saved[] = $item;
133 133
                 continue;
134 134
             }
@@ -138,32 +138,32 @@  discard block
 block discarded – undo
138 138
             // Save post data.
139 139
             $new_item->set_props(
140 140
                 array(
141
-                    'name'               => sanitize_text_field( $item['title'] ),
142
-                    'description'        => wp_kses_post( $item['description'] ),
141
+                    'name'               => sanitize_text_field($item['title']),
142
+                    'description'        => wp_kses_post($item['description']),
143 143
                     'status'             => 'publish',
144
-                    'type'               => empty( $item['type'] ) ? 'custom' : $item['type'],
145
-                    'price'              => wpinv_sanitize_amount( $item['price'] ),
146
-                    'vat_rule'           => empty( $item['rule'] ) ? 'digital' : $item['rule'],
147
-                    'vat_class'          => empty( $item['class'] ) ? '_standard' : $item['class'],
148
-                    'is_dynamic_pricing' => empty( $item['custom_price'] ) ? 0 : (int) $item['custom_price'],
149
-                    'minimum_price'      => empty( $item['minimum_price'] ) ? 0 : (float) $item['minimum_price'],
144
+                    'type'               => empty($item['type']) ? 'custom' : $item['type'],
145
+                    'price'              => wpinv_sanitize_amount($item['price']),
146
+                    'vat_rule'           => empty($item['rule']) ? 'digital' : $item['rule'],
147
+                    'vat_class'          => empty($item['class']) ? '_standard' : $item['class'],
148
+                    'is_dynamic_pricing' => empty($item['custom_price']) ? 0 : (int) $item['custom_price'],
149
+                    'minimum_price'      => empty($item['minimum_price']) ? 0 : (float) $item['minimum_price'],
150 150
                 )
151 151
             );
152 152
 
153 153
             // Save the item.
154 154
             $new_item->save();
155 155
 
156
-            if ( $new_item->get_id() ) {
156
+            if ($new_item->get_id()) {
157 157
                 $item['id'] = $new_item->get_id();
158 158
                 $saved[] = $item;
159 159
             }
160 160
 
161 161
         }
162 162
 
163
-        foreach ( $saved as $i => $item ) {
164
-            foreach ( array( 'new', 'type', 'class', 'rule', 'price', 'title', 'custom_price', 'minimum_price', 'recurring' ) as $key ) {
165
-                if ( isset( $item[ $key ] ) ) {
166
-                    unset( $saved[ $i ][ $key ] );
163
+        foreach ($saved as $i => $item) {
164
+            foreach (array('new', 'type', 'class', 'rule', 'price', 'title', 'custom_price', 'minimum_price', 'recurring') as $key) {
165
+                if (isset($item[$key])) {
166
+                    unset($saved[$i][$key]);
167 167
                 }
168 168
             }
169 169
         }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-discount-details.php 2 patches
Indentation   +26 added lines, -26 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
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Discount_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the discount.
@@ -368,34 +368,34 @@  discard block
 block discarded – undo
368 368
     }
369 369
 
370 370
     /**
371
-	 * Save meta box data.
372
-	 *
373
-	 * @param int $post_id
374
-	 */
375
-	public static function save( $post_id ) {
371
+     * Save meta box data.
372
+     *
373
+     * @param int $post_id
374
+     */
375
+    public static function save( $post_id ) {
376 376
 
377 377
         // Prepare the discount.
378 378
         $discount = new WPInv_Discount( $post_id );
379 379
 
380 380
         // Load new data.
381 381
         $discount->set_props(
382
-			array(
383
-				'code'                 => isset( $_POST['wpinv_discount_code'] ) ? $_POST['wpinv_discount_code'] : null,
384
-				'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? $_POST['wpinv_discount_amount'] : null,
385
-				'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
386
-				'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
387
-				'is_single_use'        => isset( $_POST['wpinv_discount_single_use'] ),
382
+            array(
383
+                'code'                 => isset( $_POST['wpinv_discount_code'] ) ? $_POST['wpinv_discount_code'] : null,
384
+                'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? $_POST['wpinv_discount_amount'] : null,
385
+                'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
386
+                'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
387
+                'is_single_use'        => isset( $_POST['wpinv_discount_single_use'] ),
388 388
                 'type'                 => isset( $_POST['wpinv_discount_type'] ) ? $_POST['wpinv_discount_type'] : null,
389
-				'is_recurring'         => isset( $_POST['wpinv_discount_recurring'] ),
390
-				'items'                => isset( $_POST['wpinv_discount_items'] ) ? $_POST['wpinv_discount_items'] : null,
391
-				'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? $_POST['wpinv_discount_excluded_items'] : null,
392
-				'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? $_POST['wpinv_discount_max_uses'] : null,
393
-				'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? $_POST['wpinv_discount_min_total'] : null,
394
-				'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? $_POST['wpinv_discount_max_total'] : null,
395
-			)
389
+                'is_recurring'         => isset( $_POST['wpinv_discount_recurring'] ),
390
+                'items'                => isset( $_POST['wpinv_discount_items'] ) ? $_POST['wpinv_discount_items'] : null,
391
+                'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? $_POST['wpinv_discount_excluded_items'] : null,
392
+                'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? $_POST['wpinv_discount_max_uses'] : null,
393
+                'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? $_POST['wpinv_discount_min_total'] : null,
394
+                'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? $_POST['wpinv_discount_max_total'] : null,
395
+            )
396 396
         );
397 397
 
398
-		$discount->save();
399
-		do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
400
-	}
398
+        $discount->save();
399
+        do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
400
+    }
401 401
 }
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 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,24 +21,24 @@  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 discount.
27
-        $discount = new WPInv_Discount( $post );
27
+        $discount = new WPInv_Discount($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32
-        do_action( 'wpinv_discount_form_top', $discount );
32
+        do_action('wpinv_discount_form_top', $discount);
33 33
 
34 34
         // Set the currency position.
35 35
         $position = wpinv_currency_position();
36 36
 
37
-        if ( $position == 'left_space' ) {
37
+        if ($position == 'left_space') {
38 38
             $position = 'left';
39 39
         }
40 40
 
41
-        if ( $position == 'right_space' ) {
41
+        if ($position == 'right_space') {
42 42
             $position = 'right';
43 43
         }
44 44
 
@@ -52,66 +52,66 @@  discard block
 block discarded – undo
52 52
         </style>
53 53
         <div class='bsui' style='max-width: 600px;padding-top: 10px;'>
54 54
 
55
-            <?php do_action( 'wpinv_discount_form_first', $discount ); ?>
55
+            <?php do_action('wpinv_discount_form_first', $discount); ?>
56 56
 
57
-            <?php do_action( 'wpinv_discount_form_before_code', $discount ); ?>
57
+            <?php do_action('wpinv_discount_form_before_code', $discount); ?>
58 58
             <div class="form-group row">
59 59
                 <label for="wpinv_discount_code" class="col-sm-3 col-form-label">
60
-                    <?php _e( 'Discount Code', 'invoicing' );?>
60
+                    <?php _e('Discount Code', 'invoicing'); ?>
61 61
                 </label>
62 62
                 <div class="col-sm-8">
63 63
                     <div class="row">
64 64
                         <div class="col-sm-12 form-group">
65
-                            <input type="text" value="<?php echo esc_attr( $discount->get_code( 'edit' ) ); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" />
65
+                            <input type="text" value="<?php echo esc_attr($discount->get_code('edit')); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" />
66 66
                         </div>
67 67
                         <div class="col-sm-12">
68 68
                             <?php
69
-                                do_action( 'wpinv_discount_form_before_single_use', $discount );
69
+                                do_action('wpinv_discount_form_before_single_use', $discount);
70 70
 
71 71
                                 echo aui()->input(
72 72
                                     array(
73 73
                                         'id'          => 'wpinv_discount_single_use',
74 74
                                         'name'        => 'wpinv_discount_single_use',
75 75
                                         'type'        => 'checkbox',
76
-                                        'label'       => __( 'Each customer can only use this discount once', 'invoicing' ),
76
+                                        'label'       => __('Each customer can only use this discount once', 'invoicing'),
77 77
                                         'value'       => '1',
78 78
                                         'checked'     => $discount->is_single_use(),
79 79
                                     )
80 80
                                 );
81 81
 
82
-                                do_action( 'wpinv_discount_form_single_use', $discount );
82
+                                do_action('wpinv_discount_form_single_use', $discount);
83 83
                             ?>
84 84
                         </div>
85 85
                         <div class="col-sm-12">
86 86
                             <?php
87
-                                do_action( 'wpinv_discount_form_before_recurring', $discount );
87
+                                do_action('wpinv_discount_form_before_recurring', $discount);
88 88
 
89 89
                                 echo aui()->input(
90 90
                                     array(
91 91
                                         'id'          => 'wpinv_discount_recurring',
92 92
                                         'name'        => 'wpinv_discount_recurring',
93 93
                                         'type'        => 'checkbox',
94
-                                        'label'       => __( 'Apply this discount to all recurring payments for subscriptions', 'invoicing' ),
94
+                                        'label'       => __('Apply this discount to all recurring payments for subscriptions', 'invoicing'),
95 95
                                         'value'       => '1',
96 96
                                         'checked'     => $discount->is_recurring(),
97 97
                                     )
98 98
                                 );
99 99
 
100
-                                do_action( 'wpinv_discount_form_recurring', $discount );
100
+                                do_action('wpinv_discount_form_recurring', $discount);
101 101
                             ?>
102 102
                         </div>
103 103
                     </div>
104 104
                 </div>
105 105
                 <div class="col-sm-1 pt-2 pl-0">
106
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter a discount code such as 10OFF.', 'invoicing' ); ?>"></span>
106
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter a discount code such as 10OFF.', 'invoicing'); ?>"></span>
107 107
                 </div>
108 108
             </div>
109
-            <?php do_action( 'wpinv_discount_form_code', $discount ); ?>
109
+            <?php do_action('wpinv_discount_form_code', $discount); ?>
110 110
 
111
-            <?php do_action( 'wpinv_discount_form_before_type', $discount ); ?>
111
+            <?php do_action('wpinv_discount_form_before_type', $discount); ?>
112 112
             <div class="form-group row">
113 113
                 <label for="wpinv_discount_type" class="col-sm-3 col-form-label">
114
-                    <?php _e( 'Discount Type', 'invoicing' );?>
114
+                    <?php _e('Discount Type', 'invoicing'); ?>
115 115
                 </label>
116 116
                 <div class="col-sm-8">
117 117
                     <?php
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
                             array(
120 120
                                 'id'               => 'wpinv_discount_type',
121 121
                                 'name'             => 'wpinv_discount_type',
122
-                                'label'            => __( 'Discount Type', 'invoicing' ),
123
-                                'placeholder'      => __( 'Select Discount Type', 'invoicing' ),
124
-                                'value'            => $discount->get_type( 'edit' ),
122
+                                'label'            => __('Discount Type', 'invoicing'),
123
+                                'placeholder'      => __('Select Discount Type', 'invoicing'),
124
+                                'value'            => $discount->get_type('edit'),
125 125
                                 'select2'          => true,
126 126
                                 'data-allow-clear' => 'false',
127 127
                                 'options'          => wpinv_get_discount_types()
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
                     ?>
131 131
                 </div>
132 132
                 <div class="col-sm-1 pt-2 pl-0">
133
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Discount type.', 'invoicing' ); ?>"></span>
133
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Discount type.', 'invoicing'); ?>"></span>
134 134
                 </div>
135 135
             </div>
136
-            <?php do_action( 'wpinv_discount_form_type', $discount ); ?>
136
+            <?php do_action('wpinv_discount_form_type', $discount); ?>
137 137
 
138
-            <?php do_action( 'wpinv_discount_form_before_amount', $discount ); ?>
139
-            <div class="form-group row <?php echo esc_attr( $discount->get_type( 'edit' ) ); ?>" id="wpinv_discount_amount_wrap">
138
+            <?php do_action('wpinv_discount_form_before_amount', $discount); ?>
139
+            <div class="form-group row <?php echo esc_attr($discount->get_type('edit')); ?>" id="wpinv_discount_amount_wrap">
140 140
                 <label for="wpinv_discount_amount" class="col-sm-3 col-form-label">
141
-                    <?php _e( 'Discount Amount', 'invoicing' );?>
141
+                    <?php _e('Discount Amount', 'invoicing'); ?>
142 142
                 </label>
143 143
                 <div class="col-sm-8">
144 144
                     <div class="input-group input-group-sm">
145
-                        <?php if( 'left' == $position ) : ?>
145
+                        <?php if ('left' == $position) : ?>
146 146
                             <div class="input-group-prepend left wpinv-if-flat">
147 147
                                 <span class="input-group-text">
148 148
                                     <?php echo wpinv_currency_symbol(); ?>
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
                             </div>
151 151
                         <?php endif; ?>
152 152
 
153
-                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr( $discount->get_amount( 'edit' ) ); ?>" placeholder="0" class="form-control">
153
+                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr($discount->get_amount('edit')); ?>" placeholder="0" class="form-control">
154 154
 
155
-                        <?php if( 'right' == $position ) : ?>
155
+                        <?php if ('right' == $position) : ?>
156 156
                             <div class="input-group-prepend left wpinv-if-flat">
157 157
                                 <span class="input-group-text">
158 158
                                     <?php echo wpinv_currency_symbol(); ?>
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
                     </div>
166 166
                 </div>
167 167
                 <div class="col-sm-1 pt-2 pl-0">
168
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?>"></span>
168
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the discount value. Ex: 10', 'invoicing'); ?>"></span>
169 169
                 </div>
170 170
             </div>
171
-            <?php do_action( 'wpinv_discount_form_amount', $discount ); ?>
171
+            <?php do_action('wpinv_discount_form_amount', $discount); ?>
172 172
 
173
-            <?php do_action( 'wpinv_discount_form_before_items', $discount ); ?>
173
+            <?php do_action('wpinv_discount_form_before_items', $discount); ?>
174 174
             <div class="form-group row">
175 175
                 <label for="wpinv_discount_items" class="col-sm-3 col-form-label">
176
-                    <?php _e( 'Items', 'invoicing' );?>
176
+                    <?php _e('Items', 'invoicing'); ?>
177 177
                 </label>
178 178
                 <div class="col-sm-8">
179 179
                     <?php
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
                             array(
182 182
                                 'id'               => 'wpinv_discount_items',
183 183
                                 'name'             => 'wpinv_discount_items',
184
-                                'label'            => __( 'Items', 'invoicing' ),
185
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
186
-                                'value'            => $discount->get_items( 'edit' ),
184
+                                'label'            => __('Items', 'invoicing'),
185
+                                'placeholder'      => __('Select Items', 'invoicing'),
186
+                                'value'            => $discount->get_items('edit'),
187 187
                                 'select2'          => true,
188 188
                                 'multiple'         => true,
189 189
                                 'data-allow-clear' => 'false',
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
                     ?>
194 194
                 </div>
195 195
                 <div class="col-sm-1 pt-2 pl-0">
196
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing' ); ?>"></span>
196
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing'); ?>"></span>
197 197
                 </div>
198 198
             </div>
199
-            <?php do_action( 'wpinv_discount_form_items', $discount ); ?>
199
+            <?php do_action('wpinv_discount_form_items', $discount); ?>
200 200
 
201
-            <?php do_action( 'wpinv_discount_form_before_excluded_items', $discount ); ?>
201
+            <?php do_action('wpinv_discount_form_before_excluded_items', $discount); ?>
202 202
             <div class="form-group row">
203 203
                 <label for="wpinv_discount_excluded_items" class="col-sm-3 col-form-label">
204
-                    <?php _e( 'Excluded Items', 'invoicing' );?>
204
+                    <?php _e('Excluded Items', 'invoicing'); ?>
205 205
                 </label>
206 206
                 <div class="col-sm-8">
207 207
                     <?php
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
                             array(
210 210
                                 'id'               => 'wpinv_discount_excluded_items',
211 211
                                 'name'             => 'wpinv_discount_excluded_items',
212
-                                'label'            => __( 'Excluded Items', 'invoicing' ),
213
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
214
-                                'value'            => $discount->get_excluded_items( 'edit' ),
212
+                                'label'            => __('Excluded Items', 'invoicing'),
213
+                                'placeholder'      => __('Select Items', 'invoicing'),
214
+                                'value'            => $discount->get_excluded_items('edit'),
215 215
                                 'select2'          => true,
216 216
                                 'multiple'         => true,
217 217
                                 'data-allow-clear' => 'false',
@@ -221,15 +221,15 @@  discard block
 block discarded – undo
221 221
                     ?>
222 222
                 </div>
223 223
                 <div class="col-sm-1 pt-2 pl-0">
224
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are not allowed to use this discount.', 'invoicing' ); ?>"></span>
224
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are not allowed to use this discount.', 'invoicing'); ?>"></span>
225 225
                 </div>
226 226
             </div>
227
-            <?php do_action( 'wpinv_discount_form_excluded_items', $discount ); ?>
227
+            <?php do_action('wpinv_discount_form_excluded_items', $discount); ?>
228 228
 
229
-            <?php do_action( 'wpinv_discount_form_before_start', $discount ); ?>
229
+            <?php do_action('wpinv_discount_form_before_start', $discount); ?>
230 230
             <div class="form-group row">
231 231
                 <label for="wpinv_discount_start" class="col-sm-3 col-form-label">
232
-                    <?php _e( 'Start Date', 'invoicing' );?>
232
+                    <?php _e('Start Date', 'invoicing'); ?>
233 233
                 </label>
234 234
                 <div class="col-sm-8">
235 235
                     <?php
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
                                 'type'        => 'datepicker',
239 239
                                 'id'          => 'wpinv_discount_start',
240 240
                                 'name'        => 'wpinv_discount_start',
241
-                                'label'       => __( 'Start Date', 'invoicing' ),
241
+                                'label'       => __('Start Date', 'invoicing'),
242 242
                                 'placeholder' => 'YYYY-MM-DD 00:00',
243 243
                                 'class'       => 'form-control-sm',
244
-                                'value'       => $discount->get_start_date( 'edit' ),
244
+                                'value'       => $discount->get_start_date('edit'),
245 245
                                 'extra_attributes' => array(
246 246
                                     'data-enable-time' => 'true',
247 247
                                     'data-time_24hr'   => 'true',
@@ -252,15 +252,15 @@  discard block
 block discarded – undo
252 252
                     ?>
253 253
                 </div>
254 254
                 <div class="col-sm-1 pt-2 pl-0">
255
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?>"></span>
255
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?>"></span>
256 256
                 </div>
257 257
             </div>
258
-            <?php do_action( 'wpinv_discount_form_start', $discount ); ?>
258
+            <?php do_action('wpinv_discount_form_start', $discount); ?>
259 259
 
260
-            <?php do_action( 'wpinv_discount_form_before_expiration', $discount ); ?>
260
+            <?php do_action('wpinv_discount_form_before_expiration', $discount); ?>
261 261
             <div class="form-group row">
262 262
                 <label for="wpinv_discount_expiration" class="col-sm-3 col-form-label">
263
-                    <?php _e( 'Expiration Date', 'invoicing' );?>
263
+                    <?php _e('Expiration Date', 'invoicing'); ?>
264 264
                 </label>
265 265
                 <div class="col-sm-8">
266 266
                     <?php
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
                                 'type'        => 'datepicker',
270 270
                                 'id'          => 'wpinv_discount_expiration',
271 271
                                 'name'        => 'wpinv_discount_expiration',
272
-                                'label'       => __( 'Expiration Date', 'invoicing' ),
272
+                                'label'       => __('Expiration Date', 'invoicing'),
273 273
                                 'placeholder' => 'YYYY-MM-DD 00:00',
274 274
                                 'class'       => 'form-control-sm',
275
-                                'value'       => $discount->get_end_date( 'edit' ),
275
+                                'value'       => $discount->get_end_date('edit'),
276 276
                                 'extra_attributes' => array(
277 277
                                     'data-enable-time' => 'true',
278 278
                                     'data-time_24hr'   => 'true',
@@ -285,27 +285,27 @@  discard block
 block discarded – undo
285 285
                     ?>
286 286
                 </div>
287 287
                 <div class="col-sm-1 pt-2 pl-0">
288
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the date after which the discount will expire.', 'invoicing' ); ?>"></span>
288
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the date after which the discount will expire.', 'invoicing'); ?>"></span>
289 289
                 </div>
290 290
             </div>
291
-            <?php do_action( 'wpinv_discount_form_expiration', $discount ); ?>
291
+            <?php do_action('wpinv_discount_form_expiration', $discount); ?>
292 292
 
293
-            <?php do_action( 'wpinv_discount_form_before_min_total', $discount ); ?>
293
+            <?php do_action('wpinv_discount_form_before_min_total', $discount); ?>
294 294
             <div class="form-group row">
295 295
                 <label for="wpinv_discount_min_total" class="col-sm-3 col-form-label">
296
-                    <?php _e( 'Minimum Amount', 'invoicing' );?>
296
+                    <?php _e('Minimum Amount', 'invoicing'); ?>
297 297
                 </label>
298 298
                 <div class="col-sm-8">
299 299
                     <div class="input-group input-group-sm">
300
-                        <?php if( 'left' == $position ) : ?>
300
+                        <?php if ('left' == $position) : ?>
301 301
                             <div class="input-group-prepend">
302 302
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
303 303
                             </div>
304 304
                         <?php endif; ?>
305 305
 
306
-                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr( $discount->get_minimum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No minimum', 'invoicing' ); ?>" class="form-control">
306
+                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr($discount->get_minimum_total('edit')); ?>" placeholder="<?php esc_attr_e('No minimum', 'invoicing'); ?>" class="form-control">
307 307
 
308
-                        <?php if( 'left' != $position ) : ?>
308
+                        <?php if ('left' != $position) : ?>
309 309
                             <div class="input-group-append">
310 310
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
311 311
                             </div>
@@ -313,27 +313,27 @@  discard block
 block discarded – undo
313 313
                     </div>
314 314
                 </div>
315 315
                 <div class="col-sm-1 pt-2 pl-0">
316
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing' ); ?>"></span>
316
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing'); ?>"></span>
317 317
                 </div>
318 318
             </div>
319
-            <?php do_action( 'wpinv_discount_form_min_total', $discount ); ?>
319
+            <?php do_action('wpinv_discount_form_min_total', $discount); ?>
320 320
 
321
-            <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?>
321
+            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?>
322 322
             <div class="form-group row">
323 323
                 <label for="wpinv_discount_max_total" class="col-sm-3 col-form-label">
324
-                    <?php _e( 'Maximum Amount', 'invoicing' );?>
324
+                    <?php _e('Maximum Amount', 'invoicing'); ?>
325 325
                 </label>
326 326
                 <div class="col-sm-8">
327 327
                     <div class="input-group input-group-sm">
328
-                        <?php if( 'left' == $position ) : ?>
328
+                        <?php if ('left' == $position) : ?>
329 329
                             <div class="input-group-prepend">
330 330
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
331 331
                             </div>
332 332
                         <?php endif; ?>
333 333
 
334
-                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr( $discount->get_maximum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No maximum', 'invoicing' ); ?>" class="form-control">
334
+                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr($discount->get_maximum_total('edit')); ?>" placeholder="<?php esc_attr_e('No maximum', 'invoicing'); ?>" class="form-control">
335 335
 
336
-                        <?php if( 'left' != $position ) : ?>
336
+                        <?php if ('left' != $position) : ?>
337 337
                             <div class="input-group-append">
338 338
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
339 339
                             </div>
@@ -341,30 +341,30 @@  discard block
 block discarded – undo
341 341
                     </div>
342 342
                 </div>
343 343
                 <div class="col-sm-1 pt-2 pl-0">
344
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing' ); ?>"></span>
344
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing'); ?>"></span>
345 345
                 </div>
346 346
             </div>
347
-            <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?>
347
+            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?>
348 348
 
349
-            <?php do_action( 'wpinv_discount_form_before_max_uses', $discount ); ?>
349
+            <?php do_action('wpinv_discount_form_before_max_uses', $discount); ?>
350 350
             <div class="form-group row">
351 351
                 <label for="wpinv_discount_max_uses" class="col-sm-3 col-form-label">
352
-                    <?php _e( 'Maximum Uses', 'invoicing' );?>
352
+                    <?php _e('Maximum Uses', 'invoicing'); ?>
353 353
                 </label>
354 354
                 <div class="col-sm-8">
355
-                    <input type="text" value="<?php echo esc_attr( $discount->get_max_uses( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'invoicing' ); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" />
355
+                    <input type="text" value="<?php echo esc_attr($discount->get_max_uses('edit')); ?>" placeholder="<?php esc_attr_e('Unlimited', 'invoicing'); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" />
356 356
                 </div>
357 357
                 <div class="col-sm-1 pt-2 pl-0">
358
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum number of times that this discount code can be used.', 'invoicing' ); ?>"></span>
358
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum number of times that this discount code can be used.', 'invoicing'); ?>"></span>
359 359
                 </div>
360 360
             </div>
361
-            <?php do_action( 'wpinv_discount_form_max_uses', $discount ); ?>
361
+            <?php do_action('wpinv_discount_form_max_uses', $discount); ?>
362 362
 
363
-            <?php do_action( 'wpinv_discount_form_last', $discount ); ?>
363
+            <?php do_action('wpinv_discount_form_last', $discount); ?>
364 364
 
365 365
         </div>
366 366
         <?php
367
-        do_action( 'wpinv_discount_form_bottom', $post );
367
+        do_action('wpinv_discount_form_bottom', $post);
368 368
     }
369 369
 
370 370
     /**
@@ -372,30 +372,30 @@  discard block
 block discarded – undo
372 372
 	 *
373 373
 	 * @param int $post_id
374 374
 	 */
375
-	public static function save( $post_id ) {
375
+	public static function save($post_id) {
376 376
 
377 377
         // Prepare the discount.
378
-        $discount = new WPInv_Discount( $post_id );
378
+        $discount = new WPInv_Discount($post_id);
379 379
 
380 380
         // Load new data.
381 381
         $discount->set_props(
382 382
 			array(
383
-				'code'                 => isset( $_POST['wpinv_discount_code'] ) ? $_POST['wpinv_discount_code'] : null,
384
-				'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? $_POST['wpinv_discount_amount'] : null,
385
-				'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
386
-				'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
387
-				'is_single_use'        => isset( $_POST['wpinv_discount_single_use'] ),
388
-                'type'                 => isset( $_POST['wpinv_discount_type'] ) ? $_POST['wpinv_discount_type'] : null,
389
-				'is_recurring'         => isset( $_POST['wpinv_discount_recurring'] ),
390
-				'items'                => isset( $_POST['wpinv_discount_items'] ) ? $_POST['wpinv_discount_items'] : null,
391
-				'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? $_POST['wpinv_discount_excluded_items'] : null,
392
-				'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? $_POST['wpinv_discount_max_uses'] : null,
393
-				'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? $_POST['wpinv_discount_min_total'] : null,
394
-				'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? $_POST['wpinv_discount_max_total'] : null,
383
+				'code'                 => isset($_POST['wpinv_discount_code']) ? $_POST['wpinv_discount_code'] : null,
384
+				'amount'               => isset($_POST['wpinv_discount_amount']) ? $_POST['wpinv_discount_amount'] : null,
385
+				'start'                => isset($_POST['wpinv_discount_start']) ? wpinv_clean($_POST['wpinv_discount_start']) : null,
386
+				'expiration'           => isset($_POST['wpinv_discount_expiration']) ? wpinv_clean($_POST['wpinv_discount_expiration']) : null,
387
+				'is_single_use'        => isset($_POST['wpinv_discount_single_use']),
388
+                'type'                 => isset($_POST['wpinv_discount_type']) ? $_POST['wpinv_discount_type'] : null,
389
+				'is_recurring'         => isset($_POST['wpinv_discount_recurring']),
390
+				'items'                => isset($_POST['wpinv_discount_items']) ? $_POST['wpinv_discount_items'] : null,
391
+				'excluded_items'       => isset($_POST['wpinv_discount_excluded_items']) ? $_POST['wpinv_discount_excluded_items'] : null,
392
+				'max_uses'             => isset($_POST['wpinv_discount_max_uses']) ? $_POST['wpinv_discount_max_uses'] : null,
393
+				'min_total'            => isset($_POST['wpinv_discount_min_total']) ? $_POST['wpinv_discount_min_total'] : null,
394
+				'max_total'            => isset($_POST['wpinv_discount_max_total']) ? $_POST['wpinv_discount_max_total'] : null,
395 395
 			)
396 396
         );
397 397
 
398 398
 		$discount->save();
399
-		do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
399
+		do_action('getpaid_discount_metabox_save', $post_id, $discount);
400 400
 	}
401 401
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-notes.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,39 +1,39 @@
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Notes {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $post;
10 10
 
11
-        $notes = wpinv_get_invoice_notes( $post->ID );
11
+        $notes = wpinv_get_invoice_notes($post->ID);
12 12
 
13 13
         echo '<ul class="invoice_notes">';
14 14
 
15
-        if ( $notes ) {
16
-            foreach( $notes as $note ) {
17
-                wpinv_get_invoice_note_line_item( $note );
15
+        if ($notes) {
16
+            foreach ($notes as $note) {
17
+                wpinv_get_invoice_note_line_item($note);
18 18
             }
19 19
 
20 20
         } else {
21
-            echo '<li>' . __( 'There are no notes yet.', 'invoicing' ) . '</li>';
21
+            echo '<li>' . __('There are no notes yet.', 'invoicing') . '</li>';
22 22
         }
23 23
 
24 24
         echo '</ul>';
25 25
         ?>
26 26
         <div class="add_note">
27
-            <h4><?php _e( 'Add note', 'invoicing' ); ?></h4>
27
+            <h4><?php _e('Add note', 'invoicing'); ?></h4>
28 28
             <p>
29 29
                 <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea>
30 30
             </p>
31 31
             <p>
32 32
                 <select name="invoice_note_type" id="invoice_note_type" class="regular-text">
33
-                    <option value=""><?php _e( 'Private note', 'invoicing' ); ?></option>
34
-                    <option value="customer"><?php _e( 'Note to customer', 'invoicing' ); ?></option>
33
+                    <option value=""><?php _e('Private note', 'invoicing'); ?></option>
34
+                    <option value="customer"><?php _e('Note to customer', 'invoicing'); ?></option>
35 35
                 </select>
36
-                <a href="#" class="add_note button"><?php _e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php _e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span>
36
+                <a href="#" class="add_note button"><?php _e('Add', 'invoicing'); ?></a> <span class="description"><?php _e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span>
37 37
             </p>
38 38
         </div>
39 39
         <?php
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-details.php 2 patches
Indentation   +27 added lines, -27 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
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Item_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the item.
@@ -289,35 +289,35 @@  discard block
 block discarded – undo
289 289
     }
290 290
 
291 291
     /**
292
-	 * Save meta box data.
293
-	 *
294
-	 * @param int $post_id
295
-	 */
296
-	public static function save( $post_id ) {
292
+     * Save meta box data.
293
+     *
294
+     * @param int $post_id
295
+     */
296
+    public static function save( $post_id ) {
297 297
 
298 298
         // Prepare the item.
299 299
         $item = new WPInv_Item( $post_id );
300 300
 
301 301
         // Load new data.
302 302
         $item->set_props(
303
-			array(
304
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null,
305
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
306
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
307
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
308
-				'is_dynamic_pricing'   => isset( $_POST['wpinv_name_your_price'] ),
303
+            array(
304
+                'price'                => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null,
305
+                'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
306
+                'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
307
+                'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
308
+                'is_dynamic_pricing'   => isset( $_POST['wpinv_name_your_price'] ),
309 309
                 'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null,
310
-				'is_recurring'         => isset( $_POST['wpinv_is_recurring'] ),
311
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
312
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : null,
313
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
314
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
315
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
316
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
317
-			)
310
+                'is_recurring'         => isset( $_POST['wpinv_is_recurring'] ),
311
+                'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
312
+                'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : null,
313
+                'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
314
+                'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
315
+                'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
316
+                'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
317
+            )
318 318
         );
319 319
 
320
-		$item->save();
321
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
322
-	}
320
+        $item->save();
321
+        do_action( 'getpaid_item_metabox_save', $post_id, $item );
322
+    }
323 323
 }
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 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,27 +21,27 @@  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 item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32 32
         // Set the currency position.
33 33
         $position = wpinv_currency_position();
34 34
 
35
-        if ( $position == 'left_space' ) {
35
+        if ($position == 'left_space') {
36 36
             $position = 'left';
37 37
         }
38 38
 
39
-        if ( $position == 'right_space' ) {
39
+        if ($position == 'right_space') {
40 40
             $position = 'right';
41 41
         }
42 42
 
43 43
         ?>
44
-        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" />
44
+        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" />
45 45
         <input type="hidden" id="_wpi_is_editable" value="<?php echo (int) $item->is_editable(); ?>" />
46 46
         <style>
47 47
             #poststuff .input-group-text,
@@ -51,21 +51,21 @@  discard block
 block discarded – undo
51 51
         </style>
52 52
         <div class='bsui' style='max-width: 600px;padding-top: 10px; max-width: 820px;'>
53 53
 
54
-            <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?>
54
+            <?php do_action('wpinv_item_details_metabox_before_price', $item); ?>
55 55
             <div class="form-group row">
56
-                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label>
56
+                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label>
57 57
                 <div class="col-sm-8">
58 58
                     <div class="row">
59 59
                         <div class="col-sm-4 getpaid-price-input">
60 60
                             <div class="input-group input-group-sm">
61
-                                <?php if( 'left' == $position ) : ?>
61
+                                <?php if ('left' == $position) : ?>
62 62
                                 <div class="input-group-prepend">
63 63
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
64 64
                                 </div>
65 65
                                 <?php endif; ?>
66
-                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( $item->get_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
66
+                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr($item->get_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
67 67
 
68
-                                <?php if( 'left' != $position ) : ?>
68
+                                <?php if ('left' != $position) : ?>
69 69
                                 <div class="input-group-append">
70 70
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
71 71
                                 </div>
@@ -79,25 +79,25 @@  discard block
 block discarded – undo
79 79
                                     array(
80 80
                                         'id'               => 'wpinv_recurring_interval',
81 81
                                         'name'             => 'wpinv_recurring_interval',
82
-                                        'label'            => __( 'Interval', 'invoicing' ),
83
-                                        'placeholder'      => __( 'Select Interval', 'invoicing' ),
84
-                                        'value'            => $item->get_recurring_interval( 'edit' ),
82
+                                        'label'            => __('Interval', 'invoicing'),
83
+                                        'placeholder'      => __('Select Interval', 'invoicing'),
84
+                                        'value'            => $item->get_recurring_interval('edit'),
85 85
                                         'select2'          => true,
86 86
                                         'data-allow-clear' => 'false',
87 87
                                         'options'          => array(
88
-                                            '1'  => __( 'every', 'invoicing' ),
89
-                                            '2'  => __( 'every 2nd', 'invoicing' ),
90
-                                            '3'  => __( 'every 3rd', 'invoicing' ),
91
-                                            '4'  => __( 'every 4th', 'invoicing' ),
92
-                                            '5'  => __( 'every 5th', 'invoicing' ),
93
-                                            '6'  => __( 'every 6th', 'invoicing' ),
94
-                                            '8'  => __( 'every 8th', 'invoicing' ),
95
-                                            '9'  => __( 'every 9th', 'invoicing' ),
96
-                                            '10' => __( 'every 10th', 'invoicing' ),
97
-                                            '11' => __( 'every 11th', 'invoicing' ),
98
-                                            '12' => __( 'every 12th', 'invoicing' ),
99
-                                            '13' => __( 'every 13th', 'invoicing' ),
100
-                                            '14' => __( 'every 14th', 'invoicing' ),
88
+                                            '1'  => __('every', 'invoicing'),
89
+                                            '2'  => __('every 2nd', 'invoicing'),
90
+                                            '3'  => __('every 3rd', 'invoicing'),
91
+                                            '4'  => __('every 4th', 'invoicing'),
92
+                                            '5'  => __('every 5th', 'invoicing'),
93
+                                            '6'  => __('every 6th', 'invoicing'),
94
+                                            '8'  => __('every 8th', 'invoicing'),
95
+                                            '9'  => __('every 9th', 'invoicing'),
96
+                                            '10' => __('every 10th', 'invoicing'),
97
+                                            '11' => __('every 11th', 'invoicing'),
98
+                                            '12' => __('every 12th', 'invoicing'),
99
+                                            '13' => __('every 13th', 'invoicing'),
100
+                                            '14' => __('every 14th', 'invoicing'),
101 101
                                         )
102 102
                                     )
103 103
                                 );
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
                                     array(
110 110
                                         'id'               => 'wpinv_recurring_period',
111 111
                                         'name'             => 'wpinv_recurring_period',
112
-                                        'label'            => __( 'Period', 'invoicing' ),
113
-                                        'placeholder'      => __( 'Select Period', 'invoicing' ),
114
-                                        'value'            => $item->get_recurring_period( 'edit' ),
112
+                                        'label'            => __('Period', 'invoicing'),
113
+                                        'placeholder'      => __('Select Period', 'invoicing'),
114
+                                        'value'            => $item->get_recurring_period('edit'),
115 115
                                         'select2'          => true,
116 116
                                         'data-allow-clear' => 'false',
117 117
                                         'options'     => array(
118
-                                            'D'  => __( 'day', 'invoicing' ),
119
-                                            'W'  => __( 'week', 'invoicing' ),
120
-                                            'M'  => __( 'month', 'invoicing' ),
121
-                                            'Y'  => __( 'year', 'invoicing' ),
118
+                                            'D'  => __('day', 'invoicing'),
119
+                                            'W'  => __('week', 'invoicing'),
120
+                                            'M'  => __('month', 'invoicing'),
121
+                                            'Y'  => __('year', 'invoicing'),
122 122
                                         )
123 123
                                     )
124 124
                                 );
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
                             <?php
131 131
 
132 132
                                 // Dynamic pricing.
133
-                                if( $item->supports_dynamic_pricing() ) {
133
+                                if ($item->supports_dynamic_pricing()) {
134 134
 
135
-                                    do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
135
+                                    do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item);
136 136
 
137 137
                                     // NYP toggle.
138 138
                                     echo aui()->input(
@@ -140,31 +140,31 @@  discard block
 block discarded – undo
140 140
                                             'id'          => 'wpinv_name_your_price',
141 141
                                             'name'        => 'wpinv_name_your_price',
142 142
                                             'type'        => 'checkbox',
143
-                                            'label'       => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
143
+                                            'label'       => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')),
144 144
                                             'value'       => '1',
145 145
                                             'checked'     => $item->user_can_set_their_price(),
146 146
                                             'no_wrap'     => true,
147 147
                                         )
148 148
                                     );
149 149
 
150
-                                    do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
150
+                                    do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item);
151 151
 
152 152
                                 }
153 153
 
154 154
                                 // Subscriptions.
155
-                                do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item );
155
+                                do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item);
156 156
                                 echo aui()->input(
157 157
                                     array(
158 158
                                         'id'          => 'wpinv_is_recurring',
159 159
                                         'name'        => 'wpinv_is_recurring',
160 160
                                         'type'        => 'checkbox',
161
-                                        'label'       => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ),
161
+                                        'label'       => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')),
162 162
                                         'value'       => '1',
163 163
                                         'checked'     => $item->is_recurring(),
164 164
                                         'no_wrap'     => true,
165 165
                                     )
166 166
                                 );
167
-                                do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item );
167
+                                do_action('wpinv_item_details_metabox_subscription_checkbox', $item);
168 168
 
169 169
                             ?>
170 170
                             <div class="wpinv_show_if_recurring">
@@ -174,30 +174,30 @@  discard block
 block discarded – undo
174 174
                     </div>
175 175
                 </div>
176 176
                 <div class="col-sm-1 pt-2 pl-0">
177
-                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span>
177
+                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span>
178 178
                 </div>
179 179
             </div>
180
-            <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?>
180
+            <?php do_action('wpinv_item_details_metabox_after_price', $item); ?>
181 181
 
182
-            <?php if( $item->supports_dynamic_pricing() ) : ?>
183
-                <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?>
182
+            <?php if ($item->supports_dynamic_pricing()) : ?>
183
+                <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?>
184 184
                 <div class="wpinv_show_if_dynamic wpinv_minimum_price">
185 185
 
186 186
                     <div class="form-group row">
187 187
                         <label for="wpinv_minimum_price" class="col-sm-3 col-form-label">
188
-                            <?php _e( 'Minimum Price', 'invoicing' );?>
188
+                            <?php _e('Minimum Price', 'invoicing'); ?>
189 189
                         </label>
190 190
                         <div class="col-sm-8">
191 191
                             <div class="input-group input-group-sm">
192
-                                <?php if( 'left' == $position ) : ?>
192
+                                <?php if ('left' == $position) : ?>
193 193
                                     <div class="input-group-prepend">
194 194
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
195 195
                                     </div>
196 196
                                 <?php endif; ?>
197 197
 
198
-                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( $item->get_minimum_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
198
+                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr($item->get_minimum_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
199 199
 
200
-                                <?php if( 'left' != $position ) : ?>
200
+                                <?php if ('left' != $position) : ?>
201 201
                                     <div class="input-group-append">
202 202
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
203 203
                                     </div>
@@ -206,45 +206,45 @@  discard block
 block discarded – undo
206 206
                         </div>
207 207
 
208 208
                         <div class="col-sm-1 pt-2 pl-0">
209
-                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span>
209
+                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span>
210 210
                         </div>
211 211
                     </div>
212 212
 
213 213
                 </div>
214
-                <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?>
214
+                <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?>
215 215
             <?php endif; ?>
216 216
 
217
-            <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?>
217
+            <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?>
218 218
             <div class="wpinv_show_if_recurring wpinv_maximum_renewals">
219 219
 
220 220
                 <div class="form-group row">
221 221
                     <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label">
222
-                        <?php _e( 'Maximum Renewals', 'invoicing' );?>
222
+                        <?php _e('Maximum Renewals', 'invoicing'); ?>
223 223
                     </label>
224 224
                     <div class="col-sm-8">
225
-                        <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
225
+                        <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
226 226
                     </div>
227 227
                     <div class="col-sm-1 pt-2 pl-0">
228
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span>
228
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span>
229 229
                     </div>
230 230
                 </div>
231 231
 
232 232
             </div>
233
-            <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?>
233
+            <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?>
234 234
 
235
-            <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?>
235
+            <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?>
236 236
             <div class="wpinv_show_if_recurring wpinv_free_trial">
237 237
 
238 238
                 <div class="form-group row">
239
-                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e( 'Free Trial', 'invoicing' )?></label>
239
+                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e('Free Trial', 'invoicing')?></label>
240 240
 
241 241
                     <div class="col-sm-8">
242 242
                         <div class="row">
243 243
                             <div class="col-sm-6">
244
-                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?>
244
+                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?>
245 245
 
246 246
                                 <div>
247
-                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" >
247
+                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" >
248 248
                                 </div>
249 249
                             </div>
250 250
                             <div class="col-sm-6">
@@ -253,17 +253,17 @@  discard block
 block discarded – undo
253 253
                                         array(
254 254
                                             'id'               => 'wpinv_trial_period',
255 255
                                             'name'             => 'wpinv_trial_period',
256
-                                            'label'            => __( 'Trial Period', 'invoicing' ),
257
-                                            'placeholder'      => __( 'Trial Period', 'invoicing' ),
258
-                                            'value'            => $item->get_recurring_period( 'edit' ),
256
+                                            'label'            => __('Trial Period', 'invoicing'),
257
+                                            'placeholder'      => __('Trial Period', 'invoicing'),
258
+                                            'value'            => $item->get_recurring_period('edit'),
259 259
                                             'select2'          => true,
260 260
                                             'data-allow-clear' => 'false',
261 261
                                             'no_wrap'          => true,
262 262
                                             'options'          => array(
263
-                                                'D'  => __( 'day(s)', 'invoicing' ),
264
-                                                'W'  => __( 'week(s)', 'invoicing' ),
265
-                                                'M'  => __( 'month(s)', 'invoicing' ),
266
-                                                'Y'  => __( 'year(s)', 'invoicing' ),
263
+                                                'D'  => __('day(s)', 'invoicing'),
264
+                                                'W'  => __('week(s)', 'invoicing'),
265
+                                                'M'  => __('month(s)', 'invoicing'),
266
+                                                'Y'  => __('year(s)', 'invoicing'),
267 267
                                             )
268 268
                                         )
269 269
                                     );
@@ -274,15 +274,15 @@  discard block
 block discarded – undo
274 274
                     </div>
275 275
 
276 276
                     <div class="col-sm-1 pt-2 pl-0">
277
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span>
277
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span>
278 278
                     </div>
279 279
 
280 280
                 </div>
281 281
 
282 282
             </div>
283
-            <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?>
283
+            <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?>
284 284
 
285
-            <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?>
285
+            <?php do_action('wpinv_item_details_metabox_item_details', $item); ?>
286 286
         </div>
287 287
         <?php
288 288
 
@@ -293,31 +293,31 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @param int $post_id
295 295
 	 */
296
-	public static function save( $post_id ) {
296
+	public static function save($post_id) {
297 297
 
298 298
         // Prepare the item.
299
-        $item = new WPInv_Item( $post_id );
299
+        $item = new WPInv_Item($post_id);
300 300
 
301 301
         // Load new data.
302 302
         $item->set_props(
303 303
 			array(
304
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null,
305
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
306
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
307
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
308
-				'is_dynamic_pricing'   => isset( $_POST['wpinv_name_your_price'] ),
309
-                'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null,
310
-				'is_recurring'         => isset( $_POST['wpinv_is_recurring'] ),
311
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
312
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : null,
313
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
314
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
315
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
316
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
304
+				'price'                => isset($_POST['wpinv_item_price']) ? (float) $_POST['wpinv_item_price'] : null,
305
+				'vat_rule'             => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null,
306
+				'vat_class'            => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null,
307
+				'type'                 => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null,
308
+				'is_dynamic_pricing'   => isset($_POST['wpinv_name_your_price']),
309
+                'minimum_price'        => isset($_POST['wpinv_minimum_price']) ? (float) $_POST['wpinv_minimum_price'] : null,
310
+				'is_recurring'         => isset($_POST['wpinv_is_recurring']),
311
+				'recurring_period'     => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null,
312
+				'recurring_interval'   => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : null,
313
+				'recurring_limit'      => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null,
314
+				'is_free_trial'        => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null,
315
+				'trial_period'         => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null,
316
+				'trial_interval'       => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null,
317 317
 			)
318 318
         );
319 319
 
320 320
 		$item->save();
321
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
321
+		do_action('getpaid_item_metabox_save', $post_id, $item);
322 322
 	}
323 323
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-address.php 2 patches
Indentation   +14 added lines, -14 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
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Invoice_Address {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the invoice.
@@ -300,18 +300,18 @@  discard block
 block discarded – undo
300 300
     }
301 301
 
302 302
     /**
303
-	 * Save meta box data.
304
-	 *
305
-	 * @param int $post_id
306
-	 */
307
-	public static function save( $post_id ) {
303
+     * Save meta box data.
304
+     *
305
+     * @param int $post_id
306
+     */
307
+    public static function save( $post_id ) {
308 308
 
309 309
         // Prepare the invoice.
310 310
         $invoice = new WPInv_Invoice( $post_id );
311 311
 
312 312
         // Load new data.
313 313
         $invoice->set_props(
314
-			array(
314
+            array(
315 315
                 'template'             => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
316 316
                 'email_cc'             => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
317 317
                 'disable_taxes'        => isset( $_POST['disable_taxes'] ),
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
                 'due_date'             => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
333 333
                 'number'               => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
334 334
                 'status'               => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
335
-			)
335
+            )
336 336
         );
337 337
 
338 338
         // Recalculate totals.
@@ -362,6 +362,6 @@  discard block
 block discarded – undo
362 362
         }
363 363
 
364 364
         // Fires after an invoice is saved.
365
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
366
-	}
365
+        do_action( 'wpinv_invoice_metabox_saved', $invoice );
366
+    }
367 367
 }
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 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,12 +21,12 @@  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 );
27
+        $invoice = new WPInv_Invoice($post);
28 28
 
29
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
29
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
30 30
 
31 31
         ?>
32 32
 
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
                         <div class="col-12 col-sm-6">
43 43
                             <div id="getpaid-invoice-user-id-wrapper" class="form-group">
44 44
                                 <div>
45
-                                    <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label>
45
+                                    <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label>
46 46
                                 </div>
47 47
                                 <?php 
48 48
                                     wpinv_dropdown_users(
49 49
                                         array(
50 50
                                             'name'             => 'post_author_override',
51
-                                            'selected'         => $invoice->get_id() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(),
51
+                                            'selected'         => $invoice->get_id() ? $invoice->get_user_id('edit') : get_current_user_id(),
52 52
                                             'include_selected' => true,
53 53
                                             'show'             => 'display_name_with_email',
54 54
                                             'orderby'          => 'user_email',
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
                                             'type'        => 'text',
67 67
                                             'id'          => 'getpaid-invoice-new-user-email',
68 68
                                             'name'        => 'wpinv_email',
69
-                                            'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
69
+                                            'label'       => __('Email', 'invoicing') . '<span class="required">*</span>',
70 70
                                             'label_type'  => 'vertical',
71 71
                                             'placeholder' => '[email protected]',
72 72
                                             'class'       => 'form-control-sm',
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
                             </div>
77 77
                         </div>
78 78
                         <div class="col-12 col-sm-6 form-group mt-sm-4">
79
-                            <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
79
+                            <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
80 80
                                 <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)">
81 81
                                     <i aria-hidden="true" class="fa fa-refresh"></i>
82
-                                    <?php _e( 'Fill User Details', 'invoicing' );?>
82
+                                    <?php _e('Fill User Details', 'invoicing'); ?>
83 83
                                 </a>
84 84
                                 <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)">
85 85
                                     <i aria-hidden="true" class="fa fa-plus"></i>
86
-                                    <?php _e( 'Add New User', 'invoicing' );?>
86
+                                    <?php _e('Add New User', 'invoicing'); ?>
87 87
                                 </a>
88 88
                                 <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)">
89 89
                                     <i aria-hidden="true" class="fa fa-close"></i>
90
-                                    <?php _e( 'Cancel', 'invoicing' );?>
90
+                                    <?php _e('Cancel', 'invoicing'); ?>
91 91
                                 </a>
92 92
                             <?php endif; ?>
93 93
                         </div>
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
                                         'type'        => 'text',
101 101
                                         'id'          => 'wpinv_first_name',
102 102
                                         'name'        => 'wpinv_first_name',
103
-                                        'label'       => __( 'First Name', 'invoicing' ),
103
+                                        'label'       => __('First Name', 'invoicing'),
104 104
                                         'label_type'  => 'vertical',
105 105
                                         'placeholder' => 'Jane',
106 106
                                         'class'       => 'form-control-sm',
107
-                                        'value'       => $invoice->get_first_name( 'edit' ),
107
+                                        'value'       => $invoice->get_first_name('edit'),
108 108
                                     )
109 109
                                 );
110 110
                             ?>
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
                                         'type'        => 'text',
117 117
                                         'id'          => 'wpinv_last_name',
118 118
                                         'name'        => 'wpinv_last_name',
119
-                                        'label'       => __( 'Last Name', 'invoicing' ),
119
+                                        'label'       => __('Last Name', 'invoicing'),
120 120
                                         'label_type'  => 'vertical',
121 121
                                         'placeholder' => 'Doe',
122 122
                                         'class'       => 'form-control-sm',
123
-                                        'value'       => $invoice->get_last_name( 'edit' ),
123
+                                        'value'       => $invoice->get_last_name('edit'),
124 124
                                     )
125 125
                                 );
126 126
                             ?>
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
                                         'type'        => 'text',
136 136
                                         'id'          => 'wpinv_company',
137 137
                                         'name'        => 'wpinv_company',
138
-                                        'label'       => __( 'Company', 'invoicing' ),
138
+                                        'label'       => __('Company', 'invoicing'),
139 139
                                         'label_type'  => 'vertical',
140 140
                                         'placeholder' => 'Acme Corporation',
141 141
                                         'class'       => 'form-control-sm',
142
-                                        'value'       => $invoice->get_company( 'edit' ),
142
+                                        'value'       => $invoice->get_company('edit'),
143 143
                                     )
144 144
                                 );
145 145
                             ?>
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
                                         'type'        => 'text',
152 152
                                         'id'          => 'wpinv_vat_number',
153 153
                                         'name'        => 'wpinv_vat_number',
154
-                                        'label'       => __( 'Vat Number', 'invoicing' ),
154
+                                        'label'       => __('Vat Number', 'invoicing'),
155 155
                                         'label_type'  => 'vertical',
156 156
                                         'placeholder' => '1234567890',
157 157
                                         'class'       => 'form-control-sm',
158
-                                        'value'       => $invoice->get_vat_number( 'edit' ),
158
+                                        'value'       => $invoice->get_vat_number('edit'),
159 159
                                     )
160 160
                                 );
161 161
                             ?>
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
                                         'type'        => 'text',
171 171
                                         'id'          => 'wpinv_address',
172 172
                                         'name'        => 'wpinv_address',
173
-                                        'label'       => __( 'Address', 'invoicing' ),
173
+                                        'label'       => __('Address', 'invoicing'),
174 174
                                         'label_type'  => 'vertical',
175 175
                                         'placeholder' => 'Blekersdijk 295',
176 176
                                         'class'       => 'form-control-sm',
177
-                                        'value'       => $invoice->get_address( 'edit' ),
177
+                                        'value'       => $invoice->get_address('edit'),
178 178
                                     )
179 179
                                 );
180 180
                             ?>
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
                                         'type'        => 'text',
187 187
                                         'id'          => 'wpinv_city',
188 188
                                         'name'        => 'wpinv_city',
189
-                                        'label'       => __( 'City', 'invoicing' ),
189
+                                        'label'       => __('City', 'invoicing'),
190 190
                                         'label_type'  => 'vertical',
191 191
                                         'placeholder' => 'Dolembreux',
192 192
                                         'class'       => 'form-control-sm',
193
-                                        'value'       => $invoice->get_vat_number( 'edit' ),
193
+                                        'value'       => $invoice->get_vat_number('edit'),
194 194
                                     )
195 195
                                 );
196 196
                             ?>
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
                                     array(
205 205
                                         'id'          => 'wpinv_country',
206 206
                                         'name'        => 'wpinv_country',
207
-                                        'label'       => __( 'Country', 'invoicing' ),
207
+                                        'label'       => __('Country', 'invoicing'),
208 208
                                         'label_type'  => 'vertical',
209
-                                        'placeholder' => __( 'Choose a country', 'invoicing' ),
209
+                                        'placeholder' => __('Choose a country', 'invoicing'),
210 210
                                         'class'       => 'form-control-sm',
211
-                                        'value'       => $invoice->get_country( 'edit' ),
211
+                                        'value'       => $invoice->get_country('edit'),
212 212
                                         'options'     => wpinv_get_country_list(),
213 213
                                         'data-allow-clear' => 'false',
214 214
                                         'select2'          => true,
@@ -219,20 +219,20 @@  discard block
 block discarded – undo
219 219
                         <div class="col-12 col-sm-6">
220 220
                             <?php
221 221
 
222
-                                $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
222
+                                $states = wpinv_get_country_states($invoice->get_country('edit'));
223 223
 
224
-                                if ( empty( $states ) ) {
224
+                                if (empty($states)) {
225 225
 
226 226
                                     echo aui()->input(
227 227
                                         array(
228 228
                                             'type'        => 'text',
229 229
                                             'id'          => 'wpinv_state',
230 230
                                             'name'        => 'wpinv_state',
231
-                                            'label'       => __( 'State', 'invoicing' ),
231
+                                            'label'       => __('State', 'invoicing'),
232 232
                                             'label_type'  => 'vertical',
233 233
                                             'placeholder' => 'Liège',
234 234
                                             'class'       => 'form-control-sm',
235
-                                            'value'       => $invoice->get_state( 'edit' ),
235
+                                            'value'       => $invoice->get_state('edit'),
236 236
                                         )
237 237
                                     );
238 238
 
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
                                         array(
243 243
                                             'id'          => 'wpinv_state',
244 244
                                             'name'        => 'wpinv_state',
245
-                                            'label'       => __( 'State', 'invoicing' ),
245
+                                            'label'       => __('State', 'invoicing'),
246 246
                                             'label_type'  => 'vertical',
247
-                                            'placeholder' => __( 'Select a state', 'invoicing' ),
247
+                                            'placeholder' => __('Select a state', 'invoicing'),
248 248
                                             'class'       => 'form-control-sm',
249
-                                            'value'       => $invoice->get_state( 'edit' ),
249
+                                            'value'       => $invoice->get_state('edit'),
250 250
                                             'options'     => $states,
251 251
                                             'data-allow-clear' => 'false',
252 252
                                             'select2'          => true,
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
                                         'type'        => 'text',
268 268
                                         'id'          => 'wpinv_zip',
269 269
                                         'name'        => 'wpinv_zip',
270
-                                        'label'       => __( 'Zip / Postal Code', 'invoicing' ),
270
+                                        'label'       => __('Zip / Postal Code', 'invoicing'),
271 271
                                         'label_type'  => 'vertical',
272 272
                                         'placeholder' => '4140',
273 273
                                         'class'       => 'form-control-sm',
274
-                                        'value'       => $invoice->get_zip( 'edit' ),
274
+                                        'value'       => $invoice->get_zip('edit'),
275 275
                                     )
276 276
                                 );
277 277
                             ?>
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
                                         'type'        => 'text',
284 284
                                         'id'          => 'wpinv_phone',
285 285
                                         'name'        => 'wpinv_phone',
286
-                                        'label'       => __( 'Phone', 'invoicing' ),
286
+                                        'label'       => __('Phone', 'invoicing'),
287 287
                                         'label_type'  => 'vertical',
288 288
                                         'placeholder' => '0493 18 45822',
289 289
                                         'class'       => 'form-control-sm',
290
-                                        'value'       => $invoice->get_phone( 'edit' ),
290
+                                        'value'       => $invoice->get_phone('edit'),
291 291
                                     )
292 292
                                 );
293 293
                             ?>
@@ -304,34 +304,34 @@  discard block
 block discarded – undo
304 304
 	 *
305 305
 	 * @param int $post_id
306 306
 	 */
307
-	public static function save( $post_id ) {
307
+	public static function save($post_id) {
308 308
 
309 309
         // Prepare the invoice.
310
-        $invoice = new WPInv_Invoice( $post_id );
310
+        $invoice = new WPInv_Invoice($post_id);
311 311
 
312 312
         // Load new data.
313 313
         $invoice->set_props(
314 314
 			array(
315
-                'template'             => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
316
-                'email_cc'             => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
317
-                'disable_taxes'        => isset( $_POST['disable_taxes'] ),
318
-                'currency'             => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null,
319
-                'gateway'              => isset( $_POST['wpinv_gateway'] ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null,
320
-                'address'              => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null,
321
-                'vat_number'           => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null,
322
-                'company'              => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null,
323
-                'zip'                  => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null,
324
-                'state'                => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null,
325
-                'city'                 => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null,
326
-                'country'              => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null,
327
-                'phone'                => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null,
328
-                'first_name'           => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null,
329
-                'last_name'            => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null,
330
-                'author'               => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null,
331
-                'date_created'         => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null,
332
-                'due_date'             => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
333
-                'number'               => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
334
-                'status'               => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
315
+                'template'             => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null,
316
+                'email_cc'             => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null,
317
+                'disable_taxes'        => isset($_POST['disable_taxes']),
318
+                'currency'             => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null,
319
+                'gateway'              => isset($_POST['wpinv_gateway']) ? wpinv_clean($_POST['wpinv_gateway']) : null,
320
+                'address'              => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null,
321
+                'vat_number'           => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null,
322
+                'company'              => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null,
323
+                'zip'                  => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null,
324
+                'state'                => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null,
325
+                'city'                 => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null,
326
+                'country'              => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null,
327
+                'phone'                => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null,
328
+                'first_name'           => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null,
329
+                'last_name'            => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null,
330
+                'author'               => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null,
331
+                'date_created'         => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null,
332
+                'due_date'             => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null,
333
+                'number'               => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null,
334
+                'status'               => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null,
335 335
 			)
336 336
         );
337 337
 
@@ -339,17 +339,17 @@  discard block
 block discarded – undo
339 339
         $invoice->recalculate_total();
340 340
 
341 341
         // If we're creating a new user...
342
-        if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( $_POST['wpinv_email'] ) ) {
342
+        if (!empty($_POST['wpinv_new_user']) && is_email($_POST['wpinv_email'])) {
343 343
 
344 344
             // Attempt to create the user.
345
-            $user = wpinv_create_user( sanitize_email( $_POST['wpinv_email'] ) );
345
+            $user = wpinv_create_user(sanitize_email($_POST['wpinv_email']));
346 346
 
347 347
 
348 348
             // If successful, update the invoice author.
349
-            if ( is_numeric( $user ) ) {
350
-                $invoice->set_author( $user );
349
+            if (is_numeric($user)) {
350
+                $invoice->set_author($user);
351 351
             } else {
352
-                wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
352
+                wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__);
353 353
             }
354 354
         }
355 355
 
@@ -357,11 +357,11 @@  discard block
 block discarded – undo
357 357
         $invoice->save();
358 358
 
359 359
         // (Maybe) send new user notification.
360
-        if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', true ) ) {
361
-            wp_send_new_user_notifications( $user, 'user' );
360
+        if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', true)) {
361
+            wp_send_new_user_notifications($user, 'user');
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/wpinv-general-functions.php 1 patch
Spacing   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -7,202 +7,202 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_is_checkout() {
15 15
     global $wp_query;
16 16
 
17
-    $is_object_set    = isset( $wp_query->queried_object );
18
-    $is_object_id_set = isset( $wp_query->queried_object_id );
19
-    $is_checkout      = is_page( wpinv_get_option( 'checkout_page' ) );
17
+    $is_object_set    = isset($wp_query->queried_object);
18
+    $is_object_id_set = isset($wp_query->queried_object_id);
19
+    $is_checkout      = is_page(wpinv_get_option('checkout_page'));
20 20
 
21
-    if ( !$is_object_set ) {
22
-        unset( $wp_query->queried_object );
21
+    if (!$is_object_set) {
22
+        unset($wp_query->queried_object);
23 23
     }
24 24
 
25
-    if ( !$is_object_id_set ) {
26
-        unset( $wp_query->queried_object_id );
25
+    if (!$is_object_id_set) {
26
+        unset($wp_query->queried_object_id);
27 27
     }
28 28
 
29
-    return apply_filters( 'wpinv_is_checkout', $is_checkout );
29
+    return apply_filters('wpinv_is_checkout', $is_checkout);
30 30
 }
31 31
 
32 32
 function wpinv_can_checkout() {
33 33
 	$can_checkout = true; // Always true for now
34 34
 
35
-	return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
35
+	return (bool) apply_filters('wpinv_can_checkout', $can_checkout);
36 36
 }
37 37
 
38 38
 function wpinv_get_success_page_uri() {
39
-	$page_id = wpinv_get_option( 'success_page', 0 );
40
-	$page_id = absint( $page_id );
39
+	$page_id = wpinv_get_option('success_page', 0);
40
+	$page_id = absint($page_id);
41 41
 
42
-	return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
42
+	return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id));
43 43
 }
44 44
 
45 45
 function wpinv_get_history_page_uri() {
46
-	$page_id = wpinv_get_option( 'invoice_history_page', 0 );
47
-	$page_id = absint( $page_id );
46
+	$page_id = wpinv_get_option('invoice_history_page', 0);
47
+	$page_id = absint($page_id);
48 48
 
49
-	return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
49
+	return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id));
50 50
 }
51 51
 
52 52
 function wpinv_is_success_page() {
53
-	$is_success_page = wpinv_get_option( 'success_page', false );
54
-	$is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false;
53
+	$is_success_page = wpinv_get_option('success_page', false);
54
+	$is_success_page = isset($is_success_page) ? is_page($is_success_page) : false;
55 55
 
56
-	return apply_filters( 'wpinv_is_success_page', $is_success_page );
56
+	return apply_filters('wpinv_is_success_page', $is_success_page);
57 57
 }
58 58
 
59 59
 function wpinv_is_invoice_history_page() {
60
-	$ret = wpinv_get_option( 'invoice_history_page', false );
61
-	$ret = $ret ? is_page( $ret ) : false;
62
-	return apply_filters( 'wpinv_is_invoice_history_page', $ret );
60
+	$ret = wpinv_get_option('invoice_history_page', false);
61
+	$ret = $ret ? is_page($ret) : false;
62
+	return apply_filters('wpinv_is_invoice_history_page', $ret);
63 63
 }
64 64
 
65 65
 function wpinv_is_subscriptions_history_page() {
66
-    $ret = wpinv_get_option( 'invoice_subscription_page', false );
67
-    $ret = $ret ? is_page( $ret ) : false;
68
-    return apply_filters( 'wpinv_is_subscriptions_history_page', $ret );
66
+    $ret = wpinv_get_option('invoice_subscription_page', false);
67
+    $ret = $ret ? is_page($ret) : false;
68
+    return apply_filters('wpinv_is_subscriptions_history_page', $ret);
69 69
 }
70 70
 
71
-function wpinv_send_to_success_page( $args = null ) {
71
+function wpinv_send_to_success_page($args = null) {
72 72
 	$redirect = wpinv_get_success_page_uri();
73 73
     
74
-    if ( !empty( $args ) ) {
74
+    if (!empty($args)) {
75 75
         // Check for backward compatibility
76
-        if ( is_string( $args ) )
77
-            $args = str_replace( '?', '', $args );
76
+        if (is_string($args))
77
+            $args = str_replace('?', '', $args);
78 78
 
79
-        $args = wp_parse_args( $args );
79
+        $args = wp_parse_args($args);
80 80
 
81
-        $redirect = add_query_arg( $args, $redirect );
81
+        $redirect = add_query_arg($args, $redirect);
82 82
     }
83 83
 
84
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
84
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
85 85
     
86
-    $redirect = apply_filters( 'wpinv_success_page_redirect', $redirect, $gateway, $args );
87
-    wp_redirect( $redirect );
86
+    $redirect = apply_filters('wpinv_success_page_redirect', $redirect, $gateway, $args);
87
+    wp_redirect($redirect);
88 88
     exit;
89 89
 }
90 90
 
91
-function wpinv_send_to_failed_page( $args = null ) {
91
+function wpinv_send_to_failed_page($args = null) {
92 92
 	$redirect = wpinv_get_failed_transaction_uri();
93 93
     
94
-    if ( !empty( $args ) ) {
94
+    if (!empty($args)) {
95 95
         // Check for backward compatibility
96
-        if ( is_string( $args ) )
97
-            $args = str_replace( '?', '', $args );
96
+        if (is_string($args))
97
+            $args = str_replace('?', '', $args);
98 98
 
99
-        $args = wp_parse_args( $args );
99
+        $args = wp_parse_args($args);
100 100
 
101
-        $redirect = add_query_arg( $args, $redirect );
101
+        $redirect = add_query_arg($args, $redirect);
102 102
     }
103 103
 
104
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
104
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
105 105
     
106
-    $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args );
107
-    wp_redirect( $redirect );
106
+    $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args);
107
+    wp_redirect($redirect);
108 108
     exit;
109 109
 }
110 110
 
111
-function wpinv_get_checkout_uri( $args = array() ) {
112
-	$uri = wpinv_get_option( 'checkout_page', false );
113
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
111
+function wpinv_get_checkout_uri($args = array()) {
112
+	$uri = wpinv_get_option('checkout_page', false);
113
+	$uri = isset($uri) ? get_permalink($uri) : NULL;
114 114
 
115
-	if ( !empty( $args ) ) {
115
+	if (!empty($args)) {
116 116
 		// Check for backward compatibility
117
-		if ( is_string( $args ) )
118
-			$args = str_replace( '?', '', $args );
117
+		if (is_string($args))
118
+			$args = str_replace('?', '', $args);
119 119
 
120
-		$args = wp_parse_args( $args );
120
+		$args = wp_parse_args($args);
121 121
 
122
-		$uri = add_query_arg( $args, $uri );
122
+		$uri = add_query_arg($args, $uri);
123 123
 	}
124 124
 
125
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
125
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
126 126
 
127
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
127
+	$ajax_url = admin_url('admin-ajax.php', $scheme);
128 128
 
129
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
130
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
129
+	if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) {
130
+		$uri = preg_replace('/^http:/', 'https:', $uri);
131 131
 	}
132 132
 
133
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
133
+	return apply_filters('wpinv_get_checkout_uri', $uri);
134 134
 }
135 135
 
136
-function wpinv_send_back_to_checkout( $args = array() ) {
136
+function wpinv_send_back_to_checkout($args = array()) {
137 137
 	$redirect = wpinv_get_checkout_uri();
138 138
 
139
-	if ( ! empty( $args ) ) {
139
+	if (!empty($args)) {
140 140
 		// Check for backward compatibility
141
-		if ( is_string( $args ) )
142
-			$args = str_replace( '?', '', $args );
141
+		if (is_string($args))
142
+			$args = str_replace('?', '', $args);
143 143
 
144
-		$args = wp_parse_args( $args );
144
+		$args = wp_parse_args($args);
145 145
 
146
-		$redirect = add_query_arg( $args, $redirect );
146
+		$redirect = add_query_arg($args, $redirect);
147 147
 	}
148 148
 
149
-    do_action( 'wpinv_pre_send_back_to_checkout', $args );
150
-	wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
149
+    do_action('wpinv_pre_send_back_to_checkout', $args);
150
+	wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args));
151 151
 	exit;
152 152
 }
153 153
 
154
-function wpinv_get_success_page_url( $query_string = null ) {
155
-	$success_page = wpinv_get_option( 'success_page', 0 );
156
-	$success_page = get_permalink( $success_page );
154
+function wpinv_get_success_page_url($query_string = null) {
155
+	$success_page = wpinv_get_option('success_page', 0);
156
+	$success_page = get_permalink($success_page);
157 157
 
158
-	if ( $query_string )
158
+	if ($query_string)
159 159
 		$success_page .= $query_string;
160 160
 
161
-	return apply_filters( 'wpinv_success_page_url', $success_page );
161
+	return apply_filters('wpinv_success_page_url', $success_page);
162 162
 }
163 163
 
164
-function wpinv_get_failed_transaction_uri( $extras = false ) {
165
-	$uri = wpinv_get_option( 'failure_page', '' );
166
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
164
+function wpinv_get_failed_transaction_uri($extras = false) {
165
+	$uri = wpinv_get_option('failure_page', '');
166
+	$uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url();
167 167
 
168
-	if ( $extras )
168
+	if ($extras)
169 169
 		$uri .= $extras;
170 170
 
171
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
171
+	return apply_filters('wpinv_get_failed_transaction_uri', $uri);
172 172
 }
173 173
 
174 174
 function wpinv_is_failed_transaction_page() {
175
-	$ret = wpinv_get_option( 'failure_page', false );
176
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
175
+	$ret = wpinv_get_option('failure_page', false);
176
+	$ret = isset($ret) ? is_page($ret) : false;
177 177
 
178
-	return apply_filters( 'wpinv_is_failure_page', $ret );
178
+	return apply_filters('wpinv_is_failure_page', $ret);
179 179
 }
180 180
 
181
-function wpinv_transaction_query( $type = 'start' ) {
181
+function wpinv_transaction_query($type = 'start') {
182 182
     global $wpdb;
183 183
 
184 184
     $wpdb->hide_errors();
185 185
 
186
-    if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) {
187
-        define( 'WPINV_USE_TRANSACTIONS', true );
186
+    if (!defined('WPINV_USE_TRANSACTIONS')) {
187
+        define('WPINV_USE_TRANSACTIONS', true);
188 188
     }
189 189
 
190
-    if ( WPINV_USE_TRANSACTIONS ) {
191
-        switch ( $type ) {
190
+    if (WPINV_USE_TRANSACTIONS) {
191
+        switch ($type) {
192 192
             case 'commit' :
193
-                $wpdb->query( 'COMMIT' );
193
+                $wpdb->query('COMMIT');
194 194
                 break;
195 195
             case 'rollback' :
196
-                $wpdb->query( 'ROLLBACK' );
196
+                $wpdb->query('ROLLBACK');
197 197
                 break;
198 198
             default :
199
-                $wpdb->query( 'START TRANSACTION' );
199
+                $wpdb->query('START TRANSACTION');
200 200
             break;
201 201
         }
202 202
     }
203 203
 }
204 204
 
205
-function wpinv_create_invoice( $args = array(), $data = array(), $wp_error = false ) {
205
+function wpinv_create_invoice($args = array(), $data = array(), $wp_error = false) {
206 206
     $default_args = array(
207 207
         'status'        => '',
208 208
         'user_id'       => null,
@@ -213,66 +213,66 @@  discard block
 block discarded – undo
213 213
         'post_type'     => 'wpi_invoice'
214 214
     );
215 215
 
216
-    $args           = wp_parse_args( $args, $default_args );
216
+    $args           = wp_parse_args($args, $default_args);
217 217
     $invoice_data   = array();
218 218
 
219
-    if ( $args['invoice_id'] > 0 ) {
220
-        $updating           = true;
219
+    if ($args['invoice_id'] > 0) {
220
+        $updating = true;
221 221
         $invoice_data['post_type']  = $args['post_type'];
222 222
         $invoice_data['ID']         = $args['invoice_id'];
223 223
     } else {
224 224
         $updating                       = false;
225 225
         $invoice_data['post_type']      = $args['post_type'];
226
-        $invoice_data['post_status']    = apply_filters( 'wpinv_default_invoice_status', 'wpi-pending' );
226
+        $invoice_data['post_status']    = apply_filters('wpinv_default_invoice_status', 'wpi-pending');
227 227
         $invoice_data['ping_status']    = 'closed';
228
-        $invoice_data['post_author']    = !empty( $args['user_id'] ) ? $args['user_id'] : get_current_user_id();
229
-        $invoice_data['post_title']     = wpinv_format_invoice_number( '0' );
230
-        $invoice_data['post_parent']    = absint( $args['parent'] );
231
-        if ( !empty( $args['created_date'] ) ) {
228
+        $invoice_data['post_author']    = !empty($args['user_id']) ? $args['user_id'] : get_current_user_id();
229
+        $invoice_data['post_title']     = wpinv_format_invoice_number('0');
230
+        $invoice_data['post_parent']    = absint($args['parent']);
231
+        if (!empty($args['created_date'])) {
232 232
             $invoice_data['post_date']      = $args['created_date'];
233
-            $invoice_data['post_date_gmt']  = get_gmt_from_date( $args['created_date'] );
233
+            $invoice_data['post_date_gmt']  = get_gmt_from_date($args['created_date']);
234 234
         }
235 235
     }
236 236
 
237
-    if ( $args['status'] ) {
238
-        if ( ! in_array( $args['status'], array_keys( wpinv_get_invoice_statuses() ) ) && 'wpi_invoice' === $invoice_data['post_type'] ) {
239
-            return new WP_Error( 'wpinv_invalid_invoice_status', wp_sprintf( __( 'Invalid invoice status: %s', 'invoicing' ), $args['status'] ) );
237
+    if ($args['status']) {
238
+        if (!in_array($args['status'], array_keys(wpinv_get_invoice_statuses())) && 'wpi_invoice' === $invoice_data['post_type']) {
239
+            return new WP_Error('wpinv_invalid_invoice_status', wp_sprintf(__('Invalid invoice status: %s', 'invoicing'), $args['status']));
240 240
         }
241
-        $invoice_data['post_status']    = $args['status'];
241
+        $invoice_data['post_status'] = $args['status'];
242 242
     }
243 243
 
244
-    if ( ! is_null( $args['user_note'] ) ) {
245
-        $invoice_data['post_excerpt']   = $args['user_note'];
244
+    if (!is_null($args['user_note'])) {
245
+        $invoice_data['post_excerpt'] = $args['user_note'];
246 246
     }
247 247
 
248
-    if ( $updating ) {
249
-        $invoice_id = wp_update_post( $invoice_data, true );
248
+    if ($updating) {
249
+        $invoice_id = wp_update_post($invoice_data, true);
250 250
     } else {
251
-        $invoice_id = wp_insert_post( apply_filters( 'wpinv_new_invoice_data', $invoice_data ), true );
251
+        $invoice_id = wp_insert_post(apply_filters('wpinv_new_invoice_data', $invoice_data), true);
252 252
     }
253 253
 
254
-    if ( is_wp_error( $invoice_id ) ) {
254
+    if (is_wp_error($invoice_id)) {
255 255
         return $wp_error ? $invoice_id : 0;
256 256
     }
257 257
     
258
-    $invoice = wpinv_get_invoice( $invoice_id );
259
-
260
-    if ( !$updating ) {
261
-        update_post_meta( $invoice_id, '_wpinv_key', apply_filters( 'wpinv_generate_invoice_key', uniqid( 'wpinv_' ) ) );
262
-        update_post_meta( $invoice_id, '_wpinv_currency', wpinv_get_currency() );
263
-        update_post_meta( $invoice_id, '_wpinv_include_tax', get_option( 'wpinv_prices_include_tax' ) );
264
-        update_post_meta( $invoice_id, '_wpinv_user_ip', wpinv_get_ip() );
265
-        update_post_meta( $invoice_id, '_wpinv_user_agent', wpinv_get_user_agent() );
266
-        update_post_meta( $invoice_id, '_wpinv_created_via', sanitize_text_field( $args['created_via'] ) );
258
+    $invoice = wpinv_get_invoice($invoice_id);
259
+
260
+    if (!$updating) {
261
+        update_post_meta($invoice_id, '_wpinv_key', apply_filters('wpinv_generate_invoice_key', uniqid('wpinv_')));
262
+        update_post_meta($invoice_id, '_wpinv_currency', wpinv_get_currency());
263
+        update_post_meta($invoice_id, '_wpinv_include_tax', get_option('wpinv_prices_include_tax'));
264
+        update_post_meta($invoice_id, '_wpinv_user_ip', wpinv_get_ip());
265
+        update_post_meta($invoice_id, '_wpinv_user_agent', wpinv_get_user_agent());
266
+        update_post_meta($invoice_id, '_wpinv_created_via', sanitize_text_field($args['created_via']));
267 267
         
268 268
         // Add invoice note
269
-        if ( ! $invoice->is_quote() ) {
270
-            $invoice->add_note( wp_sprintf( __( 'Invoice is created with status %s.', 'invoicing' ), wpinv_status_nicename( $invoice->status ) ) );
269
+        if (!$invoice->is_quote()) {
270
+            $invoice->add_note(wp_sprintf(__('Invoice is created with status %s.', 'invoicing'), wpinv_status_nicename($invoice->status)));
271 271
         }
272 272
         
273 273
     }
274 274
 
275
-    update_post_meta( $invoice_id, '_wpinv_version', WPINV_VERSION );
275
+    update_post_meta($invoice_id, '_wpinv_version', WPINV_VERSION);
276 276
 
277 277
     return $invoice;
278 278
 }
@@ -280,191 +280,191 @@  discard block
 block discarded – undo
280 280
 function wpinv_get_prefix() {
281 281
     $invoice_prefix = 'INV-';
282 282
     
283
-    return apply_filters( 'wpinv_get_prefix', $invoice_prefix );
283
+    return apply_filters('wpinv_get_prefix', $invoice_prefix);
284 284
 }
285 285
 
286 286
 function wpinv_get_business_logo() {
287
-    $business_logo = wpinv_get_option( 'logo' );
288
-    return apply_filters( 'wpinv_get_business_logo', $business_logo );
287
+    $business_logo = wpinv_get_option('logo');
288
+    return apply_filters('wpinv_get_business_logo', $business_logo);
289 289
 }
290 290
 
291 291
 function wpinv_get_business_name() {
292 292
     $business_name = wpinv_get_option('store_name');
293
-    return apply_filters( 'wpinv_get_business_name', $business_name );
293
+    return apply_filters('wpinv_get_business_name', $business_name);
294 294
 }
295 295
 
296 296
 function wpinv_get_blogname() {
297
-    return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
297
+    return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
298 298
 }
299 299
 
300 300
 function wpinv_get_admin_email() {
301
-    $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) );
302
-    return apply_filters( 'wpinv_admin_email', $admin_email );
301
+    $admin_email = wpinv_get_option('admin_email', get_option('admin_email'));
302
+    return apply_filters('wpinv_admin_email', $admin_email);
303 303
 }
304 304
 
305 305
 function wpinv_get_business_website() {
306
-    $business_website = home_url( '/' );
307
-    return apply_filters( 'wpinv_get_business_website', $business_website );
306
+    $business_website = home_url('/');
307
+    return apply_filters('wpinv_get_business_website', $business_website);
308 308
 }
309 309
 
310
-function wpinv_get_terms_text( $invoice_id = 0 ) {
310
+function wpinv_get_terms_text($invoice_id = 0) {
311 311
     $terms_text = '';
312
-    return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id );
312
+    return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id);
313 313
 }
314 314
 
315 315
 function wpinv_get_business_footer() {
316
-    $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>';
317
-    $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link );
318
-    return apply_filters( 'wpinv_get_business_footer', $business_footer );
316
+    $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>';
317
+    $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link);
318
+    return apply_filters('wpinv_get_business_footer', $business_footer);
319 319
 }
320 320
 
321 321
 function wpinv_checkout_required_fields() {
322 322
     $required_fields = array();
323 323
     
324 324
     // Let payment gateways and other extensions determine if address fields should be required
325
-    $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
325
+    $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes());
326 326
     
327
-    if ( $require_billing_details ) {
328
-		if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
327
+    if ($require_billing_details) {
328
+		if ((bool) wpinv_get_option('fname_mandatory')) {
329 329
 			$required_fields['first_name'] = array(
330 330
 				'error_id' => 'invalid_first_name',
331
-				'error_message' => __( 'Please enter your first name', 'invoicing' )
331
+				'error_message' => __('Please enter your first name', 'invoicing')
332 332
 			);
333 333
 		}
334
-		if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
334
+		if ((bool) wpinv_get_option('address_mandatory')) {
335 335
 			$required_fields['address'] = array(
336 336
 				'error_id' => 'invalid_address',
337
-				'error_message' => __( 'Please enter your address', 'invoicing' )
337
+				'error_message' => __('Please enter your address', 'invoicing')
338 338
 			);
339 339
 		}
340
-		if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
340
+		if ((bool) wpinv_get_option('city_mandatory')) {
341 341
 			$required_fields['city'] = array(
342 342
 				'error_id' => 'invalid_city',
343
-				'error_message' => __( 'Please enter your billing city', 'invoicing' )
343
+				'error_message' => __('Please enter your billing city', 'invoicing')
344 344
 			);
345 345
 		}
346
-		if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
346
+		if ((bool) wpinv_get_option('state_mandatory')) {
347 347
 			$required_fields['state'] = array(
348 348
 				'error_id' => 'invalid_state',
349
-				'error_message' => __( 'Please enter billing state / province', 'invoicing' )
349
+				'error_message' => __('Please enter billing state / province', 'invoicing')
350 350
 			);
351 351
 		}
352
-		if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
352
+		if ((bool) wpinv_get_option('country_mandatory')) {
353 353
 			$required_fields['country'] = array(
354 354
 				'error_id' => 'invalid_country',
355
-				'error_message' => __( 'Please select your billing country', 'invoicing' )
355
+				'error_message' => __('Please select your billing country', 'invoicing')
356 356
 			);
357 357
 		}
358 358
     }
359 359
 
360
-    return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
360
+    return apply_filters('wpinv_checkout_required_fields', $required_fields);
361 361
 }
362 362
 
363 363
 function wpinv_is_ssl_enforced() {
364
-    $ssl_enforced = wpinv_get_option( 'enforce_ssl', false );
365
-    return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced );
364
+    $ssl_enforced = wpinv_get_option('enforce_ssl', false);
365
+    return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced);
366 366
 }
367 367
 
368 368
 /**
369 369
  * Checks if the current user cna view an invoice.
370 370
  */
371
-function wpinv_user_can_view_invoice( $invoice ) {
372
-    $invoice = new WPInv_Invoice( $invoice );
371
+function wpinv_user_can_view_invoice($invoice) {
372
+    $invoice = new WPInv_Invoice($invoice);
373 373
 
374 374
     // Abort if the invoice does not exist.
375
-    if ( 0 == $invoice->get_id() ) {
375
+    if (0 == $invoice->get_id()) {
376 376
         return false;
377 377
     }
378 378
 
379 379
     // Don't allow trash, draft status
380
-    if ( $invoice->is_draft() ) {
380
+    if ($invoice->is_draft()) {
381 381
         return false;
382 382
     }
383 383
 
384 384
     // If users are not required to login to check out, compare the invoice keys.
385
-    if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && trim( $_GET['invoice_key'] ) == $invoice->get_key() ) {
385
+    if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && trim($_GET['invoice_key']) == $invoice->get_key()) {
386 386
         return true;
387 387
     }
388 388
 
389 389
     // Always enable for admins..
390
-    if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->ID ) ) { // Admin user
390
+    if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->ID)) { // Admin user
391 391
         return true;
392 392
     }
393 393
 
394 394
     // Else, ensure that this is their invoice.
395
-    if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) {
395
+    if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) {
396 396
         return true;
397 397
     }
398 398
 
399
-    return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice );
399
+    return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice);
400 400
 }
401 401
 
402 402
 function wpinv_schedule_events() {
403 403
 
404 404
     // Get the timestamp for the next event.
405
-    $timestamp = wp_next_scheduled( 'wpinv_register_schedule_event_twicedaily' );
405
+    $timestamp = wp_next_scheduled('wpinv_register_schedule_event_twicedaily');
406 406
 
407
-    if ( $timestamp ) {
408
-        wp_unschedule_event( $timestamp, 'wpinv_register_schedule_event_twicedaily' );
407
+    if ($timestamp) {
408
+        wp_unschedule_event($timestamp, 'wpinv_register_schedule_event_twicedaily');
409 409
     }
410 410
 
411
-    if ( ! wp_next_scheduled( 'wpinv_register_schedule_event_daily' ) ) {
412
-        wp_schedule_event( current_time( 'timestamp' ), 'daily', 'wpinv_register_schedule_event_daily' );
411
+    if (!wp_next_scheduled('wpinv_register_schedule_event_daily')) {
412
+        wp_schedule_event(current_time('timestamp'), 'daily', 'wpinv_register_schedule_event_daily');
413 413
     }
414 414
 }
415
-add_action( 'wp', 'wpinv_schedule_events' );
415
+add_action('wp', 'wpinv_schedule_events');
416 416
 
417 417
 function wpinv_schedule_event_twicedaily() {
418 418
     wpinv_email_payment_reminders();
419 419
     wpinv_email_renewal_reminders();
420 420
 }
421
-add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' );
421
+add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily');
422 422
 
423 423
 function wpinv_require_login_to_checkout() {
424
-    $return = wpinv_get_option( 'login_to_checkout', false );
425
-    return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return );
424
+    $return = wpinv_get_option('login_to_checkout', false);
425
+    return (bool) apply_filters('wpinv_require_login_to_checkout', $return);
426 426
 }
427 427
 
428
-function wpinv_sequential_number_active( $type = '' ) {
429
-    $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type );
430
-    if ( null !== $check ) {
428
+function wpinv_sequential_number_active($type = '') {
429
+    $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type);
430
+    if (null !== $check) {
431 431
         return $check;
432 432
     }
433 433
     
434
-    return wpinv_get_option( 'sequential_invoice_number' );
434
+    return wpinv_get_option('sequential_invoice_number');
435 435
 }
436 436
 
437
-function wpinv_switch_to_locale( $locale = NULL ) {
437
+function wpinv_switch_to_locale($locale = NULL) {
438 438
     global $invoicing, $wpi_switch_locale;
439 439
 
440
-    if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) {
441
-        $locale = empty( $locale ) ? get_locale() : $locale;
440
+    if (!empty($invoicing) && function_exists('switch_to_locale')) {
441
+        $locale = empty($locale) ? get_locale() : $locale;
442 442
 
443
-        switch_to_locale( $locale );
443
+        switch_to_locale($locale);
444 444
 
445 445
         $wpi_switch_locale = $locale;
446 446
 
447
-        add_filter( 'plugin_locale', 'get_locale' );
447
+        add_filter('plugin_locale', 'get_locale');
448 448
 
449 449
         $invoicing->load_textdomain();
450 450
 
451
-        do_action( 'wpinv_switch_to_locale', $locale );
451
+        do_action('wpinv_switch_to_locale', $locale);
452 452
     }
453 453
 }
454 454
 
455 455
 function wpinv_restore_locale() {
456 456
     global $invoicing, $wpi_switch_locale;
457 457
     
458
-    if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) {
458
+    if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) {
459 459
         restore_previous_locale();
460 460
 
461 461
         $wpi_switch_locale = NULL;
462 462
 
463
-        remove_filter( 'plugin_locale', 'get_locale' );
463
+        remove_filter('plugin_locale', 'get_locale');
464 464
 
465 465
         $invoicing->load_textdomain();
466 466
 
467
-        do_action( 'wpinv_restore_locale' );
467
+        do_action('wpinv_restore_locale');
468 468
     }
469 469
 }
470 470
 
@@ -472,22 +472,22 @@  discard block
 block discarded – undo
472 472
  * Returns the default form's id.
473 473
  */
474 474
 function wpinv_get_default_payment_form() {
475
-    $form = get_option( 'wpinv_default_payment_form' );
475
+    $form = get_option('wpinv_default_payment_form');
476 476
 
477
-    if ( empty( $form ) || 'publish' != get_post_status( $form ) ) {
477
+    if (empty($form) || 'publish' != get_post_status($form)) {
478 478
         $form = wp_insert_post(
479 479
             array(
480 480
                 'post_type'   => 'wpi_payment_form',
481
-                'post_title'  => __( 'Checkout (default)', 'invoicing' ),
481
+                'post_title'  => __('Checkout (default)', 'invoicing'),
482 482
                 'post_status' => 'publish',
483 483
                 'meta_input'  => array(
484
-                    'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ),
484
+                    'wpinv_form_elements' => wpinv_get_data('default-payment-form'),
485 485
                     'wpinv_form_items'    => array(),
486 486
                 )
487 487
             )
488 488
         );
489 489
 
490
-        update_option( 'wpinv_default_payment_form', $form );
490
+        update_option('wpinv_default_payment_form', $form);
491 491
     }
492 492
 
493 493
     return $form;
Please login to merge, or discard this patch.