Passed
Pull Request — master (#861)
by Kiran
06:26 queued 01:06
created
includes/reports/class-getpaid-invoice-exporter.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Invoice_Exporter Class.
@@ -19,33 +19,33 @@  discard block
 block discarded – undo
19 19
 	 * @param array $args Args to search for.
20 20
 	 * @return array
21 21
 	 */
22
-	public function get_invoice_query_args( $post_type, $args ) {
22
+	public function get_invoice_query_args($post_type, $args) {
23 23
 
24 24
 		$query_args = array(
25 25
 			'post_type'              => $post_type,
26
-			'post_status'            => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ),
26
+			'post_status'            => array_keys(wpinv_get_invoice_statuses(true, false, $post_type)),
27 27
 			'posts_per_page'         => -1,
28 28
 			'no_found_rows'          => true,
29 29
 			'update_post_term_cache' => false,
30 30
 			'fields'                 => 'ids',
31 31
 		);
32 32
 
33
-		if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) {
34
-			$query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
33
+		if (!empty($args['status']) && in_array($args['status'], $query_args['post_status'], true)) {
34
+			$query_args['post_status'] = wpinv_clean(wpinv_parse_list($args['status']));
35 35
 		}
36 36
 
37 37
 		$date_query = array();
38
-		if ( ! empty( $args['to_date'] ) ) {
39
-			$date_query['before'] = wpinv_clean( $args['to_date'] );
38
+		if (!empty($args['to_date'])) {
39
+			$date_query['before'] = wpinv_clean($args['to_date']);
40 40
 		}
41 41
 
42
-		if ( ! empty( $args['from_date'] ) ) {
43
-			$date_query['after'] = wpinv_clean( $args['from_date'] );
42
+		if (!empty($args['from_date'])) {
43
+			$date_query['after'] = wpinv_clean($args['from_date']);
44 44
 		}
45 45
 
46
-		if ( ! empty( $date_query ) ) {
46
+		if (!empty($date_query)) {
47 47
 			$date_query['inclusive']  = true;
48
-			$query_args['date_query'] = array( $date_query );
48
+			$query_args['date_query'] = array($date_query);
49 49
 		}
50 50
 
51 51
 		return $query_args;
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 	 * @param array $query_args WP_Query args.
58 58
 	 * @return WPInv_Invoice[]
59 59
 	 */
60
-	public function get_invoices( $query_args ) {
60
+	public function get_invoices($query_args) {
61 61
 
62 62
 		// Get invoices.
63
-		$invoices = new WP_Query( $query_args );
63
+		$invoices = new WP_Query($query_args);
64 64
 
65 65
 		// Prepare the results.
66
-		return array_map( 'wpinv_get_invoice', $invoices->posts );
66
+		return array_map('wpinv_get_invoice', $invoices->posts);
67 67
 
68 68
 	}
69 69
 
@@ -71,22 +71,22 @@  discard block
 block discarded – undo
71 71
 	 * Handles the actual download.
72 72
 	 *
73 73
 	 */
74
-	public function export( $post_type, $args ) {
74
+	public function export($post_type, $args) {
75 75
 
76
-		$invoices  = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) );
76
+		$invoices  = $this->get_invoices($this->get_invoice_query_args($post_type, $args));
77 77
 		$stream    = $this->prepare_output();
78
-		$headers   = $this->get_export_fields( $post_type );
79
-		$file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) );
78
+		$headers   = $this->get_export_fields($post_type);
79
+		$file_type = $this->prepare_file_type(strtolower(getpaid_get_post_type_label($post_type)));
80 80
 
81
-		if ( 'csv' == $file_type ) {
82
-			$this->download_csv( $invoices, $stream, $headers );
83
-		} elseif ( 'xml' == $file_type ) {
84
-			$this->download_xml( $invoices, $stream, $headers );
81
+		if ('csv' == $file_type) {
82
+			$this->download_csv($invoices, $stream, $headers);
83
+		} elseif ('xml' == $file_type) {
84
+			$this->download_xml($invoices, $stream, $headers);
85 85
 		} else {
86
-			$this->download_json( $invoices, $stream, $headers );
86
+			$this->download_json($invoices, $stream, $headers);
87 87
 		}
88 88
 
89
-		fclose( $stream );
89
+		fclose($stream);
90 90
 		exit;
91 91
 	}
92 92
 
@@ -98,27 +98,27 @@  discard block
 block discarded – undo
98 98
 	 * @since       1.0.19
99 99
 	 * @return array
100 100
 	 */
101
-	public function prepare_row( $invoice, $fields ) {
101
+	public function prepare_row($invoice, $fields) {
102 102
 
103 103
 		$prepared      = array();
104
-		$amount_fields = $this->get_amount_fields( $invoice->get_post_type() );
105
-		$meta_fields = $this->get_payment_form_meta( $invoice );
104
+		$amount_fields = $this->get_amount_fields($invoice->get_post_type());
105
+		$meta_fields = $this->get_payment_form_meta($invoice);
106 106
 
107
-		foreach ( $fields as $field ) {
107
+		foreach ($fields as $field) {
108 108
 			$value  = '';
109 109
 			$method = "get_$field";
110 110
 
111
-			if ( method_exists( $invoice, $method ) ) {
112
-				$value  = $invoice->$method();
113
-			} else if( strpos( $field, '_' ) === 0 && isset( $meta_fields[ $field ] ) ) {
114
-				$value = $meta_fields[ $field ];
111
+			if (method_exists($invoice, $method)) {
112
+				$value = $invoice->$method();
113
+			} else if (strpos($field, '_') === 0 && isset($meta_fields[$field])) {
114
+				$value = $meta_fields[$field];
115 115
 			}
116 116
 
117
-			if ( in_array( $field, $amount_fields ) ) {
118
-				$value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
117
+			if (in_array($field, $amount_fields)) {
118
+				$value = wpinv_round_amount(wpinv_sanitize_amount($value));
119 119
 			}
120 120
 
121
-			$prepared[ $field ] = wpinv_clean( $value );
121
+			$prepared[$field] = wpinv_clean($value);
122 122
 
123 123
 		}
124 124
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @since       1.0.19
133 133
 	 * @return array
134 134
 	 */
135
-	public function get_export_fields( $post_type ) {
135
+	public function get_export_fields($post_type) {
136 136
 
137 137
 		$fields = array(
138 138
 			'id',
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
 		// Payment form meta fields.
186 186
 		$meta_fields = getpaid_get_payment_form_custom_fields();
187 187
 
188
-		if ( ! empty( $meta_fields ) ) {
189
-			foreach ( $meta_fields as $field_key => $field_label ) {
188
+		if (!empty($meta_fields)) {
189
+			foreach ($meta_fields as $field_key => $field_label) {
190 190
 				$fields[] = $field_key;
191 191
 			}
192 192
 		}
193 193
 
194
-		return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type );
194
+		return apply_filters('getpaid_invoice_exporter_get_fields', $fields, $post_type);
195 195
 	}
196 196
 
197 197
 	/**
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 * @since       1.0.19
202 202
 	 * @return array
203 203
 	 */
204
-	public function get_amount_fields( $post_type ) {
204
+	public function get_amount_fields($post_type) {
205 205
 
206 206
 		$fields = array(
207 207
 			'subtotal',
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			'total_fees',
211 211
     	);
212 212
 
213
-		return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type );
213
+		return apply_filters('getpaid_invoice_exporter_get_amount_fields', $fields, $post_type);
214 214
 	}
215 215
 
216 216
 	/**
@@ -220,25 +220,25 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @return array
222 222
 	 */
223
-	public function get_payment_form_meta( $invoice ) {
223
+	public function get_payment_form_meta($invoice) {
224 224
 		// Payment form meta fields.
225 225
 		$field_keys = getpaid_get_payment_form_custom_fields();
226
-		$meta = get_post_meta( $invoice->get_id(), 'additional_meta_data', true );
226
+		$meta = get_post_meta($invoice->get_id(), 'additional_meta_data', true);
227 227
 
228 228
 		$field_values = array();
229
-		if ( ! empty( $field_keys ) ) {
230
-			foreach ( $field_keys as $field_key => $field_label ) {
229
+		if (!empty($field_keys)) {
230
+			foreach ($field_keys as $field_key => $field_label) {
231 231
 				$value = '';
232 232
 
233
-				if ( ! empty( $meta ) ) {
234
-					foreach ( $meta as $meta_label => $meta_value ) {
235
-						if ( getpaid_strtolower( wpinv_clean( wp_unslash( $meta_label ) ) ) == getpaid_strtolower( $field_label ) ) {
233
+				if (!empty($meta)) {
234
+					foreach ($meta as $meta_label => $meta_value) {
235
+						if (getpaid_strtolower(wpinv_clean(wp_unslash($meta_label))) == getpaid_strtolower($field_label)) {
236 236
 							$value = $meta_value;
237 237
 						}
238 238
 					}
239 239
 				}
240 240
 
241
-				$field_values[ $field_key ] = $value;
241
+				$field_values[$field_key] = $value;
242 242
 			}
243 243
 		}
244 244
 
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 1 patch
Spacing   +294 added lines, -294 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
  * Are we supporting item quantities?
@@ -20,35 +20,35 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function wpinv_get_ip() {
22 22
 
23
-    if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) {
24
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) );
23
+    if (isset($_SERVER['HTTP_X_REAL_IP'])) {
24
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP']));
25 25
     }
26 26
 
27
-    if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
27
+    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
28 28
         // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2
29 29
         // Make sure we always only send through the first IP in the list which should always be the client IP.
30
-        return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) );
30
+        return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR']))))));
31 31
     }
32 32
 
33
-    if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
34
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) );
33
+    if (isset($_SERVER['HTTP_CLIENT_IP'])) {
34
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP']));
35 35
     }
36 36
 
37
-    if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
38
-        return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
37
+    if (isset($_SERVER['REMOTE_ADDR'])) {
38
+        return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']));
39 39
     }
40 40
 
41 41
     return '';
42 42
 }
43 43
 
44 44
 function wpinv_get_user_agent() {
45
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
46
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
45
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
46
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
47 47
     } else {
48 48
         $user_agent = '';
49 49
     }
50 50
 
51
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
51
+    return apply_filters('wpinv_get_user_agent', $user_agent);
52 52
 }
53 53
 
54 54
 /**
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
  * @param string $amount The amount to sanitize.
58 58
  * @return float
59 59
  */
60
-function getpaid_standardize_amount( $amount ) {
60
+function getpaid_standardize_amount($amount) {
61 61
 
62
-    $amount = str_replace( wpinv_thousands_separator(), '', $amount );
63
-    $amount = str_replace( wpinv_decimal_separator(), '.', $amount );
64
-    if ( is_numeric( $amount ) ) {
65
-        return floatval( $amount );
62
+    $amount = str_replace(wpinv_thousands_separator(), '', $amount);
63
+    $amount = str_replace(wpinv_decimal_separator(), '.', $amount);
64
+    if (is_numeric($amount)) {
65
+        return floatval($amount);
66 66
     }
67 67
 
68 68
     // Cast the remaining to a float.
69
-    return wpinv_round_amount( preg_replace( '/[^0-9\.\-]/', '', $amount ) );
69
+    return wpinv_round_amount(preg_replace('/[^0-9\.\-]/', '', $amount));
70 70
 
71 71
 }
72 72
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
  *
76 76
  * @param string $amount The amount to sanitize.
77 77
  */
78
-function getpaid_unstandardize_amount( $amount ) {
79
-    return str_replace( '.', wpinv_decimal_separator(), $amount );
78
+function getpaid_unstandardize_amount($amount) {
79
+    return str_replace('.', wpinv_decimal_separator(), $amount);
80 80
 }
81 81
 
82 82
 /**
@@ -84,24 +84,24 @@  discard block
 block discarded – undo
84 84
  *
85 85
  * @param string $amount The amount to sanitize.
86 86
  */
87
-function wpinv_sanitize_amount( $amount ) {
87
+function wpinv_sanitize_amount($amount) {
88 88
 
89
-    if ( is_numeric( $amount ) ) {
90
-        return floatval( $amount );
89
+    if (is_numeric($amount)) {
90
+        return floatval($amount);
91 91
     }
92 92
 
93 93
     // Separate the decimals and thousands.
94
-    $amount    = empty( $amount ) ? '0' : (string) $amount;
95
-    $amount    = explode( wpinv_decimal_separator(), $amount );
94
+    $amount    = empty($amount) ? '0' : (string) $amount;
95
+    $amount    = explode(wpinv_decimal_separator(), $amount);
96 96
 
97 97
     // Remove thousands.
98
-    $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] );
98
+    $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]);
99 99
 
100 100
     // Convert back to string.
101
-    $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
101
+    $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
102 102
 
103 103
     // Cast the remaining to a float.
104
-    return (float) preg_replace( '/[^0-9\.\-]/', '', $amount );
104
+    return (float) preg_replace('/[^0-9\.\-]/', '', $amount);
105 105
 
106 106
 }
107 107
 
@@ -111,19 +111,19 @@  discard block
 block discarded – undo
111 111
  * @param float $amount
112 112
  * @param float|string|int|null $decimals
113 113
  */
114
-function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) {
114
+function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) {
115 115
 
116
-    if ( $decimals === null ) {
116
+    if ($decimals === null) {
117 117
         $decimals = wpinv_decimals();
118 118
     }
119 119
 
120
-    if ( $use_sprintf ) {
121
-        $amount = sprintf( "%.{$decimals}f", (float) $amount );
120
+    if ($use_sprintf) {
121
+        $amount = sprintf("%.{$decimals}f", (float) $amount);
122 122
     } else {
123
-        $amount = round( (float) $amount, absint( $decimals ) );
123
+        $amount = round((float) $amount, absint($decimals));
124 124
     }
125 125
 
126
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
126
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
127 127
 }
128 128
 
129 129
 /**
@@ -135,32 +135,32 @@  discard block
 block discarded – undo
135 135
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
136 136
  * @return array
137 137
  */
138
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
138
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
139 139
 
140 140
 	$invoice_statuses = array(
141
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
142
-        'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
143
-        'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
144
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
145
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
146
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
147
-        'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
148
-        'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
141
+		'wpi-pending'    => _x('Pending payment', 'Invoice status', 'invoicing'),
142
+        'publish'        => _x('Paid', 'Invoice status', 'invoicing'),
143
+        'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'),
144
+		'wpi-onhold'     => _x('On hold', 'Invoice status', 'invoicing'),
145
+		'wpi-cancelled'  => _x('Cancelled', 'Invoice status', 'invoicing'),
146
+		'wpi-refunded'   => _x('Refunded', 'Invoice status', 'invoicing'),
147
+        'wpi-failed'     => _x('Failed', 'Invoice status', 'invoicing'),
148
+        'wpi-renewal'    => _x('Renewal Payment', 'Invoice status', 'invoicing'),
149 149
     );
150 150
 
151
-    if ( $draft ) {
152
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
151
+    if ($draft) {
152
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
153 153
     }
154 154
 
155
-    if ( $trashed ) {
156
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
155
+    if ($trashed) {
156
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
157 157
     }
158 158
 
159
-    if ( $invoice instanceof WPInv_Invoice ) {
159
+    if ($invoice instanceof WPInv_Invoice) {
160 160
         $invoice = $invoice->get_post_type();
161 161
     }
162 162
 
163
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
163
+	return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
164 164
 }
165 165
 
166 166
 /**
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
  * @param string $status The raw status
170 170
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
171 171
  */
172
-function wpinv_status_nicename( $status, $invoice = false ) {
173
-    $statuses = wpinv_get_invoice_statuses( true, true, $invoice );
174
-    $status   = isset( $statuses[ $status ] ) ? $statuses[ $status ] : $status;
172
+function wpinv_status_nicename($status, $invoice = false) {
173
+    $statuses = wpinv_get_invoice_statuses(true, true, $invoice);
174
+    $status   = isset($statuses[$status]) ? $statuses[$status] : $status;
175 175
 
176
-    return sanitize_text_field( $status );
176
+    return sanitize_text_field($status);
177 177
 }
178 178
 
179 179
 /**
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
  *
182 182
  * @param string $current
183 183
  */
184
-function wpinv_get_currency( $current = '' ) {
184
+function wpinv_get_currency($current = '') {
185 185
 
186
-    if ( empty( $current ) ) {
187
-        $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) );
186
+    if (empty($current)) {
187
+        $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD'));
188 188
     }
189 189
 
190
-    return trim( strtoupper( $current ) );
190
+    return trim(strtoupper($current));
191 191
 }
192 192
 
193 193
 /**
@@ -195,25 +195,25 @@  discard block
 block discarded – undo
195 195
  *
196 196
  * @param string|null $currency The currency code. Defaults to the default currency.
197 197
  */
198
-function wpinv_currency_symbol( $currency = null ) {
198
+function wpinv_currency_symbol($currency = null) {
199 199
 
200 200
     // Prepare the currency.
201
-    $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency );
201
+    $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency);
202 202
 
203 203
     // Fetch all symbols.
204 204
     $symbols = wpinv_get_currency_symbols();
205 205
 
206 206
     // Fetch this currencies symbol.
207
-    $currency_symbol = isset( $symbols[ $currency ] ) ? $symbols[ $currency ] : $currency;
207
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
208 208
 
209 209
     // Filter the symbol.
210
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
210
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
211 211
 }
212 212
 
213 213
 function wpinv_currency_position() {
214
-    $position = wpinv_get_option( 'currency_position', 'left' );
214
+    $position = wpinv_get_option('currency_position', 'left');
215 215
 
216
-    return apply_filters( 'wpinv_currency_position', $position );
216
+    return apply_filters('wpinv_currency_position', $position);
217 217
 }
218 218
 
219 219
 /**
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
  *
222 222
  * @param $string|null $current
223 223
  */
224
-function wpinv_thousands_separator( $current = null ) {
224
+function wpinv_thousands_separator($current = null) {
225 225
 
226
-    if ( null == $current ) {
227
-        $current = wpinv_get_option( 'thousands_separator', ',' );
226
+    if (null == $current) {
227
+        $current = wpinv_get_option('thousands_separator', ',');
228 228
     }
229 229
 
230
-    return trim( $current );
230
+    return trim($current);
231 231
 }
232 232
 
233 233
 /**
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
  *
236 236
  * @param $string|null $current
237 237
  */
238
-function wpinv_decimal_separator( $current = null ) {
238
+function wpinv_decimal_separator($current = null) {
239 239
 
240
-    if ( null == $current ) {
241
-        $current = wpinv_get_option( 'decimal_separator', '.' );
240
+    if (null == $current) {
241
+        $current = wpinv_get_option('decimal_separator', '.');
242 242
     }
243 243
 
244
-    return trim( $current );
244
+    return trim($current);
245 245
 }
246 246
 
247 247
 /**
@@ -249,27 +249,27 @@  discard block
 block discarded – undo
249 249
  *
250 250
  * @param $string|null $current
251 251
  */
252
-function wpinv_decimals( $current = null ) {
252
+function wpinv_decimals($current = null) {
253 253
 
254
-    if ( null == $current ) {
255
-        $current = wpinv_get_option( 'decimals', 2 );
254
+    if (null == $current) {
255
+        $current = wpinv_get_option('decimals', 2);
256 256
     }
257 257
 
258
-    return absint( $current );
258
+    return absint($current);
259 259
 }
260 260
 
261 261
 /**
262 262
  * Retrieves a list of all supported currencies.
263 263
  */
264 264
 function wpinv_get_currencies() {
265
-    return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) );
265
+    return apply_filters('wpinv_currencies', wpinv_get_data('currencies'));
266 266
 }
267 267
 
268 268
 /**
269 269
  * Retrieves a list of all currency symbols.
270 270
  */
271 271
 function wpinv_get_currency_symbols() {
272
-    return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) );
272
+    return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols'));
273 273
 }
274 274
 
275 275
 /**
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 	$currency_pos = wpinv_currency_position();
282 282
 	$format       = '%1$s%2$s';
283 283
 
284
-	switch ( $currency_pos ) {
284
+	switch ($currency_pos) {
285 285
 		case 'left':
286 286
 			$format = '%1$s%2$s';
287 287
 			break;
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 			break;
297 297
 	}
298 298
 
299
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
299
+	return apply_filters('getpaid_price_format', $format, $currency_pos);
300 300
 }
301 301
 
302 302
 /**
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
  * @param  string $currency Currency.
307 307
  * @return string
308 308
  */
309
-function wpinv_the_price( $amount = 0, $currency = '' ) {
310
-    echo wp_kses_post( wpinv_price( $amount, $currency ) );
309
+function wpinv_the_price($amount = 0, $currency = '') {
310
+    echo wp_kses_post(wpinv_price($amount, $currency));
311 311
 }
312 312
 
313 313
 /**
@@ -317,25 +317,25 @@  discard block
 block discarded – undo
317 317
  * @param  string $currency Currency.
318 318
  * @return string
319 319
  */
320
-function wpinv_price( $amount = 0, $currency = '' ) {
320
+function wpinv_price($amount = 0, $currency = '') {
321 321
 
322 322
     // Backwards compatibility.
323
-    $amount             = wpinv_sanitize_amount( $amount );
323
+    $amount             = wpinv_sanitize_amount($amount);
324 324
 
325 325
     // Prepare variables.
326
-    $currency           = wpinv_get_currency( $currency );
326
+    $currency           = wpinv_get_currency($currency);
327 327
     $amount             = (float) $amount;
328 328
     $unformatted_amount = $amount;
329 329
     $negative           = $amount < 0;
330
-    $amount             = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) );
331
-    $amount             = wpinv_format_amount( $amount );
330
+    $amount             = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount));
331
+    $amount             = wpinv_format_amount($amount);
332 332
 
333 333
     // Format the amount.
334 334
     $format             = getpaid_get_price_format();
335
-    $formatted_amount   = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount );
335
+    $formatted_amount   = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount);
336 336
 
337 337
     // Filter the formatting.
338
-    return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount );
338
+    return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount);
339 339
 }
340 340
 
341 341
 /**
@@ -346,25 +346,25 @@  discard block
 block discarded – undo
346 346
  * @param  bool     $calculate Whether or not to apply separators.
347 347
  * @return string
348 348
  */
349
-function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) {
349
+function wpinv_format_amount($amount, $decimals = null, $calculate = false) {
350 350
     $thousands_sep = wpinv_thousands_separator();
351 351
     $decimal_sep   = wpinv_decimal_separator();
352
-    $decimals      = wpinv_decimals( $decimals );
353
-    $amount        = wpinv_sanitize_amount( $amount );
352
+    $decimals      = wpinv_decimals($decimals);
353
+    $amount        = wpinv_sanitize_amount($amount);
354 354
 
355
-    if ( $calculate ) {
355
+    if ($calculate) {
356 356
         return $amount;
357 357
     }
358 358
 
359 359
     // Fomart the amount.
360
-    return number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
360
+    return number_format($amount, $decimals, $decimal_sep, $thousands_sep);
361 361
 }
362 362
 
363
-function wpinv_sanitize_key( $key ) {
363
+function wpinv_sanitize_key($key) {
364 364
     $raw_key = $key;
365
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
365
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
366 366
 
367
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
367
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
368 368
 }
369 369
 
370 370
 /**
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
  *
373 373
  * @param $str the file whose extension should be retrieved.
374 374
  */
375
-function wpinv_get_file_extension( $str ) {
376
-    $filetype = wp_check_filetype( $str );
375
+function wpinv_get_file_extension($str) {
376
+    $filetype = wp_check_filetype($str);
377 377
     return $filetype['ext'];
378 378
 }
379 379
 
@@ -382,16 +382,16 @@  discard block
 block discarded – undo
382 382
  *
383 383
  * @param string $string
384 384
  */
385
-function wpinv_string_is_image_url( $string ) {
386
-    $extension = strtolower( wpinv_get_file_extension( $string ) );
387
-    return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true );
385
+function wpinv_string_is_image_url($string) {
386
+    $extension = strtolower(wpinv_get_file_extension($string));
387
+    return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true);
388 388
 }
389 389
 
390 390
 /**
391 391
  * Returns the current URL.
392 392
  */
393 393
 function wpinv_get_current_page_url() {
394
-    return esc_url( add_query_arg( array() ) );
394
+    return esc_url(add_query_arg(array()));
395 395
 }
396 396
 
397 397
 /**
@@ -401,46 +401,46 @@  discard block
 block discarded – undo
401 401
  * @param string $name  Constant name.
402 402
  * @param mixed  $value Value.
403 403
  */
404
-function getpaid_maybe_define_constant( $name, $value ) {
405
-	if ( ! defined( $name ) ) {
406
-		define( $name, $value );
404
+function getpaid_maybe_define_constant($name, $value) {
405
+	if (!defined($name)) {
406
+		define($name, $value);
407 407
 	}
408 408
 }
409 409
 
410 410
 function wpinv_get_php_arg_separator_output() {
411
-	return ini_get( 'arg_separator.output' );
411
+	return ini_get('arg_separator.output');
412 412
 }
413 413
 
414
-function wpinv_rgb_from_hex( $color ) {
415
-    $color = str_replace( '#', '', $color );
414
+function wpinv_rgb_from_hex($color) {
415
+    $color = str_replace('#', '', $color);
416 416
 
417 417
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
418
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
419
-    if ( empty( $color ) ) {
418
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
419
+    if (empty($color)) {
420 420
         return null;
421 421
     }
422 422
 
423
-    $color = str_split( $color );
423
+    $color = str_split($color);
424 424
 
425 425
     $rgb      = array();
426
-    $rgb['R'] = hexdec( $color[0] . $color[1] );
427
-    $rgb['G'] = hexdec( $color[2] . $color[3] );
428
-    $rgb['B'] = hexdec( $color[4] . $color[5] );
426
+    $rgb['R'] = hexdec($color[0] . $color[1]);
427
+    $rgb['G'] = hexdec($color[2] . $color[3]);
428
+    $rgb['B'] = hexdec($color[4] . $color[5]);
429 429
 
430 430
     return $rgb;
431 431
 }
432 432
 
433
-function wpinv_hex_darker( $color, $factor = 30 ) {
434
-    $base  = wpinv_rgb_from_hex( $color );
433
+function wpinv_hex_darker($color, $factor = 30) {
434
+    $base  = wpinv_rgb_from_hex($color);
435 435
     $color = '#';
436 436
 
437
-    foreach ( $base as $k => $v ) {
437
+    foreach ($base as $k => $v) {
438 438
         $amount      = $v / 100;
439
-        $amount      = round( $amount * $factor );
439
+        $amount      = round($amount * $factor);
440 440
         $new_decimal = $v - $amount;
441 441
 
442
-        $new_hex_component = dechex( $new_decimal );
443
-        if ( strlen( $new_hex_component ) < 2 ) {
442
+        $new_hex_component = dechex($new_decimal);
443
+        if (strlen($new_hex_component) < 2) {
444 444
             $new_hex_component = '0' . $new_hex_component;
445 445
         }
446 446
         $color .= $new_hex_component;
@@ -449,18 +449,18 @@  discard block
 block discarded – undo
449 449
     return $color;
450 450
 }
451 451
 
452
-function wpinv_hex_lighter( $color, $factor = 30 ) {
453
-    $base  = wpinv_rgb_from_hex( $color );
452
+function wpinv_hex_lighter($color, $factor = 30) {
453
+    $base  = wpinv_rgb_from_hex($color);
454 454
     $color = '#';
455 455
 
456
-    foreach ( $base as $k => $v ) {
456
+    foreach ($base as $k => $v) {
457 457
         $amount      = 255 - $v;
458 458
         $amount      = $amount / 100;
459
-        $amount      = round( $amount * $factor );
459
+        $amount      = round($amount * $factor);
460 460
         $new_decimal = $v + $amount;
461 461
 
462
-        $new_hex_component = dechex( $new_decimal );
463
-        if ( strlen( $new_hex_component ) < 2 ) {
462
+        $new_hex_component = dechex($new_decimal);
463
+        if (strlen($new_hex_component) < 2) {
464 464
             $new_hex_component = '0' . $new_hex_component;
465 465
         }
466 466
         $color .= $new_hex_component;
@@ -469,22 +469,22 @@  discard block
 block discarded – undo
469 469
     return $color;
470 470
 }
471 471
 
472
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
473
-    $hex = str_replace( '#', '', $color );
472
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
473
+    $hex = str_replace('#', '', $color);
474 474
 
475
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
476
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
477
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
475
+    $c_r = hexdec(substr($hex, 0, 2));
476
+    $c_g = hexdec(substr($hex, 2, 2));
477
+    $c_b = hexdec(substr($hex, 4, 2));
478 478
 
479
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
479
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
480 480
 
481 481
     return $brightness > 155 ? $dark : $light;
482 482
 }
483 483
 
484
-function wpinv_format_hex( $hex ) {
485
-    $hex = trim( str_replace( '#', '', $hex ) );
484
+function wpinv_format_hex($hex) {
485
+    $hex = trim(str_replace('#', '', $hex));
486 486
 
487
-    if ( strlen( $hex ) == 3 ) {
487
+    if (strlen($hex) == 3) {
488 488
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
489 489
     }
490 490
 
@@ -504,12 +504,12 @@  discard block
 block discarded – undo
504 504
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
505 505
  * @return string
506 506
  */
507
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
508
-    if ( function_exists( 'mb_strimwidth' ) ) {
509
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
507
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
508
+    if (function_exists('mb_strimwidth')) {
509
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
510 510
     }
511 511
 
512
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
512
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
513 513
 }
514 514
 
515 515
 /**
@@ -521,28 +521,28 @@  discard block
 block discarded – undo
521 521
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
522 522
  * @return int Returns the number of characters in string.
523 523
  */
524
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
525
-    if ( function_exists( 'mb_strlen' ) ) {
526
-        return mb_strlen( $str, $encoding );
524
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
525
+    if (function_exists('mb_strlen')) {
526
+        return mb_strlen($str, $encoding);
527 527
     }
528 528
 
529
-    return strlen( $str );
529
+    return strlen($str);
530 530
 }
531 531
 
532
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
533
-    if ( function_exists( 'mb_strtolower' ) ) {
534
-        return mb_strtolower( $str, $encoding );
532
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
533
+    if (function_exists('mb_strtolower')) {
534
+        return mb_strtolower($str, $encoding);
535 535
     }
536 536
 
537
-    return strtolower( $str );
537
+    return strtolower($str);
538 538
 }
539 539
 
540
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
541
-    if ( function_exists( 'mb_strtoupper' ) ) {
542
-        return mb_strtoupper( $str, $encoding );
540
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
541
+    if (function_exists('mb_strtoupper')) {
542
+        return mb_strtoupper($str, $encoding);
543 543
     }
544 544
 
545
-    return strtoupper( $str );
545
+    return strtoupper($str);
546 546
 }
547 547
 
548 548
 /**
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
557 557
  * @return int Returns the position of the first occurrence of search in the string.
558 558
  */
559
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
560
-    if ( function_exists( 'mb_strpos' ) ) {
561
-        return mb_strpos( $str, $find, $offset, $encoding );
559
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
560
+    if (function_exists('mb_strpos')) {
561
+        return mb_strpos($str, $find, $offset, $encoding);
562 562
     }
563 563
 
564
-    return strpos( $str, $find, $offset );
564
+    return strpos($str, $find, $offset);
565 565
 }
566 566
 
567 567
 /**
@@ -575,12 +575,12 @@  discard block
 block discarded – undo
575 575
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
576 576
  * @return int Returns the position of the last occurrence of search.
577 577
  */
578
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
579
-    if ( function_exists( 'mb_strrpos' ) ) {
580
-        return mb_strrpos( $str, $find, $offset, $encoding );
578
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
579
+    if (function_exists('mb_strrpos')) {
580
+        return mb_strrpos($str, $find, $offset, $encoding);
581 581
     }
582 582
 
583
-    return strrpos( $str, $find, $offset );
583
+    return strrpos($str, $find, $offset);
584 584
 }
585 585
 
586 586
 /**
@@ -595,16 +595,16 @@  discard block
 block discarded – undo
595 595
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
596 596
  * @return string
597 597
  */
598
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
599
-    if ( function_exists( 'mb_substr' ) ) {
600
-        if ( null === $length ) {
601
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
598
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
599
+    if (function_exists('mb_substr')) {
600
+        if (null === $length) {
601
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
602 602
         } else {
603
-            return mb_substr( $str, $start, $length, $encoding );
603
+            return mb_substr($str, $start, $length, $encoding);
604 604
         }
605 605
     }
606 606
 
607
-    return substr( $str, $start, $length );
607
+    return substr($str, $start, $length);
608 608
 }
609 609
 
610 610
 /**
@@ -616,48 +616,48 @@  discard block
 block discarded – undo
616 616
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
617 617
  * @return string The width of string.
618 618
  */
619
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
620
-    if ( function_exists( 'mb_strwidth' ) ) {
621
-        return mb_strwidth( $str, $encoding );
619
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
620
+    if (function_exists('mb_strwidth')) {
621
+        return mb_strwidth($str, $encoding);
622 622
     }
623 623
 
624
-    return wpinv_utf8_strlen( $str, $encoding );
624
+    return wpinv_utf8_strlen($str, $encoding);
625 625
 }
626 626
 
627
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
628
-    if ( function_exists( 'mb_strlen' ) ) {
629
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
627
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
628
+    if (function_exists('mb_strlen')) {
629
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
630 630
         $str_end = '';
631 631
 
632
-        if ( $lower_str_end ) {
633
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
632
+        if ($lower_str_end) {
633
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
634 634
         } else {
635
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
635
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
636 636
         }
637 637
 
638 638
         return $first_letter . $str_end;
639 639
     }
640 640
 
641
-    return ucfirst( $str );
641
+    return ucfirst($str);
642 642
 }
643 643
 
644
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
645
-    if ( function_exists( 'mb_convert_case' ) ) {
646
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
644
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
645
+    if (function_exists('mb_convert_case')) {
646
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
647 647
     }
648 648
 
649
-    return ucwords( $str );
649
+    return ucwords($str);
650 650
 }
651 651
 
652
-function wpinv_period_in_days( $period, $unit ) {
653
-    $period = absint( $period );
652
+function wpinv_period_in_days($period, $unit) {
653
+    $period = absint($period);
654 654
 
655
-    if ( $period > 0 ) {
656
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
655
+    if ($period > 0) {
656
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
657 657
             $period = $period * 7;
658
-        } elseif ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
658
+        } elseif (in_array(strtolower($unit), array('m', 'month', 'months'))) {
659 659
             $period = $period * 30;
660
-        } elseif ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
660
+        } elseif (in_array(strtolower($unit), array('y', 'year', 'years'))) {
661 661
             $period = $period * 365;
662 662
         }
663 663
     }
@@ -665,14 +665,14 @@  discard block
 block discarded – undo
665 665
     return $period;
666 666
 }
667 667
 
668
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
669
-    if ( function_exists( 'cal_days_in_month' ) ) {
670
-        return cal_days_in_month( $calendar, $month, $year );
668
+function wpinv_cal_days_in_month($calendar, $month, $year) {
669
+    if (function_exists('cal_days_in_month')) {
670
+        return cal_days_in_month($calendar, $month, $year);
671 671
     }
672 672
 
673 673
     // Fallback in case the calendar extension is not loaded in PHP
674 674
     // Only supports Gregorian calendar
675
-    return gmdate( 't', mktime( 0, 0, 0, $month, 1, $year ) );
675
+    return gmdate('t', mktime(0, 0, 0, $month, 1, $year));
676 676
 }
677 677
 
678 678
 /**
@@ -683,27 +683,27 @@  discard block
 block discarded – undo
683 683
  *
684 684
  * @return string
685 685
  */
686
-function wpi_help_tip( $tip, $allow_html = false, $is_vue = false, $echo = false ) {
686
+function wpi_help_tip($tip, $allow_html = false, $is_vue = false, $echo = false) {
687 687
 
688
-    if ( $allow_html ) {
689
-        $tip = wpi_sanitize_tooltip( $tip );
688
+    if ($allow_html) {
689
+        $tip = wpi_sanitize_tooltip($tip);
690 690
     } else {
691
-        $tip = strip_tags( $tip );
691
+        $tip = strip_tags($tip);
692 692
     }
693 693
 
694
-    if ( $is_vue ) {
694
+    if ($is_vue) {
695 695
 
696
-        if ( $echo ) {
697
-            echo '<span class="dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
696
+        if ($echo) {
697
+            echo '<span class="dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
698 698
         } else {
699
-            return '<span class="dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
699
+            return '<span class="dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
700 700
         }
701 701
 }
702 702
 
703
-    if ( $echo ) {
704
-        echo '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
703
+    if ($echo) {
704
+        echo '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
705 705
     } else {
706
-        return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
706
+        return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
707 707
     }
708 708
 }
709 709
 
@@ -715,9 +715,9 @@  discard block
 block discarded – undo
715 715
  * @param string $var
716 716
  * @return string
717 717
  */
718
-function wpi_sanitize_tooltip( $var ) {
718
+function wpi_sanitize_tooltip($var) {
719 719
     return wp_kses(
720
-        html_entity_decode( $var ),
720
+        html_entity_decode($var),
721 721
         array(
722 722
 			'br'     => array(),
723 723
 			'em'     => array(),
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
  */
741 741
 function wpinv_get_screen_ids() {
742 742
 
743
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
743
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
744 744
 
745 745
     $screen_ids = array(
746 746
         'toplevel_page_' . $screen_id,
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
         'gp-setup', // setup wizard
763 763
     );
764 764
 
765
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
765
+    return apply_filters('wpinv_screen_ids', $screen_ids);
766 766
 }
767 767
 
768 768
 /**
@@ -773,14 +773,14 @@  discard block
 block discarded – undo
773 773
  * @param array|string $list List of values.
774 774
  * @return array Sanitized array of values.
775 775
  */
776
-function wpinv_parse_list( $list ) {
776
+function wpinv_parse_list($list) {
777 777
 
778
-    if ( empty( $list ) ) {
778
+    if (empty($list)) {
779 779
         $list = array();
780 780
     }
781 781
 
782
-	if ( ! is_array( $list ) ) {
783
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
782
+	if (!is_array($list)) {
783
+		return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
784 784
 	}
785 785
 
786 786
 	return $list;
@@ -794,8 +794,8 @@  discard block
 block discarded – undo
794 794
  * @param string $key Type of data to fetch.
795 795
  * @return mixed Fetched data.
796 796
  */
797
-function wpinv_get_data( $key ) {
798
-    return apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
797
+function wpinv_get_data($key) {
798
+    return apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php");
799 799
 }
800 800
 
801 801
 /**
@@ -807,10 +807,10 @@  discard block
 block discarded – undo
807 807
  * @param bool $first_empty Whether or not the first item in the list should be empty
808 808
  * @return mixed Fetched data.
809 809
  */
810
-function wpinv_maybe_add_empty_option( $options, $first_empty ) {
810
+function wpinv_maybe_add_empty_option($options, $first_empty) {
811 811
 
812
-    if ( ! empty( $options ) && $first_empty ) {
813
-        return array_merge( array( '' => '' ), $options );
812
+    if (!empty($options) && $first_empty) {
813
+        return array_merge(array('' => ''), $options);
814 814
     }
815 815
     return $options;
816 816
 
@@ -822,21 +822,21 @@  discard block
 block discarded – undo
822 822
  * @param mixed $var Data to sanitize.
823 823
  * @return string|array
824 824
  */
825
-function wpinv_clean( $var ) {
825
+function wpinv_clean($var) {
826 826
 
827
-	if ( is_array( $var ) ) {
828
-		return array_map( 'wpinv_clean', $var );
827
+	if (is_array($var)) {
828
+		return array_map('wpinv_clean', $var);
829 829
     }
830 830
 
831
-    if ( is_object( $var ) ) {
832
-		$object_vars = get_object_vars( $var );
833
-		foreach ( $object_vars as $property_name => $property_value ) {
834
-			$var->$property_name = wpinv_clean( $property_value );
831
+    if (is_object($var)) {
832
+		$object_vars = get_object_vars($var);
833
+		foreach ($object_vars as $property_name => $property_value) {
834
+			$var->$property_name = wpinv_clean($property_value);
835 835
         }
836 836
         return $var;
837 837
 	}
838 838
 
839
-    return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var;
839
+    return is_string($var) ? sanitize_text_field(stripslashes($var)) : $var;
840 840
 }
841 841
 
842 842
 /**
@@ -845,43 +845,43 @@  discard block
 block discarded – undo
845 845
  * @param string $str Data to convert.
846 846
  * @return string|array
847 847
  */
848
-function getpaid_convert_price_string_to_options( $str ) {
848
+function getpaid_convert_price_string_to_options($str) {
849 849
 
850
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
851
-    $options     = array();
850
+	$raw_options = array_map('trim', explode(',', $str));
851
+    $options = array();
852 852
 
853
-    foreach ( $raw_options as $option ) {
853
+    foreach ($raw_options as $option) {
854 854
 
855
-        if ( '' == $option ) {
855
+        if ('' == $option) {
856 856
             continue;
857 857
         }
858 858
 
859
-        $option = array_map( 'trim', explode( '|', $option ) );
859
+        $option = array_map('trim', explode('|', $option));
860 860
 
861 861
         $price = null;
862 862
         $label = null;
863 863
 
864
-        if ( isset( $option[0] ) && '' != $option[0] ) {
865
-            $label  = $option[0];
864
+        if (isset($option[0]) && '' != $option[0]) {
865
+            $label = $option[0];
866 866
         }
867 867
 
868
-        if ( isset( $option[1] ) && '' != $option[1] ) {
868
+        if (isset($option[1]) && '' != $option[1]) {
869 869
             $price = $option[1];
870 870
         }
871 871
 
872
-        if ( ! isset( $price ) ) {
872
+        if (!isset($price)) {
873 873
             $price = $label;
874 874
         }
875 875
 
876
-        if ( ! isset( $price ) || ! is_numeric( $price ) ) {
876
+        if (!isset($price) || !is_numeric($price)) {
877 877
             continue;
878 878
         }
879 879
 
880
-        if ( ! isset( $label ) ) {
880
+        if (!isset($label)) {
881 881
             $label = $price;
882 882
         }
883 883
 
884
-        $options[ "$label|$price" ] = $label;
884
+        $options["$label|$price"] = $label;
885 885
     }
886 886
 
887 887
     return $options;
@@ -890,14 +890,14 @@  discard block
 block discarded – undo
890 890
 /**
891 891
  * Returns the help tip.
892 892
  */
893
-function getpaid_get_help_tip( $tip, $additional_classes = '', $echo = false ) {
893
+function getpaid_get_help_tip($tip, $additional_classes = '', $echo = false) {
894 894
     $classes = 'wpi-help-tip dashicons dashicons-editor-help ' . $additional_classes;
895
-    $tip     = esc_attr( $tip );
895
+    $tip     = esc_attr($tip);
896 896
 
897
-    if ( $echo ) {
898
-        echo '<span class="' . esc_attr( $classes ) . '" data-tip="' . esc_attr( $tip ) . '"></span>';
897
+    if ($echo) {
898
+        echo '<span class="' . esc_attr($classes) . '" data-tip="' . esc_attr($tip) . '"></span>';
899 899
     } else {
900
-        return '<span class="' . esc_attr( $classes ) . '" data-tip="' . esc_attr( $tip ) . '"></span>';
900
+        return '<span class="' . esc_attr($classes) . '" data-tip="' . esc_attr($tip) . '"></span>';
901 901
     }
902 902
 
903 903
 }
@@ -905,18 +905,18 @@  discard block
 block discarded – undo
905 905
 /**
906 906
  * Formats a date
907 907
  */
908
-function getpaid_format_date( $date, $with_time = false ) {
908
+function getpaid_format_date($date, $with_time = false) {
909 909
 
910
-    if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) {
910
+    if (empty($date) || $date == '0000-00-00 00:00:00') {
911 911
         return '';
912 912
     }
913 913
 
914 914
     $format = getpaid_date_format();
915 915
 
916
-    if ( $with_time ) {
916
+    if ($with_time) {
917 917
         $format .= ' ' . getpaid_time_format();
918 918
     }
919
-    return date_i18n( $format, strtotime( $date ) );
919
+    return date_i18n($format, strtotime($date));
920 920
 
921 921
 }
922 922
 
@@ -925,9 +925,9 @@  discard block
 block discarded – undo
925 925
  *
926 926
  * @return string
927 927
  */
928
-function getpaid_format_date_value( $date, $default = '&mdash;', $with_time = false ) {
929
-    $date = getpaid_format_date( $date, $with_time );
930
-    return empty( $date ) ? $default : $date;
928
+function getpaid_format_date_value($date, $default = '&mdash;', $with_time = false) {
929
+    $date = getpaid_format_date($date, $with_time);
930
+    return empty($date) ? $default : $date;
931 931
 }
932 932
 
933 933
 /**
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
  * @return string
937 937
  */
938 938
 function getpaid_date_format() {
939
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
939
+	return apply_filters('getpaid_date_format', get_option('date_format'));
940 940
 }
941 941
 
942 942
 /**
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
  * @return string
946 946
  */
947 947
 function getpaid_time_format() {
948
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
948
+	return apply_filters('getpaid_time_format', get_option('time_format'));
949 949
 }
950 950
 
951 951
 /**
@@ -955,16 +955,16 @@  discard block
 block discarded – undo
955 955
  * @param  integer $limit Limit size in characters.
956 956
  * @return string
957 957
  */
958
-function getpaid_limit_length( $string, $limit ) {
958
+function getpaid_limit_length($string, $limit) {
959 959
     $str_limit = $limit - 3;
960 960
 
961
-	if ( function_exists( 'mb_strimwidth' ) ) {
962
-		if ( mb_strlen( $string ) > $limit ) {
963
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
961
+	if (function_exists('mb_strimwidth')) {
962
+		if (mb_strlen($string) > $limit) {
963
+			$string = mb_strimwidth($string, 0, $str_limit) . '...';
964 964
 		}
965 965
 	} else {
966
-		if ( strlen( $string ) > $limit ) {
967
-			$string = substr( $string, 0, $str_limit ) . '...';
966
+		if (strlen($string) > $limit) {
967
+			$string = substr($string, 0, $str_limit) . '...';
968 968
 		}
969 969
 	}
970 970
     return $string;
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
  * @since 1.0.19
979 979
  */
980 980
 function getpaid_api() {
981
-    return getpaid()->get( 'api' );
981
+    return getpaid()->get('api');
982 982
 }
983 983
 
984 984
 /**
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
  * @since 1.0.19
989 989
  */
990 990
 function getpaid_post_types() {
991
-    return getpaid()->get( 'post_types' );
991
+    return getpaid()->get('post_types');
992 992
 }
993 993
 
994 994
 /**
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
  * @since 1.0.19
999 999
  */
1000 1000
 function getpaid_session() {
1001
-    return getpaid()->get( 'session' );
1001
+    return getpaid()->get('session');
1002 1002
 }
1003 1003
 
1004 1004
 /**
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
  * @since 1.0.19
1009 1009
  */
1010 1010
 function getpaid_notes() {
1011
-    return getpaid()->get( 'notes' );
1011
+    return getpaid()->get('notes');
1012 1012
 }
1013 1013
 
1014 1014
 /**
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
  * @return GetPaid_Admin
1018 1018
  */
1019 1019
 function getpaid_admin() {
1020
-    return getpaid()->get( 'admin' );
1020
+    return getpaid()->get('admin');
1021 1021
 }
1022 1022
 
1023 1023
 /**
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
  * @param string $base the base url
1028 1028
  * @return string
1029 1029
  */
1030
-function getpaid_get_authenticated_action_url( $action, $base = false ) {
1031
-    return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' );
1030
+function getpaid_get_authenticated_action_url($action, $base = false) {
1031
+    return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce');
1032 1032
 }
1033 1033
 
1034 1034
 /**
@@ -1036,11 +1036,11 @@  discard block
 block discarded – undo
1036 1036
  *
1037 1037
  * @return string
1038 1038
  */
1039
-function getpaid_get_post_type_label( $post_type, $plural = true ) {
1039
+function getpaid_get_post_type_label($post_type, $plural = true) {
1040 1040
 
1041
-    $post_type = get_post_type_object( $post_type );
1041
+    $post_type = get_post_type_object($post_type);
1042 1042
 
1043
-    if ( ! is_object( $post_type ) ) {
1043
+    if (!is_object($post_type)) {
1044 1044
         return null;
1045 1045
     }
1046 1046
 
@@ -1053,18 +1053,18 @@  discard block
 block discarded – undo
1053 1053
  *
1054 1054
  * @return mixed|null
1055 1055
  */
1056
-function getpaid_get_array_field( $array, $key, $secondary_key = null ) {
1056
+function getpaid_get_array_field($array, $key, $secondary_key = null) {
1057 1057
 
1058
-    if ( ! is_array( $array ) ) {
1058
+    if (!is_array($array)) {
1059 1059
         return null;
1060 1060
     }
1061 1061
 
1062
-    if ( ! empty( $secondary_key ) ) {
1063
-        $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array();
1064
-        return getpaid_get_array_field( $array, $key );
1062
+    if (!empty($secondary_key)) {
1063
+        $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array();
1064
+        return getpaid_get_array_field($array, $key);
1065 1065
     }
1066 1066
 
1067
-    return isset( $array[ $key ] ) ? $array[ $key ] : null;
1067
+    return isset($array[$key]) ? $array[$key] : null;
1068 1068
 
1069 1069
 }
1070 1070
 
@@ -1073,12 +1073,12 @@  discard block
 block discarded – undo
1073 1073
  *
1074 1074
  * @return array
1075 1075
  */
1076
-function getpaid_array_merge_if_empty( $args, $defaults ) {
1076
+function getpaid_array_merge_if_empty($args, $defaults) {
1077 1077
 
1078
-    foreach ( $defaults as $key => $value ) {
1078
+    foreach ($defaults as $key => $value) {
1079 1079
 
1080
-        if ( empty( $args[ $key ] ) ) {
1081
-            $args[ $key ] = $value;
1080
+        if (empty($args[$key])) {
1081
+            $args[$key] = $value;
1082 1082
         }
1083 1083
     }
1084 1084
 
@@ -1095,12 +1095,12 @@  discard block
 block discarded – undo
1095 1095
 
1096 1096
     $types = get_allowed_mime_types();
1097 1097
 
1098
-    if ( isset( $types['htm|html'] ) ) {
1099
-		unset( $types['htm|html'] );
1098
+    if (isset($types['htm|html'])) {
1099
+		unset($types['htm|html']);
1100 1100
 	}
1101 1101
 
1102
-    if ( isset( $types['js'] ) ) {
1103
-		unset( $types['js'] );
1102
+    if (isset($types['js'])) {
1103
+		unset($types['js']);
1104 1104
 	}
1105 1105
 
1106 1106
     return $types;
@@ -1108,21 +1108,21 @@  discard block
 block discarded – undo
1108 1108
 }
1109 1109
 
1110 1110
 
1111
-function getpaid_user_delete_invoice( $data ) {
1111
+function getpaid_user_delete_invoice($data) {
1112 1112
 
1113 1113
     // Ensure there is an invoice to delete.
1114
-    if ( empty( $data['invoice_id'] ) ) {
1114
+    if (empty($data['invoice_id'])) {
1115 1115
         return;
1116 1116
     }
1117 1117
 
1118
-    $invoice = new WPInv_Invoice( (int) $data['invoice_id'] );
1118
+    $invoice = new WPInv_Invoice((int) $data['invoice_id']);
1119 1119
 
1120 1120
     // Ensure that it exists and that it belongs to the current user.
1121
-    if ( ! $invoice->exists() || $invoice->get_customer_id() != get_current_user_id() ) {
1121
+    if (!$invoice->exists() || $invoice->get_customer_id() != get_current_user_id()) {
1122 1122
         $notice = 'perm_delete_invoice';
1123 1123
 
1124 1124
     // Can it be deleted?
1125
-    } elseif ( ! $invoice->needs_payment() ) {
1125
+    } elseif (!$invoice->needs_payment()) {
1126 1126
         $notice = 'cannot_delete_invoice';
1127 1127
 
1128 1128
     // Delete it.
@@ -1141,11 +1141,11 @@  discard block
 block discarded – undo
1141 1141
         )
1142 1142
     );
1143 1143
 
1144
-    wp_safe_redirect( $redirect );
1144
+    wp_safe_redirect($redirect);
1145 1145
     exit;
1146 1146
 
1147 1147
 }
1148
-add_action( 'getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice' );
1148
+add_action('getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice');
1149 1149
 
1150 1150
 /**
1151 1151
  * Converts string to lower case.
@@ -1156,11 +1156,11 @@  discard block
 block discarded – undo
1156 1156
  * @param string $charset Character set to use for conversion.
1157 1157
  * @return string Returns converted string.
1158 1158
  */
1159
-function getpaid_strtolower( $string, $charset = 'UTF-8' ) {
1160
-	if ( function_exists( 'mb_convert_case' ) ) {
1161
-		return mb_convert_case( $string, MB_CASE_LOWER, $charset );
1159
+function getpaid_strtolower($string, $charset = 'UTF-8') {
1160
+	if (function_exists('mb_convert_case')) {
1161
+		return mb_convert_case($string, MB_CASE_LOWER, $charset);
1162 1162
 	} else {
1163
-		return strtolower( $string );
1163
+		return strtolower($string);
1164 1164
 	}
1165 1165
 }
1166 1166
 
@@ -1173,10 +1173,10 @@  discard block
 block discarded – undo
1173 1173
  * @param string $charset Character set to use for conversion.
1174 1174
  * @return string Returns converted string.
1175 1175
  */
1176
-function getpaid_strtoupper( $string, $charset = 'UTF-8' ) {
1177
-	if ( function_exists( 'mb_convert_case' ) ) {
1178
-		return mb_convert_case( $string, MB_CASE_UPPER, $charset );
1176
+function getpaid_strtoupper($string, $charset = 'UTF-8') {
1177
+	if (function_exists('mb_convert_case')) {
1178
+		return mb_convert_case($string, MB_CASE_UPPER, $charset);
1179 1179
 	} else {
1180
-		return strtoupper( $string );
1180
+		return strtoupper($string);
1181 1181
 	}
1182 1182
 }
1183 1183
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/views/wizard-thank-you.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,40 +4,40 @@
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 global $aui_bs5;
10 10
 ?>
11 11
 <div class="card shadow-sm my-5">
12 12
 	<div class="text-center card-body">
13
-		<h1 class="h3"><?php esc_html_e( 'Awesome, you are ready to Get Paid', 'invoicing' ); ?></h1>
13
+		<h1 class="h3"><?php esc_html_e('Awesome, you are ready to Get Paid', 'invoicing'); ?></h1>
14 14
 
15 15
 		<div class="geodirectory-message geodirectory-tracker">
16
-			<p><?php esc_html_e( 'Thank you for choosing GetPaid!', 'invoicing' ); ?> <i class="far fa-smile-beam"></i></p>
16
+			<p><?php esc_html_e('Thank you for choosing GetPaid!', 'invoicing'); ?> <i class="far fa-smile-beam"></i></p>
17 17
 		</div>
18 18
 
19 19
 		<div class="gp-setup-next-steps">
20 20
 			<div class="gp-setup-next-steps-first mb-4">
21 21
 				<div>
22
-					<h2 class="h3"><i class="fas fa-arrow-down"></i> <?php esc_html_e( 'Watch This', 'invoicing' ); ?> <i class="fas fa-arrow-down"></i></h2>
23
-					<div class="<?php echo( $aui_bs5 ? 'ratio ratio-16x9' : 'embed-responsive embed-responsive-16by9' ); ?> mb-4">
24
-						<iframe class="<?php echo( $aui_bs5 ? '' : 'embed-responsive-item' ); ?>" src="https://www.youtube.com/embed/TXZuPXHjt9E?rel=0" allowfullscreen></iframe>
22
+					<h2 class="h3"><i class="fas fa-arrow-down"></i> <?php esc_html_e('Watch This', 'invoicing'); ?> <i class="fas fa-arrow-down"></i></h2>
23
+					<div class="<?php echo($aui_bs5 ? 'ratio ratio-16x9' : 'embed-responsive embed-responsive-16by9'); ?> mb-4">
24
+						<iframe class="<?php echo($aui_bs5 ? '' : 'embed-responsive-item'); ?>" src="https://www.youtube.com/embed/TXZuPXHjt9E?rel=0" allowfullscreen></iframe>
25 25
 					</div>
26 26
 				</div>
27
-				<h2 class="h3"><?php esc_html_e( 'Next steps', 'invoicing' ); ?></h2>
27
+				<h2 class="h3"><?php esc_html_e('Next steps', 'invoicing'); ?></h2>
28 28
 
29 29
 				<div class="d-flex justify-content-between">
30
-					<a class="btn btn-outline-primary btn-sm" href="<?php echo esc_url( admin_url( 'post-new.php?post_type=wpi_item' ) ); ?>"><span class="h1 d-block"><i class="fas fa-box-open"></i></span> <?php esc_html_e( 'Create Item', 'invoicing' ); ?></a>
31
-					<a class="btn btn-outline-primary btn-sm" href="<?php echo esc_url( admin_url( 'post-new.php?post_type=wpi_payment_form' ) ); ?>"><span class="h1 d-block"><i class="fas fa-align-justify"></i></span> <?php esc_html_e( 'Create Payment Form', 'invoicing' ); ?></a>
32
-					<a class="btn btn-outline-primary btn-sm" href="<?php echo esc_url( admin_url( 'post-new.php?post_type=wpi_invoice' ) ); ?>"><span class="h1 d-block"><i class="fas fa-file-alt"></i></span> <?php esc_html_e( 'Create Invoice', 'invoicing' ); ?></a>
30
+					<a class="btn btn-outline-primary btn-sm" href="<?php echo esc_url(admin_url('post-new.php?post_type=wpi_item')); ?>"><span class="h1 d-block"><i class="fas fa-box-open"></i></span> <?php esc_html_e('Create Item', 'invoicing'); ?></a>
31
+					<a class="btn btn-outline-primary btn-sm" href="<?php echo esc_url(admin_url('post-new.php?post_type=wpi_payment_form')); ?>"><span class="h1 d-block"><i class="fas fa-align-justify"></i></span> <?php esc_html_e('Create Payment Form', 'invoicing'); ?></a>
32
+					<a class="btn btn-outline-primary btn-sm" href="<?php echo esc_url(admin_url('post-new.php?post_type=wpi_invoice')); ?>"><span class="h1 d-block"><i class="fas fa-file-alt"></i></span> <?php esc_html_e('Create Invoice', 'invoicing'); ?></a>
33 33
 				</div>
34 34
 
35
-				<h2 class="h3 mt-4"><?php esc_html_e( 'Learn more', 'invoicing' ); ?></h2>
35
+				<h2 class="h3 mt-4"><?php esc_html_e('Learn more', 'invoicing'); ?></h2>
36 36
 				<div class="gp-setup-next-steps-last mt-2 d-flex justify-content-between">
37
-					<a class="btn btn-outline-primary btn-sm" href="https://docs.wpgetpaid.com/collection/114-getting-started?utm_source=setupwizard&utm_medium=product&utm_content=getting-started&utm_campaign=invoicingplugin" target="_blank"><?php esc_html_e( 'Getting Started', 'invoicing' ); ?></a>
38
-					<a class="btn btn-outline-primary btn-sm" href="https://docs.wpgetpaid.com/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=invoicingplugin" target="_blank"><?php esc_html_e( 'Documentation', 'invoicing' ); ?></a>
39
-					<a class="btn btn-outline-primary btn-sm" href="https://wpgetpaid.com/support/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=invoicingyplugin" target="_blank"><?php esc_html_e( 'Support', 'invoicing' ); ?></a>
40
-					<a class="btn btn-outline-primary btn-sm" href="https://demos.ayecode.io/getpaid/?utm_source=setupwizard&utm_medium=product&utm_content=demos&utm_campaign=invoicingyplugin" target="_blank"><?php esc_html_e( 'Demos', 'invoicing' ); ?></a>
37
+					<a class="btn btn-outline-primary btn-sm" href="https://docs.wpgetpaid.com/collection/114-getting-started?utm_source=setupwizard&utm_medium=product&utm_content=getting-started&utm_campaign=invoicingplugin" target="_blank"><?php esc_html_e('Getting Started', 'invoicing'); ?></a>
38
+					<a class="btn btn-outline-primary btn-sm" href="https://docs.wpgetpaid.com/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=invoicingplugin" target="_blank"><?php esc_html_e('Documentation', 'invoicing'); ?></a>
39
+					<a class="btn btn-outline-primary btn-sm" href="https://wpgetpaid.com/support/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=invoicingyplugin" target="_blank"><?php esc_html_e('Support', 'invoicing'); ?></a>
40
+					<a class="btn btn-outline-primary btn-sm" href="https://demos.ayecode.io/getpaid/?utm_source=setupwizard&utm_medium=product&utm_content=demos&utm_campaign=invoicingyplugin" target="_blank"><?php esc_html_e('Demos', 'invoicing'); ?></a>
41 41
 				</div>
42 42
 			</div>
43 43
 		</div>
Please login to merge, or discard this patch.
includes/admin/views/wizard-gateways.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 global $aui_bs5;
10 10
 ?>
@@ -12,24 +12,24 @@  discard block
 block discarded – undo
12 12
 
13 13
     <form method="post" class="text-center card-body">
14 14
         <div class="gp-wizard-payments">
15
-            <h2 class="gd-settings-title h3 "><?php esc_html_e( 'Gateway Setup', 'invoicing' ); ?></h2>
16
-            <p><?php esc_html_e( 'Below are a few gateways that can be setup in a few seconds.', 'invoicing' ); ?>
15
+            <h2 class="gd-settings-title h3 "><?php esc_html_e('Gateway Setup', 'invoicing'); ?></h2>
16
+            <p><?php esc_html_e('Below are a few gateways that can be setup in a few seconds.', 'invoicing'); ?>
17 17
                 <br>
18
-                <?php esc_html_e( 'We have 20+ Gateways that can be setup later.', 'invoicing' ); ?>
18
+                <?php esc_html_e('We have 20+ Gateways that can be setup later.', 'invoicing'); ?>
19 19
             </p>
20 20
 
21 21
             <ul class="list-group">
22 22
 
23 23
 				<li class="list-group-item d-flex justify-content-between align-items-center">
24
-				    <span class="mr-auto"><img src="<?php echo esc_url( WPINV_PLUGIN_URL . 'assets/images/stripe-verified.svg' ); ?>" class="<?php echo( $aui_bs5 ? 'ms-n2' : 'ml-n2' ); ?>" alt="Stripe"></span>
25
-				    <?php if ( false === wpinv_get_option( 'stripe_live_connect_account_id' ) ) : ?>
24
+				    <span class="mr-auto"><img src="<?php echo esc_url(WPINV_PLUGIN_URL . 'assets/images/stripe-verified.svg'); ?>" class="<?php echo($aui_bs5 ? 'ms-n2' : 'ml-n2'); ?>" alt="Stripe"></span>
25
+				    <?php if (false === wpinv_get_option('stripe_live_connect_account_id')) : ?>
26 26
                         <a href="<?php
27
-                        echo esc_url( wp_nonce_url(
27
+                        echo esc_url(wp_nonce_url(
28 28
                             add_query_arg(
29 29
                                 array(
30 30
                                     'getpaid-admin-action' => 'connect_gateway',
31 31
                                     'plugin'               => 'stripe',
32
-                                    'redirect'             => urlencode( add_query_arg( 'step', 'payments' ) ),
32
+                                    'redirect'             => urlencode(add_query_arg('step', 'payments')),
33 33
                                 ),
34 34
                                 admin_url()
35 35
                             ),
@@ -37,42 +37,42 @@  discard block
 block discarded – undo
37 37
                             'getpaid-nonce'
38 38
                         ));
39 39
                         ?>"
40
-                        class="btn btn-sm btn-outline-primary"><?php esc_html_e( 'Connect', 'invoicing' ); ?></a>
40
+                        class="btn btn-sm btn-outline-primary"><?php esc_html_e('Connect', 'invoicing'); ?></a>
41 41
                     <?php else : ?>
42
-                        <span class="btn btn-sm btn-success"><?php esc_html_e( 'Connected', 'invoicing' ); ?></span>
42
+                        <span class="btn btn-sm btn-success"><?php esc_html_e('Connected', 'invoicing'); ?></span>
43 43
                     <?php endif; ?>
44 44
 				</li>
45 45
 
46 46
 				<li class="list-group-item">
47 47
                     <div class="d-flex justify-content-between align-items-center">
48
-                        <span class="<?php echo( $aui_bs5 ? 'me-auto' : 'mr-auto' ); ?>">
49
-                            <img src="<?php echo esc_url( WPINV_PLUGIN_URL . 'assets/images/pp-logo-150px.webp' ); ?>" class="" alt="PayPal" height="25">
48
+                        <span class="<?php echo($aui_bs5 ? 'me-auto' : 'mr-auto'); ?>">
49
+                            <img src="<?php echo esc_url(WPINV_PLUGIN_URL . 'assets/images/pp-logo-150px.webp'); ?>" class="" alt="PayPal" height="25">
50 50
                         </span>
51 51
                         <a
52 52
                             href="#"
53 53
                             onclick="jQuery('.getpaid-setup-paypal-input').toggleClass('d-none'); return false;"
54
-                            class="getpaid-setup-paypal btn btn-sm btn-outline-primary"><?php esc_html_e( 'Set-up', 'invoicing' ); ?></a>
54
+                            class="getpaid-setup-paypal btn btn-sm btn-outline-primary"><?php esc_html_e('Set-up', 'invoicing'); ?></a>
55 55
                     </div>
56 56
                     <div class="mt-4 getpaid-setup-paypal-input d-none">
57
-                        <input type="text" placeholder="<?php esc_attr_e( 'PayPal Email', 'invoicing' ); ?>" name="paypal-email" class="form-control" value="<?php echo esc_attr( wpinv_get_option( 'paypal_email' ) ); ?>">
57
+                        <input type="text" placeholder="<?php esc_attr_e('PayPal Email', 'invoicing'); ?>" name="paypal-email" class="form-control" value="<?php echo esc_attr(wpinv_get_option('paypal_email')); ?>">
58 58
                     </div>
59 59
                 </li>
60 60
 
61 61
 				<li class="list-group-item d-flex justify-content-between align-items-center">
62
-					<span class="<?php echo( $aui_bs5 ? 'me-auto' : 'mr-auto' ); ?>"><?php esc_html_e( 'Test Gateway', 'invoicing' ); ?></span>
63
-					<div class="<?php echo ( $aui_bs5 ? 'form-check form-switch' : 'custom-control custom-switch' ); ?>">
64
-						<input type="checkbox" name="enable-manual-gateway" id="enable-manual-gateway" value="1" class="<?php echo ( $aui_bs5 ? 'form-check-input' : 'custom-control-input' ); ?>" <?php checked( wpinv_is_gateway_active( 'manual' ) ); ?>>
65
-						<label class="<?php echo ( $aui_bs5 ? 'form-check-label' : 'custom-control-label' ); ?>" for="enable-manual-gateway"></label>
62
+					<span class="<?php echo($aui_bs5 ? 'me-auto' : 'mr-auto'); ?>"><?php esc_html_e('Test Gateway', 'invoicing'); ?></span>
63
+					<div class="<?php echo ($aui_bs5 ? 'form-check form-switch' : 'custom-control custom-switch'); ?>">
64
+						<input type="checkbox" name="enable-manual-gateway" id="enable-manual-gateway" value="1" class="<?php echo ($aui_bs5 ? 'form-check-input' : 'custom-control-input'); ?>" <?php checked(wpinv_is_gateway_active('manual')); ?>>
65
+						<label class="<?php echo ($aui_bs5 ? 'form-check-label' : 'custom-control-label'); ?>" for="enable-manual-gateway"></label>
66 66
 					</div>
67 67
 				</li>
68 68
 			</ul>
69 69
         </div>
70 70
 
71 71
         <p class="gp-setup-actions step text-center mt-4">
72
-			<input type="submit" class="btn btn-primary" value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" />
72
+			<input type="submit" class="btn btn-primary" value="<?php esc_attr_e('Continue', 'invoicing'); ?>" />
73 73
 		</p>
74 74
         
75
-        <?php getpaid_hidden_field( 'save_step', 1 ); ?>
76
-        <?php wp_nonce_field( 'getpaid-setup-wizard', 'getpaid-setup-wizard' ); ?>
75
+        <?php getpaid_hidden_field('save_step', 1); ?>
76
+        <?php wp_nonce_field('getpaid-setup-wizard', 'getpaid-setup-wizard'); ?>
77 77
     </form>
78 78
 </div>
Please login to merge, or discard this patch.
includes/admin/views/wizard-settings.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -4,14 +4,14 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 global $aui_bs5;
10 10
 ?>
11 11
 <div class="card shadow-sm my-5">
12
-    <form method="post" class="<?php echo( $aui_bs5 ? 'text-start' : 'text-left' ); ?> card-body" action="options.php">
13
-        <?php settings_fields( 'wpinv_settings' ); ?>
14
-        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $next_url ); ?>">
12
+    <form method="post" class="<?php echo($aui_bs5 ? 'text-start' : 'text-left'); ?> card-body" action="options.php">
13
+        <?php settings_fields('wpinv_settings'); ?>
14
+        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url($next_url); ?>">
15 15
 
16 16
         <table class="gp-setup-maps w-100 " cellspacing="0">
17 17
             <tbody>
@@ -19,28 +19,28 @@  discard block
 block discarded – undo
19 19
 
20 20
                     global $wp_settings_fields;
21 21
 
22
-                    if ( isset( $wp_settings_fields[ $page ][ $section ] ) ) {
23
-					$settings = $wp_settings_fields[ $page ][ $section ];
22
+                    if (isset($wp_settings_fields[$page][$section])) {
23
+					$settings = $wp_settings_fields[$page][$section];
24 24
 
25
-					foreach ( $settings as $field ) {
25
+					foreach ($settings as $field) {
26 26
 
27
-						$name      = esc_attr( $field['id'] );
28
-						$id        = sanitize_key( $name );
27
+						$name      = esc_attr($field['id']);
28
+						$id        = sanitize_key($name);
29 29
 						$class     = '';
30
-						$value     = isset( $field['args']['std'] ) ? $field['args']['std'] : '';
31
-						$value     = wpinv_clean( wpinv_get_option( $field['args']['id'], $value ) );
32
-						$help_text = isset( $field['args']['desc'] ) ? wp_kses_post( $field['args']['desc'] ) : '';
33
-						$type      = str_replace( 'wpinv_', '', str_replace( '_callback', '', $field['callback'] ) );
34
-						$label     = isset( $field['args']['name'] ) ? wp_kses_post( $field['args']['name'] ) : '';
35
-						$options   = isset( $field['args']['options'] ) ? $field['args']['options'] : array();
36
-
37
-						if ( false !== strpos( $name, 'logo' ) ) {
30
+						$value     = isset($field['args']['std']) ? $field['args']['std'] : '';
31
+						$value     = wpinv_clean(wpinv_get_option($field['args']['id'], $value));
32
+						$help_text = isset($field['args']['desc']) ? wp_kses_post($field['args']['desc']) : '';
33
+						$type      = str_replace('wpinv_', '', str_replace('_callback', '', $field['callback']));
34
+						$label     = isset($field['args']['name']) ? wp_kses_post($field['args']['name']) : '';
35
+						$options   = isset($field['args']['options']) ? $field['args']['options'] : array();
36
+
37
+						if (false !== strpos($name, 'logo')) {
38 38
 							$type = 'hidden';
39 39
                             }
40 40
 
41
-						if ( 'country_states' == $type ) {
41
+						if ('country_states' == $type) {
42 42
 
43
-							if ( 0 == count( wpinv_get_country_states( wpinv_get_default_country() ) ) ) {
43
+							if (0 == count(wpinv_get_country_states(wpinv_get_default_country()))) {
44 44
 								$type = 'text';
45 45
                                 } else {
46 46
 								$type = 'select';
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
 							$class = 'getpaid_js_field-state';
50 50
                             }
51 51
 
52
-						if ( 'wpinv_settings[default_country]' == $name ) {
52
+						if ('wpinv_settings[default_country]' == $name) {
53 53
 							$class = 'getpaid_js_field-country';
54 54
                             }
55 55
 
56
-						switch ( $type ) {
56
+						switch ($type) {
57 57
 
58 58
 							case 'hidden':
59
-								echo "<input type='hidden' id='" . esc_attr( $id ) . "' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' />";
59
+								echo "<input type='hidden' id='" . esc_attr($id) . "' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' />";
60 60
 								break;
61 61
 							case 'text':
62 62
                             case 'number':
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 								'type'        => $type,
66 66
 								'id'          => $id,
67 67
 								'name'        => $name,
68
-								'value'       => is_scalar( $value ) ? esc_attr( $value ) : '',
68
+								'value'       => is_scalar($value) ? esc_attr($value) : '',
69 69
 								'required'    => false,
70 70
 								'help_text'   => $help_text,
71 71
 								'label'       => $label,
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 									array(
82 82
 										'id'          => $id,
83 83
 										'name'        => $name,
84
-										'value'       => is_scalar( $value ) ? esc_textarea( $value ) : '',
84
+										'value'       => is_scalar($value) ? esc_textarea($value) : '',
85 85
 										'required'    => false,
86 86
 										'help_text'   => $help_text,
87 87
 										'label'       => $label,
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 										'id'          => $id,
101 101
 										'name'        => $name,
102 102
 										'placeholder' => '',
103
-										'value'       => is_scalar( $value ) ? esc_attr( $value ) : '',
103
+										'value'       => is_scalar($value) ? esc_attr($value) : '',
104 104
 										'required'    => false,
105 105
 										'help_text'   => $help_text,
106 106
 										'label'       => $label,
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 				<input
127 127
                     type="submit"
128 128
                     class="btn btn-primary button-next"
129
-				    value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/>
129
+				    value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/>
130 130
 			</p>
131 131
         </table>
132 132
     </form>
Please login to merge, or discard this patch.
includes/admin/views/wizard-plugins.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,31 +4,31 @@
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 global $aui_bs5;
10 10
 ?>
11 11
 <div class="card shadow-sm my-5">
12
-	<form method="post" class="text-center card-body" action="<?php echo esc_url( admin_url() ); ?>">
13
-		<?php getpaid_hidden_field( 'getpaid-admin-action', 'install_plugin' ); ?>
14
-		<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
15
-		<?php getpaid_hidden_field( 'redirect', $next_url ); ?>
12
+	<form method="post" class="text-center card-body" action="<?php echo esc_url(admin_url()); ?>">
13
+		<?php getpaid_hidden_field('getpaid-admin-action', 'install_plugin'); ?>
14
+		<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
15
+		<?php getpaid_hidden_field('redirect', $next_url); ?>
16 16
 		<div class="gd-wizard-recommend">
17
-			<h2 class="gd-settings-title h3"><?php esc_html_e( 'Recommended Plugins', 'invoicing' ); ?></h2>
18
-			<p><?php esc_html_e( 'Below are a few of our own plugins that may help you.', 'invoicing' ); ?></p>
17
+			<h2 class="gd-settings-title h3"><?php esc_html_e('Recommended Plugins', 'invoicing'); ?></h2>
18
+			<p><?php esc_html_e('Below are a few of our own plugins that may help you.', 'invoicing'); ?></p>
19 19
 			<ul class="list-group">
20
-				<?php foreach ( $recommended_plugins as $key => $plugin ) : ?>
21
-				<li class="list-group-item d-flex justify-content-between align-items-center flex-wrap <?php echo( $aui_bs5 ? 'text-start' : 'text-left' ); ?>">
22
-					<span class="mr-auto"><?php echo esc_html( $plugin['name'] ); ?></span>
23
-					<div class="<?php echo( $aui_bs5 ? 'form-check form-switch me-n2' : 'custom-control custom-switch mr-n2 getpaid-install-plugin-siwtch-div' ); ?>">
24
-						<input type="checkbox" name="plugins[<?php echo esc_attr( $plugin['slug'] ); ?>]" value="<?php echo esc_attr( $plugin['file'] ); ?>" class="<?php echo ( $aui_bs5 ? 'form-check-input' : 'custom-control-input' ); ?>" <?php if ( is_plugin_active( $plugin['file'] ) ) { echo 'checked';}?> id="ac-setting-updates<?php echo esc_attr( $key ); ?>">
25
-						<label class="<?php echo ( $aui_bs5 ? 'form-check-label' : 'custom-control-label' ); ?>" for="ac-setting-updates<?php echo esc_attr( $key ); ?>"></label>
20
+				<?php foreach ($recommended_plugins as $key => $plugin) : ?>
21
+				<li class="list-group-item d-flex justify-content-between align-items-center flex-wrap <?php echo($aui_bs5 ? 'text-start' : 'text-left'); ?>">
22
+					<span class="mr-auto"><?php echo esc_html($plugin['name']); ?></span>
23
+					<div class="<?php echo($aui_bs5 ? 'form-check form-switch me-n2' : 'custom-control custom-switch mr-n2 getpaid-install-plugin-siwtch-div'); ?>">
24
+						<input type="checkbox" name="plugins[<?php echo esc_attr($plugin['slug']); ?>]" value="<?php echo esc_attr($plugin['file']); ?>" class="<?php echo ($aui_bs5 ? 'form-check-input' : 'custom-control-input'); ?>" <?php if (is_plugin_active($plugin['file'])) { echo 'checked'; }?> id="ac-setting-updates<?php echo esc_attr($key); ?>">
25
+						<label class="<?php echo ($aui_bs5 ? 'form-check-label' : 'custom-control-label'); ?>" for="ac-setting-updates<?php echo esc_attr($key); ?>"></label>
26 26
 					</div>
27
-					<small class="w-100"><?php echo esc_attr( $plugin['desc'] ); ?></small>
27
+					<small class="w-100"><?php echo esc_attr($plugin['desc']); ?></small>
28 28
 				</li>
29 29
 				<?php endforeach; ?>
30 30
 			</ul>
31
-			<p class="gp-setup-actions step text-center mt-4"><input type="submit" class="btn btn-primary button-next" value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/></p>
31
+			<p class="gp-setup-actions step text-center mt-4"><input type="submit" class="btn btn-primary button-next" value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/></p>
32 32
 		</div>
33 33
 	</form>
34 34
 </div>
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-api.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Exit if accessed directly.
4
-defined( 'ABSPATH' ) || exit;
4
+defined('ABSPATH') || exit;
5 5
 
6 6
 /**
7 7
  * PayPal API handler.
@@ -15,43 +15,43 @@  discard block
 block discarded – undo
15 15
 	 *
16 16
      * @return string|\WP_Error
17 17
 	 */
18
-	public static function get_token( $mode = 'live' ) {
18
+	public static function get_token($mode = 'live') {
19 19
 
20
-		$token = get_transient( 'getpaid_paypal_' . $mode . '_token' );
20
+		$token = get_transient('getpaid_paypal_' . $mode . '_token');
21 21
 
22
-		if ( $token ) {
22
+		if ($token) {
23 23
 			return $token;
24 24
 		}
25 25
 
26
-		$client_id  = 'live' === $mode ? wpinv_get_option( 'paypal_client_id' ) : wpinv_get_option( 'paypal_sandbox_client_id' );
27
-		$secret_key = 'live' === $mode ? wpinv_get_option( 'paypal_secret' ) : wpinv_get_option( 'paypal_sandbox_secret' );
28
-		$url        = self::get_api_url( 'v1/oauth2/token?grant_type=client_credentials', $mode );
26
+		$client_id  = 'live' === $mode ? wpinv_get_option('paypal_client_id') : wpinv_get_option('paypal_sandbox_client_id');
27
+		$secret_key = 'live' === $mode ? wpinv_get_option('paypal_secret') : wpinv_get_option('paypal_sandbox_secret');
28
+		$url        = self::get_api_url('v1/oauth2/token?grant_type=client_credentials', $mode);
29 29
 
30
-        if ( empty( $client_id ) || empty( $secret_key ) ) {
31
-            return new \WP_Error( 'invalid_request', 'Missing client id or secret key.', array( 'status' => 400 ) );
30
+        if (empty($client_id) || empty($secret_key)) {
31
+            return new \WP_Error('invalid_request', 'Missing client id or secret key.', array('status' => 400));
32 32
         }
33 33
 
34
-		$args   = array(
34
+		$args = array(
35 35
 			'method'  => 'POST',
36 36
 			'timeout' => 30,
37 37
 			'headers' => array(
38
-				'Authorization' => 'Basic ' . base64_encode( $client_id . ':' . $secret_key ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
38
+				'Authorization' => 'Basic ' . base64_encode($client_id . ':' . $secret_key), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
39 39
 				'Accept'        => 'application/json',
40 40
 				'Content-Type'  => 'application/x-www-form-urlencoded',
41 41
 			),
42 42
 		);
43 43
 
44
-		$response = self::response_or_error( wp_remote_post( $url, $args ) );
44
+		$response = self::response_or_error(wp_remote_post($url, $args));
45 45
 
46
-		if ( is_wp_error( $response ) ) {
46
+		if (is_wp_error($response)) {
47 47
 			return $response;
48 48
 		}
49 49
 
50
-		if ( ! isset( $response->access_token ) ) {
51
-			return new \WP_Error( 'invalid_request', 'Could not create token.', array( 'status' => 400 ) );
50
+		if (!isset($response->access_token)) {
51
+			return new \WP_Error('invalid_request', 'Could not create token.', array('status' => 400));
52 52
 		}
53 53
 
54
-		set_transient( 'getpaid_paypal_' . $mode . '_token', $response->access_token, $response->expires_in - 600 );
54
+		set_transient('getpaid_paypal_' . $mode . '_token', $response->access_token, $response->expires_in - 600);
55 55
 		return $response->access_token;
56 56
 	}
57 57
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 * @param string $endpoint
62 62
 	 * @return string
63 63
 	 */
64
-	public static function get_api_url( $endpoint = '', $mode = 'live'  ) {
65
-		$endpoint = ltrim( $endpoint, '/' );
64
+	public static function get_api_url($endpoint = '', $mode = 'live') {
65
+		$endpoint = ltrim($endpoint, '/');
66 66
 		return 'live' === $mode ? 'https://api-m.paypal.com/' . $endpoint : 'https://api-m.sandbox.paypal.com/' . $endpoint;
67 67
 	}
68 68
 
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return true|\WP_Error
77 77
 	 */
78
-	public static function post( $path, $data, $mode = 'live', $method = 'POST' ) {
78
+	public static function post($path, $data, $mode = 'live', $method = 'POST') {
79 79
 
80
-		$access_token = self::get_token( $mode );
80
+		$access_token = self::get_token($mode);
81 81
 
82
-		if ( is_wp_error( $access_token ) ) {
82
+		if (is_wp_error($access_token)) {
83 83
 			return $access_token;
84 84
 		}
85 85
 
86
-		$url  = self::get_api_url( $path, $mode );
86
+		$url  = self::get_api_url($path, $mode);
87 87
 		$args = array(
88 88
 			'method'  => $method,
89 89
 			'headers' => array(
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 			),
93 93
 		);
94 94
 
95
-		if( ! empty( $data )) {
96
-			$args['body'] = wp_json_encode( $data );
95
+		if (!empty($data)) {
96
+			$args['body'] = wp_json_encode($data);
97 97
 		}
98 98
 
99
-		return self::response_or_error( wp_remote_post( $url, $args ) );
99
+		return self::response_or_error(wp_remote_post($url, $args));
100 100
 	}
101 101
 
102 102
 	/**
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
 	 * @param string $method
107 107
 	 * @return object|\WP_Error
108 108
 	 */
109
-	public static function get( $path, $mode = 'live', $method = 'GET' ) {
109
+	public static function get($path, $mode = 'live', $method = 'GET') {
110 110
 
111
-		$access_token = self::get_token( $mode );
111
+		$access_token = self::get_token($mode);
112 112
 
113
-		if ( is_wp_error( $access_token ) ) {
113
+		if (is_wp_error($access_token)) {
114 114
 			return $access_token;
115 115
 		}
116 116
 
117
-		$url  = self::get_api_url( $path, $mode );
117
+		$url  = self::get_api_url($path, $mode);
118 118
 		$args = array(
119 119
 			'method'  => $method,
120 120
 			'headers' => array(
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			),
123 123
 		);
124 124
 
125
-		return self::response_or_error( wp_remote_get( $url, $args ) );
125
+		return self::response_or_error(wp_remote_get($url, $args));
126 126
 	}
127 127
 
128 128
 	/**
@@ -133,33 +133,33 @@  discard block
 block discarded – undo
133 133
 	 * @param \WP_Error|array $response
134 134
 	 * @return \WP_Error|object
135 135
 	 */
136
-	public static function response_or_error( $response ) {
136
+	public static function response_or_error($response) {
137 137
 
138
-		if ( is_wp_error( $response ) ) {
139
-			return new \WP_Error( 'paypal_error', __( 'There was a problem connecting to the PayPal API endpoint.', 'invoicing' ) );
138
+		if (is_wp_error($response)) {
139
+			return new \WP_Error('paypal_error', __('There was a problem connecting to the PayPal API endpoint.', 'invoicing'));
140 140
 		}
141 141
 
142
-		if ( empty( $response['body'] ) ) {
142
+		if (empty($response['body'])) {
143 143
 			return true;
144 144
 		}
145 145
 
146
-		$response_body = json_decode( wp_remote_retrieve_body( $response ) );
146
+		$response_body = json_decode(wp_remote_retrieve_body($response));
147 147
 
148
-		if ( wp_remote_retrieve_response_code( $response ) > 299 ) {
148
+		if (wp_remote_retrieve_response_code($response) > 299) {
149 149
 
150 150
 			// Normal errors.
151
-			if ( $response_body && isset( $response_body->message ) ) {
151
+			if ($response_body && isset($response_body->message)) {
152 152
 				$error_message = $response_body->message;
153 153
 
154 154
 			// Identity errors.
155
-			} elseif ( $response_body && isset( $response_body->error_description ) ) {
155
+			} elseif ($response_body && isset($response_body->error_description)) {
156 156
 				$error_message = $response_body->error_description;
157
-				return new \WP_Error( 'paypal_error', wp_kses_post( $response_body->error_description ) );
157
+				return new \WP_Error('paypal_error', wp_kses_post($response_body->error_description));
158 158
 			} else {
159
-				$error_message = __( 'There was an error connecting to the PayPal API endpoint.', 'invoicing' );
159
+				$error_message = __('There was an error connecting to the PayPal API endpoint.', 'invoicing');
160 160
 			}
161 161
 
162
-			return new \WP_Error( 'paypal_error', $error_message );
162
+			return new \WP_Error('paypal_error', $error_message);
163 163
 		}
164 164
 
165 165
 		return $response_body;
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 * @link https://developer.paypal.com/docs/api/orders/v2/#orders_get
175 175
 	 * @return \WP_Error|object
176 176
 	 */
177
-	public static function get_order( $order_id, $mode = 'live' ) {
178
-		return self::get( '/v2/checkout/orders/' . $order_id, $mode );
177
+	public static function get_order($order_id, $mode = 'live') {
178
+		return self::get('/v2/checkout/orders/' . $order_id, $mode);
179 179
 	}
180 180
 
181 181
 	/**
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 	 * @link https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_get
188 188
 	 * @return \WP_Error|object
189 189
 	 */
190
-	public static function get_subscription( $subscription_id, $mode = 'live' ) {
191
-		return self::get( '/v1/billing/subscriptions/' . $subscription_id, $mode );
190
+	public static function get_subscription($subscription_id, $mode = 'live') {
191
+		return self::get('/v1/billing/subscriptions/' . $subscription_id, $mode);
192 192
 	}
193 193
 
194 194
 	/**
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
 	 * @link https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_transactions
201 201
 	 * @return \WP_Error|object
202 202
 	 */
203
-	public static function get_subscription_transaction( $subscription_id, $mode = 'live' ) {
204
-		$start_time = gmdate( 'Y-m-d\TH:i:s\Z', strtotime( '-1 day' ) );
205
-		$end_time   = gmdate( 'Y-m-d\TH:i:s\Z' );
206
-		return self::get( "/v1/billing/subscriptions/$subscription_id/transactions?start_time=$start_time&end_time=$end_time", $mode );
203
+	public static function get_subscription_transaction($subscription_id, $mode = 'live') {
204
+		$start_time = gmdate('Y-m-d\TH:i:s\Z', strtotime('-1 day'));
205
+		$end_time   = gmdate('Y-m-d\TH:i:s\Z');
206
+		return self::get("/v1/billing/subscriptions/$subscription_id/transactions?start_time=$start_time&end_time=$end_time", $mode);
207 207
 	}
208 208
 
209 209
 	/**
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
 	 * @link https://developer.paypal.com/docs/api/payments/v2/#captures_refund
217 217
 	 * @return \WP_Error|object
218 218
 	 */
219
-	public static function refund_capture( $capture_id, $args = array(), $mode = 'live' ) {
220
-		return self::post( '/v2/payments/captures/' . $capture_id . '/refund', $args, $mode );
219
+	public static function refund_capture($capture_id, $args = array(), $mode = 'live') {
220
+		return self::post('/v2/payments/captures/' . $capture_id . '/refund', $args, $mode);
221 221
 	}
222 222
 
223 223
 	/**
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 * @link https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_cancel
231 231
 	 * @return \WP_Error|object
232 232
 	 */
233
-	public static function cancel_subscription( $subscription_id, $args = array(), $mode = 'live' ) {
234
-		return self::post( '/v1/billing/subscriptions/' . $subscription_id . '/cancel', $args, $mode );
233
+	public static function cancel_subscription($subscription_id, $args = array(), $mode = 'live') {
234
+		return self::post('/v1/billing/subscriptions/' . $subscription_id . '/cancel', $args, $mode);
235 235
 	}
236 236
 }
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway.php 1 patch
Spacing   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Paypal Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group', 'refunds' );
27
+    protected $supports = array('subscription', 'sandbox', 'single_subscription_group', 'refunds');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @var array
61 61
 	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
62
+	public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR');
63 63
 
64 64
     /**
65 65
 	 * URL to view a transaction.
@@ -81,22 +81,22 @@  discard block
 block discarded – undo
81 81
 	public function __construct() {
82 82
 		parent::__construct();
83 83
 
84
-        $this->title                = __( 'PayPal Standard', 'invoicing' );
85
-        $this->method_title         = __( 'PayPal Standard', 'invoicing' );
86
-        $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' );
87
-        $this->notify_url           = wpinv_get_ipn_url( $this->id );
88
-
89
-		add_filter( 'wpinv_subscription_cancel_url', array( $this, 'filter_cancel_subscription_url' ), 10, 2 );
90
-		add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
91
-		add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
92
-		add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
93
-		add_action( 'wpinv_paypal_connect', array( $this, 'display_connect_buttons' ) );
94
-
95
-		if ( $this->enabled ) {
96
-			add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
97
-			add_action( 'getpaid_paypal_subscription_cancelled', array( $this, 'subscription_cancelled' ) );
98
-			add_action( 'getpaid_delete_subscription', array( $this, 'subscription_cancelled' ) );
99
-			add_action( 'getpaid_refund_invoice_remotely', array( $this, 'refund_invoice' ) );
84
+        $this->title                = __('PayPal Standard', 'invoicing');
85
+        $this->method_title         = __('PayPal Standard', 'invoicing');
86
+        $this->checkout_button_text = __('Proceed to PayPal', 'invoicing');
87
+        $this->notify_url           = wpinv_get_ipn_url($this->id);
88
+
89
+		add_filter('wpinv_subscription_cancel_url', array($this, 'filter_cancel_subscription_url'), 10, 2);
90
+		add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2);
91
+		add_filter('getpaid_get_paypal_connect_url', array($this, 'maybe_get_connect_url'), 10, 2);
92
+		add_action('getpaid_authenticated_admin_action_connect_paypal', array($this, 'connect_paypal'));
93
+		add_action('wpinv_paypal_connect', array($this, 'display_connect_buttons'));
94
+
95
+		if ($this->enabled) {
96
+			add_filter('getpaid_paypal_sandbox_notice', array($this, 'sandbox_notice'));
97
+			add_action('getpaid_paypal_subscription_cancelled', array($this, 'subscription_cancelled'));
98
+			add_action('getpaid_delete_subscription', array($this, 'subscription_cancelled'));
99
+			add_action('getpaid_refund_invoice_remotely', array($this, 'refund_invoice'));
100 100
 		}
101 101
     }
102 102
 
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
110 110
 	 * @return array
111 111
 	 */
112
-	public function process_payment( $invoice, $submission_data, $submission ) {
112
+	public function process_payment($invoice, $submission_data, $submission) {
113 113
 
114 114
         // Get redirect url.
115
-        $paypal_redirect = $this->get_request_url( $invoice );
115
+        $paypal_redirect = $this->get_request_url($invoice);
116 116
 
117 117
         // Add a note about the request url.
118 118
         $invoice->add_note(
119 119
             sprintf(
120
-                __( 'Redirecting to PayPal: %s', 'invoicing' ),
121
-                esc_url( $paypal_redirect )
120
+                __('Redirecting to PayPal: %s', 'invoicing'),
121
+                esc_url($paypal_redirect)
122 122
             ),
123 123
             false,
124 124
             false,
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         );
127 127
 
128 128
         // Redirect to PayPal
129
-        wp_redirect( $paypal_redirect );
129
+        wp_redirect($paypal_redirect);
130 130
         exit;
131 131
 
132 132
     }
@@ -137,21 +137,21 @@  discard block
 block discarded – undo
137 137
 	 * @param  WPInv_Invoice $invoice Invoice object.
138 138
 	 * @return string
139 139
 	 */
140
-	public function get_request_url( $invoice ) {
140
+	public function get_request_url($invoice) {
141 141
 
142 142
         // Endpoint for this request
143
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
143
+		$this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
144 144
 
145 145
         // Retrieve paypal args.
146
-        $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
146
+        $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode');
147 147
 
148
-        if ( $invoice->is_recurring() ) {
148
+        if ($invoice->is_recurring()) {
149 149
             $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US';
150 150
         } else {
151 151
             $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US';
152 152
         }
153 153
 
154
-        return add_query_arg( $paypal_args, $this->endpoint );
154
+        return add_query_arg($paypal_args, $this->endpoint);
155 155
 
156 156
 	}
157 157
 
@@ -161,25 +161,25 @@  discard block
 block discarded – undo
161 161
 	 * @param  WPInv_Invoice $invoice Invoice object.
162 162
 	 * @return array
163 163
 	 */
164
-	protected function get_paypal_args( $invoice ) {
164
+	protected function get_paypal_args($invoice) {
165 165
 
166 166
         // Whether or not to send the line items as one item.
167
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
167
+		$force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', true, $invoice);
168 168
 
169
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
169
+		if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) {
170 170
 			$force_one_line_item = true;
171 171
 		}
172 172
 
173 173
 		$paypal_args = apply_filters(
174 174
 			'getpaid_paypal_args',
175 175
 			array_merge(
176
-				$this->get_transaction_args( $invoice ),
177
-				$this->get_line_item_args( $invoice, $force_one_line_item )
176
+				$this->get_transaction_args($invoice),
177
+				$this->get_line_item_args($invoice, $force_one_line_item)
178 178
 			),
179 179
 			$invoice
180 180
 		);
181 181
 
182
-		return $this->fix_request_length( $invoice, $paypal_args );
182
+		return $this->fix_request_length($invoice, $paypal_args);
183 183
     }
184 184
 
185 185
     /**
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 	 * @param WPInv_Invoice $invoice Invoice object.
189 189
 	 * @return array
190 190
 	 */
191
-	protected function get_transaction_args( $invoice ) {
191
+	protected function get_transaction_args($invoice) {
192 192
 
193
-		$email = $this->is_sandbox( $invoice ) ? wpinv_get_option( 'paypal_sandbox_email', wpinv_get_option( 'paypal_email', '' ) ) : wpinv_get_option( 'paypal_email', '' );
193
+		$email = $this->is_sandbox($invoice) ? wpinv_get_option('paypal_sandbox_email', wpinv_get_option('paypal_email', '')) : wpinv_get_option('paypal_email', '');
194 194
 		return array(
195 195
             'cmd'           => '_cart',
196 196
             'business'      => $email,
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
             'rm'            => is_ssl() ? 2 : 1,
202 202
             'upload'        => 1,
203 203
             'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal
204
-            'return'        => esc_url_raw( $this->get_return_url( $invoice ) ),
205
-            'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ),
206
-            'notify_url'    => getpaid_limit_length( $this->notify_url, 255 ),
207
-            'invoice'       => getpaid_limit_length( $invoice->get_number(), 127 ),
204
+            'return'        => esc_url_raw($this->get_return_url($invoice)),
205
+            'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()),
206
+            'notify_url'    => getpaid_limit_length($this->notify_url, 255),
207
+            'invoice'       => getpaid_limit_length($invoice->get_number(), 127),
208 208
             'custom'        => $invoice->get_id(),
209
-            'first_name'    => getpaid_limit_length( $invoice->get_first_name(), 32 ),
210
-            'last_name'     => getpaid_limit_length( $invoice->get_last_name(), 64 ),
211
-            'country'       => getpaid_limit_length( $invoice->get_country(), 2 ),
212
-            'email'         => getpaid_limit_length( $invoice->get_email(), 127 ),
213
-            'cbt'           => get_bloginfo( 'name' ),
209
+            'first_name'    => getpaid_limit_length($invoice->get_first_name(), 32),
210
+            'last_name'     => getpaid_limit_length($invoice->get_last_name(), 64),
211
+            'country'       => getpaid_limit_length($invoice->get_country(), 2),
212
+            'email'         => getpaid_limit_length($invoice->get_email(), 127),
213
+            'cbt'           => get_bloginfo('name'),
214 214
         );
215 215
 
216 216
     }
@@ -222,30 +222,30 @@  discard block
 block discarded – undo
222 222
 	 * @param  bool     $force_one_line_item Create only one item for this invoice.
223 223
 	 * @return array
224 224
 	 */
225
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
225
+	protected function get_line_item_args($invoice, $force_one_line_item = false) {
226 226
 
227 227
         // Maybe send invoice as a single item.
228
-		if ( $force_one_line_item ) {
229
-            return $this->get_line_item_args_single_item( $invoice );
228
+		if ($force_one_line_item) {
229
+            return $this->get_line_item_args_single_item($invoice);
230 230
         }
231 231
 
232 232
         // Send each line item individually.
233 233
         $line_item_args = array();
234 234
 
235 235
         // Prepare line items.
236
-        $this->prepare_line_items( $invoice );
236
+        $this->prepare_line_items($invoice);
237 237
 
238 238
         // Add taxes to the cart
239
-        if ( wpinv_use_taxes() && $invoice->is_taxable() ) {
240
-            $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 );
239
+        if (wpinv_use_taxes() && $invoice->is_taxable()) {
240
+            $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2);
241 241
         }
242 242
 
243 243
         // Add discount.
244
-        if ( $invoice->get_total_discount() > 0 ) {
245
-            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
244
+        if ($invoice->get_total_discount() > 0) {
245
+            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2);
246 246
         }
247 247
 
248
-		return array_merge( $line_item_args, $this->get_line_items() );
248
+		return array_merge($line_item_args, $this->get_line_items());
249 249
 
250 250
     }
251 251
 
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
 	 * @param  WPInv_Invoice $invoice Invoice object.
256 256
 	 * @return array
257 257
 	 */
258
-	protected function get_line_item_args_single_item( $invoice ) {
258
+	protected function get_line_item_args_single_item($invoice) {
259 259
 		$this->delete_line_items();
260 260
 
261
-        $item_name = wp_sprintf( __( 'Invoice %s', 'invoicing' ), $invoice->get_number() );
262
-		$this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
261
+        $item_name = wp_sprintf(__('Invoice %s', 'invoicing'), $invoice->get_number());
262
+		$this->add_line_item($item_name, 1, wpinv_round_amount((float) $invoice->get_total(), 2, true), $invoice->get_id());
263 263
 
264 264
 		return $this->get_line_items();
265 265
     }
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
 	 *
284 284
 	 * @param  WPInv_Invoice $invoice Invoice object.
285 285
 	 */
286
-	protected function prepare_line_items( $invoice ) {
286
+	protected function prepare_line_items($invoice) {
287 287
 		$this->delete_line_items();
288 288
 
289 289
 		// Items.
290
-		foreach ( $invoice->get_items() as $item ) {
290
+		foreach ($invoice->get_items() as $item) {
291 291
 			$amount   = $item->get_price();
292 292
 			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
293
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
293
+			$this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id());
294 294
         }
295 295
 
296 296
         // Fees.
297
-		foreach ( $invoice->get_fees() as $fee => $data ) {
298
-            $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) );
297
+		foreach ($invoice->get_fees() as $fee => $data) {
298
+            $this->add_line_item($fee, 1, wpinv_sanitize_amount($data['initial_fee']));
299 299
         }
300 300
 
301 301
     }
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 	 * @param  float  $amount Amount.
309 309
 	 * @param  string $item_number Item number.
310 310
 	 */
311
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
312
-		$index = ( count( $this->line_items ) / 4 ) + 1;
311
+	protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') {
312
+		$index = (count($this->line_items) / 4) + 1;
313 313
 
314 314
 		/**
315 315
 		 * Prevent error "Things don't appear to be working at the moment. (https://www.sandbox.paypal.com/webapps/hermes/error)"
316 316
 		 */
317
-		$item_name = str_replace( "#", "", $item_name );
317
+		$item_name = str_replace("#", "", $item_name);
318 318
 
319 319
 		$item = apply_filters(
320 320
 			'getpaid_paypal_line_item',
321 321
 			array(
322
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
322
+				'item_name'   => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'),
323 323
 				'quantity'    => (float) $quantity,
324
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
324
+				'amount'      => wpinv_sanitize_amount((float) $amount, 2),
325 325
 				'item_number' => $item_number,
326 326
 			),
327 327
 			$item_name,
@@ -330,12 +330,12 @@  discard block
 block discarded – undo
330 330
 			$item_number
331 331
 		);
332 332
 
333
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
334
-        $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
333
+		$this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127);
334
+        $this->line_items['quantity_' . $index] = $item['quantity'];
335 335
 
336 336
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
337
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
338
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
337
+		$this->line_items['amount_' . $index]      = $item['amount'] * $item['quantity'];
338
+		$this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127);
339 339
     }
340 340
 
341 341
     /**
@@ -347,19 +347,19 @@  discard block
 block discarded – undo
347 347
 	 * @param array    $paypal_args Arguments sent to Paypal in the request.
348 348
 	 * @return array
349 349
 	 */
350
-	protected function fix_request_length( $invoice, $paypal_args ) {
350
+	protected function fix_request_length($invoice, $paypal_args) {
351 351
 		$max_paypal_length = 2083;
352
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
352
+		$query_candidate   = http_build_query($paypal_args, '', '&');
353 353
 
354
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
354
+		if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) {
355 355
 			return $paypal_args;
356 356
 		}
357 357
 
358 358
 		return apply_filters(
359 359
 			'getpaid_paypal_args',
360 360
 			array_merge(
361
-				$this->get_transaction_args( $invoice ),
362
-				$this->get_line_item_args( $invoice, true )
361
+				$this->get_transaction_args($invoice),
362
+				$this->get_line_item_args($invoice, true)
363 363
 			),
364 364
 			$invoice
365 365
 		);
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
 	 * @param  array $paypal_args PayPal args.
373 373
 	 * @param  WPInv_Invoice    $invoice Invoice object.
374 374
 	 */
375
-	public function process_subscription( $paypal_args, $invoice ) {
375
+	public function process_subscription($paypal_args, $invoice) {
376 376
 
377 377
         // Make sure this is a subscription.
378
-        if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) {
378
+        if (!$invoice->is_recurring() || !$subscription = getpaid_get_invoice_subscription($invoice)) {
379 379
             return $paypal_args;
380 380
         }
381 381
 
@@ -383,23 +383,23 @@  discard block
 block discarded – undo
383 383
         $paypal_args['cmd'] = '_xclick-subscriptions';
384 384
 
385 385
         // Subscription name.
386
-        $paypal_args['item_name'] = wp_sprintf( __( 'Invoice %s', 'invoicing' ), $invoice->get_number() );
386
+        $paypal_args['item_name'] = wp_sprintf(__('Invoice %s', 'invoicing'), $invoice->get_number());
387 387
 
388 388
         // Get subscription args.
389
-        $period                 = strtoupper( substr( $subscription->get_period(), 0, 1 ) );
389
+        $period                 = strtoupper(substr($subscription->get_period(), 0, 1));
390 390
         $interval               = (int) $subscription->get_frequency();
391 391
         $bill_times             = (int) $subscription->get_bill_times();
392
-        $initial_amount         = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 );
393
-        $recurring_amount       = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 );
394
-        $subscription_item      = $invoice->get_recurring( true );
392
+        $initial_amount         = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2);
393
+        $recurring_amount       = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2);
394
+        $subscription_item      = $invoice->get_recurring(true);
395 395
 
396 396
 		// Convert 365 days to 1 year.
397
-		if ( 'D' == $period && 365 == $interval ) {
397
+		if ('D' == $period && 365 == $interval) {
398 398
 			$period = 'Y';
399 399
 			$interval = 1;
400 400
 		}
401 401
 
402
-        if ( $subscription_item->has_free_trial() ) {
402
+        if ($subscription_item->has_free_trial()) {
403 403
 
404 404
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
405 405
 
@@ -409,28 +409,28 @@  discard block
 block discarded – undo
409 409
 			// Trial period.
410 410
 			$paypal_args['t1'] = $subscription_item->get_trial_period();
411 411
 
412
-        } elseif ( $initial_amount != $recurring_amount ) {
412
+        } elseif ($initial_amount != $recurring_amount) {
413 413
 
414 414
             // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period.
415 415
 
416
-            if ( 1 == $bill_times ) {
416
+            if (1 == $bill_times) {
417 417
                 $param_number = 3;
418 418
             } else {
419 419
                 $param_number = 1;
420 420
             }
421 421
 
422
-            $paypal_args[ 'a' . $param_number ] = $initial_amount ? $initial_amount : 0;
422
+            $paypal_args['a' . $param_number] = $initial_amount ? $initial_amount : 0;
423 423
 
424 424
             // Sign Up interval
425
-            $paypal_args[ 'p' . $param_number ] = $interval;
425
+            $paypal_args['p' . $param_number] = $interval;
426 426
 
427 427
             // Sign Up unit of duration
428
-            $paypal_args[ 't' . $param_number ] = $period;
428
+            $paypal_args['t' . $param_number] = $period;
429 429
 
430 430
         }
431 431
 
432 432
         // We have a recurring payment
433
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
433
+		if (!isset($param_number) || 1 == $param_number) {
434 434
 
435 435
 			// Subscription price
436 436
 			$paypal_args['a3'] = $recurring_amount;
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
         }
445 445
 
446 446
         // Recurring payments
447
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
447
+		if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) {
448 448
 
449 449
 			// Non-recurring payments
450 450
 			$paypal_args['src'] = 0;
@@ -453,15 +453,15 @@  discard block
 block discarded – undo
453 453
 
454 454
 			$paypal_args['src'] = 1;
455 455
 
456
-			if ( $bill_times > 0 ) {
456
+			if ($bill_times > 0) {
457 457
 
458 458
 				// An initial period is being used to charge a sign-up fee
459
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
459
+				if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) {
460 460
 					$bill_times--;
461 461
 				}
462 462
 
463 463
                 // Make sure it's not over the max of 52
464
-                $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
464
+                $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
465 465
 
466 466
 			}
467 467
         }
@@ -470,10 +470,10 @@  discard block
 block discarded – undo
470 470
         $paypal_args['rm'] = 2;
471 471
 
472 472
         // Get rid of redudant items.
473
-        foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) {
473
+        foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) {
474 474
 
475
-            if ( isset( $paypal_args[ $arg ] ) ) {
476
-                unset( $paypal_args[ $arg ] );
475
+            if (isset($paypal_args[$arg])) {
476
+                unset($paypal_args[$arg]);
477 477
             }
478 478
 		}
479 479
 
@@ -491,20 +491,20 @@  discard block
 block discarded – undo
491 491
 	 * @since 2.8.24
492 492
 	 * @param WPInv_Invoice $invoice Invoice object.
493 493
 	 */
494
-	public function refund_invoice( $invoice ) {
494
+	public function refund_invoice($invoice) {
495 495
 
496
-		if ( $invoice->get_gateway() !== $this->id ) {
496
+		if ($invoice->get_gateway() !== $this->id) {
497 497
 			return;
498 498
 		}
499 499
 
500
-		$mode	= $this->is_sandbox( $invoice ) ? 'sandbox' : 'live';
501
-		$result = GetPaid_PayPal_API::refund_capture( $invoice->get_transaction_id(), array(), $mode );
500
+		$mode = $this->is_sandbox($invoice) ? 'sandbox' : 'live';
501
+		$result = GetPaid_PayPal_API::refund_capture($invoice->get_transaction_id(), array(), $mode);
502 502
 
503
-		if ( is_wp_error( $result ) ) {
503
+		if (is_wp_error($result)) {
504 504
 			$invoice->add_system_note(
505 505
 				sprintf(
506 506
 					// translators: %s is the error message.
507
-					__( 'An error occured while trying to refund invoice #%1$s in PayPal: %2$s', 'invoicing' ),
507
+					__('An error occured while trying to refund invoice #%1$s in PayPal: %2$s', 'invoicing'),
508 508
 					$invoice->get_id(),
509 509
 					$result->get_error_message()
510 510
 				)
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 			$invoice->add_system_note(
514 514
 				sprintf(
515 515
 					// translators: %s is the refund ID.
516
-					__( 'Successfully refunded invoice #%1$s in PayPal. Refund ID: %2$s', 'invoicing' ),
516
+					__('Successfully refunded invoice #%1$s in PayPal. Refund ID: %2$s', 'invoicing'),
517 517
 					$invoice->get_id(),
518 518
 					$result->id
519 519
 				)
@@ -527,50 +527,50 @@  discard block
 block discarded – undo
527 527
 	 * @since 2.8.24
528 528
 	 * @param WPInv_Subscription $subscription Subscription object.
529 529
 	 */
530
-	public function subscription_cancelled( $subscription ) {
530
+	public function subscription_cancelled($subscription) {
531 531
 
532
-		if ( $subscription->get_gateway() != $this->id ) {
532
+		if ($subscription->get_gateway() != $this->id) {
533 533
 			return;
534 534
 		}
535 535
 
536 536
 		$invoice = $subscription->get_parent_invoice();
537 537
 
538 538
 		// Abort if the parent invoice does not exist.
539
-		if ( ! $invoice->exists() ) {
539
+		if (!$invoice->exists()) {
540 540
 			return;
541 541
 		}
542 542
 
543
-		$mode	= $this->is_sandbox( $invoice ) ? 'sandbox' : 'live';
543
+		$mode = $this->is_sandbox($invoice) ? 'sandbox' : 'live';
544 544
 		$result = GetPaid_PayPal_API::cancel_subscription( 
545 545
 			$invoice->get_remote_subscription_id(), 
546 546
 			array(
547
-				'reason' => __(' Customer requested cancellation', 'invoicing' ),
547
+				'reason' => __(' Customer requested cancellation', 'invoicing'),
548 548
 			), 
549 549
 			$mode 
550 550
 		);
551 551
 
552
-		if ( is_wp_error( $result ) ) {
552
+		if (is_wp_error($result)) {
553 553
 
554 554
 			$error = sprintf(
555 555
 				// translators: %s is the subscription ID.
556
-				__( 'An error occured while trying to cancel subscription #%s in PayPal.', 'invoicing' ),
556
+				__('An error occured while trying to cancel subscription #%s in PayPal.', 'invoicing'),
557 557
 				$subscription->get_id()
558 558
 			);
559 559
 
560
-			getpaid_admin()->show_error( $error . ' ' . $result->get_error_message() );
560
+			getpaid_admin()->show_error($error . ' ' . $result->get_error_message());
561 561
 
562
-			if ( ! is_admin() ) {
563
-				wpinv_set_error( $result->get_error_code(), $error );
562
+			if (!is_admin()) {
563
+				wpinv_set_error($result->get_error_code(), $error);
564 564
 			}
565 565
 
566 566
 			return;
567 567
 		}
568 568
 
569
-		if ( is_admin() ) {
569
+		if (is_admin()) {
570 570
 			getpaid_admin()->show_success(
571 571
 				sprintf(
572 572
 					// translators: %s is the subscription ID.
573
-					__( 'Successfully cancelled subscription #%s in PayPal.', 'invoicing' ),
573
+					__('Successfully cancelled subscription #%s in PayPal.', 'invoicing'),
574 574
 					$subscription->get_id()
575 575
 				)
576 576
 			);
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 	 * @return void
585 585
 	 */
586 586
 	public function verify_ipn() {
587
-        new GetPaid_Paypal_Gateway_IPN_Handler( $this );
587
+        new GetPaid_Paypal_Gateway_IPN_Handler($this);
588 588
     }
589 589
 
590 590
     /**
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
     public function sandbox_notice() {
594 594
 
595 595
         return sprintf(
596
-			__( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %1$sPayPal Sandbox Testing Guide%2$s for more details.', 'invoicing' ),
596
+			__('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %1$sPayPal Sandbox Testing Guide%2$s for more details.', 'invoicing'),
597 597
 			'<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
598 598
 			'</a>'
599 599
 		);
@@ -605,41 +605,41 @@  discard block
 block discarded – undo
605 605
 	 *
606 606
 	 * @param array $admin_settings
607 607
 	 */
608
-	public function admin_settings( $admin_settings ) {
608
+	public function admin_settings($admin_settings) {
609 609
 
610 610
         $currencies = sprintf(
611
-            __( 'Supported Currencies: %s', 'invoicing' ),
612
-            implode( ', ', $this->currencies )
611
+            __('Supported Currencies: %s', 'invoicing'),
612
+            implode(', ', $this->currencies)
613 613
         );
614 614
 
615 615
         $admin_settings['paypal_active']['desc'] .= " ($currencies)";
616
-        $admin_settings['paypal_desc']['std']     = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
616
+        $admin_settings['paypal_desc']['std']     = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
617 617
 
618 618
 		// Access tokens.
619
-		$live_email      = wpinv_get_option( 'paypal_email' );
620
-		$sandbox_email   = wpinv_get_option( 'paypal_sandbox_email' );
619
+		$live_email      = wpinv_get_option('paypal_email');
620
+		$sandbox_email   = wpinv_get_option('paypal_sandbox_email');
621 621
 
622 622
 		$admin_settings['paypal_connect'] = array(
623 623
 			'type' => 'hook',
624 624
 			'id'   => 'paypal_connect',
625
-			'name' => __( 'Connect to PayPal', 'invoicing' ),
625
+			'name' => __('Connect to PayPal', 'invoicing'),
626 626
 		);
627 627
 
628 628
         $admin_settings['paypal_email'] = array(
629 629
             'type'  => 'text',
630 630
 			'class' => 'live-auth-data',
631 631
             'id'    => 'paypal_email',
632
-            'name'  => __( 'Live Email Address', 'invoicing' ),
633
-            'desc'  => __( 'The email address of your PayPal account.', 'invoicing' ),
632
+            'name'  => __('Live Email Address', 'invoicing'),
633
+            'desc'  => __('The email address of your PayPal account.', 'invoicing'),
634 634
         );
635 635
 
636 636
 		$admin_settings['paypal_sandbox_email'] = array(
637 637
             'type'  => 'text',
638 638
 			'class' => 'sandbox-auth-data',
639 639
             'id'    => 'paypal_sandbox_email',
640
-            'name'  => __( 'Sandbox Email Address', 'invoicing' ),
641
-            'desc'  => __( 'The email address of your sandbox PayPal account.', 'invoicing' ),
642
-			'std'   => wpinv_get_option( 'paypal_email', '' ),
640
+            'name'  => __('Sandbox Email Address', 'invoicing'),
641
+            'desc'  => __('The email address of your sandbox PayPal account.', 'invoicing'),
642
+			'std'   => wpinv_get_option('paypal_email', ''),
643 643
         );
644 644
 
645 645
 		// Client ID and secret.
@@ -647,41 +647,41 @@  discard block
 block discarded – undo
647 647
 			'type'  => 'text',
648 648
 			'class' => 'live-auth-data',
649 649
 			'id'    => 'paypal_client_id',
650
-			'name'  => __( 'Live Client ID', 'invoicing' ),
651
-			'desc'  => __( 'The client ID of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
650
+			'name'  => __('Live Client ID', 'invoicing'),
651
+			'desc'  => __('The client ID of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'),
652 652
 		);
653 653
 
654 654
 		$admin_settings['paypal_sandbox_client_id'] = array(
655 655
 			'type'  => 'text',
656 656
 			'class' => 'sandbox-auth-data',
657 657
 			'id'    => 'paypal_sandbox_client_id',
658
-			'name'  => __( 'Sandbox Client ID', 'invoicing' ),
659
-			'desc'  => __( 'The client ID of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
660
-			'std'   => wpinv_get_option( 'paypal_client_id', '' ),
658
+			'name'  => __('Sandbox Client ID', 'invoicing'),
659
+			'desc'  => __('The client ID of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'),
660
+			'std'   => wpinv_get_option('paypal_client_id', ''),
661 661
 		);
662 662
 
663 663
 		$admin_settings['paypal_secret'] = array(
664 664
 			'type'  => 'text',
665 665
 			'class' => 'live-auth-data',
666 666
 			'id'    => 'paypal_secret',
667
-			'name'  => __( 'Live Secret', 'invoicing' ),
668
-			'desc'  => __( 'The secret of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
667
+			'name'  => __('Live Secret', 'invoicing'),
668
+			'desc'  => __('The secret of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'),
669 669
 		);
670 670
 
671 671
 		$admin_settings['paypal_sandbox_secret'] = array(
672 672
 			'type'  => 'text',
673 673
 			'class' => 'sandbox-auth-data',
674 674
 			'id'    => 'paypal_sandbox_secret',
675
-			'name'  => __( 'Sandbox Secret', 'invoicing' ),
676
-			'desc'  => __( 'The secret of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
675
+			'name'  => __('Sandbox Secret', 'invoicing'),
676
+			'desc'  => __('The secret of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'),
677 677
 		);
678 678
 
679 679
         $admin_settings['paypal_ipn_url'] = array(
680 680
             'type'     => 'ipn_url',
681 681
             'id'       => 'paypal_ipn_url',
682
-            'name'     => __( 'IPN Url', 'invoicing' ),
682
+            'name'     => __('IPN Url', 'invoicing'),
683 683
             'std'      => $this->notify_url,
684
-            'desc'     => __( "If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing' ) . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
684
+            'desc'     => __("If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing') . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
685 685
             'readonly' => true,
686 686
         );
687 687
 
@@ -694,9 +694,9 @@  discard block
 block discarded – undo
694 694
 	 * @param string $url
695 695
 	 * @param WPInv_Subscription $subscription
696 696
 	 */
697
-	public function filter_cancel_subscription_url( $url, $subscription ) {
697
+	public function filter_cancel_subscription_url($url, $subscription) {
698 698
 
699
-		if ( $this->id !== $subscription->get_gateway() ) {
699
+		if ($this->id !== $subscription->get_gateway()) {
700 700
 			return $url;
701 701
 		}
702 702
 
@@ -704,16 +704,16 @@  discard block
 block discarded – undo
704 704
 		$profile_id = $subscription->get_profile_id();
705 705
 
706 706
 		// Bail if no profile ID.
707
-		if ( empty( $profile_id ) ) {
707
+		if (empty($profile_id)) {
708 708
 			return $url;
709 709
 		}
710 710
 
711 711
 		$cancel_url = 'https://www.paypal.com/myaccount/autopay/connect/%s/cancel';
712
-		if ( $this->is_sandbox( $subscription->get_parent_payment() ) ) {
712
+		if ($this->is_sandbox($subscription->get_parent_payment())) {
713 713
 			$cancel_url = 'https://www.sandbox.paypal.com/myaccount/autopay/connect/%s/cancel';
714 714
 		}
715 715
 
716
-		return sprintf( $cancel_url, $profile_id );
716
+		return sprintf($cancel_url, $profile_id);
717 717
 	}
718 718
 
719 719
 	/**
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
      * @param array $data
724 724
      * @return string
725 725
 	 */
726
-	public static function maybe_get_connect_url( $url = '', $data = array() ) {
727
-		return self::get_connect_url( false, urldecode( $data['redirect'] ) );
726
+	public static function maybe_get_connect_url($url = '', $data = array()) {
727
+		return self::get_connect_url(false, urldecode($data['redirect']));
728 728
 	}
729 729
 
730 730
 	/**
@@ -735,25 +735,25 @@  discard block
 block discarded – undo
735 735
 	 * @param string $redirect
736 736
      * @return string
737 737
 	 */
738
-	public static function get_connect_url( $is_sandbox, $redirect = '' ) {
738
+	public static function get_connect_url($is_sandbox, $redirect = '') {
739 739
 
740 740
         $redirect_url = add_query_arg(
741 741
             array(
742 742
                 'getpaid-admin-action' => 'connect_paypal',
743 743
                 'page'                 => 'wpinv-settings',
744
-                'live_mode'            => (int) empty( $is_sandbox ),
744
+                'live_mode'            => (int) empty($is_sandbox),
745 745
                 'tab'                  => 'gateways',
746 746
                 'section'              => 'paypal',
747
-                'getpaid-nonce'        => wp_create_nonce( 'getpaid-nonce' ),
748
-				'redirect'             => urlencode( $redirect ),
747
+                'getpaid-nonce'        => wp_create_nonce('getpaid-nonce'),
748
+				'redirect'             => urlencode($redirect),
749 749
             ),
750
-            admin_url( 'admin.php' )
750
+            admin_url('admin.php')
751 751
         );
752 752
 
753 753
         return add_query_arg(
754 754
             array(
755
-                'live_mode'    => (int) empty( $is_sandbox ),
756
-                'redirect_url' => urlencode( str_replace( '&amp;', '&', $redirect_url ) ),
755
+                'live_mode'    => (int) empty($is_sandbox),
756
+                'redirect_url' => urlencode(str_replace('&amp;', '&', $redirect_url)),
757 757
             ),
758 758
             'https://ayecode.io/oauth/paypal'
759 759
         );
@@ -769,10 +769,10 @@  discard block
 block discarded – undo
769 769
 
770 770
         ?>
771 771
 			<div class="wpinv-paypal-connect-live">
772
-				<a class="button button-primary" href="<?php echo esc_url( self::get_connect_url( false ) ); ?>"><?php esc_html_e( 'Connect to PayPal', 'invoicing' ); ?></a>
772
+				<a class="button button-primary" href="<?php echo esc_url(self::get_connect_url(false)); ?>"><?php esc_html_e('Connect to PayPal', 'invoicing'); ?></a>
773 773
 			</div>
774 774
 			<div class="wpinv-paypal-connect-sandbox">
775
-				<a class="button button-primary" href="<?php echo esc_url( self::get_connect_url( true ) ); ?>"><?php esc_html_e( 'Connect to PayPal Sandbox', 'invoicing' ); ?></a>
775
+				<a class="button button-primary" href="<?php echo esc_url(self::get_connect_url(true)); ?>"><?php esc_html_e('Connect to PayPal Sandbox', 'invoicing'); ?></a>
776 776
 			</div>
777 777
 
778 778
             <script>
@@ -813,26 +813,26 @@  discard block
 block discarded – undo
813 813
 	 * @param array $data Connection data.
814 814
 	 * @return void
815 815
 	 */
816
-	public function connect_paypal( $data ) {
816
+	public function connect_paypal($data) {
817 817
 
818 818
 		$sandbox      = $this->is_sandbox();
819
-		$data         = wp_unslash( $data );
820
-		$access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
819
+		$data         = wp_unslash($data);
820
+		$access_token = empty($data['access_token']) ? '' : sanitize_text_field($data['access_token']);
821 821
 
822
-		if ( isset( $data['live_mode'] ) ) {
823
-			$sandbox = empty( $data['live_mode'] );
822
+		if (isset($data['live_mode'])) {
823
+			$sandbox = empty($data['live_mode']);
824 824
 		}
825 825
 
826
-		wpinv_update_option( 'paypal_sandbox', (int) $sandbox );
827
-		wpinv_update_option( 'paypal_active', 1 );
826
+		wpinv_update_option('paypal_sandbox', (int) $sandbox);
827
+		wpinv_update_option('paypal_active', 1);
828 828
 
829
-		if ( ! empty( $data['error_description'] ) ) {
830
-			getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
829
+		if (!empty($data['error_description'])) {
830
+			getpaid_admin()->show_error(wp_kses_post(urldecode($data['error_description'])));
831 831
 		} else {
832 832
 
833 833
 			// Retrieve the user info.
834 834
 			$user_info = wp_remote_get(
835
-				! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
835
+				!$sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
836 836
 				array(
837 837
 
838 838
 					'headers' => array(
@@ -843,33 +843,33 @@  discard block
 block discarded – undo
843 843
 				)
844 844
 			);
845 845
 
846
-			if ( is_wp_error( $user_info ) ) {
847
-				getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
846
+			if (is_wp_error($user_info)) {
847
+				getpaid_admin()->show_error(wp_kses_post($user_info->get_error_message()));
848 848
 			} else {
849 849
 
850 850
 				// Create application.
851
-				$user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
851
+				$user_info = json_decode(wp_remote_retrieve_body($user_info));
852 852
 
853
-				if ( $sandbox ) {
854
-					wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
855
-					wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
856
-					set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
857
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) );
853
+				if ($sandbox) {
854
+					wpinv_update_option('paypal_sandbox_email', sanitize_email($user_info->emails[0]->value));
855
+					wpinv_update_option('paypal_sandbox_refresh_token', sanitize_text_field(urldecode($data['refresh_token'])));
856
+					set_transient('getpaid_paypal_sandbox_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']);
857
+					getpaid_admin()->show_success(__('Successfully connected your PayPal sandbox account', 'invoicing'));
858 858
 				} else {
859
-					wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
860
-					wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
861
-					set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
862
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) );
859
+					wpinv_update_option('paypal_email', sanitize_email($user_info->emails[0]->value));
860
+					wpinv_update_option('paypal_refresh_token', sanitize_text_field(urldecode($data['refresh_token'])));
861
+					set_transient('getpaid_paypal_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']);
862
+					getpaid_admin()->show_success(__('Successfully connected your PayPal account', 'invoicing'));
863 863
 				}
864 864
 			}
865 865
 		}
866 866
 
867
-		$redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
867
+		$redirect = empty($data['redirect']) ? admin_url('admin.php?page=wpinv-settings&tab=gateways&section=paypal') : urldecode($data['redirect']);
868 868
 
869
-		if ( isset( $data['step'] ) ) {
870
-			$redirect = add_query_arg( 'step', $data['step'], $redirect );
869
+		if (isset($data['step'])) {
870
+			$redirect = add_query_arg('step', $data['step'], $redirect);
871 871
 		}
872
-		wp_redirect( $redirect );
872
+		wp_redirect($redirect);
873 873
 		exit;
874 874
 	}
875 875
 
Please login to merge, or discard this patch.
templates/payment-forms/elements/checkbox.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,24 +7,24 @@
 block discarded – undo
7 7
  * @version 2.8.24
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$label = empty( $label ) ? '' : wp_kses_post( $label );
13
-$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
12
+$label = empty($label) ? '' : wp_kses_post($label);
13
+$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label));
14 14
 
15
-if ( ! empty( $required ) ) {
15
+if (!empty($required)) {
16 16
 	$label .= "<span class='text-danger'> *</span>";
17 17
 }
18 18
 
19 19
 aui()->input(
20 20
 	array(
21 21
 		'type'      => 'checkbox',
22
-		'name'      => esc_attr( $id ),
23
-		'id'        => esc_attr( $element_id ),
24
-		'required'  => ! empty( $required ),
22
+		'name'      => esc_attr($id),
23
+		'id'        => esc_attr($element_id),
24
+		'required'  => !empty($required),
25 25
 		'label'     => $label,
26
-		'value'     => esc_attr__( 'Yes', 'invoicing' ),
27
-		'help_text' => empty( $description ) ? '' : wp_kses_post( $description ),
26
+		'value'     => esc_attr__('Yes', 'invoicing'),
27
+		'help_text' => empty($description) ? '' : wp_kses_post($description),
28 28
 		'class'     => $label_class
29 29
 	),
30 30
 	true
Please login to merge, or discard this patch.