Completed
Pull Request — master (#801)
by
unknown
18:24
created
includes/admin/customers/customer-actions.php 1 patch
Spacing   +128 added lines, -128 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,15 +23,15 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array $output Response messages
25 25
  */
26
-function give_edit_customer( $args ) {
26
+function give_edit_customer($args) {
27 27
 	
28
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
28
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
29 29
 
30
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
31
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ) );
30
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
31
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'));
32 32
 	}
33 33
 
34
-	if ( empty( $args ) ) {
34
+	if (empty($args)) {
35 35
 		return;
36 36
 	}
37 37
 
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 	$customer_id   = (int) $args['customerinfo']['id'];
40 40
 	$nonce         = $args['_wpnonce'];
41 41
 
42
-	if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) {
43
-		wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ) );
42
+	if ( ! wp_verify_nonce($nonce, 'edit-customer')) {
43
+		wp_die(esc_html__('Cheatin\' eh?!', 'give'));
44 44
 	}
45 45
 
46
-	$customer = new Give_Customer( $customer_id );
47
-	if ( empty( $customer->id ) ) {
46
+	$customer = new Give_Customer($customer_id);
47
+	if (empty($customer->id)) {
48 48
 		return false;
49 49
 	}
50 50
 
@@ -54,23 +54,23 @@  discard block
 block discarded – undo
54 54
 		'user_id' => 0
55 55
 	);
56 56
 
57
-	$customer_info = wp_parse_args( $customer_info, $defaults );
57
+	$customer_info = wp_parse_args($customer_info, $defaults);
58 58
 
59
-	if ( ! is_email( $customer_info['email'] ) ) {
60
-		give_set_error( 'give-invalid-email', esc_html__( 'Please enter a valid email address.', 'give' ) );
59
+	if ( ! is_email($customer_info['email'])) {
60
+		give_set_error('give-invalid-email', esc_html__('Please enter a valid email address.', 'give'));
61 61
 	}
62 62
 
63
-	if ( (int) $customer_info['user_id'] != (int) $customer->user_id ) {
63
+	if ((int) $customer_info['user_id'] != (int) $customer->user_id) {
64 64
 
65 65
 		// Make sure we don't already have this user attached to a customer
66
-		if ( ! empty( $customer_info['user_id'] ) && false !== Give()->customers->get_customer_by( 'user_id', $customer_info['user_id'] ) ) {
67
-			give_set_error( 'give-invalid-customer-user_id', sprintf( esc_html__( 'The User ID %d is already associated with a different donor.', 'give' ), $customer_info['user_id'] ) );
66
+		if ( ! empty($customer_info['user_id']) && false !== Give()->customers->get_customer_by('user_id', $customer_info['user_id'])) {
67
+			give_set_error('give-invalid-customer-user_id', sprintf(esc_html__('The User ID %d is already associated with a different donor.', 'give'), $customer_info['user_id']));
68 68
 		}
69 69
 
70 70
 		// Make sure it's actually a user
71
-		$user = get_user_by( 'id', $customer_info['user_id'] );
72
-		if ( ! empty( $customer_info['user_id'] ) && false === $user ) {
73
-			give_set_error( 'give-invalid-user_id', sprintf( esc_html__( 'The User ID %d does not exist. Please assign an existing user.', 'give' ), $customer_info['user_id'] ) );
71
+		$user = get_user_by('id', $customer_info['user_id']);
72
+		if ( ! empty($customer_info['user_id']) && false === $user) {
73
+			give_set_error('give-invalid-user_id', sprintf(esc_html__('The User ID %d does not exist. Please assign an existing user.', 'give'), $customer_info['user_id']));
74 74
 		}
75 75
 
76 76
 	}
@@ -78,82 +78,82 @@  discard block
 block discarded – undo
78 78
 	// Record this for later
79 79
 	$previous_user_id = $customer->user_id;
80 80
 
81
-	if ( give_get_errors() ) {
81
+	if (give_get_errors()) {
82 82
 		return;
83 83
 	}
84 84
 
85 85
 	// Setup the customer address, if present
86 86
 	$address = array();
87
-	if ( intval( $customer_info['user_id'] ) > 0 ) {
87
+	if (intval($customer_info['user_id']) > 0) {
88 88
 
89
-		$current_address = get_user_meta( $customer_info['user_id'], '_give_user_address', true );
89
+		$current_address = get_user_meta($customer_info['user_id'], '_give_user_address', true);
90 90
 
91
-		if ( false === $current_address ) {
92
-			$address['line1']   = isset( $customer_info['line1'] ) ? $customer_info['line1'] : '';
93
-			$address['line2']   = isset( $customer_info['line2'] ) ? $customer_info['line2'] : '';
94
-			$address['city']    = isset( $customer_info['city'] ) ? $customer_info['city'] : '';
95
-			$address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : '';
96
-			$address['zip']     = isset( $customer_info['zip'] ) ? $customer_info['zip'] : '';
97
-			$address['state']   = isset( $customer_info['state'] ) ? $customer_info['state'] : '';
91
+		if (false === $current_address) {
92
+			$address['line1']   = isset($customer_info['line1']) ? $customer_info['line1'] : '';
93
+			$address['line2']   = isset($customer_info['line2']) ? $customer_info['line2'] : '';
94
+			$address['city']    = isset($customer_info['city']) ? $customer_info['city'] : '';
95
+			$address['country'] = isset($customer_info['country']) ? $customer_info['country'] : '';
96
+			$address['zip']     = isset($customer_info['zip']) ? $customer_info['zip'] : '';
97
+			$address['state']   = isset($customer_info['state']) ? $customer_info['state'] : '';
98 98
 		} else {
99
-			$current_address    = wp_parse_args( $current_address, array(
99
+			$current_address    = wp_parse_args($current_address, array(
100 100
 				'line1',
101 101
 				'line2',
102 102
 				'city',
103 103
 				'zip',
104 104
 				'state',
105 105
 				'country'
106
-			) );
107
-			$address['line1']   = isset( $customer_info['line1'] ) ? $customer_info['line1'] : $current_address['line1'];
108
-			$address['line2']   = isset( $customer_info['line2'] ) ? $customer_info['line2'] : $current_address['line2'];
109
-			$address['city']    = isset( $customer_info['city'] ) ? $customer_info['city'] : $current_address['city'];
110
-			$address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : $current_address['country'];
111
-			$address['zip']     = isset( $customer_info['zip'] ) ? $customer_info['zip'] : $current_address['zip'];
112
-			$address['state']   = isset( $customer_info['state'] ) ? $customer_info['state'] : $current_address['state'];
106
+			));
107
+			$address['line1']   = isset($customer_info['line1']) ? $customer_info['line1'] : $current_address['line1'];
108
+			$address['line2']   = isset($customer_info['line2']) ? $customer_info['line2'] : $current_address['line2'];
109
+			$address['city']    = isset($customer_info['city']) ? $customer_info['city'] : $current_address['city'];
110
+			$address['country'] = isset($customer_info['country']) ? $customer_info['country'] : $current_address['country'];
111
+			$address['zip']     = isset($customer_info['zip']) ? $customer_info['zip'] : $current_address['zip'];
112
+			$address['state']   = isset($customer_info['state']) ? $customer_info['state'] : $current_address['state'];
113 113
 		}
114 114
 
115 115
 	}
116 116
 
117 117
 	// Sanitize the inputs
118 118
 	$customer_data            = array();
119
-	$customer_data['name']    = strip_tags( stripslashes( $customer_info['name'] ) );
119
+	$customer_data['name']    = strip_tags(stripslashes($customer_info['name']));
120 120
 	$customer_data['email']   = $customer_info['email'];
121 121
 	$customer_data['user_id'] = $customer_info['user_id'];
122 122
 
123
-	$customer_data = apply_filters( 'give_edit_customer_info', $customer_data, $customer_id );
124
-	$address       = apply_filters( 'give_edit_customer_address', $address, $customer_id );
123
+	$customer_data = apply_filters('give_edit_customer_info', $customer_data, $customer_id);
124
+	$address       = apply_filters('give_edit_customer_address', $address, $customer_id);
125 125
 
126
-	$customer_data = array_map( 'sanitize_text_field', $customer_data );
127
-	$address       = array_map( 'sanitize_text_field', $address );
126
+	$customer_data = array_map('sanitize_text_field', $customer_data);
127
+	$address       = array_map('sanitize_text_field', $address);
128 128
 
129
-	do_action( 'give_pre_edit_customer', $customer_id, $customer_data, $address );
129
+	do_action('give_pre_edit_customer', $customer_id, $customer_data, $address);
130 130
 
131 131
 	$output         = array();
132 132
 	$previous_email = $customer->email;
133 133
 
134
-	if ( $customer->update( $customer_data ) ) {
134
+	if ($customer->update($customer_data)) {
135 135
 
136
-		if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) {
137
-			update_user_meta( $customer->user_id, '_give_user_address', $address );
136
+		if ( ! empty($customer->user_id) && $customer->user_id > 0) {
137
+			update_user_meta($customer->user_id, '_give_user_address', $address);
138 138
 		}
139 139
 
140 140
 		// Update some payment meta if we need to
141
-		$payments_array = explode( ',', $customer->payment_ids );
141
+		$payments_array = explode(',', $customer->payment_ids);
142 142
 
143
-		if ( $customer->email != $previous_email ) {
144
-			foreach ( $payments_array as $payment_id ) {
145
-				give_update_payment_meta( $payment_id, 'email', $customer->email );
143
+		if ($customer->email != $previous_email) {
144
+			foreach ($payments_array as $payment_id) {
145
+				give_update_payment_meta($payment_id, 'email', $customer->email);
146 146
 			}
147 147
 		}
148 148
 
149
-		if ( $customer->user_id != $previous_user_id ) {
150
-			foreach ( $payments_array as $payment_id ) {
151
-				give_update_payment_meta( $payment_id, '_give_payment_user_id', $customer->user_id );
149
+		if ($customer->user_id != $previous_user_id) {
150
+			foreach ($payments_array as $payment_id) {
151
+				give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id);
152 152
 			}
153 153
 		}
154 154
 
155 155
 		$output['success']       = true;
156
-		$customer_data           = array_merge( $customer_data, $address );
156
+		$customer_data           = array_merge($customer_data, $address);
157 157
 		$output['customer_info'] = $customer_data;
158 158
 
159 159
 	} else {
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
 
163 163
 	}
164 164
 
165
-	do_action( 'give_post_edit_customer', $customer_id, $customer_data );
165
+	do_action('give_post_edit_customer', $customer_id, $customer_data);
166 166
 
167
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
168
-		header( 'Content-Type: application/json' );
169
-		echo json_encode( $output );
167
+	if (defined('DOING_AJAX') && DOING_AJAX) {
168
+		header('Content-Type: application/json');
169
+		echo json_encode($output);
170 170
 		wp_die();
171 171
 	}
172 172
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
 }
176 176
 
177
-add_action( 'give_edit-customer', 'give_edit_customer', 10, 1 );
177
+add_action('give_edit-customer', 'give_edit_customer', 10, 1);
178 178
 
179 179
 /**
180 180
  * Save a customer note being added
@@ -185,53 +185,53 @@  discard block
 block discarded – undo
185 185
  *
186 186
  * @return int         The Note ID that was saved, or 0 if nothing was saved
187 187
  */
188
-function give_customer_save_note( $args ) {
188
+function give_customer_save_note($args) {
189 189
 
190
-	$customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' );
190
+	$customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports');
191 191
 
192
-	if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) {
193
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ) );
192
+	if ( ! is_admin() || ! current_user_can($customer_view_role)) {
193
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'));
194 194
 	}
195 195
 
196
-	if ( empty( $args ) ) {
196
+	if (empty($args)) {
197 197
 		return;
198 198
 	}
199 199
 
200
-	$customer_note = trim( sanitize_text_field( $args['customer_note'] ) );
200
+	$customer_note = trim(sanitize_text_field($args['customer_note']));
201 201
 	$customer_id   = (int) $args['customer_id'];
202 202
 	$nonce         = $args['add_customer_note_nonce'];
203 203
 
204
-	if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) {
205
-		wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ) );
204
+	if ( ! wp_verify_nonce($nonce, 'add-customer-note')) {
205
+		wp_die(esc_html__('Cheatin\' eh?!', 'give'));
206 206
 	}
207 207
 
208
-	if ( empty( $customer_note ) ) {
209
-		give_set_error( 'empty-customer-note', esc_html__( 'A note is required.', 'give' ) );
208
+	if (empty($customer_note)) {
209
+		give_set_error('empty-customer-note', esc_html__('A note is required.', 'give'));
210 210
 	}
211 211
 
212
-	if ( give_get_errors() ) {
212
+	if (give_get_errors()) {
213 213
 		return;
214 214
 	}
215 215
 
216
-	$customer = new Give_Customer( $customer_id );
217
-	$new_note = $customer->add_note( $customer_note );
216
+	$customer = new Give_Customer($customer_id);
217
+	$new_note = $customer->add_note($customer_note);
218 218
 
219
-	do_action( 'give_pre_insert_customer_note', $customer_id, $new_note );
219
+	do_action('give_pre_insert_customer_note', $customer_id, $new_note);
220 220
 
221
-	if ( ! empty( $new_note ) && ! empty( $customer->id ) ) {
221
+	if ( ! empty($new_note) && ! empty($customer->id)) {
222 222
 
223 223
 		ob_start();
224 224
 		?>
225 225
 		<div class="customer-note-wrapper dashboard-comment-wrap comment-item">
226 226
 			<span class="note-content-wrap">
227
-				<?php echo stripslashes( $new_note ); ?>
227
+				<?php echo stripslashes($new_note); ?>
228 228
 			</span>
229 229
 		</div>
230 230
 		<?php
231 231
 		$output = ob_get_contents();
232 232
 		ob_end_clean();
233 233
 
234
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
234
+		if (defined('DOING_AJAX') && DOING_AJAX) {
235 235
 			echo $output;
236 236
 			exit;
237 237
 		}
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
 }
246 246
 
247
-add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 );
247
+add_action('give_add-customer-note', 'give_customer_save_note', 10, 1);
248 248
 
249 249
 /**
250 250
  * Delete a customer
@@ -255,87 +255,87 @@  discard block
 block discarded – undo
255 255
  *
256 256
  * @return int Whether it was a successful deletion
257 257
  */
258
-function give_customer_delete( $args ) {
258
+function give_customer_delete($args) {
259 259
 
260
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
260
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
261 261
 
262
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
263
-		wp_die( esc_html__( 'You do not have permission to delete donors.', 'give' ) );
262
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
263
+		wp_die(esc_html__('You do not have permission to delete donors.', 'give'));
264 264
 	}
265 265
 
266
-	if ( empty( $args ) ) {
266
+	if (empty($args)) {
267 267
 		return;
268 268
 	}
269 269
 
270 270
 	$customer_id = (int) $args['customer_id'];
271
-	$confirm     = ! empty( $args['give-customer-delete-confirm'] ) ? true : false;
272
-	$remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false;
271
+	$confirm     = ! empty($args['give-customer-delete-confirm']) ? true : false;
272
+	$remove_data = ! empty($args['give-customer-delete-records']) ? true : false;
273 273
 	$nonce       = $args['_wpnonce'];
274 274
 
275
-	if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) {
276
-		wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ) );
275
+	if ( ! wp_verify_nonce($nonce, 'delete-customer')) {
276
+		wp_die(esc_html__('Cheatin\' eh?!', 'give'));
277 277
 	}
278 278
 
279
-	if ( ! $confirm ) {
280
-		give_set_error( 'customer-delete-no-confirm', esc_html__( 'Please confirm you want to delete this donor.', 'give' ) );
279
+	if ( ! $confirm) {
280
+		give_set_error('customer-delete-no-confirm', esc_html__('Please confirm you want to delete this donor.', 'give'));
281 281
 	}
282 282
 
283
-	if ( give_get_errors() ) {
284
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) );
283
+	if (give_get_errors()) {
284
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id));
285 285
 		exit;
286 286
 	}
287 287
 
288
-	$customer = new Give_Customer( $customer_id );
288
+	$customer = new Give_Customer($customer_id);
289 289
 
290
-	do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data );
290
+	do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data);
291 291
 
292 292
 	$success = false;
293 293
 
294
-	if ( $customer->id > 0 ) {
294
+	if ($customer->id > 0) {
295 295
 
296
-		$payments_array = explode( ',', $customer->payment_ids );
297
-		$success        = Give()->customers->delete( $customer->id );
296
+		$payments_array = explode(',', $customer->payment_ids);
297
+		$success        = Give()->customers->delete($customer->id);
298 298
 
299
-		if ( $success ) {
299
+		if ($success) {
300 300
 
301
-			if ( $remove_data ) {
301
+			if ($remove_data) {
302 302
 
303 303
 				// Remove all payments, logs, etc
304
-				foreach ( $payments_array as $payment_id ) {
305
-					give_delete_purchase( $payment_id );
304
+				foreach ($payments_array as $payment_id) {
305
+					give_delete_purchase($payment_id);
306 306
 				}
307 307
 
308 308
 			} else {
309 309
 
310 310
 				// Just set the payments to customer_id of 0
311
-				foreach ( $payments_array as $payment_id ) {
312
-					give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 );
311
+				foreach ($payments_array as $payment_id) {
312
+					give_update_payment_meta($payment_id, '_give_payment_customer_id', 0);
313 313
 				}
314 314
 
315 315
 			}
316 316
 
317
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' );
317
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted');
318 318
 
319 319
 		} else {
320 320
 
321
-			give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) );
322
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id );
321
+			give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give'));
322
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id);
323 323
 
324 324
 		}
325 325
 
326 326
 	} else {
327 327
 
328
-		give_set_error( 'give-customer-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) );
329
-		$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' );
328
+		give_set_error('give-customer-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give'));
329
+		$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors');
330 330
 
331 331
 	}
332 332
 
333
-	wp_redirect( $redirect );
333
+	wp_redirect($redirect);
334 334
 	exit;
335 335
 
336 336
 }
337 337
 
338
-add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 );
338
+add_action('give_delete-customer', 'give_customer_delete', 10, 1);
339 339
 
340 340
 /**
341 341
  * Disconnect a user ID from a donor
@@ -346,39 +346,39 @@  discard block
 block discarded – undo
346 346
  *
347 347
  * @return bool        If the disconnect was successful
348 348
  */
349
-function give_disconnect_customer_user_id( $args ) {
349
+function give_disconnect_customer_user_id($args) {
350 350
 
351
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
351
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
352 352
 
353
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
354
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ) );
353
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
354
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'));
355 355
 	}
356 356
 
357
-	if ( empty( $args ) ) {
357
+	if (empty($args)) {
358 358
 		return;
359 359
 	}
360 360
 
361 361
 	$customer_id = (int) $args['customer_id'];
362 362
 	$nonce       = $args['_wpnonce'];
363 363
 
364
-	if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) {
365
-		wp_die( esc_html__( 'Cheatin\' eh?!', 'give' ) );
364
+	if ( ! wp_verify_nonce($nonce, 'edit-customer')) {
365
+		wp_die(esc_html__('Cheatin\' eh?!', 'give'));
366 366
 	}
367 367
 
368
-	$customer = new Give_Customer( $customer_id );
369
-	if ( empty( $customer->id ) ) {
368
+	$customer = new Give_Customer($customer_id);
369
+	if (empty($customer->id)) {
370 370
 		return false;
371 371
 	}
372 372
 
373
-	do_action( 'give_pre_customer_disconnect_user_id', $customer_id, $customer->user_id );
373
+	do_action('give_pre_customer_disconnect_user_id', $customer_id, $customer->user_id);
374 374
 
375
-	$customer_args = array( 'user_id' => 0 );
375
+	$customer_args = array('user_id' => 0);
376 376
 
377
-	if ( $customer->update( $customer_args ) ) {
377
+	if ($customer->update($customer_args)) {
378 378
 		global $wpdb;
379 379
 
380
-		if ( ! empty( $customer->payment_ids ) ) {
381
-			$wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )" );
380
+		if ( ! empty($customer->payment_ids)) {
381
+			$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )");
382 382
 		}
383 383
 
384 384
 		$output['success'] = true;
@@ -386,14 +386,14 @@  discard block
 block discarded – undo
386 386
 	} else {
387 387
 
388 388
 		$output['success'] = false;
389
-		give_set_error( 'give-disconnect-user-fail', esc_html__( 'Failed to disconnect user from donor.', 'give' ) );
389
+		give_set_error('give-disconnect-user-fail', esc_html__('Failed to disconnect user from donor.', 'give'));
390 390
 	}
391 391
 
392
-	do_action( 'give_post_customer_disconnect_user_id', $customer_id );
392
+	do_action('give_post_customer_disconnect_user_id', $customer_id);
393 393
 
394
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
395
-		header( 'Content-Type: application/json' );
396
-		echo json_encode( $output );
394
+	if (defined('DOING_AJAX') && DOING_AJAX) {
395
+		header('Content-Type: application/json');
396
+		echo json_encode($output);
397 397
 		wp_die();
398 398
 	}
399 399
 
@@ -401,4 +401,4 @@  discard block
 block discarded – undo
401 401
 
402 402
 }
403 403
 
404
-add_action( 'give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1 );
404
+add_action('give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1);
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Spacing   +65 added lines, -65 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
 
@@ -29,31 +29,31 @@  discard block
 block discarded – undo
29 29
 	global $give_settings_page, $give_payments_page, $give_reports_page, $give_add_ons_page, $give_upgrades_screen, $give_donors_page;
30 30
 
31 31
 	//Payments
32
-	$give_payment       = get_post_type_object( 'give_payment' );
33
-	$give_payments_page = add_submenu_page( 'edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page' );
32
+	$give_payment       = get_post_type_object('give_payment');
33
+	$give_payments_page = add_submenu_page('edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page');
34 34
 
35 35
 	//Donors
36
-	$give_donors_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Donors', 'give' ), esc_html__( 'Donors', 'give' ), 'view_give_reports', 'give-donors', 'give_customers_page' );
36
+	$give_donors_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Donors', 'give'), esc_html__('Donors', 'give'), 'view_give_reports', 'give-donors', 'give_customers_page');
37 37
 
38 38
 	//Reports`
39
-	$give_reports_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Donation Reports', 'give' ), esc_html__( 'Reports', 'give' ), 'view_give_reports', 'give-reports', 'give_reports_page' );
39
+	$give_reports_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Donation Reports', 'give'), esc_html__('Reports', 'give'), 'view_give_reports', 'give-reports', 'give_reports_page');
40 40
 
41 41
 	//Settings
42
-	$give_settings_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Settings', 'give' ), esc_html__( 'Settings', 'give' ), 'manage_give_settings', 'give-settings', array(
42
+	$give_settings_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Settings', 'give'), esc_html__('Settings', 'give'), 'manage_give_settings', 'give-settings', array(
43 43
 		Give()->give_settings,
44 44
 		'admin_page_display'
45
-	) );
45
+	));
46 46
 
47 47
 	//Add-ons
48
-	$give_add_ons_page = add_submenu_page( 'edit.php?post_type=give_forms', esc_html__( 'Give Add-ons', 'give' ), esc_html__( 'Add-ons', 'give' ), 'install_plugins', 'give-addons', 'give_add_ons_page' );
48
+	$give_add_ons_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Add-ons', 'give'), esc_html__('Add-ons', 'give'), 'install_plugins', 'give-addons', 'give_add_ons_page');
49 49
 
50 50
 	//Upgrades
51
-	$give_upgrades_screen = add_submenu_page( null, esc_html__( 'Give Upgrades', 'give' ), esc_html__( 'Give Upgrades', 'give' ), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen' );
51
+	$give_upgrades_screen = add_submenu_page(null, esc_html__('Give Upgrades', 'give'), esc_html__('Give Upgrades', 'give'), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen');
52 52
 
53 53
 
54 54
 }
55 55
 
56
-add_action( 'admin_menu', 'give_add_options_links', 10 );
56
+add_action('admin_menu', 'give_add_options_links', 10);
57 57
 
58 58
 /**
59 59
  *  Determines whether the current admin page is a Give admin page.
@@ -68,224 +68,224 @@  discard block
 block discarded – undo
68 68
  *
69 69
  * @return bool True if Give admin page.
70 70
  */
71
-function give_is_admin_page( $passed_page = '', $passed_view = '' ) {
71
+function give_is_admin_page($passed_page = '', $passed_view = '') {
72 72
 
73 73
 	global $pagenow, $typenow;
74 74
 
75 75
 	$found     = false;
76
-	$post_type = isset( $_GET['post_type'] ) ? strtolower( $_GET['post_type'] ) : false;
77
-	$action    = isset( $_GET['action'] ) ? strtolower( $_GET['action'] ) : false;
78
-	$taxonomy  = isset( $_GET['taxonomy'] ) ? strtolower( $_GET['taxonomy'] ) : false;
79
-	$page      = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
80
-	$view      = isset( $_GET['view'] ) ? strtolower( $_GET['view'] ) : false;
81
-	$tab       = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : false;
76
+	$post_type = isset($_GET['post_type']) ? strtolower($_GET['post_type']) : false;
77
+	$action    = isset($_GET['action']) ? strtolower($_GET['action']) : false;
78
+	$taxonomy  = isset($_GET['taxonomy']) ? strtolower($_GET['taxonomy']) : false;
79
+	$page      = isset($_GET['page']) ? strtolower($_GET['page']) : false;
80
+	$view      = isset($_GET['view']) ? strtolower($_GET['view']) : false;
81
+	$tab       = isset($_GET['tab']) ? strtolower($_GET['tab']) : false;
82 82
 
83
-	switch ( $passed_page ) {
83
+	switch ($passed_page) {
84 84
 		case 'give_forms':
85
-			switch ( $passed_view ) {
85
+			switch ($passed_view) {
86 86
 				case 'list-table':
87
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' ) {
87
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php') {
88 88
 						$found = true;
89 89
 					}
90 90
 					break;
91 91
 				case 'edit':
92
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post.php' ) {
92
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post.php') {
93 93
 						$found = true;
94 94
 					}
95 95
 					break;
96 96
 				case 'new':
97
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'post-new.php' ) {
97
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'post-new.php') {
98 98
 						$found = true;
99 99
 					}
100 100
 					break;
101 101
 				default:
102
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) || 'give_forms' === $post_type || ( 'post-new.php' == $pagenow && 'give_forms' === $post_type ) ) {
102
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) || 'give_forms' === $post_type || ('post-new.php' == $pagenow && 'give_forms' === $post_type)) {
103 103
 						$found = true;
104 104
 					}
105 105
 					break;
106 106
 			}
107 107
 			break;
108 108
 		case 'categories':
109
-			switch ( $passed_view ) {
109
+			switch ($passed_view) {
110 110
 				case 'list-table':
111 111
 				case 'new':
112
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy ) {
112
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_category' === $taxonomy) {
113 113
 						$found = true;
114 114
 					}
115 115
 					break;
116 116
 				case 'edit':
117
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy ) {
117
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_category' === $taxonomy) {
118 118
 						$found = true;
119 119
 					}
120 120
 					break;
121 121
 				default:
122
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy ) {
122
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_category' === $taxonomy) {
123 123
 						$found = true;
124 124
 					}
125 125
 					break;
126 126
 			}
127 127
 			break;
128 128
 		case 'tags':
129
-			switch ( $passed_view ) {
129
+			switch ($passed_view) {
130 130
 				case 'list-table':
131 131
 				case 'new':
132
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy ) {
132
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' !== $action && 'give_forms_tag' === $taxonomy) {
133 133
 						$found = true;
134 134
 					}
135 135
 					break;
136 136
 				case 'edit':
137
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy ) {
137
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'edit' === $action && 'give_forms_tag' === $taxonomy) {
138 138
 						$found = true;
139 139
 					}
140 140
 					break;
141 141
 				default:
142
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy ) {
142
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit-tags.php' && 'give_forms_tag' === $taxonomy) {
143 143
 						$found = true;
144 144
 					}
145 145
 					break;
146 146
 			}
147 147
 			break;
148 148
 		case 'payments':
149
-			switch ( $passed_view ) {
149
+			switch ($passed_view) {
150 150
 				case 'list-table':
151
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view ) {
151
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && false === $view) {
152 152
 						$found = true;
153 153
 					}
154 154
 					break;
155 155
 				case 'edit':
156
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view ) {
156
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page && 'view-order-details' === $view) {
157 157
 						$found = true;
158 158
 					}
159 159
 					break;
160 160
 				default:
161
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-payment-history' === $page ) {
161
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-payment-history' === $page) {
162 162
 						$found = true;
163 163
 					}
164 164
 					break;
165 165
 			}
166 166
 			break;
167 167
 		case 'reports':
168
-			switch ( $passed_view ) {
168
+			switch ($passed_view) {
169 169
 				// If you want to do something like enqueue a script on a particular report's duration, look at $_GET[ 'range' ]
170 170
 				case 'earnings':
171
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && ( 'earnings' === $view || '-1' === $view || false === $view ) ) {
171
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && ('earnings' === $view || '-1' === $view || false === $view)) {
172 172
 						$found = true;
173 173
 					}
174 174
 					break;
175 175
 				case 'donors':
176
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view ) {
176
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'customers' === $view) {
177 177
 						$found = true;
178 178
 					}
179 179
 					break;
180 180
 				case 'gateways':
181
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view ) {
181
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'gateways' === $view) {
182 182
 						$found = true;
183 183
 					}
184 184
 					break;
185 185
 				case 'export':
186
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view ) {
186
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'export' === $view) {
187 187
 						$found = true;
188 188
 					}
189 189
 					break;
190 190
 				case 'logs':
191
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view ) {
191
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page && 'logs' === $view) {
192 192
 						$found = true;
193 193
 					}
194 194
 					break;
195 195
 				default:
196
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) {
196
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) {
197 197
 						$found = true;
198 198
 					}
199 199
 					break;
200 200
 			}
201 201
 			break;
202 202
 		case 'settings':
203
-			switch ( $passed_view ) {
203
+			switch ($passed_view) {
204 204
 				case 'general':
205
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && ( 'general' === $tab || false === $tab ) ) {
205
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && ('general' === $tab || false === $tab)) {
206 206
 						$found = true;
207 207
 					}
208 208
 					break;
209 209
 				case 'gateways':
210
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab ) {
210
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'gateways' === $tab) {
211 211
 						$found = true;
212 212
 					}
213 213
 					break;
214 214
 				case 'emails':
215
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab ) {
215
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'emails' === $tab) {
216 216
 						$found = true;
217 217
 					}
218 218
 					break;
219 219
 				case 'display':
220
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab ) {
220
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'display' === $tab) {
221 221
 						$found = true;
222 222
 					}
223 223
 					break;
224 224
 				case 'licenses':
225
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab ) {
225
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'licenses' === $tab) {
226 226
 						$found = true;
227 227
 					}
228 228
 					break;
229 229
 				case 'api':
230
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab ) {
230
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'api' === $tab) {
231 231
 						$found = true;
232 232
 					}
233 233
 					break;
234 234
 				case 'advanced':
235
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab ) {
235
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'advanced' === $tab) {
236 236
 						$found = true;
237 237
 					}
238 238
 					break;
239 239
 				case 'system_info':
240
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab ) {
240
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page && 'system_info' === $tab) {
241 241
 						$found = true;
242 242
 					}
243 243
 					break;
244 244
 				default:
245
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-settings' === $page ) {
245
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-settings' === $page) {
246 246
 						$found = true;
247 247
 					}
248 248
 					break;
249 249
 			}
250 250
 			break;
251 251
 		case 'addons':
252
-			if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-addons' === $page ) {
252
+			if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-addons' === $page) {
253 253
 				$found = true;
254 254
 			}
255 255
 			break;
256 256
 		case 'donors':
257
-			switch ( $passed_view ) {
257
+			switch ($passed_view) {
258 258
 				case 'list-table':
259
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view ) {
259
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && false === $view) {
260 260
 						$found = true;
261 261
 					}
262 262
 					break;
263 263
 				case 'overview':
264
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view ) {
264
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'overview' === $view) {
265 265
 						$found = true;
266 266
 					}
267 267
 					break;
268 268
 				case 'notes':
269
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view ) {
269
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page && 'notes' === $view) {
270 270
 						$found = true;
271 271
 					}
272 272
 					break;
273 273
 				default:
274
-					if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-donors' === $page ) {
274
+					if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-donors' === $page) {
275 275
 						$found = true;
276 276
 					}
277 277
 					break;
278 278
 			}
279 279
 			break;
280 280
 		case 'reports':
281
-			if ( ( 'give_forms' == $typenow || 'give_forms' === $post_type ) && $pagenow == 'edit.php' && 'give-reports' === $page ) {
281
+			if (('give_forms' == $typenow || 'give_forms' === $post_type) && $pagenow == 'edit.php' && 'give-reports' === $page) {
282 282
 				$found = true;
283 283
 			}
284 284
 			break;
285 285
 		default:
286 286
 			global $give_payments_page, $give_settings_page, $give_reports_page, $give_system_info_page, $give_add_ons_page, $give_settings_export, $give_upgrades_screen, $give_customers_page;
287 287
 
288
-			$admin_pages = apply_filters( 'give_admin_pages', array(
288
+			$admin_pages = apply_filters('give_admin_pages', array(
289 289
 				$give_payments_page,
290 290
 				$give_settings_page,
291 291
 				$give_reports_page,
@@ -294,18 +294,18 @@  discard block
 block discarded – undo
294 294
 				$give_upgrades_screen,
295 295
 				$give_settings_export,
296 296
 				$give_customers_page
297
-			) );
298
-			if ( 'give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow ) {
297
+			));
298
+			if ('give_forms' == $typenow || 'index.php' == $pagenow || 'post-new.php' == $pagenow || 'post.php' == $pagenow) {
299 299
 				$found = true;
300
-				if ( 'give-upgrades' === $page ) {
300
+				if ('give-upgrades' === $page) {
301 301
 					$found = false;
302 302
 				}
303
-			} elseif ( in_array( $pagenow, $admin_pages ) ) {
303
+			} elseif (in_array($pagenow, $admin_pages)) {
304 304
 				$found = true;
305 305
 			}
306 306
 			break;
307 307
 	}
308 308
 
309
-	return (bool) apply_filters( 'give_is_admin_page', $found, $page, $view, $passed_page, $passed_view );
309
+	return (bool) apply_filters('give_is_admin_page', $found, $page, $view, $passed_page, $passed_view);
310 310
 
311 311
 }
312 312
\ No newline at end of file
Please login to merge, or discard this patch.
includes/payments/actions.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
 
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * @return void
30 30
  */
31
-function give_complete_purchase( $payment_id, $new_status, $old_status ) {
31
+function give_complete_purchase($payment_id, $new_status, $old_status) {
32 32
 
33 33
 	// Make sure that payments are only completed once
34
-	if ( $old_status == 'publish' || $old_status == 'complete' ) {
34
+	if ($old_status == 'publish' || $old_status == 'complete') {
35 35
 		return;
36 36
 	}
37 37
 
38 38
 	// Make sure the payment completion is only processed when new status is complete
39
-	if ( $new_status != 'publish' && $new_status != 'complete' ) {
39
+	if ($new_status != 'publish' && $new_status != 'complete') {
40 40
 		return;
41 41
 	}
42 42
 	
43
-	$payment = new Give_Payment( $payment_id );
43
+	$payment = new Give_Payment($payment_id);
44 44
 
45
-	$creation_date  = get_post_field( 'post_date', $payment_id, 'raw' );
45
+	$creation_date  = get_post_field('post_date', $payment_id, 'raw');
46 46
 	$payment_meta   = $payment->payment_meta;
47 47
 	$completed_date = $payment->completed_date;
48 48
 	$user_info      = $payment->user_info;
@@ -51,45 +51,45 @@  discard block
 block discarded – undo
51 51
 	$price_id       = $payment->price_id;
52 52
 	$form_id        = $payment->form_id;
53 53
 
54
-	do_action( 'give_pre_complete_purchase', $payment_id );
54
+	do_action('give_pre_complete_purchase', $payment_id);
55 55
 
56 56
 	// Ensure these actions only run once, ever
57
-	if ( empty( $completed_date ) ) {
57
+	if (empty($completed_date)) {
58 58
 
59
-		give_record_sale_in_log( $form_id, $payment_id, $price_id, $creation_date );
60
-		do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta );
59
+		give_record_sale_in_log($form_id, $payment_id, $price_id, $creation_date);
60
+		do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta);
61 61
 
62 62
 	}
63 63
 
64 64
 	// Increase the earnings for this form ID
65
-	give_increase_earnings( $form_id, $amount );
66
-	give_increase_purchase_count( $form_id );
65
+	give_increase_earnings($form_id, $amount);
66
+	give_increase_purchase_count($form_id);
67 67
 
68 68
 	// Clear the total earnings cache
69
-	delete_transient( 'give_earnings_total' );
69
+	delete_transient('give_earnings_total');
70 70
 	// Clear the This Month earnings (this_monththis_month is NOT a typo)
71
-	delete_transient( md5( 'give_earnings_this_monththis_month' ) );
72
-	delete_transient( md5( 'give_earnings_todaytoday' ) );
71
+	delete_transient(md5('give_earnings_this_monththis_month'));
72
+	delete_transient(md5('give_earnings_todaytoday'));
73 73
 	
74 74
 	// Increase the donor's purchase stats
75
-	$customer = new Give_Customer( $customer_id );
75
+	$customer = new Give_Customer($customer_id);
76 76
 	$customer->increase_purchase_count();
77
-	$customer->increase_value( $amount );
77
+	$customer->increase_value($amount);
78 78
 
79
-	give_increase_total_earnings( $amount );
79
+	give_increase_total_earnings($amount);
80 80
 
81 81
 	// Ensure this action only runs once ever
82
-	if ( empty( $completed_date ) ) {
82
+	if (empty($completed_date)) {
83 83
 
84 84
 		// Save the completed date
85
-		$payment->completed_date = current_time( 'mysql' );
85
+		$payment->completed_date = current_time('mysql');
86 86
 		$payment->save();
87
-		do_action( 'give_complete_purchase', $payment_id );
87
+		do_action('give_complete_purchase', $payment_id);
88 88
 	}
89 89
 
90 90
 }
91 91
 
92
-add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 );
92
+add_action('give_update_payment_status', 'give_complete_purchase', 100, 3);
93 93
 
94 94
 
95 95
 /**
@@ -103,24 +103,24 @@  discard block
 block discarded – undo
103 103
  *
104 104
  * @return void
105 105
  */
106
-function give_record_status_change( $payment_id, $new_status, $old_status ) {
106
+function give_record_status_change($payment_id, $new_status, $old_status) {
107 107
 
108 108
 	// Get the list of statuses so that status in the payment note can be translated
109 109
 	$stati      = give_get_payment_statuses();
110
-	$old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status;
111
-	$new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status;
110
+	$old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status;
111
+	$new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status;
112 112
 
113 113
 	$status_change = sprintf(
114 114
 		/* translators: 1: old status 2: new status */
115
-		esc_html__( 'Status changed from %1$s to %2$s.', 'give' ),
115
+		esc_html__('Status changed from %1$s to %2$s.', 'give'),
116 116
 		$old_status,
117 117
 		$new_status
118 118
 	);
119 119
 
120
-	give_insert_payment_note( $payment_id, $status_change );
120
+	give_insert_payment_note($payment_id, $status_change);
121 121
 }
122 122
 
123
-add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 );
123
+add_action('give_update_payment_status', 'give_record_status_change', 100, 3);
124 124
 
125 125
 
126 126
 /**
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
  * @param $new_status the status of the payment, probably "publish"
134 134
  * @param $old_status the status of the payment prior to being marked as "complete", probably "pending"
135 135
  */
136
-function give_clear_user_history_cache( $payment_id, $new_status, $old_status ) {
136
+function give_clear_user_history_cache($payment_id, $new_status, $old_status) {
137 137
 
138
-	$payment = new Give_Payment( $payment_id );
138
+	$payment = new Give_Payment($payment_id);
139 139
 
140
-	if ( ! empty( $payment->user_id ) ) {
141
-		delete_transient( 'give_user_' . $payment->user_id . '_purchases' );
140
+	if ( ! empty($payment->user_id)) {
141
+		delete_transient('give_user_'.$payment->user_id.'_purchases');
142 142
 	}
143 143
 
144 144
 }
145 145
 
146
-add_action( 'give_update_payment_status', 'give_clear_user_history_cache', 10, 3 );
146
+add_action('give_update_payment_status', 'give_clear_user_history_cache', 10, 3);
147 147
 
148 148
 /**
149 149
  * Updates all old payments, prior to 1.2, with new
@@ -157,25 +157,25 @@  discard block
 block discarded – undo
157 157
  *
158 158
  * @return void
159 159
  */
160
-function give_update_old_payments_with_totals( $data ) {
161
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) {
160
+function give_update_old_payments_with_totals($data) {
161
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) {
162 162
 		return;
163 163
 	}
164 164
 
165
-	if ( get_option( 'give_payment_totals_upgraded' ) ) {
165
+	if (get_option('give_payment_totals_upgraded')) {
166 166
 		return;
167 167
 	}
168 168
 
169
-	$payments = give_get_payments( array(
169
+	$payments = give_get_payments(array(
170 170
 		'offset' => 0,
171
-		'number' => - 1,
171
+		'number' => -1,
172 172
 		'mode'   => 'all'
173
-	) );
173
+	));
174 174
 
175
-	if ( $payments ) {
176
-		foreach ( $payments as $payment ) {
175
+	if ($payments) {
176
+		foreach ($payments as $payment) {
177 177
 
178
-			$payment = new Give_Payment( $payment->ID );
178
+			$payment = new Give_Payment($payment->ID);
179 179
 			$meta    = $payment->get_meta();
180 180
 
181 181
 			$payment->total = $meta['amount'];
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
 		}
185 185
 	}
186 186
 
187
-	add_option( 'give_payment_totals_upgraded', 1 );
187
+	add_option('give_payment_totals_upgraded', 1);
188 188
 }
189 189
 
190
-add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' );
190
+add_action('give_upgrade_payments', 'give_update_old_payments_with_totals');
191 191
 
192 192
 /**
193 193
  * Updates week-old+ 'pending' orders to 'abandoned'
@@ -198,21 +198,21 @@  discard block
 block discarded – undo
198 198
 function give_mark_abandoned_donations() {
199 199
 	$args = array(
200 200
 		'status' => 'pending',
201
-		'number' => - 1,
201
+		'number' => -1,
202 202
 		'output' => 'give_payments',
203 203
 	);
204 204
 
205
-	add_filter( 'posts_where', 'give_filter_where_older_than_week' );
205
+	add_filter('posts_where', 'give_filter_where_older_than_week');
206 206
 
207
-	$payments = give_get_payments( $args );
207
+	$payments = give_get_payments($args);
208 208
 
209
-	remove_filter( 'posts_where', 'give_filter_where_older_than_week' );
209
+	remove_filter('posts_where', 'give_filter_where_older_than_week');
210 210
 
211
-	if ( $payments ) {
212
-		foreach ( $payments as $payment ) {
213
-			$gateway = give_get_payment_gateway( $payment );
211
+	if ($payments) {
212
+		foreach ($payments as $payment) {
213
+			$gateway = give_get_payment_gateway($payment);
214 214
 			//Skip offline gateway payments
215
-			if ( $gateway == 'offline' ) {
215
+			if ($gateway == 'offline') {
216 216
 				continue;
217 217
 			}
218 218
 			$payment->status = 'abandoned';
@@ -221,4 +221,4 @@  discard block
 block discarded – undo
221 221
 	}
222 222
 }
223 223
 
224
-add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' );
225 224
\ No newline at end of file
225
+add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations');
226 226
\ No newline at end of file
Please login to merge, or discard this patch.
includes/emails/class-give-emails.php 1 patch
Spacing   +58 added lines, -58 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
 
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function __construct() {
81 81
 
82
-		if ( 'none' === $this->get_template() ) {
82
+		if ('none' === $this->get_template()) {
83 83
 			$this->html = false;
84 84
 		}
85 85
 
86
-		add_action( 'give_email_send_before', array( $this, 'send_before' ) );
87
-		add_action( 'give_email_send_after', array( $this, 'send_after' ) );
86
+		add_action('give_email_send_before', array($this, 'send_before'));
87
+		add_action('give_email_send_after', array($this, 'send_after'));
88 88
 
89 89
 	}
90 90
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 *
94 94
 	 * @since 1.0
95 95
 	 */
96
-	public function __set( $key, $value ) {
96
+	public function __set($key, $value) {
97 97
 		$this->$key = $value;
98 98
 	}
99 99
 
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 	 * @since 1.0
104 104
 	 */
105 105
 	public function get_from_name() {
106
-		if ( ! $this->from_name ) {
107
-			$this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) );
106
+		if ( ! $this->from_name) {
107
+			$this->from_name = give_get_option('from_name', get_bloginfo('name'));
108 108
 		}
109 109
 
110
-		return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this );
110
+		return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this);
111 111
 	}
112 112
 
113 113
 	/**
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 	 * @since 1.0
117 117
 	 */
118 118
 	public function get_from_address() {
119
-		if ( ! $this->from_address ) {
120
-			$this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) );
119
+		if ( ! $this->from_address) {
120
+			$this->from_address = give_get_option('from_email', get_option('admin_email'));
121 121
 		}
122 122
 
123
-		return apply_filters( 'give_email_from_address', $this->from_address, $this );
123
+		return apply_filters('give_email_from_address', $this->from_address, $this);
124 124
 	}
125 125
 
126 126
 	/**
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	 * @since 1.0
130 130
 	 */
131 131
 	public function get_content_type() {
132
-		if ( ! $this->content_type && $this->html ) {
133
-			$this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this );
134
-		} else if ( ! $this->html ) {
132
+		if ( ! $this->content_type && $this->html) {
133
+			$this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this);
134
+		} else if ( ! $this->html) {
135 135
 			$this->content_type = 'text/plain';
136 136
 		}
137 137
 
138
-		return apply_filters( 'give_email_content_type', $this->content_type, $this );
138
+		return apply_filters('give_email_content_type', $this->content_type, $this);
139 139
 	}
140 140
 
141 141
 	/**
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 	 * @since 1.0
145 145
 	 */
146 146
 	public function get_headers() {
147
-		if ( ! $this->headers ) {
147
+		if ( ! $this->headers) {
148 148
 			$this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n";
149 149
 			$this->headers .= "Reply-To: {$this->get_from_address()}\r\n";
150 150
 			$this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n";
151 151
 		}
152 152
 
153
-		return apply_filters( 'give_email_headers', $this->headers, $this );
153
+		return apply_filters('give_email_headers', $this->headers, $this);
154 154
 	}
155 155
 
156 156
 	/**
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function get_templates() {
162 162
 		$templates = array(
163
-			'default' => esc_html__( 'Default Template', 'give' ),
164
-			'none'    => esc_html__( 'No template, plain text only', 'give' )
163
+			'default' => esc_html__('Default Template', 'give'),
164
+			'none'    => esc_html__('No template, plain text only', 'give')
165 165
 		);
166 166
 
167
-		return apply_filters( 'give_email_templates', $templates );
167
+		return apply_filters('give_email_templates', $templates);
168 168
 	}
169 169
 
170 170
 	/**
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 	 * @since 1.0
174 174
 	 */
175 175
 	public function get_template() {
176
-		if ( ! $this->template ) {
177
-			$this->template = give_get_option( 'email_template', 'default' );
176
+		if ( ! $this->template) {
177
+			$this->template = give_get_option('email_template', 'default');
178 178
 		}
179 179
 
180
-		return apply_filters( 'give_email_template', $this->template );
180
+		return apply_filters('give_email_template', $this->template);
181 181
 	}
182 182
 
183 183
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @since 1.0
187 187
 	 */
188 188
 	public function get_heading() {
189
-		return apply_filters( 'give_email_heading', $this->heading );
189
+		return apply_filters('give_email_heading', $this->heading);
190 190
 	}
191 191
 
192 192
 	/**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @return mixed
198 198
 	 */
199
-	public function parse_tags( $content ) {
199
+	public function parse_tags($content) {
200 200
 		return $content;
201 201
 	}
202 202
 
@@ -205,36 +205,36 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @since 1.0
207 207
 	 */
208
-	public function build_email( $message ) {
208
+	public function build_email($message) {
209 209
 
210
-		if ( false === $this->html ) {
211
-			return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this );
210
+		if (false === $this->html) {
211
+			return apply_filters('give_email_message', wp_strip_all_tags($message), $this);
212 212
 		}
213 213
 
214
-		$message = $this->text_to_html( $message );
214
+		$message = $this->text_to_html($message);
215 215
 
216 216
 		ob_start();
217 217
 
218
-		give_get_template_part( 'emails/header', $this->get_template(), true );
218
+		give_get_template_part('emails/header', $this->get_template(), true);
219 219
 
220
-		do_action( 'give_email_header', $this );
220
+		do_action('give_email_header', $this);
221 221
 
222
-		if ( has_action( 'give_email_template_' . $this->get_template() ) ) {
223
-			do_action( 'give_email_template_' . $this->get_template() );
222
+		if (has_action('give_email_template_'.$this->get_template())) {
223
+			do_action('give_email_template_'.$this->get_template());
224 224
 		} else {
225
-			give_get_template_part( 'emails/body', $this->get_template(), true );
225
+			give_get_template_part('emails/body', $this->get_template(), true);
226 226
 		}
227 227
 
228
-		do_action( 'give_email_body', $this );
228
+		do_action('give_email_body', $this);
229 229
 
230
-		give_get_template_part( 'emails/footer', $this->get_template(), true );
230
+		give_get_template_part('emails/footer', $this->get_template(), true);
231 231
 
232
-		do_action( 'give_email_footer', $this );
232
+		do_action('give_email_footer', $this);
233 233
 
234 234
 		$body    = ob_get_clean();
235
-		$message = str_replace( '{email}', $message, $body );
235
+		$message = str_replace('{email}', $message, $body);
236 236
 
237
-		return apply_filters( 'give_email_message', $message, $this );
237
+		return apply_filters('give_email_message', $message, $this);
238 238
 	}
239 239
 
240 240
 	/**
@@ -247,26 +247,26 @@  discard block
 block discarded – undo
247 247
 	 *
248 248
 	 * @return bool
249 249
 	 */
250
-	public function send( $to, $subject, $message, $attachments = '' ) {
250
+	public function send($to, $subject, $message, $attachments = '') {
251 251
 
252
-		if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) {
253
-			_doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null );
252
+		if ( ! did_action('init') && ! did_action('admin_init')) {
253
+			_doing_it_wrong(__FUNCTION__, esc_html__('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null);
254 254
 
255 255
 			return false;
256 256
 		}
257 257
 
258
-		do_action( 'give_email_send_before', $this );
258
+		do_action('give_email_send_before', $this);
259 259
 
260
-		$subject = $this->parse_tags( $subject );
261
-		$message = $this->parse_tags( $message );
260
+		$subject = $this->parse_tags($subject);
261
+		$message = $this->parse_tags($message);
262 262
 
263
-		$message = $this->build_email( $message );
263
+		$message = $this->build_email($message);
264 264
 
265
-		$attachments = apply_filters( 'give_email_attachments', $attachments, $this );
265
+		$attachments = apply_filters('give_email_attachments', $attachments, $this);
266 266
 
267
-		$sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments );
267
+		$sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments);
268 268
 
269
-		do_action( 'give_email_send_after', $this );
269
+		do_action('give_email_send_after', $this);
270 270
 
271 271
 		return $sent;
272 272
 
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 	 * @since 1.0
279 279
 	 */
280 280
 	public function send_before() {
281
-		add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
282
-		add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
283
-		add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
281
+		add_filter('wp_mail_from', array($this, 'get_from_address'));
282
+		add_filter('wp_mail_from_name', array($this, 'get_from_name'));
283
+		add_filter('wp_mail_content_type', array($this, 'get_content_type'));
284 284
 	}
285 285
 
286 286
 	/**
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
 	 * @since 1.0
290 290
 	 */
291 291
 	public function send_after() {
292
-		remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
293
-		remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
294
-		remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
292
+		remove_filter('wp_mail_from', array($this, 'get_from_address'));
293
+		remove_filter('wp_mail_from_name', array($this, 'get_from_name'));
294
+		remove_filter('wp_mail_content_type', array($this, 'get_content_type'));
295 295
 
296 296
 		// Reset heading to an empty string
297 297
 		$this->heading = '';
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 	 *
303 303
 	 * @since 1.0
304 304
 	 */
305
-	public function text_to_html( $message ) {
305
+	public function text_to_html($message) {
306 306
 
307
-		if ( 'text/html' == $this->content_type || true === $this->html ) {
308
-			$message = wpautop( $message );
307
+		if ('text/html' == $this->content_type || true === $this->html) {
308
+			$message = wpautop($message);
309 309
 		}
310 310
 
311 311
 		return $message;
Please login to merge, or discard this patch.
includes/emails/actions.php 1 patch
Spacing   +18 added lines, -18 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,17 +23,17 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return void
25 25
  */
26
-function give_trigger_donation_receipt( $payment_id ) {
26
+function give_trigger_donation_receipt($payment_id) {
27 27
 	// Make sure we don't send a purchase receipt while editing a payment
28
-	if ( isset( $_POST['give-action'] ) && 'edit_payment' == $_POST['give-action'] ) {
28
+	if (isset($_POST['give-action']) && 'edit_payment' == $_POST['give-action']) {
29 29
 		return;
30 30
 	}
31 31
 
32 32
 	// Send email
33
-	give_email_donation_receipt( $payment_id );
33
+	give_email_donation_receipt($payment_id);
34 34
 }
35 35
 
36
-add_action( 'give_complete_purchase', 'give_trigger_donation_receipt', 999, 1 );
36
+add_action('give_complete_purchase', 'give_trigger_donation_receipt', 999, 1);
37 37
 
38 38
 /**
39 39
  * Resend the Email Purchase Receipt. (This can be done from the Payment History page)
@@ -44,29 +44,29 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @return void
46 46
  */
47
-function give_resend_donation_receipt( $data ) {
47
+function give_resend_donation_receipt($data) {
48 48
 
49
-	$purchase_id = absint( $data['purchase_id'] );
49
+	$purchase_id = absint($data['purchase_id']);
50 50
 
51
-	if ( empty( $purchase_id ) ) {
51
+	if (empty($purchase_id)) {
52 52
 		return;
53 53
 	}
54 54
 
55
-	if ( ! current_user_can( 'edit_give_payments', $purchase_id ) ) {
56
-		wp_die( esc_html__( 'You do not have permission to edit payment records.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
55
+	if ( ! current_user_can('edit_give_payments', $purchase_id)) {
56
+		wp_die(esc_html__('You do not have permission to edit payment records.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
57 57
 	}
58 58
 
59
-	give_email_donation_receipt( $purchase_id, false );
59
+	give_email_donation_receipt($purchase_id, false);
60 60
 
61
-	wp_redirect( add_query_arg( array(
61
+	wp_redirect(add_query_arg(array(
62 62
 		'give-message' => 'email_sent',
63 63
 		'give-action'  => false,
64 64
 		'purchase_id'  => false
65
-	) ) );
65
+	)));
66 66
 	exit;
67 67
 }
68 68
 
69
-add_action( 'give_email_links', 'give_resend_donation_receipt' );
69
+add_action('give_email_links', 'give_resend_donation_receipt');
70 70
 
71 71
 /**
72 72
  * Trigger the sending of a Test Email
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
  *
78 78
  * @return void
79 79
  */
80
-function give_send_test_email( $data ) {
81
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-test-email' ) ) {
80
+function give_send_test_email($data) {
81
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give-test-email')) {
82 82
 		return;
83 83
 	}
84 84
 
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 	give_email_test_donation_receipt();
87 87
 
88 88
 	// Remove the test email query arg
89
-	wp_redirect( remove_query_arg( 'give_action' ) );
89
+	wp_redirect(remove_query_arg('give_action'));
90 90
 	exit;
91 91
 }
92 92
 
93
-add_action( 'give_send_test_email', 'give_send_test_email' );
93
+add_action('give_send_test_email', 'give_send_test_email');
Please login to merge, or discard this patch.
includes/emails/class-give-email-tags.php 1 patch
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 // Exit if accessed directly
26
-if ( ! defined( 'ABSPATH' ) ) {
26
+if ( ! defined('ABSPATH')) {
27 27
 	exit;
28 28
 }
29 29
 
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 	 * @param string $tag Email tag to be replace in email
55 55
 	 * @param callable $func Hook to run when email tag is found
56 56
 	 */
57
-	public function add( $tag, $description, $func ) {
58
-		if ( is_callable( $func ) ) {
59
-			$this->tags[ $tag ] = array(
57
+	public function add($tag, $description, $func) {
58
+		if (is_callable($func)) {
59
+			$this->tags[$tag] = array(
60 60
 				'tag'         => $tag,
61 61
 				'description' => $description,
62 62
 				'func'        => $func
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @param string $tag Email tag to remove hook from
73 73
 	 */
74
-	public function remove( $tag ) {
75
-		unset( $this->tags[ $tag ] );
74
+	public function remove($tag) {
75
+		unset($this->tags[$tag]);
76 76
 	}
77 77
 
78 78
 	/**
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @return bool
86 86
 	 */
87
-	public function email_tag_exists( $tag ) {
88
-		return array_key_exists( $tag, $this->tags );
87
+	public function email_tag_exists($tag) {
88
+		return array_key_exists($tag, $this->tags);
89 89
 	}
90 90
 
91 91
 	/**
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return string Content with email tags filtered out.
111 111
 	 */
112
-	public function do_tags( $content, $payment_id ) {
112
+	public function do_tags($content, $payment_id) {
113 113
 
114 114
 		// Check if there is atleast one tag added
115
-		if ( empty( $this->tags ) || ! is_array( $this->tags ) ) {
115
+		if (empty($this->tags) || ! is_array($this->tags)) {
116 116
 			return $content;
117 117
 		}
118 118
 
119 119
 		$this->payment_id = $payment_id;
120 120
 
121
-		$new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content );
121
+		$new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content);
122 122
 
123 123
 		$this->payment_id = null;
124 124
 
@@ -134,17 +134,17 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @return mixed
136 136
 	 */
137
-	public function do_tag( $m ) {
137
+	public function do_tag($m) {
138 138
 
139 139
 		// Get tag
140 140
 		$tag = $m[1];
141 141
 
142 142
 		// Return tag if tag not set
143
-		if ( ! $this->email_tag_exists( $tag ) ) {
143
+		if ( ! $this->email_tag_exists($tag)) {
144 144
 			return $m[0];
145 145
 		}
146 146
 
147
-		return call_user_func( $this->tags[ $tag ]['func'], $this->payment_id, $tag );
147
+		return call_user_func($this->tags[$tag]['func'], $this->payment_id, $tag);
148 148
 	}
149 149
 
150 150
 }
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
  * @param string $description Description of the email tag added
159 159
  * @param callable $func Hook to run when email tag is found
160 160
  */
161
-function give_add_email_tag( $tag, $description, $func ) {
162
-	Give()->email_tags->add( $tag, $description, $func );
161
+function give_add_email_tag($tag, $description, $func) {
162
+	Give()->email_tags->add($tag, $description, $func);
163 163
 }
164 164
 
165 165
 /**
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
  *
170 170
  * @param string $tag Email tag to remove hook from
171 171
  */
172
-function give_remove_email_tag( $tag ) {
173
-	Give()->email_tags->remove( $tag );
172
+function give_remove_email_tag($tag) {
173
+	Give()->email_tags->remove($tag);
174 174
 }
175 175
 
176 176
 /**
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
  *
183 183
  * @return bool
184 184
  */
185
-function give_email_tag_exists( $tag ) {
186
-	return Give()->email_tags->email_tag_exists( $tag );
185
+function give_email_tag_exists($tag) {
186
+	return Give()->email_tags->email_tag_exists($tag);
187 187
 }
188 188
 
189 189
 /**
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
 	$email_tags = give_get_email_tags();
213 213
 
214 214
 	// Check
215
-	if ( count( $email_tags ) > 0 ) {
215
+	if (count($email_tags) > 0) {
216 216
 
217 217
 		// Loop
218
-		foreach ( $email_tags as $email_tag ) {
218
+		foreach ($email_tags as $email_tag) {
219 219
 
220 220
 			// Add email tag to list
221
-			$list .= '<code>{' . $email_tag['tag'] . '}</code> - ' . $email_tag['description'] . '<br/>';
221
+			$list .= '<code>{'.$email_tag['tag'].'}</code> - '.$email_tag['description'].'<br/>';
222 222
 
223 223
 		}
224 224
 
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return string Content with email tags filtered out.
240 240
  */
241
-function give_do_email_tags( $content, $payment_id ) {
241
+function give_do_email_tags($content, $payment_id) {
242 242
 
243 243
 	// Replace all tags
244
-	$content = Give()->email_tags->do_tags( $content, $payment_id );
244
+	$content = Give()->email_tags->do_tags($content, $payment_id);
245 245
 
246 246
 	// Maintaining backwards compatibility
247
-	$content = apply_filters( 'give_email_template_tags', $content, give_get_payment_meta( $payment_id ), $payment_id );
247
+	$content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id);
248 248
 
249 249
 	// Return content
250 250
 	return $content;
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
  * @since 1.0
257 257
  */
258 258
 function give_load_email_tags() {
259
-	do_action( 'give_add_email_tags' );
259
+	do_action('give_add_email_tags');
260 260
 }
261 261
 
262
-add_action( 'init', 'give_load_email_tags', - 999 );
262
+add_action('init', 'give_load_email_tags', - 999);
263 263
 
264 264
 /**
265 265
  * Add default Give email template tags
@@ -272,82 +272,82 @@  discard block
 block discarded – undo
272 272
 	$email_tags = array(
273 273
 		array(
274 274
 			'tag'         => 'donation',
275
-			'description' => esc_html__( 'The name of completed donation form and the donation level chosen if applicable.', 'give' ),
275
+			'description' => esc_html__('The name of completed donation form and the donation level chosen if applicable.', 'give'),
276 276
 			'function'    => 'give_email_tag_donation'
277 277
 		),
278 278
 		array(
279 279
 			'tag'         => 'name',
280
-			'description' => esc_html__( 'The donor\'s first name.', 'give' ),
280
+			'description' => esc_html__('The donor\'s first name.', 'give'),
281 281
 			'function'    => 'give_email_tag_first_name'
282 282
 		),
283 283
 		array(
284 284
 			'tag'         => 'fullname',
285
-			'description' => esc_html__( 'The donor\'s full name, first and last.', 'give' ),
285
+			'description' => esc_html__('The donor\'s full name, first and last.', 'give'),
286 286
 			'function'    => 'give_email_tag_fullname'
287 287
 		),
288 288
 		array(
289 289
 			'tag'         => 'username',
290
-			'description' => esc_html__( 'The donor\'s user name on the site, if they registered an account.', 'give' ),
290
+			'description' => esc_html__('The donor\'s user name on the site, if they registered an account.', 'give'),
291 291
 			'function'    => 'give_email_tag_username'
292 292
 		),
293 293
 		array(
294 294
 			'tag'         => 'user_email',
295
-			'description' => esc_html__( 'The donor\'s email address.', 'give' ),
295
+			'description' => esc_html__('The donor\'s email address.', 'give'),
296 296
 			'function'    => 'give_email_tag_user_email'
297 297
 		),
298 298
 		array(
299 299
 			'tag'         => 'billing_address',
300
-			'description' => esc_html__( 'The donor\'s billing address.', 'give' ),
300
+			'description' => esc_html__('The donor\'s billing address.', 'give'),
301 301
 			'function'    => 'give_email_tag_billing_address'
302 302
 		),
303 303
 		array(
304 304
 			'tag'         => 'date',
305
-			'description' => esc_html__( 'The date of the donation.', 'give' ),
305
+			'description' => esc_html__('The date of the donation.', 'give'),
306 306
 			'function'    => 'give_email_tag_date'
307 307
 		),
308 308
 		array(
309 309
 			'tag'         => 'price',
310
-			'description' => esc_html__( 'The total price of the donation.', 'give' ),
310
+			'description' => esc_html__('The total price of the donation.', 'give'),
311 311
 			'function'    => 'give_email_tag_price'
312 312
 		),
313 313
 		array(
314 314
 			'tag'         => 'payment_id',
315
-			'description' => esc_html__( 'The unique ID number for this donation.', 'give' ),
315
+			'description' => esc_html__('The unique ID number for this donation.', 'give'),
316 316
 			'function'    => 'give_email_tag_payment_id'
317 317
 		),
318 318
 		array(
319 319
 			'tag'         => 'receipt_id',
320
-			'description' => esc_html__( 'The unique ID number for this donation receipt.', 'give' ),
320
+			'description' => esc_html__('The unique ID number for this donation receipt.', 'give'),
321 321
 			'function'    => 'give_email_tag_receipt_id'
322 322
 		),
323 323
 		array(
324 324
 			'tag'         => 'payment_method',
325
-			'description' => esc_html__( 'The method of payment used for this donation.', 'give' ),
325
+			'description' => esc_html__('The method of payment used for this donation.', 'give'),
326 326
 			'function'    => 'give_email_tag_payment_method'
327 327
 		),
328 328
 		array(
329 329
 			'tag'         => 'sitename',
330
-			'description' => esc_html__( 'Your site name', 'give' ),
330
+			'description' => esc_html__('Your site name', 'give'),
331 331
 			'function'    => 'give_email_tag_sitename'
332 332
 		),
333 333
 		array(
334 334
 			'tag'         => 'receipt_link',
335
-			'description' => esc_html__( 'Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give' ),
335
+			'description' => esc_html__('Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give'),
336 336
 			'function'    => 'give_email_tag_receipt_link'
337 337
 		),
338 338
 	);
339 339
 
340 340
 	// Apply give_email_tags filter
341
-	$email_tags = apply_filters( 'give_email_tags', $email_tags );
341
+	$email_tags = apply_filters('give_email_tags', $email_tags);
342 342
 
343 343
 	// Add email tags
344
-	foreach ( $email_tags as $email_tag ) {
345
-		give_add_email_tag( $email_tag['tag'], $email_tag['description'], $email_tag['function'] );
344
+	foreach ($email_tags as $email_tag) {
345
+		give_add_email_tag($email_tag['tag'], $email_tag['description'], $email_tag['function']);
346 346
 	}
347 347
 
348 348
 }
349 349
 
350
-add_action( 'give_add_email_tags', 'give_setup_email_tags' );
350
+add_action('give_add_email_tags', 'give_setup_email_tags');
351 351
 
352 352
 
353 353
 /**
@@ -358,15 +358,15 @@  discard block
 block discarded – undo
358 358
  *
359 359
  * @return string name
360 360
  */
361
-function give_email_tag_first_name( $payment_id ) {
362
-	$payment   = new Give_Payment( $payment_id );
361
+function give_email_tag_first_name($payment_id) {
362
+	$payment   = new Give_Payment($payment_id);
363 363
 	$user_info = $payment->user_info;
364 364
 
365
-	if ( empty( $user_info ) ) {
365
+	if (empty($user_info)) {
366 366
 		return '';
367 367
 	}
368 368
 
369
-	$email_name = give_get_email_names( $user_info );
369
+	$email_name = give_get_email_names($user_info);
370 370
 
371 371
 	return $email_name['name'];
372 372
 }
@@ -379,15 +379,15 @@  discard block
 block discarded – undo
379 379
  *
380 380
  * @return string fullname
381 381
  */
382
-function give_email_tag_fullname( $payment_id ) {
383
-	$payment   = new Give_Payment( $payment_id );
382
+function give_email_tag_fullname($payment_id) {
383
+	$payment   = new Give_Payment($payment_id);
384 384
 	$user_info = $payment->user_info;
385 385
 
386
-	if ( empty( $user_info ) ) {
386
+	if (empty($user_info)) {
387 387
 		return '';
388 388
 	}
389 389
 
390
-	$email_name = give_get_email_names( $user_info );
390
+	$email_name = give_get_email_names($user_info);
391 391
 
392 392
 	return $email_name['fullname'];
393 393
 }
@@ -400,15 +400,15 @@  discard block
 block discarded – undo
400 400
  *
401 401
  * @return string username
402 402
  */
403
-function give_email_tag_username( $payment_id ) {
404
-	$payment   = new Give_Payment( $payment_id );
403
+function give_email_tag_username($payment_id) {
404
+	$payment   = new Give_Payment($payment_id);
405 405
 	$user_info = $payment->user_info;
406 406
 
407
-	if ( empty( $user_info ) ) {
407
+	if (empty($user_info)) {
408 408
 		return '';
409 409
 	}
410 410
 
411
-	$email_name = give_get_email_names( $user_info );
411
+	$email_name = give_get_email_names($user_info);
412 412
 
413 413
 	return $email_name['username'];
414 414
 }
@@ -421,8 +421,8 @@  discard block
 block discarded – undo
421 421
  *
422 422
  * @return string user_email
423 423
  */
424
-function give_email_tag_user_email( $payment_id ) {
425
-	$payment = new Give_Payment( $payment_id );
424
+function give_email_tag_user_email($payment_id) {
425
+	$payment = new Give_Payment($payment_id);
426 426
 
427 427
 	return $payment->email;
428 428
 }
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
  *
436 436
  * @return string billing_address
437 437
  */
438
-function give_email_tag_billing_address( $payment_id ) {
438
+function give_email_tag_billing_address($payment_id) {
439 439
 
440
-	$user_info    = give_get_payment_meta_user_info( $payment_id );
441
-	$user_address = ! empty( $user_info['address'] ) ? $user_info['address'] : array(
440
+	$user_info    = give_get_payment_meta_user_info($payment_id);
441
+	$user_address = ! empty($user_info['address']) ? $user_info['address'] : array(
442 442
 		'line1'   => '',
443 443
 		'line2'   => '',
444 444
 		'city'    => '',
@@ -447,11 +447,11 @@  discard block
 block discarded – undo
447 447
 		'zip'     => ''
448 448
 	);
449 449
 
450
-	$return = $user_address['line1'] . "\n";
451
-	if ( ! empty( $user_address['line2'] ) ) {
452
-		$return .= $user_address['line2'] . "\n";
450
+	$return = $user_address['line1']."\n";
451
+	if ( ! empty($user_address['line2'])) {
452
+		$return .= $user_address['line2']."\n";
453 453
 	}
454
-	$return .= $user_address['city'] . ' ' . $user_address['zip'] . ' ' . $user_address['state'] . "\n";
454
+	$return .= $user_address['city'].' '.$user_address['zip'].' '.$user_address['state']."\n";
455 455
 	$return .= $user_address['country'];
456 456
 
457 457
 	return $return;
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
  *
466 466
  * @return string date
467 467
  */
468
-function give_email_tag_date( $payment_id ) {
469
-	$payment = new Give_Payment( $payment_id );
468
+function give_email_tag_date($payment_id) {
469
+	$payment = new Give_Payment($payment_id);
470 470
 
471
-	return date_i18n( get_option( 'date_format' ), strtotime( $payment->date ) );
471
+	return date_i18n(get_option('date_format'), strtotime($payment->date));
472 472
 }
473 473
 
474 474
 /**
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
  *
480 480
  * @return string price
481 481
  */
482
-function give_email_tag_price( $payment_id ) {
483
-	$payment = new Give_Payment( $payment_id );
484
-	$price   = give_currency_filter( give_format_amount( $payment->total ), $payment->currency );
482
+function give_email_tag_price($payment_id) {
483
+	$payment = new Give_Payment($payment_id);
484
+	$price   = give_currency_filter(give_format_amount($payment->total), $payment->currency);
485 485
 
486
-	return html_entity_decode( $price, ENT_COMPAT, 'UTF-8' );
486
+	return html_entity_decode($price, ENT_COMPAT, 'UTF-8');
487 487
 }
488 488
 
489 489
 /**
@@ -494,8 +494,8 @@  discard block
 block discarded – undo
494 494
  *
495 495
  * @return int payment_id
496 496
  */
497
-function give_email_tag_payment_id( $payment_id ) {
498
-	$payment = new Give_Payment( $payment_id );
497
+function give_email_tag_payment_id($payment_id) {
498
+	$payment = new Give_Payment($payment_id);
499 499
 
500 500
 	return $payment->number;
501 501
 }
@@ -508,8 +508,8 @@  discard block
 block discarded – undo
508 508
  *
509 509
  * @return string receipt_id
510 510
  */
511
-function give_email_tag_receipt_id( $payment_id ) {
512
-	$payment = new Give_Payment( $payment_id );
511
+function give_email_tag_receipt_id($payment_id) {
512
+	$payment = new Give_Payment($payment_id);
513 513
 
514 514
 	return $payment->key;
515 515
 }
@@ -523,11 +523,11 @@  discard block
 block discarded – undo
523 523
  *
524 524
  * @return string $form_title
525 525
  */
526
-function give_email_tag_donation( $payment_id ) {
527
-	$payment    = new Give_Payment( $payment_id );
528
-	$form_title = strip_tags( give_get_payment_form_title( $payment->meta, false, '-' ) );
526
+function give_email_tag_donation($payment_id) {
527
+	$payment    = new Give_Payment($payment_id);
528
+	$form_title = strip_tags(give_get_payment_form_title($payment->meta, false, '-'));
529 529
 
530
-	return ! empty( $form_title ) ? $form_title : esc_html__( 'There was an error retrieving this donation title.', 'give' );
530
+	return ! empty($form_title) ? $form_title : esc_html__('There was an error retrieving this donation title.', 'give');
531 531
 
532 532
 }
533 533
 
@@ -539,10 +539,10 @@  discard block
 block discarded – undo
539 539
  *
540 540
  * @return string gateway
541 541
  */
542
-function give_email_tag_payment_method( $payment_id ) {
543
-	$payment = new Give_Payment( $payment_id );
542
+function give_email_tag_payment_method($payment_id) {
543
+	$payment = new Give_Payment($payment_id);
544 544
 
545
-	return give_get_gateway_checkout_label( $payment->gateway );
545
+	return give_get_gateway_checkout_label($payment->gateway);
546 546
 }
547 547
 
548 548
 /**
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
  *
554 554
  * @return string sitename
555 555
  */
556
-function give_email_tag_sitename( $payment_id ) {
557
-	return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
556
+function give_email_tag_sitename($payment_id) {
557
+	return wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
558 558
 }
559 559
 
560 560
 /**
@@ -566,19 +566,19 @@  discard block
 block discarded – undo
566 566
  *
567 567
  * @return string receipt_link
568 568
  */
569
-function give_email_tag_receipt_link( $payment_id ) {
569
+function give_email_tag_receipt_link($payment_id) {
570 570
 
571
-	$receipt_url = esc_url( add_query_arg( array(
572
-		'payment_key' => give_get_payment_key( $payment_id ),
571
+	$receipt_url = esc_url(add_query_arg(array(
572
+		'payment_key' => give_get_payment_key($payment_id),
573 573
 		'give_action' => 'view_receipt'
574
-	), home_url() ) );
575
-	$formatted   = sprintf(
574
+	), home_url()));
575
+	$formatted = sprintf(
576 576
 		'<a href="%1$s">%2$s</a>',
577 577
 		$receipt_url,
578
-		esc_html__( 'View it in your browser', 'give' )
578
+		esc_html__('View it in your browser', 'give')
579 579
 	);
580 580
 
581
-	if ( give_get_option( 'email_template' ) !== 'none' ) {
581
+	if (give_get_option('email_template') !== 'none') {
582 582
 		return $formatted;
583 583
 	} else {
584 584
 		return $receipt_url;
Please login to merge, or discard this patch.
includes/post-types.php 1 patch
Spacing   +135 added lines, -135 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,40 +23,40 @@  discard block
 block discarded – undo
23 23
 function give_setup_post_types() {
24 24
 
25 25
 	/** Give Forms Post Type */
26
-	$give_forms_singular = give_get_option( 'disable_forms_singular' ) !== 'on' ? true : false;
26
+	$give_forms_singular = give_get_option('disable_forms_singular') !== 'on' ? true : false;
27 27
 
28
-	$give_forms_archives = give_get_option( 'disable_forms_archives' ) !== 'on' ? true : false;
28
+	$give_forms_archives = give_get_option('disable_forms_archives') !== 'on' ? true : false;
29 29
 
30
-	$give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations';
30
+	$give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations';
31 31
 	//support for old 'GIVE_FORMS_SLUG' constant
32
-	if ( defined( 'GIVE_FORMS_SLUG' ) ) {
32
+	if (defined('GIVE_FORMS_SLUG')) {
33 33
 		$give_forms_slug = GIVE_FORMS_SLUG;
34 34
 	}
35 35
 
36
-	$give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array(
36
+	$give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array(
37 37
 		'slug'       => $give_forms_slug,
38 38
 		'with_front' => false
39 39
 	);
40 40
 
41
-	$give_forms_labels = apply_filters( 'give_forms_labels', array(
42
-		'name'               => esc_html__( 'Donation %2$s', 'give' ),
41
+	$give_forms_labels = apply_filters('give_forms_labels', array(
42
+		'name'               => esc_html__('Donation %2$s', 'give'),
43 43
 		'singular_name'      => '%1$s',
44
-		'add_new'            => esc_html__( 'Add %1$s', 'give' ),
45
-		'add_new_item'       => esc_html__( 'Add New Donation %1$s', 'give' ),
46
-		'edit_item'          => esc_html__( 'Edit Donation %1$s', 'give' ),
47
-		'new_item'           => esc_html__( 'New %1$s', 'give' ),
48
-		'all_items'          => esc_html__( 'All %2$s', 'give' ),
49
-		'view_item'          => esc_html__( 'View %1$s', 'give' ),
50
-		'search_items'       => esc_html__( 'Search %2$s', 'give' ),
51
-		'not_found'          => esc_html__( 'No %2$s found', 'give' ),
52
-		'not_found_in_trash' => esc_html__( 'No %2$s found in Trash', 'give' ),
44
+		'add_new'            => esc_html__('Add %1$s', 'give'),
45
+		'add_new_item'       => esc_html__('Add New Donation %1$s', 'give'),
46
+		'edit_item'          => esc_html__('Edit Donation %1$s', 'give'),
47
+		'new_item'           => esc_html__('New %1$s', 'give'),
48
+		'all_items'          => esc_html__('All %2$s', 'give'),
49
+		'view_item'          => esc_html__('View %1$s', 'give'),
50
+		'search_items'       => esc_html__('Search %2$s', 'give'),
51
+		'not_found'          => esc_html__('No %2$s found', 'give'),
52
+		'not_found_in_trash' => esc_html__('No %2$s found in Trash', 'give'),
53 53
 		'parent_item_colon'  => '',
54
-		'menu_name'          => apply_filters( 'give_menu_name', esc_html__( 'Donations', 'give' ) ),
55
-		'name_admin_bar'     => apply_filters( 'give_name_admin_bar_name', esc_html__( 'Donation Form', 'give' ) )
56
-	) );
54
+		'menu_name'          => apply_filters('give_menu_name', esc_html__('Donations', 'give')),
55
+		'name_admin_bar'     => apply_filters('give_name_admin_bar_name', esc_html__('Donation Form', 'give'))
56
+	));
57 57
 
58
-	foreach ( $give_forms_labels as $key => $value ) {
59
-		$give_forms_labels[ $key ] = sprintf( $value, give_get_forms_label_singular(), give_get_forms_label_plural() );
58
+	foreach ($give_forms_labels as $key => $value) {
59
+		$give_forms_labels[$key] = sprintf($value, give_get_forms_label_singular(), give_get_forms_label_plural());
60 60
 	}
61 61
 
62 62
 	//Default give_forms supports
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
 	);
70 70
 
71 71
 	//Has the user disabled the excerpt
72
-	if ( give_get_option( 'disable_forms_excerpt' ) === 'on' ) {
73
-		unset( $give_form_supports[2] );
72
+	if (give_get_option('disable_forms_excerpt') === 'on') {
73
+		unset($give_form_supports[2]);
74 74
 	}
75 75
 
76 76
 	//Has user disabled the featured image?
77
-	if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) {
78
-		unset( $give_form_supports[1] );
79
-		remove_action( 'give_before_single_form_summary', 'give_show_form_images' );
77
+	if (give_get_option('disable_form_featured_img') === 'on') {
78
+		unset($give_form_supports[1]);
79
+		remove_action('give_before_single_form_summary', 'give_show_form_images');
80 80
 	}
81 81
 
82 82
 	$give_forms_args = array(
@@ -92,42 +92,42 @@  discard block
 block discarded – undo
92 92
 		'has_archive'        => $give_forms_archives,
93 93
 		'menu_icon'          => 'dashicons-give',
94 94
 		'hierarchical'       => false,
95
-		'supports'           => apply_filters( 'give_forms_supports', $give_form_supports ),
95
+		'supports'           => apply_filters('give_forms_supports', $give_form_supports),
96 96
 	);
97
-	register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) );
97
+	register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args));
98 98
 	
99 99
 	/** Payment Post Type */
100 100
 	$payment_labels = array(
101
-		'name'               => _x( 'Donations', 'post type general name', 'give' ),
102
-		'singular_name'      => _x( 'Donation', 'post type singular name', 'give' ),
103
-		'add_new'            => esc_html__( 'Add New', 'give' ),
104
-		'add_new_item'       => esc_html__( 'Add New Donation', 'give' ),
105
-		'edit_item'          => esc_html__( 'Edit Donation', 'give' ),
106
-		'new_item'           => esc_html__( 'New Donation', 'give' ),
107
-		'all_items'          => esc_html__( 'All Donations', 'give' ),
108
-		'view_item'          => esc_html__( 'View Donation', 'give' ),
109
-		'search_items'       => esc_html__( 'Search Donations', 'give' ),
110
-		'not_found'          => esc_html__( 'No Donations found', 'give' ),
111
-		'not_found_in_trash' => esc_html__( 'No Donations found in Trash', 'give' ),
101
+		'name'               => _x('Donations', 'post type general name', 'give'),
102
+		'singular_name'      => _x('Donation', 'post type singular name', 'give'),
103
+		'add_new'            => esc_html__('Add New', 'give'),
104
+		'add_new_item'       => esc_html__('Add New Donation', 'give'),
105
+		'edit_item'          => esc_html__('Edit Donation', 'give'),
106
+		'new_item'           => esc_html__('New Donation', 'give'),
107
+		'all_items'          => esc_html__('All Donations', 'give'),
108
+		'view_item'          => esc_html__('View Donation', 'give'),
109
+		'search_items'       => esc_html__('Search Donations', 'give'),
110
+		'not_found'          => esc_html__('No Donations found', 'give'),
111
+		'not_found_in_trash' => esc_html__('No Donations found in Trash', 'give'),
112 112
 		'parent_item_colon'  => '',
113
-		'menu_name'          => esc_html__( 'Transactions', 'give' )
113
+		'menu_name'          => esc_html__('Transactions', 'give')
114 114
 	);
115 115
 
116 116
 	$payment_args = array(
117
-		'labels'          => apply_filters( 'give_payment_labels', $payment_labels ),
117
+		'labels'          => apply_filters('give_payment_labels', $payment_labels),
118 118
 		'public'          => false,
119 119
 		'query_var'       => false,
120 120
 		'rewrite'         => false,
121 121
 		'map_meta_cap'    => true,
122 122
 		'capability_type' => 'give_payment',
123
-		'supports'        => array( 'title' ),
123
+		'supports'        => array('title'),
124 124
 		'can_export'      => true
125 125
 	);
126
-	register_post_type( 'give_payment', $payment_args );
126
+	register_post_type('give_payment', $payment_args);
127 127
 
128 128
 }
129 129
 
130
-add_action( 'init', 'give_setup_post_types', 1 );
130
+add_action('init', 'give_setup_post_types', 1);
131 131
 
132 132
 
133 133
 /**
@@ -140,32 +140,32 @@  discard block
 block discarded – undo
140 140
  */
141 141
 function give_setup_taxonomies() {
142 142
 
143
-	$slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations';
143
+	$slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations';
144 144
 
145 145
 	/** Categories */
146 146
 	$category_labels = array(
147 147
 		/* translators: %s: form singular label */
148
-		'name'              => sprintf( _x( '%s Categories', 'taxonomy general name', 'give' ), give_get_forms_label_singular() ),
149
-		'singular_name'     => _x( 'Category', 'taxonomy singular name', 'give' ),
150
-		'search_items'      => esc_html__( 'Search Categories', 'give' ),
151
-		'all_items'         => esc_html__( 'All Categories', 'give' ),
152
-		'parent_item'       => esc_html__( 'Parent Category', 'give' ),
153
-		'parent_item_colon' => esc_html__( 'Parent Category:', 'give' ),
154
-		'edit_item'         => esc_html__( 'Edit Category', 'give' ),
155
-		'update_item'       => esc_html__( 'Update Category', 'give' ),
148
+		'name'              => sprintf(_x('%s Categories', 'taxonomy general name', 'give'), give_get_forms_label_singular()),
149
+		'singular_name'     => _x('Category', 'taxonomy singular name', 'give'),
150
+		'search_items'      => esc_html__('Search Categories', 'give'),
151
+		'all_items'         => esc_html__('All Categories', 'give'),
152
+		'parent_item'       => esc_html__('Parent Category', 'give'),
153
+		'parent_item_colon' => esc_html__('Parent Category:', 'give'),
154
+		'edit_item'         => esc_html__('Edit Category', 'give'),
155
+		'update_item'       => esc_html__('Update Category', 'give'),
156 156
 		/* translators: %s: form singular label */
157
-		'add_new_item'      => sprintf( esc_html__( 'Add New %s Category', 'give' ), give_get_forms_label_singular() ),
158
-		'new_item_name'     => esc_html__( 'New Category Name', 'give' ),
159
-		'menu_name'         => esc_html__( 'Categories', 'give' ),
157
+		'add_new_item'      => sprintf(esc_html__('Add New %s Category', 'give'), give_get_forms_label_singular()),
158
+		'new_item_name'     => esc_html__('New Category Name', 'give'),
159
+		'menu_name'         => esc_html__('Categories', 'give'),
160 160
 	);
161 161
 
162
-	$category_args = apply_filters( 'give_forms_category_args', array(
162
+	$category_args = apply_filters('give_forms_category_args', array(
163 163
 			'hierarchical' => true,
164
-			'labels'       => apply_filters( 'give_forms_category_labels', $category_labels ),
164
+			'labels'       => apply_filters('give_forms_category_labels', $category_labels),
165 165
 			'show_ui'      => true,
166 166
 			'query_var'    => 'give_forms_category',
167 167
 			'rewrite'      => array(
168
-				'slug'         => $slug . '/category',
168
+				'slug'         => $slug.'/category',
169 169
 				'with_front'   => false,
170 170
 				'hierarchical' => true
171 171
 			),
@@ -179,36 +179,36 @@  discard block
 block discarded – undo
179 179
 	);
180 180
 
181 181
 	//Does the user want categories?
182
-	if ( give_get_option( 'enable_categories' ) == 'on' ) {
183
-		register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args );
184
-		register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' );
182
+	if (give_get_option('enable_categories') == 'on') {
183
+		register_taxonomy('give_forms_category', array('give_forms'), $category_args);
184
+		register_taxonomy_for_object_type('give_forms_category', 'give_forms');
185 185
 	}
186 186
 
187 187
 
188 188
 	/** Tags */
189 189
 	$tag_labels = array(
190 190
 		/* translators: %s: form singular label */
191
-		'name'                  => sprintf( _x( '%s Tags', 'taxonomy general name', 'give' ), give_get_forms_label_singular() ),
192
-		'singular_name'         => _x( 'Tag', 'taxonomy singular name', 'give' ),
193
-		'search_items'          => esc_html__( 'Search Tags', 'give' ),
194
-		'all_items'             => esc_html__( 'All Tags', 'give' ),
195
-		'parent_item'           => esc_html__( 'Parent Tag', 'give' ),
196
-		'parent_item_colon'     => esc_html__( 'Parent Tag:', 'give' ),
197
-		'edit_item'             => esc_html__( 'Edit Tag', 'give' ),
198
-		'update_item'           => esc_html__( 'Update Tag', 'give' ),
199
-		'add_new_item'          => esc_html__( 'Add New Tag', 'give' ),
200
-		'new_item_name'         => esc_html__( 'New Tag Name', 'give' ),
201
-		'menu_name'             => esc_html__( 'Tags', 'give' ),
191
+		'name'                  => sprintf(_x('%s Tags', 'taxonomy general name', 'give'), give_get_forms_label_singular()),
192
+		'singular_name'         => _x('Tag', 'taxonomy singular name', 'give'),
193
+		'search_items'          => esc_html__('Search Tags', 'give'),
194
+		'all_items'             => esc_html__('All Tags', 'give'),
195
+		'parent_item'           => esc_html__('Parent Tag', 'give'),
196
+		'parent_item_colon'     => esc_html__('Parent Tag:', 'give'),
197
+		'edit_item'             => esc_html__('Edit Tag', 'give'),
198
+		'update_item'           => esc_html__('Update Tag', 'give'),
199
+		'add_new_item'          => esc_html__('Add New Tag', 'give'),
200
+		'new_item_name'         => esc_html__('New Tag Name', 'give'),
201
+		'menu_name'             => esc_html__('Tags', 'give'),
202 202
 		/* translators: %s: form singular label */
203
-		'choose_from_most_used' => sprintf( esc_html__( 'Choose from most used %s tags.', 'give' ), give_get_forms_label_singular() ),
203
+		'choose_from_most_used' => sprintf(esc_html__('Choose from most used %s tags.', 'give'), give_get_forms_label_singular()),
204 204
 	);
205 205
 
206
-	$tag_args = apply_filters( 'give_forms_tag_args', array(
206
+	$tag_args = apply_filters('give_forms_tag_args', array(
207 207
 			'hierarchical' => false,
208
-			'labels'       => apply_filters( 'give_forms_tag_labels', $tag_labels ),
208
+			'labels'       => apply_filters('give_forms_tag_labels', $tag_labels),
209 209
 			'show_ui'      => true,
210 210
 			'query_var'    => 'give_forms_tag',
211
-			'rewrite'      => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ),
211
+			'rewrite'      => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true),
212 212
 			'capabilities' => array(
213 213
 				'manage_terms' => 'manage_give_forms_terms',
214 214
 				'edit_terms'   => 'edit_give_forms_terms',
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
 		)
220 220
 	);
221 221
 
222
-	if ( give_get_option( 'enable_tags' ) == 'on' ) {
223
-		register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args );
224
-		register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' );
222
+	if (give_get_option('enable_tags') == 'on') {
223
+		register_taxonomy('give_forms_tag', array('give_forms'), $tag_args);
224
+		register_taxonomy_for_object_type('give_forms_tag', 'give_forms');
225 225
 	}
226 226
 
227 227
 
228 228
 }
229 229
 
230
-add_action( 'init', 'give_setup_taxonomies', 0 );
230
+add_action('init', 'give_setup_taxonomies', 0);
231 231
 
232 232
 
233 233
 /**
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
  */
239 239
 function give_get_default_form_labels() {
240 240
 	$defaults = array(
241
-		'singular' => esc_html__( 'Form', 'give' ),
242
-		'plural'   => esc_html__( 'Forms', 'give' )
241
+		'singular' => esc_html__('Form', 'give'),
242
+		'plural'   => esc_html__('Forms', 'give')
243 243
 	);
244 244
 
245
-	return apply_filters( 'give_default_form_name', $defaults );
245
+	return apply_filters('give_default_form_name', $defaults);
246 246
 }
247 247
 
248 248
 /**
@@ -254,10 +254,10 @@  discard block
 block discarded – undo
254 254
  *
255 255
  * @return string $defaults['singular'] Singular label
256 256
  */
257
-function give_get_forms_label_singular( $lowercase = false ) {
257
+function give_get_forms_label_singular($lowercase = false) {
258 258
 	$defaults = give_get_default_form_labels();
259 259
 
260
-	return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
260
+	return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
261 261
 }
262 262
 
263 263
 /**
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
  * @since 1.0
267 267
  * @return string $defaults['plural'] Plural label
268 268
  */
269
-function give_get_forms_label_plural( $lowercase = false ) {
269
+function give_get_forms_label_plural($lowercase = false) {
270 270
 	$defaults = give_get_default_form_labels();
271 271
 
272
-	return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
272
+	return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
273 273
 }
274 274
 
275 275
 /**
@@ -281,12 +281,12 @@  discard block
 block discarded – undo
281 281
  *
282 282
  * @return string $title New placeholder text
283 283
  */
284
-function give_change_default_title( $title ) {
284
+function give_change_default_title($title) {
285 285
 	// If a frontend plugin uses this filter (check extensions before changing this function)
286
-	if ( ! is_admin() ) {
286
+	if ( ! is_admin()) {
287 287
 		$title = sprintf(
288 288
 			/* translators: %s: form singular label */
289
-			esc_html__( 'Enter %s title here', 'give' ),
289
+			esc_html__('Enter %s title here', 'give'),
290 290
 			give_get_forms_label_singular()
291 291
 		);
292 292
 
@@ -295,10 +295,10 @@  discard block
 block discarded – undo
295 295
 
296 296
 	$screen = get_current_screen();
297 297
 
298
-	if ( 'give_forms' == $screen->post_type ) {
298
+	if ('give_forms' == $screen->post_type) {
299 299
 		$title = sprintf(
300 300
 			/* translators: %s: form singular label */
301
-			esc_html__( 'Enter %s title here', 'give' ),
301
+			esc_html__('Enter %s title here', 'give'),
302 302
 			give_get_forms_label_singular()
303 303
 		);
304 304
 	}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	return $title;
307 307
 }
308 308
 
309
-add_filter( 'enter_title_here', 'give_change_default_title' );
309
+add_filter('enter_title_here', 'give_change_default_title');
310 310
 
311 311
 /**
312 312
  * Registers Custom Post Statuses which are used by the Payments
@@ -316,50 +316,50 @@  discard block
 block discarded – undo
316 316
  */
317 317
 function give_register_post_type_statuses() {
318 318
 	// Payment Statuses
319
-	register_post_status( 'refunded', array(
320
-		'label'                     => _x( 'Refunded', 'Refunded payment status', 'give' ),
319
+	register_post_status('refunded', array(
320
+		'label'                     => _x('Refunded', 'Refunded payment status', 'give'),
321 321
 		'public'                    => true,
322 322
 		'exclude_from_search'       => false,
323 323
 		'show_in_admin_all_list'    => true,
324 324
 		'show_in_admin_status_list' => true,
325
-		'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' )
326
-	) );
327
-	register_post_status( 'failed', array(
328
-		'label'                     => _x( 'Failed', 'Failed payment status', 'give' ),
325
+		'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give')
326
+	));
327
+	register_post_status('failed', array(
328
+		'label'                     => _x('Failed', 'Failed payment status', 'give'),
329 329
 		'public'                    => true,
330 330
 		'exclude_from_search'       => false,
331 331
 		'show_in_admin_all_list'    => true,
332 332
 		'show_in_admin_status_list' => true,
333
-		'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' )
334
-	) );
335
-	register_post_status( 'revoked', array(
336
-		'label'                     => _x( 'Revoked', 'Revoked payment status', 'give' ),
333
+		'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give')
334
+	));
335
+	register_post_status('revoked', array(
336
+		'label'                     => _x('Revoked', 'Revoked payment status', 'give'),
337 337
 		'public'                    => true,
338 338
 		'exclude_from_search'       => false,
339 339
 		'show_in_admin_all_list'    => true,
340 340
 		'show_in_admin_status_list' => true,
341
-		'label_count'               => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' )
342
-	) );
343
-	register_post_status( 'cancelled', array(
344
-		'label'                     => _x( 'Cancelled', 'Cancelled payment status', 'give' ),
341
+		'label_count'               => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give')
342
+	));
343
+	register_post_status('cancelled', array(
344
+		'label'                     => _x('Cancelled', 'Cancelled payment status', 'give'),
345 345
 		'public'                    => true,
346 346
 		'exclude_from_search'       => false,
347 347
 		'show_in_admin_all_list'    => true,
348 348
 		'show_in_admin_status_list' => true,
349
-		'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' )
350
-	) );
351
-	register_post_status( 'abandoned', array(
352
-		'label'                     => _x( 'Abandoned', 'Abandoned payment status', 'give' ),
349
+		'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give')
350
+	));
351
+	register_post_status('abandoned', array(
352
+		'label'                     => _x('Abandoned', 'Abandoned payment status', 'give'),
353 353
 		'public'                    => true,
354 354
 		'exclude_from_search'       => false,
355 355
 		'show_in_admin_all_list'    => true,
356 356
 		'show_in_admin_status_list' => true,
357
-		'label_count'               => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' )
358
-	) );
357
+		'label_count'               => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give')
358
+	));
359 359
 
360 360
 }
361 361
 
362
-add_action( 'init', 'give_register_post_type_statuses' );
362
+add_action('init', 'give_register_post_type_statuses');
363 363
 
364 364
 /**
365 365
  * Updated Messages
@@ -372,43 +372,43 @@  discard block
 block discarded – undo
372 372
  *
373 373
  * @return array $messages New post updated messages
374 374
  */
375
-function give_updated_messages( $messages ) {
375
+function give_updated_messages($messages) {
376 376
 	global $post, $post_ID;
377 377
 
378
-	$url1 = '<a href="' . get_permalink( $post_ID ) . '">';
378
+	$url1 = '<a href="'.get_permalink($post_ID).'">';
379 379
 	$url2 = give_get_forms_label_singular();
380 380
 	$url3 = '</a>';
381 381
 
382 382
 	$messages['give_forms'] = array(
383
-		1 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
384
-		4 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
385
-		6 => sprintf( __( '%2$s published. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
386
-		7 => sprintf( __( '%2$s saved. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
387
-		8 => sprintf( __( '%2$s submitted. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 )
383
+		1 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
384
+		4 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
385
+		6 => sprintf(__('%2$s published. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
386
+		7 => sprintf(__('%2$s saved. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
387
+		8 => sprintf(__('%2$s submitted. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3)
388 388
 	);
389 389
 
390 390
 	return $messages;
391 391
 }
392 392
 
393
-add_filter( 'post_updated_messages', 'give_updated_messages' );
393
+add_filter('post_updated_messages', 'give_updated_messages');
394 394
 
395 395
 
396 396
 /**
397 397
  * Setup Post Type Images
398 398
  */
399
-add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 );
399
+add_action('after_setup_theme', 'give_add_thumbnail_support', 10);
400 400
 
401 401
 /**
402 402
  * Ensure post thumbnail support is turned on
403 403
  */
404 404
 function give_add_thumbnail_support() {
405
-	if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) {
405
+	if (give_get_option('disable_form_featured_img') === 'on') {
406 406
 		return;
407 407
 	}
408
-	if ( ! current_theme_supports( 'post-thumbnails' ) ) {
409
-		add_theme_support( 'post-thumbnails' );
408
+	if ( ! current_theme_supports('post-thumbnails')) {
409
+		add_theme_support('post-thumbnails');
410 410
 	}
411
-	add_post_type_support( 'give_forms', 'thumbnail' );
411
+	add_post_type_support('give_forms', 'thumbnail');
412 412
 }
413 413
 
414 414
 /**
@@ -420,19 +420,19 @@  discard block
 block discarded – undo
420 420
 function give_widgets_init() {
421 421
 
422 422
 	//Single Give Forms (disabled if single turned off in settings)
423
-	if ( give_get_option( 'disable_forms_singular' ) !== 'on' && give_get_option( 'disable_form_sidebar' ) !== 'on' ) {
423
+	if (give_get_option('disable_forms_singular') !== 'on' && give_get_option('disable_form_sidebar') !== 'on') {
424 424
 
425
-		register_sidebar( apply_filters( 'give_forms_single_sidebar', array(
426
-			'name'          => esc_html__( 'Give Single Form Sidebar', 'give' ),
425
+		register_sidebar(apply_filters('give_forms_single_sidebar', array(
426
+			'name'          => esc_html__('Give Single Form Sidebar', 'give'),
427 427
 			'id'            => 'give-forms-sidebar',
428
-			'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' ),
428
+			'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'),
429 429
 			'before_widget' => '<div id="%1$s" class="widget %2$s">',
430 430
 			'after_widget'  => '</div>',
431 431
 			'before_title'  => '<h3 class="widgettitle widget-title">',
432 432
 			'after_title'   => '</h3>',
433
-		) ) );
433
+		)));
434 434
 
435 435
 	}
436 436
 }
437 437
 
438
-add_action( 'widgets_init', 'give_widgets_init', 999 );
438
+add_action('widgets_init', 'give_widgets_init', 999);
Please login to merge, or discard this patch.
includes/class-give-license-handler.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 // Exit if accessed directly
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
15
-if ( ! class_exists( 'Give_License' ) ) :
15
+if ( ! class_exists('Give_License')) :
16 16
 
17 17
 	/**
18 18
 	 * Give_License Class
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 		 * @param string  $_optname
39 39
 		 * @param string  $_api_url
40 40
 		 */
41
-		public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null ) {
41
+		public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null) {
42 42
 			global $give_options;
43 43
 
44 44
 			$this->file           = $_file;
45 45
 			$this->item_name      = $_item_name;
46
-			$this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
46
+			$this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
47 47
 			$this->version        = $_version;
48
-			$this->license        = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
48
+			$this->license        = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
49 49
 			$this->author         = $_author;
50
-			$this->api_url        = is_null( $_api_url ) ? $this->api_url : $_api_url;
50
+			$this->api_url        = is_null($_api_url) ? $this->api_url : $_api_url;
51 51
 
52 52
 
53 53
 			// Setup hooks
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		 * @return  void
64 64
 		 */
65 65
 		private function includes() {
66
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
66
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
67 67
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
68 68
 			}
69 69
 		}
@@ -77,18 +77,18 @@  discard block
 block discarded – undo
77 77
 		private function hooks() {
78 78
 
79 79
 			// Register settings
80
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
80
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
81 81
 
82 82
 			// Activate license key on settings save
83
-			add_action( 'admin_init', array( $this, 'activate_license' ) );
83
+			add_action('admin_init', array($this, 'activate_license'));
84 84
 
85 85
 			// Deactivate license key
86
-			add_action( 'admin_init', array( $this, 'deactivate_license' ) );
86
+			add_action('admin_init', array($this, 'deactivate_license'));
87 87
 
88 88
 			// Updater
89
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
89
+			add_action('admin_init', array($this, 'auto_updater'), 0);
90 90
 
91
-			add_action( 'admin_notices', array( $this, 'notices' ) );
91
+			add_action('admin_notices', array($this, 'notices'));
92 92
 		}
93 93
 
94 94
 		/**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 		 */
101 101
 		public function auto_updater() {
102 102
 
103
-			if ( 'valid' !== get_option( $this->item_shortname . '_license_active' ) ) {
103
+			if ('valid' !== get_option($this->item_shortname.'_license_active')) {
104 104
 				return;
105 105
 			}
106 106
 
@@ -127,20 +127,20 @@  discard block
 block discarded – undo
127 127
 		 *
128 128
 		 * @return  array
129 129
 		 */
130
-		public function settings( $settings ) {
130
+		public function settings($settings) {
131 131
 
132 132
 			$give_license_settings = array(
133 133
 				array(
134 134
 					'name'    => $this->item_name,
135
-					'id'      => $this->item_shortname . '_license_key',
135
+					'id'      => $this->item_shortname.'_license_key',
136 136
 					'desc'    => '',
137 137
 					'type'    => 'license_key',
138
-					'options' => array( 'is_valid_license_option' => $this->item_shortname . '_license_active' ),
138
+					'options' => array('is_valid_license_option' => $this->item_shortname.'_license_active'),
139 139
 					'size'    => 'regular'
140 140
 				)
141 141
 			);
142 142
 
143
-			return array_merge( $settings, $give_license_settings );
143
+			return array_merge($settings, $give_license_settings);
144 144
 		}
145 145
 
146 146
 		/**
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
 		 *
153 153
 		 * @return  array
154 154
 		 */
155
-		public function license_settings_content( $settings ) {
155
+		public function license_settings_content($settings) {
156 156
 
157 157
 			$give_license_settings = array(
158 158
 				array(
159
-					'name' => esc_html__( 'Add-on Licenses', 'give' ),
159
+					'name' => esc_html__('Add-on Licenses', 'give'),
160 160
 					'desc' => '<hr>',
161 161
 					'type' => 'give_title',
162 162
 					'id'   => 'give_title'
163 163
 				),
164 164
 			);
165 165
 
166
-			return array_merge( $settings, $give_license_settings );
166
+			return array_merge($settings, $give_license_settings);
167 167
 		}
168 168
 
169 169
 
@@ -175,34 +175,34 @@  discard block
 block discarded – undo
175 175
 		 */
176 176
 		public function activate_license() {
177 177
 
178
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
178
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
179 179
 				return;
180 180
 			}
181 181
 
182
-			foreach ( $_POST as $key => $value ) {
183
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
182
+			foreach ($_POST as $key => $value) {
183
+				if (false !== strpos($key, 'license_key_deactivate')) {
184 184
 					// Don't activate a key when deactivating a different key
185 185
 					return;
186 186
 				}
187 187
 			}
188 188
 
189
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
189
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
190 190
 
191
-				wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
191
+				wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
192 192
 
193 193
 			}
194 194
 
195
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
195
+			if ( ! current_user_can('manage_give_settings')) {
196 196
 				return;
197 197
 			}
198 198
 
199
-			if ( 'valid' === get_option( $this->item_shortname . '_license_active' ) ) {
199
+			if ('valid' === get_option($this->item_shortname.'_license_active')) {
200 200
 				return;
201 201
 			}
202 202
 
203
-			$license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
203
+			$license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
204 204
 
205
-			if ( empty( $license ) ) {
205
+			if (empty($license)) {
206 206
 				return;
207 207
 			}
208 208
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			$api_params = array(
211 211
 				'edd_action' => 'activate_license', //never change from "edd_" to "give_"!
212 212
 				'license'    => $license,
213
-				'item_name'  => urlencode( $this->item_name ),
213
+				'item_name'  => urlencode($this->item_name),
214 214
 				'url'        => home_url()
215 215
 			);
216 216
 
@@ -225,22 +225,22 @@  discard block
 block discarded – undo
225 225
 			);
226 226
 
227 227
 			// Make sure there are no errors
228
-			if ( is_wp_error( $response ) ) {
228
+			if (is_wp_error($response)) {
229 229
 				return;
230 230
 			}
231 231
 
232 232
 			// Tell WordPress to look for updates
233
-			set_site_transient( 'update_plugins', null );
233
+			set_site_transient('update_plugins', null);
234 234
 
235 235
 			// Decode license data
236
-			$license_data = json_decode( wp_remote_retrieve_body( $response ) );
236
+			$license_data = json_decode(wp_remote_retrieve_body($response));
237 237
 
238
-			update_option( $this->item_shortname . '_license_active', $license_data->license );
238
+			update_option($this->item_shortname.'_license_active', $license_data->license);
239 239
 
240
-			if ( ! (bool) $license_data->success ) {
241
-				set_transient( 'give_license_error', $license_data, 1000 );
240
+			if ( ! (bool) $license_data->success) {
241
+				set_transient('give_license_error', $license_data, 1000);
242 242
 			} else {
243
-				delete_transient( 'give_license_error' );
243
+				delete_transient('give_license_error');
244 244
 			}
245 245
 		}
246 246
 
@@ -253,28 +253,28 @@  discard block
 block discarded – undo
253 253
 		 */
254 254
 		public function deactivate_license() {
255 255
 
256
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
256
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
257 257
 				return;
258 258
 			}
259 259
 
260
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
260
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
261 261
 
262
-				wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
262
+				wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
263 263
 
264 264
 			}
265 265
 
266
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
266
+			if ( ! current_user_can('manage_give_settings')) {
267 267
 				return;
268 268
 			}
269 269
 
270 270
 			// Run on deactivate button press
271
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
271
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
272 272
 
273 273
 				// Data to send to the API
274 274
 				$api_params = array(
275 275
 					'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"!
276 276
 					'license'    => $this->license,
277
-					'item_name'  => urlencode( $this->item_name ),
277
+					'item_name'  => urlencode($this->item_name),
278 278
 					'url'        => home_url()
279 279
 				);
280 280
 
@@ -290,19 +290,19 @@  discard block
 block discarded – undo
290 290
 
291 291
 
292 292
 				// Make sure there are no errors
293
-				if ( is_wp_error( $response ) ) {
293
+				if (is_wp_error($response)) {
294 294
 					return;
295 295
 				}
296 296
 
297 297
 				// Decode the license data
298
-				$license_data = json_decode( wp_remote_retrieve_body( $response ) );
298
+				$license_data = json_decode(wp_remote_retrieve_body($response));
299 299
 
300
-				delete_option( $this->item_shortname . '_license_active' );
300
+				delete_option($this->item_shortname.'_license_active');
301 301
 
302
-				if ( ! (bool) $license_data->success ) {
303
-					set_transient( 'give_license_error', $license_data, 1000 );
302
+				if ( ! (bool) $license_data->success) {
303
+					set_transient('give_license_error', $license_data, 1000);
304 304
 				} else {
305
-					delete_transient( 'give_license_error' );
305
+					delete_transient('give_license_error');
306 306
 				}
307 307
 			}
308 308
 		}
@@ -316,44 +316,44 @@  discard block
 block discarded – undo
316 316
 		 */
317 317
 		public function notices() {
318 318
 
319
-			if ( ! isset( $_GET['page'] ) || 'give-settings' !== $_GET['page'] ) {
319
+			if ( ! isset($_GET['page']) || 'give-settings' !== $_GET['page']) {
320 320
 				return;
321 321
 			}
322 322
 
323
-			if ( ! isset( $_GET['tab'] ) || 'licenses' !== $_GET['tab'] ) {
323
+			if ( ! isset($_GET['tab']) || 'licenses' !== $_GET['tab']) {
324 324
 				return;
325 325
 			}
326 326
 
327
-			$license_error = get_transient( 'give_license_error' );
327
+			$license_error = get_transient('give_license_error');
328 328
 
329
-			if ( false === $license_error ) {
329
+			if (false === $license_error) {
330 330
 				return;
331 331
 			}
332 332
 
333
-			if ( ! empty( $license_error->error ) ) {
333
+			if ( ! empty($license_error->error)) {
334 334
 
335
-				switch ( $license_error->error ) {
335
+				switch ($license_error->error) {
336 336
 
337 337
 					case 'item_name_mismatch' :
338 338
 
339
-						$message = esc_html__( 'This license does not belong to the product you have entered it for.', 'give' );
339
+						$message = esc_html__('This license does not belong to the product you have entered it for.', 'give');
340 340
 						break;
341 341
 
342 342
 					case 'no_activations_left' :
343 343
 
344
-						$message = esc_html__( 'This license does not have any activations left.', 'give' );
344
+						$message = esc_html__('This license does not have any activations left.', 'give');
345 345
 						break;
346 346
 
347 347
 					case 'expired' :
348 348
 
349
-						$message = esc_html__( 'This license key is expired. Please renew it.', 'give' );
349
+						$message = esc_html__('This license key is expired. Please renew it.', 'give');
350 350
 						break;
351 351
 
352 352
 					default :
353 353
 
354 354
 						$message = sprintf(
355 355
 							/* translators: %s: license error */
356
-							esc_html__( 'There was a problem activating your license key, please try again or contact support. Error code: %s', 'give' ),
356
+							esc_html__('There was a problem activating your license key, please try again or contact support. Error code: %s', 'give'),
357 357
 							$license_error->error
358 358
 						);
359 359
 						break;
@@ -362,15 +362,15 @@  discard block
 block discarded – undo
362 362
 
363 363
 			}
364 364
 
365
-			if ( ! empty( $message ) ) {
365
+			if ( ! empty($message)) {
366 366
 
367 367
 				echo '<div class="error">';
368
-				echo '<p>' . $message . '</p>';
368
+				echo '<p>'.$message.'</p>';
369 369
 				echo '</div>';
370 370
 
371 371
 			}
372 372
 
373
-			delete_transient( 'give_license_error' );
373
+			delete_transient('give_license_error');
374 374
 
375 375
 		}
376 376
 	}
Please login to merge, or discard this patch.
includes/class-give-roles.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function __construct() {
30 30
 
31
-		add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 );
31
+		add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4);
32 32
 	}
33 33
 
34 34
 	/**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @return void
40 40
 	 */
41 41
 	public function add_roles() {
42
-		add_role( 'give_manager', esc_html__( 'Give Manager', 'give' ), array(
42
+		add_role('give_manager', esc_html__('Give Manager', 'give'), array(
43 43
 			'read'                   => true,
44 44
 			'edit_posts'             => true,
45 45
 			'delete_posts'           => true,
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
 			'publish_posts'          => true,
69 69
 			'read_private_pages'     => true,
70 70
 			'read_private_posts'     => true
71
-		) );
71
+		));
72 72
 
73
-		add_role( 'give_accountant', esc_html__( 'Give Accountant', 'give' ), array(
73
+		add_role('give_accountant', esc_html__('Give Accountant', 'give'), array(
74 74
 		    'read'                   => true,
75 75
 		    'edit_posts'             => false,
76 76
 		    'delete_posts'           => false
77
-		) );
77
+		));
78 78
 
79
-		add_role( 'give_worker', esc_html__( 'Give Worker', 'give' ), array(
79
+		add_role('give_worker', esc_html__('Give Worker', 'give'), array(
80 80
 			'read'                   => true,
81 81
 			'edit_posts'             => false,
82 82
 			'upload_files'           => true,
83 83
 			'delete_posts'           => false
84
-		) );
84
+		));
85 85
 
86 86
 	}
87 87
 
@@ -96,38 +96,38 @@  discard block
 block discarded – undo
96 96
 	public function add_caps() {
97 97
 		global $wp_roles;
98 98
 
99
-		if ( class_exists('WP_Roles') ) {
100
-			if ( ! isset( $wp_roles ) ) {
99
+		if (class_exists('WP_Roles')) {
100
+			if ( ! isset($wp_roles)) {
101 101
 				$wp_roles = new WP_Roles();
102 102
 			}
103 103
 		}
104 104
 
105
-		if ( is_object( $wp_roles ) ) {
106
-			$wp_roles->add_cap( 'give_manager', 'view_give_reports' );
107
-			$wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' );
108
-			$wp_roles->add_cap( 'give_manager', 'export_give_reports' );
109
-			$wp_roles->add_cap( 'give_manager', 'manage_give_settings' );
105
+		if (is_object($wp_roles)) {
106
+			$wp_roles->add_cap('give_manager', 'view_give_reports');
107
+			$wp_roles->add_cap('give_manager', 'view_give_sensitive_data');
108
+			$wp_roles->add_cap('give_manager', 'export_give_reports');
109
+			$wp_roles->add_cap('give_manager', 'manage_give_settings');
110 110
 
111
-			$wp_roles->add_cap( 'administrator', 'view_give_reports' );
112
-			$wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' );
113
-			$wp_roles->add_cap( 'administrator', 'export_give_reports' );
114
-			$wp_roles->add_cap( 'administrator', 'manage_give_settings' );
111
+			$wp_roles->add_cap('administrator', 'view_give_reports');
112
+			$wp_roles->add_cap('administrator', 'view_give_sensitive_data');
113
+			$wp_roles->add_cap('administrator', 'export_give_reports');
114
+			$wp_roles->add_cap('administrator', 'manage_give_settings');
115 115
 
116 116
 			// Add the main post type capabilities
117 117
 			$capabilities = $this->get_core_caps();
118
-			foreach ( $capabilities as $cap_group ) {
119
-				foreach ( $cap_group as $cap ) {
120
-					$wp_roles->add_cap( 'administrator', $cap );
121
-					$wp_roles->add_cap( 'give_manager', $cap );
122
-					$wp_roles->add_cap( 'give_worker', $cap );
118
+			foreach ($capabilities as $cap_group) {
119
+				foreach ($cap_group as $cap) {
120
+					$wp_roles->add_cap('administrator', $cap);
121
+					$wp_roles->add_cap('give_manager', $cap);
122
+					$wp_roles->add_cap('give_worker', $cap);
123 123
 				}
124 124
 			}
125 125
 
126
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_forms' );
127
-			$wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' );
128
-			$wp_roles->add_cap( 'give_accountant', 'view_give_reports' );
129
-			$wp_roles->add_cap( 'give_accountant', 'export_give_reports' );
130
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_payments' );
126
+			$wp_roles->add_cap('give_accountant', 'edit_give_forms');
127
+			$wp_roles->add_cap('give_accountant', 'read_private_give_forms');
128
+			$wp_roles->add_cap('give_accountant', 'view_give_reports');
129
+			$wp_roles->add_cap('give_accountant', 'export_give_reports');
130
+			$wp_roles->add_cap('give_accountant', 'edit_give_payments');
131 131
 
132 132
 		}
133 133
 	}
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
 	public function get_core_caps() {
143 143
 		$capabilities = array();
144 144
 
145
-		$capability_types = array( 'give_form', 'give_payment' );
145
+		$capability_types = array('give_form', 'give_payment');
146 146
 
147
-		foreach ( $capability_types as $capability_type ) {
148
-			$capabilities[ $capability_type ] = array(
147
+		foreach ($capability_types as $capability_type) {
148
+			$capabilities[$capability_type] = array(
149 149
 				// Post type
150 150
 				"edit_{$capability_type}",
151 151
 				"read_{$capability_type}",
@@ -182,22 +182,22 @@  discard block
 block discarded – undo
182 182
 	 * @since  1.0
183 183
 	 * @return array $caps
184 184
 	 */
185
-	public function meta_caps( $caps, $cap, $user_id, $args ) {
185
+	public function meta_caps($caps, $cap, $user_id, $args) {
186 186
 
187
-		switch( $cap ) {
187
+		switch ($cap) {
188 188
 
189 189
 			case 'view_give_forms_stats' :
190 190
 				
191
-				if( empty( $args[0] ) ) {
191
+				if (empty($args[0])) {
192 192
 					break;
193 193
 				}
194 194
 				
195
-				$form = get_post( $args[0] );
196
-				if ( empty( $form ) ) {
195
+				$form = get_post($args[0]);
196
+				if (empty($form)) {
197 197
 					break;
198 198
 				}
199 199
 
200
-				if( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) {
200
+				if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) {
201 201
 					$caps = array();
202 202
 				}
203 203
 
@@ -219,41 +219,41 @@  discard block
 block discarded – undo
219 219
 		
220 220
 		global $wp_roles;
221 221
 
222
-		if ( class_exists( 'WP_Roles' ) ) {
223
-			if ( ! isset( $wp_roles ) ) {
222
+		if (class_exists('WP_Roles')) {
223
+			if ( ! isset($wp_roles)) {
224 224
 				$wp_roles = new WP_Roles();
225 225
 			}
226 226
 		}
227 227
 
228
-		if ( is_object( $wp_roles ) ) {
228
+		if (is_object($wp_roles)) {
229 229
 			/** Give Manager Capabilities */
230
-			$wp_roles->remove_cap( 'give_manager', 'view_give_reports' );
231
-			$wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' );
232
-			$wp_roles->remove_cap( 'give_manager', 'export_give_reports' );
233
-			$wp_roles->remove_cap( 'give_manager', 'manage_give_settings' );
230
+			$wp_roles->remove_cap('give_manager', 'view_give_reports');
231
+			$wp_roles->remove_cap('give_manager', 'view_give_sensitive_data');
232
+			$wp_roles->remove_cap('give_manager', 'export_give_reports');
233
+			$wp_roles->remove_cap('give_manager', 'manage_give_settings');
234 234
 
235 235
 			/** Site Administrator Capabilities */
236
-			$wp_roles->remove_cap( 'administrator', 'view_give_reports' );
237
-			$wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' );
238
-			$wp_roles->remove_cap( 'administrator', 'export_give_reports' );
239
-			$wp_roles->remove_cap( 'administrator', 'manage_give_settings' );
236
+			$wp_roles->remove_cap('administrator', 'view_give_reports');
237
+			$wp_roles->remove_cap('administrator', 'view_give_sensitive_data');
238
+			$wp_roles->remove_cap('administrator', 'export_give_reports');
239
+			$wp_roles->remove_cap('administrator', 'manage_give_settings');
240 240
 
241 241
 			/** Remove the Main Post Type Capabilities */
242 242
 			$capabilities = $this->get_core_caps();
243 243
 
244
-			foreach ( $capabilities as $cap_group ) {
245
-				foreach ( $cap_group as $cap ) {
246
-					$wp_roles->remove_cap( 'give_manager', $cap );
247
-					$wp_roles->remove_cap( 'administrator', $cap );
248
-					$wp_roles->remove_cap( 'give_worker', $cap );
244
+			foreach ($capabilities as $cap_group) {
245
+				foreach ($cap_group as $cap) {
246
+					$wp_roles->remove_cap('give_manager', $cap);
247
+					$wp_roles->remove_cap('administrator', $cap);
248
+					$wp_roles->remove_cap('give_worker', $cap);
249 249
 				}
250 250
 			}
251 251
 
252 252
 			/** Give Accountant Capabilities */
253
-			$wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' );
254
-			$wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' );
255
-			$wp_roles->remove_cap( 'give_accountant', 'view_give_reports' );
256
-			$wp_roles->remove_cap( 'give_accountant', 'export_give_reports' );
253
+			$wp_roles->remove_cap('give_accountant', 'edit_give_forms');
254
+			$wp_roles->remove_cap('give_accountant', 'read_private_give_forms');
255
+			$wp_roles->remove_cap('give_accountant', 'view_give_reports');
256
+			$wp_roles->remove_cap('give_accountant', 'export_give_reports');
257 257
 
258 258
 		}
259 259
 	}
Please login to merge, or discard this patch.