Test Failed
Pull Request — master (#2668)
by Devin
07:48
created
includes/class-give-async-process.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @category Class
12 12
  * @author   WordImpress
13 13
  */
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
 		 * )
53 53
 		 */
54 54
 
55
-		$_post = give_clean( $_POST );
55
+		$_post = give_clean($_POST);
56 56
 
57
-		if ( empty( $_post ) || empty( $_post['data'] ) || empty( $_post['hook'] ) ) {
57
+		if (empty($_post) || empty($_post['data']) || empty($_post['hook'])) {
58 58
 			exit();
59 59
 		}
60 60
 
61 61
 		/**
62 62
 		 * Fire the hook.
63 63
 		 */
64
-		do_action( $_post['hook'], $_post['data'] );
64
+		do_action($_post['hook'], $_post['data']);
65 65
 
66 66
 		exit();
67 67
 	}
Please login to merge, or discard this patch.
includes/shortcodes.php 1 patch
Spacing   +112 added lines, -112 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,41 +23,41 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return string|bool
25 25
  */
26
-function give_donation_history( $atts ) {
26
+function give_donation_history($atts) {
27 27
 
28
-	$donation_history_args = shortcode_atts( array(
28
+	$donation_history_args = shortcode_atts(array(
29 29
 		'id'             => true,
30 30
 		'date'           => true,
31 31
 		'donor'          => false,
32 32
 		'amount'         => true,
33 33
 		'status'         => false,
34 34
 		'payment_method' => false,
35
-	), $atts, 'donation_history' );
35
+	), $atts, 'donation_history');
36 36
 
37 37
 	// Always show receipt link.
38 38
 	$donation_history_args['details'] = true;
39 39
 
40 40
 	// Set Donation History Shortcode Arguments in session variable.
41
-	Give()->session->set( 'give_donation_history_args', $donation_history_args );
41
+	Give()->session->set('give_donation_history_args', $donation_history_args);
42 42
 
43 43
 	// If payment_key query arg exists, return receipt instead of donation history.
44
-	if ( isset( $_GET['payment_key'] ) ) {
44
+	if (isset($_GET['payment_key'])) {
45 45
 		ob_start();
46 46
 
47
-		echo give_receipt_shortcode( array() );
47
+		echo give_receipt_shortcode(array());
48 48
 
49 49
 		// Display donation history link only if Receipt Access Session is available.
50
-		if ( give_get_receipt_session() ) {
50
+		if (give_get_receipt_session()) {
51 51
 			echo sprintf(
52 52
 				'<a href="%s">%s</a>',
53
-				esc_url( give_get_history_page_uri() ),
54
-				__( '&laquo; Return to All Donations', 'give' )
53
+				esc_url(give_get_history_page_uri()),
54
+				__('&laquo; Return to All Donations', 'give')
55 55
 			);
56 56
 		}
57 57
 		return ob_get_clean();
58 58
 	}
59 59
 
60
-	$email_access = give_get_option( 'email_access' );
60
+	$email_access = give_get_option('email_access');
61 61
 
62 62
 	/**
63 63
 	 * Determine access
@@ -68,31 +68,31 @@  discard block
 block discarded – undo
68 68
 	if (
69 69
 		is_user_logged_in() ||
70 70
 		false !== Give()->session->get_session_expiration() ||
71
-		( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists ) ||
71
+		(give_is_setting_enabled($email_access) && Give()->email_access->token_exists) ||
72 72
 		true === give_get_history_session()
73 73
 	) {
74 74
 		ob_start();
75
-		give_get_template_part( 'history', 'donations' );
75
+		give_get_template_part('history', 'donations');
76 76
 
77 77
 		return ob_get_clean();
78 78
 
79
-	} elseif ( give_is_setting_enabled( $email_access ) ) {
79
+	} elseif (give_is_setting_enabled($email_access)) {
80 80
 		// Is Email-based access enabled?
81 81
 		ob_start();
82
-		give_get_template_part( 'email', 'login-form' );
82
+		give_get_template_part('email', 'login-form');
83 83
 
84 84
 		return ob_get_clean();
85 85
 
86 86
 	} else {
87 87
 
88
-		$output = apply_filters( 'give_donation_history_nonuser_message', Give()->notices->print_frontend_notice( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) );
89
-		$output .= do_shortcode( '[give_login]' );
88
+		$output = apply_filters('give_donation_history_nonuser_message', Give()->notices->print_frontend_notice(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false));
89
+		$output .= do_shortcode('[give_login]');
90 90
 
91 91
 		return $output;
92 92
 	}
93 93
 }
94 94
 
95
-add_shortcode( 'donation_history', 'give_donation_history' );
95
+add_shortcode('donation_history', 'give_donation_history');
96 96
 
97 97
 /**
98 98
  * Donation Form Shortcode
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
  *
106 106
  * @return string
107 107
  */
108
-function give_form_shortcode( $atts ) {
109
-	$atts = shortcode_atts( array(
108
+function give_form_shortcode($atts) {
109
+	$atts = shortcode_atts(array(
110 110
 		'id'                    => '',
111 111
 		'show_title'            => true,
112 112
 		'show_goal'             => true,
@@ -114,21 +114,21 @@  discard block
 block discarded – undo
114 114
 		'float_labels'          => '',
115 115
 		'display_style'         => '',
116 116
 		'continue_button_title' => '',
117
-	), $atts, 'give_form' );
117
+	), $atts, 'give_form');
118 118
 
119 119
 	// Convert string to bool.
120
-	$atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN );
121
-	$atts['show_goal']  = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN );
120
+	$atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN);
121
+	$atts['show_goal']  = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN);
122 122
 
123 123
 	// get the Give Form
124 124
 	ob_start();
125
-	give_get_donation_form( $atts );
125
+	give_get_donation_form($atts);
126 126
 	$final_output = ob_get_clean();
127 127
 
128
-	return apply_filters( 'give_donate_form', $final_output, $atts );
128
+	return apply_filters('give_donate_form', $final_output, $atts);
129 129
 }
130 130
 
131
-add_shortcode( 'give_form', 'give_form_shortcode' );
131
+add_shortcode('give_form', 'give_form_shortcode');
132 132
 
133 133
 /**
134 134
  * Donation Form Goal Shortcode.
@@ -141,36 +141,36 @@  discard block
 block discarded – undo
141 141
  *
142 142
  * @return string
143 143
  */
144
-function give_goal_shortcode( $atts ) {
145
-	$atts = shortcode_atts( array(
144
+function give_goal_shortcode($atts) {
145
+	$atts = shortcode_atts(array(
146 146
 		'id'        => '',
147 147
 		'show_text' => true,
148 148
 		'show_bar'  => true,
149
-	), $atts, 'give_goal' );
149
+	), $atts, 'give_goal');
150 150
 
151 151
 	// get the Give Form.
152 152
 	ob_start();
153 153
 
154 154
 	// Sanity check 1: ensure there is an ID Provided.
155
-	if ( empty( $atts['id'] ) ) {
156
-		Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true );
155
+	if (empty($atts['id'])) {
156
+		Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true);
157 157
 	}
158 158
 
159 159
 	// Sanity check 2: Check the form even has Goals enabled.
160
-	if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) {
160
+	if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) {
161 161
 
162
-		Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true );
162
+		Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true);
163 163
 	} else {
164 164
 		// Passed all sanity checks: output Goal.
165
-		give_show_goal_progress( $atts['id'], $atts );
165
+		give_show_goal_progress($atts['id'], $atts);
166 166
 	}
167 167
 
168 168
 	$final_output = ob_get_clean();
169 169
 
170
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
170
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
171 171
 }
172 172
 
173
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
173
+add_shortcode('give_goal', 'give_goal_shortcode');
174 174
 
175 175
 
176 176
 /**
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
  *
188 188
  * @return string
189 189
  */
190
-function give_login_form_shortcode( $atts ) {
190
+function give_login_form_shortcode($atts) {
191 191
 
192
-	$atts = shortcode_atts( array(
192
+	$atts = shortcode_atts(array(
193 193
 		// Add backward compatibility for redirect attribute.
194 194
 		'redirect' => '',
195 195
 		'login-redirect'  => '',
196 196
 		'logout-redirect' => '',
197
-	), $atts, 'give_login' );
197
+	), $atts, 'give_login');
198 198
 
199 199
 	// Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
200
-	$atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' );
200
+	$atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : '');
201 201
 
202
-	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
202
+	return give_login_form($atts['login-redirect'], $atts['logout-redirect']);
203 203
 }
204 204
 
205
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
205
+add_shortcode('give_login', 'give_login_form_shortcode');
206 206
 
207 207
 /**
208 208
  * Register Shortcode.
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return string
219 219
  */
220
-function give_register_form_shortcode( $atts ) {
221
-	$atts = shortcode_atts( array(
220
+function give_register_form_shortcode($atts) {
221
+	$atts = shortcode_atts(array(
222 222
 		'redirect' => '',
223
-	), $atts, 'give_register' );
223
+	), $atts, 'give_register');
224 224
 
225
-	return give_register_form( $atts['redirect'] );
225
+	return give_register_form($atts['redirect']);
226 226
 }
227 227
 
228
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
228
+add_shortcode('give_register', 'give_register_form_shortcode');
229 229
 
230 230
 /**
231 231
  * Receipt Shortcode.
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return string
240 240
  */
241
-function give_receipt_shortcode( $atts ) {
241
+function give_receipt_shortcode($atts) {
242 242
 
243 243
 	global $give_receipt_args;
244 244
 
245
-	$give_receipt_args = shortcode_atts( array(
246
-		'error'          => __( 'You are missing the payment key to view this donation receipt.', 'give' ),
245
+	$give_receipt_args = shortcode_atts(array(
246
+		'error'          => __('You are missing the payment key to view this donation receipt.', 'give'),
247 247
 		'price'          => true,
248 248
 		'donor'          => true,
249 249
 		'date'           => true,
@@ -252,49 +252,49 @@  discard block
 block discarded – undo
252 252
 		'payment_id'     => true,
253 253
 		'payment_status' => false,
254 254
 		'status_notice'  => true,
255
-	), $atts, 'give_receipt' );
255
+	), $atts, 'give_receipt');
256 256
 
257 257
 	// set $session var
258 258
 	$session = give_get_purchase_session();
259 259
 
260 260
 	// set payment key var
261
-	if ( isset( $_GET['payment_key'] ) ) {
262
-		$payment_key = urldecode( $_GET['payment_key'] );
263
-	} elseif ( $session ) {
261
+	if (isset($_GET['payment_key'])) {
262
+		$payment_key = urldecode($_GET['payment_key']);
263
+	} elseif ($session) {
264 264
 		$payment_key = $session['purchase_key'];
265
-	} elseif ( $give_receipt_args['payment_key'] ) {
265
+	} elseif ($give_receipt_args['payment_key']) {
266 266
 		$payment_key = $give_receipt_args['payment_key'];
267 267
 	}
268 268
 
269
-	$email_access = give_get_option( 'email_access' );
269
+	$email_access = give_get_option('email_access');
270 270
 
271 271
 	// No payment_key found & Email Access is Turned on.
272
-	if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
272
+	if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
273 273
 
274 274
 		ob_start();
275 275
 
276
-		give_get_template_part( 'email-login-form' );
276
+		give_get_template_part('email-login-form');
277 277
 
278 278
 		return ob_get_clean();
279 279
 
280
-	} elseif ( ! isset( $payment_key ) ) {
280
+	} elseif ( ! isset($payment_key)) {
281 281
 
282
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
282
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
283 283
 
284 284
 	}
285 285
 
286
-	$user_can_view = give_can_view_receipt( $payment_key );
286
+	$user_can_view = give_can_view_receipt($payment_key);
287 287
 
288 288
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt.
289
-	if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
289
+	if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
290 290
 
291 291
 		ob_start();
292 292
 
293
-		give_get_template_part( 'email-login-form' );
293
+		give_get_template_part('email-login-form');
294 294
 
295 295
 		return ob_get_clean();
296 296
 
297
-	} elseif ( ! $user_can_view ) {
297
+	} elseif ( ! $user_can_view) {
298 298
 
299 299
 		global $give_login_redirect;
300 300
 
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 
303 303
 		ob_start();
304 304
 
305
-		Give()->notices->print_frontend_notice( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) );
305
+		Give()->notices->print_frontend_notice(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give')));
306 306
 
307
-		give_get_template_part( 'shortcode', 'login' );
307
+		give_get_template_part('shortcode', 'login');
308 308
 
309 309
 		$login_form = ob_get_clean();
310 310
 
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
 	 * or if user is logged out and donation was made as a guest, the donation session is checked for
319 319
 	 * or if user is logged in and the user can view sensitive shop data.
320 320
 	 */
321
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
322
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
321
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
322
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
323 323
 	}
324 324
 
325 325
 	ob_start();
326 326
 
327
-	give_get_template_part( 'shortcode', 'receipt' );
327
+	give_get_template_part('shortcode', 'receipt');
328 328
 
329 329
 	$display = ob_get_clean();
330 330
 
331 331
 	return $display;
332 332
 }
333 333
 
334
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
334
+add_shortcode('give_receipt', 'give_receipt_shortcode');
335 335
 
336 336
 /**
337 337
  * Profile Editor Shortcode.
@@ -350,25 +350,25 @@  discard block
 block discarded – undo
350 350
  *
351 351
  * @return string Output generated from the profile editor
352 352
  */
353
-function give_profile_editor_shortcode( $atts ) {
353
+function give_profile_editor_shortcode($atts) {
354 354
 
355 355
 	ob_start();
356 356
 
357 357
 	// Restrict access to donor profile, if donor and user are disconnected.
358
-	$is_donor_disconnected = get_user_meta( get_current_user_id(), '_give_is_donor_disconnected', true );
359
-	if ( is_user_logged_in() && $is_donor_disconnected ) {
360
-		Give()->notices->print_frontend_notice( __( 'Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give' ), true, 'error' );
358
+	$is_donor_disconnected = get_user_meta(get_current_user_id(), '_give_is_donor_disconnected', true);
359
+	if (is_user_logged_in() && $is_donor_disconnected) {
360
+		Give()->notices->print_frontend_notice(__('Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give'), true, 'error');
361 361
 		return false;
362 362
 	}
363 363
 
364
-	give_get_template_part( 'shortcode', 'profile-editor' );
364
+	give_get_template_part('shortcode', 'profile-editor');
365 365
 
366 366
 	$display = ob_get_clean();
367 367
 
368 368
 	return $display;
369 369
 }
370 370
 
371
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
371
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
372 372
 
373 373
 /**
374 374
  * Process Profile Updater Form.
@@ -381,29 +381,29 @@  discard block
 block discarded – undo
381 381
  *
382 382
  * @return bool
383 383
  */
384
-function give_process_profile_editor_updates( $data ) {
384
+function give_process_profile_editor_updates($data) {
385 385
 	// Profile field change request.
386
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
386
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
387 387
 		return false;
388 388
 	}
389 389
 
390 390
 	// Nonce security.
391
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
391
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
392 392
 		return false;
393 393
 	}
394 394
 
395 395
 	$user_id       = get_current_user_id();
396
-	$old_user_data = get_userdata( $user_id );
396
+	$old_user_data = get_userdata($user_id);
397 397
 
398 398
 	/* @var Give_Donor $donor */
399
-	$donor = new Give_Donor( $user_id, true );
399
+	$donor = new Give_Donor($user_id, true);
400 400
 
401
-	$display_name     = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
402
-	$first_name       = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
403
-	$last_name        = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
404
-	$email            = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
405
-	$password         = ! empty( $data['give_new_user_pass1'] ) ? $data['give_new_user_pass1'] : '';
406
-	$confirm_password = ! empty( $data['give_new_user_pass2'] ) ? $data['give_new_user_pass2'] : '';
401
+	$display_name     = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
402
+	$first_name       = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
403
+	$last_name        = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
404
+	$email            = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
405
+	$password         = ! empty($data['give_new_user_pass1']) ? $data['give_new_user_pass1'] : '';
406
+	$confirm_password = ! empty($data['give_new_user_pass2']) ? $data['give_new_user_pass2'] : '';
407 407
 
408 408
 	$userdata = array(
409 409
 		'ID'           => $user_id,
@@ -422,55 +422,55 @@  discard block
 block discarded – undo
422 422
 	 * @param int $user_id The ID of the user.
423 423
 	 * @param array $userdata User info, including ID, first name, last name, display name and email.
424 424
 	 */
425
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
425
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
426 426
 
427 427
 	// Make sure to validate first name of existing donors.
428
-	if ( empty( $first_name ) ) {
428
+	if (empty($first_name)) {
429 429
 		// Empty First Name.
430
-		give_set_error( 'empty_first_name', __( 'Please enter your first name.', 'give' ) );
430
+		give_set_error('empty_first_name', __('Please enter your first name.', 'give'));
431 431
 	}
432 432
 
433 433
 	// Make sure to validate passwords for existing Donors.
434
-	give_validate_user_password( $password, $confirm_password );
434
+	give_validate_user_password($password, $confirm_password);
435 435
 
436
-	if ( empty( $email ) ) {
436
+	if (empty($email)) {
437 437
 		// Make sure email should not be empty.
438
-		give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) );
438
+		give_set_error('email_empty', __('The email you entered is empty.', 'give'));
439 439
 
440
-	} elseif ( ! is_email( $email ) ) {
440
+	} elseif ( ! is_email($email)) {
441 441
 		// Make sure email should be valid.
442
-		give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) );
442
+		give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give'));
443 443
 
444
-	} elseif ( $email != $old_user_data->user_email ) {
444
+	} elseif ($email != $old_user_data->user_email) {
445 445
 		// Make sure the new email doesn't belong to another user
446
-		if ( email_exists( $email ) ) {
447
-			give_set_error( 'user_email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) );
448
-		} elseif ( Give()->donors->get_donor_by( 'email', $email ) ) {
446
+		if (email_exists($email)) {
447
+			give_set_error('user_email_exists', __('The email you entered belongs to another user. Please use another.', 'give'));
448
+		} elseif (Give()->donors->get_donor_by('email', $email)) {
449 449
 			// Make sure the new email doesn't belong to another user
450
-			give_set_error( 'donor_email_exists', __( 'The email you entered belongs to another donor. Please use another.', 'give' ) );
450
+			give_set_error('donor_email_exists', __('The email you entered belongs to another donor. Please use another.', 'give'));
451 451
 		}
452 452
 	}
453 453
 
454 454
 	// Check for errors.
455 455
 	$errors = give_get_errors();
456 456
 
457
-	if ( $errors ) {
457
+	if ($errors) {
458 458
 		// Send back to the profile editor if there are errors.
459
-		wp_redirect( $data['give_redirect'] );
459
+		wp_redirect($data['give_redirect']);
460 460
 		give_die();
461 461
 	}
462 462
 
463 463
 	// Update Donor First Name and Last Name.
464
-	Give()->donors->update( $donor->id, array(
465
-		'name' => trim( "{$first_name} {$last_name}" ),
466
-	) );
467
-	Give()->donor_meta->update_meta( $donor->id, '_give_donor_first_name', $first_name );
468
-	Give()->donor_meta->update_meta( $donor->id, '_give_donor_last_name', $last_name );
464
+	Give()->donors->update($donor->id, array(
465
+		'name' => trim("{$first_name} {$last_name}"),
466
+	));
467
+	Give()->donor_meta->update_meta($donor->id, '_give_donor_first_name', $first_name);
468
+	Give()->donor_meta->update_meta($donor->id, '_give_donor_last_name', $last_name);
469 469
 
470 470
 	// Update the user.
471
-	$updated = wp_update_user( $userdata );
471
+	$updated = wp_update_user($userdata);
472 472
 
473
-	if ( $updated ) {
473
+	if ($updated) {
474 474
 
475 475
 		/**
476 476
 		 * Fires after updating user profile.
@@ -480,12 +480,12 @@  discard block
 block discarded – undo
480 480
 		 * @param int $user_id The ID of the user.
481 481
 		 * @param array $userdata User info, including ID, first name, last name, display name and email.
482 482
 		 */
483
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
484
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
483
+		do_action('give_user_profile_updated', $user_id, $userdata);
484
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
485 485
 		give_die();
486 486
 	}
487 487
 
488 488
 	return false;
489 489
 }
490 490
 
491
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
491
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
Please login to merge, or discard this patch.
includes/login-register.php 1 patch
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,24 +26,24 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return string Login form
28 28
  */
29
-function give_login_form( $login_redirect = '', $logout_redirect = '' ) {
29
+function give_login_form($login_redirect = '', $logout_redirect = '') {
30 30
 
31
-	if ( empty( $login_redirect ) ) {
32
-		$login_redirect = add_query_arg( 'give-login-success', 'true', give_get_history_page_uri() );
31
+	if (empty($login_redirect)) {
32
+		$login_redirect = add_query_arg('give-login-success', 'true', give_get_history_page_uri());
33 33
 	}
34 34
 
35
-	if ( empty( $logout_redirect ) ) {
36
-		$logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
35
+	if (empty($logout_redirect)) {
36
+		$logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url());
37 37
 	}
38 38
 
39 39
 	// Add user_logout action to logout url.
40 40
 	$logout_redirect = add_query_arg(
41 41
 		array(
42 42
 			'give_action'          => 'user_logout',
43
-			'give_logout_nonce'    => wp_create_nonce( 'give-logout-nonce' ),
44
-			'give_logout_redirect' => urlencode( $logout_redirect ),
43
+			'give_logout_nonce'    => wp_create_nonce('give-logout-nonce'),
44
+			'give_logout_redirect' => urlencode($logout_redirect),
45 45
 		),
46
-		home_url( '/' )
46
+		home_url('/')
47 47
 	);
48 48
 
49 49
 	ob_start();
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		)
57 57
 	);
58 58
 
59
-	return apply_filters( 'give_login_form', ob_get_clean() );
59
+	return apply_filters('give_login_form', ob_get_clean());
60 60
 }
61 61
 
62 62
 /**
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
  *
70 70
  * @return string Register form
71 71
  */
72
-function give_register_form( $redirect = '' ) {
73
-	if ( empty( $redirect ) ) {
72
+function give_register_form($redirect = '') {
73
+	if (empty($redirect)) {
74 74
 		$redirect = give_get_current_page_url();
75 75
 	}
76 76
 
77 77
 	ob_start();
78 78
 
79
-	if ( ! is_user_logged_in() ) {
79
+	if ( ! is_user_logged_in()) {
80 80
 		give_get_template(
81 81
 			'shortcode-register',
82 82
 			array(
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		);
86 86
 	}
87 87
 
88
-	return apply_filters( 'give_register_form', ob_get_clean() );
88
+	return apply_filters('give_register_form', ob_get_clean());
89 89
 }
90 90
 
91 91
 /**
@@ -97,40 +97,40 @@  discard block
 block discarded – undo
97 97
  *
98 98
  * @return void
99 99
  */
100
-function give_process_login_form( $data ) {
101
-	if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) {
100
+function give_process_login_form($data) {
101
+	if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) {
102 102
 
103 103
 		// Set Receipt Access Session.
104
-		if ( ! empty( $_GET['payment_key'] ) ) {
105
-			Give()->session->set( 'receipt_access', true );
104
+		if ( ! empty($_GET['payment_key'])) {
105
+			Give()->session->set('receipt_access', true);
106 106
 		}
107 107
 
108
-		$user_data = get_user_by( 'login', $data['give_user_login'] );
109
-		if ( ! $user_data ) {
110
-			$user_data = get_user_by( 'email', $data['give_user_login'] );
108
+		$user_data = get_user_by('login', $data['give_user_login']);
109
+		if ( ! $user_data) {
110
+			$user_data = get_user_by('email', $data['give_user_login']);
111 111
 		}
112
-		if ( $user_data ) {
112
+		if ($user_data) {
113 113
 			$user_ID    = $user_data->ID;
114 114
 			$user_email = $user_data->user_email;
115
-			if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_ID ) ) {
116
-				give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] );
115
+			if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_ID)) {
116
+				give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']);
117 117
 			} else {
118
-				give_set_error( 'password_incorrect', __( 'The password you entered is incorrect.', 'give' ) );
118
+				give_set_error('password_incorrect', __('The password you entered is incorrect.', 'give'));
119 119
 			}
120 120
 		} else {
121
-			give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
121
+			give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
122 122
 		}
123 123
 		// Check for errors and redirect if none present
124 124
 		$errors = give_get_errors();
125
-		if ( ! $errors ) {
126
-			$redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID );
127
-			wp_redirect( $redirect );
125
+		if ( ! $errors) {
126
+			$redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID);
127
+			wp_redirect($redirect);
128 128
 			give_die();
129 129
 		}
130 130
 	}
131 131
 }
132 132
 
133
-add_action( 'give_user_login', 'give_process_login_form' );
133
+add_action('give_user_login', 'give_process_login_form');
134 134
 
135 135
 
136 136
 /**
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
  *
143 143
  * @return void
144 144
  */
145
-function give_process_user_logout( $data ) {
146
-	if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) {
145
+function give_process_user_logout($data) {
146
+	if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) {
147 147
 
148 148
 		// Prevent occurring of any custom action on wp_logout.
149
-		remove_all_actions( 'wp_logout' );
149
+		remove_all_actions('wp_logout');
150 150
 
151 151
 		/**
152 152
 		 * Fires before processing user logout.
153 153
 		 *
154 154
 		 * @since 1.0
155 155
 		 */
156
-		do_action( 'give_before_user_logout' );
156
+		do_action('give_before_user_logout');
157 157
 
158 158
 		// Logout user.
159 159
 		wp_logout();
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 		 *
164 164
 		 * @since 1.0
165 165
 		 */
166
-		do_action( 'give_after_user_logout' );
166
+		do_action('give_after_user_logout');
167 167
 
168
-		wp_redirect( $data['give_logout_redirect'] );
168
+		wp_redirect($data['give_logout_redirect']);
169 169
 		give_die();
170 170
 	}
171 171
 }
172 172
 
173
-add_action( 'give_user_logout', 'give_process_user_logout' );
173
+add_action('give_user_logout', 'give_process_user_logout');
174 174
 
175 175
 /**
176 176
  * Log User In
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
  *
184 184
  * @return bool
185 185
  */
186
-function give_log_user_in( $user_id, $user_login, $user_pass ) {
186
+function give_log_user_in($user_id, $user_login, $user_pass) {
187 187
 
188
-	if ( $user_id < 1 ) {
188
+	if ($user_id < 1) {
189 189
 		return false;
190 190
 	}
191 191
 
192
-	wp_set_auth_cookie( $user_id );
193
-	wp_set_current_user( $user_id, $user_login );
192
+	wp_set_auth_cookie($user_id);
193
+	wp_set_current_user($user_id, $user_login);
194 194
 
195 195
 	/**
196 196
 	 * Fires after the user has successfully logged in.
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @param string $user_login Username.
201 201
 	 * @param WP_User $$user      WP_User object of the logged-in user.
202 202
 	 */
203
-	do_action( 'wp_login', $user_login, get_userdata( $user_id ) );
203
+	do_action('wp_login', $user_login, get_userdata($user_id));
204 204
 
205 205
 	/**
206 206
 	 * Fires after give user has successfully logged in.
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	 * @param string $user_login Username.
212 212
 	 * @param string $user_pass  User password.
213 213
 	 */
214
-	do_action( 'give_log_user_in', $user_id, $user_login, $user_pass );
214
+	do_action('give_log_user_in', $user_id, $user_login, $user_pass);
215 215
 }
216 216
 
217 217
 
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
  *
225 225
  * @return bool
226 226
  */
227
-function give_process_register_form( $data ) {
227
+function give_process_register_form($data) {
228 228
 
229
-	if ( is_user_logged_in() ) {
229
+	if (is_user_logged_in()) {
230 230
 		return false;
231 231
 	}
232 232
 
233
-	if ( empty( $_POST['give_register_submit'] ) ) {
233
+	if (empty($_POST['give_register_submit'])) {
234 234
 		return false;
235 235
 	}
236 236
 
@@ -239,38 +239,38 @@  discard block
 block discarded – undo
239 239
 	 *
240 240
 	 * @since 1.0
241 241
 	 */
242
-	do_action( 'give_pre_process_register_form' );
242
+	do_action('give_pre_process_register_form');
243 243
 
244
-	if ( empty( $data['give_user_login'] ) ) {
245
-		give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) );
244
+	if (empty($data['give_user_login'])) {
245
+		give_set_error('empty_username', esc_html__('Invalid username.', 'give'));
246 246
 	}
247 247
 
248
-	if ( username_exists( $data['give_user_login'] ) ) {
249
-		give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
248
+	if (username_exists($data['give_user_login'])) {
249
+		give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
250 250
 	}
251 251
 
252
-	if ( ! validate_username( $data['give_user_login'] ) ) {
253
-		give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
252
+	if ( ! validate_username($data['give_user_login'])) {
253
+		give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
254 254
 	}
255 255
 
256
-	if ( email_exists( $data['give_user_email'] ) ) {
257
-		give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) );
256
+	if (email_exists($data['give_user_email'])) {
257
+		give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give'));
258 258
 	}
259 259
 
260
-	if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) {
261
-		give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
260
+	if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) {
261
+		give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
262 262
 	}
263 263
 
264
-	if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) {
265
-		give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) );
264
+	if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) {
265
+		give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give'));
266 266
 	}
267 267
 
268
-	if ( empty( $_POST['give_user_pass'] ) ) {
269
-		give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) );
268
+	if (empty($_POST['give_user_pass'])) {
269
+		give_set_error('empty_password', esc_html__('Please enter a password.', 'give'));
270 270
 	}
271 271
 
272
-	if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) {
273
-		give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
272
+	if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) {
273
+		give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
274 274
 	}
275 275
 
276 276
 	/**
@@ -278,29 +278,29 @@  discard block
 block discarded – undo
278 278
 	 *
279 279
 	 * @since 1.0
280 280
 	 */
281
-	do_action( 'give_process_register_form' );
281
+	do_action('give_process_register_form');
282 282
 
283 283
 	// Check for errors and redirect if none present
284 284
 	$errors = give_get_errors();
285 285
 
286
-	if ( empty( $errors ) ) {
286
+	if (empty($errors)) {
287 287
 
288
-		$redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] );
288
+		$redirect = apply_filters('give_register_redirect', $data['give_redirect']);
289 289
 
290
-		give_register_and_login_new_user( array(
290
+		give_register_and_login_new_user(array(
291 291
 			'user_login'      => $data['give_user_login'],
292 292
 			'user_pass'       => $data['give_user_pass'],
293 293
 			'user_email'      => $data['give_user_email'],
294
-			'user_registered' => date( 'Y-m-d H:i:s' ),
295
-			'role'            => get_option( 'default_role' ),
296
-		) );
294
+			'user_registered' => date('Y-m-d H:i:s'),
295
+			'role'            => get_option('default_role'),
296
+		));
297 297
 
298
-		wp_redirect( $redirect );
298
+		wp_redirect($redirect);
299 299
 		give_die();
300 300
 	}
301 301
 }
302 302
 
303
-add_action( 'give_user_register', 'give_process_register_form' );
303
+add_action('give_user_register', 'give_process_register_form');
304 304
 
305 305
 
306 306
 /**
@@ -313,23 +313,23 @@  discard block
 block discarded – undo
313 313
 function give_email_access_login() {
314 314
 
315 315
 	// Verify nonce.
316
-	if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'give' ) ) {
316
+	if ( ! isset($_POST['_wpnonce']) || ! wp_verify_nonce($_POST['_wpnonce'], 'give')) {
317 317
 		return false;
318 318
 	}
319 319
 
320 320
 	// Need email to proceed.
321
-	$email = isset( $_POST['give_email'] ) ? give_clean( $_POST['give_email'] ) : '';
322
-	if ( empty( $email ) ) {
323
-		give_set_error( 'give_empty_email', __( 'Please enter the email address you used for your donation.', 'give' ) );
321
+	$email = isset($_POST['give_email']) ? give_clean($_POST['give_email']) : '';
322
+	if (empty($email)) {
323
+		give_set_error('give_empty_email', __('Please enter the email address you used for your donation.', 'give'));
324 324
 	}
325 325
 
326
-	$recaptcha_key    = give_get_option( 'recaptcha_key' );
327
-	$recaptcha_secret = give_get_option( 'recaptcha_secret' );
328
-	$enable_recaptcha = ! empty( $recaptcha_key ) && ! empty( $recaptcha_secret ) ? true : false;
329
-	$access_token     = ! empty( $_GET['payment_key'] ) ? $_GET['payment_key'] : '';
326
+	$recaptcha_key    = give_get_option('recaptcha_key');
327
+	$recaptcha_secret = give_get_option('recaptcha_secret');
328
+	$enable_recaptcha = ! empty($recaptcha_key) && ! empty($recaptcha_secret) ? true : false;
329
+	$access_token     = ! empty($_GET['payment_key']) ? $_GET['payment_key'] : '';
330 330
 
331 331
 	// Use reCAPTCHA.
332
-	if ( $enable_recaptcha ) {
332
+	if ($enable_recaptcha) {
333 333
 
334 334
 		$args = array(
335 335
 			'secret'   => $recaptcha_secret,
@@ -337,43 +337,43 @@  discard block
 block discarded – undo
337 337
 			'remoteip' => $_POST['give_ip'],
338 338
 		);
339 339
 
340
-		if ( ! empty( $args['response'] ) ) {
341
-			$request = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array(
340
+		if ( ! empty($args['response'])) {
341
+			$request = wp_remote_post('https://www.google.com/recaptcha/api/siteverify', array(
342 342
 				'body' => $args,
343
-			) );
344
-			if ( ! is_wp_error( $request ) || 200 == wp_remote_retrieve_response_code( $request ) ) {
343
+			));
344
+			if ( ! is_wp_error($request) || 200 == wp_remote_retrieve_response_code($request)) {
345 345
 
346
-				$response = json_decode( $request['body'], true );
346
+				$response = json_decode($request['body'], true);
347 347
 
348 348
 				// reCAPTCHA fail.
349
-				if ( ! $response['success'] ) {
350
-					give_set_error( 'give_recaptcha_test_failed', apply_filters( 'give_recaptcha_test_failed_message', __( 'reCAPTCHA test failed.', 'give' ) ) );
349
+				if ( ! $response['success']) {
350
+					give_set_error('give_recaptcha_test_failed', apply_filters('give_recaptcha_test_failed_message', __('reCAPTCHA test failed.', 'give')));
351 351
 				}
352 352
 			} else {
353 353
 
354 354
 				// Connection issue.
355
-				give_set_error( 'give_recaptcha_connection_issue', apply_filters( 'give_recaptcha_connection_issue_message', __( 'Unable to connect to reCAPTCHA server.', 'give' ) ) );
355
+				give_set_error('give_recaptcha_connection_issue', apply_filters('give_recaptcha_connection_issue_message', __('Unable to connect to reCAPTCHA server.', 'give')));
356 356
 
357 357
 			}  // End if().
358 358
 		} else {
359 359
 
360
-			give_set_error( 'give_recaptcha_failed', apply_filters( 'give_recaptcha_failed_message', __( 'It looks like the reCAPTCHA test has failed.', 'give' ) ) );
360
+			give_set_error('give_recaptcha_failed', apply_filters('give_recaptcha_failed_message', __('It looks like the reCAPTCHA test has failed.', 'give')));
361 361
 
362 362
 		}  // End if().
363 363
 	}  // End if().
364 364
 
365 365
 	// If no errors or only expired token key error - then send email.
366
-	if ( ! give_get_errors() ) {
366
+	if ( ! give_get_errors()) {
367 367
 
368
-		$donor = Give()->donors->get_donor_by( 'email', $email );
368
+		$donor = Give()->donors->get_donor_by('email', $email);
369 369
 
370 370
 		Give()->email_access->init();
371 371
 
372 372
 		// Verify that donor object is present and donor is connected with its user profile or not.
373
-		if ( is_object( $donor ) ) {
373
+		if (is_object($donor)) {
374 374
 
375 375
 			// Verify that email can be sent.
376
-			if ( ! Give()->email_access->can_send_email( $donor->id ) ) {
376
+			if ( ! Give()->email_access->can_send_email($donor->id)) {
377 377
 
378 378
 				$_POST['email-access-exhausted'] = true;
379 379
 
@@ -381,10 +381,10 @@  discard block
 block discarded – undo
381 381
 
382 382
 			} else {
383 383
 				// Send the email. Requests not
384
-				$email_sent = Give()->email_access->send_email( $donor->id, $donor->email );
384
+				$email_sent = Give()->email_access->send_email($donor->id, $donor->email);
385 385
 
386
-				if ( ! $email_sent ) {
387
-					give_set_error( 'give_email_access_send_issue', __( 'Unable to send email. Please try again.', 'give' ) );
386
+				if ( ! $email_sent) {
387
+					give_set_error('give_email_access_send_issue', __('Unable to send email. Please try again.', 'give'));
388 388
 					return false;
389 389
 				}
390 390
 
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
 			}
395 395
 		} else {
396 396
 
397
-			give_set_error( 'give-no-donations', __( 'We were unable to find any donations associated with the email address provided. Please try again using another email.', 'give' ) );
397
+			give_set_error('give-no-donations', __('We were unable to find any donations associated with the email address provided. Please try again using another email.', 'give'));
398 398
 
399 399
 		}
400 400
 	} // End if().
401 401
 
402 402
 }
403 403
 
404
-add_action( 'give_email_access_form_login', 'give_email_access_login' );
404
+add_action('give_email_access_form_login', 'give_email_access_login');
Please login to merge, or discard this patch.
includes/class-notices.php 1 patch
Spacing   +104 added lines, -104 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
 
@@ -53,21 +53,21 @@  discard block
 block discarded – undo
53 53
 	 * @since 1.8.9
54 54
 	 */
55 55
 	public function __construct() {
56
-		add_action( 'admin_notices', array( $this, 'render_admin_notices' ), 999 );
57
-		add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) );
56
+		add_action('admin_notices', array($this, 'render_admin_notices'), 999);
57
+		add_action('give_dismiss_notices', array($this, 'dismiss_notices'));
58 58
 
59
-		add_action( 'give_frontend_notices', array( $this, 'render_frontend_notices' ), 999 );
60
-		add_action( 'give_donation_form_before_personal_info', array( $this, 'render_frontend_notices' ) );
61
-		add_action( 'give_ajax_donation_errors', array( $this, 'render_frontend_notices' ) );
59
+		add_action('give_frontend_notices', array($this, 'render_frontend_notices'), 999);
60
+		add_action('give_donation_form_before_personal_info', array($this, 'render_frontend_notices'));
61
+		add_action('give_ajax_donation_errors', array($this, 'render_frontend_notices'));
62 62
 
63 63
 		/**
64 64
 		 * Backward compatibility for deprecated params.
65 65
 		 *
66 66
 		 * @since 1.8.14
67 67
 		 */
68
-		add_filter( 'give_register_notice_args', array( $this, 'bc_deprecated_params' ) );
69
-		add_filter( 'give_frontend_errors_args', array( $this, 'bc_deprecated_params' ) );
70
-		add_filter( 'give_frontend_notice_args', array( $this, 'bc_deprecated_params' ) );
68
+		add_filter('give_register_notice_args', array($this, 'bc_deprecated_params'));
69
+		add_filter('give_frontend_errors_args', array($this, 'bc_deprecated_params'));
70
+		add_filter('give_frontend_notice_args', array($this, 'bc_deprecated_params'));
71 71
 	}
72 72
 
73 73
 	/**
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return array
82 82
 	 */
83
-	public function bc_deprecated_params( $args ) {
83
+	public function bc_deprecated_params($args) {
84 84
 		/**
85 85
 		 *  Param: auto_dismissible
86 86
 		 *  deprecated in 1.8.14
87 87
 		 *
88 88
 		 *  Check if auto_dismissible is set and it true then unset and change dismissible parameter value to auto
89 89
 		 */
90
-		if ( isset( $args['auto_dismissible'] ) ) {
91
-			if ( ! empty( $args['auto_dismissible'] ) ) {
90
+		if (isset($args['auto_dismissible'])) {
91
+			if ( ! empty($args['auto_dismissible'])) {
92 92
 				$args['dismissible'] = 'auto';
93 93
 			}
94 94
 			// unset auto_dismissible as it has been deprecated.
95
-			unset( $args['auto_dismissible'] );
95
+			unset($args['auto_dismissible']);
96 96
 		}
97 97
 
98 98
 		return $args;
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return bool
110 110
 	 */
111
-	public function register_notice( $notice_args ) {
111
+	public function register_notice($notice_args) {
112 112
 		// Bailout.
113
-		if ( empty( $notice_args['id'] ) || array_key_exists( $notice_args['id'], self::$notices ) ) {
113
+		if (empty($notice_args['id']) || array_key_exists($notice_args['id'], self::$notices)) {
114 114
 			return false;
115 115
 		}
116 116
 
@@ -159,39 +159,39 @@  discard block
 block discarded – undo
159 159
 		 *
160 160
 		 * @since 1.8.14
161 161
 		 */
162
-		$notice_args = apply_filters( 'give_register_notice_args', $notice_args );
162
+		$notice_args = apply_filters('give_register_notice_args', $notice_args);
163 163
 
164 164
 		// Set extra dismiss links if any.
165
-		if ( false !== strpos( $notice_args['description'], 'data-dismiss-interval' ) ) {
165
+		if (false !== strpos($notice_args['description'], 'data-dismiss-interval')) {
166 166
 
167
-			preg_match_all( "/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link );
167
+			preg_match_all("/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link);
168 168
 
169
-			if ( ! empty( $extra_notice_dismiss_link ) ) {
170
-				$extra_notice_dismiss_links = array_chunk( current( $extra_notice_dismiss_link ), 3 );
171
-				foreach ( $extra_notice_dismiss_links as $extra_notice_dismiss_link ) {
169
+			if ( ! empty($extra_notice_dismiss_link)) {
170
+				$extra_notice_dismiss_links = array_chunk(current($extra_notice_dismiss_link), 3);
171
+				foreach ($extra_notice_dismiss_links as $extra_notice_dismiss_link) {
172 172
 					// Create array og key ==> value by parsing query string created after renaming data attributes.
173
-					$data_attribute_query_str = str_replace( array( 'data-', '-', '"' ), array(
173
+					$data_attribute_query_str = str_replace(array('data-', '-', '"'), array(
174 174
 						'',
175 175
 						'_',
176 176
 						'',
177
-					), implode( '&', $extra_notice_dismiss_link ) );
177
+					), implode('&', $extra_notice_dismiss_link));
178 178
 
179
-					$notice_args['extra_links'][] = wp_parse_args( $data_attribute_query_str );
179
+					$notice_args['extra_links'][] = wp_parse_args($data_attribute_query_str);
180 180
 				}
181 181
 			}
182 182
 		}
183 183
 
184 184
 
185
-		self::$notices[ $notice_args['id'] ] = $notice_args;
185
+		self::$notices[$notice_args['id']] = $notice_args;
186 186
 
187 187
 		// Auto set show param if not already set.
188
-		if ( ! isset( self::$notices[ $notice_args['id'] ]['show'] ) ) {
189
-			self::$notices[ $notice_args['id'] ]['show'] = $this->is_notice_dismissed( $notice_args ) ? false : true;
188
+		if ( ! isset(self::$notices[$notice_args['id']]['show'])) {
189
+			self::$notices[$notice_args['id']]['show'] = $this->is_notice_dismissed($notice_args) ? false : true;
190 190
 		}
191 191
 
192 192
 		// Auto set time interval for shortly.
193
-		if ( 'shortly' === self::$notices[ $notice_args['id'] ]['dismiss_interval'] ) {
194
-			self::$notices[ $notice_args['id'] ]['dismiss_interval_time'] = DAY_IN_SECONDS;
193
+		if ('shortly' === self::$notices[$notice_args['id']]['dismiss_interval']) {
194
+			self::$notices[$notice_args['id']]['dismiss_interval_time'] = DAY_IN_SECONDS;
195 195
 		}
196 196
 
197 197
 		return true;
@@ -205,51 +205,51 @@  discard block
 block discarded – undo
205 205
 	 */
206 206
 	public function render_admin_notices() {
207 207
 		// Bailout.
208
-		if ( empty( self::$notices ) ) {
208
+		if (empty(self::$notices)) {
209 209
 			return;
210 210
 		}
211 211
 
212 212
 		$output = '';
213 213
 
214
-		foreach ( self::$notices as $notice_id => $notice ) {
214
+		foreach (self::$notices as $notice_id => $notice) {
215 215
 			// Check flag set to true to show notice.
216
-			if ( ! $notice['show'] ) {
216
+			if ( ! $notice['show']) {
217 217
 				continue;
218 218
 			}
219 219
 
220 220
 
221 221
 			// Render custom html.
222
-			if( ! empty( $notice['description_html'] ) ) {
222
+			if ( ! empty($notice['description_html'])) {
223 223
 				$output .= "{$notice['description_html']} \n";
224 224
 				continue;
225 225
 			}
226 226
 
227 227
 			// Check if notice dismissible or not.
228
-			if ( ! self::$has_auto_dismissible_notice ) {
229
-				self::$has_auto_dismissible_notice = ( 'auto' === $notice['dismissible'] );
228
+			if ( ! self::$has_auto_dismissible_notice) {
229
+				self::$has_auto_dismissible_notice = ('auto' === $notice['dismissible']);
230 230
 			}
231 231
 
232 232
 			// Check if notice dismissible or not.
233
-			if ( ! self::$has_dismiss_interval_notice ) {
233
+			if ( ! self::$has_dismiss_interval_notice) {
234 234
 				self::$has_dismiss_interval_notice = $notice['dismiss_interval'];
235 235
 			}
236 236
 
237
-			$css_id = ( false === strpos( $notice['id'], 'give' ) ? "give-{$notice['id']}" : $notice['id'] );
237
+			$css_id = (false === strpos($notice['id'], 'give') ? "give-{$notice['id']}" : $notice['id']);
238 238
 
239
-			$css_class = 'give-notice notice ' . ( empty( $notice['dismissible'] ) ? 'non' : 'is' ) . "-dismissible {$notice['type']} notice-{$notice['type']}";
240
-			$output    .= sprintf(
241
-				'<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">' . " \n",
239
+			$css_class = 'give-notice notice '.(empty($notice['dismissible']) ? 'non' : 'is')."-dismissible {$notice['type']} notice-{$notice['type']}";
240
+			$output .= sprintf(
241
+				'<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">'." \n",
242 242
 				$css_id,
243 243
 				$css_class,
244
-				give_clean( $notice['dismissible'] ),
244
+				give_clean($notice['dismissible']),
245 245
 				$notice['dismissible_type'],
246 246
 				$notice['dismiss_interval'],
247 247
 				$notice['id'],
248
-				empty( $notice['dismissible_type'] ) ? '' : wp_create_nonce( "give_edit_{$notice_id}_notice" ),
248
+				empty($notice['dismissible_type']) ? '' : wp_create_nonce("give_edit_{$notice_id}_notice"),
249 249
 				$notice['dismiss_interval_time']
250 250
 			);
251 251
 
252
-			$output .= ( 0 === strpos( $notice['description'], '<div' ) || 0 === strpos( $notice['description'], '<p' ) ? $notice['description'] : "<p>{$notice['description']}</p>" );
252
+			$output .= (0 === strpos($notice['description'], '<div') || 0 === strpos($notice['description'], '<p') ? $notice['description'] : "<p>{$notice['description']}</p>");
253 253
 			$output .= "</div> \n";
254 254
 		}
255 255
 
@@ -267,18 +267,18 @@  discard block
 block discarded – undo
267 267
 	 *
268 268
 	 * @param int $form_id
269 269
 	 */
270
-	public function render_frontend_notices( $form_id = 0 ) {
270
+	public function render_frontend_notices($form_id = 0) {
271 271
 		$errors = give_get_errors();
272 272
 
273
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? absint( $_REQUEST['form-id'] ) : 0;
273
+		$request_form_id = isset($_REQUEST['form-id']) ? absint($_REQUEST['form-id']) : 0;
274 274
 
275 275
 		// Sanity checks first: Ensure that gateway returned errors display on the appropriate form.
276
-		if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) {
276
+		if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) {
277 277
 			return;
278 278
 		}
279 279
 
280
-		if ( $errors ) {
281
-			self::print_frontend_errors( $errors );
280
+		if ($errors) {
281
+			self::print_frontend_errors($errors);
282 282
 
283 283
 			give_clear_errors();
284 284
 		}
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @access private
292 292
 	 */
293 293
 	private function print_js() {
294
-		if ( self::$has_auto_dismissible_notice ) :
294
+		if (self::$has_auto_dismissible_notice) :
295 295
 			?>
296 296
 			<script>
297 297
 				jQuery(document).ready(function () {
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 			<?php
308 308
 		endif;
309 309
 
310
-		if ( self::$has_dismiss_interval_notice ) :
310
+		if (self::$has_dismiss_interval_notice) :
311 311
 			?>
312 312
 			<script>
313 313
 				jQuery(document).ready(function () {
@@ -386,36 +386,36 @@  discard block
 block discarded – undo
386 386
 	 * @access public
387 387
 	 */
388 388
 	public function dismiss_notices() {
389
-		$_post     = give_clean( $_POST );
390
-		$notice_id = esc_attr( $_post['notice_id'] );
389
+		$_post     = give_clean($_POST);
390
+		$notice_id = esc_attr($_post['notice_id']);
391 391
 
392 392
 		// Bailout.
393 393
 		if (
394
-			empty( $notice_id ) ||
395
-			empty( $_post['dismissible_type'] ) ||
396
-			empty( $_post['dismiss_interval'] ) ||
397
-			! check_ajax_referer( "give_edit_{$notice_id}_notice", '_wpnonce' )
394
+			empty($notice_id) ||
395
+			empty($_post['dismissible_type']) ||
396
+			empty($_post['dismiss_interval']) ||
397
+			! check_ajax_referer("give_edit_{$notice_id}_notice", '_wpnonce')
398 398
 		) {
399 399
 			wp_send_json_error();
400 400
 		}
401 401
 
402
-		$notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'] );
403
-		if ( 'user' === $_post['dismissible_type'] ) {
402
+		$notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval']);
403
+		if ('user' === $_post['dismissible_type']) {
404 404
 			$current_user = wp_get_current_user();
405
-			$notice_key   = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'], $current_user->ID );
405
+			$notice_key   = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval'], $current_user->ID);
406 406
 		}
407 407
 
408
-		$notice_dismiss_time = ! empty( $_post['dismiss_interval_time'] ) ? $_post['dismiss_interval_time'] : null;
408
+		$notice_dismiss_time = ! empty($_post['dismiss_interval_time']) ? $_post['dismiss_interval_time'] : null;
409 409
 
410 410
 		// Save option to hide notice.
411
-		Give_Cache::set( $notice_key, true, $notice_dismiss_time, true );
411
+		Give_Cache::set($notice_key, true, $notice_dismiss_time, true);
412 412
 
413 413
 		/**
414 414
 		 * Fire the action when notice dismissed
415 415
 		 *
416 416
 		 * @since 2.0
417 417
 		 */
418
-		do_action( 'give_dismiss_notices', $_post );
418
+		do_action('give_dismiss_notices', $_post);
419 419
 
420 420
 		wp_send_json_success();
421 421
 	}
@@ -433,18 +433,18 @@  discard block
 block discarded – undo
433 433
 	 *
434 434
 	 * @return string
435 435
 	 */
436
-	public function get_notice_key( $notice_id, $dismiss_interval = null, $user_id = 0 ) {
436
+	public function get_notice_key($notice_id, $dismiss_interval = null, $user_id = 0) {
437 437
 		$notice_key = "_give_notice_{$notice_id}";
438 438
 
439
-		if ( ! empty( $dismiss_interval ) ) {
439
+		if ( ! empty($dismiss_interval)) {
440 440
 			$notice_key .= "_{$dismiss_interval}";
441 441
 		}
442 442
 
443
-		if ( $user_id ) {
443
+		if ($user_id) {
444 444
 			$notice_key .= "_{$user_id}";
445 445
 		}
446 446
 
447
-		$notice_key = sanitize_key( $notice_key );
447
+		$notice_key = sanitize_key($notice_key);
448 448
 
449 449
 		return $notice_key;
450 450
 	}
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
 	 *
458 458
 	 * @return string
459 459
 	 */
460
-	public function get_dismiss_link( $notice_args ) {
460
+	public function get_dismiss_link($notice_args) {
461 461
 		$notice_args = wp_parse_args(
462 462
 			$notice_args,
463 463
 			array(
464
-				'title'                 => __( 'Click here', 'give' ),
464
+				'title'                 => __('Click here', 'give'),
465 465
 				'dismissible_type'      => '',
466 466
 				'dismiss_interval'      => '',
467 467
 				'dismiss_interval_time' => null,
@@ -488,31 +488,31 @@  discard block
 block discarded – undo
488 488
 	 *
489 489
 	 * @return bool|null
490 490
 	 */
491
-	public function is_notice_dismissed( $notice ) {
492
-		$notice_key          = $this->get_notice_key( $notice['id'], $notice['dismiss_interval'] );
491
+	public function is_notice_dismissed($notice) {
492
+		$notice_key          = $this->get_notice_key($notice['id'], $notice['dismiss_interval']);
493 493
 		$is_notice_dismissed = false;
494 494
 
495
-		if ( 'user' === $notice['dismissible_type'] ) {
495
+		if ('user' === $notice['dismissible_type']) {
496 496
 			$current_user = wp_get_current_user();
497
-			$notice_key   = Give()->notices->get_notice_key( $notice['id'], $notice['dismiss_interval'], $current_user->ID );
497
+			$notice_key   = Give()->notices->get_notice_key($notice['id'], $notice['dismiss_interval'], $current_user->ID);
498 498
 		}
499 499
 
500
-		$notice_data = Give_Cache::get( $notice_key, true );
500
+		$notice_data = Give_Cache::get($notice_key, true);
501 501
 
502 502
 		// Find notice dismiss link status if notice has extra dismissible links.
503
-		if ( ( empty( $notice_data ) || is_wp_error( $notice_data ) ) && ! empty( $notice['extra_links'] ) ) {
503
+		if ((empty($notice_data) || is_wp_error($notice_data)) && ! empty($notice['extra_links'])) {
504 504
 
505
-			foreach ( $notice['extra_links'] as $extra_link ) {
506
-				$new_notice_data = wp_parse_args( $extra_link, $notice );
507
-				unset( $new_notice_data['extra_links'] );
505
+			foreach ($notice['extra_links'] as $extra_link) {
506
+				$new_notice_data = wp_parse_args($extra_link, $notice);
507
+				unset($new_notice_data['extra_links']);
508 508
 
509
-				if ( $is_notice_dismissed = $this->is_notice_dismissed( $new_notice_data ) ) {
509
+				if ($is_notice_dismissed = $this->is_notice_dismissed($new_notice_data)) {
510 510
 					return $is_notice_dismissed;
511 511
 				}
512 512
 			}
513 513
 		}
514 514
 
515
-		$is_notice_dismissed = ! empty( $notice_data ) && ! is_wp_error( $notice_data );
515
+		$is_notice_dismissed = ! empty($notice_data) && ! is_wp_error($notice_data);
516 516
 
517 517
 		return $is_notice_dismissed;
518 518
 	}
@@ -526,9 +526,9 @@  discard block
 block discarded – undo
526 526
 	 *
527 527
 	 * @param array $errors
528 528
 	 */
529
-	public static function print_frontend_errors( $errors ) {
529
+	public static function print_frontend_errors($errors) {
530 530
 		// Bailout.
531
-		if ( ! $errors ) {
531
+		if ( ! $errors) {
532 532
 			return;
533 533
 		}
534 534
 
@@ -543,37 +543,37 @@  discard block
 block discarded – undo
543 543
 		);
544 544
 
545 545
 		// Note: we will remove give_errors class in future.
546
-		$classes = apply_filters( 'give_error_class', array( 'give_notices', 'give_errors' ) );
546
+		$classes = apply_filters('give_error_class', array('give_notices', 'give_errors'));
547 547
 
548
-		echo sprintf( '<div class="%s">', implode( ' ', $classes ) );
548
+		echo sprintf('<div class="%s">', implode(' ', $classes));
549 549
 
550 550
 		// Loop error codes and display errors.
551
-		foreach ( $errors as $error_id => $error ) {
551
+		foreach ($errors as $error_id => $error) {
552 552
 			// Backward compatibility v<1.8.11
553
-			if ( is_string( $error ) ) {
553
+			if (is_string($error)) {
554 554
 				$error = array(
555 555
 					'message'     => $error,
556 556
 					'notice_args' => array(),
557 557
 				);
558 558
 			}
559 559
 
560
-			$notice_args = wp_parse_args( $error['notice_args'], $default_notice_args );
560
+			$notice_args = wp_parse_args($error['notice_args'], $default_notice_args);
561 561
 
562 562
 			/**
563 563
 			 * Filter to modify Frontend Errors args before errors is display.
564 564
 			 *
565 565
 			 * @since 1.8.14
566 566
 			 */
567
-			$notice_args = apply_filters( 'give_frontend_errors_args', $notice_args );
567
+			$notice_args = apply_filters('give_frontend_errors_args', $notice_args);
568 568
 
569 569
 			echo sprintf(
570 570
 				'<div class="give_error give_notice" id="give_error_%1$s" data-dismissible="%2$s" data-dismiss-interval="%3$d">
571 571
 						<p><strong>%4$s</strong>: %5$s</p>
572 572
 					</div>',
573 573
 				$error_id,
574
-				give_clean( $notice_args['dismissible'] ),
575
-				absint( $notice_args['dismiss_interval'] ),
576
-				esc_html__( 'Error', 'give' ),
574
+				give_clean($notice_args['dismissible']),
575
+				absint($notice_args['dismiss_interval']),
576
+				esc_html__('Error', 'give'),
577 577
 				$error['message']
578 578
 			);
579 579
 		}
@@ -595,8 +595,8 @@  discard block
 block discarded – undo
595 595
 	 *
596 596
 	 * @return  string
597 597
 	 */
598
-	public static function print_frontend_notice( $message, $echo = true, $notice_type = 'warning', $notice_args = array() ) {
599
-		if ( empty( $message ) ) {
598
+	public static function print_frontend_notice($message, $echo = true, $notice_type = 'warning', $notice_args = array()) {
599
+		if (empty($message)) {
600 600
 			return '';
601 601
 		}
602 602
 
@@ -610,14 +610,14 @@  discard block
 block discarded – undo
610 610
 			'dismiss_interval' => 5000,
611 611
 		);
612 612
 
613
-		$notice_args = wp_parse_args( $notice_args, $default_notice_args );
613
+		$notice_args = wp_parse_args($notice_args, $default_notice_args);
614 614
 
615 615
 		/**
616 616
 		 * Filter to modify Frontend notice args before notices is display.
617 617
 		 *
618 618
 		 * @since 1.8.14
619 619
 		 */
620
-		$notice_args = apply_filters( 'give_frontend_notice_args', $notice_args );
620
+		$notice_args = apply_filters('give_frontend_notice_args', $notice_args);
621 621
 
622 622
 		// Note: we will remove give_errors class in future.
623 623
 		$error = sprintf(
@@ -627,12 +627,12 @@  discard block
 block discarded – undo
627 627
 				</p>
628 628
 			</div>',
629 629
 			$notice_type,
630
-			give_clean( $notice_args['dismissible'] ),
631
-			absint( $notice_args['dismiss_interval'] ),
630
+			give_clean($notice_args['dismissible']),
631
+			absint($notice_args['dismiss_interval']),
632 632
 			$message
633 633
 		);
634 634
 
635
-		if ( ! $echo ) {
635
+		if ( ! $echo) {
636 636
 			return $error;
637 637
 		}
638 638
 
@@ -652,24 +652,24 @@  discard block
 block discarded – undo
652 652
 	 *
653 653
 	 * @return string
654 654
 	 */
655
-	public function print_admin_notices( $notice_args = array() ) {
655
+	public function print_admin_notices($notice_args = array()) {
656 656
 		// Bailout.
657
-		if ( empty( $notice_args['description'] ) ) {
657
+		if (empty($notice_args['description'])) {
658 658
 			return '';
659 659
 		}
660 660
 
661
-		$defaults    = array(
661
+		$defaults = array(
662 662
 			'id'          => '',
663 663
 			'echo'        => true,
664 664
 			'notice_type' => 'warning',
665 665
 			'dismissible' => true,
666 666
 		);
667
-		$notice_args = wp_parse_args( $notice_args, $defaults );
667
+		$notice_args = wp_parse_args($notice_args, $defaults);
668 668
 
669 669
 		$output    = '';
670
-		$css_id    = ! empty( $notice_args['id'] ) ? $notice_args['id'] : uniqid( 'give-inline-notice-' );
670
+		$css_id    = ! empty($notice_args['id']) ? $notice_args['id'] : uniqid('give-inline-notice-');
671 671
 		$css_class = "notice-{$notice_args['notice_type']} give-notice notice inline";
672
-		$css_class .= ( $notice_args['dismissible'] ) ? ' is-dismissible' : '';
672
+		$css_class .= ($notice_args['dismissible']) ? ' is-dismissible' : '';
673 673
 		$output    .= sprintf(
674 674
 			'<div id="%1$s" class="%2$s"><p>%3$s</p></div>',
675 675
 			$css_id,
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 			$notice_args['description']
678 678
 		);
679 679
 
680
-		if ( ! $notice_args['echo'] ) {
680
+		if ( ! $notice_args['echo']) {
681 681
 			return $output;
682 682
 		}
683 683
 
Please login to merge, or discard this patch.
includes/gateways/offline-donations.php 1 patch
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
  *
19 19
  * @return array
20 20
  */
21
-function give_offline_register_gateway( $gateways ) {
21
+function give_offline_register_gateway($gateways) {
22 22
 	// Format: ID => Name
23 23
 	$gateways['offline'] = array(
24
-		'admin_label'    => esc_attr__( 'Offline Donation', 'give' ),
25
-		'checkout_label' => esc_attr__( 'Offline Donation', 'give' ),
24
+		'admin_label'    => esc_attr__('Offline Donation', 'give'),
25
+		'checkout_label' => esc_attr__('Offline Donation', 'give'),
26 26
 	);
27 27
 
28 28
 	return $gateways;
29 29
 }
30 30
 
31
-add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 );
31
+add_filter('give_payment_gateways', 'give_offline_register_gateway', 1);
32 32
 
33 33
 
34 34
 /**
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
  *
41 41
  * @return void
42 42
  */
43
-function give_offline_payment_cc_form( $form_id ) {
43
+function give_offline_payment_cc_form($form_id) {
44 44
 	// Get offline payment instruction.
45
-	$offline_instructions = give_get_offline_payment_instruction( $form_id, true );
45
+	$offline_instructions = give_get_offline_payment_instruction($form_id, true);
46 46
 
47 47
 	ob_start();
48 48
 
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @param int $form_id Give form id.
55 55
 	 */
56
-	do_action( 'give_before_offline_info_fields', $form_id );
56
+	do_action('give_before_offline_info_fields', $form_id);
57 57
 	?>
58 58
     <fieldset id="give_offline_payment_info">
59
-		<?php echo stripslashes( $offline_instructions ); ?>
59
+		<?php echo stripslashes($offline_instructions); ?>
60 60
     </fieldset>
61 61
 	<?php
62 62
 	/**
@@ -66,35 +66,35 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @param int $form_id Give form id.
68 68
 	 */
69
-	do_action( 'give_after_offline_info_fields', $form_id );
69
+	do_action('give_after_offline_info_fields', $form_id);
70 70
 
71 71
 	echo ob_get_clean();
72 72
 }
73 73
 
74
-add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' );
74
+add_action('give_offline_cc_form', 'give_offline_payment_cc_form');
75 75
 
76 76
 /**
77 77
  * Give Offline Billing Field
78 78
  *
79 79
  * @param $form_id
80 80
  */
81
-function give_offline_billing_fields( $form_id ) {
81
+function give_offline_billing_fields($form_id) {
82 82
 	//Enable Default CC fields (billing info)
83
-	$post_offline_cc_fields        = give_get_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true );
84
-	$post_offline_customize_option = give_get_meta( $form_id, '_give_customize_offline_donations', true );
83
+	$post_offline_cc_fields        = give_get_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true);
84
+	$post_offline_customize_option = give_get_meta($form_id, '_give_customize_offline_donations', true);
85 85
 
86
-	$global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' );
86
+	$global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields');
87 87
 
88 88
 	//Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options
89 89
 	if (
90
-		( give_is_setting_enabled( $post_offline_customize_option, 'global' ) && give_is_setting_enabled( $global_offline_cc_fields ) )
91
-		|| ( give_is_setting_enabled( $post_offline_customize_option, 'enabled' ) && give_is_setting_enabled( $post_offline_cc_fields ) )
90
+		(give_is_setting_enabled($post_offline_customize_option, 'global') && give_is_setting_enabled($global_offline_cc_fields))
91
+		|| (give_is_setting_enabled($post_offline_customize_option, 'enabled') && give_is_setting_enabled($post_offline_cc_fields))
92 92
 	) {
93
-		give_default_cc_address_fields( $form_id );
93
+		give_default_cc_address_fields($form_id);
94 94
 	}
95 95
 }
96 96
 
97
-add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 );
97
+add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1);
98 98
 
99 99
 /**
100 100
  * Process the payment
@@ -105,18 +105,18 @@  discard block
 block discarded – undo
105 105
  *
106 106
  * @return void
107 107
  */
108
-function give_offline_process_payment( $purchase_data ) {
108
+function give_offline_process_payment($purchase_data) {
109 109
 
110 110
 	// Setup the payment details.
111 111
 	$payment_data = array(
112 112
 		'price'           => $purchase_data['price'],
113 113
 		'give_form_title' => $purchase_data['post_data']['give-form-title'],
114
-		'give_form_id'    => intval( $purchase_data['post_data']['give-form-id'] ),
115
-		'give_price_id'   => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '',
114
+		'give_form_id'    => intval($purchase_data['post_data']['give-form-id']),
115
+		'give_price_id'   => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '',
116 116
 		'date'            => $purchase_data['date'],
117 117
 		'user_email'      => $purchase_data['user_email'],
118 118
 		'purchase_key'    => $purchase_data['purchase_key'],
119
-		'currency'        => give_get_currency( $purchase_data['post_data']['give-form-id'], $purchase_data ),
119
+		'currency'        => give_get_currency($purchase_data['post_data']['give-form-id'], $purchase_data),
120 120
 		'user_info'       => $purchase_data['user_info'],
121 121
 		'status'          => 'pending',
122 122
 		'gateway'         => 'offline',
@@ -124,18 +124,18 @@  discard block
 block discarded – undo
124 124
 
125 125
 
126 126
 	// record the pending payment
127
-	$payment = give_insert_payment( $payment_data );
127
+	$payment = give_insert_payment($payment_data);
128 128
 
129
-	if ( $payment ) {
129
+	if ($payment) {
130 130
 		give_send_to_success_page();
131 131
 	} else {
132 132
 		// if errors are present, send the user back to the donation form so they can be corrected
133
-		give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] );
133
+		give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']);
134 134
 	}
135 135
 
136 136
 }
137 137
 
138
-add_action( 'give_gateway_offline', 'give_offline_process_payment' );
138
+add_action('give_gateway_offline', 'give_offline_process_payment');
139 139
 
140 140
 
141 141
 /**
@@ -148,59 +148,59 @@  discard block
 block discarded – undo
148 148
  * @since       1.0
149 149
  * @return void
150 150
  */
151
-function give_offline_send_donor_instructions( $payment_id = 0 ) {
151
+function give_offline_send_donor_instructions($payment_id = 0) {
152 152
 
153
-	$payment_data                      = give_get_payment_meta( $payment_id );
154
-	$post_offline_customization_option = give_get_meta( $payment_data['form_id'], '_give_customize_offline_donations', true );
153
+	$payment_data                      = give_get_payment_meta($payment_id);
154
+	$post_offline_customization_option = give_get_meta($payment_data['form_id'], '_give_customize_offline_donations', true);
155 155
 
156 156
 	//Customize email content depending on whether the single form has been customized
157
-	$email_content = give_get_option( 'global_offline_donation_email' );
157
+	$email_content = give_get_option('global_offline_donation_email');
158 158
 
159
-	if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) {
160
-		$email_content = give_get_meta( $payment_data['form_id'], '_give_offline_donation_email', true );
159
+	if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) {
160
+		$email_content = give_get_meta($payment_data['form_id'], '_give_offline_donation_email', true);
161 161
 	}
162 162
 
163
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
163
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
164 164
 
165 165
 	/**
166 166
 	 * Filters the from name.
167 167
 	 *
168 168
 	 * @since 1.7
169 169
 	 */
170
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
170
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
171 171
 
172
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
172
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
173 173
 
174 174
 	/**
175 175
 	 * Filters the from email.
176 176
 	 *
177 177
 	 * @since 1.7
178 178
 	 */
179
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
179
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
180 180
 
181
-	$to_email = give_get_payment_user_email( $payment_id );
181
+	$to_email = give_get_payment_user_email($payment_id);
182 182
 
183
-	$subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) );
184
-	if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) {
185
-		$subject = give_get_meta( $payment_data['form_id'], '_give_offline_donation_subject', true );
183
+	$subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give'));
184
+	if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) {
185
+		$subject = give_get_meta($payment_data['form_id'], '_give_offline_donation_subject', true);
186 186
 	}
187 187
 
188
-	$subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id );
189
-	$subject = give_do_email_tags( $subject, $payment_id );
188
+	$subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id);
189
+	$subject = give_do_email_tags($subject, $payment_id);
190 190
 
191
-	$attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data );
192
-	$message     = give_do_email_tags( $email_content, $payment_id );
191
+	$attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data);
192
+	$message     = give_do_email_tags($email_content, $payment_id);
193 193
 
194 194
 	$emails = Give()->emails;
195 195
 
196
-	$emails->__set( 'from_name', $from_name );
197
-	$emails->__set( 'from_email', $from_email );
198
-	$emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) );
196
+	$emails->__set('from_name', $from_name);
197
+	$emails->__set('from_email', $from_email);
198
+	$emails->__set('heading', __('Offline Donation Instructions', 'give'));
199 199
 
200
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data );
201
-	$emails->__set( 'headers', $headers );
200
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
201
+	$emails->__set('headers', $headers);
202 202
 
203
-	$emails->send( $to_email, $subject, $message, $attachments );
203
+	$emails->send($to_email, $subject, $message, $attachments);
204 204
 
205 205
 }
206 206
 
@@ -217,54 +217,54 @@  discard block
 block discarded – undo
217 217
  * @return void
218 218
  *
219 219
  */
220
-function give_offline_send_admin_notice( $payment_id = 0 ) {
220
+function give_offline_send_admin_notice($payment_id = 0) {
221 221
 
222 222
 	/* Send an email notification to the admin */
223 223
 	$admin_email = give_get_admin_notice_emails();
224
-	$user_info   = give_get_payment_meta_user_info( $payment_id );
224
+	$user_info   = give_get_payment_meta_user_info($payment_id);
225 225
 
226
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
227
-		$user_data = get_userdata( $user_info['id'] );
226
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
227
+		$user_data = get_userdata($user_info['id']);
228 228
 		$name      = $user_data->display_name;
229
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
230
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
229
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
230
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
231 231
 	} else {
232 232
 		$name = $user_info['email'];
233 233
 	}
234 234
 
235
-	$amount = give_donation_amount( $payment_id );
235
+	$amount = give_donation_amount($payment_id);
236 236
 
237
-	$admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id );
237
+	$admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id);
238 238
 
239
-	$admin_message = __( 'Dear Admin,', 'give' ) . "\n\n";
240
-	$admin_message .= sprintf(__( 'A new offline donation has been made on your website for %s.', 'give' ), $amount) . "\n\n";
241
-	$admin_message .= __( 'The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n";
239
+	$admin_message = __('Dear Admin,', 'give')."\n\n";
240
+	$admin_message .= sprintf(__('A new offline donation has been made on your website for %s.', 'give'), $amount)."\n\n";
241
+	$admin_message .= __('The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n";
242 242
 
243 243
 
244
-	$admin_message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
245
-	$admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n";
244
+	$admin_message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n";
245
+	$admin_message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n";
246 246
 
247 247
 	$admin_message .= sprintf(
248 248
 		                  '<a href="%1$s">%2$s</a>',
249
-		                  admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ),
250
-		                  __( 'View Donation Details &raquo;', 'give' )
251
-	                  ) . "\n\n";
249
+		                  admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment_id),
250
+		                  __('View Donation Details &raquo;', 'give')
251
+	                  )."\n\n";
252 252
 
253
-	$admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id );
254
-	$admin_message = give_do_email_tags( $admin_message, $payment_id );
253
+	$admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id);
254
+	$admin_message = give_do_email_tags($admin_message, $payment_id);
255 255
 
256
-	$attachments   = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id );
257
-	$admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id );
256
+	$attachments   = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id);
257
+	$admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id);
258 258
 
259 259
 	//Send Email
260 260
 	$emails = Give()->emails;
261
-	$emails->__set( 'heading', __( 'New Offline Donation', 'give' ) );
261
+	$emails->__set('heading', __('New Offline Donation', 'give'));
262 262
 
263
-	if ( ! empty( $admin_headers ) ) {
264
-		$emails->__set( 'headers', $admin_headers );
263
+	if ( ! empty($admin_headers)) {
264
+		$emails->__set('headers', $admin_headers);
265 265
 	}
266 266
 
267
-	$emails->send( $admin_email, $admin_subject, $admin_message, $attachments );
267
+	$emails->send($admin_email, $admin_subject, $admin_message, $attachments);
268 268
 
269 269
 }
270 270
 
@@ -277,20 +277,20 @@  discard block
 block discarded – undo
277 277
  *
278 278
  * @return array
279 279
  */
280
-function give_offline_add_settings( $settings ) {
280
+function give_offline_add_settings($settings) {
281 281
 
282 282
 	// Bailout: Do not show offline gateways setting in to metabox if its disabled globally.
283
-	if ( in_array( 'offline', (array) give_get_option( 'gateways' ) ) ) {
283
+	if (in_array('offline', (array) give_get_option('gateways'))) {
284 284
 		return $settings;
285 285
 	}
286 286
 
287 287
 	//Vars
288 288
 	$prefix = '_give_';
289 289
 
290
-	$is_gateway_active = give_is_gateway_active( 'offline' );
290
+	$is_gateway_active = give_is_gateway_active('offline');
291 291
 
292 292
 	//this gateway isn't active
293
-	if ( ! $is_gateway_active ) {
293
+	if ( ! $is_gateway_active) {
294 294
 		//return settings and bounce
295 295
 		return $settings;
296 296
 	}
@@ -299,34 +299,34 @@  discard block
 block discarded – undo
299 299
 	$check_settings = array(
300 300
 
301 301
 		array(
302
-			'name'    => __( 'Offline Donations', 'give' ),
303
-			'desc'    => __( 'Do you want to customize the donation instructions for this form?', 'give' ),
304
-			'id'      => $prefix . 'customize_offline_donations',
302
+			'name'    => __('Offline Donations', 'give'),
303
+			'desc'    => __('Do you want to customize the donation instructions for this form?', 'give'),
304
+			'id'      => $prefix.'customize_offline_donations',
305 305
 			'type'    => 'radio_inline',
306 306
 			'default' => 'global',
307
-			'options' => apply_filters( 'give_forms_content_options_select', array(
308
-					'global'   => __( 'Global Option', 'give' ),
309
-					'enabled'  => __( 'Customize', 'give' ),
310
-					'disabled' => __( 'Disable', 'give' ),
307
+			'options' => apply_filters('give_forms_content_options_select', array(
308
+					'global'   => __('Global Option', 'give'),
309
+					'enabled'  => __('Customize', 'give'),
310
+					'disabled' => __('Disable', 'give'),
311 311
 				)
312 312
 			),
313 313
 		),
314 314
 		array(
315
-			'name'        => __( 'Billing Fields', 'give' ),
316
-			'desc'        => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ),
317
-			'id'          => $prefix . 'offline_donation_enable_billing_fields_single',
315
+			'name'        => __('Billing Fields', 'give'),
316
+			'desc'        => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'),
317
+			'id'          => $prefix.'offline_donation_enable_billing_fields_single',
318 318
 			'row_classes' => 'give-subfield give-hidden',
319 319
 			'type'        => 'radio_inline',
320 320
 			'default'     => 'disabled',
321 321
 			'options'     => array(
322
-				'enabled'  => __( 'Enabled', 'give' ),
323
-				'disabled' => __( 'Disabled', 'give' ),
322
+				'enabled'  => __('Enabled', 'give'),
323
+				'disabled' => __('Disabled', 'give'),
324 324
 			),
325 325
 		),
326 326
 		array(
327
-			'id'          => $prefix . 'offline_checkout_notes',
328
-			'name'        => __( 'Donation Instructions', 'give' ),
329
-			'desc'        => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ),
327
+			'id'          => $prefix.'offline_checkout_notes',
328
+			'name'        => __('Donation Instructions', 'give'),
329
+			'desc'        => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'),
330 330
 			'default'     => give_get_default_offline_donation_content(),
331 331
 			'type'        => 'wysiwyg',
332 332
 			'row_classes' => 'give-subfield give-hidden',
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
 			'name'  => 'offline_docs',
339 339
 			'type'  => 'docs_link',
340 340
 			'url'   => 'http://docs.givewp.com/settings-gateway-offline-donations',
341
-			'title' => __( 'Offline Donations', 'give' ),
341
+			'title' => __('Offline Donations', 'give'),
342 342
 		),
343 343
 	);
344 344
 
345
-	return array_merge( $settings, $check_settings );
345
+	return array_merge($settings, $check_settings);
346 346
 }
347 347
 
348
-add_filter( 'give_forms_offline_donations_metabox_fields', 'give_offline_add_settings' );
348
+add_filter('give_forms_offline_donations_metabox_fields', 'give_offline_add_settings');
349 349
 
350 350
 
351 351
 /**
@@ -357,32 +357,32 @@  discard block
 block discarded – undo
357 357
  */
358 358
 function give_get_default_offline_donation_content() {
359 359
 
360
-	$sitename = get_bloginfo( 'sitename' );
360
+	$sitename = get_bloginfo('sitename');
361 361
 
362
-	$default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>';
362
+	$default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>';
363 363
 	$default_text .= '<ol>';
364 364
 	$default_text .= '<li>';
365 365
 	$default_text .= sprintf(
366 366
 	/* translators: %s: site name */
367
-		__( 'Make a check payable to "%s"', 'give' ),
367
+		__('Make a check payable to "%s"', 'give'),
368 368
 		$sitename
369 369
 	);
370 370
 	$default_text .= '</li>';
371 371
 	$default_text .= '<li>';
372 372
 	$default_text .= sprintf(
373 373
 	/* translators: %s: site name */
374
-		__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ),
374
+		__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'),
375 375
 		$sitename
376 376
 	);
377 377
 	$default_text .= '</li>';
378
-	$default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>';
378
+	$default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>';
379 379
 	$default_text .= '</ol>';
380
-	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>' . $sitename . '</em><br>';
380
+	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>'.$sitename.'</em><br>';
381 381
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>111 Not A Real St.</em><br>';
382 382
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>Anytown, CA 12345 </em><br>';
383
-	$default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>';
383
+	$default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>';
384 384
 
385
-	return apply_filters( 'give_default_offline_donation_content', $default_text );
385
+	return apply_filters('give_default_offline_donation_content', $default_text);
386 386
 
387 387
 }
388 388
 
@@ -395,34 +395,34 @@  discard block
 block discarded – undo
395 395
  */
396 396
 function give_get_default_offline_donation_email_content() {
397 397
 
398
-	$sitename     = get_bloginfo( 'sitename' );
399
-	$default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>';
400
-	$default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>';
398
+	$sitename     = get_bloginfo('sitename');
399
+	$default_text = '<p>'.__('Dear {name},', 'give').'</p>';
400
+	$default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>';
401 401
 	$default_text .= '<ol>';
402 402
 	$default_text .= '<li>';
403 403
 	$default_text .= sprintf(
404 404
 	/* translators: %s: site name */
405
-		__( 'Make a check payable to "%s"', 'give' ),
405
+		__('Make a check payable to "%s"', 'give'),
406 406
 		$sitename
407 407
 	);
408 408
 	$default_text .= '</li>';
409 409
 	$default_text .= '<li>';
410 410
 	$default_text .= sprintf(
411 411
 	/* translators: %s: site name */
412
-		__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ),
412
+		__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'),
413 413
 		$sitename
414 414
 	);
415 415
 	$default_text .= '</li>';
416
-	$default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>';
416
+	$default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>';
417 417
 	$default_text .= '</ol>';
418
-	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>' . $sitename . '</em><br>';
418
+	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>'.$sitename.'</em><br>';
419 419
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>111 Not A Real St.</em><br>';
420 420
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>Anytown, CA 12345 </em><br>';
421
-	$default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>';
422
-	$default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>';
423
-	$default_text .= '<p>' . $sitename . '</p>';
421
+	$default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>';
422
+	$default_text .= '<p>'.__('Sincerely,', 'give').'</p>';
423
+	$default_text .= '<p>'.$sitename.'</p>';
424 424
 
425
-	return apply_filters( 'give_default_offline_donation_content', $default_text );
425
+	return apply_filters('give_default_offline_donation_content', $default_text);
426 426
 
427 427
 }
428 428
 
@@ -436,17 +436,17 @@  discard block
 block discarded – undo
436 436
  *
437 437
  * @return string
438 438
  */
439
-function give_offline_donation_receipt_status_notice( $notice, $id ) {
440
-	$payment = new Give_Payment( $id );
439
+function give_offline_donation_receipt_status_notice($notice, $id) {
440
+	$payment = new Give_Payment($id);
441 441
 
442
-	if ( 'offline' !== $payment->gateway || $payment->is_completed() ) {
442
+	if ('offline' !== $payment->gateway || $payment->is_completed()) {
443 443
 		return $notice;
444 444
 	}
445 445
 
446
-	return Give()->notices->print_frontend_notice( __( 'Payment Pending: Please follow the instructions below to complete your donation.', 'give' ), false, 'warning' );
446
+	return Give()->notices->print_frontend_notice(__('Payment Pending: Please follow the instructions below to complete your donation.', 'give'), false, 'warning');
447 447
 }
448 448
 
449
-add_filter( 'give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2 );
449
+add_filter('give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2);
450 450
 
451 451
 /**
452 452
  * Get offline payment instructions.
@@ -458,27 +458,27 @@  discard block
 block discarded – undo
458 458
  *
459 459
  * @return string
460 460
  */
461
-function give_get_offline_payment_instruction( $form_id, $wpautop = false ) {
461
+function give_get_offline_payment_instruction($form_id, $wpautop = false) {
462 462
 	// Bailout.
463
-	if ( ! $form_id ) {
463
+	if ( ! $form_id) {
464 464
 		return '';
465 465
 	}
466 466
 
467
-	$post_offline_customization_option = give_get_meta( $form_id, '_give_customize_offline_donations', true );
468
-	$post_offline_instructions         = give_get_meta( $form_id, '_give_offline_checkout_notes', true );
469
-	$global_offline_instruction        = give_get_option( 'global_offline_donation_content' );
467
+	$post_offline_customization_option = give_get_meta($form_id, '_give_customize_offline_donations', true);
468
+	$post_offline_instructions         = give_get_meta($form_id, '_give_offline_checkout_notes', true);
469
+	$global_offline_instruction        = give_get_option('global_offline_donation_content');
470 470
 	$offline_instructions              = $global_offline_instruction;
471 471
 
472
-	if ( give_is_setting_enabled( $post_offline_customization_option ) ) {
472
+	if (give_is_setting_enabled($post_offline_customization_option)) {
473 473
 		$offline_instructions = $post_offline_instructions;
474 474
 	}
475 475
 
476
-	$settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' );
476
+	$settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1');
477 477
 
478 478
 	/* translators: %s: form settings url */
479
-	$offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url );
479
+	$offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url);
480 480
 
481
-	return ( $wpautop ? wpautop( $offline_instructions ) : $offline_instructions );
481
+	return ($wpautop ? wpautop($offline_instructions) : $offline_instructions);
482 482
 }
483 483
 
484 484
 
@@ -492,21 +492,21 @@  discard block
 block discarded – undo
492 492
  *
493 493
  * @return array
494 494
  */
495
-function give_filter_offline_gateway( $gateway_list, $form_id ) {
495
+function give_filter_offline_gateway($gateway_list, $form_id) {
496 496
 	if (
497 497
 		// Show offline payment gateway if enable for new donation form.
498
-		( false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) )
498
+		(false === strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms'))
499 499
 		&& $form_id
500
-		&& ! give_is_setting_enabled( give_get_meta( $form_id, '_give_customize_offline_donations', true ), array( 'enabled', 'global' ) )
500
+		&& ! give_is_setting_enabled(give_get_meta($form_id, '_give_customize_offline_donations', true), array('enabled', 'global'))
501 501
 	) {
502
-		unset( $gateway_list['offline'] );
502
+		unset($gateway_list['offline']);
503 503
 	}
504 504
 
505 505
 	// Output.
506 506
 	return $gateway_list;
507 507
 }
508 508
 
509
-add_filter( 'give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2 );
509
+add_filter('give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2);
510 510
 
511 511
 /**
512 512
  * Set default gateway to global default payment gateway
@@ -520,13 +520,13 @@  discard block
 block discarded – undo
520 520
  *
521 521
  * @return void
522 522
  */
523
-function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) {
523
+function _give_customize_offline_donations_on_save_callback($meta_key, $meta_value, $postid) {
524 524
 	if (
525
-		! give_is_setting_enabled( $meta_value, array( 'global', 'enabled' ) )
526
-		&& ( 'offline' === give_get_meta( $postid, '_give_default_gateway', true ) )
525
+		! give_is_setting_enabled($meta_value, array('global', 'enabled'))
526
+		&& ('offline' === give_get_meta($postid, '_give_default_gateway', true))
527 527
 	) {
528
-		give_update_meta( $postid, '_give_default_gateway', 'global' );
528
+		give_update_meta($postid, '_give_default_gateway', 'global');
529 529
 	}
530 530
 }
531 531
 
532
-add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 );
532
+add_filter('give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3);
Please login to merge, or discard this patch.
includes/gateways/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
 
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @param $data
23 23
  */
24
-function give_process_gateway_select( $data ) {
25
-	if ( isset( $_POST['gateway_submit'] ) ) {
26
-		wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) );
24
+function give_process_gateway_select($data) {
25
+	if (isset($_POST['gateway_submit'])) {
26
+		wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode'])));
27 27
 		exit;
28 28
 	}
29 29
 }
30 30
 
31
-add_action( 'give_gateway_select', 'give_process_gateway_select' );
31
+add_action('give_gateway_select', 'give_process_gateway_select');
32 32
 
33 33
 /**
34 34
  * Loads a payment gateway via AJAX.
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
  * @return void
39 39
  */
40 40
 function give_load_ajax_gateway() {
41
-	if ( isset( $_POST['give_payment_mode'] ) ) {
41
+	if (isset($_POST['give_payment_mode'])) {
42 42
 		/**
43 43
 		 * Fire to render donation form.
44 44
 		 *
45 45
 		 * @since 1.7
46 46
 		 */
47
-		do_action( 'give_donation_form', $_POST['give_form_id'] );
47
+		do_action('give_donation_form', $_POST['give_form_id']);
48 48
 
49 49
 		exit();
50 50
 	}
51 51
 }
52 52
 
53
-add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' );
54
-add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' );
53
+add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway');
54
+add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway');
55 55
 
56 56
 /**
57 57
  * Create wp nonce using Ajax call.
@@ -63,18 +63,18 @@  discard block
 block discarded – undo
63 63
  * @return void
64 64
  */
65 65
 function give_donation_form_nonce() {
66
-	if ( isset( $_POST['give_form_id'] ) ) {
66
+	if (isset($_POST['give_form_id'])) {
67 67
 
68 68
 		// Get donation form id.
69
-		$form_id = is_numeric( $_POST['give_form_id'] ) ? absint( $_POST['give_form_id'] ) : 0;
69
+		$form_id = is_numeric($_POST['give_form_id']) ? absint($_POST['give_form_id']) : 0;
70 70
 
71 71
 		// Send nonce json data.
72
-		wp_send_json_success( wp_create_nonce( "donation_form_nonce_{$form_id}" ) );
72
+		wp_send_json_success(wp_create_nonce("donation_form_nonce_{$form_id}"));
73 73
 	}
74 74
 }
75 75
 
76
-add_action( 'wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce' );
77
-add_action( 'wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce' );
76
+add_action('wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce');
77
+add_action('wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce');
78 78
 
79 79
 /**
80 80
  * Sets an error within the donation form if no gateways are enabled.
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 function give_no_gateway_error() {
87 87
 	$gateways = give_get_enabled_payment_gateways();
88 88
 
89
-	if ( empty( $gateways ) ) {
90
-		give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) );
89
+	if (empty($gateways)) {
90
+		give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give'));
91 91
 	} else {
92
-		give_unset_error( 'no_gateways' );
92
+		give_unset_error('no_gateways');
93 93
 	}
94 94
 }
95 95
 
96
-add_action( 'init', 'give_no_gateway_error' );
96
+add_action('init', 'give_no_gateway_error');
Please login to merge, or discard this patch.
includes/gateways/functions.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
 	// Default, built-in gateways
25 25
 	$gateways = array(
26 26
 		'paypal' => array(
27
-			'admin_label'    => __( 'PayPal Standard', 'give' ),
28
-			'checkout_label' => __( 'PayPal', 'give' ),
27
+			'admin_label'    => __('PayPal Standard', 'give'),
28
+			'checkout_label' => __('PayPal', 'give'),
29 29
 		),
30 30
 		'manual' => array(
31
-			'admin_label'    => __( 'Test Donation', 'give' ),
32
-			'checkout_label' => __( 'Test Donation', 'give' )
31
+			'admin_label'    => __('Test Donation', 'give'),
32
+			'checkout_label' => __('Test Donation', 'give')
33 33
 		),
34 34
 	);
35 35
 
36
-	return apply_filters( 'give_payment_gateways', $gateways );
36
+	return apply_filters('give_payment_gateways', $gateways);
37 37
 
38 38
 }
39 39
 
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
  *
47 47
  * @return array $gateway_list All the available gateways
48 48
  */
49
-function give_get_enabled_payment_gateways( $form_id = 0 ) {
49
+function give_get_enabled_payment_gateways($form_id = 0) {
50 50
 
51 51
 	$gateways = give_get_payment_gateways();
52 52
 
53
-	$enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
53
+	$enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
54 54
 
55 55
 	$gateway_list = array();
56 56
 
57
-	foreach ( $gateways as $key => $gateway ) {
58
-		if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
59
-			$gateway_list[ $key ] = $gateway;
57
+	foreach ($gateways as $key => $gateway) {
58
+		if (isset($enabled[$key]) && $enabled[$key] == 1) {
59
+			$gateway_list[$key] = $gateway;
60 60
 		}
61 61
 	}
62 62
 
63 63
 	// Set order of payment gateway in list.
64
-	$gateway_list = give_get_ordered_payment_gateways( $gateway_list );
64
+	$gateway_list = give_get_ordered_payment_gateways($gateway_list);
65 65
 
66
-	return apply_filters( 'give_enabled_payment_gateways', $gateway_list, $form_id );
66
+	return apply_filters('give_enabled_payment_gateways', $gateway_list, $form_id);
67 67
 }
68 68
 
69 69
 /**
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
  *
76 76
  * @return boolean true if enabled, false otherwise
77 77
  */
78
-function give_is_gateway_active( $gateway ) {
78
+function give_is_gateway_active($gateway) {
79 79
 	$gateways = give_get_enabled_payment_gateways();
80 80
 
81
-	$ret = array_key_exists( $gateway, $gateways );
81
+	$ret = array_key_exists($gateway, $gateways);
82 82
 
83
-	return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways );
83
+	return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways);
84 84
 }
85 85
 
86 86
 /**
@@ -92,25 +92,25 @@  discard block
 block discarded – undo
92 92
  *
93 93
  * @return string Gateway ID
94 94
  */
95
-function give_get_default_gateway( $form_id ) {
95
+function give_get_default_gateway($form_id) {
96 96
 
97
-	$enabled_gateways = array_keys( give_get_enabled_payment_gateways() );
97
+	$enabled_gateways = array_keys(give_get_enabled_payment_gateways());
98 98
 	$default_gateway  = give_get_option('default_gateway');
99
-	$default          = ! empty( $default_gateway ) && give_is_gateway_active( $default_gateway ) ? $default_gateway : $enabled_gateways[0];
100
-	$form_default     = give_get_meta( $form_id, '_give_default_gateway', true );
99
+	$default          = ! empty($default_gateway) && give_is_gateway_active($default_gateway) ? $default_gateway : $enabled_gateways[0];
100
+	$form_default     = give_get_meta($form_id, '_give_default_gateway', true);
101 101
 
102 102
 	// Single Form settings varies compared to the Global default settings.
103 103
 	if (
104
-		! empty( $form_default ) &&
104
+		! empty($form_default) &&
105 105
 		$form_id !== null &&
106 106
 		$default !== $form_default &&
107 107
 		'global' !== $form_default &&
108
-		give_is_gateway_active( $form_default )
108
+		give_is_gateway_active($form_default)
109 109
 	) {
110 110
 		$default = $form_default;
111 111
 	}
112 112
 
113
-	return apply_filters( 'give_default_gateway', $default );
113
+	return apply_filters('give_default_gateway', $default);
114 114
 }
115 115
 
116 116
 /**
@@ -122,18 +122,18 @@  discard block
 block discarded – undo
122 122
  *
123 123
  * @return string Gateway admin label
124 124
  */
125
-function give_get_gateway_admin_label( $gateway ) {
125
+function give_get_gateway_admin_label($gateway) {
126 126
 	$gateways = give_get_payment_gateways();
127
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
128
-	$payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
127
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
128
+	$payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
129 129
 
130
-	if ( $gateway == 'manual' && $payment ) {
131
-		if ( give_donation_amount( $payment ) == 0 ) {
132
-			$label = __( 'Test Donation', 'give' );
130
+	if ($gateway == 'manual' && $payment) {
131
+		if (give_donation_amount($payment) == 0) {
132
+			$label = __('Test Donation', 'give');
133 133
 		}
134 134
 	}
135 135
 
136
-	return apply_filters( 'give_gateway_admin_label', $label, $gateway );
136
+	return apply_filters('give_gateway_admin_label', $label, $gateway);
137 137
 }
138 138
 
139 139
 /**
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
  *
146 146
  * @return string Checkout label for the gateway
147 147
  */
148
-function give_get_gateway_checkout_label( $gateway ) {
148
+function give_get_gateway_checkout_label($gateway) {
149 149
 	$gateways = give_get_payment_gateways();
150
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
150
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
151 151
 
152
-	if ( $gateway == 'manual' ) {
153
-		$label = __( 'Test Donation', 'give' );
152
+	if ($gateway == 'manual') {
153
+		$label = __('Test Donation', 'give');
154 154
 	}
155 155
 
156
-	return apply_filters( 'give_gateway_checkout_label', $label, $gateway );
156
+	return apply_filters('give_gateway_checkout_label', $label, $gateway);
157 157
 }
158 158
 
159 159
 /**
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
  *
166 166
  * @return array Options the gateway supports
167 167
  */
168
-function give_get_gateway_supports( $gateway ) {
168
+function give_get_gateway_supports($gateway) {
169 169
 	$gateways = give_get_enabled_payment_gateways();
170
-	$supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
170
+	$supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
171 171
 
172
-	return apply_filters( 'give_gateway_supports', $supports, $gateway );
172
+	return apply_filters('give_gateway_supports', $supports, $gateway);
173 173
 }
174 174
 
175 175
 /**
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
  *
183 183
  * @return void
184 184
  */
185
-function give_send_to_gateway( $gateway, $payment_data ) {
185
+function give_send_to_gateway($gateway, $payment_data) {
186 186
 
187
-	$payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' );
187
+	$payment_data['gateway_nonce'] = wp_create_nonce('give-gateway');
188 188
 
189 189
 	/**
190 190
 	 * Fires while loading payment gateway via AJAX.
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 *
196 196
 	 * @param array $payment_data All the payment data to be sent to the gateway.
197 197
 	 */
198
-	do_action( "give_gateway_{$gateway}", $payment_data );
198
+	do_action("give_gateway_{$gateway}", $payment_data);
199 199
 }
200 200
 
201 201
 
@@ -209,34 +209,34 @@  discard block
 block discarded – undo
209 209
  *
210 210
  * @return string $enabled_gateway The slug of the gateway
211 211
  */
212
-function give_get_chosen_gateway( $form_id ) {
212
+function give_get_chosen_gateway($form_id) {
213 213
 
214
-	$request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0;
214
+	$request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0;
215 215
 
216 216
 	// Back to check if 'form-id' is present.
217
-	if ( empty( $request_form_id ) ) {
218
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0;
217
+	if (empty($request_form_id)) {
218
+		$request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0;
219 219
 	}
220 220
 
221
-	$request_payment_mode = isset( $_REQUEST['payment-mode'] ) ? $_REQUEST['payment-mode'] : '';
221
+	$request_payment_mode = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : '';
222 222
 	$chosen               = false;
223 223
 
224 224
 	// If both 'payment-mode' and 'form-id' then set for only this form.
225
-	if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) {
225
+	if ( ! empty($request_form_id) && $form_id == $request_form_id) {
226 226
 		$chosen = $request_payment_mode;
227
-	} elseif ( empty( $request_form_id ) && $request_payment_mode ) {
227
+	} elseif (empty($request_form_id) && $request_payment_mode) {
228 228
 		// If no 'form-id' but there is 'payment-mode'.
229 229
 		$chosen = $request_payment_mode;
230 230
 	}
231 231
 
232 232
 	// Get the enable gateway based of chosen var.
233
-	if ( $chosen && give_is_gateway_active( $chosen ) ) {
234
-		$enabled_gateway = urldecode( $chosen );
233
+	if ($chosen && give_is_gateway_active($chosen)) {
234
+		$enabled_gateway = urldecode($chosen);
235 235
 	} else {
236
-		$enabled_gateway = give_get_default_gateway( $form_id );
236
+		$enabled_gateway = give_get_default_gateway($form_id);
237 237
 	}
238 238
 
239
-	return apply_filters( 'give_chosen_gateway', $enabled_gateway );
239
+	return apply_filters('give_chosen_gateway', $enabled_gateway);
240 240
 
241 241
 }
242 242
 
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
  *
256 256
  * @return int             ID of the new log entry.
257 257
  */
258
-function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) {
259
-	return Give()->logs->add( $title, $message, $parent, $type );
258
+function give_record_log($title = '', $message = '', $parent = 0, $type = null) {
259
+	return Give()->logs->add($title, $message, $parent, $type);
260 260
 }
261 261
 
262 262
 /**
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
  *
274 274
  * @return int ID of the new log entry
275 275
  */
276
-function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
277
-	$title = empty( $title ) ? esc_html__( 'Payment Error', 'give' ) : $title;
276
+function give_record_gateway_error($title = '', $message = '', $parent = 0) {
277
+	$title = empty($title) ? esc_html__('Payment Error', 'give') : $title;
278 278
 
279
-	return give_record_log( $title, $message, $parent, 'gateway_error' );
279
+	return give_record_log($title, $message, $parent, 'gateway_error');
280 280
 }
281 281
 
282 282
 /**
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
  *
290 290
  * @return int
291 291
  */
292
-function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
292
+function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
293 293
 
294 294
 	$ret  = 0;
295 295
 	$args = array(
@@ -301,9 +301,9 @@  discard block
 block discarded – undo
301 301
 		'fields'      => 'ids',
302 302
 	);
303 303
 
304
-	$payments = new WP_Query( $args );
304
+	$payments = new WP_Query($args);
305 305
 
306
-	if ( $payments ) {
306
+	if ($payments) {
307 307
 		$ret = $payments->post_count;
308 308
 	}
309 309
 
@@ -320,27 +320,27 @@  discard block
 block discarded – undo
320 320
  *
321 321
  * @return array $gateways All the available gateways
322 322
  */
323
-function give_get_ordered_payment_gateways( $gateways ) {
323
+function give_get_ordered_payment_gateways($gateways) {
324 324
 
325 325
 	// Get gateways setting.
326
-	$gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
326
+	$gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
327 327
 
328 328
 	// Return from here if we do not have gateways setting.
329
-	if ( empty( $gateways_setting ) ) {
329
+	if (empty($gateways_setting)) {
330 330
 		return $gateways;
331 331
 	}
332 332
 
333 333
 	// Reverse array to order payment gateways.
334
-	$gateways_setting = array_reverse( $gateways_setting );
334
+	$gateways_setting = array_reverse($gateways_setting);
335 335
 
336 336
 	// Reorder gateways array
337
-	foreach ( $gateways_setting as $gateway_key => $value ) {
337
+	foreach ($gateways_setting as $gateway_key => $value) {
338 338
 
339
-		$new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : '';
340
-		unset( $gateways[ $gateway_key ] );
339
+		$new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : '';
340
+		unset($gateways[$gateway_key]);
341 341
 
342
-		if ( ! empty( $new_gateway_value ) ) {
343
-			$gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways );
342
+		if ( ! empty($new_gateway_value)) {
343
+			$gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways);
344 344
 		}
345 345
 	}
346 346
 
@@ -351,5 +351,5 @@  discard block
 block discarded – undo
351 351
 	 *
352 352
 	 * @param array $gateways All the available gateways
353 353
 	 */
354
-	return apply_filters( 'give_payment_gateways_order', $gateways );
354
+	return apply_filters('give_payment_gateways_order', $gateways);
355 355
 }
356 356
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-html-elements.php 1 patch
Spacing   +156 added lines, -156 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
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return string       Donations dropdown.
37 37
 	 */
38
-	public function donations_dropdown( $args = array() ) {
38
+	public function donations_dropdown($args = array()) {
39 39
 
40 40
 		$defaults = array(
41 41
 			'name'        => 'donations',
@@ -45,32 +45,32 @@  discard block
 block discarded – undo
45 45
 			'selected'    => 0,
46 46
 			'chosen'      => false,
47 47
 			'number'      => 30,
48
-			'placeholder' => __( 'Select a donation', 'give' ),
48
+			'placeholder' => __('Select a donation', 'give'),
49 49
 		);
50 50
 
51
-		$args = wp_parse_args( $args, $defaults );
51
+		$args = wp_parse_args($args, $defaults);
52 52
 
53
-		$payments = new Give_Payments_Query( array(
53
+		$payments = new Give_Payments_Query(array(
54 54
 			'number' => $args['number'],
55
-		) );
55
+		));
56 56
 
57 57
 		$payments = $payments->get_payments();
58 58
 
59 59
 		$options = array();
60 60
 
61 61
 		// Provide nice human readable options.
62
-		if ( $payments ) {
62
+		if ($payments) {
63 63
 			$options[0] = $args['placeholder'];
64
-			foreach ( $payments as $payment ) {
64
+			foreach ($payments as $payment) {
65 65
 
66
-				$options[ absint( $payment->ID ) ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title );
66
+				$options[absint($payment->ID)] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title);
67 67
 
68 68
 			}
69 69
 		} else {
70
-			$options[0] = __( 'No donations found.', 'give' );
70
+			$options[0] = __('No donations found.', 'give');
71 71
 		}
72 72
 
73
-		$output = $this->select( array(
73
+		$output = $this->select(array(
74 74
 			'name'             => $args['name'],
75 75
 			'selected'         => $args['selected'],
76 76
 			'id'               => $args['id'],
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			'select_atts'      => $args['select_atts'],
83 83
 			'show_option_all'  => false,
84 84
 			'show_option_none' => false,
85
-		) );
85
+		));
86 86
 
87 87
 		return $output;
88 88
 	}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 *
100 100
 	 * @return string      Give forms dropdown.
101 101
 	 */
102
-	public function forms_dropdown( $args = array() ) {
102
+	public function forms_dropdown($args = array()) {
103 103
 
104 104
 		$defaults = array(
105 105
 			'name'        => 'forms',
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
 			'selected'    => 0,
110 110
 			'chosen'      => false,
111 111
 			'number'      => 30,
112
-			'placeholder' => esc_attr__( 'All Forms', 'give' ),
112
+			'placeholder' => esc_attr__('All Forms', 'give'),
113 113
 			'data'        => array(
114 114
 				'search-type' => 'form',
115 115
 			),
116 116
 		);
117 117
 
118
-		$args = wp_parse_args( $args, $defaults );
118
+		$args = wp_parse_args($args, $defaults);
119 119
 
120 120
 		$form_args = array(
121 121
 			'post_type'      => 'give_forms',
@@ -124,34 +124,34 @@  discard block
 block discarded – undo
124 124
 			'posts_per_page' => $args['number'],
125 125
 		);
126 126
 
127
-		$cache_key   = Give_Cache::get_key( 'give_forms', $form_args, false );
127
+		$cache_key = Give_Cache::get_key('give_forms', $form_args, false);
128 128
 
129 129
 		// Get forms from cache.
130
-		$forms = Give_Cache::get_db_query( $cache_key );
130
+		$forms = Give_Cache::get_db_query($cache_key);
131 131
 
132
-		if ( is_null( $forms ) ) {
133
-			$forms = get_posts( $form_args );
134
-			Give_Cache::set_db_query( $cache_key, $forms );
132
+		if (is_null($forms)) {
133
+			$forms = get_posts($form_args);
134
+			Give_Cache::set_db_query($cache_key, $forms);
135 135
 		}
136 136
 
137 137
 		$options = array();
138 138
 
139 139
 		// Ensure the selected.
140
-		if ( false !== $args['selected'] && $args['selected'] !== 0 ) {
141
-			$options[ $args['selected'] ] = get_the_title( $args['selected'] );
140
+		if (false !== $args['selected'] && $args['selected'] !== 0) {
141
+			$options[$args['selected']] = get_the_title($args['selected']);
142 142
 		}
143 143
 
144
-		if ( $forms ) {
144
+		if ($forms) {
145 145
 			$options[0] = $args['placeholder'];
146
-			foreach ( $forms as $form ) {
147
-				$form_title                     = empty( $form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form->ID ) : $form->post_title;
148
-				$options[ absint( $form->ID ) ] = esc_html( $form_title );
146
+			foreach ($forms as $form) {
147
+				$form_title                     = empty($form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $form->ID) : $form->post_title;
148
+				$options[absint($form->ID)] = esc_html($form_title);
149 149
 			}
150 150
 		} else {
151
-			$options[0] = esc_html__( 'No forms found.', 'give' );
151
+			$options[0] = esc_html__('No forms found.', 'give');
152 152
 		}
153 153
 
154
-		$output = $this->select( array(
154
+		$output = $this->select(array(
155 155
 			'name'             => $args['name'],
156 156
 			'selected'         => $args['selected'],
157 157
 			'id'               => $args['id'],
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 			'show_option_all'  => false,
164 164
 			'show_option_none' => false,
165 165
 			'data'             => $args['data'],
166
-		) );
166
+		));
167 167
 
168 168
 		return $output;
169 169
 	}
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @return string      Donors dropdown.
182 182
 	 */
183
-	public function donor_dropdown( $args = array() ) {
183
+	public function donor_dropdown($args = array()) {
184 184
 
185 185
 		$defaults = array(
186 186
 			'name'        => 'donors',
@@ -189,57 +189,57 @@  discard block
 block discarded – undo
189 189
 			'multiple'    => false,
190 190
 			'selected'    => 0,
191 191
 			'chosen'      => true,
192
-			'placeholder' => esc_attr__( 'Select a Donor', 'give' ),
192
+			'placeholder' => esc_attr__('Select a Donor', 'give'),
193 193
 			'number'      => 30,
194 194
 			'data'        => array(
195 195
 				'search-type' => 'donor',
196 196
 			),
197 197
 		);
198 198
 
199
-		$args = wp_parse_args( $args, $defaults );
199
+		$args = wp_parse_args($args, $defaults);
200 200
 
201
-		$donors = Give()->donors->get_donors( array(
201
+		$donors = Give()->donors->get_donors(array(
202 202
 			'number' => $args['number']
203
-		) );
203
+		));
204 204
 
205 205
 		$options = array();
206 206
 
207
-		if ( $donors ) {
208
-			$options[0] = esc_html__( 'No donor attached', 'give' );
209
-			foreach ( $donors as $donor ) {
210
-				$options[ absint( $donor->id ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' );
207
+		if ($donors) {
208
+			$options[0] = esc_html__('No donor attached', 'give');
209
+			foreach ($donors as $donor) {
210
+				$options[absint($donor->id)] = esc_html($donor->name.' ('.$donor->email.')');
211 211
 			}
212 212
 		} else {
213
-			$options[0] = esc_html__( 'No donors found.', 'give' );
213
+			$options[0] = esc_html__('No donors found.', 'give');
214 214
 		}
215 215
 
216
-		if ( ! empty( $args['selected'] ) ) {
216
+		if ( ! empty($args['selected'])) {
217 217
 
218 218
 			// If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed.
219
-			if ( ! array_key_exists( $args['selected'], $options ) ) {
219
+			if ( ! array_key_exists($args['selected'], $options)) {
220 220
 
221
-				$donor = new Give_Donor( $args['selected'] );
221
+				$donor = new Give_Donor($args['selected']);
222 222
 
223
-				if ( $donor ) {
223
+				if ($donor) {
224 224
 
225
-					$options[ absint( $args['selected'] ) ] = esc_html( $donor->name . ' (' . $donor->email . ')' );
225
+					$options[absint($args['selected'])] = esc_html($donor->name.' ('.$donor->email.')');
226 226
 
227 227
 				}
228 228
 			}
229 229
 		}
230 230
 
231
-		$output = $this->select( array(
231
+		$output = $this->select(array(
232 232
 			'name'             => $args['name'],
233 233
 			'selected'         => $args['selected'],
234 234
 			'id'               => $args['id'],
235
-			'class'            => $args['class'] . ' give-customer-select',
235
+			'class'            => $args['class'].' give-customer-select',
236 236
 			'options'          => $options,
237 237
 			'multiple'         => $args['multiple'],
238 238
 			'chosen'           => $args['chosen'],
239 239
 			'show_option_all'  => false,
240 240
 			'show_option_none' => false,
241 241
 			'data'             => $args['data'],
242
-		) );
242
+		));
243 243
 
244 244
 		return $output;
245 245
 	}
@@ -258,21 +258,21 @@  discard block
 block discarded – undo
258 258
 	 *
259 259
 	 * @return string           Categories dropdown.
260 260
 	 */
261
-	public function category_dropdown( $name = 'give_forms_categories', $selected = 0, $args = array() ) {
262
-		$categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) );
261
+	public function category_dropdown($name = 'give_forms_categories', $selected = 0, $args = array()) {
262
+		$categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array()));
263 263
 		$options    = array();
264 264
 
265
-		foreach ( $categories as $category ) {
266
-			$options[ absint( $category->term_id ) ] = esc_html( $category->name );
265
+		foreach ($categories as $category) {
266
+			$options[absint($category->term_id)] = esc_html($category->name);
267 267
 		}
268 268
 
269
-		$output = $this->select( wp_parse_args( $args, array(
269
+		$output = $this->select(wp_parse_args($args, array(
270 270
 			'name'             => $name,
271 271
 			'selected'         => $selected,
272 272
 			'options'          => $options,
273
-			'show_option_all'  => esc_html__( 'All Categories', 'give' ),
273
+			'show_option_all'  => esc_html__('All Categories', 'give'),
274 274
 			'show_option_none' => false,
275
-		) ) );
275
+		)));
276 276
 
277 277
 		return $output;
278 278
 	}
@@ -291,21 +291,21 @@  discard block
 block discarded – undo
291 291
 	 *
292 292
 	 * @return string           Tags dropdown.
293 293
 	 */
294
-	public function tags_dropdown( $name = 'give_forms_tags', $selected = 0, $args = array() ) {
295
-		$tags    = get_terms( 'give_forms_tag', apply_filters( 'give_forms_tag_dropdown', array() ) );
294
+	public function tags_dropdown($name = 'give_forms_tags', $selected = 0, $args = array()) {
295
+		$tags    = get_terms('give_forms_tag', apply_filters('give_forms_tag_dropdown', array()));
296 296
 		$options = array();
297 297
 
298
-		foreach ( $tags as $tag ) {
299
-			$options[ absint( $tag->term_id ) ] = esc_html( $tag->name );
298
+		foreach ($tags as $tag) {
299
+			$options[absint($tag->term_id)] = esc_html($tag->name);
300 300
 		}
301 301
 
302
-		$output = $this->select( wp_parse_args( $args, array(
302
+		$output = $this->select(wp_parse_args($args, array(
303 303
 			'name'             => $name,
304 304
 			'selected'         => $selected,
305 305
 			'options'          => $options,
306
-			'show_option_all'  => esc_html__( 'All Tags', 'give' ),
306
+			'show_option_all'  => esc_html__('All Tags', 'give'),
307 307
 			'show_option_none' => false,
308
-		) ) );
308
+		)));
309 309
 
310 310
 		return $output;
311 311
 	}
@@ -325,25 +325,25 @@  discard block
 block discarded – undo
325 325
 	 *
326 326
 	 * @return string               Years dropdown.
327 327
 	 */
328
-	public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
329
-		$current    = date( 'Y' );
330
-		$start_year = $current - absint( $years_before );
331
-		$end_year   = $current + absint( $years_after );
332
-		$selected   = empty( $selected ) ? date( 'Y' ) : $selected;
328
+	public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
329
+		$current    = date('Y');
330
+		$start_year = $current - absint($years_before);
331
+		$end_year   = $current + absint($years_after);
332
+		$selected   = empty($selected) ? date('Y') : $selected;
333 333
 		$options    = array();
334 334
 
335
-		while ( $start_year <= $end_year ) {
336
-			$options[ absint( $start_year ) ] = $start_year;
337
-			$start_year ++;
335
+		while ($start_year <= $end_year) {
336
+			$options[absint($start_year)] = $start_year;
337
+			$start_year++;
338 338
 		}
339 339
 
340
-		$output = $this->select( array(
340
+		$output = $this->select(array(
341 341
 			'name'             => $name,
342 342
 			'selected'         => $selected,
343 343
 			'options'          => $options,
344 344
 			'show_option_all'  => false,
345 345
 			'show_option_none' => false,
346
-		) );
346
+		));
347 347
 
348 348
 		return $output;
349 349
 	}
@@ -361,23 +361,23 @@  discard block
 block discarded – undo
361 361
 	 *
362 362
 	 * @return string           Months dropdown.
363 363
 	 */
364
-	public function month_dropdown( $name = 'month', $selected = 0 ) {
364
+	public function month_dropdown($name = 'month', $selected = 0) {
365 365
 		$month    = 1;
366 366
 		$options  = array();
367
-		$selected = empty( $selected ) ? date( 'n' ) : $selected;
367
+		$selected = empty($selected) ? date('n') : $selected;
368 368
 
369
-		while ( $month <= 12 ) {
370
-			$options[ absint( $month ) ] = give_month_num_to_name( $month );
371
-			$month ++;
369
+		while ($month <= 12) {
370
+			$options[absint($month)] = give_month_num_to_name($month);
371
+			$month++;
372 372
 		}
373 373
 
374
-		$output = $this->select( array(
374
+		$output = $this->select(array(
375 375
 			'name'             => $name,
376 376
 			'selected'         => $selected,
377 377
 			'options'          => $options,
378 378
 			'show_option_all'  => false,
379 379
 			'show_option_none' => false,
380
-		) );
380
+		));
381 381
 
382 382
 		return $output;
383 383
 	}
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	 *
395 395
 	 * @return string      The dropdown.
396 396
 	 */
397
-	public function select( $args = array() ) {
397
+	public function select($args = array()) {
398 398
 		$defaults = array(
399 399
 			'options'          => array(),
400 400
 			'name'             => null,
@@ -405,74 +405,74 @@  discard block
 block discarded – undo
405 405
 			'placeholder'      => null,
406 406
 			'multiple'         => false,
407 407
 			'select_atts'      => false,
408
-			'show_option_all'  => __( 'All', 'give' ),
409
-			'show_option_none' => __( 'None', 'give' ),
408
+			'show_option_all'  => __('All', 'give'),
409
+			'show_option_none' => __('None', 'give'),
410 410
 			'data'             => array(),
411 411
 			'readonly'         => false,
412 412
 			'disabled'         => false,
413 413
 		);
414 414
 
415
-		$args = wp_parse_args( $args, $defaults );
415
+		$args = wp_parse_args($args, $defaults);
416 416
 
417 417
 		$data_elements = '';
418
-		foreach ( $args['data'] as $key => $value ) {
419
-			$data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
418
+		foreach ($args['data'] as $key => $value) {
419
+			$data_elements .= ' data-'.esc_attr($key).'="'.esc_attr($value).'"';
420 420
 		}
421 421
 
422 422
 		$multiple = '';
423
-		if ( $args['multiple'] ) {
423
+		if ($args['multiple']) {
424 424
 			$multiple = 'MULTIPLE';
425 425
 		}
426 426
 
427
-		if ( $args['chosen'] ) {
427
+		if ($args['chosen']) {
428 428
 			$args['class'] .= ' give-select-chosen';
429 429
 		}
430 430
 
431 431
 		$placeholder = '';
432
-		if ( $args['placeholder'] ) {
432
+		if ($args['placeholder']) {
433 433
 			$placeholder = $args['placeholder'];
434 434
 		}
435 435
 
436 436
 		$output = sprintf(
437 437
 			'<select name="%1$s" id="%2$s" class="give-select %3$s" %4$s %5$s placeholder="%6$s" data-placeholder="%6$s" %7$s>',
438
-			esc_attr( $args['name'] ),
439
-			esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ),
440
-			esc_attr( $args['class'] ),
438
+			esc_attr($args['name']),
439
+			esc_attr(sanitize_key(str_replace('-', '_', $args['id']))),
440
+			esc_attr($args['class']),
441 441
 			$multiple,
442 442
 			$args['select_atts'],
443 443
 			$placeholder,
444 444
 			$data_elements
445 445
 		);
446 446
 
447
-		if ( $args['show_option_all'] ) {
448
-			if ( $args['multiple'] ) {
449
-				$selected = selected( true, in_array( 0, $args['selected'] ), false );
447
+		if ($args['show_option_all']) {
448
+			if ($args['multiple']) {
449
+				$selected = selected(true, in_array(0, $args['selected']), false);
450 450
 			} else {
451
-				$selected = selected( $args['selected'], 0, false );
451
+				$selected = selected($args['selected'], 0, false);
452 452
 			}
453
-			$output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
453
+			$output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>';
454 454
 		}
455 455
 
456
-		if ( ! empty( $args['options'] ) ) {
456
+		if ( ! empty($args['options'])) {
457 457
 
458
-			if ( $args['show_option_none'] ) {
459
-				if ( $args['multiple'] ) {
460
-					$selected = selected( true, in_array( - 1, $args['selected'] ), false );
458
+			if ($args['show_option_none']) {
459
+				if ($args['multiple']) {
460
+					$selected = selected(true, in_array( -1, $args['selected'] ), false);
461 461
 				} else {
462
-					$selected = selected( $args['selected'], - 1, false );
462
+					$selected = selected($args['selected'], - 1, false);
463 463
 				}
464
-				$output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
464
+				$output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>';
465 465
 			}
466 466
 
467
-			foreach ( $args['options'] as $key => $option ) {
467
+			foreach ($args['options'] as $key => $option) {
468 468
 
469
-				if ( $args['multiple'] && is_array( $args['selected'] ) ) {
470
-					$selected = selected( true, in_array( $key, $args['selected'] ), false );
469
+				if ($args['multiple'] && is_array($args['selected'])) {
470
+					$selected = selected(true, in_array($key, $args['selected']), false);
471 471
 				} else {
472
-					$selected = selected( $args['selected'], $key, false );
472
+					$selected = selected($args['selected'], $key, false);
473 473
 				}
474 474
 
475
-				$output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
475
+				$output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>';
476 476
 			}
477 477
 		}
478 478
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 	 *
494 494
 	 * @return string      The checkbox.
495 495
 	 */
496
-	public function checkbox( $args = array() ) {
496
+	public function checkbox($args = array()) {
497 497
 		$defaults = array(
498 498
 			'name'    => null,
499 499
 			'current' => null,
@@ -504,16 +504,16 @@  discard block
 block discarded – undo
504 504
 			),
505 505
 		);
506 506
 
507
-		$args = wp_parse_args( $args, $defaults );
507
+		$args = wp_parse_args($args, $defaults);
508 508
 
509 509
 		$options = '';
510
-		if ( ! empty( $args['options']['disabled'] ) ) {
510
+		if ( ! empty($args['options']['disabled'])) {
511 511
 			$options .= ' disabled="disabled"';
512
-		} elseif ( ! empty( $args['options']['readonly'] ) ) {
512
+		} elseif ( ! empty($args['options']['readonly'])) {
513 513
 			$options .= ' readonly';
514 514
 		}
515 515
 
516
-		$output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
516
+		$output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />';
517 517
 
518 518
 		return $output;
519 519
 	}
@@ -530,22 +530,22 @@  discard block
 block discarded – undo
530 530
 	 *
531 531
 	 * @return string      The text field.
532 532
 	 */
533
-	public function text( $args = array() ) {
533
+	public function text($args = array()) {
534 534
 		// Backwards compatibility.
535
-		if ( func_num_args() > 1 ) {
535
+		if (func_num_args() > 1) {
536 536
 			$args = func_get_args();
537 537
 
538 538
 			$name  = $args[0];
539
-			$value = isset( $args[1] ) ? $args[1] : '';
540
-			$label = isset( $args[2] ) ? $args[2] : '';
541
-			$desc  = isset( $args[3] ) ? $args[3] : '';
539
+			$value = isset($args[1]) ? $args[1] : '';
540
+			$label = isset($args[2]) ? $args[2] : '';
541
+			$desc  = isset($args[3]) ? $args[3] : '';
542 542
 		}
543 543
 
544 544
 		$defaults = array(
545
-			'name'         => isset( $name ) ? $name : 'text',
546
-			'value'        => isset( $value ) ? $value : null,
547
-			'label'        => isset( $label ) ? $label : null,
548
-			'desc'         => isset( $desc ) ? $desc : null,
545
+			'name'         => isset($name) ? $name : 'text',
546
+			'value'        => isset($value) ? $value : null,
547
+			'label'        => isset($label) ? $label : null,
548
+			'desc'         => isset($desc) ? $desc : null,
549 549
 			'placeholder'  => '',
550 550
 			'class'        => 'regular-text',
551 551
 			'disabled'     => false,
@@ -553,29 +553,29 @@  discard block
 block discarded – undo
553 553
 			'data'         => false,
554 554
 		);
555 555
 
556
-		$args = wp_parse_args( $args, $defaults );
556
+		$args = wp_parse_args($args, $defaults);
557 557
 
558 558
 		$disabled = '';
559
-		if ( $args['disabled'] ) {
559
+		if ($args['disabled']) {
560 560
 			$disabled = ' disabled="disabled"';
561 561
 		}
562 562
 
563 563
 		$data = '';
564
-		if ( ! empty( $args['data'] ) ) {
565
-			foreach ( $args['data'] as $key => $value ) {
566
-				$data .= 'data-' . $key . '="' . $value . '" ';
564
+		if ( ! empty($args['data'])) {
565
+			foreach ($args['data'] as $key => $value) {
566
+				$data .= 'data-'.$key.'="'.$value.'" ';
567 567
 			}
568 568
 		}
569 569
 
570
-		$output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">';
570
+		$output = '<span id="give-'.sanitize_key($args['name']).'-wrap">';
571 571
 
572
-		$output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
572
+		$output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>';
573 573
 
574
-		if ( ! empty( $args['desc'] ) ) {
575
-			$output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>';
574
+		if ( ! empty($args['desc'])) {
575
+			$output .= '<span class="give-description">'.esc_html($args['desc']).'</span>';
576 576
 		}
577 577
 
578
-		$output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>';
578
+		$output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>';
579 579
 
580 580
 		$output .= '</span>';
581 581
 
@@ -594,15 +594,15 @@  discard block
 block discarded – undo
594 594
 	 *
595 595
 	 * @return string      The date picker.
596 596
 	 */
597
-	public function date_field( $args = array() ) {
597
+	public function date_field($args = array()) {
598 598
 
599
-		if ( empty( $args['class'] ) ) {
599
+		if (empty($args['class'])) {
600 600
 			$args['class'] = 'give_datepicker';
601
-		} elseif ( ! strpos( $args['class'], 'give_datepicker' ) ) {
601
+		} elseif ( ! strpos($args['class'], 'give_datepicker')) {
602 602
 			$args['class'] .= ' give_datepicker';
603 603
 		}
604 604
 
605
-		return $this->text( $args );
605
+		return $this->text($args);
606 606
 	}
607 607
 
608 608
 	/**
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
 	 *
618 618
 	 * @return string      The textarea.
619 619
 	 */
620
-	public function textarea( $args = array() ) {
620
+	public function textarea($args = array()) {
621 621
 		$defaults = array(
622 622
 			'name'     => 'textarea',
623 623
 			'value'    => null,
@@ -627,21 +627,21 @@  discard block
 block discarded – undo
627 627
 			'disabled' => false,
628 628
 		);
629 629
 
630
-		$args = wp_parse_args( $args, $defaults );
630
+		$args = wp_parse_args($args, $defaults);
631 631
 
632 632
 		$disabled = '';
633
-		if ( $args['disabled'] ) {
633
+		if ($args['disabled']) {
634 634
 			$disabled = ' disabled="disabled"';
635 635
 		}
636 636
 
637
-		$output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">';
637
+		$output = '<span id="give-'.sanitize_key($args['name']).'-wrap">';
638 638
 
639
-		$output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
639
+		$output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>';
640 640
 
641
-		$output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
641
+		$output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>';
642 642
 
643
-		if ( ! empty( $args['desc'] ) ) {
644
-			$output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>';
643
+		if ( ! empty($args['desc'])) {
644
+			$output .= '<span class="give-description">'.esc_html($args['desc']).'</span>';
645 645
 		}
646 646
 
647 647
 		$output .= '</span>';
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 	 *
662 662
 	 * @return string      The text field with ajax search.
663 663
 	 */
664
-	public function ajax_user_search( $args = array() ) {
664
+	public function ajax_user_search($args = array()) {
665 665
 
666 666
 		$defaults = array(
667 667
 			'name'        => 'users',
@@ -672,13 +672,13 @@  discard block
 block discarded – undo
672 672
 			'chosen'      => true,
673 673
 			'number'      => 30,
674 674
 			'select_atts' => '',
675
-			'placeholder' => __( 'Select a user', 'give' ),
675
+			'placeholder' => __('Select a user', 'give'),
676 676
 			'data'        => array(
677 677
 				'search-type' => 'user',
678 678
 			),
679 679
 		);
680 680
 
681
-		$args = wp_parse_args( $args, $defaults );
681
+		$args = wp_parse_args($args, $defaults);
682 682
 
683 683
 		// Set initial args.
684 684
 		$get_users_args = array(
@@ -687,31 +687,31 @@  discard block
 block discarded – undo
687 687
 
688 688
 		// Ensure selected user is not included in initial query.
689 689
 		// This is because sites with many users, it's not a guarantee the selected user will be returned.
690
-		if ( ! empty( $args['selected'] ) ) {
690
+		if ( ! empty($args['selected'])) {
691 691
 			$get_users_args['exclude'] = $args['selected'];
692 692
 		}
693 693
 
694 694
 		// Initial users array.
695
-		$users = apply_filters( 'give_ajax_user_search_initial_results', get_users( $get_users_args ), $args );
695
+		$users = apply_filters('give_ajax_user_search_initial_results', get_users($get_users_args), $args);
696 696
 
697 697
 		// Now add the selected user to the $users array if the arg is present.
698
-		if ( ! empty( $args['selected'] ) ) {
699
-			$selected_user =  apply_filters( 'give_ajax_user_search_selected_results', get_users( "include={$args['selected']}" ), $args );;
700
-			$users         = array_merge( $users, $selected_user );
698
+		if ( ! empty($args['selected'])) {
699
+			$selected_user = apply_filters('give_ajax_user_search_selected_results', get_users("include={$args['selected']}"), $args); ;
700
+			$users         = array_merge($users, $selected_user);
701 701
 		}
702 702
 
703 703
 		$options = array();
704 704
 
705
-		if ( $users ) {
705
+		if ($users) {
706 706
 			$options[0] = $args['placeholder'];
707
-			foreach ( $users as $user ) {
708
-				$options[ absint( $user->ID ) ] = esc_html( $user->user_login . ' (' . $user->user_email . ')' );
707
+			foreach ($users as $user) {
708
+				$options[absint($user->ID)] = esc_html($user->user_login.' ('.$user->user_email.')');
709 709
 			}
710 710
 		} else {
711
-			$options[0] = __( 'No users found.', 'give' );
711
+			$options[0] = __('No users found.', 'give');
712 712
 		}
713 713
 
714
-		$output = $this->select( array(
714
+		$output = $this->select(array(
715 715
 			'name'             => $args['name'],
716 716
 			'selected'         => $args['selected'],
717 717
 			'id'               => $args['id'],
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 			'show_option_all'  => false,
725 725
 			'show_option_none' => false,
726 726
 			'data'             => $args['data'],
727
-		) );
727
+		));
728 728
 
729 729
 		return $output;
730 730
 
Please login to merge, or discard this patch.
templates/emails/header-default.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,16 +6,16 @@  discard block
 block discarded – undo
6 6
  * @version     1.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if ( ! defined('ABSPATH')) {
10 10
 	exit;
11 11
 } // Exit if accessed directly.
12 12
 
13 13
 // For gmail compatibility, including CSS styles in head/body are stripped out therefore styles need to be inline. These variables contain rules which are added to the template inline. !important; is a gmail hack to prevent styles being stripped if it doesn't like something.
14
-$body               = "
14
+$body = "
15 15
 	background-color: #f6f6f6;
16 16
 	font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
17 17
 ";
18
-$wrapper            = "
18
+$wrapper = "
19 19
 	width:100%;
20 20
 	-webkit-text-size-adjust:none !important;
21 21
 	margin:0;
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	border-radius:3px !important;
30 30
 	padding: 20px;
31 31
 ";
32
-$template_header    = "
32
+$template_header = "
33 33
 	color: #00000;
34 34
 	border-top-left-radius:3px !important;
35 35
 	border-top-right-radius:3px !important;
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	text-align: center;
40 40
 	vertical-align:middle;
41 41
 ";
42
-$body_content       = "
42
+$body_content = "
43 43
 	border-radius:3px !important;
44 44
 	font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
45 45
 ";
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	line-height:150%;
51 51
 	text-align:left;
52 52
 ";
53
-$header_content_h1  = "
53
+$header_content_h1 = "
54 54
 	color: #000000;
55 55
 	margin:0;
56 56
 	padding: 28px 24px;
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 <html>
66 66
 	<head>
67 67
 		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
68
-		<title><?php echo get_bloginfo( 'name' ); ?></title>
68
+		<title><?php echo get_bloginfo('name'); ?></title>
69 69
 	</head>
70 70
 	<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" style="<?php echo $body; ?>">
71 71
 		<div style="<?php echo $wrapper; ?>">
Please login to merge, or discard this patch.