Passed
Pull Request — master (#190)
by Kiran
03:06
created
includes/wpinv-general-functions.php 2 patches
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -30,36 +30,36 @@  discard block
 block discarded – undo
30 30
 }
31 31
 
32 32
 function wpinv_can_checkout() {
33
-	$can_checkout = true; // Always true for now
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() {
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 function wpinv_send_to_success_page( $args = null ) {
72
-	$redirect = wpinv_get_success_page_uri();
72
+    $redirect = wpinv_get_success_page_uri();
73 73
     
74 74
     if ( !empty( $args ) ) {
75 75
         // Check for backward compatibility
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 }
90 90
 
91 91
 function wpinv_send_to_failed_page( $args = null ) {
92
-	$redirect = wpinv_get_failed_transaction_uri();
92
+    $redirect = wpinv_get_failed_transaction_uri();
93 93
     
94 94
     if ( !empty( $args ) ) {
95 95
         // Check for backward compatibility
@@ -109,72 +109,72 @@  discard block
 block discarded – undo
109 109
 }
110 110
 
111 111
 function wpinv_get_checkout_uri( $args = array() ) {
112
-	$uri = wpinv_get_option( 'checkout_page', false );
113
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
112
+    $uri = wpinv_get_option( 'checkout_page', false );
113
+    $uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
114 114
 
115
-	if ( !empty( $args ) ) {
116
-		// Check for backward compatibility
117
-		if ( is_string( $args ) )
118
-			$args = str_replace( '?', '', $args );
115
+    if ( !empty( $args ) ) {
116
+        // Check for backward compatibility
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 );
123
-	}
122
+        $uri = add_query_arg( $args, $uri );
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 );
131
-	}
129
+    if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
130
+        $uri = preg_replace( '/^http:/', 'https:', $uri );
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 136
 function wpinv_send_back_to_checkout( $args = array() ) {
137
-	$redirect = wpinv_get_checkout_uri();
137
+    $redirect = wpinv_get_checkout_uri();
138 138
 
139
-	if ( ! empty( $args ) ) {
140
-		// Check for backward compatibility
141
-		if ( is_string( $args ) )
142
-			$args = str_replace( '?', '', $args );
139
+    if ( ! empty( $args ) ) {
140
+        // Check for backward compatibility
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 );
147
-	}
146
+        $redirect = add_query_arg( $args, $redirect );
147
+    }
148 148
 
149
-	wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
150
-	exit;
149
+    wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
150
+    exit;
151 151
 }
152 152
 
153 153
 function wpinv_get_success_page_url( $query_string = null ) {
154
-	$success_page = wpinv_get_option( 'success_page', 0 );
155
-	$success_page = get_permalink( $success_page );
154
+    $success_page = wpinv_get_option( 'success_page', 0 );
155
+    $success_page = get_permalink( $success_page );
156 156
 
157
-	if ( $query_string )
158
-		$success_page .= $query_string;
157
+    if ( $query_string )
158
+        $success_page .= $query_string;
159 159
 
160
-	return apply_filters( 'wpinv_success_page_url', $success_page );
160
+    return apply_filters( 'wpinv_success_page_url', $success_page );
161 161
 }
162 162
 
163 163
 function wpinv_get_failed_transaction_uri( $extras = false ) {
164
-	$uri = wpinv_get_option( 'failure_page', '' );
165
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
164
+    $uri = wpinv_get_option( 'failure_page', '' );
165
+    $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
166 166
 
167
-	if ( $extras )
168
-		$uri .= $extras;
167
+    if ( $extras )
168
+        $uri .= $extras;
169 169
 
170
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
170
+    return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
171 171
 }
172 172
 
173 173
 function wpinv_is_failed_transaction_page() {
174
-	$ret = wpinv_get_option( 'failure_page', false );
175
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
174
+    $ret = wpinv_get_option( 'failure_page', false );
175
+    $ret = isset( $ret ) ? is_page( $ret ) : false;
176 176
 
177
-	return apply_filters( 'wpinv_is_failure_page', $ret );
177
+    return apply_filters( 'wpinv_is_failure_page', $ret );
178 178
 }
179 179
 
180 180
 function wpinv_transaction_query( $type = 'start' ) {
@@ -320,36 +320,36 @@  discard block
 block discarded – undo
320 320
     $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
321 321
     
322 322
     if ( $require_billing_details ) {
323
-		if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
324
-			$required_fields['first_name'] = array(
325
-				'error_id' => 'invalid_first_name',
326
-				'error_message' => __( 'Please enter your first name', 'invoicing' )
327
-			);
328
-		}
329
-		if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
330
-			$required_fields['address'] = array(
331
-				'error_id' => 'invalid_address',
332
-				'error_message' => __( 'Please enter your address', 'invoicing' )
333
-			);
334
-		}
335
-		if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
336
-			$required_fields['city'] = array(
337
-				'error_id' => 'invalid_city',
338
-				'error_message' => __( 'Please enter your billing city', 'invoicing' )
339
-			);
340
-		}
341
-		if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
342
-			$required_fields['state'] = array(
343
-				'error_id' => 'invalid_state',
344
-				'error_message' => __( 'Please enter billing state / province', 'invoicing' )
345
-			);
346
-		}
347
-		if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
348
-			$required_fields['country'] = array(
349
-				'error_id' => 'invalid_country',
350
-				'error_message' => __( 'Please select your billing country', 'invoicing' )
351
-			);
352
-		}
323
+        if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
324
+            $required_fields['first_name'] = array(
325
+                'error_id' => 'invalid_first_name',
326
+                'error_message' => __( 'Please enter your first name', 'invoicing' )
327
+            );
328
+        }
329
+        if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
330
+            $required_fields['address'] = array(
331
+                'error_id' => 'invalid_address',
332
+                'error_message' => __( 'Please enter your address', 'invoicing' )
333
+            );
334
+        }
335
+        if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
336
+            $required_fields['city'] = array(
337
+                'error_id' => 'invalid_city',
338
+                'error_message' => __( 'Please enter your billing city', 'invoicing' )
339
+            );
340
+        }
341
+        if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
342
+            $required_fields['state'] = array(
343
+                'error_id' => 'invalid_state',
344
+                'error_message' => __( 'Please enter billing state / province', 'invoicing' )
345
+            );
346
+        }
347
+        if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
348
+            $required_fields['country'] = array(
349
+                'error_id' => 'invalid_country',
350
+                'error_message' => __( 'Please select your billing country', 'invoicing' )
351
+            );
352
+        }
353 353
     }
354 354
 
355 355
     return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
Please login to merge, or discard this patch.
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -7,201 +7,201 @@  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
-	wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
149
+	wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args));
150 150
 	exit;
151 151
 }
152 152
 
153
-function wpinv_get_success_page_url( $query_string = null ) {
154
-	$success_page = wpinv_get_option( 'success_page', 0 );
155
-	$success_page = get_permalink( $success_page );
153
+function wpinv_get_success_page_url($query_string = null) {
154
+	$success_page = wpinv_get_option('success_page', 0);
155
+	$success_page = get_permalink($success_page);
156 156
 
157
-	if ( $query_string )
157
+	if ($query_string)
158 158
 		$success_page .= $query_string;
159 159
 
160
-	return apply_filters( 'wpinv_success_page_url', $success_page );
160
+	return apply_filters('wpinv_success_page_url', $success_page);
161 161
 }
162 162
 
163
-function wpinv_get_failed_transaction_uri( $extras = false ) {
164
-	$uri = wpinv_get_option( 'failure_page', '' );
165
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
163
+function wpinv_get_failed_transaction_uri($extras = false) {
164
+	$uri = wpinv_get_option('failure_page', '');
165
+	$uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url();
166 166
 
167
-	if ( $extras )
167
+	if ($extras)
168 168
 		$uri .= $extras;
169 169
 
170
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
170
+	return apply_filters('wpinv_get_failed_transaction_uri', $uri);
171 171
 }
172 172
 
173 173
 function wpinv_is_failed_transaction_page() {
174
-	$ret = wpinv_get_option( 'failure_page', false );
175
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
174
+	$ret = wpinv_get_option('failure_page', false);
175
+	$ret = isset($ret) ? is_page($ret) : false;
176 176
 
177
-	return apply_filters( 'wpinv_is_failure_page', $ret );
177
+	return apply_filters('wpinv_is_failure_page', $ret);
178 178
 }
179 179
 
180
-function wpinv_transaction_query( $type = 'start' ) {
180
+function wpinv_transaction_query($type = 'start') {
181 181
     global $wpdb;
182 182
 
183 183
     $wpdb->hide_errors();
184 184
 
185
-    if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) {
186
-        define( 'WPINV_USE_TRANSACTIONS', true );
185
+    if (!defined('WPINV_USE_TRANSACTIONS')) {
186
+        define('WPINV_USE_TRANSACTIONS', true);
187 187
     }
188 188
 
189
-    if ( WPINV_USE_TRANSACTIONS ) {
190
-        switch ( $type ) {
189
+    if (WPINV_USE_TRANSACTIONS) {
190
+        switch ($type) {
191 191
             case 'commit' :
192
-                $wpdb->query( 'COMMIT' );
192
+                $wpdb->query('COMMIT');
193 193
                 break;
194 194
             case 'rollback' :
195
-                $wpdb->query( 'ROLLBACK' );
195
+                $wpdb->query('ROLLBACK');
196 196
                 break;
197 197
             default :
198
-                $wpdb->query( 'START TRANSACTION' );
198
+                $wpdb->query('START TRANSACTION');
199 199
             break;
200 200
         }
201 201
     }
202 202
 }
203 203
 
204
-function wpinv_create_invoice( $args = array(), $data = array(), $wp_error = false ) {
204
+function wpinv_create_invoice($args = array(), $data = array(), $wp_error = false) {
205 205
     $default_args = array(
206 206
         'status'        => '',
207 207
         'user_id'       => null,
@@ -211,63 +211,63 @@  discard block
 block discarded – undo
211 211
         'parent'        => 0
212 212
     );
213 213
 
214
-    $args           = wp_parse_args( $args, $default_args );
214
+    $args           = wp_parse_args($args, $default_args);
215 215
     $invoice_data   = array();
216 216
 
217
-    if ( $args['invoice_id'] > 0 ) {
218
-        $updating           = true;
217
+    if ($args['invoice_id'] > 0) {
218
+        $updating = true;
219 219
         $invoice_data['post_type']  = 'wpi_invoice';
220 220
         $invoice_data['ID']         = $args['invoice_id'];
221 221
     } else {
222 222
         $updating                       = false;
223 223
         $invoice_data['post_type']      = 'wpi_invoice';
224
-        $invoice_data['post_status']    = apply_filters( 'wpinv_default_invoice_status', 'wpi-pending' );
224
+        $invoice_data['post_status']    = apply_filters('wpinv_default_invoice_status', 'wpi-pending');
225 225
         $invoice_data['ping_status']    = 'closed';
226
-        $invoice_data['post_author']    = !empty( $args['user_id'] ) ? $args['user_id'] : get_current_user_id();
227
-        $invoice_data['post_title']     = wpinv_format_invoice_number( '0' );
228
-        $invoice_data['post_parent']    = absint( $args['parent'] );
229
-        if ( !empty( $args['created_date'] ) ) {
226
+        $invoice_data['post_author']    = !empty($args['user_id']) ? $args['user_id'] : get_current_user_id();
227
+        $invoice_data['post_title']     = wpinv_format_invoice_number('0');
228
+        $invoice_data['post_parent']    = absint($args['parent']);
229
+        if (!empty($args['created_date'])) {
230 230
             $invoice_data['post_date']      = $args['created_date'];
231
-            $invoice_data['post_date_gmt']  = get_gmt_from_date( $args['created_date'] );
231
+            $invoice_data['post_date_gmt']  = get_gmt_from_date($args['created_date']);
232 232
         }
233 233
     }
234 234
 
235
-    if ( $args['status'] ) {
236
-        if ( ! in_array( $args['status'], array_keys( wpinv_get_invoice_statuses() ) ) ) {
237
-            return new WP_Error( 'wpinv_invalid_invoice_status', wp_sprintf( __( 'Invalid invoice status: %s', 'invoicing' ), $args['status'] ) );
235
+    if ($args['status']) {
236
+        if (!in_array($args['status'], array_keys(wpinv_get_invoice_statuses()))) {
237
+            return new WP_Error('wpinv_invalid_invoice_status', wp_sprintf(__('Invalid invoice status: %s', 'invoicing'), $args['status']));
238 238
         }
239
-        $invoice_data['post_status']    = $args['status'];
239
+        $invoice_data['post_status'] = $args['status'];
240 240
     }
241 241
 
242
-    if ( ! is_null( $args['user_note'] ) ) {
243
-        $invoice_data['post_excerpt']   = $args['user_note'];
242
+    if (!is_null($args['user_note'])) {
243
+        $invoice_data['post_excerpt'] = $args['user_note'];
244 244
     }
245 245
 
246
-    if ( $updating ) {
247
-        $invoice_id = wp_update_post( $invoice_data, true );
246
+    if ($updating) {
247
+        $invoice_id = wp_update_post($invoice_data, true);
248 248
     } else {
249
-        $invoice_id = wp_insert_post( apply_filters( 'wpinv_new_invoice_data', $invoice_data ), true );
249
+        $invoice_id = wp_insert_post(apply_filters('wpinv_new_invoice_data', $invoice_data), true);
250 250
     }
251 251
 
252
-    if ( is_wp_error( $invoice_id ) ) {
252
+    if (is_wp_error($invoice_id)) {
253 253
         return $wp_error ? $invoice_id : 0;
254 254
     }
255 255
     
256
-    $invoice = wpinv_get_invoice( $invoice_id );
257
-
258
-    if ( !$updating ) {
259
-        update_post_meta( $invoice_id, '_wpinv_key', apply_filters( 'wpinv_generate_invoice_key', uniqid( 'wpinv_' ) ) );
260
-        update_post_meta( $invoice_id, '_wpinv_currency', wpinv_get_currency() );
261
-        update_post_meta( $invoice_id, '_wpinv_include_tax', get_option( 'wpinv_prices_include_tax' ) );
262
-        update_post_meta( $invoice_id, '_wpinv_user_ip', wpinv_get_ip() );
263
-        update_post_meta( $invoice_id, '_wpinv_user_agent', wpinv_get_user_agent() );
264
-        update_post_meta( $invoice_id, '_wpinv_created_via', sanitize_text_field( $args['created_via'] ) );
256
+    $invoice = wpinv_get_invoice($invoice_id);
257
+
258
+    if (!$updating) {
259
+        update_post_meta($invoice_id, '_wpinv_key', apply_filters('wpinv_generate_invoice_key', uniqid('wpinv_')));
260
+        update_post_meta($invoice_id, '_wpinv_currency', wpinv_get_currency());
261
+        update_post_meta($invoice_id, '_wpinv_include_tax', get_option('wpinv_prices_include_tax'));
262
+        update_post_meta($invoice_id, '_wpinv_user_ip', wpinv_get_ip());
263
+        update_post_meta($invoice_id, '_wpinv_user_agent', wpinv_get_user_agent());
264
+        update_post_meta($invoice_id, '_wpinv_created_via', sanitize_text_field($args['created_via']));
265 265
         
266 266
         // Add invoice note
267
-        $invoice->add_note( wp_sprintf( __( 'Invoice is created with status %s.', 'invoicing' ), wpinv_status_nicename( $invoice->status ) ) );
267
+        $invoice->add_note(wp_sprintf(__('Invoice is created with status %s.', 'invoicing'), wpinv_status_nicename($invoice->status)));
268 268
     }
269 269
 
270
-    update_post_meta( $invoice_id, '_wpinv_version', WPINV_VERSION );
270
+    update_post_meta($invoice_id, '_wpinv_version', WPINV_VERSION);
271 271
 
272 272
     return $invoice;
273 273
 }
@@ -275,184 +275,184 @@  discard block
 block discarded – undo
275 275
 function wpinv_get_prefix() {
276 276
     $invoice_prefix = 'INV-';
277 277
     
278
-    return apply_filters( 'wpinv_get_prefix', $invoice_prefix );
278
+    return apply_filters('wpinv_get_prefix', $invoice_prefix);
279 279
 }
280 280
 
281 281
 function wpinv_get_business_logo() {
282
-    $business_logo = wpinv_get_option( 'logo' );
283
-    return apply_filters( 'wpinv_get_business_logo', $business_logo );
282
+    $business_logo = wpinv_get_option('logo');
283
+    return apply_filters('wpinv_get_business_logo', $business_logo);
284 284
 }
285 285
 
286 286
 function wpinv_get_business_name() {
287 287
     $business_name = wpinv_get_option('store_name');
288
-    return apply_filters( 'wpinv_get_business_name', $business_name );
288
+    return apply_filters('wpinv_get_business_name', $business_name);
289 289
 }
290 290
 
291 291
 function wpinv_get_blogname() {
292
-    return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
292
+    return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
293 293
 }
294 294
 
295 295
 function wpinv_get_admin_email() {
296
-    $admin_email = get_option( 'admin_email' );
297
-    return apply_filters( 'wpinv_admin_email', $admin_email );
296
+    $admin_email = get_option('admin_email');
297
+    return apply_filters('wpinv_admin_email', $admin_email);
298 298
 }
299 299
 
300 300
 function wpinv_get_business_website() {
301
-    $business_website = home_url( '/' );
302
-    return apply_filters( 'wpinv_get_business_website', $business_website );
301
+    $business_website = home_url('/');
302
+    return apply_filters('wpinv_get_business_website', $business_website);
303 303
 }
304 304
 
305
-function wpinv_get_terms_text( $invoice_id = 0 ) {
305
+function wpinv_get_terms_text($invoice_id = 0) {
306 306
     $terms_text = '';
307
-    return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id );
307
+    return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id);
308 308
 }
309 309
 
310 310
 function wpinv_get_business_footer() {
311
-    $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>';
312
-    $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link );
313
-    return apply_filters( 'wpinv_get_business_footer', $business_footer );
311
+    $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>';
312
+    $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link);
313
+    return apply_filters('wpinv_get_business_footer', $business_footer);
314 314
 }
315 315
 
316 316
 function wpinv_checkout_required_fields() {
317 317
     $required_fields = array();
318 318
     
319 319
     // Let payment gateways and other extensions determine if address fields should be required
320
-    $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
320
+    $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes());
321 321
     
322
-    if ( $require_billing_details ) {
323
-		if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
322
+    if ($require_billing_details) {
323
+		if ((bool)wpinv_get_option('fname_mandatory')) {
324 324
 			$required_fields['first_name'] = array(
325 325
 				'error_id' => 'invalid_first_name',
326
-				'error_message' => __( 'Please enter your first name', 'invoicing' )
326
+				'error_message' => __('Please enter your first name', 'invoicing')
327 327
 			);
328 328
 		}
329
-		if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
329
+		if ((bool)wpinv_get_option('address_mandatory')) {
330 330
 			$required_fields['address'] = array(
331 331
 				'error_id' => 'invalid_address',
332
-				'error_message' => __( 'Please enter your address', 'invoicing' )
332
+				'error_message' => __('Please enter your address', 'invoicing')
333 333
 			);
334 334
 		}
335
-		if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
335
+		if ((bool)wpinv_get_option('city_mandatory')) {
336 336
 			$required_fields['city'] = array(
337 337
 				'error_id' => 'invalid_city',
338
-				'error_message' => __( 'Please enter your billing city', 'invoicing' )
338
+				'error_message' => __('Please enter your billing city', 'invoicing')
339 339
 			);
340 340
 		}
341
-		if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
341
+		if ((bool)wpinv_get_option('state_mandatory')) {
342 342
 			$required_fields['state'] = array(
343 343
 				'error_id' => 'invalid_state',
344
-				'error_message' => __( 'Please enter billing state / province', 'invoicing' )
344
+				'error_message' => __('Please enter billing state / province', 'invoicing')
345 345
 			);
346 346
 		}
347
-		if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
347
+		if ((bool)wpinv_get_option('country_mandatory')) {
348 348
 			$required_fields['country'] = array(
349 349
 				'error_id' => 'invalid_country',
350
-				'error_message' => __( 'Please select your billing country', 'invoicing' )
350
+				'error_message' => __('Please select your billing country', 'invoicing')
351 351
 			);
352 352
 		}
353 353
     }
354 354
 
355
-    return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
355
+    return apply_filters('wpinv_checkout_required_fields', $required_fields);
356 356
 }
357 357
 
358 358
 function wpinv_is_ssl_enforced() {
359
-    $ssl_enforced = wpinv_get_option( 'enforce_ssl', false );
360
-    return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced );
359
+    $ssl_enforced = wpinv_get_option('enforce_ssl', false);
360
+    return (bool)apply_filters('wpinv_is_ssl_enforced', $ssl_enforced);
361 361
 }
362 362
 
363
-function wpinv_user_can_view_invoice( $post ) {
363
+function wpinv_user_can_view_invoice($post) {
364 364
     $allow = false;
365 365
 
366
-    $post = get_post( $post );
366
+    $post = get_post($post);
367 367
 
368
-    if ( empty( $post->ID ) ) {
368
+    if (empty($post->ID)) {
369 369
         return $allow;
370 370
     }
371 371
 
372
-    $invoice = wpinv_get_invoice( $post->ID );
373
-    if ( empty( $invoice->ID ) ) {
372
+    $invoice = wpinv_get_invoice($post->ID);
373
+    if (empty($invoice->ID)) {
374 374
         return $allow;
375 375
     }
376 376
 
377 377
     // Don't allow trash, draft status
378
-    if ( $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
379
-        if ( current_user_can( 'manage_options' ) ) { // Admin user
378
+    if ($invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
379
+        if (current_user_can('manage_options')) { // Admin user
380 380
             $allow = true;
381 381
         } else {
382
-            if ( is_user_logged_in() ) {
383
-                if ( (int)$invoice->get_user_id() === (int)get_current_user_id() ) {
382
+            if (is_user_logged_in()) {
383
+                if ((int)$invoice->get_user_id() === (int)get_current_user_id()) {
384 384
                     $allow = true;
385
-                } else if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
385
+                } else if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
386 386
                     $allow = true;
387 387
                 }
388 388
             } else {
389
-                if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
389
+                if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
390 390
                     $allow = true;
391 391
                 }
392 392
             }
393 393
         }
394 394
     }
395 395
     
396
-    return apply_filters( 'wpinv_can_print_invoice', $allow, $post, $invoice );
396
+    return apply_filters('wpinv_can_print_invoice', $allow, $post, $invoice);
397 397
 }
398 398
 
399 399
 function wpinv_schedule_events() {
400 400
     // hourly, daily and twicedaily
401
-    if ( !wp_next_scheduled( 'wpinv_register_schedule_event_twicedaily' ) ) {
402
-        wp_schedule_event( current_time( 'timestamp' ), 'twicedaily', 'wpinv_register_schedule_event_twicedaily' );
401
+    if (!wp_next_scheduled('wpinv_register_schedule_event_twicedaily')) {
402
+        wp_schedule_event(current_time('timestamp'), 'twicedaily', 'wpinv_register_schedule_event_twicedaily');
403 403
     }
404 404
 }
405
-add_action( 'wp', 'wpinv_schedule_events' );
405
+add_action('wp', 'wpinv_schedule_events');
406 406
 
407 407
 function wpinv_schedule_event_twicedaily() {
408 408
     wpinv_email_payment_reminders();
409 409
 }
410
-add_action( 'wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily' );
410
+add_action('wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily');
411 411
 
412 412
 function wpinv_require_login_to_checkout() {
413
-    $return = wpinv_get_option( 'login_to_checkout', false );
414
-    return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return );
413
+    $return = wpinv_get_option('login_to_checkout', false);
414
+    return (bool)apply_filters('wpinv_require_login_to_checkout', $return);
415 415
 }
416 416
 
417
-function wpinv_sequential_number_active( $type = '' ) {
418
-    $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type );
419
-    if ( null !== $check ) {
417
+function wpinv_sequential_number_active($type = '') {
418
+    $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type);
419
+    if (null !== $check) {
420 420
         return $check;
421 421
     }
422 422
     
423
-    return wpinv_get_option( 'sequential_invoice_number' );
423
+    return wpinv_get_option('sequential_invoice_number');
424 424
 }
425 425
 
426
-function wpinv_switch_to_locale( $locale = NULL ) {
426
+function wpinv_switch_to_locale($locale = NULL) {
427 427
     global $invoicing, $wpi_switch_locale;
428 428
 
429
-    if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) {
430
-        $locale = empty( $locale ) ? get_locale() : $locale;
429
+    if (!empty($invoicing) && function_exists('switch_to_locale')) {
430
+        $locale = empty($locale) ? get_locale() : $locale;
431 431
 
432
-        switch_to_locale( $locale );
432
+        switch_to_locale($locale);
433 433
 
434 434
         $wpi_switch_locale = $locale;
435 435
 
436
-        add_filter( 'plugin_locale', 'get_locale' );
436
+        add_filter('plugin_locale', 'get_locale');
437 437
 
438 438
         $invoicing->load_textdomain();
439 439
 
440
-        do_action( 'wpinv_switch_to_locale', $locale );
440
+        do_action('wpinv_switch_to_locale', $locale);
441 441
     }
442 442
 }
443 443
 
444 444
 function wpinv_restore_locale() {
445 445
     global $invoicing, $wpi_switch_locale;
446 446
     
447
-    if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) {
447
+    if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) {
448 448
         restore_previous_locale();
449 449
 
450 450
         $wpi_switch_locale = NULL;
451 451
 
452
-        remove_filter( 'plugin_locale', 'get_locale' );
452
+        remove_filter('plugin_locale', 'get_locale');
453 453
 
454 454
         $invoicing->load_textdomain();
455 455
 
456
-        do_action( 'wpinv_restore_locale' );
456
+        do_action('wpinv_restore_locale');
457 457
     }
458 458
 }
459 459
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-bp-core.php 1 patch
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -11,60 +11,60 @@  discard block
 block discarded – undo
11 11
     public function __construct() {
12 12
         global $bp;
13 13
         
14
-        if ( !defined( 'WPINV_BP_SLUG' ) ) {
15
-            define( 'WPINV_BP_SLUG', 'invoices' );
14
+        if (!defined('WPINV_BP_SLUG')) {
15
+            define('WPINV_BP_SLUG', 'invoices');
16 16
         }
17 17
         
18
-        $position       = wpinv_get_option( 'wpinv_menu_position' );
18
+        $position       = wpinv_get_option('wpinv_menu_position');
19 19
         $position       = $position !== '' && $position !== false ? $position : 91;
20
-        $this->position = apply_filters( 'wpinv_bp_nav_position', $position );
20
+        $this->position = apply_filters('wpinv_bp_nav_position', $position);
21 21
         $this->slug     = WPINV_BP_SLUG;
22 22
         
23 23
         parent::start(
24 24
             'invoicing',
25
-            _x( 'Invoices', 'Invoices screen page <title>', 'invoicing' ),
26
-            trailingslashit( dirname( __FILE__ ) ),
25
+            _x('Invoices', 'Invoices screen page <title>', 'invoicing'),
26
+            trailingslashit(dirname(__FILE__)),
27 27
             array(
28 28
                 'adminbar_myaccount_order' => $this->position
29 29
             )
30 30
         );
31 31
     }
32 32
     
33
-    public function includes( $includes = array() ) {
34
-        parent::includes( $includes );
33
+    public function includes($includes = array()) {
34
+        parent::includes($includes);
35 35
     }
36 36
     
37
-    public function setup_globals( $args = array() ) {
37
+    public function setup_globals($args = array()) {
38 38
         global $bp;
39 39
 
40 40
         $args = array(
41 41
             'slug' => $this->slug,
42 42
         );
43 43
 
44
-        parent::setup_globals( $args );
44
+        parent::setup_globals($args);
45 45
     }
46 46
     
47
-    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
48
-        if ( !bp_is_my_profile() ) {
47
+    public function setup_nav($main_nav = array(), $sub_nav = array()) {
48
+        if (!bp_is_my_profile()) {
49 49
             return;
50 50
         }
51 51
         
52
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) {
52
+        if (wpinv_get_option('wpinv_bp_hide_menu')) {
53 53
             return;
54 54
         }
55 55
         
56 56
         $this->setup_invoice_count();
57 57
 
58 58
         $user_domain    = bp_loggedin_user_domain();
59
-        $invoices_link  = trailingslashit( $user_domain . $this->slug );
60
-        $class          = ( 0 === $this->count ) ? 'no-count' : 'count';
59
+        $invoices_link  = trailingslashit($user_domain . $this->slug);
60
+        $class          = (0 === $this->count) ? 'no-count' : 'count';
61 61
 
62 62
         $main_nav_name = sprintf(
63
-            __( 'My Invoices %s', 'invoicing' ),
63
+            __('My Invoices %s', 'invoicing'),
64 64
             sprintf(
65 65
                 '<span class="%s">%s</span>',
66
-                esc_attr( $class ),
67
-                bp_core_number_format( $this->count )
66
+                esc_attr($class),
67
+                bp_core_number_format($this->count)
68 68
             )
69 69
         );
70 70
 
@@ -72,54 +72,54 @@  discard block
 block discarded – undo
72 72
             'name'                => $main_nav_name,
73 73
             'slug'                => $this->slug,
74 74
             'position'            => $this->position,
75
-            'screen_function'     => array( $this, 'invoices_screen' ),
75
+            'screen_function'     => array($this, 'invoices_screen'),
76 76
             'default_subnav_slug' => 'invoices',
77 77
             'item_css_id'         => $this->id
78 78
         );
79 79
         
80 80
         $sub_nav[] = array(
81
-            'name'            => _x( 'My Invoices', 'Invoices screen sub nav', 'invoicing' ),
81
+            'name'            => _x('My Invoices', 'Invoices screen sub nav', 'invoicing'),
82 82
             'slug'            => 'invoices',
83 83
             'parent_url'      => $invoices_link,
84 84
             'parent_slug'     => $this->slug,
85
-            'screen_function' => array( $this, 'invoices_screen' ),
85
+            'screen_function' => array($this, 'invoices_screen'),
86 86
             'position'        => 10,
87 87
             'item_css_id'     => 'invoices-my-invoices'
88 88
         );
89 89
 
90
-        parent::setup_nav( $main_nav, $sub_nav );
90
+        parent::setup_nav($main_nav, $sub_nav);
91 91
     }
92 92
     
93 93
     public function setup_title() {
94 94
         // Adjust title.
95
-        if ( (bool)bp_is_current_component( 'invoicing' ) ) {
95
+        if ((bool)bp_is_current_component('invoicing')) {
96 96
             global $bp;
97 97
             
98
-            $bp->bp_options_title = __( 'My Invoices', 'invoicing' );
98
+            $bp->bp_options_title = __('My Invoices', 'invoicing');
99 99
         }
100 100
 
101 101
         parent::setup_title();
102 102
     }
103 103
     
104 104
     public function invoices_screen() {
105
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) {
105
+        if (wpinv_get_option('wpinv_bp_hide_menu')) {
106 106
             return;
107 107
         }
108 108
         
109 109
         global $bp;
110 110
         
111
-        add_action( 'bp_template_content', array( $this, 'invoices_content' ) );
111
+        add_action('bp_template_content', array($this, 'invoices_content'));
112 112
 
113
-        $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
113
+        $template = apply_filters('bp_core_template_plugin', 'members/single/plugins');
114 114
         
115
-        bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
115
+        bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template));
116 116
     }
117 117
     
118 118
     public function invoices_content() {
119
-        if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) {
119
+        if ($this->has_invoices(bp_ajax_querystring('invoices'))) {
120 120
             global $invoices_template;
121 121
             
122
-            do_action( 'wpinv_bp_invoices_before_content' );
122
+            do_action('wpinv_bp_invoices_before_content');
123 123
             ?>
124 124
             <div class="wpi-g wpi-bp-invoices invoices invoicing" style="position:relative">
125 125
                 <div id="pag-top" class="pagination">
@@ -133,61 +133,61 @@  discard block
 block discarded – undo
133 133
                 <table class="table table-bordered table-hover table-responsive wpi-user-invoices" style="margin:0">
134 134
                     <thead>
135 135
                         <tr>
136
-                            <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
137
-                                <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th>
136
+                            <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
137
+                                <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th>
138 138
                             <?php endforeach; ?>
139 139
                         </tr>
140 140
                     </thead>
141 141
                     <tbody>
142
-                        <?php foreach ( $invoices_template->invoices as $invoice ) {
142
+                        <?php foreach ($invoices_template->invoices as $invoice) {
143 143
                             ?>
144 144
                             <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
145
-                                <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
146
-                                    <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>">
147
-                                        <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?>
148
-                                            <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?>
149
-
150
-                                        <?php elseif ( 'invoice-number' === $column_id ) : ?>
151
-                                            <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>">
152
-                                                <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?>
145
+                                <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
146
+                                    <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>">
147
+                                        <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?>
148
+                                            <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?>
149
+
150
+                                        <?php elseif ('invoice-number' === $column_id) : ?>
151
+                                            <a href="<?php echo esc_url($invoice->get_view_url()); ?>">
152
+                                                <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?>
153 153
                                             </a>
154 154
 
155
-                                        <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?>
156
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
155
+                                        <?php elseif ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($invoice->ID, 'Y-m-d H:i:s'); ?>
156
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
157 157
 
158
-                                        <?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?>
159
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
158
+                                        <?php elseif ('payment-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID, '', false); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s', false); ?>
159
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
160 160
 
161
-                                        <?php elseif ( 'invoice-status' === $column_id ) : ?>
162
-                                            <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?>
161
+                                        <?php elseif ('invoice-status' === $column_id) : ?>
162
+                                            <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?>
163 163
 
164
-                                        <?php elseif ( 'invoice-total' === $column_id ) : ?>
165
-                                            <?php echo $invoice->get_total( true ); ?>
164
+                                        <?php elseif ('invoice-total' === $column_id) : ?>
165
+                                            <?php echo $invoice->get_total(true); ?>
166 166
 
167
-                                        <?php elseif ( 'invoice-actions' === $column_id ) : ?>
167
+                                        <?php elseif ('invoice-actions' === $column_id) : ?>
168 168
                                             <?php
169 169
                                                 $actions = array(
170 170
                                                     'pay'    => array(
171 171
                                                         'url'  => $invoice->get_checkout_payment_url(),
172
-                                                        'name' => __( 'Pay Now', 'invoicing' ),
172
+                                                        'name' => __('Pay Now', 'invoicing'),
173 173
                                                         'class' => 'btn-success'
174 174
                                                     ),
175 175
                                                     'print'   => array(
176 176
                                                         'url'  => $invoice->get_view_url(),
177
-                                                        'name' => __( 'Print', 'invoicing' ),
177
+                                                        'name' => __('Print', 'invoicing'),
178 178
                                                         'class' => 'btn-primary',
179 179
                                                         'attrs' => 'target="_blank"'
180 180
                                                     )
181 181
                                                 );
182 182
 
183
-                                                if ( ! $invoice->needs_payment() ) {
184
-                                                    unset( $actions['pay'] );
183
+                                                if (!$invoice->needs_payment()) {
184
+                                                    unset($actions['pay']);
185 185
                                                 }
186 186
 
187
-                                                if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
188
-                                                    foreach ( $actions as $key => $action ) {
187
+                                                if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) {
188
+                                                    foreach ($actions as $key => $action) {
189 189
                                                         $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
190
-                                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
190
+                                                        echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>';
191 191
                                                     }
192 192
                                                 }
193 193
                                             ?>
@@ -215,64 +215,64 @@  discard block
 block discarded – undo
215 215
             </div>
216 216
             <?php
217 217
         
218
-            do_action( 'wpinv_bp_invoices_after_content' );
218
+            do_action('wpinv_bp_invoices_after_content');
219 219
         } else {
220 220
             ?>
221 221
             <div id="message" class="info">
222
-                <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p>
222
+                <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p>
223 223
             </div>
224 224
             <?php
225 225
         }
226 226
         
227
-        if ( defined( 'DOING_AJAX' ) ) {
227
+        if (defined('DOING_AJAX')) {
228 228
             exit;
229 229
         }
230 230
     }
231 231
     
232
-    public function has_invoices( $args = '' ) {
232
+    public function has_invoices($args = '') {
233 233
         global $invoices_template;
234 234
 
235
-        $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) );
235
+        $per_page = absint(wpinv_get_option('wpinv_bp_per_page'));
236 236
         // Parse arguments.
237
-        $r = bp_parse_args( $args, array(
237
+        $r = bp_parse_args($args, array(
238 238
             'status'            => 'all',
239 239
             'page_arg'          => 'bpage',
240 240
             'page'              => 1,
241 241
             'per_page'          => $per_page > 0 ? $per_page : 20,
242 242
             'max'               => false,
243 243
             'user_id'           => bp_loggedin_user_id(),
244
-        ), 'has_invoices' );
244
+        ), 'has_invoices');
245 245
 
246 246
 
247
-        if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) {
247
+        if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) {
248 248
             $r['per_page'] = (int)$r['max'];
249 249
         }
250 250
 
251 251
         // Get the invoices.
252
-        $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] );
252
+        $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']);
253 253
 
254
-        return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r );
254
+        return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r);
255 255
     }
256 256
     
257 257
     public function setup_invoice_count() {
258
-        $query      = apply_filters( 'wpinv_user_invoices_count_query', array( 'user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) );
259
-        $invoices   = wpinv_get_invoices( $query );
258
+        $query      = apply_filters('wpinv_user_invoices_count_query', array('user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false));
259
+        $invoices   = wpinv_get_invoices($query);
260 260
         
261
-        $this->count = !empty( $invoices ) ? count( $invoices ) : 0;
261
+        $this->count = !empty($invoices) ? count($invoices) : 0;
262 262
     }
263 263
     
264 264
     public function pagination_count() {
265 265
         global $invoices_template;
266 266
 
267
-        $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1;
268
-        $from_num  = bp_core_number_format( $start_num );
269
-        $to_num    = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) );
270
-        $total     = bp_core_number_format( $invoices_template->total_invoice_count );
267
+        $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1;
268
+        $from_num  = bp_core_number_format($start_num);
269
+        $to_num    = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1));
270
+        $total     = bp_core_number_format($invoices_template->total_invoice_count);
271 271
 
272
-        if ( 1 == $invoices_template->total_invoice_count ) {
273
-            $message = __( 'Viewing 1 invoice', 'invoicing' );
272
+        if (1 == $invoices_template->total_invoice_count) {
273
+            $message = __('Viewing 1 invoice', 'invoicing');
274 274
         } else {
275
-            $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total );
275
+            $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total);
276 276
         }
277 277
 
278 278
         return $message;
@@ -281,32 +281,32 @@  discard block
 block discarded – undo
281 281
     function pagination_links() {
282 282
         global $invoices_template;
283 283
 
284
-        return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links );
284
+        return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links);
285 285
     }
286 286
     
287
-    public function bp_section( $settings = array() ) {
288
-        $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' );
287
+    public function bp_section($settings = array()) {
288
+        $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing');
289 289
         return $settings;
290 290
     }
291 291
     
292
-    public function bp_settings( $settings = array() ) {
292
+    public function bp_settings($settings = array()) {
293 293
         $settings['wpinv_bp'] = array(
294 294
             'wpinv_bp_labels' => array(
295 295
                 'id'   => 'wpinv_bp_settings',
296
-                'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>',
296
+                'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>',
297 297
                 'desc' => '',
298 298
                 'type' => 'header',
299 299
             ),
300 300
             'wpinv_bp_hide_menu' => array(
301 301
                 'id'   => 'wpinv_bp_hide_menu',
302
-                'name' => __( 'Hide Invoices link', 'invoicing' ),
303
-                'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ),
302
+                'name' => __('Hide Invoices link', 'invoicing'),
303
+                'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'),
304 304
                 'type' => 'checkbox',
305 305
             ),
306 306
             'wpinv_menu_position' => array(
307 307
                 'id'   => 'wpinv_menu_position',
308
-                'name' => __( 'Menu position', 'invoicing' ),
309
-                'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ),
308
+                'name' => __('Menu position', 'invoicing'),
309
+                'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'),
310 310
                 'type' => 'number',
311 311
                 'size' => 'small',
312 312
                 'min'  => '1',
@@ -316,8 +316,8 @@  discard block
 block discarded – undo
316 316
             ),
317 317
             'wpinv_bp_per_page' => array(
318 318
                 'id'   => 'wpinv_bp_per_page',
319
-                'name' => __( 'Max invoices per page', 'invoicing' ),
320
-                'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ),
319
+                'name' => __('Max invoices per page', 'invoicing'),
320
+                'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'),
321 321
                 'type' => 'number',
322 322
                 'size' => 'small',
323 323
                 'min'  => '1',
@@ -342,25 +342,25 @@  discard block
 block discarded – undo
342 342
     public $pag_links = '';
343 343
     public $total_invoice_count = 0;
344 344
     
345
-    public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) {
346
-        $this->invoices = array( 'invoices' => array(), 'total' => 0 );
345
+    public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') {
346
+        $this->invoices = array('invoices' => array(), 'total' => 0);
347 347
         
348
-        $this->pag_arg  = sanitize_key( $page_arg );
349
-        $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page );
350
-        $this->pag_num  = bp_sanitize_pagination_arg( 'num', $per_page );
348
+        $this->pag_arg  = sanitize_key($page_arg);
349
+        $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page);
350
+        $this->pag_num  = bp_sanitize_pagination_arg('num', $per_page);
351 351
 
352
-        $query_args     = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true );
353
-        if ( !empty( $status ) && $status != 'all' ) {
352
+        $query_args     = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true);
353
+        if (!empty($status) && $status != 'all') {
354 354
            $query_args['status'] = $status;
355 355
         }
356
-        $invoices  = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) );
356
+        $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args));
357 357
         
358
-        if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) {
359
-            $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts );
358
+        if (!empty($invoices) && !empty($invoices->found_posts)) {
359
+            $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts);
360 360
             $this->invoices['total']    = $invoices->found_posts;
361 361
         }
362 362
 
363
-        if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) {
363
+        if (empty($max) || ($max >= (int)$this->invoices['total'])) {
364 364
             $this->total_invoice_count = (int)$this->invoices['total'];
365 365
         } else {
366 366
             $this->total_invoice_count = (int)$max;
@@ -368,52 +368,52 @@  discard block
 block discarded – undo
368 368
 
369 369
         $this->invoices = $this->invoices['invoices'];
370 370
 
371
-        $invoice_count = count( $this->invoices );
371
+        $invoice_count = count($this->invoices);
372 372
 
373
-        if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) {
373
+        if (empty($max) || ($max >= (int)$invoice_count)) {
374 374
             $this->invoice_count = (int)$invoice_count;
375 375
         } else {
376 376
             $this->invoice_count = (int)$max;
377 377
         }
378 378
         
379
-        if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) {
380
-            $this->pag_links = paginate_links( array(
381
-                'base'      => add_query_arg( $this->pag_arg, '%#%' ),
379
+        if (!empty($this->total_invoice_count) && !empty($this->pag_num)) {
380
+            $this->pag_links = paginate_links(array(
381
+                'base'      => add_query_arg($this->pag_arg, '%#%'),
382 382
                 'format'    => '',
383
-                'total'     => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ),
383
+                'total'     => ceil((int)$this->total_invoice_count / (int)$this->pag_num),
384 384
                 'current'   => (int)$this->pag_page,
385
-                'prev_text' => _x( '&larr;', 'Invoice pagination previous text', 'invoicing' ),
386
-                'next_text' => _x( '&rarr;', 'Invoice pagination next text',     'invoicing' ),
385
+                'prev_text' => _x('&larr;', 'Invoice pagination previous text', 'invoicing'),
386
+                'next_text' => _x('&rarr;', 'Invoice pagination next text', 'invoicing'),
387 387
                 'mid_size'  => 1,
388 388
                 'add_args'  => array(),
389
-            ) );
389
+            ));
390 390
         }
391 391
     }
392 392
 
393 393
     public function has_invoices() {
394
-        return (bool) ! empty( $this->invoice_count );
394
+        return (bool)!empty($this->invoice_count);
395 395
     }
396 396
 
397 397
     public function next_invoice() {
398 398
         $this->current_invoice++;
399
-        $this->invoice = $this->invoices[ $this->current_invoice ];
399
+        $this->invoice = $this->invoices[$this->current_invoice];
400 400
 
401 401
         return $this->invoice;
402 402
     }
403 403
 
404 404
     public function rewind_invoices() {
405 405
         $this->current_invoice = -1;
406
-        if ( $this->invoice_count > 0 ) {
406
+        if ($this->invoice_count > 0) {
407 407
             $this->invoice = $this->invoices[0];
408 408
         }
409 409
     }
410 410
 
411 411
     public function invoices() {
412
-        if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) {
412
+        if (($this->current_invoice + 1) < $this->invoice_count) {
413 413
             return true;
414
-        } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) {
414
+        } elseif (($this->current_invoice + 1) === $this->invoice_count) {
415 415
 
416
-            do_action( 'wpinv_bp_invoice_loop_end' );
416
+            do_action('wpinv_bp_invoice_loop_end');
417 417
             
418 418
             $this->rewind_invoices();
419 419
         }
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
         $this->in_the_loop = true;
428 428
         $this->invoice     = $this->next_invoice();
429 429
 
430
-        if ( 0 === $this->current_invoice ) {
431
-            do_action( 'wpinv_bp_invoice_loop_start' );
430
+        if (0 === $this->current_invoice) {
431
+            do_action('wpinv_bp_invoice_loop_start');
432 432
         }
433 433
     }
434 434
 }
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
 
439 439
     $bp->invoicing = new WPInv_BP_Component();
440 440
     
441
-    add_action( 'wp_ajax_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) );
442
-    add_action( 'wp_ajax_nopriv_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) );
443
-    add_filter( 'wpinv_settings_sections_general', array( $bp->invoicing, 'bp_section' ), 10, 1 );
444
-    add_filter( 'wpinv_settings_general', array( $bp->invoicing, 'bp_settings' ), 10, 1 );
441
+    add_action('wp_ajax_invoicing_filter', array($bp->invoicing, 'invoices_content'));
442
+    add_action('wp_ajax_nopriv_invoicing_filter', array($bp->invoicing, 'invoices_content'));
443
+    add_filter('wpinv_settings_sections_general', array($bp->invoicing, 'bp_section'), 10, 1);
444
+    add_filter('wpinv_settings_general', array($bp->invoicing, 'bp_settings'), 10, 1);
445 445
 }
446
-add_action( 'bp_loaded', 'wpinv_bp_setup_component' );
447 446
\ No newline at end of file
447
+add_action('bp_loaded', 'wpinv_bp_setup_component');
448 448
\ No newline at end of file
Please login to merge, or discard this patch.