Completed
Pull Request — master (#1412)
by Ravinder
17:25
created
includes/deprecated/deprecated-functions.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
  *
28 28
  * @return bool $ret True if guest checkout is enabled, false otherwise
29 29
  */
30
-function give_no_guest_checkout( $form_id ) {
30
+function give_no_guest_checkout($form_id) {
31 31
 
32 32
 	$backtrace = debug_backtrace();
33 33
 
34
-	_give_deprecated_function( __FUNCTION__, '1.4.1', null, $backtrace );
34
+	_give_deprecated_function(__FUNCTION__, '1.4.1', null, $backtrace);
35 35
 
36
-	$ret = get_post_meta( $form_id, '_give_logged_in_only', true );
36
+	$ret = get_post_meta($form_id, '_give_logged_in_only', true);
37 37
 
38
-	return (bool) apply_filters( 'give_no_guest_checkout', give_is_setting_enabled( $ret ) );
38
+	return (bool) apply_filters('give_no_guest_checkout', give_is_setting_enabled($ret));
39 39
 }
40 40
 
41 41
 
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
 
51 51
 	$backtrace = debug_backtrace();
52 52
 
53
-	_give_deprecated_function( __FUNCTION__, '1.8', null, $backtrace );
53
+	_give_deprecated_function(__FUNCTION__, '1.8', null, $backtrace);
54 54
 
55 55
 	$views = array(
56
-		'sales'          => esc_html__( 'Donations', 'give' ),
57
-		'gateway_errors' => esc_html__( 'Payment Errors', 'give' ),
58
-		'api_requests'   => esc_html__( 'API Requests', 'give' ),
56
+		'sales'          => esc_html__('Donations', 'give'),
57
+		'gateway_errors' => esc_html__('Payment Errors', 'give'),
58
+		'api_requests'   => esc_html__('API Requests', 'give'),
59 59
 	);
60 60
 
61
-	$views = apply_filters( 'give_log_views', $views );
61
+	$views = apply_filters('give_log_views', $views);
62 62
 
63 63
 	return $views;
64 64
 }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
includes/deprecated/deprecated-filters.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
  */
5 5
 $give_map_deprecated_filters = give_deprecated_filters();
6 6
 
7
-foreach ( $give_map_deprecated_filters as $new => $old ) {
8
-	add_filter( $new, 'give_deprecated_filter_mapping', 10, 4 );
7
+foreach ($give_map_deprecated_filters as $new => $old) {
8
+	add_filter($new, 'give_deprecated_filter_mapping', 10, 4);
9 9
 }
10 10
 
11 11
 /**
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
  *
42 42
  * @return mixed
43 43
  */
44
-function give_deprecated_filter_mapping( $data, $arg_1 = '', $arg_2 = '', $arg_3 = '' ) {
44
+function give_deprecated_filter_mapping($data, $arg_1 = '', $arg_2 = '', $arg_3 = '') {
45 45
 	$give_map_deprecated_filters = give_deprecated_filters();
46 46
 	$filter                      = current_filter();
47 47
 
48
-	if ( isset( $give_map_deprecated_filters[ $filter ] ) ) {
49
-		if ( has_filter( $give_map_deprecated_filters[ $filter ] ) ) {
50
-			$data = apply_filters( $give_map_deprecated_filters[ $filter ], $data, $arg_1, $arg_2, $arg_3 );
48
+	if (isset($give_map_deprecated_filters[$filter])) {
49
+		if (has_filter($give_map_deprecated_filters[$filter])) {
50
+			$data = apply_filters($give_map_deprecated_filters[$filter], $data, $arg_1, $arg_2, $arg_3);
51 51
 
52
-			if ( ! defined( 'DOING_AJAX' ) ) {
52
+			if ( ! defined('DOING_AJAX')) {
53 53
 				_give_deprecated_function(
54 54
 					sprintf(
55 55
 					/* translators: %s: filter name */
56
-						__( 'The %s filter' ),
57
-						$give_map_deprecated_filters[ $filter ]
56
+						__('The %s filter'),
57
+						$give_map_deprecated_filters[$filter]
58 58
 					),
59 59
 					'1.7',
60 60
 					$filter
Please login to merge, or discard this patch.
includes/gateways/functions.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
 	// Default, built-in gateways
25 25
 	$gateways = array(
26 26
 		'paypal' => array(
27
-			'admin_label'    => __( 'PayPal Standard', 'give' ),
28
-			'checkout_label' => __( 'PayPal', 'give' ),
27
+			'admin_label'    => __('PayPal Standard', 'give'),
28
+			'checkout_label' => __('PayPal', 'give'),
29 29
 		),
30 30
 		'manual' => array(
31
-			'admin_label'    => __( 'Test Donation', 'give' ),
32
-			'checkout_label' => __( 'Test Donation', 'give' )
31
+			'admin_label'    => __('Test Donation', 'give'),
32
+			'checkout_label' => __('Test Donation', 'give')
33 33
 		),
34 34
 	);
35 35
 
36
-	return apply_filters( 'give_payment_gateways', $gateways );
36
+	return apply_filters('give_payment_gateways', $gateways);
37 37
 
38 38
 }
39 39
 
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
  *
47 47
  * @return array $gateway_list All the available gateways
48 48
  */
49
-function give_get_enabled_payment_gateways( $form_id = 0 ) {
49
+function give_get_enabled_payment_gateways($form_id = 0) {
50 50
 
51 51
 	$gateways = give_get_payment_gateways();
52 52
 
53
-	$enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
53
+	$enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
54 54
 
55 55
 	$gateway_list = array();
56 56
 
57
-	foreach ( $gateways as $key => $gateway ) {
58
-		if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
59
-			$gateway_list[ $key ] = $gateway;
57
+	foreach ($gateways as $key => $gateway) {
58
+		if (isset($enabled[$key]) && $enabled[$key] == 1) {
59
+			$gateway_list[$key] = $gateway;
60 60
 		}
61 61
 	}
62 62
 
63 63
 	// Set order of payment gateway in list.
64
-	$gateway_list = give_get_ordered_payment_gateways( $gateway_list );
64
+	$gateway_list = give_get_ordered_payment_gateways($gateway_list);
65 65
 
66
-	return apply_filters( 'give_enabled_payment_gateways', $gateway_list, $form_id );
66
+	return apply_filters('give_enabled_payment_gateways', $gateway_list, $form_id);
67 67
 }
68 68
 
69 69
 /**
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
  *
76 76
  * @return boolean true if enabled, false otherwise
77 77
  */
78
-function give_is_gateway_active( $gateway ) {
78
+function give_is_gateway_active($gateway) {
79 79
 	$gateways = give_get_enabled_payment_gateways();
80 80
 
81
-	$ret = array_key_exists( $gateway, $gateways );
81
+	$ret = array_key_exists($gateway, $gateways);
82 82
 
83
-	return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways );
83
+	return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways);
84 84
 }
85 85
 
86 86
 /**
@@ -92,23 +92,23 @@  discard block
 block discarded – undo
92 92
  *
93 93
  * @return string Gateway ID
94 94
  */
95
-function give_get_default_gateway( $form_id ) {
95
+function give_get_default_gateway($form_id) {
96 96
 
97 97
 	$give_options = give_get_settings();
98
-	$default      = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal';
99
-	$form_default = get_post_meta( $form_id, '_give_default_gateway', true );
98
+	$default      = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal';
99
+	$form_default = get_post_meta($form_id, '_give_default_gateway', true);
100 100
 
101 101
 	// Single Form settings varies compared to the Global default settings.
102
-	if ( ! empty( $form_default ) &&
102
+	if ( ! empty($form_default) &&
103 103
 		 $form_id !== null &&
104 104
 		 $default !== $form_default &&
105 105
 		 $form_default !== 'global' &&
106
-		 give_is_gateway_active( $form_default )
106
+		 give_is_gateway_active($form_default)
107 107
 	) {
108 108
 		$default = $form_default;
109 109
 	}
110 110
 
111
-	return apply_filters( 'give_default_gateway', $default );
111
+	return apply_filters('give_default_gateway', $default);
112 112
 }
113 113
 
114 114
 /**
@@ -120,18 +120,18 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return string Gateway admin label
122 122
  */
123
-function give_get_gateway_admin_label( $gateway ) {
123
+function give_get_gateway_admin_label($gateway) {
124 124
 	$gateways = give_get_payment_gateways();
125
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
126
-	$payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
125
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
126
+	$payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
127 127
 
128
-	if ( $gateway == 'manual' && $payment ) {
129
-		if ( give_get_payment_amount( $payment ) == 0 ) {
130
-			$label = __( 'Test Donation', 'give' );
128
+	if ($gateway == 'manual' && $payment) {
129
+		if (give_get_payment_amount($payment) == 0) {
130
+			$label = __('Test Donation', 'give');
131 131
 		}
132 132
 	}
133 133
 
134
-	return apply_filters( 'give_gateway_admin_label', $label, $gateway );
134
+	return apply_filters('give_gateway_admin_label', $label, $gateway);
135 135
 }
136 136
 
137 137
 /**
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
  *
144 144
  * @return string Checkout label for the gateway
145 145
  */
146
-function give_get_gateway_checkout_label( $gateway ) {
146
+function give_get_gateway_checkout_label($gateway) {
147 147
 	$gateways = give_get_payment_gateways();
148
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
148
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
149 149
 
150
-	if ( $gateway == 'manual' ) {
151
-		$label = __( 'Test Donation', 'give' );
150
+	if ($gateway == 'manual') {
151
+		$label = __('Test Donation', 'give');
152 152
 	}
153 153
 
154
-	return apply_filters( 'give_gateway_checkout_label', $label, $gateway );
154
+	return apply_filters('give_gateway_checkout_label', $label, $gateway);
155 155
 }
156 156
 
157 157
 /**
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @return array Options the gateway supports
165 165
  */
166
-function give_get_gateway_supports( $gateway ) {
166
+function give_get_gateway_supports($gateway) {
167 167
 	$gateways = give_get_enabled_payment_gateways();
168
-	$supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
168
+	$supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
169 169
 
170
-	return apply_filters( 'give_gateway_supports', $supports, $gateway );
170
+	return apply_filters('give_gateway_supports', $supports, $gateway);
171 171
 }
172 172
 
173 173
 /**
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
  *
181 181
  * @return void
182 182
  */
183
-function give_send_to_gateway( $gateway, $payment_data ) {
183
+function give_send_to_gateway($gateway, $payment_data) {
184 184
 
185
-	$payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' );
185
+	$payment_data['gateway_nonce'] = wp_create_nonce('give-gateway');
186 186
 
187 187
 	/**
188 188
 	 * Fires while loading payment gateway via AJAX.
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 *
194 194
 	 * @param array $payment_data All the payment data to be sent to the gateway.
195 195
 	 */
196
-	do_action( "give_gateway_{$gateway}", $payment_data );
196
+	do_action("give_gateway_{$gateway}", $payment_data);
197 197
 }
198 198
 
199 199
 
@@ -207,34 +207,34 @@  discard block
 block discarded – undo
207 207
  *
208 208
  * @return string $enabled_gateway The slug of the gateway
209 209
  */
210
-function give_get_chosen_gateway( $form_id ) {
210
+function give_get_chosen_gateway($form_id) {
211 211
 
212
-	$request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0;
212
+	$request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0;
213 213
 
214 214
 	// Back to check if 'form-id' is present.
215
-	if ( empty( $request_form_id ) ) {
216
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0;
215
+	if (empty($request_form_id)) {
216
+		$request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0;
217 217
 	}
218 218
 
219
-	$request_payment_mode = isset( $_REQUEST['payment-mode'] ) ? $_REQUEST['payment-mode'] : '';
219
+	$request_payment_mode = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : '';
220 220
 	$chosen               = false;
221 221
 
222 222
 	// If both 'payment-mode' and 'form-id' then set for only this form.
223
-	if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) {
223
+	if ( ! empty($request_form_id) && $form_id == $request_form_id) {
224 224
 		$chosen = $request_payment_mode;
225
-	} elseif ( empty( $request_form_id ) && $request_payment_mode ) {
225
+	} elseif (empty($request_form_id) && $request_payment_mode) {
226 226
 		// If no 'form-id' but there is 'payment-mode'.
227 227
 		$chosen = $request_payment_mode;
228 228
 	}
229 229
 
230 230
 	// Get the enable gateway based of chosen var.
231
-	if ( $chosen && give_is_gateway_active( $chosen ) ) {
232
-		$enabled_gateway = urldecode( $chosen );
231
+	if ($chosen && give_is_gateway_active($chosen)) {
232
+		$enabled_gateway = urldecode($chosen);
233 233
 	} else {
234
-		$enabled_gateway = give_get_default_gateway( $form_id );
234
+		$enabled_gateway = give_get_default_gateway($form_id);
235 235
 	}
236 236
 
237
-	return apply_filters( 'give_chosen_gateway', $enabled_gateway );
237
+	return apply_filters('give_chosen_gateway', $enabled_gateway);
238 238
 
239 239
 }
240 240
 
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
  *
253 253
  * @return int ID of the new log entry
254 254
  */
255
-function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
256
-	return give_record_log( $title, $message, $parent, 'gateway_error' );
255
+function give_record_gateway_error($title = '', $message = '', $parent = 0) {
256
+	return give_record_log($title, $message, $parent, 'gateway_error');
257 257
 }
258 258
 
259 259
 /**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
  *
267 267
  * @return int
268 268
  */
269
-function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
269
+function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
270 270
 
271 271
 	$ret  = 0;
272 272
 	$args = array(
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 		'fields'      => 'ids',
279 279
 	);
280 280
 
281
-	$payments = new WP_Query( $args );
281
+	$payments = new WP_Query($args);
282 282
 
283
-	if ( $payments ) {
283
+	if ($payments) {
284 284
 		$ret = $payments->post_count;
285 285
 	}
286 286
 
@@ -297,27 +297,27 @@  discard block
 block discarded – undo
297 297
  *
298 298
  * @return array $gateways All the available gateways
299 299
  */
300
-function give_get_ordered_payment_gateways( $gateways ) {
300
+function give_get_ordered_payment_gateways($gateways) {
301 301
 
302 302
 	// Get gateways setting.
303
-	$gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
303
+	$gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
304 304
 
305 305
 	// Return from here if we do not have gateways setting.
306
-	if ( empty( $gateways_setting ) ) {
306
+	if (empty($gateways_setting)) {
307 307
 		return $gateways;
308 308
 	}
309 309
 
310 310
 	// Reverse array to order payment gateways.
311
-	$gateways_setting = array_reverse( $gateways_setting );
311
+	$gateways_setting = array_reverse($gateways_setting);
312 312
 
313 313
 	// Reorder gateways array
314
-	foreach ( $gateways_setting as $gateway_key => $value ) {
314
+	foreach ($gateways_setting as $gateway_key => $value) {
315 315
 
316
-		$new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : '';
317
-		unset( $gateways[ $gateway_key ] );
316
+		$new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : '';
317
+		unset($gateways[$gateway_key]);
318 318
 
319
-		if ( ! empty( $new_gateway_value ) ) {
320
-			$gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways );
319
+		if ( ! empty($new_gateway_value)) {
320
+			$gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways);
321 321
 		}
322 322
 	}
323 323
 
@@ -328,5 +328,5 @@  discard block
 block discarded – undo
328 328
 	 *
329 329
 	 * @param array $gateways All the available gateways
330 330
 	 */
331
-	return apply_filters( 'give_payment_gateways_order', $gateways );
331
+	return apply_filters('give_payment_gateways_order', $gateways);
332 332
 }
333 333
\ No newline at end of file
Please login to merge, or discard this patch.
includes/ajax-functions.php 1 patch
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -26,26 +26,26 @@  discard block
 block discarded – undo
26 26
 function give_test_ajax_works() {
27 27
 
28 28
 	// Check if the Airplane Mode plugin is installed
29
-	if ( class_exists( 'Airplane_Mode_Core' ) ) {
29
+	if (class_exists('Airplane_Mode_Core')) {
30 30
 
31 31
 		$airplane = Airplane_Mode_Core::getInstance();
32 32
 
33
-		if ( method_exists( $airplane, 'enabled' ) ) {
33
+		if (method_exists($airplane, 'enabled')) {
34 34
 
35
-			if ( $airplane->enabled() ) {
35
+			if ($airplane->enabled()) {
36 36
 				return true;
37 37
 			}
38 38
 		} else {
39 39
 
40
-			if ( $airplane->check_status() == 'on' ) {
40
+			if ($airplane->check_status() == 'on') {
41 41
 				return true;
42 42
 			}
43 43
 		}
44 44
 	}
45 45
 
46
-	add_filter( 'block_local_requests', '__return_false' );
46
+	add_filter('block_local_requests', '__return_false');
47 47
 
48
-	if ( get_transient( '_give_ajax_works' ) ) {
48
+	if (get_transient('_give_ajax_works')) {
49 49
 		return true;
50 50
 	}
51 51
 
@@ -57,35 +57,35 @@  discard block
 block discarded – undo
57 57
 		),
58 58
 	);
59 59
 
60
-	$ajax = wp_remote_post( give_get_ajax_url(), $params );
60
+	$ajax = wp_remote_post(give_get_ajax_url(), $params);
61 61
 
62 62
 	$works = true;
63 63
 
64
-	if ( is_wp_error( $ajax ) ) {
64
+	if (is_wp_error($ajax)) {
65 65
 
66 66
 		$works = false;
67 67
 
68 68
 	} else {
69 69
 
70
-		if ( empty( $ajax['response'] ) ) {
70
+		if (empty($ajax['response'])) {
71 71
 			$works = false;
72 72
 		}
73 73
 
74
-		if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) {
74
+		if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) {
75 75
 			$works = false;
76 76
 		}
77 77
 
78
-		if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) {
78
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
79 79
 			$works = false;
80 80
 		}
81 81
 
82
-		if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) {
82
+		if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) {
83 83
 			$works = false;
84 84
 		}
85 85
 	}
86 86
 
87
-	if ( $works ) {
88
-		set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS );
87
+	if ($works) {
88
+		set_transient('_give_ajax_works', '1', DAY_IN_SECONDS);
89 89
 	}
90 90
 
91 91
 	return $works;
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
  * @return string
101 101
  */
102 102
 function give_get_ajax_url() {
103
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
103
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
104 104
 
105 105
 	$current_url = give_get_current_page_url();
106
-	$ajax_url    = admin_url( 'admin-ajax.php', $scheme );
106
+	$ajax_url    = admin_url('admin-ajax.php', $scheme);
107 107
 
108
-	if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
109
-		$ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
108
+	if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) {
109
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
110 110
 	}
111 111
 
112
-	return apply_filters( 'give_ajax_url', $ajax_url );
112
+	return apply_filters('give_ajax_url', $ajax_url);
113 113
 }
114 114
 
115 115
 /**
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @since 1.7
127 127
 	 */
128
-	do_action( 'give_donation_form_login_fields' );
128
+	do_action('give_donation_form_login_fields');
129 129
 
130 130
 	give_die();
131 131
 }
132 132
 
133
-add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' );
133
+add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
134 134
 
135 135
 /**
136 136
  * Load Checkout Fields
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
  * @return void
141 141
  */
142 142
 function give_load_checkout_fields() {
143
-	$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : '';
143
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
144 144
 
145 145
 	ob_start();
146 146
 
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @since 1.7
151 151
 	 */
152
-	do_action( 'give_donation_form_register_login_fields', $form_id );
152
+	do_action('give_donation_form_register_login_fields', $form_id);
153 153
 
154 154
 	$fields = ob_get_clean();
155 155
 
156
-	wp_send_json( array(
157
-		'fields' => wp_json_encode( $fields ),
158
-		'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ),
159
-	) );
156
+	wp_send_json(array(
157
+		'fields' => wp_json_encode($fields),
158
+		'submit' => wp_json_encode(give_checkout_button_purchase($form_id)),
159
+	));
160 160
 }
161 161
 
162
-add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' );
163
-add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' );
162
+add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
163
+add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields');
164 164
 
165 165
 /**
166 166
  * Get Form Title via AJAX (used only in WordPress Admin)
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
  * @return void
171 171
  */
172 172
 function give_ajax_get_form_title() {
173
-	if ( isset( $_POST['form_id'] ) ) {
174
-		$title = get_the_title( $_POST['form_id'] );
175
-		if ( $title ) {
173
+	if (isset($_POST['form_id'])) {
174
+		$title = get_the_title($_POST['form_id']);
175
+		if ($title) {
176 176
 			echo $title;
177 177
 		} else {
178 178
 			echo 'fail';
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	give_die();
182 182
 }
183 183
 
184
-add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' );
185
-add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' );
184
+add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
185
+add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title');
186 186
 
187 187
 /**
188 188
  * Retrieve a states drop down
@@ -193,23 +193,23 @@  discard block
 block discarded – undo
193 193
  */
194 194
 function give_ajax_get_states_field() {
195 195
 
196
-	if ( empty( $_POST['country'] ) ) {
196
+	if (empty($_POST['country'])) {
197 197
 		$_POST['country'] = give_get_country();
198 198
 	}
199
-	$states = give_get_states( $_POST['country'] );
199
+	$states = give_get_states($_POST['country']);
200 200
 
201
-	if ( ! empty( $states ) ) {
201
+	if ( ! empty($states)) {
202 202
 
203 203
 		$args = array(
204 204
 			'name'             => $_POST['field_name'],
205 205
 			'id'               => $_POST['field_name'],
206
-			'class'            => $_POST['field_name'] . '  give-select',
207
-			'options'          => give_get_states( $_POST['country'] ),
206
+			'class'            => $_POST['field_name'].'  give-select',
207
+			'options'          => give_get_states($_POST['country']),
208 208
 			'show_option_all'  => false,
209 209
 			'show_option_none' => false,
210 210
 		);
211 211
 
212
-		$response = Give()->html->select( $args );
212
+		$response = Give()->html->select($args);
213 213
 
214 214
 	} else {
215 215
 
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	give_die();
222 222
 }
223 223
 
224
-add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' );
225
-add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' );
224
+add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
225
+add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field');
226 226
 
227 227
 /**
228 228
  * Retrieve a states drop down
@@ -234,17 +234,17 @@  discard block
 block discarded – undo
234 234
 function give_ajax_form_search() {
235 235
 	global $wpdb;
236 236
 
237
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
237
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
238 238
 	$results = array();
239
-	if ( current_user_can( 'edit_give_forms' ) ) {
240
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" );
239
+	if (current_user_can('edit_give_forms')) {
240
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
241 241
 	} else {
242
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" );
242
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50");
243 243
 	}
244 244
 
245
-	if ( $items ) {
245
+	if ($items) {
246 246
 
247
-		foreach ( $items as $item ) {
247
+		foreach ($items as $item) {
248 248
 
249 249
 			$results[] = array(
250 250
 				'id'   => $item->ID,
@@ -255,18 +255,18 @@  discard block
 block discarded – undo
255 255
 
256 256
 		$items[] = array(
257 257
 			'id'   => 0,
258
-			'name' => esc_html__( 'No forms found.', 'give' ),
258
+			'name' => esc_html__('No forms found.', 'give'),
259 259
 		);
260 260
 
261 261
 	}
262 262
 
263
-	echo json_encode( $results );
263
+	echo json_encode($results);
264 264
 
265 265
 	give_die();
266 266
 }
267 267
 
268
-add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' );
269
-add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' );
268
+add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
269
+add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search');
270 270
 
271 271
 /**
272 272
  * Search the donors database via Ajax
@@ -278,38 +278,38 @@  discard block
 block discarded – undo
278 278
 function give_ajax_donor_search() {
279 279
 	global $wpdb;
280 280
 
281
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
281
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
282 282
 	$results = array();
283
-	if ( ! current_user_can( 'view_give_reports' ) ) {
283
+	if ( ! current_user_can('view_give_reports')) {
284 284
 		$donors = array();
285 285
 	} else {
286
-		$donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" );
286
+		$donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
287 287
 	}
288 288
 
289
-	if ( $donors ) {
289
+	if ($donors) {
290 290
 
291
-		foreach ( $donors as $donor ) {
291
+		foreach ($donors as $donor) {
292 292
 
293 293
 			$results[] = array(
294 294
 				'id'   => $donor->id,
295
-				'name' => $donor->name . '(' . $donor->email . ')',
295
+				'name' => $donor->name.'('.$donor->email.')',
296 296
 			);
297 297
 		}
298 298
 	} else {
299 299
 
300 300
 		$donors[] = array(
301 301
 			'id'   => 0,
302
-			'name' => esc_html__( 'No donors found.', 'give' ),
302
+			'name' => esc_html__('No donors found.', 'give'),
303 303
 		);
304 304
 
305 305
 	}
306 306
 
307
-	echo json_encode( $results );
307
+	echo json_encode($results);
308 308
 
309 309
 	give_die();
310 310
 }
311 311
 
312
-add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' );
312
+add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
313 313
 
314 314
 
315 315
 /**
@@ -321,42 +321,42 @@  discard block
 block discarded – undo
321 321
  */
322 322
 function give_ajax_search_users() {
323 323
 
324
-	if ( current_user_can( 'manage_give_settings' ) ) {
324
+	if (current_user_can('manage_give_settings')) {
325 325
 
326
-		$search_query = trim( $_POST['user_name'] );
327
-		$exclude      = trim( $_POST['exclude'] );
326
+		$search_query = trim($_POST['user_name']);
327
+		$exclude      = trim($_POST['exclude']);
328 328
 
329 329
 		$get_users_args = array(
330 330
 			'number' => 9999,
331
-			'search' => $search_query . '*',
331
+			'search' => $search_query.'*',
332 332
 		);
333 333
 
334
-		if ( ! empty( $exclude ) ) {
335
-			$exclude_array             = explode( ',', $exclude );
334
+		if ( ! empty($exclude)) {
335
+			$exclude_array             = explode(',', $exclude);
336 336
 			$get_users_args['exclude'] = $exclude_array;
337 337
 		}
338 338
 
339
-		$get_users_args = apply_filters( 'give_search_users_args', $get_users_args );
339
+		$get_users_args = apply_filters('give_search_users_args', $get_users_args);
340 340
 
341
-		$found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query );
341
+		$found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query);
342 342
 
343 343
 		$user_list = '<ul>';
344
-		if ( $found_users ) {
345
-			foreach ( $found_users as $user ) {
346
-				$user_list .= '<li><a href="#" data-userid="' . esc_attr( $user->ID ) . '" data-login="' . esc_attr( $user->user_login ) . '">' . esc_html( $user->user_login ) . '</a></li>';
344
+		if ($found_users) {
345
+			foreach ($found_users as $user) {
346
+				$user_list .= '<li><a href="#" data-userid="'.esc_attr($user->ID).'" data-login="'.esc_attr($user->user_login).'">'.esc_html($user->user_login).'</a></li>';
347 347
 			}
348 348
 		} else {
349
-			$user_list .= '<li>' . esc_html__( 'No users found.', 'give' ) . '</li>';
349
+			$user_list .= '<li>'.esc_html__('No users found.', 'give').'</li>';
350 350
 		}
351 351
 		$user_list .= '</ul>';
352 352
 
353
-		echo json_encode( array( 'results' => $user_list ) );
353
+		echo json_encode(array('results' => $user_list));
354 354
 
355 355
 	}
356 356
 	die();
357 357
 }
358 358
 
359
-add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' );
359
+add_action('wp_ajax_give_search_users', 'give_ajax_search_users');
360 360
 
361 361
 
362 362
 /**
@@ -368,32 +368,32 @@  discard block
 block discarded – undo
368 368
  */
369 369
 function give_check_for_form_price_variations() {
370 370
 
371
-	if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
372
-		die( '-1' );
371
+	if ( ! current_user_can('edit_give_forms', get_current_user_id())) {
372
+		die('-1');
373 373
 	}
374 374
 
375
-	$form_id = intval( $_POST['form_id'] );
376
-	$form    = get_post( $form_id );
375
+	$form_id = intval($_POST['form_id']);
376
+	$form    = get_post($form_id);
377 377
 
378
-	if ( 'give_forms' != $form->post_type ) {
379
-		die( '-2' );
378
+	if ('give_forms' != $form->post_type) {
379
+		die('-2');
380 380
 	}
381 381
 
382
-	if ( give_has_variable_prices( $form_id ) ) {
383
-		$variable_prices = give_get_variable_prices( $form_id );
382
+	if (give_has_variable_prices($form_id)) {
383
+		$variable_prices = give_get_variable_prices($form_id);
384 384
 
385
-		if ( $variable_prices ) {
385
+		if ($variable_prices) {
386 386
 			$ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
387 387
 
388
-			if ( isset( $_POST['all_prices'] ) ) {
389
-				$ajax_response .= '<option value="">' . esc_html__( 'All Levels', 'give' ) . '</option>';
388
+			if (isset($_POST['all_prices'])) {
389
+				$ajax_response .= '<option value="">'.esc_html__('All Levels', 'give').'</option>';
390 390
 			}
391 391
 
392
-			foreach ( $variable_prices as $key => $price ) {
392
+			foreach ($variable_prices as $key => $price) {
393 393
 
394
-				$level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) );
394
+				$level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount']));
395 395
 
396
-				$ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>';
396
+				$ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>';
397 397
 			}
398 398
 			$ajax_response .= '</select>';
399 399
 			echo $ajax_response;
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	give_die();
404 404
 }
405 405
 
406
-add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' );
406
+add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations');
407 407
 
408 408
 
409 409
 /**
@@ -414,29 +414,29 @@  discard block
 block discarded – undo
414 414
  * @return void
415 415
  */
416 416
 function give_check_for_form_price_variations_html() {
417
-	if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) {
417
+	if ( ! current_user_can('edit_give_payments', get_current_user_id())) {
418 418
 		wp_die();
419 419
 	}
420 420
 
421
-	$form_id    = intval( $_POST['form_id'] );
422
-	$payment_id = intval( $_POST['payment_id'] );
423
-	$form       = get_post( $form_id );
421
+	$form_id    = intval($_POST['form_id']);
422
+	$payment_id = intval($_POST['payment_id']);
423
+	$form       = get_post($form_id);
424 424
 
425
-	if ( 'give_forms' != $form->post_type ) {
425
+	if ('give_forms' != $form->post_type) {
426 426
 		wp_die();
427 427
 	}
428 428
 
429
-	if ( ! give_has_variable_prices( $form_id ) ) {
430
-		esc_html_e( 'n/a', 'give' );
429
+	if ( ! give_has_variable_prices($form_id)) {
430
+		esc_html_e('n/a', 'give');
431 431
 	} else {
432 432
 		// Payment object.
433
-		$payment = new Give_Payment( $payment_id );
433
+		$payment = new Give_Payment($payment_id);
434 434
 
435 435
 
436 436
 		$prices_atts = '';
437
-		if( $variable_prices = give_get_variable_prices( $form_id ) ) {
438
-			foreach ( $variable_prices as $variable_price ) {
439
-				$prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount( $variable_price['_give_amount'] );
437
+		if ($variable_prices = give_get_variable_prices($form_id)) {
438
+			foreach ($variable_prices as $variable_price) {
439
+				$prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount']);
440 440
 			}
441 441
 		}
442 442
 
@@ -451,15 +451,15 @@  discard block
 block discarded – undo
451 451
 			'chosen'           => true,
452 452
 			'show_option_all'  => '',
453 453
 			'show_option_none' => '',
454
-			'select_atts'      => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ),
454
+			'select_atts'      => 'data-prices='.esc_attr(json_encode($prices_atts)),
455 455
 			'selected'         => $payment_meta['price_id'],
456 456
 		);
457 457
 
458 458
 		// Render variable prices select tag html.
459
-		give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
459
+		give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
460 460
 	}
461 461
 
462 462
 	give_die();
463 463
 }
464 464
 
465
-add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' );
465
+add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html');
Please login to merge, or discard this patch.
includes/install.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
  * @global     $wpdb
27 27
  * @return void
28 28
  */
29
-function give_install( $network_wide = false ) {
29
+function give_install($network_wide = false) {
30 30
 
31 31
 	global $wpdb;
32 32
 
33
-	if ( is_multisite() && $network_wide ) {
33
+	if (is_multisite() && $network_wide) {
34 34
 
35
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
35
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
36 36
 
37
-			switch_to_blog( $blog_id );
37
+			switch_to_blog($blog_id);
38 38
 			give_run_install();
39 39
 			restore_current_blog();
40 40
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 }
50 50
 
51
-register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
51
+register_activation_hook(GIVE_PLUGIN_FILE, 'give_install');
52 52
 
53 53
 /**
54 54
  * Run the Give Install process.
@@ -64,24 +64,24 @@  discard block
 block discarded – undo
64 64
 	give_setup_post_types();
65 65
 
66 66
 	// Clear the permalinks.
67
-	flush_rewrite_rules( false );
67
+	flush_rewrite_rules(false);
68 68
 
69 69
 	// Add Upgraded From Option.
70
-	$current_version = get_option( 'give_version' );
71
-	if ( $current_version ) {
72
-		update_option( 'give_version_upgraded_from', $current_version );
70
+	$current_version = get_option('give_version');
71
+	if ($current_version) {
72
+		update_option('give_version_upgraded_from', $current_version);
73 73
 	}
74 74
 
75 75
 	// Setup some default options.
76 76
 	$options = array();
77 77
 
78 78
 	// Checks if the Success Page option exists AND that the page exists.
79
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
79
+	if ( ! get_post(give_get_option('success_page'))) {
80 80
 
81 81
 		// Donation Confirmation (Success) Page
82 82
 		$success = wp_insert_post(
83 83
 			array(
84
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
84
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
85 85
 				'post_content'   => '[give_receipt]',
86 86
 				'post_status'    => 'publish',
87 87
 				'post_author'    => 1,
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 
97 97
 	// Checks if the Failure Page option exists AND that the page exists.
98
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
98
+	if ( ! get_post(give_get_option('failure_page'))) {
99 99
 
100 100
 		// Failed Donation Page
101 101
 		$failed = wp_insert_post(
102 102
 			array(
103
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
104
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
103
+				'post_title'     => esc_html__('Donation Failed', 'give'),
104
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
105 105
 				'post_status'    => 'publish',
106 106
 				'post_author'    => 1,
107 107
 				'post_type'      => 'page',
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 	}
114 114
 
115 115
 	// Checks if the History Page option exists AND that the page exists.
116
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
116
+	if ( ! get_post(give_get_option('history_page'))) {
117 117
 		// Donation History Page
118 118
 		$history = wp_insert_post(
119 119
 			array(
120
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
120
+				'post_title'     => esc_html__('Donation History', 'give'),
121 121
 				'post_content'   => '[donation_history]',
122 122
 				'post_status'    => 'publish',
123 123
 				'post_author'    => 1,
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
 	}
131 131
 
132 132
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
133
-	if ( empty( $current_version ) ) {
133
+	if (empty($current_version)) {
134 134
 
135 135
 		// General.
136 136
 		$options['base_country']       = 'US';
137 137
 		$options['test_mode']          = 'enabled';
138 138
 		$options['currency']           = 'USD';
139
-		$options['currency_position']   = 'before';
139
+		$options['currency_position'] = 'before';
140 140
 		$options['session_lifetime']   = '604800';
141 141
 		$options['email_access']       = 'disabled';
142 142
 		$options['number_decimals']    = 2;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		$options['scripts_footer']       = 'disabled';
160 160
 
161 161
 		// Paypal IPN verification.
162
-		$options['paypal_verification']       = 'enabled';
162
+		$options['paypal_verification'] = 'enabled';
163 163
 
164 164
 		// Default is manual gateway.
165 165
 		$options['gateways']['manual'] = 1;
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	}
182 182
 
183 183
 	// Populate the default values.
184
-	update_option( 'give_settings', array_merge( $give_options, $options ) );
185
-	update_option( 'give_version', GIVE_VERSION );
184
+	update_option('give_settings', array_merge($give_options, $options));
185
+	update_option('give_version', GIVE_VERSION);
186 186
 
187 187
 	// Create Give roles.
188 188
 	$roles = new Give_Roles();
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	$roles->add_caps();
191 191
 
192 192
 	$api = new Give_API();
193
-	update_option( 'give_default_api_version', 'v' . $api->get_version() );
193
+	update_option('give_default_api_version', 'v'.$api->get_version());
194 194
 
195 195
 	// Create the customers databases.
196 196
 	@Give()->customers->create_table();
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
 	Give()->session->use_php_sessions();
201 201
 
202 202
 	// Add a temporary option to note that Give pages have been created.
203
-	set_transient( '_give_installed', $options, 30 );
203
+	set_transient('_give_installed', $options, 30);
204 204
 
205
-	if ( ! $current_version ) {
205
+	if ( ! $current_version) {
206 206
 
207
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
207
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
208 208
 
209 209
 		// When new upgrade routines are added, mark them as complete on fresh install.
210 210
 		$upgrade_routines = array(
@@ -213,22 +213,22 @@  discard block
 block discarded – undo
213 213
 			'upgrade_give_offline_status'
214 214
 		);
215 215
 
216
-		foreach ( $upgrade_routines as $upgrade ) {
217
-			give_set_upgrade_complete( $upgrade );
216
+		foreach ($upgrade_routines as $upgrade) {
217
+			give_set_upgrade_complete($upgrade);
218 218
 		}
219 219
 	}
220 220
 
221 221
 	// Bail if activating from network, or bulk.
222
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
222
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
223 223
 		return;
224 224
 	}
225 225
 
226 226
 	// Add the transient to redirect.
227
-	set_transient( '_give_activation_redirect', true, 30 );
227
+	set_transient('_give_activation_redirect', true, 30);
228 228
 
229 229
 }
230 230
 
231
-register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
231
+register_activation_hook(GIVE_PLUGIN_FILE, 'give_install');
232 232
 
233 233
 /**
234 234
  * Network Activated New Site Setup.
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
  * @param  int    $site_id The Site ID.
245 245
  * @param  array  $meta    Blog Meta.
246 246
  */
247
-function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
247
+function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
248 248
 
249
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
249
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
250 250
 
251
-		switch_to_blog( $blog_id );
251
+		switch_to_blog($blog_id);
252 252
 		give_install();
253 253
 		restore_current_blog();
254 254
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
 }
258 258
 
259
-add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 );
259
+add_action('wpmu_new_blog', 'on_create_blog', 10, 6);
260 260
 
261 261
 
262 262
 /**
@@ -269,13 +269,13 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return array          The tables to drop.
271 271
  */
272
-function give_wpmu_drop_tables( $tables, $blog_id ) {
272
+function give_wpmu_drop_tables($tables, $blog_id) {
273 273
 
274
-	switch_to_blog( $blog_id );
274
+	switch_to_blog($blog_id);
275 275
 	$customers_db     = new Give_DB_Customers();
276 276
 	$customer_meta_db = new Give_DB_Customer_Meta();
277 277
 
278
-	if ( $customers_db->installed() ) {
278
+	if ($customers_db->installed()) {
279 279
 		$tables[] = $customers_db->table_name;
280 280
 		$tables[] = $customer_meta_db->table_name;
281 281
 	}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 
286 286
 }
287 287
 
288
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
288
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
289 289
 
290 290
 /**
291 291
  * Post-installation
@@ -297,16 +297,16 @@  discard block
 block discarded – undo
297 297
  */
298 298
 function give_after_install() {
299 299
 
300
-	if ( ! is_admin() ) {
300
+	if ( ! is_admin()) {
301 301
 		return;
302 302
 	}
303 303
 
304
-	$give_options     = get_transient( '_give_installed' );
305
-	$give_table_check = get_option( '_give_table_check', false );
304
+	$give_options     = get_transient('_give_installed');
305
+	$give_table_check = get_option('_give_table_check', false);
306 306
 
307
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
307
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
308 308
 
309
-		if ( ! @Give()->customer_meta->installed() ) {
309
+		if ( ! @Give()->customer_meta->installed()) {
310 310
 
311 311
 			// Create the customer meta database
312 312
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 
315 315
 		}
316 316
 
317
-		if ( ! @Give()->customers->installed() ) {
317
+		if ( ! @Give()->customers->installed()) {
318 318
 			// Create the customers database
319 319
 			// (this ensures it creates it on multisite instances where it is network activated).
320 320
 			@Give()->customers->create_table();
@@ -326,22 +326,22 @@  discard block
 block discarded – undo
326 326
 			 *
327 327
 			 * @param array $give_options Give plugin options.
328 328
 			 */
329
-			do_action( 'give_after_install', $give_options );
329
+			do_action('give_after_install', $give_options);
330 330
 		}
331 331
 
332
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
332
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
333 333
 
334 334
 	}
335 335
 
336 336
 	// Delete the transient
337
-	if ( false !== $give_options ) {
338
-		delete_transient( '_give_installed' );
337
+	if (false !== $give_options) {
338
+		delete_transient('_give_installed');
339 339
 	}
340 340
 
341 341
 
342 342
 }
343 343
 
344
-add_action( 'admin_init', 'give_after_install' );
344
+add_action('admin_init', 'give_after_install');
345 345
 
346 346
 
347 347
 /**
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
 
357 357
 	global $wp_roles;
358 358
 
359
-	if ( ! is_object( $wp_roles ) ) {
359
+	if ( ! is_object($wp_roles)) {
360 360
 		return;
361 361
 	}
362 362
 
363
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
363
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
364 364
 
365 365
 		// Create Give plugin roles
366 366
 		$roles = new Give_Roles();
@@ -371,4 +371,4 @@  discard block
 block discarded – undo
371 371
 
372 372
 }
373 373
 
374
-add_action( 'admin_init', 'give_install_roles_on_network' );
374
+add_action('admin_init', 'give_install_roles_on_network');
Please login to merge, or discard this patch.
includes/process-donation.php 1 patch
Spacing   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 1.0
32 32
 	 */
33
-	do_action( 'give_pre_process_donation' );
33
+	do_action('give_pre_process_donation');
34 34
 
35 35
 	// Validate the form $_POST data
36 36
 	$valid_data = give_purchase_form_validate_fields();
@@ -45,26 +45,26 @@  discard block
 block discarded – undo
45 45
 	 * @param bool|array $valid_data Validate fields.
46 46
 	 * @param array      $_POST      Array of variables passed via the HTTP POST.
47 47
 	 */
48
-	do_action( 'give_checkout_error_checks', $valid_data, $_POST );
48
+	do_action('give_checkout_error_checks', $valid_data, $_POST);
49 49
 
50
-	$is_ajax = isset( $_POST['give_ajax'] );
50
+	$is_ajax = isset($_POST['give_ajax']);
51 51
 
52 52
 	// Process the login form
53
-	if ( isset( $_POST['give_login_submit'] ) ) {
53
+	if (isset($_POST['give_login_submit'])) {
54 54
 		give_process_form_login();
55 55
 	}
56 56
 
57 57
 	// Validate the user
58
-	$user = give_get_purchase_form_user( $valid_data );
58
+	$user = give_get_purchase_form_user($valid_data);
59 59
 
60
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
61
-		if ( $is_ajax ) {
60
+	if (false === $valid_data || give_get_errors() || ! $user) {
61
+		if ($is_ajax) {
62 62
 			/**
63 63
 			 * Fires when AJAX sends back errors from the donation form.
64 64
 			 *
65 65
 			 * @since 1.0
66 66
 			 */
67
-			do_action( 'give_ajax_donation_errors' );
67
+			do_action('give_ajax_donation_errors');
68 68
 			give_die();
69 69
 		} else {
70 70
 			return false;
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	// If AJAX send back success to proceed with form submission
75
-	if ( $is_ajax ) {
75
+	if ($is_ajax) {
76 76
 		echo 'success';
77 77
 		give_die();
78 78
 	}
79 79
 
80 80
 	// After AJAX: Setup session if not using php_sessions
81
-	if ( ! Give()->session->use_php_sessions() ) {
81
+	if ( ! Give()->session->use_php_sessions()) {
82 82
 		// Double-check that set_cookie is publicly accessible;
83 83
 		// we're using a slightly modified class-wp-sessions.php
84
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
85
-		if ( $session_reflection->isPublic() ) {
84
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
85
+		if ($session_reflection->isPublic()) {
86 86
 			// Manually set the cookie.
87 87
 			Give()->session->init()->set_cookie();
88 88
 		}
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
 		'address'    => $user['address'],
98 98
 	);
99 99
 
100
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
100
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
101 101
 
102
-	$price        = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00';
103
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
102
+	$price        = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00';
103
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
104 104
 
105 105
 	// Setup donation information
106 106
 	$purchase_data = array(
107 107
 		'price'        => $price,
108 108
 		'purchase_key' => $purchase_key,
109 109
 		'user_email'   => $user['user_email'],
110
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
111
-		'user_info'    => stripslashes_deep( $user_info ),
110
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
111
+		'user_info'    => stripslashes_deep($user_info),
112 112
 		'post_data'    => $_POST,
113 113
 		'gateway'      => $valid_data['gateway'],
114 114
 		'card_info'    => $valid_data['cc_info'],
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 	 * @param array      $user_info  Array containing basic user information.
129 129
 	 * @param bool|array $valid_data Validate fields.
130 130
 	 */
131
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
131
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
132 132
 
133 133
 	// Sanity check for price
134
-	if ( ! $purchase_data['price'] ) {
134
+	if ( ! $purchase_data['price']) {
135 135
 		// Revert to manual
136 136
 		$purchase_data['gateway'] = 'manual';
137 137
 		$_POST['give-gateway']    = 'manual';
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @since 1.7
144 144
 	 */
145
-	$purchase_data = apply_filters( 'give_donation_data_before_gateway', $purchase_data, $valid_data );
145
+	$purchase_data = apply_filters('give_donation_data_before_gateway', $purchase_data, $valid_data);
146 146
 
147 147
 	// Setup the data we're storing in the donation session
148 148
 	$session_data = $purchase_data;
149 149
 
150 150
 	// Make sure credit card numbers are never stored in sessions
151
-	unset( $session_data['card_info']['card_number'] );
152
-	unset( $session_data['post_data']['card_number'] );
151
+	unset($session_data['card_info']['card_number']);
152
+	unset($session_data['post_data']['card_number']);
153 153
 
154 154
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
155
-	give_set_purchase_session( $session_data );
155
+	give_set_purchase_session($session_data);
156 156
 
157 157
 	// Send info to the gateway for payment processing
158
-	give_send_to_gateway( $purchase_data['gateway'], $purchase_data );
158
+	give_send_to_gateway($purchase_data['gateway'], $purchase_data);
159 159
 	give_die();
160 160
 
161 161
 }
162 162
 
163
-add_action( 'give_purchase', 'give_process_purchase_form' );
164
-add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' );
165
-add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' );
163
+add_action('give_purchase', 'give_process_purchase_form');
164
+add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form');
165
+add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form');
166 166
 
167 167
 
168 168
 /**
@@ -175,26 +175,26 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return void
177 177
  */
178
-function give_checkout_check_existing_email( $valid_data, $post ) {
178
+function give_checkout_check_existing_email($valid_data, $post) {
179 179
 
180 180
 	// Verify that the email address belongs to this customer.
181
-	if ( is_user_logged_in() ) {
181
+	if (is_user_logged_in()) {
182 182
 
183 183
 		$email    = $valid_data['logged_in_user']['user_email'];
184
-		$customer = new Give_Customer( get_current_user_id(), true );
184
+		$customer = new Give_Customer(get_current_user_id(), true);
185 185
 
186 186
 		// If this email address is not registered with this customer, see if it belongs to any other customer
187
-		if ( $email !== $customer->email && ( is_array( $customer->emails ) && ! in_array( $email, $customer->emails ) ) ) {
188
-			$found_customer = new Give_Customer( $email );
187
+		if ($email !== $customer->email && (is_array($customer->emails) && ! in_array($email, $customer->emails))) {
188
+			$found_customer = new Give_Customer($email);
189 189
 
190
-			if ( $found_customer->id > 0 ) {
191
-				give_set_error( 'give-customer-email-exists', sprintf( esc_html__( 'The email address %s is already in use.', 'give' ), $email ) );
190
+			if ($found_customer->id > 0) {
191
+				give_set_error('give-customer-email-exists', sprintf(esc_html__('The email address %s is already in use.', 'give'), $email));
192 192
 			}
193 193
 		}
194 194
 	}
195 195
 }
196 196
 
197
-add_action( 'give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2 );
197
+add_action('give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2);
198 198
 
199 199
 /**
200 200
  * Process the checkout login form
@@ -205,37 +205,37 @@  discard block
 block discarded – undo
205 205
  */
206 206
 function give_process_form_login() {
207 207
 
208
-	$is_ajax = isset( $_POST['give_ajax'] );
208
+	$is_ajax = isset($_POST['give_ajax']);
209 209
 
210 210
 	$user_data = give_purchase_form_validate_user_login();
211 211
 
212
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
213
-		if ( $is_ajax ) {
212
+	if (give_get_errors() || $user_data['user_id'] < 1) {
213
+		if ($is_ajax) {
214 214
 			/**
215 215
 			 * Fires when AJAX sends back errors from the donation form.
216 216
 			 *
217 217
 			 * @since 1.0
218 218
 			 */
219
-			do_action( 'give_ajax_donation_errors' );
219
+			do_action('give_ajax_donation_errors');
220 220
 			give_die();
221 221
 		} else {
222
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
222
+			wp_redirect($_SERVER['HTTP_REFERER']);
223 223
 			exit;
224 224
 		}
225 225
 	}
226 226
 
227
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
227
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
228 228
 
229
-	if ( $is_ajax ) {
229
+	if ($is_ajax) {
230 230
 		echo 'success';
231 231
 		give_die();
232 232
 	} else {
233
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
233
+		wp_redirect($_SERVER['HTTP_REFERER']);
234 234
 	}
235 235
 }
236 236
 
237
-add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' );
238
-add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' );
237
+add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login');
238
+add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login');
239 239
 
240 240
 /**
241 241
  * Donation Form Validate Fields
@@ -247,44 +247,44 @@  discard block
 block discarded – undo
247 247
 function give_purchase_form_validate_fields() {
248 248
 
249 249
 	// Check if there is $_POST
250
-	if ( empty( $_POST ) ) {
250
+	if (empty($_POST)) {
251 251
 		return false;
252 252
 	}
253 253
 
254
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
254
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
255 255
 
256 256
 	// Start an array to collect valid data
257 257
 	$valid_data = array(
258 258
 		'gateway'          => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here)
259
-		'need_new_user'    => false,     // New user flag
260
-		'need_user_login'  => false,     // Login user flag
261
-		'logged_user_data' => array(),   // Logged user collected data
262
-		'new_user_data'    => array(),   // New user collected data
263
-		'login_user_data'  => array(),   // Login user collected data
264
-		'guest_user_data'  => array(),   // Guest user collected data
265
-		'cc_info'          => give_purchase_form_validate_cc(),// Credit card info
259
+		'need_new_user'    => false, // New user flag
260
+		'need_user_login'  => false, // Login user flag
261
+		'logged_user_data' => array(), // Logged user collected data
262
+		'new_user_data'    => array(), // New user collected data
263
+		'login_user_data'  => array(), // Login user collected data
264
+		'guest_user_data'  => array(), // Guest user collected data
265
+		'cc_info'          => give_purchase_form_validate_cc(), // Credit card info
266 266
 	);
267 267
 
268 268
 	// Validate Honeypot First
269
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
270
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
269
+	if ( ! empty($_POST['give-honeypot'])) {
270
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
271 271
 	}
272 272
 
273 273
 	// Validate agree to terms
274
-	if ( give_is_terms_enabled( $form_id ) ) {
274
+	if (give_is_terms_enabled($form_id)) {
275 275
 		give_purchase_form_validate_agree_to_terms();
276 276
 	}
277 277
 
278
-	if ( is_user_logged_in() ) {
278
+	if (is_user_logged_in()) {
279 279
 		// Collect logged in user data
280 280
 		$valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user();
281
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
281
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
282 282
 		// Set new user registration as required
283 283
 		$valid_data['need_new_user'] = true;
284 284
 		// Validate new user data
285 285
 		$valid_data['new_user_data'] = give_purchase_form_validate_new_user();
286 286
 		// Check if login validation is needed
287
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
287
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
288 288
 		// Set user login as required
289 289
 		$valid_data['need_user_login'] = true;
290 290
 		// Validate users login info
@@ -309,41 +309,41 @@  discard block
 block discarded – undo
309 309
  */
310 310
 function give_purchase_form_validate_gateway() {
311 311
 
312
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
313
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
314
-	$gateway = give_get_default_gateway( $form_id );
312
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
313
+	$amount  = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
314
+	$gateway = give_get_default_gateway($form_id);
315 315
 
316 316
 	// Check if a gateway value is present
317
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
317
+	if ( ! empty($_REQUEST['give-gateway'])) {
318 318
 
319
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
319
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
320 320
 
321 321
 		// Is amount being donated in LIVE mode 0.00? If so, error:
322
-		if ( $amount == 0 && ! give_is_test_mode() ) {
322
+		if ($amount == 0 && ! give_is_test_mode()) {
323 323
 
324
-			give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) );
324
+			give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give'));
325 325
 
326 326
 		} //Check for a minimum custom amount
327
-		elseif ( ! give_verify_minimum_price() ) {
327
+		elseif ( ! give_verify_minimum_price()) {
328 328
 			// translators: %s: minimum donation amount.
329 329
 			give_set_error(
330 330
 				'invalid_donation_minimum',
331 331
 				sprintf(
332 332
 					/* translators: %s: minimum donation amount */
333
-					esc_html__( 'This form has a minimum donation amount of %s.', 'give' ),
334
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) )
333
+					esc_html__('This form has a minimum donation amount of %s.', 'give'),
334
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))
335 335
 				)
336 336
 			);
337 337
 
338 338
 		} //Is this test mode zero donation? Let it through but set to manual gateway.
339
-		elseif ( $amount == 0 && give_is_test_mode() ) {
339
+		elseif ($amount == 0 && give_is_test_mode()) {
340 340
 
341 341
 			$gateway = 'manual';
342 342
 
343 343
 		} //Check if this gateway is active.
344
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
344
+		elseif ( ! give_is_gateway_active($gateway)) {
345 345
 
346
-			give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) );
346
+			give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give'));
347 347
 
348 348
 		}
349 349
 	}
@@ -361,23 +361,23 @@  discard block
 block discarded – undo
361 361
  */
362 362
 function give_verify_minimum_price() {
363 363
 
364
-	$amount          = give_sanitize_amount( $_REQUEST['give-amount'] );
365
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
366
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0;
367
-	$variable_prices = give_has_variable_prices( $form_id );
364
+	$amount          = give_sanitize_amount($_REQUEST['give-amount']);
365
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
366
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0;
367
+	$variable_prices = give_has_variable_prices($form_id);
368 368
 
369
-	if ( $variable_prices && ! empty( $price_id ) ) {
369
+	if ($variable_prices && ! empty($price_id)) {
370 370
 
371
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
371
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
372 372
 
373
-		if ( $price_level_amount == $amount ) {
373
+		if ($price_level_amount == $amount) {
374 374
 			return true;
375 375
 		}
376 376
 	}
377 377
 
378
-	$minimum = give_get_form_minimum_price( $form_id );
378
+	$minimum = give_get_form_minimum_price($form_id);
379 379
 
380
-	if ( $minimum > $amount ) {
380
+	if ($minimum > $amount) {
381 381
 		return false;
382 382
 	}
383 383
 
@@ -393,9 +393,9 @@  discard block
 block discarded – undo
393 393
  */
394 394
 function give_purchase_form_validate_agree_to_terms() {
395 395
 	// Validate agree to terms.
396
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
396
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
397 397
 		// User did not agree.
398
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms and conditions.', 'give' ) ) );
398
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms and conditions.', 'give')));
399 399
 	}
400 400
 }
401 401
 
@@ -409,43 +409,43 @@  discard block
 block discarded – undo
409 409
  *
410 410
  * @return      array
411 411
  */
412
-function give_get_required_fields( $form_id ) {
412
+function give_get_required_fields($form_id) {
413 413
 
414
-	$payment_mode = give_get_chosen_gateway( $form_id );
414
+	$payment_mode = give_get_chosen_gateway($form_id);
415 415
 
416 416
 	$required_fields = array(
417 417
 		'give_email' => array(
418 418
 			'error_id'      => 'invalid_email',
419
-			'error_message' => esc_html__( 'Please enter a valid email address.', 'give' ),
419
+			'error_message' => esc_html__('Please enter a valid email address.', 'give'),
420 420
 		),
421 421
 		'give_first' => array(
422 422
 			'error_id'      => 'invalid_first_name',
423
-			'error_message' => esc_html__( 'Please enter your first name.', 'give' ),
423
+			'error_message' => esc_html__('Please enter your first name.', 'give'),
424 424
 		),
425 425
 	);
426 426
 
427
-	$require_address = give_require_billing_address( $payment_mode );
427
+	$require_address = give_require_billing_address($payment_mode);
428 428
 
429
-	if ( $require_address ) {
430
-		$required_fields['card_address']    = array(
429
+	if ($require_address) {
430
+		$required_fields['card_address'] = array(
431 431
 			'error_id'      => 'invalid_card_address',
432
-			'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' ),
432
+			'error_message' => esc_html__('Please enter your primary billing address.', 'give'),
433 433
 		);
434
-		$required_fields['card_zip']        = array(
434
+		$required_fields['card_zip'] = array(
435 435
 			'error_id'      => 'invalid_zip_code',
436
-			'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' ),
436
+			'error_message' => esc_html__('Please enter your zip / postal code.', 'give'),
437 437
 		);
438
-		$required_fields['card_city']       = array(
438
+		$required_fields['card_city'] = array(
439 439
 			'error_id'      => 'invalid_city',
440
-			'error_message' => esc_html__( 'Please enter your billing city.', 'give' ),
440
+			'error_message' => esc_html__('Please enter your billing city.', 'give'),
441 441
 		);
442 442
 		$required_fields['billing_country'] = array(
443 443
 			'error_id'      => 'invalid_country',
444
-			'error_message' => esc_html__( 'Please select your billing country.', 'give' ),
444
+			'error_message' => esc_html__('Please select your billing country.', 'give'),
445 445
 		);
446
-		$required_fields['card_state']      = array(
446
+		$required_fields['card_state'] = array(
447 447
 			'error_id'      => 'invalid_state',
448
-			'error_message' => esc_html__( 'Please enter billing state / province.', 'give' ),
448
+			'error_message' => esc_html__('Please enter billing state / province.', 'give'),
449 449
 		);
450 450
 	}
451 451
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 	 *
455 455
 	 * @since 1.7
456 456
 	 */
457
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
457
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
458 458
 
459 459
 	return $required_fields;
460 460
 
@@ -469,16 +469,16 @@  discard block
 block discarded – undo
469 469
  *
470 470
  * @return mixed|void
471 471
  */
472
-function give_require_billing_address( $payment_mode ) {
472
+function give_require_billing_address($payment_mode) {
473 473
 
474 474
 	$return = false;
475 475
 
476
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
476
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
477 477
 		$return = true;
478 478
 	}
479 479
 
480 480
 	// Let payment gateways and other extensions determine if address fields should be required.
481
-	return apply_filters( 'give_require_billing_address', $return );
481
+	return apply_filters('give_require_billing_address', $return);
482 482
 
483 483
 }
484 484
 
@@ -492,42 +492,42 @@  discard block
 block discarded – undo
492 492
 function give_purchase_form_validate_logged_in_user() {
493 493
 	global $user_ID;
494 494
 
495
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
495
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
496 496
 
497 497
 	// Start empty array to collect valid user data.
498 498
 	$valid_user_data = array(
499 499
 		// Assume there will be errors.
500
-		'user_id' => - 1,
500
+		'user_id' => -1,
501 501
 	);
502 502
 
503 503
 	// Verify there is a user_ID.
504
-	if ( $user_ID > 0 ) {
504
+	if ($user_ID > 0) {
505 505
 		// Get the logged in user data.
506
-		$user_data = get_userdata( $user_ID );
506
+		$user_data = get_userdata($user_ID);
507 507
 
508 508
 		// Loop through required fields and show error messages.
509
-		foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
510
-			if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
511
-				give_set_error( $value['error_id'], $value['error_message'] );
509
+		foreach (give_get_required_fields($form_id) as $field_name => $value) {
510
+			if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
511
+				give_set_error($value['error_id'], $value['error_message']);
512 512
 			}
513 513
 		}
514 514
 
515 515
 		// Verify data.
516
-		if ( $user_data ) {
516
+		if ($user_data) {
517 517
 			// Collected logged in user data.
518 518
 			$valid_user_data = array(
519 519
 				'user_id'    => $user_ID,
520
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
521
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
522
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
520
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
521
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
522
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
523 523
 			);
524 524
 
525
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
526
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
525
+			if ( ! is_email($valid_user_data['user_email'])) {
526
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
527 527
 			}
528 528
 		} else {
529 529
 			// Set invalid user error.
530
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
530
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
531 531
 		}
532 532
 	}
533 533
 
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 	// Default user data.
547 547
 	$default_user_data = array(
548 548
 		'give-form-id'           => '',
549
-		'user_id'                => - 1, // Assume there will be errors.
549
+		'user_id'                => -1, // Assume there will be errors.
550 550
 		'user_first'             => '',
551 551
 		'user_last'              => '',
552 552
 		'give_user_login'        => false,
@@ -556,14 +556,14 @@  discard block
 block discarded – undo
556 556
 	);
557 557
 
558 558
 	// Get user data.
559
-	$user_data = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data );
559
+	$user_data = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data);
560 560
 	$registering_new_user = false;
561
-	$form_id              = absint( $user_data['give-form-id'] );
561
+	$form_id              = absint($user_data['give-form-id']);
562 562
 
563 563
 	// Start an empty array to collect valid user data.
564 564
 	$valid_user_data = array(
565 565
 		// Assume there will be errors.
566
-		'user_id'    => - 1,
566
+		'user_id'    => -1,
567 567
 
568 568
 		// Get first name.
569 569
 		'user_first' => $user_data['give_first'],
@@ -573,25 +573,25 @@  discard block
 block discarded – undo
573 573
 	);
574 574
 
575 575
 	// Loop through required fields and show error messages.
576
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
577
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
578
-			give_set_error( $value['error_id'], $value['error_message'] );
576
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
577
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
578
+			give_set_error($value['error_id'], $value['error_message']);
579 579
 		}
580 580
 	}
581 581
 
582 582
 	// Check if we have an username to register.
583
-	if( give_validate_username( $user_data['give_user_login'] ) ) {
583
+	if (give_validate_username($user_data['give_user_login'])) {
584 584
 		$registering_new_user = true;
585 585
 		$valid_user_data['user_login'] = $user_data['give_user_login'];
586 586
 	}
587 587
 
588 588
 	// Check if we have an email to verify.
589
-	if( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
589
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
590 590
 		$valid_user_data['user_email'] = $user_data['give_email'];
591 591
 	}
592 592
 
593 593
 	// Check password.
594
-	if( give_validate_user_password( $user_data['give_user_pass'],  $user_data['give_user_pass_confirm'], $registering_new_user)){
594
+	if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) {
595 595
 		// All is good to go.
596 596
 		$valid_user_data['user_pass'] = $user_data['give_user_pass'];
597 597
 	}
@@ -611,36 +611,36 @@  discard block
 block discarded – undo
611 611
 	// Start an array to collect valid user data.
612 612
 	$valid_user_data = array(
613 613
 		// Assume there will be errors
614
-		'user_id' => - 1,
614
+		'user_id' => -1,
615 615
 	);
616 616
 
617 617
 	// Username.
618
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
619
-		give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
618
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
619
+		give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give'));
620 620
 
621 621
 		return $valid_user_data;
622 622
 	}
623 623
 
624 624
 	// Get the user by login.
625
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
625
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
626 626
 
627 627
 	// Check if user exists.
628
-	if ( $user_data ) {
628
+	if ($user_data) {
629 629
 		// Get password.
630
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
630
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
631 631
 
632 632
 		// Check user_pass.
633
-		if ( $user_pass ) {
633
+		if ($user_pass) {
634 634
 			// Check if password is valid.
635
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
635
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
636 636
 				// Incorrect password.
637 637
 				give_set_error(
638 638
 					'password_incorrect',
639 639
 					sprintf(
640 640
 						'%1$s <a href="%2$s">%3$s</a>',
641
-						esc_html__( 'The password you entered is incorrect.', 'give' ),
642
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
643
-						esc_html__( 'Reset Password', 'give' )
641
+						esc_html__('The password you entered is incorrect.', 'give'),
642
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
643
+						esc_html__('Reset Password', 'give')
644 644
 					)
645 645
 				);
646 646
 				// All is correct.
@@ -657,11 +657,11 @@  discard block
 block discarded – undo
657 657
 			}
658 658
 		} else {
659 659
 			// Empty password.
660
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
660
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
661 661
 		}
662 662
 	} else {
663 663
 		// No username.
664
-		give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) );
664
+		give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give'));
665 665
 	}
666 666
 
667 667
 	return $valid_user_data;
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
  */
677 677
 function give_purchase_form_validate_guest_user() {
678 678
 
679
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
679
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
680 680
 
681 681
 	// Start an array to collect valid user data.
682 682
 	$valid_user_data = array(
@@ -685,38 +685,38 @@  discard block
 block discarded – undo
685 685
 	);
686 686
 
687 687
 	// Show error message if user must be logged in.
688
-	if ( give_logged_in_only( $form_id ) ) {
689
-		give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) );
688
+	if (give_logged_in_only($form_id)) {
689
+		give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give'));
690 690
 	}
691 691
 
692 692
 	// Get the guest email.
693
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
693
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
694 694
 
695 695
 	// Check email.
696
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
696
+	if ($guest_email && strlen($guest_email) > 0) {
697 697
 		// Validate email.
698
-		if ( ! is_email( $guest_email ) ) {
698
+		if ( ! is_email($guest_email)) {
699 699
 			// Invalid email.
700
-			give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
700
+			give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
701 701
 		} else {
702 702
 			// All is good to go.
703 703
 			$valid_user_data['user_email'] = $guest_email;
704 704
 
705 705
 			// Get user_id from donor if exist.
706
-			$donor = new Give_Customer( $guest_email );
707
-			if ( $donor->id && $donor->user_id ) {
706
+			$donor = new Give_Customer($guest_email);
707
+			if ($donor->id && $donor->user_id) {
708 708
 				$valid_user_data['user_id'] = $donor->user_id;
709 709
 			}
710 710
 		}
711 711
 	} else {
712 712
 		// No email.
713
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
713
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
714 714
 	}
715 715
 
716 716
 	// Loop through required fields and show error messages.
717
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
718
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
719
-			give_set_error( $value['error_id'], $value['error_message'] );
717
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
718
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
719
+			give_set_error($value['error_id'], $value['error_message']);
720 720
 		}
721 721
 	}
722 722
 
@@ -732,36 +732,36 @@  discard block
 block discarded – undo
732 732
  * @since   1.0
733 733
  * @return  integer
734 734
  */
735
-function give_register_and_login_new_user( $user_data = array() ) {
735
+function give_register_and_login_new_user($user_data = array()) {
736 736
 	// Verify the array.
737
-	if ( empty( $user_data ) ) {
738
-		return - 1;
737
+	if (empty($user_data)) {
738
+		return -1;
739 739
 	}
740 740
 
741
-	if ( give_get_errors() ) {
742
-		return - 1;
741
+	if (give_get_errors()) {
742
+		return -1;
743 743
 	}
744 744
 
745
-	$user_args = apply_filters( 'give_insert_user_args', array(
746
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
747
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
748
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
749
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
750
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
751
-		'user_registered' => date( 'Y-m-d H:i:s' ),
752
-		'role'            => get_option( 'default_role' ),
753
-	), $user_data );
745
+	$user_args = apply_filters('give_insert_user_args', array(
746
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
747
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
748
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
749
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
750
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
751
+		'user_registered' => date('Y-m-d H:i:s'),
752
+		'role'            => get_option('default_role'),
753
+	), $user_data);
754 754
 
755 755
 	// Insert new user.
756
-	$user_id = wp_insert_user( $user_args );
756
+	$user_id = wp_insert_user($user_args);
757 757
 
758 758
 	// Validate inserted user.
759
-	if ( is_wp_error( $user_id ) ) {
760
-		return - 1;
759
+	if (is_wp_error($user_id)) {
760
+		return -1;
761 761
 	}
762 762
 
763 763
 	// Allow themes and plugins to filter the user data.
764
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
764
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
765 765
 
766 766
 	/**
767 767
 	 * Fires after inserting user.
@@ -771,10 +771,10 @@  discard block
 block discarded – undo
771 771
 	 * @param int   $user_id   User id.
772 772
 	 * @param array $user_data Array containing user data.
773 773
 	 */
774
-	do_action( 'give_insert_user', $user_id, $user_data );
774
+	do_action('give_insert_user', $user_id, $user_data);
775 775
 
776 776
 	// Login new user.
777
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
777
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
778 778
 
779 779
 	// Return user id.
780 780
 	return $user_id;
@@ -789,27 +789,27 @@  discard block
 block discarded – undo
789 789
  * @since   1.0
790 790
  * @return  array
791 791
  */
792
-function give_get_purchase_form_user( $valid_data = array() ) {
792
+function give_get_purchase_form_user($valid_data = array()) {
793 793
 
794 794
 	// Initialize user.
795 795
 	$user    = false;
796
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
796
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
797 797
 
798
-	if ( $is_ajax ) {
798
+	if ($is_ajax) {
799 799
 		// Do not create or login the user during the ajax submission (check for errors only).
800 800
 		return true;
801
-	} elseif ( is_user_logged_in() ) {
801
+	} elseif (is_user_logged_in()) {
802 802
 		// Set the valid user as the logged in collected data.
803 803
 		$user = $valid_data['logged_in_user'];
804
-	} elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
804
+	} elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
805 805
 		// New user registration.
806
-		if ( $valid_data['need_new_user'] === true ) {
806
+		if ($valid_data['need_new_user'] === true) {
807 807
 			// Set user.
808 808
 			$user = $valid_data['new_user_data'];
809 809
 			// Register and login new user.
810
-			$user['user_id'] = give_register_and_login_new_user( $user );
810
+			$user['user_id'] = give_register_and_login_new_user($user);
811 811
 			// User login
812
-		} elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
812
+		} elseif ($valid_data['need_user_login'] === true && ! $is_ajax) {
813 813
 
814 814
 			/*
815 815
 			 * The login form is now processed in the give_process_purchase_login() function.
@@ -822,48 +822,48 @@  discard block
 block discarded – undo
822 822
 			// Set user.
823 823
 			$user = $valid_data['login_user_data'];
824 824
 			// Login user.
825
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
825
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
826 826
 		}
827 827
 	}
828 828
 
829 829
 	// Check guest checkout.
830
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
830
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
831 831
 		// Set user
832 832
 		$user = $valid_data['guest_user_data'];
833 833
 	}
834 834
 
835 835
 	// Verify we have an user.
836
-	if ( false === $user || empty( $user ) ) {
836
+	if (false === $user || empty($user)) {
837 837
 		// Return false.
838 838
 		return false;
839 839
 	}
840 840
 
841 841
 	// Get user first name.
842
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
843
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
842
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
843
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
844 844
 	}
845 845
 
846 846
 	// Get user last name.
847
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
848
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
847
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
848
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
849 849
 	}
850 850
 
851 851
 	// Get the user's billing address details.
852 852
 	$user['address']            = array();
853
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
854
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
855
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
856
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
857
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
858
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
859
-
860
-	if ( empty( $user['address']['country'] ) ) {
853
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
854
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
855
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
856
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
857
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
858
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
859
+
860
+	if (empty($user['address']['country'])) {
861 861
 		$user['address'] = false;
862 862
 	} // Country will always be set if address fields are present.
863 863
 
864
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
864
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
865 865
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return purchases.
866
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
866
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
867 867
 	}
868 868
 
869 869
 	// Return valid user.
@@ -882,16 +882,16 @@  discard block
 block discarded – undo
882 882
 	$card_data = give_get_purchase_cc_info();
883 883
 
884 884
 	// Validate the card zip.
885
-	if ( ! empty( $card_data['card_zip'] ) ) {
886
-		if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
887
-			give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
885
+	if ( ! empty($card_data['card_zip'])) {
886
+		if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
887
+			give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give'));
888 888
 		}
889 889
 	}
890 890
 
891 891
 	// Ensure no spaces.
892
-	if ( ! empty( $card_data['card_number'] ) ) {
893
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs
894
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
892
+	if ( ! empty($card_data['card_number'])) {
893
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs
894
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
895 895
 	}
896 896
 
897 897
 	// This should validate card numbers at some point too.
@@ -907,17 +907,17 @@  discard block
 block discarded – undo
907 907
  */
908 908
 function give_get_purchase_cc_info() {
909 909
 	$cc_info                   = array();
910
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
911
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
912
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
913
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
914
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
915
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
916
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
917
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
918
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
919
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
920
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
910
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
911
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
912
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
913
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
914
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
915
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
916
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
917
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
918
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
919
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
920
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
921 921
 
922 922
 	// Return cc info
923 923
 	return $cc_info;
@@ -933,14 +933,14 @@  discard block
 block discarded – undo
933 933
  *
934 934
  * @return bool|mixed|void
935 935
  */
936
-function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
936
+function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') {
937 937
 	$ret = false;
938 938
 
939
-	if ( empty( $zip ) || empty( $country_code ) ) {
939
+	if (empty($zip) || empty($country_code)) {
940 940
 		return $ret;
941 941
 	}
942 942
 
943
-	$country_code = strtoupper( $country_code );
943
+	$country_code = strtoupper($country_code);
944 944
 
945 945
 	$zip_regex = array(
946 946
 		'AD' => 'AD\d{3}',
@@ -1100,11 +1100,11 @@  discard block
 block discarded – undo
1100 1100
 		'ZM' => '\d{5}',
1101 1101
 	);
1102 1102
 
1103
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1103
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1104 1104
 		$ret = true;
1105 1105
 	}
1106 1106
 
1107
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1107
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1108 1108
 }
1109 1109
 
1110 1110
 
@@ -1118,36 +1118,36 @@  discard block
 block discarded – undo
1118 1118
  *
1119 1119
  * @return bool
1120 1120
  */
1121
-function give_validate_multi_donation_form_level( $valid_data, $data ) {
1121
+function give_validate_multi_donation_form_level($valid_data, $data) {
1122 1122
 	/* @var Give_Donate_Form $form */
1123
-	$form = new Give_Donate_Form( $data['give-form-id'] );
1123
+	$form = new Give_Donate_Form($data['give-form-id']);
1124 1124
 
1125 1125
 	$donation_level_matched = false;
1126 1126
 
1127
-	if ( $form->is_multi_type_donation_form() ) {
1127
+	if ($form->is_multi_type_donation_form()) {
1128 1128
 
1129 1129
 		// Bailout.
1130
-		if ( ! ( $variable_prices = $form->get_prices() ) ) {
1130
+		if ( ! ($variable_prices = $form->get_prices())) {
1131 1131
 			return false;
1132 1132
 		}
1133 1133
 
1134 1134
 		// Sanitize donation amount.
1135
-		$data['give-amount'] = give_sanitize_amount( $data['give-amount'] );
1135
+		$data['give-amount'] = give_sanitize_amount($data['give-amount']);
1136 1136
 
1137 1137
 		// Get number of decimals.
1138 1138
 		$default_decimals = give_get_price_decimals();
1139 1139
 
1140
-		if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) {
1140
+		if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) {
1141 1141
 			return true;
1142 1142
 		}
1143 1143
 
1144 1144
 		// Find correct donation level from all donation levels.
1145
-		foreach ( $variable_prices as $variable_price ) {
1145
+		foreach ($variable_prices as $variable_price) {
1146 1146
 			// Sanitize level amount.
1147
-			$variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );
1147
+			$variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals);
1148 1148
 
1149 1149
 			// Set first match donation level ID.
1150
-			if ( $data['give-amount'] === $variable_price['_give_amount'] ) {
1150
+			if ($data['give-amount'] === $variable_price['_give_amount']) {
1151 1151
 				$_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1152 1152
 				$donation_level_matched = true;
1153 1153
 				break;
@@ -1158,19 +1158,19 @@  discard block
 block discarded – undo
1158 1158
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1159 1159
 		if (
1160 1160
 			! $donation_level_matched
1161
-			&& ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) )
1161
+			&& ('yes' === get_post_meta($data['give-form-id'], '_give_custom_amount', true))
1162 1162
 		) {
1163 1163
 			// Sanitize custom minimum amount.
1164
-			$custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );
1164
+			$custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals);
1165 1165
 
1166
-			if ( $data['give-amount'] >= $custom_minimum_amount ) {
1166
+			if ($data['give-amount'] >= $custom_minimum_amount) {
1167 1167
 				$_POST['give-price-id'] = 'custom';
1168 1168
 				$donation_level_matched = true;
1169 1169
 			}
1170 1170
 		}
1171 1171
 	}
1172 1172
 
1173
-	return ( $donation_level_matched ? true : false );
1173
+	return ($donation_level_matched ? true : false);
1174 1174
 }
1175 1175
 
1176
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1176
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
Please login to merge, or discard this patch.
includes/post-types.php 1 patch
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,36 +23,36 @@  discard block
 block discarded – undo
23 23
 function give_setup_post_types() {
24 24
 
25 25
 	// Give Forms single post and archive options.
26
-	$give_forms_singular = give_is_setting_enabled( give_get_option( 'forms_singular' ) );
27
-	$give_forms_archives = give_is_setting_enabled( give_get_option( 'forms_archives' ) );
26
+	$give_forms_singular = give_is_setting_enabled(give_get_option('forms_singular'));
27
+	$give_forms_archives = give_is_setting_enabled(give_get_option('forms_archives'));
28 28
 
29
-	$give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations';
29
+	$give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations';
30 30
 	// Support for old 'GIVE_FORMS_SLUG' constant
31
-	if ( defined( 'GIVE_FORMS_SLUG' ) ) {
31
+	if (defined('GIVE_FORMS_SLUG')) {
32 32
 		$give_forms_slug = GIVE_FORMS_SLUG;
33 33
 	}
34 34
 
35
-	$give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array(
35
+	$give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array(
36 36
 		'slug'       => $give_forms_slug,
37 37
 		'with_front' => false,
38 38
 	);
39 39
 
40
-	$give_forms_labels = apply_filters( 'give_forms_labels', array(
41
-		'name'               => esc_html__( 'Donation Forms', 'give' ),
42
-		'singular_name'      => esc_html__( 'Form', 'give' ),
43
-		'add_new'            => esc_html__( 'Add Form', 'give' ),
44
-		'add_new_item'       => esc_html__( 'Add New Donation Form', 'give' ),
45
-		'edit_item'          => esc_html__( 'Edit Donation Form', 'give' ),
46
-		'new_item'           => esc_html__( 'New Form', 'give' ),
47
-		'all_items'          => esc_html__( 'All Forms', 'give' ),
48
-		'view_item'          => esc_html__( 'View Form', 'give' ),
49
-		'search_items'       => esc_html__( 'Search Forms', 'give' ),
50
-		'not_found'          => esc_html__( 'No forms found.', 'give' ),
51
-		'not_found_in_trash' => esc_html__( 'No forms found in Trash.', 'give' ),
40
+	$give_forms_labels = apply_filters('give_forms_labels', array(
41
+		'name'               => esc_html__('Donation Forms', 'give'),
42
+		'singular_name'      => esc_html__('Form', 'give'),
43
+		'add_new'            => esc_html__('Add Form', 'give'),
44
+		'add_new_item'       => esc_html__('Add New Donation Form', 'give'),
45
+		'edit_item'          => esc_html__('Edit Donation Form', 'give'),
46
+		'new_item'           => esc_html__('New Form', 'give'),
47
+		'all_items'          => esc_html__('All Forms', 'give'),
48
+		'view_item'          => esc_html__('View Form', 'give'),
49
+		'search_items'       => esc_html__('Search Forms', 'give'),
50
+		'not_found'          => esc_html__('No forms found.', 'give'),
51
+		'not_found_in_trash' => esc_html__('No forms found in Trash.', 'give'),
52 52
 		'parent_item_colon'  => '',
53
-		'menu_name'          => apply_filters( 'give_menu_name', esc_html__( 'Donations', 'give' ) ),
54
-		'name_admin_bar'     => apply_filters( 'give_name_admin_bar_name', esc_html__( 'Donation Form', 'give' ) ),
55
-	) );
53
+		'menu_name'          => apply_filters('give_menu_name', esc_html__('Donations', 'give')),
54
+		'name_admin_bar'     => apply_filters('give_name_admin_bar_name', esc_html__('Donation Form', 'give')),
55
+	));
56 56
 
57 57
 	// Default give_forms supports.
58 58
 	$give_form_supports = array(
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
 	);
65 65
 
66 66
 	// Has the user disabled the excerpt?
67
-	if ( ! give_is_setting_enabled( give_get_option( 'forms_excerpt' ) ) ) {
68
-		unset( $give_form_supports[2] );
67
+	if ( ! give_is_setting_enabled(give_get_option('forms_excerpt'))) {
68
+		unset($give_form_supports[2]);
69 69
 	}
70 70
 
71 71
 	// Has user disabled the featured image?
72
-	if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
73
-		unset( $give_form_supports[1] );
74
-		remove_action( 'give_before_single_form_summary', 'give_show_form_images' );
72
+	if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) {
73
+		unset($give_form_supports[1]);
74
+		remove_action('give_before_single_form_summary', 'give_show_form_images');
75 75
 	}
76 76
 
77 77
 	$give_forms_args = array(
@@ -87,42 +87,42 @@  discard block
 block discarded – undo
87 87
 		'has_archive'        => $give_forms_archives,
88 88
 		'menu_icon'          => 'dashicons-give',
89 89
 		'hierarchical'       => false,
90
-		'supports'           => apply_filters( 'give_forms_supports', $give_form_supports ),
90
+		'supports'           => apply_filters('give_forms_supports', $give_form_supports),
91 91
 	);
92
-	register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) );
92
+	register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args));
93 93
 
94 94
 	/** Donation Post Type */
95 95
 	$payment_labels = array(
96
-		'name'               => _x( 'Donations', 'post type general name', 'give' ),
97
-		'singular_name'      => _x( 'Donation', 'post type singular name', 'give' ),
98
-		'add_new'            => esc_html__( 'Add New', 'give' ),
99
-		'add_new_item'       => esc_html__( 'Add New Donation', 'give' ),
100
-		'edit_item'          => esc_html__( 'Edit Donation', 'give' ),
101
-		'new_item'           => esc_html__( 'New Donation', 'give' ),
102
-		'all_items'          => esc_html__( 'All Donations', 'give' ),
103
-		'view_item'          => esc_html__( 'View Donation', 'give' ),
104
-		'search_items'       => esc_html__( 'Search Donations', 'give' ),
105
-		'not_found'          => esc_html__( 'No donations found.', 'give' ),
106
-		'not_found_in_trash' => esc_html__( 'No donations found in Trash.', 'give' ),
96
+		'name'               => _x('Donations', 'post type general name', 'give'),
97
+		'singular_name'      => _x('Donation', 'post type singular name', 'give'),
98
+		'add_new'            => esc_html__('Add New', 'give'),
99
+		'add_new_item'       => esc_html__('Add New Donation', 'give'),
100
+		'edit_item'          => esc_html__('Edit Donation', 'give'),
101
+		'new_item'           => esc_html__('New Donation', 'give'),
102
+		'all_items'          => esc_html__('All Donations', 'give'),
103
+		'view_item'          => esc_html__('View Donation', 'give'),
104
+		'search_items'       => esc_html__('Search Donations', 'give'),
105
+		'not_found'          => esc_html__('No donations found.', 'give'),
106
+		'not_found_in_trash' => esc_html__('No donations found in Trash.', 'give'),
107 107
 		'parent_item_colon'  => '',
108
-		'menu_name'          => esc_html__( 'Donations', 'give' ),
108
+		'menu_name'          => esc_html__('Donations', 'give'),
109 109
 	);
110 110
 
111 111
 	$payment_args = array(
112
-		'labels'          => apply_filters( 'give_payment_labels', $payment_labels ),
112
+		'labels'          => apply_filters('give_payment_labels', $payment_labels),
113 113
 		'public'          => false,
114 114
 		'query_var'       => false,
115 115
 		'rewrite'         => false,
116 116
 		'map_meta_cap'    => true,
117 117
 		'capability_type' => 'give_payment',
118
-		'supports'        => array( 'title' ),
118
+		'supports'        => array('title'),
119 119
 		'can_export'      => true,
120 120
 	);
121
-	register_post_type( 'give_payment', $payment_args );
121
+	register_post_type('give_payment', $payment_args);
122 122
 
123 123
 }
124 124
 
125
-add_action( 'init', 'give_setup_post_types', 1 );
125
+add_action('init', 'give_setup_post_types', 1);
126 126
 
127 127
 
128 128
 /**
@@ -135,30 +135,30 @@  discard block
 block discarded – undo
135 135
  */
136 136
 function give_setup_taxonomies() {
137 137
 
138
-	$slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations';
138
+	$slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations';
139 139
 
140 140
 	/** Categories */
141 141
 	$category_labels = array(
142
-		'name'              => _x( 'Form Categories', 'taxonomy general name', 'give' ),
143
-		'singular_name'     => _x( 'Category', 'taxonomy singular name', 'give' ),
144
-		'search_items'      => esc_html__( 'Search Categories', 'give' ),
145
-		'all_items'         => esc_html__( 'All Categories', 'give' ),
146
-		'parent_item'       => esc_html__( 'Parent Category', 'give' ),
147
-		'parent_item_colon' => esc_html__( 'Parent Category:', 'give' ),
148
-		'edit_item'         => esc_html__( 'Edit Category', 'give' ),
149
-		'update_item'       => esc_html__( 'Update Category', 'give' ),
150
-		'add_new_item'      => esc_html__( 'Add New Category', 'give' ),
151
-		'new_item_name'     => esc_html__( 'New Category Name', 'give' ),
152
-		'menu_name'         => esc_html__( 'Categories', 'give' ),
142
+		'name'              => _x('Form Categories', 'taxonomy general name', 'give'),
143
+		'singular_name'     => _x('Category', 'taxonomy singular name', 'give'),
144
+		'search_items'      => esc_html__('Search Categories', 'give'),
145
+		'all_items'         => esc_html__('All Categories', 'give'),
146
+		'parent_item'       => esc_html__('Parent Category', 'give'),
147
+		'parent_item_colon' => esc_html__('Parent Category:', 'give'),
148
+		'edit_item'         => esc_html__('Edit Category', 'give'),
149
+		'update_item'       => esc_html__('Update Category', 'give'),
150
+		'add_new_item'      => esc_html__('Add New Category', 'give'),
151
+		'new_item_name'     => esc_html__('New Category Name', 'give'),
152
+		'menu_name'         => esc_html__('Categories', 'give'),
153 153
 	);
154 154
 
155
-	$category_args = apply_filters( 'give_forms_category_args', array(
155
+	$category_args = apply_filters('give_forms_category_args', array(
156 156
 			'hierarchical' => true,
157
-			'labels'       => apply_filters( 'give_forms_category_labels', $category_labels ),
157
+			'labels'       => apply_filters('give_forms_category_labels', $category_labels),
158 158
 			'show_ui'      => true,
159 159
 			'query_var'    => 'give_forms_category',
160 160
 			'rewrite'      => array(
161
-				'slug'         => $slug . '/category',
161
+				'slug'         => $slug.'/category',
162 162
 				'with_front'   => false,
163 163
 				'hierarchical' => true,
164 164
 			),
@@ -172,33 +172,33 @@  discard block
 block discarded – undo
172 172
 	);
173 173
 
174 174
 	// Does the user want categories?
175
-	if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) {
176
-		register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args );
177
-		register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' );
175
+	if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) {
176
+		register_taxonomy('give_forms_category', array('give_forms'), $category_args);
177
+		register_taxonomy_for_object_type('give_forms_category', 'give_forms');
178 178
 	}
179 179
 
180 180
 	/** Tags */
181 181
 	$tag_labels = array(
182
-		'name'                  => _x( 'Form Tags', 'taxonomy general name', 'give' ),
183
-		'singular_name'         => _x( 'Tag', 'taxonomy singular name', 'give' ),
184
-		'search_items'          => esc_html__( 'Search Tags', 'give' ),
185
-		'all_items'             => esc_html__( 'All Tags', 'give' ),
186
-		'parent_item'           => esc_html__( 'Parent Tag', 'give' ),
187
-		'parent_item_colon'     => esc_html__( 'Parent Tag:', 'give' ),
188
-		'edit_item'             => esc_html__( 'Edit Tag', 'give' ),
189
-		'update_item'           => esc_html__( 'Update Tag', 'give' ),
190
-		'add_new_item'          => esc_html__( 'Add New Tag', 'give' ),
191
-		'new_item_name'         => esc_html__( 'New Tag Name', 'give' ),
192
-		'menu_name'             => esc_html__( 'Tags', 'give' ),
193
-		'choose_from_most_used' => esc_html__( 'Choose from most used tags.', 'give' ),
182
+		'name'                  => _x('Form Tags', 'taxonomy general name', 'give'),
183
+		'singular_name'         => _x('Tag', 'taxonomy singular name', 'give'),
184
+		'search_items'          => esc_html__('Search Tags', 'give'),
185
+		'all_items'             => esc_html__('All Tags', 'give'),
186
+		'parent_item'           => esc_html__('Parent Tag', 'give'),
187
+		'parent_item_colon'     => esc_html__('Parent Tag:', 'give'),
188
+		'edit_item'             => esc_html__('Edit Tag', 'give'),
189
+		'update_item'           => esc_html__('Update Tag', 'give'),
190
+		'add_new_item'          => esc_html__('Add New Tag', 'give'),
191
+		'new_item_name'         => esc_html__('New Tag Name', 'give'),
192
+		'menu_name'             => esc_html__('Tags', 'give'),
193
+		'choose_from_most_used' => esc_html__('Choose from most used tags.', 'give'),
194 194
 	);
195 195
 
196
-	$tag_args = apply_filters( 'give_forms_tag_args', array(
196
+	$tag_args = apply_filters('give_forms_tag_args', array(
197 197
 			'hierarchical' => false,
198
-			'labels'       => apply_filters( 'give_forms_tag_labels', $tag_labels ),
198
+			'labels'       => apply_filters('give_forms_tag_labels', $tag_labels),
199 199
 			'show_ui'      => true,
200 200
 			'query_var'    => 'give_forms_tag',
201
-			'rewrite'      => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ),
201
+			'rewrite'      => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true),
202 202
 			'capabilities' => array(
203 203
 				'manage_terms' => 'manage_give_form_terms',
204 204
 				'edit_terms'   => 'edit_give_form_terms',
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 		)
209 209
 	);
210 210
 
211
-	if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) {
212
-		register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args );
213
-		register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' );
211
+	if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) {
212
+		register_taxonomy('give_forms_tag', array('give_forms'), $tag_args);
213
+		register_taxonomy_for_object_type('give_forms_tag', 'give_forms');
214 214
 	}
215 215
 
216 216
 }
217 217
 
218
-add_action( 'init', 'give_setup_taxonomies', 0 );
218
+add_action('init', 'give_setup_taxonomies', 0);
219 219
 
220 220
 
221 221
 /**
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
  */
227 227
 function give_get_default_form_labels() {
228 228
 	$defaults = array(
229
-		'singular' => esc_html__( 'Form', 'give' ),
230
-		'plural'   => esc_html__( 'Forms', 'give' ),
229
+		'singular' => esc_html__('Form', 'give'),
230
+		'plural'   => esc_html__('Forms', 'give'),
231 231
 	);
232 232
 
233
-	return apply_filters( 'give_default_form_name', $defaults );
233
+	return apply_filters('give_default_form_name', $defaults);
234 234
 }
235 235
 
236 236
 /**
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
  *
243 243
  * @return string $defaults['singular'] Singular label
244 244
  */
245
-function give_get_forms_label_singular( $lowercase = false ) {
245
+function give_get_forms_label_singular($lowercase = false) {
246 246
 	$defaults = give_get_default_form_labels();
247 247
 
248
-	return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
248
+	return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
249 249
 }
250 250
 
251 251
 /**
@@ -254,10 +254,10 @@  discard block
 block discarded – undo
254 254
  * @since 1.0
255 255
  * @return string $defaults['plural'] Plural label
256 256
  */
257
-function give_get_forms_label_plural( $lowercase = false ) {
257
+function give_get_forms_label_plural($lowercase = false) {
258 258
 	$defaults = give_get_default_form_labels();
259 259
 
260
-	return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
260
+	return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
261 261
 }
262 262
 
263 263
 /**
@@ -269,24 +269,24 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return string $title New placeholder text
271 271
  */
272
-function give_change_default_title( $title ) {
272
+function give_change_default_title($title) {
273 273
 	// If a frontend plugin uses this filter (check extensions before changing this function)
274
-	if ( ! is_admin() ) {
275
-		$title = esc_html__( 'Enter form title here', 'give' );
274
+	if ( ! is_admin()) {
275
+		$title = esc_html__('Enter form title here', 'give');
276 276
 
277 277
 		return $title;
278 278
 	}
279 279
 
280 280
 	$screen = get_current_screen();
281 281
 
282
-	if ( 'give_forms' == $screen->post_type ) {
283
-		$title = esc_html__( 'Enter form title here', 'give' );
282
+	if ('give_forms' == $screen->post_type) {
283
+		$title = esc_html__('Enter form title here', 'give');
284 284
 	}
285 285
 
286 286
 	return $title;
287 287
 }
288 288
 
289
-add_filter( 'enter_title_here', 'give_change_default_title' );
289
+add_filter('enter_title_here', 'give_change_default_title');
290 290
 
291 291
 /**
292 292
  * Registers Custom Post Statuses which are used by the Payments
@@ -296,50 +296,50 @@  discard block
 block discarded – undo
296 296
  */
297 297
 function give_register_post_type_statuses() {
298 298
 	// Payment Statuses
299
-	register_post_status( 'refunded', array(
300
-		'label'                     => esc_html__( 'Refunded', 'give' ),
299
+	register_post_status('refunded', array(
300
+		'label'                     => esc_html__('Refunded', 'give'),
301 301
 		'public'                    => true,
302 302
 		'exclude_from_search'       => false,
303 303
 		'show_in_admin_all_list'    => true,
304 304
 		'show_in_admin_status_list' => true,
305
-		'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ),
306
-	) );
307
-	register_post_status( 'failed', array(
308
-		'label'                     => esc_html__( 'Failed', 'give' ),
305
+		'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give'),
306
+	));
307
+	register_post_status('failed', array(
308
+		'label'                     => esc_html__('Failed', 'give'),
309 309
 		'public'                    => true,
310 310
 		'exclude_from_search'       => false,
311 311
 		'show_in_admin_all_list'    => true,
312 312
 		'show_in_admin_status_list' => true,
313
-		'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ),
314
-	) );
315
-	register_post_status( 'revoked', array(
316
-		'label'                     => esc_html__( 'Revoked', 'give' ),
313
+		'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give'),
314
+	));
315
+	register_post_status('revoked', array(
316
+		'label'                     => esc_html__('Revoked', 'give'),
317 317
 		'public'                    => true,
318 318
 		'exclude_from_search'       => false,
319 319
 		'show_in_admin_all_list'    => true,
320 320
 		'show_in_admin_status_list' => true,
321
-		'label_count'               => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ),
322
-	) );
323
-	register_post_status( 'cancelled', array(
324
-		'label'                     => esc_html__( 'Cancelled', 'give' ),
321
+		'label_count'               => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give'),
322
+	));
323
+	register_post_status('cancelled', array(
324
+		'label'                     => esc_html__('Cancelled', 'give'),
325 325
 		'public'                    => true,
326 326
 		'exclude_from_search'       => false,
327 327
 		'show_in_admin_all_list'    => true,
328 328
 		'show_in_admin_status_list' => true,
329
-		'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ),
330
-	) );
331
-	register_post_status( 'abandoned', array(
332
-		'label'                     => esc_html__( 'Abandoned', 'give' ),
329
+		'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give'),
330
+	));
331
+	register_post_status('abandoned', array(
332
+		'label'                     => esc_html__('Abandoned', 'give'),
333 333
 		'public'                    => true,
334 334
 		'exclude_from_search'       => false,
335 335
 		'show_in_admin_all_list'    => true,
336 336
 		'show_in_admin_status_list' => true,
337
-		'label_count'               => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ),
338
-	) );
337
+		'label_count'               => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give'),
338
+	));
339 339
 
340 340
 }
341 341
 
342
-add_action( 'init', 'give_register_post_type_statuses' );
342
+add_action('init', 'give_register_post_type_statuses');
343 343
 
344 344
 /**
345 345
  * Updated Messages
@@ -352,27 +352,27 @@  discard block
 block discarded – undo
352 352
  *
353 353
  * @return array $messages New post updated messages
354 354
  */
355
-function give_updated_messages( $messages ) {
355
+function give_updated_messages($messages) {
356 356
 	global $post, $post_ID;
357 357
 
358
-	if ( give_get_option( 'disable_forms_singular' ) === 'on' ) {
358
+	if (give_get_option('disable_forms_singular') === 'on') {
359 359
 
360 360
 		$messages['give_forms'] = array(
361
-			1 => esc_html__( 'Form updated.', 'give' ),
362
-			4 => esc_html__( 'Form updated.', 'give' ),
363
-			6 => esc_html__( 'Form published.', 'give' ),
364
-			7 => esc_html__( 'Form saved.', 'give' ),
365
-			8 => esc_html__( 'Form submitted.', 'give' ),
361
+			1 => esc_html__('Form updated.', 'give'),
362
+			4 => esc_html__('Form updated.', 'give'),
363
+			6 => esc_html__('Form published.', 'give'),
364
+			7 => esc_html__('Form saved.', 'give'),
365
+			8 => esc_html__('Form submitted.', 'give'),
366 366
 		);
367 367
 
368 368
 	} else {
369 369
 
370 370
 		$messages['give_forms'] = array(
371
-			1 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form updated.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ),
372
-			4 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form updated.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ),
373
-			6 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form published.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ),
374
-			7 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form saved.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ),
375
-			8 => sprintf( '%1$s <a href="%2$s">%3$s</a>', esc_html__( 'Form submitted.', 'give' ), get_permalink( $post_ID ), esc_html__( 'View Form', 'give' ) ),
371
+			1 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form updated.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')),
372
+			4 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form updated.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')),
373
+			6 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form published.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')),
374
+			7 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form saved.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')),
375
+			8 => sprintf('%1$s <a href="%2$s">%3$s</a>', esc_html__('Form submitted.', 'give'), get_permalink($post_ID), esc_html__('View Form', 'give')),
376 376
 		);
377 377
 
378 378
 	}
@@ -380,27 +380,27 @@  discard block
 block discarded – undo
380 380
 	return $messages;
381 381
 }
382 382
 
383
-add_filter( 'post_updated_messages', 'give_updated_messages' );
383
+add_filter('post_updated_messages', 'give_updated_messages');
384 384
 
385 385
 
386 386
 /**
387 387
  * Setup Post Type Images
388 388
  */
389
-add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 );
389
+add_action('after_setup_theme', 'give_add_thumbnail_support', 10);
390 390
 
391 391
 /**
392 392
  * Ensure post thumbnail support is turned on
393 393
  */
394 394
 function give_add_thumbnail_support() {
395
-	if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
395
+	if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) {
396 396
 		return;
397 397
 	}
398 398
 
399
-	if ( ! current_theme_supports( 'post-thumbnails' ) ) {
400
-		add_theme_support( 'post-thumbnails' );
399
+	if ( ! current_theme_supports('post-thumbnails')) {
400
+		add_theme_support('post-thumbnails');
401 401
 	}
402 402
 
403
-	add_post_type_support( 'give_forms', 'thumbnail' );
403
+	add_post_type_support('give_forms', 'thumbnail');
404 404
 }
405 405
 
406 406
 /**
@@ -412,21 +412,21 @@  discard block
 block discarded – undo
412 412
 
413 413
 	// Single Give Forms (disabled if single turned off in settings)
414 414
 	if (
415
-		give_is_setting_enabled( give_get_option( 'forms_singular' ) )
416
-		&& give_is_setting_enabled( give_get_option( 'form_sidebar' ) )
415
+		give_is_setting_enabled(give_get_option('forms_singular'))
416
+		&& give_is_setting_enabled(give_get_option('form_sidebar'))
417 417
 	) {
418 418
 
419
-		register_sidebar( apply_filters( 'give_forms_single_sidebar', array(
420
-			'name'          => esc_html__( 'Give Single Form Sidebar', 'give' ),
419
+		register_sidebar(apply_filters('give_forms_single_sidebar', array(
420
+			'name'          => esc_html__('Give Single Form Sidebar', 'give'),
421 421
 			'id'            => 'give-forms-sidebar',
422
-			'description'   => esc_html__( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ),
422
+			'description'   => esc_html__('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'),
423 423
 			'before_widget' => '<div id="%1$s" class="widget %2$s">',
424 424
 			'after_widget'  => '</div>',
425 425
 			'before_title'  => '<h3 class="widgettitle widget-title">',
426 426
 			'after_title'   => '</h3>',
427
-		) ) );
427
+		)));
428 428
 
429 429
 	}
430 430
 }
431 431
 
432
-add_action( 'widgets_init', 'give_widgets_init', 999 );
432
+add_action('widgets_init', 'give_widgets_init', 999);
Please login to merge, or discard this patch.
includes/scripts.php 1 patch
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,25 +25,25 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_load_scripts() {
27 27
 
28
-	$js_dir         = GIVE_PLUGIN_URL . 'assets/js/frontend/';
29
-	$js_plugins     = GIVE_PLUGIN_URL . 'assets/js/plugins/';
30
-	$scripts_footer = ( give_get_option( 'scripts_footer' ) == 'on' ) ? true : false;
28
+	$js_dir         = GIVE_PLUGIN_URL.'assets/js/frontend/';
29
+	$js_plugins     = GIVE_PLUGIN_URL.'assets/js/plugins/';
30
+	$scripts_footer = (give_get_option('scripts_footer') == 'on') ? true : false;
31 31
 
32 32
 	// Use minified libraries if SCRIPT_DEBUG is turned off.
33
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
33
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
34 34
 
35 35
 	// Localize / PHP to AJAX vars.
36
-	$localize_give_vars = apply_filters( 'give_global_script_vars', array(
36
+	$localize_give_vars = apply_filters('give_global_script_vars', array(
37 37
 		'ajaxurl'             => give_get_ajax_url(),
38
-		'checkout_nonce'      => wp_create_nonce( 'give_checkout_nonce' ),
39
-		'currency_sign'       => give_currency_filter( '' ),
38
+		'checkout_nonce'      => wp_create_nonce('give_checkout_nonce'),
39
+		'currency_sign'       => give_currency_filter(''),
40 40
 		'currency_pos'        => give_get_currency_position(),
41 41
 		'thousands_separator' => give_get_price_thousand_separator(),
42 42
 		'decimal_separator'   => give_get_price_decimal_separator(),
43
-		'no_gateway'          => __( 'Please select a payment method.', 'give' ),
44
-		'bad_minimum'         => __( 'The minimum donation amount for this form is', 'give' ),
45
-		'general_loading'     => __( 'Loading...', 'give' ),
46
-		'purchase_loading'    => __( 'Please Wait...', 'give' ),
43
+		'no_gateway'          => __('Please select a payment method.', 'give'),
44
+		'bad_minimum'         => __('The minimum donation amount for this form is', 'give'),
45
+		'general_loading'     => __('Loading...', 'give'),
46
+		'purchase_loading'    => __('Please Wait...', 'give'),
47 47
 		'number_decimals'     => give_get_price_decimals(),
48 48
 		'give_version'        => GIVE_VERSION,
49 49
 		'magnific_options'    => apply_filters(
@@ -57,81 +57,81 @@  discard block
 block discarded – undo
57 57
 			'give_form_translation_js',
58 58
 			array(
59 59
 				// Field name               Validation message.
60
-				'payment-mode'           => __( 'Please select payment mode.', 'give' ),
61
-				'give_first'             => __( 'Please enter your first name.', 'give' ),
62
-				'give_email'             => __( 'Please enter a valid email address.', 'give' ),
63
-				'give_user_login'        => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ),
64
-				'give_user_pass'         => __( 'Enter a password.', 'give' ),
65
-				'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ),
66
-				'give_agree_to_terms'    => __( 'You must agree to the terms and conditions.', 'give' ),
60
+				'payment-mode'           => __('Please select payment mode.', 'give'),
61
+				'give_first'             => __('Please enter your first name.', 'give'),
62
+				'give_email'             => __('Please enter a valid email address.', 'give'),
63
+				'give_user_login'        => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'),
64
+				'give_user_pass'         => __('Enter a password.', 'give'),
65
+				'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'),
66
+				'give_agree_to_terms'    => __('You must agree to the terms and conditions.', 'give'),
67 67
 			)
68 68
 		),
69
-	) );
69
+	));
70 70
 
71
-	$localize_give_ajax = apply_filters( 'give_global_ajax_vars', array(
71
+	$localize_give_ajax = apply_filters('give_global_ajax_vars', array(
72 72
 		'ajaxurl'         => give_get_ajax_url(),
73
-		'loading'         => __( 'Loading', 'give' ),
73
+		'loading'         => __('Loading', 'give'),
74 74
 		// General loading message.
75
-		'select_option'   => __( 'Please select an option', 'give' ),
75
+		'select_option'   => __('Please select an option', 'give'),
76 76
 		// Variable pricing error with multi-donation option enabled.
77
-		'default_gateway' => give_get_default_gateway( null ),
78
-		'permalinks'      => get_option( 'permalink_structure' ) ? '1' : '0',
77
+		'default_gateway' => give_get_default_gateway(null),
78
+		'permalinks'      => get_option('permalink_structure') ? '1' : '0',
79 79
 		'number_decimals' => give_get_price_decimals(),
80
-	) );
80
+	));
81 81
 
82 82
 	// DEBUG is On.
83
-	if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
83
+	if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
84 84
 
85
-		if ( give_is_cc_verify_enabled() ) {
86
-			wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
87
-			wp_enqueue_script( 'give-cc-validator' );
85
+		if (give_is_cc_verify_enabled()) {
86
+			wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
87
+			wp_enqueue_script('give-cc-validator');
88 88
 		}
89 89
 
90
-		wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
91
-		wp_enqueue_script( 'give-float-labels' );
90
+		wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
91
+		wp_enqueue_script('give-float-labels');
92 92
 
93
-		wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
94
-		wp_enqueue_script( 'give-blockui' );
93
+		wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
94
+		wp_enqueue_script('give-blockui');
95 95
 
96
-		wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
97
-		wp_enqueue_script( 'give-qtip' );
96
+		wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
97
+		wp_enqueue_script('give-qtip');
98 98
 
99
-		wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
100
-		wp_enqueue_script( 'give-accounting' );
99
+		wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
100
+		wp_enqueue_script('give-accounting');
101 101
 
102
-		wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
103
-		wp_enqueue_script( 'give-magnific' );
102
+		wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
103
+		wp_enqueue_script('give-magnific');
104 104
 
105
-		wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
106
-		wp_enqueue_script( 'give-checkout-global' );
105
+		wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
106
+		wp_enqueue_script('give-checkout-global');
107 107
 
108 108
 		// General scripts.
109
-		wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
110
-		wp_enqueue_script( 'give-scripts' );
109
+		wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
110
+		wp_enqueue_script('give-scripts');
111 111
 
112 112
 		// Load AJAX scripts, if enabled.
113
-		wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
114
-		wp_enqueue_script( 'give-ajax' );
113
+		wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
114
+		wp_enqueue_script('give-ajax');
115 115
 
116 116
 		// Localize / Pass AJAX vars from PHP,
117
-		wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars );
118
-		wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax );
117
+		wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars);
118
+		wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax);
119 119
 
120 120
 	} else {
121 121
 
122 122
 		// DEBUG is OFF (one JS file to rule them all!).
123
-		wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
124
-		wp_enqueue_script( 'give' );
123
+		wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer);
124
+		wp_enqueue_script('give');
125 125
 
126 126
 		// Localize / Pass AJAX vars from PHP.
127
-		wp_localize_script( 'give', 'give_global_vars', $localize_give_vars );
128
-		wp_localize_script( 'give', 'give_scripts', $localize_give_ajax );
127
+		wp_localize_script('give', 'give_global_vars', $localize_give_vars);
128
+		wp_localize_script('give', 'give_scripts', $localize_give_ajax);
129 129
 
130 130
 	}
131 131
 
132 132
 }
133 133
 
134
-add_action( 'wp_enqueue_scripts', 'give_load_scripts' );
134
+add_action('wp_enqueue_scripts', 'give_load_scripts');
135 135
 
136 136
 /**
137 137
  * Register styles.
@@ -144,16 +144,16 @@  discard block
 block discarded – undo
144 144
  */
145 145
 function give_register_styles() {
146 146
 
147
-	if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) {
147
+	if ( ! give_is_setting_enabled(give_get_option('css'))) {
148 148
 		return;
149 149
 	}
150 150
 
151
-	wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' );
152
-	wp_enqueue_style( 'give-styles' );
151
+	wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all');
152
+	wp_enqueue_style('give-styles');
153 153
 
154 154
 }
155 155
 
156
-add_action( 'wp_enqueue_scripts', 'give_register_styles' );
156
+add_action('wp_enqueue_scripts', 'give_register_styles');
157 157
 
158 158
 
159 159
 /**
@@ -166,19 +166,19 @@  discard block
 block discarded – undo
166 166
 function give_get_stylesheet_uri() {
167 167
 
168 168
 	// Use minified libraries if SCRIPT_DEBUG is turned off.
169
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
169
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
170 170
 
171 171
 	// LTR or RTL files.
172
-	$direction = ( is_rtl() ) ? '-rtl' : '';
172
+	$direction = (is_rtl()) ? '-rtl' : '';
173 173
 
174
-	$file          = 'give' . $direction . $suffix . '.css';
174
+	$file          = 'give'.$direction.$suffix.'.css';
175 175
 	$templates_dir = give_get_theme_template_dir_name();
176 176
 
177
-	$child_theme_style_sheet    = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file;
178
-	$child_theme_style_sheet_2  = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css';
179
-	$parent_theme_style_sheet   = trailingslashit( get_template_directory() ) . $templates_dir . $file;
180
-	$parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css';
181
-	$give_plugin_style_sheet    = trailingslashit( give_get_templates_dir() ) . $file;
177
+	$child_theme_style_sheet    = trailingslashit(get_stylesheet_directory()).$templates_dir.$file;
178
+	$child_theme_style_sheet_2  = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css';
179
+	$parent_theme_style_sheet   = trailingslashit(get_template_directory()).$templates_dir.$file;
180
+	$parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css';
181
+	$give_plugin_style_sheet    = trailingslashit(give_get_templates_dir()).$file;
182 182
 
183 183
 	$uri = false;
184 184
 
@@ -188,23 +188,23 @@  discard block
 block discarded – undo
188 188
 	 * followed by non minified version, even if SCRIPT_DEBUG is not enabled.
189 189
 	 * This allows users to copy just give.css to their theme.
190 190
 	 */
191
-	if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) {
192
-		if ( ! empty( $nonmin ) ) {
193
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css';
191
+	if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) {
192
+		if ( ! empty($nonmin)) {
193
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css';
194 194
 		} else {
195
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file;
195
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file;
196 196
 		}
197
-	} elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) {
198
-		if ( ! empty( $nonmin ) ) {
199
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css';
197
+	} elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) {
198
+		if ( ! empty($nonmin)) {
199
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css';
200 200
 		} else {
201
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file;
201
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file;
202 202
 		}
203
-	} elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) {
204
-		$uri = trailingslashit( give_get_templates_url() ) . $file;
203
+	} elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) {
204
+		$uri = trailingslashit(give_get_templates_url()).$file;
205 205
 	}
206 206
 
207
-	return apply_filters( 'give_get_stylesheet_uri', $uri );
207
+	return apply_filters('give_get_stylesheet_uri', $uri);
208 208
 
209 209
 }
210 210
 
@@ -221,73 +221,73 @@  discard block
 block discarded – undo
221 221
  *
222 222
  * @return void
223 223
  */
224
-function give_load_admin_scripts( $hook ) {
224
+function give_load_admin_scripts($hook) {
225 225
 
226 226
 	global $post, $post_type;
227 227
 
228 228
 	$give_options = give_get_settings();
229 229
 
230 230
 	// Directories of assets.
231
-	$js_dir     = GIVE_PLUGIN_URL . 'assets/js/admin/';
232
-	$js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
233
-	$css_dir    = GIVE_PLUGIN_URL . 'assets/css/';
231
+	$js_dir     = GIVE_PLUGIN_URL.'assets/js/admin/';
232
+	$js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/';
233
+	$css_dir    = GIVE_PLUGIN_URL.'assets/css/';
234 234
 
235 235
 	// Use minified libraries if SCRIPT_DEBUG is turned off.
236
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
236
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
237 237
 
238 238
 	// LTR or RTL files.
239
-	$direction = ( is_rtl() ) ? '-rtl' : '';
239
+	$direction = (is_rtl()) ? '-rtl' : '';
240 240
 
241 241
 	// Global Admin.
242
-	wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' );
243
-	wp_enqueue_style( 'give-admin-bar-notification' );
242
+	wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css');
243
+	wp_enqueue_style('give-admin-bar-notification');
244 244
 
245 245
 	// Give Admin Only.
246
-	if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) {
246
+	if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) {
247 247
 		return;
248 248
 	}
249 249
 
250 250
 	// CSS.
251
-	wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' );
252
-	wp_enqueue_style( 'jquery-ui-css' );
253
-	wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', GIVE_VERSION );
254
-	wp_enqueue_style( 'give-admin' );
255
-	wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION );
256
-	wp_enqueue_style( 'jquery-chosen' );
257
-	wp_enqueue_style( 'thickbox' );
251
+	wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css');
252
+	wp_enqueue_style('jquery-ui-css');
253
+	wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', GIVE_VERSION);
254
+	wp_enqueue_style('give-admin');
255
+	wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION);
256
+	wp_enqueue_style('jquery-chosen');
257
+	wp_enqueue_style('thickbox');
258 258
 
259 259
 	// JS.
260
-	wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
261
-	wp_enqueue_script( 'jquery-chosen' );
260
+	wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION);
261
+	wp_enqueue_script('jquery-chosen');
262 262
 
263
-	wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
264
-	wp_enqueue_script( 'give-accounting' );
263
+	wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
264
+	wp_enqueue_script('give-accounting');
265 265
 
266
-	wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
267
-	wp_enqueue_script( 'give-admin-scripts' );
266
+	wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
267
+	wp_enqueue_script('give-admin-scripts');
268 268
 
269
-	wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' );
270
-	wp_enqueue_script( 'jquery-flot' );
269
+	wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js');
270
+	wp_enqueue_script('jquery-flot');
271 271
 
272
-	wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
273
-	wp_enqueue_script( 'give-qtip' );
272
+	wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
273
+	wp_enqueue_script('give-qtip');
274 274
 
275
-	wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
276
-	wp_enqueue_script( 'give-repeatable-fields' );
275
+	wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
276
+	wp_enqueue_script('give-repeatable-fields');
277 277
 
278
-	wp_enqueue_script( 'jquery-ui-datepicker' );
279
-	wp_enqueue_script( 'thickbox' );
278
+	wp_enqueue_script('jquery-ui-datepicker');
279
+	wp_enqueue_script('thickbox');
280 280
 
281 281
 	// Forms CPT Script.
282
-	if ( $post_type === 'give_forms' ) {
283
-		wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
284
-		wp_enqueue_script( 'give-admin-forms-scripts' );
282
+	if ($post_type === 'give_forms') {
283
+		wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
284
+		wp_enqueue_script('give-admin-forms-scripts');
285 285
 	}
286 286
 
287 287
 	// Settings Scripts.
288
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) {
289
-		wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
290
-		wp_enqueue_script( 'give-admin-settings-scripts' );
288
+	if (isset($_GET['page']) && $_GET['page'] == 'give-settings') {
289
+		wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
290
+		wp_enqueue_script('give-admin-settings-scripts');
291 291
 	}
292 292
 
293 293
 	// Price Separators.
@@ -295,54 +295,54 @@  discard block
 block discarded – undo
295 295
 	$decimal_separator  = give_get_price_decimal_separator();
296 296
 
297 297
 	// Localize strings & variables for JS.
298
-	wp_localize_script( 'give-admin-scripts', 'give_vars', array(
299
-		'post_id'                        => isset( $post->ID ) ? $post->ID : null,
298
+	wp_localize_script('give-admin-scripts', 'give_vars', array(
299
+		'post_id'                        => isset($post->ID) ? $post->ID : null,
300 300
 		'give_version'                   => GIVE_VERSION,
301 301
 		'thousands_separator'            => $thousand_separator,
302 302
 		'decimal_separator'              => $decimal_separator,
303
-		'quick_edit_warning'             => __( 'Not available for variable priced forms.', 'give' ),
304
-		'delete_payment'                 => __( 'Are you sure you wish to delete this payment?', 'give' ),
305
-		'delete_payment_note'            => __( 'Are you sure you wish to delete this note?', 'give' ),
306
-		'revoke_api_key'                 => __( 'Are you sure you wish to revoke this API key?', 'give' ),
307
-		'regenerate_api_key'             => __( 'Are you sure you wish to regenerate this API key?', 'give' ),
308
-		'resend_receipt'                 => __( 'Are you sure you wish to resend the donation receipt?', 'give' ),
309
-		'logo'                           => __( 'Logo', 'give' ),
310
-		'use_this_image'                 => __( 'Use this image', 'give' ),
311
-		'one_option'                     => __( 'Choose a form', 'give' ),
312
-		'one_or_more_option'             => __( 'Choose one or more forms', 'give' ),
313
-		'currency_sign'                  => give_currency_filter( '' ),
314
-		'currency_pos'                   => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before',
315
-		'currency_decimals'              => give_currency_decimal_filter( give_get_price_decimals() ),
316
-		'batch_export_no_class'          => __( 'You must choose a method.', 'give' ),
317
-		'batch_export_no_reqs'           => __( 'Required fields not completed.', 'give' ),
318
-		'reset_stats_warn'               => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ),
319
-		'price_format_guide'             => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ),
303
+		'quick_edit_warning'             => __('Not available for variable priced forms.', 'give'),
304
+		'delete_payment'                 => __('Are you sure you wish to delete this payment?', 'give'),
305
+		'delete_payment_note'            => __('Are you sure you wish to delete this note?', 'give'),
306
+		'revoke_api_key'                 => __('Are you sure you wish to revoke this API key?', 'give'),
307
+		'regenerate_api_key'             => __('Are you sure you wish to regenerate this API key?', 'give'),
308
+		'resend_receipt'                 => __('Are you sure you wish to resend the donation receipt?', 'give'),
309
+		'logo'                           => __('Logo', 'give'),
310
+		'use_this_image'                 => __('Use this image', 'give'),
311
+		'one_option'                     => __('Choose a form', 'give'),
312
+		'one_or_more_option'             => __('Choose one or more forms', 'give'),
313
+		'currency_sign'                  => give_currency_filter(''),
314
+		'currency_pos'                   => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before',
315
+		'currency_decimals'              => give_currency_decimal_filter(give_get_price_decimals()),
316
+		'batch_export_no_class'          => __('You must choose a method.', 'give'),
317
+		'batch_export_no_reqs'           => __('Required fields not completed.', 'give'),
318
+		'reset_stats_warn'               => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'),
319
+		'price_format_guide'             => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator),
320 320
 		/* translators : %s: Donation form options metabox */
321
-		'confirm_before_remove_row_text' => __( 'Do you want to delete this level?', 'give' ),
322
-		'matched_success_failure_page'   => __( 'You cannot set the success and failed pages to the same page', 'give' ),
323
-		'dismiss_notice_text'            => __( 'Dismiss this notice.', 'give' ),
321
+		'confirm_before_remove_row_text' => __('Do you want to delete this level?', 'give'),
322
+		'matched_success_failure_page'   => __('You cannot set the success and failed pages to the same page', 'give'),
323
+		'dismiss_notice_text'            => __('Dismiss this notice.', 'give'),
324 324
 		'bulk_action' => array(
325 325
 			'delete'         => array(
326
-				'zero_payment_selected' => __( 'You must choose at least one or more payments to delete.', 'give' ),
327
-				'delete_payment'        => __( 'Are you sure you want to permanently delete this donation?', 'give' ),
328
-				'delete_payments'       => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ),
326
+				'zero_payment_selected' => __('You must choose at least one or more payments to delete.', 'give'),
327
+				'delete_payment'        => __('Are you sure you want to permanently delete this donation?', 'give'),
328
+				'delete_payments'       => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'),
329 329
 			),
330 330
 			'resend_receipt' => array(
331
-				'zero_recipient_selected' => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ),
332
-				'resend_receipt'          => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ),
333
-				'resend_receipts'         => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ),
331
+				'zero_recipient_selected' => __('You must choose at least one or more recipients to resend the email receipt.', 'give'),
332
+				'resend_receipt'          => __('Are you sure you want to resend the email receipt to this recipient?', 'give'),
333
+				'resend_receipts'         => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'),
334 334
 			),
335 335
 		),
336
-	) );
336
+	));
337 337
 
338
-	if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) {
338
+	if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) {
339 339
 		// call for new media manager.
340 340
 		wp_enqueue_media();
341 341
 	}
342 342
 
343 343
 }
344 344
 
345
-add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 );
345
+add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100);
346 346
 
347 347
 /**
348 348
  * Admin Give Icon
@@ -357,13 +357,13 @@  discard block
 block discarded – undo
357 357
 	?>
358 358
     <style type="text/css" media="screen">
359 359
 
360
-        <?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?>
360
+        <?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?>
361 361
         @font-face {
362 362
             font-family: 'give-icomoon';
363
-            src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?-ngjl88'; ?>');
364
-            src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'),
365
-            url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'),
366
-            url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg');
363
+            src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?-ngjl88'; ?>');
364
+            src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'),
365
+            url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'),
366
+            url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg');
367 367
             font-weight: normal;
368 368
             font-style: normal;
369 369
         }
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 	<?php
383 383
 }
384 384
 
385
-add_action( 'admin_head', 'give_admin_icon' );
385
+add_action('admin_head', 'give_admin_icon');
386 386
 
387 387
 /**
388 388
  * Admin js code
@@ -412,4 +412,4 @@  discard block
 block discarded – undo
412 412
 	<?php
413 413
 }
414 414
 
415
-add_action( 'admin_head', 'give_admin_hide_notice_shortly_js' );
415
+add_action('admin_head', 'give_admin_hide_notice_shortly_js');
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -30,36 +30,36 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|object List of all user donations
32 32
  */
33
-function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43 43
 	$status = $status === 'complete' ? 'publish' : $status;
44 44
 
45
-	if ( $pagination ) {
46
-		if ( get_query_var( 'paged' ) ) {
47
-			$paged = get_query_var( 'paged' );
48
-		} elseif ( get_query_var( 'page' ) ) {
49
-			$paged = get_query_var( 'page' );
45
+	if ($pagination) {
46
+		if (get_query_var('paged')) {
47
+			$paged = get_query_var('paged');
48
+		} elseif (get_query_var('page')) {
49
+			$paged = get_query_var('page');
50 50
 		} else {
51 51
 			$paged = 1;
52 52
 		}
53 53
 	}
54 54
 
55
-	$args = apply_filters( 'give_get_users_donations_args', array(
55
+	$args = apply_filters('give_get_users_donations_args', array(
56 56
 		'user'    => $user,
57 57
 		'number'  => $number,
58 58
 		'status'  => $status,
59 59
 		'orderby' => 'date',
60
-	) );
60
+	));
61 61
 
62
-	if ( $pagination ) {
62
+	if ($pagination) {
63 63
 
64 64
 		$args['page'] = $paged;
65 65
 
@@ -69,20 +69,20 @@  discard block
 block discarded – undo
69 69
 
70 70
 	}
71 71
 
72
-	$by_user_id = is_numeric( $user ) ? true : false;
73
-	$customer   = new Give_Customer( $user, $by_user_id );
72
+	$by_user_id = is_numeric($user) ? true : false;
73
+	$customer   = new Give_Customer($user, $by_user_id);
74 74
 
75
-	if ( ! empty( $customer->payment_ids ) ) {
75
+	if ( ! empty($customer->payment_ids)) {
76 76
 
77
-		unset( $args['user'] );
78
-		$args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) );
77
+		unset($args['user']);
78
+		$args['post__in'] = array_map('absint', explode(',', $customer->payment_ids));
79 79
 
80 80
 	}
81 81
 
82
-	$purchases = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) );
82
+	$purchases = give_get_payments(apply_filters('give_get_users_donations_args', $args));
83 83
 
84 84
 	// No donations
85
-	if ( ! $purchases ) {
85
+	if ( ! $purchases) {
86 86
 		return false;
87 87
 	}
88 88
 
@@ -101,65 +101,65 @@  discard block
 block discarded – undo
101 101
  *
102 102
  * @return bool|object List of unique forms donated by user
103 103
  */
104
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
105
-	if ( empty( $user ) ) {
104
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
105
+	if (empty($user)) {
106 106
 		$user = get_current_user_id();
107 107
 	}
108 108
 
109
-	if ( empty( $user ) ) {
109
+	if (empty($user)) {
110 110
 		return false;
111 111
 	}
112 112
 
113
-	$by_user_id = is_numeric( $user ) ? true : false;
113
+	$by_user_id = is_numeric($user) ? true : false;
114 114
 
115
-	$customer = new Give_Customer( $user, $by_user_id );
115
+	$customer = new Give_Customer($user, $by_user_id);
116 116
 
117
-	if ( empty( $customer->payment_ids ) ) {
117
+	if (empty($customer->payment_ids)) {
118 118
 		return false;
119 119
 	}
120 120
 
121 121
 	// Get all the items donated
122
-	$payment_ids    = array_reverse( explode( ',', $customer->payment_ids ) );
123
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
124
-	if ( ! empty( $limit_payments ) ) {
125
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
122
+	$payment_ids    = array_reverse(explode(',', $customer->payment_ids));
123
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
124
+	if ( ! empty($limit_payments)) {
125
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
126 126
 	}
127 127
 	$donation_data = array();
128
-	foreach ( $payment_ids as $payment_id ) {
129
-		$donation_data[] = give_get_payment_meta( $payment_id );
128
+	foreach ($payment_ids as $payment_id) {
129
+		$donation_data[] = give_get_payment_meta($payment_id);
130 130
 	}
131 131
 
132
-	if ( empty( $donation_data ) ) {
132
+	if (empty($donation_data)) {
133 133
 		return false;
134 134
 	}
135 135
 
136 136
 	// Grab only the post ids "form_id" of the forms donated on this order
137 137
 	$completed_donations_ids = array();
138
-	foreach ( $donation_data as $purchase_meta ) {
139
-		$completed_donations_ids[] = isset( $purchase_meta['form_id'] ) ? $purchase_meta['form_id'] : '';
138
+	foreach ($donation_data as $purchase_meta) {
139
+		$completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : '';
140 140
 	}
141 141
 
142
-	if ( empty( $completed_donations_ids ) ) {
142
+	if (empty($completed_donations_ids)) {
143 143
 		return false;
144 144
 	}
145 145
 
146 146
 	// Only include each donation once
147
-	$form_ids = array_unique( $completed_donations_ids );
147
+	$form_ids = array_unique($completed_donations_ids);
148 148
 
149 149
 	// Make sure we still have some products and a first item
150
-	if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) {
150
+	if (empty($form_ids) || ! isset($form_ids[0])) {
151 151
 		return false;
152 152
 	}
153 153
 
154
-	$post_type = get_post_type( $form_ids[0] );
154
+	$post_type = get_post_type($form_ids[0]);
155 155
 
156
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
156
+	$args = apply_filters('give_get_users_completed_donations_args', array(
157 157
 		'include'        => $form_ids,
158 158
 		'post_type'      => $post_type,
159
-		'posts_per_page' => - 1,
160
-	) );
159
+		'posts_per_page' => -1,
160
+	));
161 161
 
162
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
162
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
163 163
 }
164 164
 
165 165
 
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return      bool True if has donated, false other wise.
177 177
  */
178
-function give_has_purchases( $user_id = null ) {
179
-	if ( empty( $user_id ) ) {
178
+function give_has_purchases($user_id = null) {
179
+	if (empty($user_id)) {
180 180
 		$user_id = get_current_user_id();
181 181
 	}
182 182
 
183
-	if ( give_get_users_purchases( $user_id, 1 ) ) {
183
+	if (give_get_users_purchases($user_id, 1)) {
184 184
 		return true; // User has at least one donation
185 185
 	}
186 186
 
@@ -200,27 +200,27 @@  discard block
 block discarded – undo
200 200
  *
201 201
  * @return      array
202 202
  */
203
-function give_get_purchase_stats_by_user( $user = '' ) {
203
+function give_get_purchase_stats_by_user($user = '') {
204 204
 
205
-	if ( is_email( $user ) ) {
205
+	if (is_email($user)) {
206 206
 
207 207
 		$field = 'email';
208 208
 
209
-	} elseif ( is_numeric( $user ) ) {
209
+	} elseif (is_numeric($user)) {
210 210
 
211 211
 		$field = 'user_id';
212 212
 
213 213
 	}
214 214
 
215 215
 	$stats    = array();
216
-	$customer = Give()->customers->get_customer_by( $field, $user );
216
+	$customer = Give()->customers->get_customer_by($field, $user);
217 217
 
218
-	if ( $customer ) {
218
+	if ($customer) {
219 219
 
220
-		$customer = new Give_Customer( $customer->id );
220
+		$customer = new Give_Customer($customer->id);
221 221
 
222
-		$stats['purchases']   = absint( $customer->purchase_count );
223
-		$stats['total_spent'] = give_sanitize_amount( $customer->purchase_value );
222
+		$stats['purchases']   = absint($customer->purchase_count);
223
+		$stats['total_spent'] = give_sanitize_amount($customer->purchase_value);
224 224
 
225 225
 	}
226 226
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @since 1.7
231 231
 	 */
232
-	$stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user );
232
+	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user);
233 233
 
234 234
 	return $stats;
235 235
 }
@@ -247,21 +247,21 @@  discard block
 block discarded – undo
247 247
  *
248 248
  * @return      int The total number of donations
249 249
  */
250
-function give_count_purchases_of_customer( $user = null ) {
250
+function give_count_purchases_of_customer($user = null) {
251 251
 
252 252
 	// Logged in?
253
-	if ( empty( $user ) ) {
253
+	if (empty($user)) {
254 254
 		$user = get_current_user_id();
255 255
 	}
256 256
 
257 257
 	// Email access?
258
-	if ( empty( $user ) && Give()->email_access->token_email ) {
258
+	if (empty($user) && Give()->email_access->token_email) {
259 259
 		$user = Give()->email_access->token_email;
260 260
 	}
261 261
 
262
-	$stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false;
262
+	$stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false;
263 263
 
264
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
264
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
265 265
 }
266 266
 
267 267
 /**
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
  *
275 275
  * @return      float The total amount the user has spent
276 276
  */
277
-function give_purchase_total_of_user( $user = null ) {
277
+function give_purchase_total_of_user($user = null) {
278 278
 
279
-	$stats = give_get_purchase_stats_by_user( $user );
279
+	$stats = give_get_purchase_stats_by_user($user);
280 280
 
281 281
 	return $stats['total_spent'];
282 282
 }
@@ -292,40 +292,40 @@  discard block
 block discarded – undo
292 292
  *
293 293
  * @return bool
294 294
  */
295
-function give_validate_username( $username, $form_id = 0 ) {
295
+function give_validate_username($username, $form_id = 0) {
296 296
 	$valid = true;
297 297
 
298 298
 	// Validate username.
299
-	if ( ! empty( $username ) ) {
299
+	if ( ! empty($username)) {
300 300
 
301 301
 		// Sanitize username.
302
-		$sanitized_user_name = sanitize_user( $username, false );
302
+		$sanitized_user_name = sanitize_user($username, false);
303 303
 
304 304
 		// We have an user name, check if it already exists.
305
-		if ( username_exists( $username ) ) {
305
+		if (username_exists($username)) {
306 306
 			// Username already registered.
307
-			give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
307
+			give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
308 308
 			$valid = false;
309 309
 
310 310
 			// Check if it's valid.
311
-		} elseif ( $sanitized_user_name !== $username ) {
311
+		} elseif ($sanitized_user_name !== $username) {
312 312
 			// Invalid username.
313
-			if ( is_multisite() ) {
314
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
313
+			if (is_multisite()) {
314
+				give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
315 315
 				$valid = false;
316 316
 			} else {
317
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
317
+				give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
318 318
 				$valid = false;
319 319
 			}
320 320
 		}
321 321
 	} else {
322 322
 		// Username is empty.
323
-		give_set_error( 'username_empty', esc_html__( 'Enter an username.', 'give' ) );
323
+		give_set_error('username_empty', esc_html__('Enter an username.', 'give'));
324 324
 		$valid = false;
325 325
 
326 326
 		// Check if guest checkout is disable for form.
327
-		if ( $form_id && give_logged_in_only( $form_id ) ) {
328
-			give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
327
+		if ($form_id && give_logged_in_only($form_id)) {
328
+			give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give'));
329 329
 			$valid = false;
330 330
 		}
331 331
 	}
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	 * @param string $username
340 340
 	 * @param bool   $form_id
341 341
 	 */
342
-	$valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id );
342
+	$valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id);
343 343
 
344 344
 	return $valid;
345 345
 }
@@ -355,22 +355,22 @@  discard block
 block discarded – undo
355 355
  *
356 356
  * @return bool
357 357
  */
358
-function give_validate_user_email( $email, $registering_new_user = false ) {
358
+function give_validate_user_email($email, $registering_new_user = false) {
359 359
 	$valid = true;
360 360
 
361
-	if ( empty( $email ) ) {
361
+	if (empty($email)) {
362 362
 		// No email.
363
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
363
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
364 364
 		$valid = false;
365 365
 
366
-	} elseif ( ! is_email( $email ) ) {
366
+	} elseif ( ! is_email($email)) {
367 367
 		// Validate email.
368
-		give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
368
+		give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
369 369
 		$valid = false;
370 370
 
371
-	} elseif ( $registering_new_user && email_exists( $email ) ) {
371
+	} elseif ($registering_new_user && email_exists($email)) {
372 372
 		// Check if email exists.
373
-		give_set_error( 'email_used', esc_html__( 'The email already active for another user.', 'give' ) );
373
+		give_set_error('email_used', esc_html__('The email already active for another user.', 'give'));
374 374
 		$valid = false;
375 375
 	}
376 376
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 * @param string $email
384 384
 	 * @param bool   $registering_new_user
385 385
 	 */
386
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user );
386
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user);
387 387
 
388 388
 	return $valid;
389 389
 }
@@ -399,25 +399,25 @@  discard block
 block discarded – undo
399 399
  *
400 400
  * @return bool
401 401
  */
402
-function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) {
402
+function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) {
403 403
 	$valid = true;
404 404
 
405
-	if ( $password && $confirm_password ) {
405
+	if ($password && $confirm_password) {
406 406
 		// Verify confirmation matches.
407
-		if ( $password != $confirm_password ) {
407
+		if ($password != $confirm_password) {
408 408
 			// Passwords do not match
409
-			give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
409
+			give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
410 410
 			$valid = false;
411 411
 		}
412
-	} elseif ( $registering_new_user ) {
412
+	} elseif ($registering_new_user) {
413 413
 		// Password or confirmation missing.
414
-		if ( ! $password ) {
414
+		if ( ! $password) {
415 415
 			// The password is invalid.
416
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
416
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
417 417
 			$valid = false;
418
-		} elseif ( ! $confirm_password ) {
418
+		} elseif ( ! $confirm_password) {
419 419
 			// Confirmation password is invalid.
420
-			give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) );
420
+			give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give'));
421 421
 			$valid = false;
422 422
 		}
423 423
 	}
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 	 * @param string $confirm_password
433 433
 	 * @param bool   $registering_new_user
434 434
 	 */
435
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user );
435
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user);
436 436
 
437 437
 	return $valid;
438 438
 }
@@ -451,32 +451,32 @@  discard block
 block discarded – undo
451 451
  *
452 452
  * @return      void
453 453
  */
454
-function give_add_past_purchases_to_new_user( $user_id ) {
454
+function give_add_past_purchases_to_new_user($user_id) {
455 455
 
456
-	$email = get_the_author_meta( 'user_email', $user_id );
456
+	$email = get_the_author_meta('user_email', $user_id);
457 457
 
458
-	$payments = give_get_payments( array( 's' => $email ) );
458
+	$payments = give_get_payments(array('s' => $email));
459 459
 
460
-	if ( $payments ) {
461
-		foreach ( $payments as $payment ) {
462
-			if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) {
460
+	if ($payments) {
461
+		foreach ($payments as $payment) {
462
+			if (intval(give_get_payment_user_id($payment->ID)) > 0) {
463 463
 				continue;
464 464
 			} // This payment already associated with an account
465 465
 
466
-			$meta                    = give_get_payment_meta( $payment->ID );
467
-			$meta['user_info']       = maybe_unserialize( $meta['user_info'] );
466
+			$meta                    = give_get_payment_meta($payment->ID);
467
+			$meta['user_info']       = maybe_unserialize($meta['user_info']);
468 468
 			$meta['user_info']['id'] = $user_id;
469 469
 			$meta['user_info']       = $meta['user_info'];
470 470
 
471 471
 			// Store the updated user ID in the payment meta
472
-			give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta );
473
-			give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id );
472
+			give_update_payment_meta($payment->ID, '_give_payment_meta', $meta);
473
+			give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id);
474 474
 		}
475 475
 	}
476 476
 
477 477
 }
478 478
 
479
-add_action( 'user_register', 'give_add_past_purchases_to_new_user' );
479
+add_action('user_register', 'give_add_past_purchases_to_new_user');
480 480
 
481 481
 
482 482
 /**
@@ -502,34 +502,34 @@  discard block
 block discarded – undo
502 502
  *
503 503
  * @return        array The donor's address, if any
504 504
  */
505
-function give_get_donor_address( $user_id = 0 ) {
506
-	if ( empty( $user_id ) ) {
505
+function give_get_donor_address($user_id = 0) {
506
+	if (empty($user_id)) {
507 507
 		$user_id = get_current_user_id();
508 508
 	}
509 509
 
510
-	$address = get_user_meta( $user_id, '_give_user_address', true );
510
+	$address = get_user_meta($user_id, '_give_user_address', true);
511 511
 
512
-	if ( ! isset( $address['line1'] ) ) {
512
+	if ( ! isset($address['line1'])) {
513 513
 		$address['line1'] = '';
514 514
 	}
515 515
 
516
-	if ( ! isset( $address['line2'] ) ) {
516
+	if ( ! isset($address['line2'])) {
517 517
 		$address['line2'] = '';
518 518
 	}
519 519
 
520
-	if ( ! isset( $address['city'] ) ) {
520
+	if ( ! isset($address['city'])) {
521 521
 		$address['city'] = '';
522 522
 	}
523 523
 
524
-	if ( ! isset( $address['zip'] ) ) {
524
+	if ( ! isset($address['zip'])) {
525 525
 		$address['zip'] = '';
526 526
 	}
527 527
 
528
-	if ( ! isset( $address['country'] ) ) {
528
+	if ( ! isset($address['country'])) {
529 529
 		$address['country'] = '';
530 530
 	}
531 531
 
532
-	if ( ! isset( $address['state'] ) ) {
532
+	if ( ! isset($address['state'])) {
533 533
 		$address['state'] = '';
534 534
 	}
535 535
 
@@ -549,42 +549,42 @@  discard block
 block discarded – undo
549 549
  *
550 550
  * @return        void
551 551
  */
552
-function give_new_user_notification( $user_id = 0, $user_data = array() ) {
552
+function give_new_user_notification($user_id = 0, $user_data = array()) {
553 553
 
554
-	if ( empty( $user_id ) || empty( $user_data ) ) {
554
+	if (empty($user_id) || empty($user_data)) {
555 555
 		return;
556 556
 	}
557
-	$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
557
+	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
558 558
 
559 559
 	/* translators: %s: site name */
560
-	$message = sprintf( esc_attr__( 'New user registration on your site %s:', 'give' ), $blogname ) . "\r\n\r\n";
560
+	$message = sprintf(esc_attr__('New user registration on your site %s:', 'give'), $blogname)."\r\n\r\n";
561 561
 	/* translators: %s: user login */
562
-	$message .= sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n\r\n";
562
+	$message .= sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n\r\n";
563 563
 	/* translators: %s: user email */
564
-	$message .= sprintf( esc_attr__( 'E-mail: %s', 'give' ), $user_data['user_email'] ) . "\r\n";
564
+	$message .= sprintf(esc_attr__('E-mail: %s', 'give'), $user_data['user_email'])."\r\n";
565 565
 
566 566
 	@wp_mail(
567
-		get_option( 'admin_email' ),
567
+		get_option('admin_email'),
568 568
 		sprintf(
569 569
 			/* translators: %s: site name */
570
-			esc_attr__( '[%s] New User Registration', 'give' ),
570
+			esc_attr__('[%s] New User Registration', 'give'),
571 571
 			$blogname
572 572
 		),
573 573
 		$message
574 574
 	);
575 575
 
576 576
 	/* translators: %s: user login */
577
-	$message = sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n";
577
+	$message = sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n";
578 578
 	/* translators: %s: paswword */
579
-	$message .= sprintf( esc_attr__( 'Password: %s', 'give' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n";
579
+	$message .= sprintf(esc_attr__('Password: %s', 'give'), esc_attr__('[Password entered during donation]', 'give'))."\r\n";
580 580
 
581
-	$message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login &raquo;', 'give' ) . '</a>' . "\r\n";
581
+	$message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login &raquo;', 'give').'</a>'."\r\n";
582 582
 
583 583
 	wp_mail(
584 584
 		$user_data['user_email'],
585 585
 		sprintf(
586 586
 			/* translators: %s: site name */
587
-			esc_attr__( '[%s] Your username and password', 'give' ),
587
+			esc_attr__('[%s] Your username and password', 'give'),
588 588
 			$blogname
589 589
 		),
590 590
 		$message
@@ -592,4 +592,4 @@  discard block
 block discarded – undo
592 592
 
593 593
 }
594 594
 
595
-add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
595
+add_action('give_insert_user', 'give_new_user_notification', 10, 2);
Please login to merge, or discard this patch.