Test Failed
Push — master ( 7fe983...516c23 )
by Devin
08:07 queued 03:09
created
includes/emails/template.php 1 patch
Spacing   +107 added lines, -107 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
 
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
  *
42 42
  * @return string $message Fully formatted message
43 43
  */
44
-function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) {
45
-	return give_do_email_tags( $message, $payment_id );
44
+function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) {
45
+	return give_do_email_tags($message, $payment_id);
46 46
 }
47 47
 
48 48
 /**
@@ -56,45 +56,45 @@  discard block
 block discarded – undo
56 56
  *
57 57
  * @return string $message Fully formatted message
58 58
  */
59
-function give_email_preview_template_tags( $message ) {
59
+function give_email_preview_template_tags($message) {
60 60
 
61
-	$price = give_currency_filter( give_format_amount( 10.50, array( 'sanitize' => false ) ) );
61
+	$price = give_currency_filter(give_format_amount(10.50, array('sanitize' => false)));
62 62
 
63 63
 	$gateway = 'PayPal';
64 64
 
65
-	$receipt_id = strtolower( md5( uniqid() ) );
65
+	$receipt_id = strtolower(md5(uniqid()));
66 66
 
67
-	$payment_id = rand( 1, 100 );
67
+	$payment_id = rand(1, 100);
68 68
 
69
-	$receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id, 'give_action' => 'view_receipt' ), home_url() ) );
69
+	$receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id, 'give_action' => 'view_receipt'), home_url()));
70 70
 	$receipt_link     = sprintf(
71 71
 		'<a href="%1$s">%2$s</a>',
72 72
 		$receipt_link_url,
73
-		esc_html__( 'View the receipt in your browser &raquo;', 'give' )
73
+		esc_html__('View the receipt in your browser &raquo;', 'give')
74 74
 	);
75 75
 
76 76
 	// Set user.
77 77
 	$user = wp_get_current_user();
78 78
 
79
-	$message = str_replace( '{name}', $user->display_name, $message );
80
-	$message = str_replace( '{fullname}', $user->display_name, $message );
81
-	$message = str_replace( '{username}', $user->user_login, $message );
82
-	$message = str_replace( '{user_email}', $user->user_email, $message );
83
-	$message = str_replace( '{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message );
84
-	$message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message );
85
-	$message = str_replace( '{amount}', $price, $message );
86
-	$message = str_replace( '{price}', $price, $message );
87
-	$message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message );
88
-	$message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message );
89
-	$message = str_replace( '{receipt_id}', $receipt_id, $message );
90
-	$message = str_replace( '{payment_method}', $gateway, $message );
91
-	$message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message );
92
-	$message = str_replace( '{payment_id}', $payment_id, $message );
93
-	$message = str_replace( '{receipt_link}', $receipt_link, $message );
94
-	$message = str_replace( '{receipt_link_url}', $receipt_link_url, $message );
95
-	$message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message );
96
-
97
-	return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) );
79
+	$message = str_replace('{name}', $user->display_name, $message);
80
+	$message = str_replace('{fullname}', $user->display_name, $message);
81
+	$message = str_replace('{username}', $user->user_login, $message);
82
+	$message = str_replace('{user_email}', $user->user_email, $message);
83
+	$message = str_replace('{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message);
84
+	$message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message);
85
+	$message = str_replace('{amount}', $price, $message);
86
+	$message = str_replace('{price}', $price, $message);
87
+	$message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message);
88
+	$message = str_replace('{form_title}', esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), $message);
89
+	$message = str_replace('{receipt_id}', $receipt_id, $message);
90
+	$message = str_replace('{payment_method}', $gateway, $message);
91
+	$message = str_replace('{sitename}', get_bloginfo('name'), $message);
92
+	$message = str_replace('{payment_id}', $payment_id, $message);
93
+	$message = str_replace('{receipt_link}', $receipt_link, $message);
94
+	$message = str_replace('{receipt_link_url}', $receipt_link_url, $message);
95
+	$message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message);
96
+
97
+	return wpautop(apply_filters('give_email_preview_template_tags', $message));
98 98
 }
99 99
 
100 100
 /**
@@ -106,23 +106,23 @@  discard block
 block discarded – undo
106 106
  * @since  1.0
107 107
  * @return array|bool
108 108
  */
109
-function give_email_template_preview( $array ) {
109
+function give_email_template_preview($array) {
110 110
 
111
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
111
+	if ( ! current_user_can('manage_give_settings')) {
112 112
 		return false;
113 113
 	}
114 114
 	$custom_field = array(
115
-		'name' => esc_html__( 'Preview Email', 'give' ),
116
-		'desc' => esc_html__( 'Click the buttons to preview or send test emails.', 'give' ),
115
+		'name' => esc_html__('Preview Email', 'give'),
116
+		'desc' => esc_html__('Click the buttons to preview or send test emails.', 'give'),
117 117
 		'id'   => 'give_email_preview_buttons',
118 118
 		'type' => 'email_preview_buttons',
119 119
 	);
120 120
 
121
-	return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) );
121
+	return give_settings_array_insert($array, 'donation_subject', array($custom_field));
122 122
 
123 123
 }
124 124
 
125
-add_filter( 'give_settings_emails', 'give_email_template_preview' );
125
+add_filter('give_settings_emails', 'give_email_template_preview');
126 126
 
127 127
 /**
128 128
  * Output Email Template Preview Buttons.
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
 function give_email_preview_buttons_callback() {
135 135
 	ob_start();
136 136
 	?>
137
-	<a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary"
138
-	   target="_blank"><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a>
139
-	<a href="<?php echo wp_nonce_url( add_query_arg( array(
137
+	<a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary"
138
+	   target="_blank"><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a>
139
+	<a href="<?php echo wp_nonce_url(add_query_arg(array(
140 140
 		'give_action'  => 'send_test_email',
141 141
 		'give-message' => 'sent-test-email',
142 142
 		'tag'          => 'emails',
143
-	) ), 'give-test-email' ); ?>" aria-label="<?php esc_attr_e( 'Send demo donation receipt to the emails listed below.', 'give' ); ?>"
144
-	   class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a>
143
+	)), 'give-test-email'); ?>" aria-label="<?php esc_attr_e('Send demo donation receipt to the emails listed below.', 'give'); ?>"
144
+	   class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a>
145 145
 	<?php
146 146
 	echo ob_get_clean();
147 147
 }
@@ -154,46 +154,46 @@  discard block
 block discarded – undo
154 154
  */
155 155
 function give_display_email_template_preview() {
156 156
 
157
-	if ( empty( $_GET['give_action'] ) ) {
157
+	if (empty($_GET['give_action'])) {
158 158
 		return;
159 159
 	}
160 160
 
161
-	if ( 'preview_email' !== $_GET['give_action'] ) {
161
+	if ('preview_email' !== $_GET['give_action']) {
162 162
 		return;
163 163
 	}
164 164
 
165
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
165
+	if ( ! current_user_can('manage_give_settings')) {
166 166
 		return;
167 167
 	}
168 168
 
169 169
 
170
-	Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' );
170
+	Give()->emails->heading = esc_html__('Donation Receipt', 'give');
171 171
 
172
-	$payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
172
+	$payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
173 173
 
174 174
 	echo give_get_preview_email_header();
175 175
 
176 176
 	//Are we previewing an actual payment?
177
-	if ( ! empty( $payment_id ) ) {
177
+	if ( ! empty($payment_id)) {
178 178
 
179
-		$content = give_get_email_body_content( $payment_id );
179
+		$content = give_get_email_body_content($payment_id);
180 180
 
181
-		$preview_content = give_do_email_tags( $content, $payment_id );
181
+		$preview_content = give_do_email_tags($content, $payment_id);
182 182
 
183 183
 	} else {
184 184
 
185 185
 		//No payment ID, use sample preview content
186
-		$preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
186
+		$preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array()));
187 187
 	}
188 188
 
189 189
 
190
-	echo Give()->emails->build_email( $preview_content );
190
+	echo Give()->emails->build_email($preview_content);
191 191
 
192 192
 	exit;
193 193
 
194 194
 }
195 195
 
196
-add_action( 'init', 'give_display_email_template_preview' );
196
+add_action('init', 'give_display_email_template_preview');
197 197
 
198 198
 /**
199 199
  * Email Template Body.
@@ -205,18 +205,18 @@  discard block
 block discarded – undo
205 205
  *
206 206
  * @return string $email_body Body of the email
207 207
  */
208
-function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) {
208
+function give_get_email_body_content($payment_id = 0, $payment_data = array()) {
209 209
 
210 210
 	$default_email_body = give_get_default_donation_receipt_email();
211 211
 
212
-	$email_content = give_get_option( 'donation_receipt' );
213
-	$email_content = ( $email_content ) ? stripslashes( $email_content ) : $default_email_body;
212
+	$email_content = give_get_option('donation_receipt');
213
+	$email_content = ($email_content) ? stripslashes($email_content) : $default_email_body;
214 214
 
215
-	$email_body = wpautop( $email_content );
215
+	$email_body = wpautop($email_content);
216 216
 
217
-	$email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data );
217
+	$email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data);
218 218
 
219
-	return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data );
219
+	return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data);
220 220
 }
221 221
 
222 222
 /**
@@ -229,35 +229,35 @@  discard block
 block discarded – undo
229 229
  *
230 230
  * @return string $email_body Body of the email
231 231
  */
232
-function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) {
232
+function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) {
233 233
 
234
-	$payment = new Give_Payment( $payment_id );
234
+	$payment = new Give_Payment($payment_id);
235 235
 
236
-	if ( $payment->user_id > 0 ) {
237
-		$user_data = get_userdata( $payment->user_id );
236
+	if ($payment->user_id > 0) {
237
+		$user_data = get_userdata($payment->user_id);
238 238
 		$name      = $user_data->display_name;
239
-	} elseif ( ! empty( $payment->first_name ) && ! empty( $payment->last_name ) ) {
240
-		$name = $payment->first_name . ' ' . $payment->last_name;
239
+	} elseif ( ! empty($payment->first_name) && ! empty($payment->last_name)) {
240
+		$name = $payment->first_name.' '.$payment->last_name;
241 241
 	} else {
242 242
 		$name = $payment->email;
243 243
 	}
244 244
 
245
-	$gateway = give_get_gateway_admin_label( $payment->gateway );
245
+	$gateway = give_get_gateway_admin_label($payment->gateway);
246 246
 
247
-	$default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n";
248
-	$default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n";
249
-	$default_email_body .= esc_html__( 'Donation:', 'give' ) . "\n\n";
250
-	$default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n";
251
-	$default_email_body .= esc_html__( 'Amount:', 'give' ) . ' ' . html_entity_decode( give_currency_filter( give_format_amount( $payment->total, array( 'sanitize' => false ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n";
252
-	$default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n";
253
-	$default_email_body .= esc_html__( 'Thank you', 'give' );
247
+	$default_email_body = esc_html__('Hello', 'give')."\n\n";
248
+	$default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n";
249
+	$default_email_body .= esc_html__('Donation:', 'give')."\n\n";
250
+	$default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n";
251
+	$default_email_body .= esc_html__('Amount:', 'give').' '.html_entity_decode(give_currency_filter(give_format_amount($payment->total, array('sanitize' => false))), ENT_COMPAT, 'UTF-8')."\n";
252
+	$default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n";
253
+	$default_email_body .= esc_html__('Thank you', 'give');
254 254
 
255
-	$message = give_get_option( 'donation_notification' );
256
-	$message = isset( $message ) ? stripslashes( $message ) : $default_email_body;
255
+	$message = give_get_option('donation_notification');
256
+	$message = isset($message) ? stripslashes($message) : $default_email_body;
257 257
 
258
-	$email_body = give_do_email_tags( $message, $payment_id );
258
+	$email_body = give_do_email_tags($message, $payment_id);
259 259
 
260
-	return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data );
260
+	return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data);
261 261
 }
262 262
 
263 263
 /**
@@ -270,19 +270,19 @@  discard block
 block discarded – undo
270 270
  * @since  1.0
271 271
  */
272 272
 function give_render_receipt_in_browser() {
273
-	if ( ! isset( $_GET['payment_key'] ) ) {
274
-		wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
273
+	if ( ! isset($_GET['payment_key'])) {
274
+		wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
275 275
 	}
276 276
 
277
-	$key = urlencode( $_GET['payment_key'] );
277
+	$key = urlencode($_GET['payment_key']);
278 278
 
279 279
 	ob_start();
280 280
 	//Disallows caching of the page
281
-	header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );
282
-	header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
283
-	header( "Cache-Control: post-check=0, pre-check=0", false );
284
-	header( "Pragma: no-cache" ); // HTTP/1.0
285
-	header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past
281
+	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
282
+	header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
283
+	header("Cache-Control: post-check=0, pre-check=0", false);
284
+	header("Pragma: no-cache"); // HTTP/1.0
285
+	header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past
286 286
 	?>
287 287
 	<!DOCTYPE html>
288 288
 	<html lang="en">
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 		 *
294 294
 		 * @since 1.0
295 295
 		 */
296
-		do_action( 'give_receipt_head' );
296
+		do_action('give_receipt_head');
297 297
 		?>
298 298
 	</head>
299
-	<body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>">
299
+	<body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>">
300 300
 
301 301
 	<div id="give_receipt_wrapper">
302 302
 		<?php
@@ -305,16 +305,16 @@  discard block
 block discarded – undo
305 305
 		 *
306 306
 		 * @since 1.0
307 307
 		 */
308
-		do_action( 'give_render_receipt_in_browser_before' );
308
+		do_action('give_render_receipt_in_browser_before');
309 309
 
310
-		echo do_shortcode( '[give_receipt payment_key=' . $key . ']' );
310
+		echo do_shortcode('[give_receipt payment_key='.$key.']');
311 311
 
312 312
 		/**
313 313
 		 * Fires in the receipt template after the content.
314 314
 		 *
315 315
 		 * @since 1.0
316 316
 		 */
317
-		do_action( 'give_render_receipt_in_browser_after' );
317
+		do_action('give_render_receipt_in_browser_after');
318 318
 		?>
319 319
 	</div>
320 320
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 *
325 325
 	 * @since 1.0
326 326
 	 */
327
-	do_action( 'give_receipt_footer' );
327
+	do_action('give_receipt_footer');
328 328
 	?>
329 329
 	</body>
330 330
 	</html>
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	die();
334 334
 }
335 335
 
336
-add_action( 'give_view_receipt', 'give_render_receipt_in_browser' );
336
+add_action('give_view_receipt', 'give_render_receipt_in_browser');
337 337
 
338 338
 
339 339
 /**
@@ -348,29 +348,29 @@  discard block
 block discarded – undo
348 348
 
349 349
 	//Payment receipt switcher
350 350
 	$payment_count = give_count_payments()->publish;
351
-	$payment_id    = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
351
+	$payment_id    = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
352 352
 
353
-	if ( $payment_count <= 0 ) {
353
+	if ($payment_count <= 0) {
354 354
 		return false;
355 355
 	}
356 356
 
357 357
 	//Get payments.
358
-	$payments = new Give_Payments_Query( array(
358
+	$payments = new Give_Payments_Query(array(
359 359
 		'number' => 100,
360
-	) );
360
+	));
361 361
 	$payments = $payments->get_payments();
362 362
 	$options  = array();
363 363
 
364 364
 	//Provide nice human readable options.
365
-	if ( $payments ) {
366
-		$options[0] = esc_html__( '- Select a donation -', 'give' );
367
-		foreach ( $payments as $payment ) {
365
+	if ($payments) {
366
+		$options[0] = esc_html__('- Select a donation -', 'give');
367
+		foreach ($payments as $payment) {
368 368
 
369
-			$options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title );
369
+			$options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title);
370 370
 
371 371
 		}
372 372
 	} else {
373
-		$options[0] = esc_html__( 'No donations found.', 'give' );
373
+		$options[0] = esc_html__('No donations found.', 'give');
374 374
 	}
375 375
 
376 376
 	//Start constructing HTML output.
@@ -383,16 +383,16 @@  discard block
 block discarded – undo
383 383
 			        var selected_trans = transactions.options[transactions.selectedIndex];
384 384
 				        console.log(selected_trans);
385 385
 				        if (selected_trans){
386
-				            var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value;
386
+				            var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value;
387 387
 				                window.location = url_string;
388 388
 				        }
389 389
 				    }
390 390
 			    </script>';
391 391
 
392
-	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>';
392
+	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a donation:', 'give').'</label>';
393 393
 
394 394
 	//The select field with 100 latest transactions
395
-	$transaction_header .= Give()->html->select( array(
395
+	$transaction_header .= Give()->html->select(array(
396 396
 		'name'             => 'preview_email_payment_id',
397 397
 		'selected'         => $payment_id,
398 398
 		'id'               => 'give_preview_email_payment_id',
@@ -402,12 +402,12 @@  discard block
 block discarded – undo
402 402
 		'select_atts'      => 'onchange="change_preview()">',
403 403
 		'show_option_all'  => false,
404 404
 		'show_option_none' => false,
405
-	) );
405
+	));
406 406
 
407 407
 	//Closing tag
408 408
 	$transaction_header .= '</div>';
409 409
 
410
-	return apply_filters( 'give_preview_email_receipt_header', $transaction_header );
410
+	return apply_filters('give_preview_email_receipt_header', $transaction_header);
411 411
 
412 412
 }
413 413
 
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 function give_receipt_head_content() {
422 422
 
423 423
 	//Title.
424
-	$output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>';
424
+	$output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>';
425 425
 
426 426
 	//Meta.
427 427
 	$output .= '<meta charset="utf-8"/>
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
 		<meta name="robots" content="noindex, nofollow"/>';
436 436
 
437 437
 	//CSS
438
-	$output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">';
438
+	$output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">';
439 439
 
440
-	echo apply_filters( 'give_receipt_head_content', $output );
440
+	echo apply_filters('give_receipt_head_content', $output);
441 441
 
442 442
 }
443 443
 
444
-add_action( 'give_receipt_head', 'give_receipt_head_content' );
445 444
\ No newline at end of file
445
+add_action('give_receipt_head', 'give_receipt_head_content');
446 446
\ No newline at end of file
Please login to merge, or discard this patch.
includes/emails/functions.php 1 patch
Spacing   +106 added lines, -106 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,11 +26,11 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return void
28 28
  */
29
-function give_email_donation_receipt( $payment_id, $admin_notice = true ) {
29
+function give_email_donation_receipt($payment_id, $admin_notice = true) {
30 30
 
31
-	$payment_data = give_get_payment_meta( $payment_id );
31
+	$payment_data = give_get_payment_meta($payment_id);
32 32
 
33
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
33
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
34 34
 
35 35
 	/**
36 36
 	 * Filters the from name.
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @since 1.0
42 42
 	 */
43
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
43
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
44 44
 
45
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
45
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
46 46
 
47 47
 	/**
48 48
 	 * Filters the from email.
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @since 1.0
54 54
 	 */
55
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
55
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
56 56
 
57
-	$to_email = give_get_payment_user_email( $payment_id );
57
+	$to_email = give_get_payment_user_email($payment_id);
58 58
 
59
-	$subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) );
59
+	$subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give'));
60 60
 
61 61
 	/**
62 62
 	 * Filters the donation email receipt subject.
63 63
 	 *
64 64
 	 * @since 1.0
65 65
 	 */
66
-	$subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), $payment_id );
67
-	$subject = give_do_email_tags( $subject, $payment_id );
66
+	$subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), $payment_id);
67
+	$subject = give_do_email_tags($subject, $payment_id);
68 68
 
69 69
 	/**
70 70
 	 * Filters the donation email receipt attachments. By default, there is no attachment but plugins can hook in to provide one more multiple for the donor. Examples would be a printable ticket or PDF receipt.
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @since 1.0
76 76
 	 */
77
-	$attachments = apply_filters( 'give_receipt_attachments', array(), $payment_id, $payment_data );
78
-	$message     = give_do_email_tags( give_get_email_body_content( $payment_id, $payment_data ), $payment_id );
77
+	$attachments = apply_filters('give_receipt_attachments', array(), $payment_id, $payment_data);
78
+	$message     = give_do_email_tags(give_get_email_body_content($payment_id, $payment_data), $payment_id);
79 79
 
80 80
 	$emails = Give()->emails;
81 81
 
82
-	$emails->__set( 'from_name', $from_name );
83
-	$emails->__set( 'from_email', $from_email );
84
-	$emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) );
82
+	$emails->__set('from_name', $from_name);
83
+	$emails->__set('from_email', $from_email);
84
+	$emails->__set('heading', esc_html__('Donation Receipt', 'give'));
85 85
 
86 86
 	/**
87 87
 	 * Filters the donation receipt's email headers.
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @since 1.0
93 93
 	 */
94
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data );
95
-	$emails->__set( 'headers', $headers );
94
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
95
+	$emails->__set('headers', $headers);
96 96
 
97 97
 	//Send the donation receipt.
98
-	$emails->send( $to_email, $subject, $message, $attachments );
98
+	$emails->send($to_email, $subject, $message, $attachments);
99 99
 
100 100
 	//If admin notifications are on, send the admin notice.
101
-	if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) {
101
+	if ($admin_notice && ! give_admin_notices_disabled($payment_id)) {
102 102
 		/**
103 103
 		 * Fires in the donation email receipt.
104 104
 		 *
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		 * @param int   $payment_id   Payment id.
110 110
 		 * @param mixed $payment_data Payment meta data.
111 111
 		 */
112
-		do_action( 'give_admin_donation_email', $payment_id, $payment_data );
112
+		do_action('give_admin_donation_email', $payment_id, $payment_data);
113 113
 	}
114 114
 }
115 115
 
@@ -122,41 +122,41 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function give_email_test_donation_receipt() {
124 124
 
125
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
125
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
126 126
 
127 127
 	/**
128 128
 	 * Filters the from name.
129 129
 	 *
130 130
 	 * @since 1.7
131 131
 	 */
132
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, 0, array() );
132
+	$from_name = apply_filters('give_donation_from_name', $from_name, 0, array());
133 133
 
134
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
134
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
135 135
 
136 136
 	/**
137 137
 	 * Filters the from email.
138 138
 	 *
139 139
 	 * @since 1.7
140 140
 	 */
141
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, 0, array() );
141
+	$from_email = apply_filters('give_donation_from_address', $from_email, 0, array());
142 142
 
143
-	$subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) );
144
-	$subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), 0 );
145
-	$subject = give_do_email_tags( $subject, 0 );
143
+	$subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give'));
144
+	$subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), 0);
145
+	$subject = give_do_email_tags($subject, 0);
146 146
 
147
-	$attachments = apply_filters( 'give_receipt_attachments', array(), 0, array() );
147
+	$attachments = apply_filters('give_receipt_attachments', array(), 0, array());
148 148
 
149
-	$message = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
149
+	$message = give_email_preview_template_tags(give_get_email_body_content(0, array()));
150 150
 
151 151
 	$emails = Give()->emails;
152
-	$emails->__set( 'from_name', $from_name );
153
-	$emails->__set( 'from_email', $from_email );
154
-	$emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) );
152
+	$emails->__set('from_name', $from_name);
153
+	$emails->__set('from_email', $from_email);
154
+	$emails->__set('heading', esc_html__('Donation Receipt', 'give'));
155 155
 
156
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), 0, array() );
157
-	$emails->__set( 'headers', $headers );
156
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), 0, array());
157
+	$emails->__set('headers', $headers);
158 158
 
159
-	$emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments );
159
+	$emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
160 160
 
161 161
 }
162 162
 
@@ -170,49 +170,49 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return void
172 172
  */
173
-function give_admin_email_notice( $payment_id = 0, $payment_data = array() ) {
173
+function give_admin_email_notice($payment_id = 0, $payment_data = array()) {
174 174
 
175
-	$payment_id = absint( $payment_id );
175
+	$payment_id = absint($payment_id);
176 176
 
177
-	if ( empty( $payment_id ) ) {
177
+	if (empty($payment_id)) {
178 178
 		return;
179 179
 	}
180 180
 
181
-	if ( ! give_get_payment_by( 'id', $payment_id ) ) {
181
+	if ( ! give_get_payment_by('id', $payment_id)) {
182 182
 		return;
183 183
 	}
184 184
 
185
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
185
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
186 186
 
187 187
 	/**
188 188
 	 * Filters the from name.
189 189
 	 *
190 190
 	 * @since 1.0
191 191
 	 */
192
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
192
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
193 193
 
194
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
194
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
195 195
 
196 196
 	/**
197 197
 	 * Filters the from email.
198 198
 	 *
199 199
 	 * @since 1.0
200 200
 	 */
201
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
201
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
202 202
 
203 203
 	/* translators: %s: payment id */
204
-	$subject = give_get_option( 'donation_notification_subject', sprintf( esc_html__( 'New Donation - Payment #%s', 'give' ), $payment_id ) );
204
+	$subject = give_get_option('donation_notification_subject', sprintf(esc_html__('New Donation - Payment #%s', 'give'), $payment_id));
205 205
 
206 206
 	/**
207 207
 	 * Filters the donation notification subject.
208 208
 	 *
209 209
 	 * @since 1.0
210 210
 	 */
211
-	$subject = apply_filters( 'give_admin_donation_notification_subject', wp_strip_all_tags( $subject ), $payment_id );
212
-	$subject = give_do_email_tags( $subject, $payment_id );
211
+	$subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id);
212
+	$subject = give_do_email_tags($subject, $payment_id);
213 213
 
214
-	$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
215
-	$headers .= "Reply-To: " . $from_email . "\r\n";
214
+	$headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n";
215
+	$headers .= "Reply-To: ".$from_email."\r\n";
216 216
 	//$headers  .= "MIME-Version: 1.0\r\n";
217 217
 	$headers .= "Content-Type: text/html; charset=utf-8\r\n";
218 218
 
@@ -221,28 +221,28 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @since 1.0
223 223
 	 */
224
-	$headers = apply_filters( 'give_admin_donation_notification_headers', $headers, $payment_id, $payment_data );
224
+	$headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data);
225 225
 
226 226
 	/**
227 227
 	 * Filters the donation notification email attachments. By default, there is no attachment but plugins can hook in to provide one more multiple.
228 228
 	 *
229 229
 	 * @since 1.0
230 230
 	 */
231
-	$attachments = apply_filters( 'give_admin_donation_notification_attachments', array(), $payment_id, $payment_data );
231
+	$attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data);
232 232
 
233
-	$message = give_get_donation_notification_body_content( $payment_id, $payment_data );
233
+	$message = give_get_donation_notification_body_content($payment_id, $payment_data);
234 234
 
235 235
 	$emails = Give()->emails;
236
-	$emails->__set( 'from_name', $from_name );
237
-	$emails->__set( 'from_email', $from_email );
238
-	$emails->__set( 'headers', $headers );
239
-	$emails->__set( 'heading', esc_html__( 'New Donation!', 'give' ) );
236
+	$emails->__set('from_name', $from_name);
237
+	$emails->__set('from_email', $from_email);
238
+	$emails->__set('headers', $headers);
239
+	$emails->__set('heading', esc_html__('New Donation!', 'give'));
240 240
 
241
-	$emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments );
241
+	$emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
242 242
 
243 243
 }
244 244
 
245
-add_action( 'give_admin_donation_email', 'give_admin_email_notice', 10, 2 );
245
+add_action('give_admin_donation_email', 'give_admin_email_notice', 10, 2);
246 246
 
247 247
 /**
248 248
  * Retrieves the emails for which admin notifications are sent to (these can be changed in the Give Settings).
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
  */
253 253
 function give_get_admin_notice_emails() {
254 254
 
255
-	$email_option = give_get_option( 'admin_notice_emails' );
255
+	$email_option = give_get_option('admin_notice_emails');
256 256
 
257
-	$emails = ! empty( $email_option ) && strlen( trim( $email_option ) ) > 0 ? $email_option : get_bloginfo( 'admin_email' );
258
-	$emails = array_map( 'trim', explode( "\n", $emails ) );
257
+	$emails = ! empty($email_option) && strlen(trim($email_option)) > 0 ? $email_option : get_bloginfo('admin_email');
258
+	$emails = array_map('trim', explode("\n", $emails));
259 259
 
260
-	return apply_filters( 'give_admin_notice_emails', $emails );
260
+	return apply_filters('give_admin_notice_emails', $emails);
261 261
 }
262 262
 
263 263
 /**
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return mixed
271 271
  */
272
-function give_admin_notices_disabled( $payment_id = 0 ) {
272
+function give_admin_notices_disabled($payment_id = 0) {
273 273
 
274 274
 	return apply_filters(
275 275
 		'give_admin_notices_disabled',
276
-		! give_is_setting_enabled( give_get_option( 'admin_notices' ) ),
276
+		! give_is_setting_enabled(give_get_option('admin_notices')),
277 277
 		$payment_id
278 278
 	);
279 279
 }
@@ -288,19 +288,19 @@  discard block
 block discarded – undo
288 288
  */
289 289
 function give_get_default_donation_notification_email() {
290 290
 
291
-	$default_email_body = esc_html__( 'Hi there,', 'give' ) . "\n\n";
292
-	$default_email_body .= esc_html__( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n";
293
-	$default_email_body .= '<strong>' . esc_html__( 'Donor:', 'give' ) . '</strong> {name}' . "\n";
294
-	$default_email_body .= '<strong>' . esc_html__( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
295
-	$default_email_body .= '<strong>' . esc_html__( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
296
-	$default_email_body .= '<strong>' . esc_html__( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n";
297
-	$default_email_body .= esc_html__( 'Thank you,', 'give' ) . "\n\n";
298
-	$default_email_body .= '{sitename}' . "\n";
291
+	$default_email_body = esc_html__('Hi there,', 'give')."\n\n";
292
+	$default_email_body .= esc_html__('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n";
293
+	$default_email_body .= '<strong>'.esc_html__('Donor:', 'give').'</strong> {name}'."\n";
294
+	$default_email_body .= '<strong>'.esc_html__('Donation:', 'give').'</strong> {donation}'."\n";
295
+	$default_email_body .= '<strong>'.esc_html__('Amount:', 'give').'</strong> {amount}'."\n";
296
+	$default_email_body .= '<strong>'.esc_html__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n";
297
+	$default_email_body .= esc_html__('Thank you,', 'give')."\n\n";
298
+	$default_email_body .= '{sitename}'."\n";
299 299
 
300
-	$custom_message = give_get_option( 'donation_notification' );
301
-	$message        = ! empty( $custom_message ) ? $custom_message : $default_email_body;
300
+	$custom_message = give_get_option('donation_notification');
301
+	$message        = ! empty($custom_message) ? $custom_message : $default_email_body;
302 302
 
303
-	return apply_filters( 'give_default_donation_notification_email', $message );
303
+	return apply_filters('give_default_donation_notification_email', $message);
304 304
 }
305 305
 
306 306
 
@@ -314,25 +314,25 @@  discard block
 block discarded – undo
314 314
  */
315 315
 function give_get_default_donation_receipt_email() {
316 316
 
317
-	$default_email_body = esc_html__( 'Dear', 'give' ) . " {name},\n\n";
318
-	$default_email_body .= esc_html__( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n";
319
-	$default_email_body .= '<strong>' . esc_html__( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
320
-	$default_email_body .= '<strong>' . esc_html__( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
321
-	$default_email_body .= '<strong>' . esc_html__( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n";
322
-	$default_email_body .= '<strong>' . esc_html__( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
323
-	$default_email_body .= '<strong>' . esc_html__( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n";
324
-	$default_email_body .= '<strong>' . esc_html__( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n";
325
-	$default_email_body .= '<strong>' . esc_html__( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n";
326
-	$default_email_body .= '{receipt_link}' . "\n\n";
317
+	$default_email_body = esc_html__('Dear', 'give')." {name},\n\n";
318
+	$default_email_body .= esc_html__('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n";
319
+	$default_email_body .= '<strong>'.esc_html__('Donor:', 'give').'</strong> {fullname}'."\n";
320
+	$default_email_body .= '<strong>'.esc_html__('Donation:', 'give').'</strong> {donation}'."\n";
321
+	$default_email_body .= '<strong>'.esc_html__('Donation Date:', 'give').'</strong> {date}'."\n";
322
+	$default_email_body .= '<strong>'.esc_html__('Amount:', 'give').'</strong> {amount}'."\n";
323
+	$default_email_body .= '<strong>'.esc_html__('Payment Method:', 'give').'</strong> {payment_method}'."\n";
324
+	$default_email_body .= '<strong>'.esc_html__('Payment ID:', 'give').'</strong> {payment_id}'."\n";
325
+	$default_email_body .= '<strong>'.esc_html__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n";
326
+	$default_email_body .= '{receipt_link}'."\n\n";
327 327
 	$default_email_body .= "\n\n";
328
-	$default_email_body .= esc_html__( 'Sincerely,', 'give' ) . "\n";
329
-	$default_email_body .= '{sitename}' . "\n";
328
+	$default_email_body .= esc_html__('Sincerely,', 'give')."\n";
329
+	$default_email_body .= '{sitename}'."\n";
330 330
 
331
-	$custom_message = give_get_option( 'donation_receipt' );
331
+	$custom_message = give_get_option('donation_receipt');
332 332
 
333
-	$message = ! empty( $custom_message ) ? $custom_message : $default_email_body;
333
+	$message = ! empty($custom_message) ? $custom_message : $default_email_body;
334 334
 
335
-	return apply_filters( 'give_default_donation_receipt_email', $message );
335
+	return apply_filters('give_default_donation_receipt_email', $message);
336 336
 }
337 337
 
338 338
 /**
@@ -345,22 +345,22 @@  discard block
 block discarded – undo
345 345
  *
346 346
  * @return array $email_names
347 347
  */
348
-function give_get_email_names( $user_info, $payment = false ) {
348
+function give_get_email_names($user_info, $payment = false) {
349 349
 	$email_names = array();
350 350
 
351
-	if ( is_a( $payment, 'Give_Payment' ) ) {
351
+	if (is_a($payment, 'Give_Payment')) {
352 352
 
353
-		if ( $payment->user_id > 0 ) {
353
+		if ($payment->user_id > 0) {
354 354
 
355
-			$user_data               = get_userdata( $payment->user_id );
355
+			$user_data               = get_userdata($payment->user_id);
356 356
 			$email_names['name']     = $payment->first_name;
357
-			$email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
357
+			$email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name);
358 358
 			$email_names['username'] = $user_data->user_login;
359 359
 
360
-		} elseif ( ! empty( $payment->first_name ) ) {
360
+		} elseif ( ! empty($payment->first_name)) {
361 361
 
362 362
 			$email_names['name']     = $payment->first_name;
363
-			$email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
363
+			$email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name);
364 364
 			$email_names['username'] = $payment->first_name;
365 365
 
366 366
 		} else {
@@ -373,30 +373,30 @@  discard block
 block discarded – undo
373 373
 	} else {
374 374
 
375 375
 		// Support for old serialized data
376
-		if ( is_serialized( $user_info ) ) {
376
+		if (is_serialized($user_info)) {
377 377
 
378 378
 			// Security check.
379
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
380
-			if ( ! empty( $matches ) ) {
379
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches);
380
+			if ( ! empty($matches)) {
381 381
 				return array(
382 382
 					'name'     => '',
383 383
 					'fullname' => '',
384 384
 					'username' => '',
385 385
 				);
386 386
 			} else {
387
-				$user_info = maybe_unserialize( $user_info );
387
+				$user_info = maybe_unserialize($user_info);
388 388
 			}
389 389
 
390 390
 		}
391 391
 
392
-		if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) {
393
-			$user_data               = get_userdata( $user_info['id'] );
392
+		if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) {
393
+			$user_data               = get_userdata($user_info['id']);
394 394
 			$email_names['name']     = $user_info['first_name'];
395
-			$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
395
+			$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
396 396
 			$email_names['username'] = $user_data->user_login;
397
-		} elseif ( isset( $user_info['first_name'] ) ) {
397
+		} elseif (isset($user_info['first_name'])) {
398 398
 			$email_names['name']     = $user_info['first_name'];
399
-			$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
399
+			$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
400 400
 			$email_names['username'] = $user_info['first_name'];
401 401
 		} else {
402 402
 			$email_names['name']     = $user_info['email'];
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -10,61 +10,61 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
13
+if ( ! defined('WP_UNINSTALL_PLUGIN')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load Give file.
18
-include_once( 'give.php' );
18
+include_once('give.php');
19 19
 
20 20
 global $wpdb, $wp_roles;
21 21
 
22 22
 
23
-if ( give_is_setting_enabled( give_get_option( 'uninstall_on_delete' ) ) ) {
23
+if (give_is_setting_enabled(give_get_option('uninstall_on_delete'))) {
24 24
 
25 25
 	// Delete All the Custom Post Types.
26
-	$give_taxonomies = array( 'form_category', 'form_tag', 'give_log_type' );
27
-	$give_post_types = array( 'give_forms', 'give_payment', 'give_log' );
28
-	foreach ( $give_post_types as $post_type ) {
26
+	$give_taxonomies = array('form_category', 'form_tag', 'give_log_type');
27
+	$give_post_types = array('give_forms', 'give_payment', 'give_log');
28
+	foreach ($give_post_types as $post_type) {
29 29
 
30
-		$give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) );
31
-		$items           = get_posts( array(
30
+		$give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type));
31
+		$items           = get_posts(array(
32 32
 			'post_type'   => $post_type,
33 33
 			'post_status' => 'any',
34
-			'numberposts' => - 1,
34
+			'numberposts' => -1,
35 35
 			'fields'      => 'ids',
36
-		) );
36
+		));
37 37
 
38
-		if ( $items ) {
39
-			foreach ( $items as $item ) {
40
-				wp_delete_post( $item, true );
38
+		if ($items) {
39
+			foreach ($items as $item) {
40
+				wp_delete_post($item, true);
41 41
 			}
42 42
 		}
43 43
 	}
44 44
 
45 45
 	// Delete All the Terms & Taxonomies.
46
-	foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) {
46
+	foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) {
47 47
 
48
-		$terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) );
48
+		$terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy));
49 49
 
50 50
 		// Delete Terms.
51
-		if ( $terms ) {
52
-			foreach ( $terms as $term ) {
53
-				$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) );
54
-				$wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) );
51
+		if ($terms) {
52
+			foreach ($terms as $term) {
53
+				$wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id));
54
+				$wpdb->delete($wpdb->terms, array('term_id' => $term->term_id));
55 55
 			}
56 56
 		}
57 57
 
58 58
 		// Delete Taxonomies.
59
-		$wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) );
59
+		$wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s'));
60 60
 	}
61 61
 
62 62
 	// Delete the Plugin Pages.
63
-	$give_created_pages = array( 'success_page', 'failure_page', 'history_page' );
64
-	foreach ( $give_created_pages as $p ) {
65
-		$page = give_get_option( $p, false );
66
-		if ( $page ) {
67
-			wp_delete_post( $page, true );
63
+	$give_created_pages = array('success_page', 'failure_page', 'history_page');
64
+	foreach ($give_created_pages as $p) {
65
+		$page = give_get_option($p, false);
66
+		if ($page) {
67
+			wp_delete_post($page, true);
68 68
 		}
69 69
 	}
70 70
 
@@ -73,21 +73,21 @@  discard block
 block discarded – undo
73 73
 	Give()->roles->remove_caps();
74 74
 
75 75
 	// Delete the Roles.
76
-	$give_roles = array( 'give_manager', 'give_accountant', 'give_worker', 'give_donor' );
77
-	foreach ( $give_roles as $role ) {
78
-		remove_role( $role );
76
+	$give_roles = array('give_manager', 'give_accountant', 'give_worker', 'give_donor');
77
+	foreach ($give_roles as $role) {
78
+		remove_role($role);
79 79
 	}
80 80
 
81 81
 	// Remove all database tables.
82
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donors' );
83
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customers' );
84
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customermeta' );
82
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donors');
83
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customers');
84
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customermeta');
85 85
 
86 86
 	// Cleanup Cron Events.
87
-	wp_clear_scheduled_hook( 'give_daily_scheduled_events' );
88
-	wp_clear_scheduled_hook( 'give_weekly_scheduled_events' );
89
-	wp_clear_scheduled_hook( 'give_daily_cron' );
90
-	wp_clear_scheduled_hook( 'give_weekly_cron' );
87
+	wp_clear_scheduled_hook('give_daily_scheduled_events');
88
+	wp_clear_scheduled_hook('give_weekly_scheduled_events');
89
+	wp_clear_scheduled_hook('give_daily_cron');
90
+	wp_clear_scheduled_hook('give_weekly_cron');
91 91
 
92 92
 	// Get all options.
93 93
 	$give_option_names = $wpdb->get_col(
@@ -97,16 +97,16 @@  discard block
 block discarded – undo
97 97
 		)
98 98
 	);
99 99
 
100
-	if ( ! empty( $give_option_names ) ) {
100
+	if ( ! empty($give_option_names)) {
101 101
 		// Convert option name to transient or option name.
102 102
 		$new_give_option_names = array();
103 103
 
104 104
 		// Delete all the Plugin Options.
105
-		foreach ( $give_option_names as $option ) {
106
-			if ( false !== strpos( $option, 'give_cache' ) ) {
107
-				Give_Cache::delete( $option );
105
+		foreach ($give_option_names as $option) {
106
+			if (false !== strpos($option, 'give_cache')) {
107
+				Give_Cache::delete($option);
108 108
 			} else {
109
-				delete_option( $option );
109
+				delete_option($option);
110 110
 			}
111 111
 		}
112 112
 	}
Please login to merge, or discard this patch.