Test Failed
Push — master ( f098b0...602e9b )
by Devin
10:54 queued 05:19
created
includes/admin/tools/data/class-give-tools-recount-all-stats.php 1 patch
Spacing   +97 added lines, -99 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	/**
74 74
 	 * Constructor.
75 75
 	 */
76
-	public function __construct( $_step = 1 ) {
77
-		parent::__construct( $_step );
76
+	public function __construct($_step = 1) {
77
+		parent::__construct($_step);
78 78
 
79 79
 		$this->is_writable = true;
80 80
 	}
@@ -89,108 +89,106 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function get_data() {
91 91
 
92
-		$totals             = $this->get_stored_data( 'give_temp_recount_all_stats' );
93
-		$payment_items      = $this->get_stored_data( 'give_temp_payment_items' );
94
-		$processed_payments = $this->get_stored_data( 'give_temp_processed_payments' );
95
-		$accepted_statuses  = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
92
+		$totals             = $this->get_stored_data('give_temp_recount_all_stats');
93
+		$payment_items      = $this->get_stored_data('give_temp_payment_items');
94
+		$processed_payments = $this->get_stored_data('give_temp_processed_payments');
95
+		$accepted_statuses  = apply_filters('give_recount_accepted_statuses', array('publish'));
96 96
 
97
-		if ( false === $totals ) {
97
+		if (false === $totals) {
98 98
 			$totals = array();
99 99
 		}
100 100
 
101
-		if ( false === $payment_items ) {
101
+		if (false === $payment_items) {
102 102
 			$payment_items = array();
103 103
 		}
104 104
 
105
-		if ( false === $processed_payments ) {
105
+		if (false === $processed_payments) {
106 106
 			$processed_payments = array();
107 107
 		}
108 108
 
109
-		$all_forms = $this->get_stored_data( 'give_temp_form_ids' );
109
+		$all_forms = $this->get_stored_data('give_temp_form_ids');
110 110
 
111
-		$payments = $this->get_stored_data( 'give_temp_all_payments_data' );
111
+		$payments = $this->get_stored_data('give_temp_all_payments_data');
112 112
 
113
-		if ( empty( $payments ) ) {
114
-			$args = apply_filters( 'give_recount_form_stats_args', array(
113
+		if (empty($payments)) {
114
+			$args = apply_filters('give_recount_form_stats_args', array(
115 115
 				'give_forms' => $all_forms,
116 116
 				'number'     => $this->per_step,
117 117
 				'status'     => $accepted_statuses,
118 118
 				'paged'      => $this->step,
119 119
 				'output'     => 'give_payments',
120
-			) );
120
+			));
121 121
 
122
-			$payments_query = new Give_Payments_Query( $args );
122
+			$payments_query = new Give_Payments_Query($args);
123 123
 			$payments       = $payments_query->get_payments();
124 124
 		}
125 125
 
126
-		if ( ! empty( $payments ) ) {
126
+		if ( ! empty($payments)) {
127 127
 
128 128
 			//Loop through payments
129
-			foreach ( $payments as $payment ) {
129
+			foreach ($payments as $payment) {
130 130
 
131
-				$payment_id = ( ! empty( $payment['ID'] ) ? absint( $payment['ID'] ) : ( ! empty( $payment->ID ) ? absint( $payment->ID ) : false ) );
132
-				$payment = new Give_Payment( $payment_id );
131
+				$payment_id = ( ! empty($payment['ID']) ? absint($payment['ID']) : ( ! empty($payment->ID) ? absint($payment->ID) : false));
132
+				$payment = new Give_Payment($payment_id);
133 133
 
134 134
 				// Prevent payments that have all ready been retrieved from a previous sales log from counting again.
135
-				if ( in_array( $payment->ID, $processed_payments ) ) {
135
+				if (in_array($payment->ID, $processed_payments)) {
136 136
 					continue;
137 137
 				}
138 138
 
139 139
 				// Verify accepted status.
140
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
140
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
141 141
 					$processed_payments[] = $payment->ID;
142 142
 					continue;
143 143
 				}
144 144
 
145
-				$payment_item = $payment_items[ $payment->ID ];
145
+				$payment_item = $payment_items[$payment->ID];
146 146
 
147
-				$form_id = isset( $payment_item['id'] ) ? $payment_item['id'] : '';
147
+				$form_id = isset($payment_item['id']) ? $payment_item['id'] : '';
148 148
 
149 149
 				// Must have a form ID.
150
-				if ( empty( $form_id ) ) {
150
+				if (empty($form_id)) {
151 151
 					continue;
152 152
 				}
153 153
 
154 154
 				// Form ID must be within $all_forms array to be validated.
155
-				if ( ! in_array( $form_id, $all_forms ) ) {
155
+				if ( ! in_array($form_id, $all_forms)) {
156 156
 					continue;
157 157
 				}
158 158
 
159 159
 				// Set Sales count
160
-				$totals[ $form_id ]['sales'] = isset( $totals[ $form_id ]['sales'] ) ?
161
-					++ $totals[ $form_id ]['sales'] :
162
-					1;
160
+				$totals[$form_id]['sales'] = isset($totals[$form_id]['sales']) ?
161
+					++$totals[$form_id]['sales'] : 1;
163 162
 
164 163
 				// Set Total Earnings
165
-				$totals[ $form_id ]['earnings'] = isset( $totals[ $form_id ]['earnings'] ) ?
166
-					( $totals[ $form_id ]['earnings'] + $payment_item['price'] ) :
167
-					$payment_item['price'];
164
+				$totals[$form_id]['earnings'] = isset($totals[$form_id]['earnings']) ?
165
+					($totals[$form_id]['earnings'] + $payment_item['price']) : $payment_item['price'];
168 166
 
169 167
 				$processed_payments[] = $payment->ID;
170 168
 			}
171 169
 
172 170
 			// Get the list of form ids which does not contain any payment record.
173
-			$remaining_form_ids = array_diff( $all_forms, array_keys( $totals ) );
174
-			foreach ( $remaining_form_ids as $form_id ) {
171
+			$remaining_form_ids = array_diff($all_forms, array_keys($totals));
172
+			foreach ($remaining_form_ids as $form_id) {
175 173
 				//If array key doesn't exist, create it
176
-				if ( ! array_key_exists( $form_id, $totals ) ) {
177
-					$totals[ $form_id ] = array(
174
+				if ( ! array_key_exists($form_id, $totals)) {
175
+					$totals[$form_id] = array(
178 176
 						'sales'    => (int) 0,
179 177
 						'earnings' => (float) 0,
180 178
 					);
181 179
 				}
182 180
 			}
183 181
 
184
-			$this->store_data( 'give_temp_processed_payments', $processed_payments );
185
-			$this->store_data( 'give_temp_recount_all_stats', $totals );
182
+			$this->store_data('give_temp_processed_payments', $processed_payments);
183
+			$this->store_data('give_temp_recount_all_stats', $totals);
186 184
 
187 185
 			return true;
188 186
 		}
189 187
 
190 188
 
191
-		foreach ( $totals as $key => $stats ) {
192
-			give_update_meta( $key, '_give_form_sales', $stats['sales'] );
193
-			give_update_meta( $key, '_give_form_earnings', give_sanitize_amount_for_db( $stats['earnings'] ) );
189
+		foreach ($totals as $key => $stats) {
190
+			give_update_meta($key, '_give_form_sales', $stats['sales']);
191
+			give_update_meta($key, '_give_form_earnings', give_sanitize_amount_for_db($stats['earnings']));
194 192
 		}
195 193
 
196 194
 		return false;
@@ -205,20 +203,20 @@  discard block
 block discarded – undo
205 203
 	 */
206 204
 	public function get_percentage_complete() {
207 205
 
208
-		$total = $this->get_stored_data( 'give_recount_all_total' );
206
+		$total = $this->get_stored_data('give_recount_all_total');
209 207
 
210
-		if ( false === $total ) {
208
+		if (false === $total) {
211 209
 			$this->pre_fetch();
212
-			$total = $this->get_stored_data( 'give_recount_all_total' );
210
+			$total = $this->get_stored_data('give_recount_all_total');
213 211
 		}
214 212
 
215 213
 		$percentage = 100;
216 214
 
217
-		if ( $total > 0 ) {
218
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
215
+		if ($total > 0) {
216
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
219 217
 		}
220 218
 
221
-		if ( $percentage > 100 ) {
219
+		if ($percentage > 100) {
222 220
 			$percentage = 100;
223 221
 		}
224 222
 
@@ -232,8 +230,8 @@  discard block
 block discarded – undo
232 230
 	 *
233 231
 	 * @param array $request The Form Data passed into the batch processing
234 232
 	 */
235
-	public function set_properties( $request ) {
236
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
233
+	public function set_properties($request) {
234
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
237 235
 	}
238 236
 
239 237
 	/**
@@ -244,25 +242,25 @@  discard block
 block discarded – undo
244 242
 	 */
245 243
 	public function process_step() {
246 244
 
247
-		if ( ! $this->can_export() ) {
248
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
245
+		if ( ! $this->can_export()) {
246
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
249 247
 		}
250 248
 
251 249
 		$had_data = $this->get_data();
252 250
 
253
-		if ( $had_data ) {
251
+		if ($had_data) {
254 252
 			$this->done = false;
255 253
 
256 254
 			return true;
257 255
 		} else {
258
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
259
-			$this->delete_data( 'give_recount_all_total' );
260
-			$this->delete_data( 'give_temp_recount_all_stats' );
261
-			$this->delete_data( 'give_temp_payment_items' );
262
-			$this->delete_data( 'give_temp_form_ids' );
263
-			$this->delete_data( 'give_temp_processed_payments' );
256
+			$this->delete_data('give_recount_total_'.$this->form_id);
257
+			$this->delete_data('give_recount_all_total');
258
+			$this->delete_data('give_temp_recount_all_stats');
259
+			$this->delete_data('give_temp_payment_items');
260
+			$this->delete_data('give_temp_form_ids');
261
+			$this->delete_data('give_temp_processed_payments');
264 262
 			$this->done    = true;
265
-			$this->message = esc_html__( 'Donation form income amounts and donation counts stats successfully recounted.', 'give' );
263
+			$this->message = esc_html__('Donation form income amounts and donation counts stats successfully recounted.', 'give');
266 264
 
267 265
 			return false;
268 266
 		}
@@ -298,70 +296,70 @@  discard block
 block discarded – undo
298 296
 	 */
299 297
 	public function pre_fetch() {
300 298
 
301
-		if ( 1 == $this->step ) {
302
-			$this->delete_data( 'give_temp_recount_all_total' );
303
-			$this->delete_data( 'give_temp_recount_all_stats' );
304
-			$this->delete_data( 'give_temp_payment_items' );
305
-			$this->delete_data( 'give_temp_processed_payments' );
306
-			$this->delete_data( 'give_temp_all_payments_data' );
299
+		if (1 == $this->step) {
300
+			$this->delete_data('give_temp_recount_all_total');
301
+			$this->delete_data('give_temp_recount_all_stats');
302
+			$this->delete_data('give_temp_payment_items');
303
+			$this->delete_data('give_temp_processed_payments');
304
+			$this->delete_data('give_temp_all_payments_data');
307 305
 		}
308 306
 
309
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
310
-		$total             = $this->get_stored_data( 'give_temp_recount_all_total' );
307
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
308
+		$total             = $this->get_stored_data('give_temp_recount_all_total');
311 309
 
312
-		if ( false === $total ) {
310
+		if (false === $total) {
313 311
 
314
-			$payment_items = $this->get_stored_data( 'give_temp_payment_items' );
312
+			$payment_items = $this->get_stored_data('give_temp_payment_items');
315 313
 
316
-			if ( false === $payment_items ) {
314
+			if (false === $payment_items) {
317 315
 				$payment_items = array();
318
-				$this->store_data( 'give_temp_payment_items', $payment_items );
316
+				$this->store_data('give_temp_payment_items', $payment_items);
319 317
 			}
320 318
 
321 319
 			$args = array(
322 320
 				'post_status'    => 'publish',
323 321
 				'post_type'      => 'give_forms',
324
-				'posts_per_page' => - 1,
322
+				'posts_per_page' => -1,
325 323
 				'fields'         => 'ids',
326 324
 			);
327 325
 
328
-			$all_forms = get_posts( $args );
326
+			$all_forms = get_posts($args);
329 327
 
330
-			$this->store_data( 'give_temp_form_ids', $all_forms );
328
+			$this->store_data('give_temp_form_ids', $all_forms);
331 329
 
332
-			$args = apply_filters( 'give_recount_form_stats_total_args', array(
330
+			$args = apply_filters('give_recount_form_stats_total_args', array(
333 331
 				'give_forms' => $all_forms,
334 332
 				'number'     => $this->per_step,
335 333
 				'status'     => $accepted_statuses,
336 334
 				'page'       => $this->step,
337 335
 				'output'     => 'payments',
338
-			) );
336
+			));
339 337
 
340
-			$payments_query = new Give_Payments_Query( $args );
338
+			$payments_query = new Give_Payments_Query($args);
341 339
 			$payments       = $payments_query->get_payments();
342 340
 
343
-			$total = wp_count_posts( 'give_payment' )->publish;
341
+			$total = wp_count_posts('give_payment')->publish;
344 342
 
345
-			$this->store_data( 'give_temp_all_payments_data', $payments );
343
+			$this->store_data('give_temp_all_payments_data', $payments);
346 344
 
347
-			if ( $payments ) {
345
+			if ($payments) {
348 346
 
349
-				foreach ( $payments as $payment ) {
347
+				foreach ($payments as $payment) {
350 348
 
351 349
 					$form_id = $payment->form_id;
352 350
 
353 351
 					//If for some reason somehow the form_ID isn't set check payment meta
354
-					if ( empty( $payment->form_id ) ) {
352
+					if (empty($payment->form_id)) {
355 353
 						$payment_meta = $payment->get_meta();
356
-						$form_id      = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
354
+						$form_id      = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
357 355
 					}
358 356
 
359
-					if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
357
+					if ( ! in_array($payment->post_status, $accepted_statuses)) {
360 358
 						continue;
361 359
 					}
362 360
 
363
-					if ( ! array_key_exists( $payment->ID, $payment_items ) ) {
364
-						$payment_items[ $payment->ID ] = array(
361
+					if ( ! array_key_exists($payment->ID, $payment_items)) {
362
+						$payment_items[$payment->ID] = array(
365 363
 							'id'         => $form_id,
366 364
 							'payment_id' => $payment->ID,
367 365
 							'price'      => $payment->total,
@@ -369,8 +367,8 @@  discard block
 block discarded – undo
369 367
 					}
370 368
 				}
371 369
 			}
372
-			$this->store_data( 'give_temp_payment_items', $payment_items );
373
-			$this->store_data( 'give_recount_all_total', $total );
370
+			$this->store_data('give_temp_payment_items', $payment_items);
371
+			$this->store_data('give_recount_all_total', $total);
374 372
 		}
375 373
 
376 374
 	}
@@ -384,17 +382,17 @@  discard block
 block discarded – undo
384 382
 	 *
385 383
 	 * @return mixed       Returns the data from the database
386 384
 	 */
387
-	private function get_stored_data( $key ) {
385
+	private function get_stored_data($key) {
388 386
 		global $wpdb;
389
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
390
-		if ( empty( $value ) ) {
387
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
388
+		if (empty($value)) {
391 389
 			return false;
392 390
 		}
393 391
 
394
-		$maybe_json = json_decode( $value );
392
+		$maybe_json = json_decode($value);
395 393
 
396
-		if ( ! is_null( $maybe_json ) ) {
397
-			$value = json_decode( $value, true );
394
+		if ( ! is_null($maybe_json)) {
395
+			$value = json_decode($value, true);
398 396
 		}
399 397
 
400 398
 		return $value;
@@ -410,10 +408,10 @@  discard block
 block discarded – undo
410 408
 	 *
411 409
 	 * @return void
412 410
 	 */
413
-	private function store_data( $key, $value ) {
411
+	private function store_data($key, $value) {
414 412
 		global $wpdb;
415 413
 
416
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
414
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
417 415
 
418 416
 		$data = array(
419 417
 			'option_name'  => $key,
@@ -427,7 +425,7 @@  discard block
 block discarded – undo
427 425
 			'%s',
428 426
 		);
429 427
 
430
-		$wpdb->replace( $wpdb->options, $data, $formats );
428
+		$wpdb->replace($wpdb->options, $data, $formats);
431 429
 	}
432 430
 
433 431
 	/**
@@ -439,9 +437,9 @@  discard block
 block discarded – undo
439 437
 	 *
440 438
 	 * @return void
441 439
 	 */
442
-	private function delete_data( $key ) {
440
+	private function delete_data($key) {
443 441
 		global $wpdb;
444
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
442
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
445 443
 	}
446 444
 
447 445
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-recount-single-donor-stats.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Constructor.
48 48
 	 */
49
-	public function __construct( $_step = 1 ) {
50
-		parent::__construct( $_step );
49
+	public function __construct($_step = 1) {
50
+		parent::__construct($_step);
51 51
 
52 52
 		$this->is_writable = true;
53 53
 	}
@@ -62,40 +62,40 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function get_data() {
64 64
 
65
-		$donor    = new Give_Donor( $this->customer_id );
66
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $donor->id );
65
+		$donor    = new Give_Donor($this->customer_id);
66
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$donor->id);
67 67
 
68
-		$offset     = ( $this->step - 1 ) * $this->per_step;
69
-		$step_items = array_slice( $payments, $offset, $this->per_step );
68
+		$offset     = ($this->step - 1) * $this->per_step;
69
+		$step_items = array_slice($payments, $offset, $this->per_step);
70 70
 
71
-		if ( count( $step_items ) > 0 ) {
72
-			$pending_total = (float) $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
71
+		if (count($step_items) > 0) {
72
+			$pending_total = (float) $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
73 73
 			$step_total    = 0;
74 74
 
75
-			$found_payment_ids = $this->get_stored_data( 'give_stats_found_payments_' . $donor->id );
75
+			$found_payment_ids = $this->get_stored_data('give_stats_found_payments_'.$donor->id);
76 76
 
77
-			foreach ( $step_items as $payment ) {
78
-				$payment = get_post( $payment->ID );
77
+			foreach ($step_items as $payment) {
78
+				$payment = get_post($payment->ID);
79 79
 
80
-				if ( is_null( $payment ) || is_wp_error( $payment ) || 'give_payment' !== $payment->post_type ) {
80
+				if (is_null($payment) || is_wp_error($payment) || 'give_payment' !== $payment->post_type) {
81 81
 
82
-					$missing_payments   = $this->get_stored_data( 'give_stats_missing_payments' . $donor->id );
82
+					$missing_payments   = $this->get_stored_data('give_stats_missing_payments'.$donor->id);
83 83
 					$missing_payments[] = $payment->ID;
84
-					$this->store_data( 'give_stats_missing_payments' . $donor->id, $missing_payments );
84
+					$this->store_data('give_stats_missing_payments'.$donor->id, $missing_payments);
85 85
 
86 86
 					continue;
87 87
 				}
88 88
 
89 89
 				$should_process_payment = 'publish' == $payment->post_status ? true : false;
90
-				$should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment );
90
+				$should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment);
91 91
 
92
-				if ( true === $should_process_payment ) {
92
+				if (true === $should_process_payment) {
93 93
 
94 94
 					$found_payment_ids[] = $payment->ID;
95 95
 
96
-					if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) {
97
-						$payment_amount = (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) );
98
-						$step_total     += $payment_amount;
96
+					if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) {
97
+						$payment_amount = (float) give_donation_amount($payment->ID, array('type' => 'stats'));
98
+						$step_total += $payment_amount;
99 99
 					}
100 100
 
101 101
 				}
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 			}
104 104
 
105 105
 			$updated_total = $pending_total + $step_total;
106
-			$this->store_data( 'give_stats_donor_pending_total' . $donor->id, $updated_total );
107
-			$this->store_data( 'give_stats_found_payments_' . $donor->id, $found_payment_ids );
106
+			$this->store_data('give_stats_donor_pending_total'.$donor->id, $updated_total);
107
+			$this->store_data('give_stats_found_payments_'.$donor->id, $found_payment_ids);
108 108
 
109 109
 			return true;
110 110
 		}
@@ -121,16 +121,16 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function get_percentage_complete() {
123 123
 
124
-		$payments = $this->get_stored_data( 'give_recount_donor_payments_' . $this->customer_id );
125
-		$total    = count( $payments );
124
+		$payments = $this->get_stored_data('give_recount_donor_payments_'.$this->customer_id);
125
+		$total    = count($payments);
126 126
 
127 127
 		$percentage = 100;
128 128
 
129
-		if ( $total > 0 ) {
130
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
129
+		if ($total > 0) {
130
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
131 131
 		}
132 132
 
133
-		if ( $percentage > 100 ) {
133
+		if ($percentage > 100) {
134 134
 			$percentage = 100;
135 135
 		}
136 136
 
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 	 *
145 145
 	 * @param array $request The Form Data passed into the batch processing
146 146
 	 */
147
-	public function set_properties( $request ) {
148
-		$this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false;
147
+	public function set_properties($request) {
148
+		$this->customer_id = isset($request['customer_id']) ? sanitize_text_field($request['customer_id']) : false;
149 149
 	}
150 150
 
151 151
 	/**
@@ -156,53 +156,53 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function process_step() {
158 158
 
159
-		if ( ! $this->can_export() ) {
160
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
159
+		if ( ! $this->can_export()) {
160
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
161 161
 		}
162 162
 
163 163
 		$had_data = $this->get_data();
164 164
 
165
-		if ( $had_data ) {
165
+		if ($had_data) {
166 166
 			$this->done = false;
167 167
 
168 168
 			return true;
169 169
 		} else {
170
-			$donor       = new Give_Donor( $this->customer_id );
171
-			$payment_ids = get_option( 'give_stats_found_payments_' . $donor->id, array() );
172
-			$this->delete_data( 'give_stats_found_payments_' . $donor->id );
170
+			$donor       = new Give_Donor($this->customer_id);
171
+			$payment_ids = get_option('give_stats_found_payments_'.$donor->id, array());
172
+			$this->delete_data('give_stats_found_payments_'.$donor->id);
173 173
 
174
-			$removed_payments = array_unique( get_option( 'give_stats_missing_payments' . $donor->id, array() ) );
174
+			$removed_payments = array_unique(get_option('give_stats_missing_payments'.$donor->id, array()));
175 175
 
176 176
 			// Find non-existing payments (deleted) and total up the donation count
177 177
 			$purchase_count = 0;
178
-			foreach ( $payment_ids as $key => $payment_id ) {
179
-				if ( in_array( $payment_id, $removed_payments ) ) {
180
-					unset( $payment_ids[ $key ] );
178
+			foreach ($payment_ids as $key => $payment_id) {
179
+				if (in_array($payment_id, $removed_payments)) {
180
+					unset($payment_ids[$key]);
181 181
 					continue;
182 182
 				}
183 183
 
184
-				$payment = get_post( $payment_id );
185
-				if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) {
186
-					$purchase_count ++;
184
+				$payment = get_post($payment_id);
185
+				if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) {
186
+					$purchase_count++;
187 187
 				}
188 188
 			}
189 189
 
190
-			$this->delete_data( 'give_stats_missing_payments' . $donor->id );
190
+			$this->delete_data('give_stats_missing_payments'.$donor->id);
191 191
 
192
-			$pending_total = $this->get_stored_data( 'give_stats_donor_pending_total' . $donor->id );
193
-			$this->delete_data( 'give_stats_donor_pending_total' . $donor->id );
194
-			$this->delete_data( 'give_recount_donor_stats_' . $donor->id );
195
-			$this->delete_data( 'give_recount_donor_payments_' . $this->customer_id );
192
+			$pending_total = $this->get_stored_data('give_stats_donor_pending_total'.$donor->id);
193
+			$this->delete_data('give_stats_donor_pending_total'.$donor->id);
194
+			$this->delete_data('give_recount_donor_stats_'.$donor->id);
195
+			$this->delete_data('give_recount_donor_payments_'.$this->customer_id);
196 196
 
197
-			$payment_ids = implode( ',', $payment_ids );
198
-			$donor->update( array(
197
+			$payment_ids = implode(',', $payment_ids);
198
+			$donor->update(array(
199 199
 				'payment_ids'    => $payment_ids,
200 200
 				'purchase_count' => $purchase_count,
201 201
 				'purchase_value' => $pending_total,
202
-			) );
202
+			));
203 203
 
204 204
 			$this->done    = true;
205
-			$this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' );
205
+			$this->message = esc_html__('Donor stats have been successfully recounted.', 'give');
206 206
 
207 207
 			return false;
208 208
 		}
@@ -235,26 +235,26 @@  discard block
 block discarded – undo
235 235
 	 * @return void
236 236
 	 */
237 237
 	public function pre_fetch() {
238
-		if ( $this->step === 1 ) {
239
-			$allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() );
238
+		if ($this->step === 1) {
239
+			$allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys());
240 240
 
241 241
 			// Before we start, let's zero out the customer's data
242
-			$donor = new Give_Donor( $this->customer_id );
243
-			$donor->update( array( 'purchase_value' => give_format_amount( 0, array( 'sanitize' => false ) ), 'purchase_count' => 0 ) );
242
+			$donor = new Give_Donor($this->customer_id);
243
+			$donor->update(array('purchase_value' => give_format_amount(0, array('sanitize' => false)), 'purchase_count' => 0));
244 244
 
245
-			$attached_payment_ids = explode( ',', $donor->payment_ids );
245
+			$attached_payment_ids = explode(',', $donor->payment_ids);
246 246
 
247 247
 			$attached_args = array(
248 248
 				'post__in' => $attached_payment_ids,
249
-				'number'   => - 1,
249
+				'number'   => -1,
250 250
 				'status'   => $allowed_payment_status,
251 251
 			);
252 252
 
253
-			$attached_payments = give_get_payments( $attached_args );
253
+			$attached_payments = give_get_payments($attached_args);
254 254
 
255 255
 			$unattached_args = array(
256 256
 				'post__not_in' => $attached_payment_ids,
257
-				'number'       => - 1,
257
+				'number'       => -1,
258 258
 				'status'       => $allowed_payment_status,
259 259
 				'meta_query'   => array(
260 260
 					array(
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
 				),
265 265
 			);
266 266
 
267
-			$unattached_payments = give_get_payments( $unattached_args );
267
+			$unattached_payments = give_get_payments($unattached_args);
268 268
 
269
-			$payments = array_merge( $attached_payments, $unattached_payments );
269
+			$payments = array_merge($attached_payments, $unattached_payments);
270 270
 
271
-			$this->store_data( 'give_recount_donor_payments_' . $donor->id, $payments );
271
+			$this->store_data('give_recount_donor_payments_'.$donor->id, $payments);
272 272
 		}
273 273
 	}
274 274
 
@@ -281,17 +281,17 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return mixed       Returns the data from the database
283 283
 	 */
284
-	private function get_stored_data( $key ) {
284
+	private function get_stored_data($key) {
285 285
 		global $wpdb;
286
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
286
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
287 287
 
288
-		if ( empty( $value ) ) {
288
+		if (empty($value)) {
289 289
 			return false;
290 290
 		}
291 291
 
292
-		$maybe_json = json_decode( $value );
293
-		if ( ! is_null( $maybe_json ) ) {
294
-			$value = json_decode( $value, true );
292
+		$maybe_json = json_decode($value);
293
+		if ( ! is_null($maybe_json)) {
294
+			$value = json_decode($value, true);
295 295
 		}
296 296
 
297 297
 		return $value;
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	 *
308 308
 	 * @return void
309 309
 	 */
310
-	private function store_data( $key, $value ) {
310
+	private function store_data($key, $value) {
311 311
 		global $wpdb;
312 312
 
313
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
313
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
314 314
 
315 315
 		$data = array(
316 316
 			'option_name'  => $key,
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 			'%s',
325 325
 		);
326 326
 
327
-		$wpdb->replace( $wpdb->options, $data, $formats );
327
+		$wpdb->replace($wpdb->options, $data, $formats);
328 328
 	}
329 329
 
330 330
 	/**
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * @return void
338 338
 	 */
339
-	private function delete_data( $key ) {
339
+	private function delete_data($key) {
340 340
 		global $wpdb;
341
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
341
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
342 342
 	}
343 343
 
344 344
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-reset-stats.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	/**
50 50
 	 * Constructor.
51 51
 	 */
52
-	public function __construct( $_step = 1 ) {
53
-		parent::__construct( $_step );
52
+	public function __construct($_step = 1) {
53
+		parent::__construct($_step);
54 54
 
55 55
 		$this->is_writable = true;
56 56
 	}
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
 	public function get_data() {
68 68
 		global $wpdb;
69 69
 
70
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
70
+		$items = $this->get_stored_data('give_temp_reset_ids');
71 71
 
72
-		if ( ! is_array( $items ) ) {
72
+		if ( ! is_array($items)) {
73 73
 			return false;
74 74
 		}
75 75
 
76
-		$offset     = ( $this->step - 1 ) * $this->per_step;
77
-		$step_items = array_slice( $items, $offset, $this->per_step );
76
+		$offset     = ($this->step - 1) * $this->per_step;
77
+		$step_items = array_slice($items, $offset, $this->per_step);
78 78
 
79
-		if ( $step_items ) {
79
+		if ($step_items) {
80 80
 
81 81
 			$step_ids = array(
82 82
 				'customers' => array(),
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 				'other'     => array(),
85 85
 			);
86 86
 
87
-			foreach ( $step_items as $item ) {
87
+			foreach ($step_items as $item) {
88 88
 
89
-				switch ( $item['type'] ) {
89
+				switch ($item['type']) {
90 90
 					case 'customer':
91 91
 						$step_ids['customers'][] = $item['id'];
92 92
 						break;
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
 						$step_ids['give_forms'][] = $item['id'];
95 95
 						break;
96 96
 					default:
97
-						$item_type                = apply_filters( 'give_reset_item_type', 'other', $item );
98
-						$step_ids[ $item_type ][] = $item['id'];
97
+						$item_type                = apply_filters('give_reset_item_type', 'other', $item);
98
+						$step_ids[$item_type][] = $item['id'];
99 99
 						break;
100 100
 				}
101 101
 			}
102 102
 
103 103
 			$sql = array();
104
-			$meta_table = __give_v20_bc_table_details('form' );
104
+			$meta_table = __give_v20_bc_table_details('form');
105 105
 
106
-			foreach ( $step_ids as $type => $ids ) {
106
+			foreach ($step_ids as $type => $ids) {
107 107
 
108
-				if ( empty( $ids ) ) {
108
+				if (empty($ids)) {
109 109
 					continue;
110 110
 				}
111 111
 
112
-				$ids = implode( ',', $ids );
112
+				$ids = implode(',', $ids);
113 113
 
114
-				switch ( $type ) {
114
+				switch ($type) {
115 115
 					case 'customers':
116 116
 						$sql[]           = "DELETE FROM $wpdb->donors WHERE id IN ($ids)";
117 117
 						$table_name      = $wpdb->donors;
@@ -131,16 +131,16 @@  discard block
 block discarded – undo
131 131
 						break;
132 132
 				}
133 133
 
134
-				if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) {
134
+				if ( ! in_array($type, array('customers', 'forms', 'other'))) {
135 135
 					// Allows other types of custom post types to filter on their own post_type
136 136
 					// and add items to the query list, for the IDs found in their post type.
137
-					$sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids );
137
+					$sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids);
138 138
 				}
139 139
 			}
140 140
 
141
-			if ( ! empty( $sql ) ) {
142
-				foreach ( $sql as $query ) {
143
-					$wpdb->query( $query );
141
+			if ( ! empty($sql)) {
142
+				foreach ($sql as $query) {
143
+					$wpdb->query($query);
144 144
 				}
145 145
 			}
146 146
 
@@ -160,16 +160,16 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function get_percentage_complete() {
162 162
 
163
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
164
-		$total = count( $items );
163
+		$items = $this->get_stored_data('give_temp_reset_ids');
164
+		$total = count($items);
165 165
 
166 166
 		$percentage = 100;
167 167
 
168
-		if ( $total > 0 ) {
169
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
168
+		if ($total > 0) {
169
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
170 170
 		}
171 171
 
172
-		if ( $percentage > 100 ) {
172
+		if ($percentage > 100) {
173 173
 			$percentage = 100;
174 174
 		}
175 175
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @param array $request The Form Data passed into the batch processing.
185 185
 	 */
186
-	public function set_properties( $request ) {
186
+	public function set_properties($request) {
187 187
 	}
188 188
 
189 189
 	/**
@@ -194,31 +194,31 @@  discard block
 block discarded – undo
194 194
 	 */
195 195
 	public function process_step() {
196 196
 
197
-		if ( ! $this->can_export() ) {
198
-			wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array(
197
+		if ( ! $this->can_export()) {
198
+			wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array(
199 199
 				'response' => 403,
200
-			) );
200
+			));
201 201
 		}
202 202
 
203 203
 		$had_data = $this->get_data();
204 204
 
205
-		if ( $had_data ) {
205
+		if ($had_data) {
206 206
 			$this->done = false;
207 207
 
208 208
 			return true;
209 209
 		} else {
210
-			update_option( 'give_earnings_total', 0 );
211
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
210
+			update_option('give_earnings_total', 0);
211
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
212 212
 
213
-			$this->delete_data( 'give_temp_reset_ids' );
213
+			$this->delete_data('give_temp_reset_ids');
214 214
 
215 215
 			// Reset the sequential order numbers
216
-			if ( give_get_option( 'enable_sequential' ) ) {
217
-				delete_option( 'give_last_payment_number' );
216
+			if (give_get_option('enable_sequential')) {
217
+				delete_option('give_last_payment_number');
218 218
 			}
219 219
 
220 220
 			$this->done    = true;
221
-			$this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' );
221
+			$this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give');
222 222
 
223 223
 			return false;
224 224
 		}
@@ -251,26 +251,26 @@  discard block
 block discarded – undo
251 251
 	 */
252 252
 	public function pre_fetch() {
253 253
 
254
-		if ( $this->step == 1 ) {
255
-			$this->delete_data( 'give_temp_reset_ids' );
254
+		if ($this->step == 1) {
255
+			$this->delete_data('give_temp_reset_ids');
256 256
 		}
257 257
 
258
-		$items = get_option( 'give_temp_reset_ids', false );
258
+		$items = get_option('give_temp_reset_ids', false);
259 259
 
260
-		if ( false === $items ) {
260
+		if (false === $items) {
261 261
 			$items = array();
262 262
 
263
-			$give_types_for_reset = array( 'give_forms', 'give_payment' );
264
-			$give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset );
263
+			$give_types_for_reset = array('give_forms', 'give_payment');
264
+			$give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset);
265 265
 
266
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
266
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
267 267
 				'post_type'      => $give_types_for_reset,
268 268
 				'post_status'    => 'any',
269
-				'posts_per_page' => - 1,
270
-			) );
269
+				'posts_per_page' => -1,
270
+			));
271 271
 
272
-			$posts = get_posts( $args );
273
-			foreach ( $posts as $post ) {
272
+			$posts = get_posts($args);
273
+			foreach ($posts as $post) {
274 274
 				$items[] = array(
275 275
 					'id'   => (int) $post->ID,
276 276
 					'type' => $post->post_type,
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
 			}
279 279
 
280 280
 			$donor_args = array(
281
-				'number' => - 1,
281
+				'number' => -1,
282 282
 			);
283
-			$donors     = Give()->donors->get_donors( $donor_args );
284
-			foreach ( $donors as $donor ) {
283
+			$donors     = Give()->donors->get_donors($donor_args);
284
+			foreach ($donors as $donor) {
285 285
 				$items[] = array(
286 286
 					'id'   => (int) $donor->id,
287 287
 					'type' => 'customer',
@@ -290,9 +290,9 @@  discard block
 block discarded – undo
290 290
 
291 291
 			// Allow filtering of items to remove with an unassociative array for each item
292 292
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method
293
-			$items = apply_filters( 'give_reset_items', $items );
293
+			$items = apply_filters('give_reset_items', $items);
294 294
 
295
-			$this->store_data( 'give_temp_reset_ids', $items );
295
+			$this->store_data('give_temp_reset_ids', $items);
296 296
 		}// End if().
297 297
 
298 298
 	}
@@ -306,17 +306,17 @@  discard block
 block discarded – undo
306 306
 	 *
307 307
 	 * @return mixed       Returns the data from the database.
308 308
 	 */
309
-	private function get_stored_data( $key ) {
309
+	private function get_stored_data($key) {
310 310
 		global $wpdb;
311
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
311
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
312 312
 
313
-		if ( empty( $value ) ) {
313
+		if (empty($value)) {
314 314
 			return false;
315 315
 		}
316 316
 
317
-		$maybe_json = json_decode( $value );
318
-		if ( ! is_null( $maybe_json ) ) {
319
-			$value = json_decode( $value, true );
317
+		$maybe_json = json_decode($value);
318
+		if ( ! is_null($maybe_json)) {
319
+			$value = json_decode($value, true);
320 320
 		}
321 321
 
322 322
 		return $value;
@@ -332,10 +332,10 @@  discard block
 block discarded – undo
332 332
 	 *
333 333
 	 * @return void
334 334
 	 */
335
-	private function store_data( $key, $value ) {
335
+	private function store_data($key, $value) {
336 336
 		global $wpdb;
337 337
 
338
-		$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
338
+		$value = is_array($value) ? wp_json_encode($value) : esc_attr($value);
339 339
 
340 340
 		$data = array(
341 341
 			'option_name'  => $key,
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 			'%s',
350 350
 		);
351 351
 
352
-		$wpdb->replace( $wpdb->options, $data, $formats );
352
+		$wpdb->replace($wpdb->options, $data, $formats);
353 353
 	}
354 354
 
355 355
 	/**
@@ -361,11 +361,11 @@  discard block
 block discarded – undo
361 361
 	 *
362 362
 	 * @return void
363 363
 	 */
364
-	private function delete_data( $key ) {
364
+	private function delete_data($key) {
365 365
 		global $wpdb;
366
-		$wpdb->delete( $wpdb->options, array(
366
+		$wpdb->delete($wpdb->options, array(
367 367
 			'option_name' => $key,
368
-		) );
368
+		));
369 369
 	}
370 370
 
371 371
 }
372 372
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/payments/payments-history.php 1 patch
Spacing   +23 added lines, -23 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,10 +24,10 @@  discard block
 block discarded – undo
24 24
  * @return      void
25 25
 */
26 26
 function give_payment_history_page() {
27
-	if ( isset( $_GET['view'] ) && 'view-payment-details' == $_GET['view'] ) {
28
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/view-payment-details.php';
27
+	if (isset($_GET['view']) && 'view-payment-details' == $_GET['view']) {
28
+		require_once GIVE_PLUGIN_DIR.'includes/admin/payments/view-payment-details.php';
29 29
 	} else {
30
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/class-payments-table.php';
30
+		require_once GIVE_PLUGIN_DIR.'includes/admin/payments/class-payments-table.php';
31 31
 		$payments_table = new Give_Payment_History_Table();
32 32
 		$payments_table->prepare_items();
33 33
 	?>
@@ -41,23 +41,23 @@  discard block
 block discarded – undo
41 41
 		 *
42 42
 		 * @since 1.7
43 43
 		 */
44
-		do_action( 'give_payments_page_top' );
44
+		do_action('give_payments_page_top');
45 45
 		?>
46 46
 		<hr class="wp-header-end">
47 47
 
48
-		<form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>">
48
+		<form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>">
49 49
 			<input type="hidden" name="post_type" value="give_forms" />
50 50
 			<input type="hidden" name="page" value="give-payment-history" />
51 51
 			<?php $payments_table->views() ?>
52 52
 			<?php $payments_table->advanced_filters(); ?>
53 53
 		</form>
54 54
 
55
-		<form id="give-payments-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>">
55
+		<form id="give-payments-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>">
56 56
 			<input type="hidden" name="post_type" value="give_forms" />
57 57
 			<input type="hidden" name="page" value="give-payment-history" />
58 58
 			<?php
59
-			if ( ! empty( $_GET['donor'] ) ) {
60
-				echo sprintf( '<input type="hidden" name="donor" value="%s"/>', absint( $_GET['donor'] ) );
59
+			if ( ! empty($_GET['donor'])) {
60
+				echo sprintf('<input type="hidden" name="donor" value="%s"/>', absint($_GET['donor']));
61 61
 			}
62 62
 
63 63
 			$payments_table->display();
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		 *
71 71
 		 * @since 1.7
72 72
 		 */
73
-		do_action( 'give_payments_page_bottom' );
73
+		do_action('give_payments_page_bottom');
74 74
 		?>
75 75
 
76 76
 	</div>
@@ -87,29 +87,29 @@  discard block
 block discarded – undo
87 87
  * @param $title
88 88
  * @return string
89 89
  */
90
-function give_view_order_details_title( $admin_title, $title ) {
90
+function give_view_order_details_title($admin_title, $title) {
91 91
 
92
-	if ( 'give_forms_page_give-payment-history' != get_current_screen()->base ) {
92
+	if ('give_forms_page_give-payment-history' != get_current_screen()->base) {
93 93
 		return $admin_title;
94 94
 	}
95 95
 
96
-	if( ! isset( $_GET['give-action'] ) ) {
96
+	if ( ! isset($_GET['give-action'])) {
97 97
 		return $admin_title;
98 98
 	}
99 99
 
100
-	switch( $_GET['give-action'] ) :
100
+	switch ($_GET['give-action']) :
101 101
 
102 102
 		case 'view-payment-details' :
103 103
 			$title = sprintf(
104 104
 				/* translators: %s: admin title */
105
-				esc_html__( 'View Donation Details - %s', 'give' ),
105
+				esc_html__('View Donation Details - %s', 'give'),
106 106
 				$admin_title
107 107
 			);
108 108
 			break;
109 109
 		case 'edit-payment' :
110 110
 			$title = sprintf(
111 111
 				/* translators: %s: admin title */
112
-				esc_html__( 'Edit Donation - %s', 'give' ),
112
+				esc_html__('Edit Donation - %s', 'give'),
113 113
 				$admin_title
114 114
 			);
115 115
 			break;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
 	return $title;
122 122
 }
123
-add_filter( 'admin_title', 'give_view_order_details_title', 10, 2 );
123
+add_filter('admin_title', 'give_view_order_details_title', 10, 2);
124 124
 
125 125
 /**
126 126
  * Intercept default Edit post links for Give payments and rewrite them to the View Order Details screen.
@@ -132,20 +132,20 @@  discard block
 block discarded – undo
132 132
  * @param $context
133 133
  * @return string
134 134
  */
135
-function give_override_edit_post_for_payment_link( $url, $post_id = 0, $context ) {
135
+function give_override_edit_post_for_payment_link($url, $post_id = 0, $context) {
136 136
 
137
-	$post = get_post( $post_id );
137
+	$post = get_post($post_id);
138 138
 
139
-	if( ! $post ) {
139
+	if ( ! $post) {
140 140
 		return $url;
141 141
 	}
142 142
 
143
-	if( 'give_payment' != $post->post_type ) {
143
+	if ('give_payment' != $post->post_type) {
144 144
 		return $url;
145 145
 	}
146 146
 
147
-	$url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $post_id );
147
+	$url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$post_id);
148 148
 
149 149
 	return $url;
150 150
 }
151
-add_filter( 'get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3 );
151
+add_filter('get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3);
Please login to merge, or discard this patch.
includes/template-functions.php 1 patch
Spacing   +89 added lines, -89 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,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @return string
22 22
  */
23 23
 function give_get_templates_dir() {
24
-	return GIVE_PLUGIN_DIR . 'templates';
24
+	return GIVE_PLUGIN_DIR.'templates';
25 25
 }
26 26
 
27 27
 /**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return string
32 32
  */
33 33
 function give_get_templates_url() {
34
-	return GIVE_PLUGIN_URL . 'templates';
34
+	return GIVE_PLUGIN_URL.'templates';
35 35
 }
36 36
 
37 37
 /**
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
  * @param string $template_path Template file path. Default is empty.
45 45
  * @param string $default_path  Default path. Default is empty.
46 46
  */
47
-function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
48
-	if ( ! empty( $args ) && is_array( $args ) ) {
49
-		extract( $args );
47
+function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
48
+	if ( ! empty($args) && is_array($args)) {
49
+		extract($args);
50 50
 	}
51 51
 
52 52
 	$template_names = "{$template_name}.php";
53 53
 
54
-	$located = give_get_locate_template( $template_names, $template_path, $default_path );
54
+	$located = give_get_locate_template($template_names, $template_path, $default_path);
55 55
 
56
-	if ( ! file_exists( $located ) ) {
56
+	if ( ! file_exists($located)) {
57 57
 		/* translators: %s: the template */
58
-		Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
58
+		Give()->notices->print_frontend_notice(sprintf(__('The %s template was not found.', 'give'), $located), true);
59 59
 
60 60
 		return;
61 61
 	}
62 62
 
63 63
 	// Allow 3rd party plugin filter template file from their plugin.
64
-	$located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
64
+	$located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path);
65 65
 
66 66
 	/**
67 67
 	 * Fires in give template, before the file is included.
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 	 * @param string $located       Template file filter by 3rd party plugin.
76 76
 	 * @param array  $args          Passed arguments.
77 77
 	 */
78
-	do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
78
+	do_action('give_before_template_part', $template_name, $template_path, $located, $args);
79 79
 
80
-	include( $located );
80
+	include($located);
81 81
 
82 82
 	/**
83 83
 	 * Fires in give template, after the file is included.
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @param string $located       Template file filter by 3rd party plugin.
92 92
 	 * @param array  $args          Passed arguments.
93 93
 	 */
94
-	do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
94
+	do_action('give_after_template_part', $template_name, $template_path, $located, $args);
95 95
 }
96 96
 
97 97
 /**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
  *
108 108
  * @return string
109 109
  */
110
-function give_get_template_part( $slug, $name = null, $load = true ) {
110
+function give_get_template_part($slug, $name = null, $load = true) {
111 111
 
112 112
 	/**
113 113
 	 * Fires in give template part, before the template part is retrieved.
@@ -119,20 +119,20 @@  discard block
 block discarded – undo
119 119
 	 * @param string $slug Template part file slug {slug}.php.
120 120
 	 * @param string $name Template part file name {slug}-{name}.php.
121 121
 	 */
122
-	do_action( "get_template_part_{$slug}", $slug, $name );
122
+	do_action("get_template_part_{$slug}", $slug, $name);
123 123
 
124 124
 	// Setup possible parts
125 125
 	$templates = array();
126
-	if ( isset( $name ) ) {
127
-		$templates[] = $slug . '-' . $name . '.php';
126
+	if (isset($name)) {
127
+		$templates[] = $slug.'-'.$name.'.php';
128 128
 	}
129
-	$templates[] = $slug . '.php';
129
+	$templates[] = $slug.'.php';
130 130
 
131 131
 	// Allow template parts to be filtered
132
-	$templates = apply_filters( 'give_get_template_part', $templates, $slug, $name );
132
+	$templates = apply_filters('give_get_template_part', $templates, $slug, $name);
133 133
 
134 134
 	// Return the part that is found
135
-	return give_locate_template( $templates, $load, false );
135
+	return give_locate_template($templates, $load, false);
136 136
 }
137 137
 
138 138
 /**
@@ -153,37 +153,37 @@  discard block
 block discarded – undo
153 153
  *
154 154
  * @return string The template filename if one is located.
155 155
  */
156
-function give_locate_template( $template_names, $load = false, $require_once = true ) {
156
+function give_locate_template($template_names, $load = false, $require_once = true) {
157 157
 	// No file found yet
158 158
 	$located = false;
159 159
 
160 160
 	// Try to find a template file
161
-	foreach ( (array) $template_names as $template_name ) {
161
+	foreach ((array) $template_names as $template_name) {
162 162
 
163 163
 		// Continue if template is empty
164
-		if ( empty( $template_name ) ) {
164
+		if (empty($template_name)) {
165 165
 			continue;
166 166
 		}
167 167
 
168 168
 		// Trim off any slashes from the template name
169
-		$template_name = ltrim( $template_name, '/' );
169
+		$template_name = ltrim($template_name, '/');
170 170
 
171 171
 		// try locating this template file by looping through the template paths
172
-		foreach ( give_get_theme_template_paths() as $template_path ) {
172
+		foreach (give_get_theme_template_paths() as $template_path) {
173 173
 
174
-			if ( file_exists( $template_path . $template_name ) ) {
175
-				$located = $template_path . $template_name;
174
+			if (file_exists($template_path.$template_name)) {
175
+				$located = $template_path.$template_name;
176 176
 				break;
177 177
 			}
178 178
 		}
179 179
 
180
-		if ( $located ) {
180
+		if ($located) {
181 181
 			break;
182 182
 		}
183 183
 	}
184 184
 
185
-	if ( ( true == $load ) && ! empty( $located ) ) {
186
-		load_template( $located, $require_once );
185
+	if ((true == $load) && ! empty($located)) {
186
+		load_template($located, $require_once);
187 187
 	}
188 188
 
189 189
 	return $located;
@@ -207,26 +207,26 @@  discard block
 block discarded – undo
207 207
  *
208 208
  * @return string
209 209
  */
210
-function give_get_locate_template( $template_name, $template_path = '', $default_path = '' ) {
211
-	if ( ! $template_path ) {
212
-		$template_path = give_get_theme_template_dir_name() . '/';
210
+function give_get_locate_template($template_name, $template_path = '', $default_path = '') {
211
+	if ( ! $template_path) {
212
+		$template_path = give_get_theme_template_dir_name().'/';
213 213
 	}
214 214
 
215
-	if ( ! $default_path ) {
216
-		$default_path = GIVE_PLUGIN_DIR . 'templates/';
215
+	if ( ! $default_path) {
216
+		$default_path = GIVE_PLUGIN_DIR.'templates/';
217 217
 	}
218 218
 
219 219
 	// Look within passed path within the theme - this is priority.
220 220
 	$template = locate_template(
221 221
 		array(
222
-			trailingslashit( $template_path ) . $template_name,
222
+			trailingslashit($template_path).$template_name,
223 223
 			$template_name,
224 224
 		)
225 225
 	);
226 226
 
227 227
 	// Get default template/
228
-	if ( ! $template ) {
229
-		$template = $default_path . $template_name;
228
+	if ( ! $template) {
229
+		$template = $default_path.$template_name;
230 230
 	}
231 231
 
232 232
 	/**
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 *
235 235
 	 * @since 2.0.3
236 236
 	 */
237
-	return apply_filters( 'give_get_locate_template', $template, $template_name, $template_path );
237
+	return apply_filters('give_get_locate_template', $template, $template_name, $template_path);
238 238
 }
239 239
 
240 240
 /**
@@ -248,17 +248,17 @@  discard block
 block discarded – undo
248 248
 	$template_dir = give_get_theme_template_dir_name();
249 249
 
250 250
 	$file_paths = array(
251
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
252
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
251
+		1   => trailingslashit(get_stylesheet_directory()).$template_dir,
252
+		10  => trailingslashit(get_template_directory()).$template_dir,
253 253
 		100 => give_get_templates_dir(),
254 254
 	);
255 255
 
256
-	$file_paths = apply_filters( 'give_template_paths', $file_paths );
256
+	$file_paths = apply_filters('give_template_paths', $file_paths);
257 257
 
258 258
 	// sort the file paths based on priority
259
-	ksort( $file_paths, SORT_NUMERIC );
259
+	ksort($file_paths, SORT_NUMERIC);
260 260
 
261
-	return array_map( 'trailingslashit', $file_paths );
261
+	return array_map('trailingslashit', $file_paths);
262 262
 }
263 263
 
264 264
 /**
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
  * @return string
271 271
  */
272 272
 function give_get_theme_template_dir_name() {
273
-	return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) );
273
+	return trailingslashit(apply_filters('give_templates_dir', 'give'));
274 274
 }
275 275
 
276 276
 /**
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
  * @return void
281 281
  */
282 282
 function give_version_in_header() {
283
-	echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n";
283
+	echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n";
284 284
 }
285 285
 
286
-add_action( 'wp_head', 'give_version_in_header' );
286
+add_action('wp_head', 'give_version_in_header');
287 287
 
288 288
 /**
289 289
  * Determines if we're currently on the Donations History page.
@@ -293,9 +293,9 @@  discard block
 block discarded – undo
293 293
  */
294 294
 function give_is_donation_history_page() {
295 295
 
296
-	$ret = is_page( give_get_option( 'history_page' ) );
296
+	$ret = is_page(give_get_option('history_page'));
297 297
 
298
-	return apply_filters( 'give_is_donation_history_page', $ret );
298
+	return apply_filters('give_is_donation_history_page', $ret);
299 299
 }
300 300
 
301 301
 /**
@@ -307,25 +307,25 @@  discard block
 block discarded – undo
307 307
  *
308 308
  * @return array Modified array of classes
309 309
  */
310
-function give_add_body_classes( $class ) {
310
+function give_add_body_classes($class) {
311 311
 	$classes = (array) $class;
312 312
 
313
-	if ( give_is_success_page() ) {
313
+	if (give_is_success_page()) {
314 314
 		$classes[] = 'give-success';
315 315
 		$classes[] = 'give-page';
316 316
 	}
317 317
 
318
-	if ( give_is_failed_transaction_page() ) {
318
+	if (give_is_failed_transaction_page()) {
319 319
 		$classes[] = 'give-failed-transaction';
320 320
 		$classes[] = 'give-page';
321 321
 	}
322 322
 
323
-	if ( give_is_donation_history_page() ) {
323
+	if (give_is_donation_history_page()) {
324 324
 		$classes[] = 'give-donation-history';
325 325
 		$classes[] = 'give-page';
326 326
 	}
327 327
 
328
-	if ( give_is_test_mode() ) {
328
+	if (give_is_test_mode()) {
329 329
 		$classes[] = 'give-test-mode';
330 330
 		$classes[] = 'give-page';
331 331
 	}
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	/* @var WP_Theme $current_theme */
335 335
 	$current_theme = wp_get_theme();
336 336
 
337
-	switch ( $current_theme->get_template() ) {
337
+	switch ($current_theme->get_template()) {
338 338
 
339 339
 		case 'Divi':
340 340
 			$classes[] = 'give-divi';
@@ -351,10 +351,10 @@  discard block
 block discarded – undo
351 351
 
352 352
 	}
353 353
 
354
-	return array_unique( $classes );
354
+	return array_unique($classes);
355 355
 }
356 356
 
357
-add_filter( 'body_class', 'give_add_body_classes' );
357
+add_filter('body_class', 'give_add_body_classes');
358 358
 
359 359
 
360 360
 /**
@@ -370,22 +370,22 @@  discard block
 block discarded – undo
370 370
  *
371 371
  * @return array
372 372
  */
373
-function give_add_post_class( $classes, $class = '', $post_id = '' ) {
374
-	if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) {
373
+function give_add_post_class($classes, $class = '', $post_id = '') {
374
+	if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) {
375 375
 		return $classes;
376 376
 	}
377 377
 
378 378
 	//@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc).
379 379
 
380
-	if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) {
381
-		unset( $classes[ $key ] );
380
+	if (false !== ($key = array_search('hentry', $classes))) {
381
+		unset($classes[$key]);
382 382
 	}
383 383
 
384 384
 	return $classes;
385 385
 }
386 386
 
387 387
 
388
-add_filter( 'post_class', 'give_add_post_class', 20, 3 );
388
+add_filter('post_class', 'give_add_post_class', 20, 3);
389 389
 
390 390
 /**
391 391
  * Get the placeholder image URL for forms etc
@@ -395,74 +395,74 @@  discard block
 block discarded – undo
395 395
  */
396 396
 function give_get_placeholder_img_src() {
397 397
 
398
-	$placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) );
398
+	$placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give'));
399 399
 
400
-	return apply_filters( 'give_placeholder_img_src', $placeholder_url );
400
+	return apply_filters('give_placeholder_img_src', $placeholder_url);
401 401
 }
402 402
 
403 403
 
404 404
 /**
405 405
  * Global
406 406
  */
407
-if ( ! function_exists( 'give_output_content_wrapper' ) ) {
407
+if ( ! function_exists('give_output_content_wrapper')) {
408 408
 
409 409
 	/**
410 410
 	 * Output the start of the page wrapper.
411 411
 	 */
412 412
 	function give_output_content_wrapper() {
413
-		give_get_template_part( 'global/wrapper-start' );
413
+		give_get_template_part('global/wrapper-start');
414 414
 	}
415 415
 }
416
-if ( ! function_exists( 'give_output_content_wrapper_end' ) ) {
416
+if ( ! function_exists('give_output_content_wrapper_end')) {
417 417
 
418 418
 	/**
419 419
 	 * Output the end of the page wrapper.
420 420
 	 */
421 421
 	function give_output_content_wrapper_end() {
422
-		give_get_template_part( 'global/wrapper-end' );
422
+		give_get_template_part('global/wrapper-end');
423 423
 	}
424 424
 }
425 425
 
426 426
 /**
427 427
  * Single Give Form
428 428
  */
429
-if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) {
429
+if ( ! function_exists('give_left_sidebar_pre_wrap')) {
430 430
 	function give_left_sidebar_pre_wrap() {
431
-		echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' );
431
+		echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">');
432 432
 	}
433 433
 }
434 434
 
435
-if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) {
435
+if ( ! function_exists('give_left_sidebar_post_wrap')) {
436 436
 	function give_left_sidebar_post_wrap() {
437
-		echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' );
437
+		echo apply_filters('give_left_sidebar_post_wrap', '</div>');
438 438
 	}
439 439
 }
440 440
 
441
-if ( ! function_exists( 'give_get_forms_sidebar' ) ) {
441
+if ( ! function_exists('give_get_forms_sidebar')) {
442 442
 	function give_get_forms_sidebar() {
443
-		give_get_template_part( 'single-give-form/sidebar' );
443
+		give_get_template_part('single-give-form/sidebar');
444 444
 	}
445 445
 }
446 446
 
447
-if ( ! function_exists( 'give_show_form_images' ) ) {
447
+if ( ! function_exists('give_show_form_images')) {
448 448
 
449 449
 	/**
450 450
 	 * Output the donation form featured image.
451 451
 	 */
452 452
 	function give_show_form_images() {
453
-		if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
454
-			give_get_template_part( 'single-give-form/featured-image' );
453
+		if (give_is_setting_enabled(give_get_option('form_featured_img'))) {
454
+			give_get_template_part('single-give-form/featured-image');
455 455
 		}
456 456
 	}
457 457
 }
458 458
 
459
-if ( ! function_exists( 'give_template_single_title' ) ) {
459
+if ( ! function_exists('give_template_single_title')) {
460 460
 
461 461
 	/**
462 462
 	 * Output the form title.
463 463
 	 */
464 464
 	function give_template_single_title() {
465
-		give_get_template_part( 'single-give-form/title' );
465
+		give_get_template_part('single-give-form/title');
466 466
 	}
467 467
 }
468 468
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
  * Conditional Functions
471 471
  */
472 472
 
473
-if ( ! function_exists( 'is_give_form' ) ) {
473
+if ( ! function_exists('is_give_form')) {
474 474
 
475 475
 	/**
476 476
 	 * is_give_form
@@ -482,11 +482,11 @@  discard block
 block discarded – undo
482 482
 	 * @return bool
483 483
 	 */
484 484
 	function is_give_form() {
485
-		return is_singular( array( 'give_form' ) );
485
+		return is_singular(array('give_form'));
486 486
 	}
487 487
 }
488 488
 
489
-if ( ! function_exists( 'is_give_category' ) ) {
489
+if ( ! function_exists('is_give_category')) {
490 490
 
491 491
 	/**
492 492
 	 * is_give_category
@@ -501,12 +501,12 @@  discard block
 block discarded – undo
501 501
 	 *
502 502
 	 * @return bool
503 503
 	 */
504
-	function is_give_category( $term = '' ) {
505
-		return is_tax( 'give_forms_category', $term );
504
+	function is_give_category($term = '') {
505
+		return is_tax('give_forms_category', $term);
506 506
 	}
507 507
 }
508 508
 
509
-if ( ! function_exists( 'is_give_tag' ) ) {
509
+if ( ! function_exists('is_give_tag')) {
510 510
 
511 511
 	/**
512 512
 	 * is_give_tag
@@ -521,12 +521,12 @@  discard block
 block discarded – undo
521 521
 	 *
522 522
 	 * @return bool
523 523
 	 */
524
-	function is_give_tag( $term = '' ) {
525
-		return is_tax( 'give_forms_tag', $term );
524
+	function is_give_tag($term = '') {
525
+		return is_tax('give_forms_tag', $term);
526 526
 	}
527 527
 }
528 528
 
529
-if ( ! function_exists( 'is_give_taxonomy' ) ) {
529
+if ( ! function_exists('is_give_taxonomy')) {
530 530
 
531 531
 	/**
532 532
 	 * is_give_taxonomy
@@ -538,6 +538,6 @@  discard block
 block discarded – undo
538 538
 	 * @return bool
539 539
 	 */
540 540
 	function is_give_taxonomy() {
541
-		return is_tax( get_object_taxonomies( 'give_form' ) );
541
+		return is_tax(get_object_taxonomies('give_form'));
542 542
 	}
543 543
 }
Please login to merge, or discard this patch.
includes/shortcodes.php 1 patch
Spacing   +123 added lines, -123 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,58 +422,58 @@  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
 	$current_user = wp_get_current_user();
471 471
 
472 472
 	// Compares new values with old values to detect change in values.
473
-	$email_update        = ( $email !== $current_user->user_email ) ? true : false;
474
-	$display_name_update = ( $display_name !== $current_user->display_name ) ? true : false;
475
-	$first_name_update   = ( $first_name !== $current_user->first_name ) ? true : false;
476
-	$last_name_update    = ( $last_name !== $current_user->last_name ) ? true : false;
473
+	$email_update        = ($email !== $current_user->user_email) ? true : false;
474
+	$display_name_update = ($display_name !== $current_user->display_name) ? true : false;
475
+	$first_name_update   = ($first_name !== $current_user->first_name) ? true : false;
476
+	$last_name_update    = ($last_name !== $current_user->last_name) ? true : false;
477 477
 	$update_code         = 0;
478 478
 
479 479
 	/**
@@ -481,35 +481,35 @@  discard block
 block discarded – undo
481 481
 	 *
482 482
 	 * @var boolean
483 483
 	 */
484
-	$profile_update  = ( $email_update || $display_name_update || $first_name_update || $last_name_update );
484
+	$profile_update = ($email_update || $display_name_update || $first_name_update || $last_name_update);
485 485
 
486 486
 	/**
487 487
 	 * True if password fields are filled.
488 488
 	 *
489 489
 	 * @var boolean
490 490
 	 */
491
-	$password_update = ( ! empty( $password ) && ! empty( $confirm_password ) );
491
+	$password_update = ( ! empty($password) && ! empty($confirm_password));
492 492
 
493
-	if ( $profile_update ) {
493
+	if ($profile_update) {
494 494
 
495 495
 		// If only profile fields are updated.
496 496
 		$update_code = '1';
497 497
 
498
-		if ( $password_update ) {
498
+		if ($password_update) {
499 499
 
500 500
 			// If profile fields AND password both are updated.
501 501
 			$update_code = '2';
502 502
 		}
503
-	} elseif ( $password_update ) {
503
+	} elseif ($password_update) {
504 504
 
505 505
 		// If only password is updated.
506 506
 		$update_code = '3';
507 507
 	}
508 508
 
509 509
 	// Update the user.
510
-	$updated = wp_update_user( $userdata );
510
+	$updated = wp_update_user($userdata);
511 511
 
512
-	if ( $updated ) {
512
+	if ($updated) {
513 513
 
514 514
 		/**
515 515
 		 * Fires after updating user profile.
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 		 * @param int $user_id The ID of the user.
520 520
 		 * @param array $userdata User info, including ID, first name, last name, display name and email.
521 521
 		 */
522
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
522
+		do_action('give_user_profile_updated', $user_id, $userdata);
523 523
 
524 524
 		$profile_edit_redirect_args = array(
525 525
 			'updated'     => 'true',
@@ -530,10 +530,10 @@  discard block
 block discarded – undo
530 530
 		 * Update codes '2' and '3' indicate a password change.
531 531
 		 * If the password is changed, then logout and redirect to the same page.
532 532
 		 */
533
-		if ( '2' === $update_code || '3' === $update_code ) {
534
-			wp_logout( wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) ) );
533
+		if ('2' === $update_code || '3' === $update_code) {
534
+			wp_logout(wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect'])));
535 535
 		} else {
536
-			wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) );
536
+			wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect']));
537 537
 		}
538 538
 
539 539
 		give_die();
@@ -542,4 +542,4 @@  discard block
 block discarded – undo
542 542
 	return false;
543 543
 }
544 544
 
545
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
545
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
Please login to merge, or discard this patch.
includes/payments/actions.php 1 patch
Spacing   +106 added lines, -110 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * @return void
30 30
  */
31
-function give_complete_purchase( $payment_id, $new_status, $old_status ) {
31
+function give_complete_purchase($payment_id, $new_status, $old_status) {
32 32
 
33 33
 	// Make sure that payments are only completed once.
34
-	if ( $old_status == 'publish' || $old_status == 'complete' ) {
34
+	if ($old_status == 'publish' || $old_status == 'complete') {
35 35
 		return;
36 36
 	}
37 37
 
38 38
 	// Make sure the payment completion is only processed when new status is complete.
39
-	if ( $new_status != 'publish' && $new_status != 'complete' ) {
39
+	if ($new_status != 'publish' && $new_status != 'complete') {
40 40
 		return;
41 41
 	}
42 42
 
43
-	$payment = new Give_Payment( $payment_id );
43
+	$payment = new Give_Payment($payment_id);
44 44
 
45
-	$creation_date  = get_post_field( 'post_date', $payment_id, 'raw' );
45
+	$creation_date  = get_post_field('post_date', $payment_id, 'raw');
46 46
 	$payment_meta   = $payment->payment_meta;
47 47
 	$completed_date = $payment->completed_date;
48 48
 	$user_info      = $payment->user_info;
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @param int $payment_id The ID of the payment.
60 60
 	 */
61
-	do_action( 'give_pre_complete_donation', $payment_id );
61
+	do_action('give_pre_complete_donation', $payment_id);
62 62
 
63 63
 	// Ensure these actions only run once, ever.
64
-	if ( empty( $completed_date ) ) {
64
+	if (empty($completed_date)) {
65 65
 
66
-		give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date );
66
+		give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date);
67 67
 
68 68
 		/**
69 69
 		 * Fires after logging donation record.
@@ -74,29 +74,29 @@  discard block
 block discarded – undo
74 74
 		 * @param int   $payment_id   The ID number of the payment.
75 75
 		 * @param array $payment_meta The payment meta.
76 76
 		 */
77
-		do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta );
77
+		do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta);
78 78
 
79 79
 	}
80 80
 
81 81
 	// Increase the earnings for this form ID.
82
-	give_increase_earnings( $form_id, $amount );
83
-	give_increase_donation_count( $form_id );
82
+	give_increase_earnings($form_id, $amount);
83
+	give_increase_donation_count($form_id);
84 84
 
85 85
 	// @todo: Refresh only range related stat cache
86 86
 	give_delete_donation_stats();
87 87
 
88 88
 	// Increase the donor's donation stats.
89
-	$donor = new Give_Donor( $donor_id );
89
+	$donor = new Give_Donor($donor_id);
90 90
 	$donor->increase_purchase_count();
91
-	$donor->increase_value( $amount );
91
+	$donor->increase_value($amount);
92 92
 
93
-	give_increase_total_earnings( $amount );
93
+	give_increase_total_earnings($amount);
94 94
 
95 95
 	// Ensure this action only runs once ever.
96
-	if ( empty( $completed_date ) ) {
96
+	if (empty($completed_date)) {
97 97
 
98 98
 		// Save the completed date.
99
-		$payment->completed_date = current_time( 'mysql' );
99
+		$payment->completed_date = current_time('mysql');
100 100
 		$payment->save();
101 101
 
102 102
 		/**
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 		 *
107 107
 		 * @param int $payment_id The ID of the payment.
108 108
 		 */
109
-		do_action( 'give_complete_donation', $payment_id );
109
+		do_action('give_complete_donation', $payment_id);
110 110
 	}
111 111
 
112 112
 }
113 113
 
114
-add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 );
114
+add_action('give_update_payment_status', 'give_complete_purchase', 100, 3);
115 115
 
116 116
 
117 117
 /**
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
  *
126 126
  * @return void
127 127
  */
128
-function give_record_status_change( $payment_id, $new_status, $old_status ) {
128
+function give_record_status_change($payment_id, $new_status, $old_status) {
129 129
 
130 130
 	// Get the list of statuses so that status in the payment note can be translated.
131 131
 	$stati      = give_get_payment_statuses();
132
-	$old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status;
133
-	$new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status;
132
+	$old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status;
133
+	$new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status;
134 134
 
135 135
 	// translators: 1: old status 2: new status.
136
-	$status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status );
136
+	$status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status);
137 137
 
138
-	give_insert_payment_note( $payment_id, $status_change );
138
+	give_insert_payment_note($payment_id, $status_change);
139 139
 }
140 140
 
141
-add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 );
141
+add_action('give_update_payment_status', 'give_record_status_change', 100, 3);
142 142
 
143 143
 
144 144
 /**
@@ -154,25 +154,25 @@  discard block
 block discarded – undo
154 154
  *
155 155
  * @return void
156 156
  */
157
-function give_update_old_payments_with_totals( $data ) {
158
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) {
157
+function give_update_old_payments_with_totals($data) {
158
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) {
159 159
 		return;
160 160
 	}
161 161
 
162
-	if ( get_option( 'give_payment_totals_upgraded' ) ) {
162
+	if (get_option('give_payment_totals_upgraded')) {
163 163
 		return;
164 164
 	}
165 165
 
166
-	$payments = give_get_payments( array(
166
+	$payments = give_get_payments(array(
167 167
 		'offset' => 0,
168
-		'number' => - 1,
168
+		'number' => -1,
169 169
 		'mode'   => 'all',
170
-	) );
170
+	));
171 171
 
172
-	if ( $payments ) {
173
-		foreach ( $payments as $payment ) {
172
+	if ($payments) {
173
+		foreach ($payments as $payment) {
174 174
 
175
-			$payment = new Give_Payment( $payment->ID );
175
+			$payment = new Give_Payment($payment->ID);
176 176
 			$meta    = $payment->get_meta();
177 177
 
178 178
 			$payment->total = $meta['amount'];
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 		}
182 182
 	}
183 183
 
184
-	add_option( 'give_payment_totals_upgraded', 1 );
184
+	add_option('give_payment_totals_upgraded', 1);
185 185
 }
186 186
 
187
-add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' );
187
+add_action('give_upgrade_payments', 'give_update_old_payments_with_totals');
188 188
 
189 189
 /**
190 190
  * Mark Abandoned Donations
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
 function give_mark_abandoned_donations() {
199 199
 	$args = array(
200 200
 		'status' => 'pending',
201
-		'number' => - 1,
201
+		'number' => -1,
202 202
 		'output' => 'give_payments',
203 203
 	);
204 204
 
205
-	add_filter( 'posts_where', 'give_filter_where_older_than_week' );
205
+	add_filter('posts_where', 'give_filter_where_older_than_week');
206 206
 
207
-	$payments = give_get_payments( $args );
207
+	$payments = give_get_payments($args);
208 208
 
209
-	remove_filter( 'posts_where', 'give_filter_where_older_than_week' );
209
+	remove_filter('posts_where', 'give_filter_where_older_than_week');
210 210
 
211
-	if ( $payments ) {
211
+	if ($payments) {
212 212
 		/**
213 213
 		 * Filter payment gateways:  Used to set payment gateways which can be skip while transferring pending payment to abandon.
214 214
 		 *
@@ -216,14 +216,14 @@  discard block
 block discarded – undo
216 216
 		 *
217 217
 		 * @param array $skip_payment_gateways Array of payment gateways
218 218
 		 */
219
-		$skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) );
219
+		$skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline'));
220 220
 
221 221
 		/* @var Give_Payment $payment */
222
-		foreach ( $payments as $payment ) {
223
-			$gateway = give_get_payment_gateway( $payment->ID );
222
+		foreach ($payments as $payment) {
223
+			$gateway = give_get_payment_gateway($payment->ID);
224 224
 
225 225
 			// Skip payment gateways.
226
-			if ( in_array( $gateway, $skip_payment_gateways ) ) {
226
+			if (in_array($gateway, $skip_payment_gateways)) {
227 227
 				continue;
228 228
 			}
229 229
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	}
234 234
 }
235 235
 
236
-Give_Cron::add_weekly_event( 'give_mark_abandoned_donations' );
236
+Give_Cron::add_weekly_event('give_mark_abandoned_donations');
237 237
 
238 238
 
239 239
 /**
@@ -245,15 +245,15 @@  discard block
 block discarded – undo
245 245
  *
246 246
  * @return void
247 247
  */
248
-function give_refresh_thismonth_stat_transients( $payment_ID ) {
248
+function give_refresh_thismonth_stat_transients($payment_ID) {
249 249
 	// Monthly stats.
250
-	Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
250
+	Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
251 251
 
252 252
 	// @todo: Refresh only range related stat cache
253 253
 	give_delete_donation_stats();
254 254
 }
255 255
 
256
-add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' );
256
+add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients');
257 257
 
258 258
 
259 259
 /**
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return array
271 271
  */
272
-function give_bc_v20_get_payment_meta( $check, $object_id, $meta_key, $single ) {
272
+function give_bc_v20_get_payment_meta($check, $object_id, $meta_key, $single) {
273 273
 	// Bailout.
274 274
 	if (
275
-		'give_payment' !== get_post_type( $object_id ) ||
275
+		'give_payment' !== get_post_type($object_id) ||
276 276
 		'_give_payment_meta' !== $meta_key ||
277
-		! give_has_upgrade_completed( 'v20_upgrades_payment_metadata' )
277
+		! give_has_upgrade_completed('v20_upgrades_payment_metadata')
278 278
 	) {
279 279
 		return $check;
280 280
 	}
@@ -282,73 +282,69 @@  discard block
 block discarded – undo
282 282
 	$cache_key = "_give_payment_meta_{$object_id}";
283 283
 
284 284
 	// Get already calculate payment meta from cache.
285
-	$payment_meta = Give_Cache::get_db_query( $cache_key );
285
+	$payment_meta = Give_Cache::get_db_query($cache_key);
286 286
 
287
-	if ( is_null( $payment_meta ) ) {
287
+	if (is_null($payment_meta)) {
288 288
 		// Remove filter.
289
-		remove_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999 );
289
+		remove_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999);
290 290
 
291
-		$donation = new Give_Payment( $object_id );
291
+		$donation = new Give_Payment($object_id);
292 292
 
293 293
 		// Get all payment meta.
294
-		$payment_meta = give_get_meta( $object_id );
294
+		$payment_meta = give_get_meta($object_id);
295 295
 
296 296
 		// Set default value to array.
297
-		if ( empty( $payment_meta ) ) {
297
+		if (empty($payment_meta)) {
298 298
 			return $check;
299 299
 		}
300 300
 
301 301
 		// Convert all meta key value to string instead of array
302
-		array_walk( $payment_meta, function ( &$meta, $key ) {
303
-			$meta = current( $meta );
302
+		array_walk($payment_meta, function(&$meta, $key) {
303
+			$meta = current($meta);
304 304
 		} );
305 305
 
306 306
 		/**
307 307
 		 * Add backward compatibility to old meta keys.
308 308
 		 */
309 309
 		// Donation key.
310
-		$payment_meta['key'] = ! empty( $payment_meta['_give_payment_purchase_key'] ) ? $payment_meta['_give_payment_purchase_key'] : '';
310
+		$payment_meta['key'] = ! empty($payment_meta['_give_payment_purchase_key']) ? $payment_meta['_give_payment_purchase_key'] : '';
311 311
 
312 312
 		// Donation form.
313
-		$payment_meta['form_title'] = ! empty( $payment_meta['_give_payment_form_title'] ) ? $payment_meta['_give_payment_form_title'] : '';
313
+		$payment_meta['form_title'] = ! empty($payment_meta['_give_payment_form_title']) ? $payment_meta['_give_payment_form_title'] : '';
314 314
 
315 315
 		// Donor email.
316
-		$payment_meta['email'] = ! empty( $payment_meta['_give_payment_donor_email'] ) ? $payment_meta['_give_payment_donor_email'] : '';
317
-		$payment_meta['email'] = ! empty( $payment_meta['email'] ) ?
318
-			$payment_meta['email'] :
319
-			Give()->donors->get_column( 'email', $donation->donor_id );
316
+		$payment_meta['email'] = ! empty($payment_meta['_give_payment_donor_email']) ? $payment_meta['_give_payment_donor_email'] : '';
317
+		$payment_meta['email'] = ! empty($payment_meta['email']) ?
318
+			$payment_meta['email'] : Give()->donors->get_column('email', $donation->donor_id);
320 319
 
321 320
 		// Form id.
322
-		$payment_meta['form_id'] = ! empty( $payment_meta['_give_payment_form_id'] ) ? $payment_meta['_give_payment_form_id'] : '';
321
+		$payment_meta['form_id'] = ! empty($payment_meta['_give_payment_form_id']) ? $payment_meta['_give_payment_form_id'] : '';
323 322
 
324 323
 		// Price id.
325
-		$payment_meta['price_id'] = ! empty( $payment_meta['_give_payment_price_id'] ) ? $payment_meta['_give_payment_price_id'] : '';
324
+		$payment_meta['price_id'] = ! empty($payment_meta['_give_payment_price_id']) ? $payment_meta['_give_payment_price_id'] : '';
326 325
 
327 326
 		// Date.
328
-		$payment_meta['date'] = ! empty( $payment_meta['_give_payment_date'] ) ? $payment_meta['_give_payment_date'] : '';
329
-		$payment_meta['date'] = ! empty( $payment_meta['date'] ) ?
330
-			$payment_meta['date'] :
331
-			get_post_field( 'post_date', $object_id );
327
+		$payment_meta['date'] = ! empty($payment_meta['_give_payment_date']) ? $payment_meta['_give_payment_date'] : '';
328
+		$payment_meta['date'] = ! empty($payment_meta['date']) ?
329
+			$payment_meta['date'] : get_post_field('post_date', $object_id);
332 330
 
333 331
 
334 332
 		// Currency.
335
-		$payment_meta['currency'] = ! empty( $payment_meta['_give_payment_currency'] ) ? $payment_meta['_give_payment_currency'] : '';
333
+		$payment_meta['currency'] = ! empty($payment_meta['_give_payment_currency']) ? $payment_meta['_give_payment_currency'] : '';
336 334
 
337 335
 		// Decode donor data.
338
-		$donor_id = ! empty( $payment_meta['_give_payment_donor_id'] ) ? $payment_meta['_give_payment_donor_id'] : 0;
339
-		$donor    = new Give_Donor( $donor_id );
336
+		$donor_id = ! empty($payment_meta['_give_payment_donor_id']) ? $payment_meta['_give_payment_donor_id'] : 0;
337
+		$donor    = new Give_Donor($donor_id);
340 338
 
341 339
 		// Donor first name.
342
-		$donor_data['first_name'] = ! empty( $payment_meta['_give_donor_billing_first_name'] ) ? $payment_meta['_give_donor_billing_first_name'] : '';
343
-		$donor_data['first_name'] = ! empty( $donor_data['first_name'] ) ?
344
-			$donor_data['first_name'] :
345
-			$donor->get_first_name();
340
+		$donor_data['first_name'] = ! empty($payment_meta['_give_donor_billing_first_name']) ? $payment_meta['_give_donor_billing_first_name'] : '';
341
+		$donor_data['first_name'] = ! empty($donor_data['first_name']) ?
342
+			$donor_data['first_name'] : $donor->get_first_name();
346 343
 
347 344
 		// Donor last name.
348
-		$donor_data['last_name'] = ! empty( $payment_meta['_give_donor_billing_last_name'] ) ? $payment_meta['_give_donor_billing_last_name'] : '';
349
-		$donor_data['last_name'] = ! empty( $donor_data['last_name'] ) ?
350
-			$donor_data['last_name'] :
351
-			$donor->get_last_name();
345
+		$donor_data['last_name'] = ! empty($payment_meta['_give_donor_billing_last_name']) ? $payment_meta['_give_donor_billing_last_name'] : '';
346
+		$donor_data['last_name'] = ! empty($donor_data['last_name']) ?
347
+			$donor_data['last_name'] : $donor->get_last_name();
352 348
 
353 349
 		// Donor email.
354 350
 		$donor_data['email'] = $payment_meta['email'];
@@ -359,63 +355,63 @@  discard block
 block discarded – undo
359 355
 		$donor_data['address'] = false;
360 356
 
361 357
 		// Address1.
362
-		$address1 = ! empty( $payment_meta['_give_donor_billing_address1'] ) ? $payment_meta['_give_donor_billing_address1'] : '';
363
-		if ( $address1 ) {
358
+		$address1 = ! empty($payment_meta['_give_donor_billing_address1']) ? $payment_meta['_give_donor_billing_address1'] : '';
359
+		if ($address1) {
364 360
 			$donor_data['address']['line1'] = $address1;
365 361
 		}
366 362
 
367 363
 		// Address2.
368
-		$address2 = ! empty( $payment_meta['_give_donor_billing_address2'] ) ? $payment_meta['_give_donor_billing_address2'] : '';
369
-		if ( $address2 ) {
364
+		$address2 = ! empty($payment_meta['_give_donor_billing_address2']) ? $payment_meta['_give_donor_billing_address2'] : '';
365
+		if ($address2) {
370 366
 			$donor_data['address']['line2'] = $address2;
371 367
 		}
372 368
 
373 369
 		// City.
374
-		$city = ! empty( $payment_meta['_give_donor_billing_city'] ) ? $payment_meta['_give_donor_billing_city'] : '';
375
-		if ( $city ) {
370
+		$city = ! empty($payment_meta['_give_donor_billing_city']) ? $payment_meta['_give_donor_billing_city'] : '';
371
+		if ($city) {
376 372
 			$donor_data['address']['city'] = $city;
377 373
 		}
378 374
 
379 375
 		// Zip.
380
-		$zip = ! empty( $payment_meta['_give_donor_billing_zip'] ) ? $payment_meta['_give_donor_billing_zip'] : '';
381
-		if ( $zip ) {
376
+		$zip = ! empty($payment_meta['_give_donor_billing_zip']) ? $payment_meta['_give_donor_billing_zip'] : '';
377
+		if ($zip) {
382 378
 			$donor_data['address']['zip'] = $zip;
383 379
 		}
384 380
 
385 381
 		// State.
386
-		$state = ! empty( $payment_meta['_give_donor_billing_state'] ) ? $payment_meta['_give_donor_billing_state'] : '';
387
-		if ( $state ) {
382
+		$state = ! empty($payment_meta['_give_donor_billing_state']) ? $payment_meta['_give_donor_billing_state'] : '';
383
+		if ($state) {
388 384
 			$donor_data['address']['state'] = $state;
389 385
 		}
390 386
 
391 387
 		// Country.
392
-		$country = ! empty( $payment_meta['_give_donor_billing_country'] ) ? $payment_meta['_give_donor_billing_country'] : '';
393
-		if ( $country ) {
388
+		$country = ! empty($payment_meta['_give_donor_billing_country']) ? $payment_meta['_give_donor_billing_country'] : '';
389
+		if ($country) {
394 390
 			$donor_data['address']['country'] = $country;
395 391
 		}
396 392
 
397 393
 		$payment_meta['user_info'] = $donor_data;
398 394
 
399 395
 		// Add filter
400
-		add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 );
396
+		add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4);
401 397
 
402 398
 		// Set custom meta key into payment meta.
403
-		if ( ! empty( $payment_meta['_give_payment_meta'] ) ) {
404
-			$payment_meta = array_merge( maybe_unserialize( $payment_meta['_give_payment_meta'] ), $payment_meta );
399
+		if ( ! empty($payment_meta['_give_payment_meta'])) {
400
+			$payment_meta = array_merge(maybe_unserialize($payment_meta['_give_payment_meta']), $payment_meta);
405 401
 		}
406 402
 
407 403
 		// Set cache.
408
-		Give_Cache::set_db_query( $cache_key, $payment_meta );
404
+		Give_Cache::set_db_query($cache_key, $payment_meta);
409 405
 	}
410 406
 
411
-	if ( $single ) {
407
+	if ($single) {
412 408
 		/**
413 409
 		 * Filter the payment meta
414 410
 		 * Add custom meta key to payment meta
415 411
 		 *
416 412
 		 * @since 2.0
417 413
 		 */
418
-		$new_payment_meta[0] = apply_filters( 'give_get_payment_meta', $payment_meta, $object_id, $meta_key );
414
+		$new_payment_meta[0] = apply_filters('give_get_payment_meta', $payment_meta, $object_id, $meta_key);
419 415
 
420 416
 		$payment_meta = $new_payment_meta;
421 417
 	}
@@ -423,7 +419,7 @@  discard block
 block discarded – undo
423 419
 	return $payment_meta;
424 420
 }
425 421
 
426
-add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 );
422
+add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4);
427 423
 
428 424
 /**
429 425
  * Add meta in payment that store page id and page url.
@@ -435,19 +431,19 @@  discard block
 block discarded – undo
435 431
  *
436 432
  * @param int $payment_id Payment id for which the meta value should be updated.
437 433
  */
438
-function give_payment_save_page_data( $payment_id ) {
439
-	$page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false );
434
+function give_payment_save_page_data($payment_id) {
435
+	$page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false);
440 436
 
441 437
 	// Check $page_url is not empty.
442
-	if ( $page_url ) {
443
-		update_post_meta( $payment_id, '_give_current_url', $page_url );
444
-		$page_id = url_to_postid( $page_url );
438
+	if ($page_url) {
439
+		update_post_meta($payment_id, '_give_current_url', $page_url);
440
+		$page_id = url_to_postid($page_url);
445 441
 		// Check $page_id is not empty.
446
-		if ( $page_id ) {
447
-			update_post_meta( $payment_id, '_give_current_page_id', $page_id );
442
+		if ($page_id) {
443
+			update_post_meta($payment_id, '_give_current_page_id', $page_id);
448 444
 		}
449 445
 	}
450 446
 }
451 447
 
452 448
 // Fire when payment is save.
453
-add_action( 'give_insert_payment', 'give_payment_save_page_data' );
454 449
\ No newline at end of file
450
+add_action('give_insert_payment', 'give_payment_save_page_data');
455 451
\ No newline at end of file
Please login to merge, or discard this patch.
includes/emails/class-give-email-tags.php 1 patch
Spacing   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 // Exit if accessed directly.
26
-if ( ! defined( 'ABSPATH' ) ) {
26
+if ( ! defined('ABSPATH')) {
27 27
 	exit;
28 28
 }
29 29
 
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 	 * @param callable $func        Hook to run when email tag is found
57 57
 	 * @param string   $context     Email tag category
58 58
 	 */
59
-	public function add( $tag, $description, $func, $context = '' ) {
60
-		if ( is_callable( $func ) ) {
61
-			$this->tags[ $tag ] = array(
59
+	public function add($tag, $description, $func, $context = '') {
60
+		if (is_callable($func)) {
61
+			$this->tags[$tag] = array(
62 62
 				'tag'         => $tag,
63 63
 				'description' => $description,
64 64
 				'func'        => $func,
65
-				'context'     => give_check_variable( $context, 'empty', 'general' ),
65
+				'context'     => give_check_variable($context, 'empty', 'general'),
66 66
 			);
67 67
 		}
68 68
 	}
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @param string $tag Email tag to remove hook from
76 76
 	 */
77
-	public function remove( $tag ) {
78
-		unset( $this->tags[ $tag ] );
77
+	public function remove($tag) {
78
+		unset($this->tags[$tag]);
79 79
 	}
80 80
 
81 81
 	/**
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @return bool
89 89
 	 */
90
-	public function email_tag_exists( $tag ) {
91
-		return array_key_exists( $tag, $this->tags );
90
+	public function email_tag_exists($tag) {
91
+		return array_key_exists($tag, $this->tags);
92 92
 	}
93 93
 
94 94
 	/**
@@ -102,23 +102,23 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @return array
104 104
 	 */
105
-	public function get_tags( $context_type = 'all', $field = '' ) {
105
+	public function get_tags($context_type = 'all', $field = '') {
106 106
 		$tags = $this->tags;
107 107
 
108
-		if ( 'all' !== $context_type ) {
108
+		if ('all' !== $context_type) {
109 109
 			$tags = array();
110 110
 
111
-			foreach ( $this->tags as $tag ) {
112
-				if ( empty( $tag['context'] ) || $context_type !== $tag['context'] ) {
111
+			foreach ($this->tags as $tag) {
112
+				if (empty($tag['context']) || $context_type !== $tag['context']) {
113 113
 					continue;
114 114
 				}
115 115
 
116
-				$tags[ $tag['tag'] ] = $tag;
116
+				$tags[$tag['tag']] = $tag;
117 117
 			}
118 118
 		}
119 119
 
120
-		if ( ! empty( $tags ) && ! empty( $field ) ) {
121
-			$tags = wp_list_pluck( $tags, $field );
120
+		if ( ! empty($tags) && ! empty($field)) {
121
+			$tags = wp_list_pluck($tags, $field);
122 122
 		}
123 123
 
124 124
 		return $tags;
@@ -136,16 +136,16 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @return string Content with email tags filtered out.
138 138
 	 */
139
-	public function do_tags( $content, $tag_args ) {
139
+	public function do_tags($content, $tag_args) {
140 140
 
141 141
 		// Check if there is at least one tag added.
142
-		if ( empty( $this->tags ) || ! is_array( $this->tags ) ) {
142
+		if (empty($this->tags) || ! is_array($this->tags)) {
143 143
 			return $content;
144 144
 		}
145 145
 
146 146
 		$this->tag_args = $tag_args;
147 147
 
148
-		$new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content );
148
+		$new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content);
149 149
 
150 150
 		$this->tag_args = null;
151 151
 
@@ -161,17 +161,17 @@  discard block
 block discarded – undo
161 161
 	 *
162 162
 	 * @return mixed
163 163
 	 */
164
-	public function do_tag( $m ) {
164
+	public function do_tag($m) {
165 165
 
166 166
 		// Get tag
167 167
 		$tag = $m[1];
168 168
 
169 169
 		// Return tag if tag not set
170
-		if ( ! $this->email_tag_exists( $tag ) ) {
170
+		if ( ! $this->email_tag_exists($tag)) {
171 171
 			return $m[0];
172 172
 		}
173 173
 
174
-		return call_user_func( $this->tags[ $tag ]['func'], $this->tag_args, $tag );
174
+		return call_user_func($this->tags[$tag]['func'], $this->tag_args, $tag);
175 175
 	}
176 176
 
177 177
 }
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
  * @param callable $func        Hook to run when email tag is found
187 187
  * @param string   $context     Email tag category
188 188
  */
189
-function give_add_email_tag( $tag, $description, $func, $context = '' ) {
190
-	Give()->email_tags->add( $tag, $description, $func, $context );
189
+function give_add_email_tag($tag, $description, $func, $context = '') {
190
+	Give()->email_tags->add($tag, $description, $func, $context);
191 191
 }
192 192
 
193 193
 /**
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
  *
198 198
  * @param string $tag Email tag to remove hook from
199 199
  */
200
-function give_remove_email_tag( $tag ) {
201
-	Give()->email_tags->remove( $tag );
200
+function give_remove_email_tag($tag) {
201
+	Give()->email_tags->remove($tag);
202 202
 }
203 203
 
204 204
 /**
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
  *
211 211
  * @return bool
212 212
  */
213
-function give_email_tag_exists( $tag ) {
214
-	return Give()->email_tags->email_tag_exists( $tag );
213
+function give_email_tag_exists($tag) {
214
+	return Give()->email_tags->email_tag_exists($tag);
215 215
 }
216 216
 
217 217
 /**
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 	$email_tags = give_get_email_tags();
239 239
 
240 240
 	ob_start();
241
-	if ( count( $email_tags ) > 0 ) : ?>
241
+	if (count($email_tags) > 0) : ?>
242 242
 		<div class="give-email-tags-wrap">
243
-			<?php foreach ( $email_tags as $email_tag ) : ?>
243
+			<?php foreach ($email_tags as $email_tag) : ?>
244 244
 				<span class="give_<?php echo $email_tag['tag']; ?>_tag">
245 245
 					<code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?>
246 246
 				</span>
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
  *
265 265
  * @return string Content with email tags filtered out.
266 266
  */
267
-function give_do_email_tags( $content, $tag_args ) {
267
+function give_do_email_tags($content, $tag_args) {
268 268
 	// Backward compatibility < 2.0
269
-	if ( ! is_array( $tag_args ) ) {
270
-		$tag_args = array( 'payment_id' => $tag_args );
269
+	if ( ! is_array($tag_args)) {
270
+		$tag_args = array('payment_id' => $tag_args);
271 271
 	}
272 272
 
273 273
 	// Replace all tags
274
-	$content = Give()->email_tags->do_tags( $content, $tag_args );
274
+	$content = Give()->email_tags->do_tags($content, $tag_args);
275 275
 
276 276
 	/**
277 277
 	 * Filter the filtered content text.
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 * @since 1.0
280 280
 	 * @since 2.0 $payment_meta, $payment_id removed and $tag_args added.
281 281
 	 */
282
-	$content = apply_filters( 'give_email_template_tags', $content, $tag_args );
282
+	$content = apply_filters('give_email_template_tags', $content, $tag_args);
283 283
 
284 284
 	// Return content
285 285
 	return $content;
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 	 *
299 299
 	 * @since 1.0
300 300
 	 */
301
-	do_action( 'give_add_email_tags' );
301
+	do_action('give_add_email_tags');
302 302
 }
303 303
 
304
-add_action( 'init', 'give_load_email_tags', - 999 );
304
+add_action('init', 'give_load_email_tags', - 999);
305 305
 
306 306
 
307 307
 /**
@@ -316,67 +316,67 @@  discard block
 block discarded – undo
316 316
 		/*	Donation Payment */
317 317
 		array(
318 318
 			'tag'         => 'donation',
319
-			'description' => esc_html__( 'The donation form name, and the donation level (if applicable).', 'give' ),
319
+			'description' => esc_html__('The donation form name, and the donation level (if applicable).', 'give'),
320 320
 			'function'    => 'give_email_tag_donation',
321 321
 			'context'     => 'donation',
322 322
 		),
323 323
 		array(
324 324
 			'tag'         => 'amount',
325
-			'description' => esc_html__( 'The total donation amount with currency sign.', 'give' ),
325
+			'description' => esc_html__('The total donation amount with currency sign.', 'give'),
326 326
 			'function'    => 'give_email_tag_amount',
327 327
 			'context'     => 'donation',
328 328
 		),
329 329
 		array(
330 330
 			'tag'         => 'price',
331
-			'description' => esc_html__( 'The total donation amount with currency sign.', 'give' ),
331
+			'description' => esc_html__('The total donation amount with currency sign.', 'give'),
332 332
 			'function'    => 'give_email_tag_price',
333 333
 			'context'     => 'donation',
334 334
 		),
335 335
 		array(
336 336
 			'tag'         => 'billing_address',
337
-			'description' => esc_html__( 'The donor\'s billing address.', 'give' ),
337
+			'description' => esc_html__('The donor\'s billing address.', 'give'),
338 338
 			'function'    => 'give_email_tag_billing_address',
339 339
 			'context'     => 'donation',
340 340
 		),
341 341
 		array(
342 342
 			'tag'         => 'date',
343
-			'description' => esc_html__( 'The date of the donation.', 'give' ),
343
+			'description' => esc_html__('The date of the donation.', 'give'),
344 344
 			'function'    => 'give_email_tag_date',
345 345
 			'context'     => 'donation',
346 346
 		),
347 347
 		array(
348 348
 			'tag'         => 'payment_id',
349
-			'description' => esc_html__( 'The unique ID number for this donation.', 'give' ),
349
+			'description' => esc_html__('The unique ID number for this donation.', 'give'),
350 350
 			'function'    => 'give_email_tag_payment_id',
351 351
 			'context'     => 'donation',
352 352
 		),
353 353
 		array(
354 354
 			'tag'         => 'payment_method',
355
-			'description' => esc_html__( 'The method of payment used for this donation.', 'give' ),
355
+			'description' => esc_html__('The method of payment used for this donation.', 'give'),
356 356
 			'function'    => 'give_email_tag_payment_method',
357 357
 			'context'     => 'donation',
358 358
 		),
359 359
 		array(
360 360
 			'tag'         => 'payment_total',
361
-			'description' => esc_html__( 'The payment total for this donation.', 'give' ),
361
+			'description' => esc_html__('The payment total for this donation.', 'give'),
362 362
 			'function'    => 'give_email_tag_payment_total',
363 363
 			'context'     => 'donation',
364 364
 		),
365 365
 		array(
366 366
 			'tag'         => 'receipt_id',
367
-			'description' => esc_html__( 'The unique ID number for this donation receipt.', 'give' ),
367
+			'description' => esc_html__('The unique ID number for this donation receipt.', 'give'),
368 368
 			'function'    => 'give_email_tag_receipt_id',
369 369
 			'context'     => 'donation',
370 370
 		),
371 371
 		array(
372 372
 			'tag'         => 'receipt_link',
373
-			'description' => esc_html__( 'The donation receipt direct link, to view the receipt on the website.', 'give' ),
373
+			'description' => esc_html__('The donation receipt direct link, to view the receipt on the website.', 'give'),
374 374
 			'function'    => 'give_email_tag_receipt_link',
375 375
 			'context'     => 'donation',
376 376
 		),
377 377
 		array(
378 378
 			'tag'         => 'receipt_link_url',
379
-			'description' => esc_html__( 'The donation receipt direct URL, to view the receipt on the website.', 'give' ),
379
+			'description' => esc_html__('The donation receipt direct URL, to view the receipt on the website.', 'give'),
380 380
 			'function'    => 'give_email_tag_receipt_link_url',
381 381
 			'context'     => 'donation',
382 382
 		),
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 		/* Donation Form */
385 385
 		array(
386 386
 			'tag'         => 'form_title',
387
-			'description' => esc_html__( 'The donation form name.', 'give' ),
387
+			'description' => esc_html__('The donation form name.', 'give'),
388 388
 			'function'    => 'give_email_tag_form_title',
389 389
 			'context'     => 'form',
390 390
 		),
@@ -392,31 +392,31 @@  discard block
 block discarded – undo
392 392
 		/* Donor */
393 393
 		array(
394 394
 			'tag'         => 'name',
395
-			'description' => esc_html__( 'The donor\'s first name.', 'give' ),
395
+			'description' => esc_html__('The donor\'s first name.', 'give'),
396 396
 			'function'    => 'give_email_tag_first_name',
397 397
 			'context'     => 'donor',
398 398
 		),
399 399
 		array(
400 400
 			'tag'         => 'fullname',
401
-			'description' => esc_html__( 'The donor\'s full name, first and last.', 'give' ),
401
+			'description' => esc_html__('The donor\'s full name, first and last.', 'give'),
402 402
 			'function'    => 'give_email_tag_fullname',
403 403
 			'context'     => 'donor',
404 404
 		),
405 405
 		array(
406 406
 			'tag'         => 'username',
407
-			'description' => esc_html__( 'The donor\'s user name on the site, if they registered an account.', 'give' ),
407
+			'description' => esc_html__('The donor\'s user name on the site, if they registered an account.', 'give'),
408 408
 			'function'    => 'give_email_tag_username',
409 409
 			'context'     => 'donor',
410 410
 		),
411 411
 		array(
412 412
 			'tag'         => 'user_email',
413
-			'description' => esc_html__( 'The donor\'s email address.', 'give' ),
413
+			'description' => esc_html__('The donor\'s email address.', 'give'),
414 414
 			'function'    => 'give_email_tag_user_email',
415 415
 			'context'     => 'donor',
416 416
 		),
417 417
 		array(
418 418
 			'tag'         => 'email_access_link',
419
-			'description' => esc_html__( 'The donor\'s email access link.', 'give' ),
419
+			'description' => esc_html__('The donor\'s email access link.', 'give'),
420 420
 			'function'    => 'give_email_tag_email_access_link',
421 421
 			'context'     => 'donor',
422 422
 		),
@@ -424,14 +424,14 @@  discard block
 block discarded – undo
424 424
 		/* General */
425 425
 		array(
426 426
 			'tag'         => 'sitename',
427
-			'description' => esc_html__( 'The name of your site.', 'give' ),
427
+			'description' => esc_html__('The name of your site.', 'give'),
428 428
 			'function'    => 'give_email_tag_sitename',
429 429
 			'context'     => 'general',
430 430
 		),
431 431
 
432 432
 		array(
433 433
 			'tag'         => 'reset_password_link',
434
-			'description' => esc_html__( 'The reset password link for user.', 'give' ),
434
+			'description' => esc_html__('The reset password link for user.', 'give'),
435 435
 			'function'    => 'give_email_tag_reset_password_link',
436 436
 			'context'     => 'general',
437 437
 		),
@@ -439,21 +439,21 @@  discard block
 block discarded – undo
439 439
 	);
440 440
 
441 441
 	// Apply give_email_tags filter
442
-	$email_tags = apply_filters( 'give_email_tags', $email_tags );
442
+	$email_tags = apply_filters('give_email_tags', $email_tags);
443 443
 
444 444
 	// Add email tags
445
-	foreach ( $email_tags as $email_tag ) {
445
+	foreach ($email_tags as $email_tag) {
446 446
 		give_add_email_tag(
447 447
 			$email_tag['tag'],
448 448
 			$email_tag['description'],
449 449
 			$email_tag['function'],
450
-			( ! empty( $email_tag['context'] ) ? $email_tag['context'] : '' )
450
+			( ! empty($email_tag['context']) ? $email_tag['context'] : '')
451 451
 		);
452 452
 	}
453 453
 
454 454
 }
455 455
 
456
-add_action( 'give_add_email_tags', 'give_setup_email_tags' );
456
+add_action('give_add_email_tags', 'give_setup_email_tags');
457 457
 
458 458
 
459 459
 /**
@@ -465,26 +465,26 @@  discard block
 block discarded – undo
465 465
  *
466 466
  * @return string $firstname
467 467
  */
468
-function give_email_tag_first_name( $tag_args ) {
468
+function give_email_tag_first_name($tag_args) {
469 469
 	$user_info = array();
470 470
 	$firstname = '';
471 471
 
472 472
 	// Backward compatibility.
473
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
473
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
474 474
 
475
-	switch ( true ) {
476
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
477
-			$payment = new Give_Payment( $tag_args['payment_id'] );
475
+	switch (true) {
476
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
477
+			$payment = new Give_Payment($tag_args['payment_id']);
478 478
 
479 479
 			// Get firstname.
480
-			if ( ! empty( $payment->user_info ) ) {
481
-				$email_names = give_get_email_names( $payment->user_info );
480
+			if ( ! empty($payment->user_info)) {
481
+				$email_names = give_get_email_names($payment->user_info);
482 482
 				$firstname   = $email_names['name'];
483 483
 			}
484 484
 			break;
485 485
 
486
-		case give_check_variable( $tag_args, 'isset', 0, 'user_id' ):
487
-			$donor = new Give_Donor( $tag_args['user_id'], true );
486
+		case give_check_variable($tag_args, 'isset', 0, 'user_id'):
487
+			$donor = new Give_Donor($tag_args['user_id'], true);
488 488
 			$firstname = $donor->get_first_name();
489 489
 			break;
490 490
 
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
 		 *
494 494
 		 * @since 2.0
495 495
 		 */
496
-		case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ):
497
-			$donor = new Give_Donor( $tag_args['donor_id'] );
496
+		case give_check_variable($tag_args, 'isset', 0, 'donor_id'):
497
+			$donor = new Give_Donor($tag_args['donor_id']);
498 498
 			$firstname = $donor->get_first_name();
499 499
 			break;
500 500
 	}
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 	 * @param string $firstname
508 508
 	 * @param array  $tag_args
509 509
 	 */
510
-	$firstname = apply_filters( 'give_email_tag_first_name', $firstname, $tag_args );
510
+	$firstname = apply_filters('give_email_tag_first_name', $firstname, $tag_args);
511 511
 
512 512
 	return $firstname;
513 513
 }
@@ -521,26 +521,26 @@  discard block
 block discarded – undo
521 521
  *
522 522
  * @return string $fullname
523 523
  */
524
-function give_email_tag_fullname( $tag_args ) {
524
+function give_email_tag_fullname($tag_args) {
525 525
 	$fullname = '';
526 526
 
527 527
 	// Backward compatibility.
528
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
528
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
529 529
 
530
-	switch ( true ) {
531
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
532
-			$payment = new Give_Payment( $tag_args['payment_id'] );
530
+	switch (true) {
531
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
532
+			$payment = new Give_Payment($tag_args['payment_id']);
533 533
 
534 534
 			// Get fullname.
535
-			if ( ! empty( $payment->user_info ) ) {
536
-				$email_names = give_get_email_names( $payment->user_info );
535
+			if ( ! empty($payment->user_info)) {
536
+				$email_names = give_get_email_names($payment->user_info);
537 537
 				$fullname    = $email_names['fullname'];
538 538
 			}
539 539
 			break;
540 540
 
541
-		case give_check_variable( $tag_args, 'isset', 0, 'user_id' ):
542
-			$donor = new Give_Donor( $tag_args['user_id'], true );
543
-			$fullname  = trim( "{$donor->get_first_name()} {$donor->get_last_name()}" );
541
+		case give_check_variable($tag_args, 'isset', 0, 'user_id'):
542
+			$donor = new Give_Donor($tag_args['user_id'], true);
543
+			$fullname = trim("{$donor->get_first_name()} {$donor->get_last_name()}");
544 544
 			break;
545 545
 
546 546
 		/**
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
 		 *
549 549
 		 * @since 2.0
550 550
 		 */
551
-		case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ):
552
-			$donor = new Give_Donor( $tag_args['donor_id'] );
551
+		case give_check_variable($tag_args, 'isset', 0, 'donor_id'):
552
+			$donor = new Give_Donor($tag_args['donor_id']);
553 553
 			$fullname = $donor->name;
554 554
 			break;
555 555
 	}
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 	 * @param string $fullname
563 563
 	 * @param array  $tag_args
564 564
 	 */
565
-	$fullname = apply_filters( 'give_email_tag_fullname', $fullname, $tag_args );
565
+	$fullname = apply_filters('give_email_tag_fullname', $fullname, $tag_args);
566 566
 
567 567
 	return $fullname;
568 568
 }
@@ -576,25 +576,25 @@  discard block
 block discarded – undo
576 576
  *
577 577
  * @return string username.
578 578
  */
579
-function give_email_tag_username( $tag_args ) {
579
+function give_email_tag_username($tag_args) {
580 580
 	$username = '';
581 581
 
582 582
 	// Backward compatibility.
583
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
583
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
584 584
 
585
-	switch ( true ) {
586
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
587
-			$payment = new Give_Payment( $tag_args['payment_id'] );
585
+	switch (true) {
586
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
587
+			$payment = new Give_Payment($tag_args['payment_id']);
588 588
 
589 589
 			// Get username.
590
-			if ( ! empty( $payment->user_info ) ) {
591
-				$email_names = give_get_email_names( $payment->user_info );
590
+			if ( ! empty($payment->user_info)) {
591
+				$email_names = give_get_email_names($payment->user_info);
592 592
 				$username    = $email_names['username'];
593 593
 			}
594 594
 			break;
595 595
 
596
-		case give_check_variable( $tag_args, 'isset', 0, 'user_id' ):
597
-			$user_info = get_user_by( 'id', $tag_args['user_id'] );
596
+		case give_check_variable($tag_args, 'isset', 0, 'user_id'):
597
+			$user_info = get_user_by('id', $tag_args['user_id']);
598 598
 			$username  = $user_info->user_login;
599 599
 			break;
600 600
 
@@ -603,10 +603,10 @@  discard block
 block discarded – undo
603 603
 		 *
604 604
 		 * @since 2.0
605 605
 		 */
606
-		case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ):
607
-			$donor = new Give_Donor( $tag_args['donor_id'] );
608
-			if ( ! empty( $donor->id ) && ! empty( $donor->user_id ) ) {
609
-				$user_info = get_user_by( 'id', $donor->user_id );
606
+		case give_check_variable($tag_args, 'isset', 0, 'donor_id'):
607
+			$donor = new Give_Donor($tag_args['donor_id']);
608
+			if ( ! empty($donor->id) && ! empty($donor->user_id)) {
609
+				$user_info = get_user_by('id', $donor->user_id);
610 610
 				$username  = $user_info->user_login;
611 611
 			}
612 612
 			break;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 	 * @param string $username
621 621
 	 * @param array  $tag_args
622 622
 	 */
623
-	$username = apply_filters( 'give_email_tag_username', $username, $tag_args );
623
+	$username = apply_filters('give_email_tag_username', $username, $tag_args);
624 624
 
625 625
 	return $username;
626 626
 }
@@ -634,20 +634,20 @@  discard block
 block discarded – undo
634 634
  *
635 635
  * @return string user_email
636 636
  */
637
-function give_email_tag_user_email( $tag_args ) {
637
+function give_email_tag_user_email($tag_args) {
638 638
 	$email = '';
639 639
 
640 640
 	// Backward compatibility.
641
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
641
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
642 642
 
643
-	switch ( true ) {
644
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
645
-			$payment = new Give_Payment( $tag_args['payment_id'] );
643
+	switch (true) {
644
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
645
+			$payment = new Give_Payment($tag_args['payment_id']);
646 646
 			$email   = $payment->email;
647 647
 			break;
648 648
 
649
-		case give_check_variable( $tag_args, 'isset', 0, 'user_id' ):
650
-			$user_info = get_user_by( 'id', $tag_args['user_id'] );
649
+		case give_check_variable($tag_args, 'isset', 0, 'user_id'):
650
+			$user_info = get_user_by('id', $tag_args['user_id']);
651 651
 			$email     = $user_info->user_email;
652 652
 			break;
653 653
 
@@ -656,9 +656,9 @@  discard block
 block discarded – undo
656 656
 		 *
657 657
 		 * @since 2.0
658 658
 		 */
659
-		case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ):
660
-			$donor = new Give_Donor( $tag_args['donor_id'] );
661
-			$email     = $donor->email;
659
+		case give_check_variable($tag_args, 'isset', 0, 'donor_id'):
660
+			$donor = new Give_Donor($tag_args['donor_id']);
661
+			$email = $donor->email;
662 662
 			break;
663 663
 	}
664 664
 
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 	 * @param string $email
671 671
 	 * @param array  $tag_args
672 672
 	 */
673
-	$email = apply_filters( 'give_email_tag_user_email', $email, $tag_args );
673
+	$email = apply_filters('give_email_tag_user_email', $email, $tag_args);
674 674
 
675 675
 	return $email;
676 676
 }
@@ -684,22 +684,22 @@  discard block
 block discarded – undo
684 684
  *
685 685
  * @return string billing_address
686 686
  */
687
-function give_email_tag_billing_address( $tag_args ) {
687
+function give_email_tag_billing_address($tag_args) {
688 688
 	$address = '';
689 689
 
690 690
 	// Backward compatibility.
691
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
691
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
692 692
 
693
-	switch ( true ) {
694
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
695
-			$donation   = new Give_Payment( $tag_args['payment_id'] );
696
-			$address = $donation->address['line1'] . "\n";
693
+	switch (true) {
694
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
695
+			$donation = new Give_Payment($tag_args['payment_id']);
696
+			$address = $donation->address['line1']."\n";
697 697
 
698
-			if ( ! empty( $donation->address['line2'] ) ) {
699
-				$address .= $donation->address['line2'] . "\n";
698
+			if ( ! empty($donation->address['line2'])) {
699
+				$address .= $donation->address['line2']."\n";
700 700
 			}
701 701
 
702
-			$address .= $donation->address['city'] . ' ' . $donation->address['zip'] . ' ' . $donation->address['state'] . "\n";
702
+			$address .= $donation->address['city'].' '.$donation->address['zip'].' '.$donation->address['state']."\n";
703 703
 			$address .= $donation->address['country'];
704 704
 			break;
705 705
 	}
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 	 * @param string $address
713 713
 	 * @param array  $tag_args
714 714
 	 */
715
-	$address = apply_filters( 'give_email_tag_billing_address', $address, $tag_args );
715
+	$address = apply_filters('give_email_tag_billing_address', $address, $tag_args);
716 716
 
717 717
 	return $address;
718 718
 }
@@ -726,16 +726,16 @@  discard block
 block discarded – undo
726 726
  *
727 727
  * @return string date
728 728
  */
729
-function give_email_tag_date( $tag_args ) {
729
+function give_email_tag_date($tag_args) {
730 730
 	$date = '';
731 731
 
732 732
 	// Backward compatibility.
733
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
733
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
734 734
 
735
-	switch ( true ) {
736
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
737
-			$payment = new Give_Payment( $tag_args['payment_id'] );
738
-			$date    = date_i18n( give_date_format(), strtotime( $payment->date ) );
735
+	switch (true) {
736
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
737
+			$payment = new Give_Payment($tag_args['payment_id']);
738
+			$date    = date_i18n(give_date_format(), strtotime($payment->date));
739 739
 			break;
740 740
 	}
741 741
 
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 	 * @param string $date
748 748
 	 * @param array  $tag_args
749 749
 	 */
750
-	$date = apply_filters( 'give_email_tag_date', $date, $tag_args );
750
+	$date = apply_filters('give_email_tag_date', $date, $tag_args);
751 751
 
752 752
 	return $date;
753 753
 }
@@ -761,17 +761,17 @@  discard block
 block discarded – undo
761 761
  *
762 762
  * @return string amount
763 763
  */
764
-function give_email_tag_amount( $tag_args ) {
764
+function give_email_tag_amount($tag_args) {
765 765
 	$amount = '';
766 766
 
767 767
 	// Backward compatibility.
768
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
768
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
769 769
 
770
-	switch ( true ) {
771
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
772
-			$payment     = new Give_Payment( $tag_args['payment_id'] );
773
-			$give_amount = give_currency_filter( give_format_amount( $payment->total, array( 'sanitize' => false ) ), array( 'currency_code' => $payment->currency ) );
774
-			$amount      = html_entity_decode( $give_amount, ENT_COMPAT, 'UTF-8' );
770
+	switch (true) {
771
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
772
+			$payment     = new Give_Payment($tag_args['payment_id']);
773
+			$give_amount = give_currency_filter(give_format_amount($payment->total, array('sanitize' => false)), array('currency_code' => $payment->currency));
774
+			$amount      = html_entity_decode($give_amount, ENT_COMPAT, 'UTF-8');
775 775
 			break;
776 776
 	}
777 777
 
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 	 * @param string $amount
784 784
 	 * @param array  $tag_args
785 785
 	 */
786
-	$amount = apply_filters( 'give_email_tag_amount', $amount, $tag_args );
786
+	$amount = apply_filters('give_email_tag_amount', $amount, $tag_args);
787 787
 
788 788
 	return $amount;
789 789
 }
@@ -797,8 +797,8 @@  discard block
 block discarded – undo
797 797
  *
798 798
  * @return string price
799 799
  */
800
-function give_email_tag_price( $tag_args ) {
801
-	return give_email_tag_amount( $tag_args );
800
+function give_email_tag_price($tag_args) {
801
+	return give_email_tag_amount($tag_args);
802 802
 }
803 803
 
804 804
 /**
@@ -810,15 +810,15 @@  discard block
 block discarded – undo
810 810
  *
811 811
  * @return int payment_id
812 812
  */
813
-function give_email_tag_payment_id( $tag_args ) {
813
+function give_email_tag_payment_id($tag_args) {
814 814
 	$payment_id = '';
815 815
 
816 816
 	// Backward compatibility.
817
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
817
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
818 818
 
819
-	switch ( true ) {
820
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
821
-			$payment    = new Give_Payment( $tag_args['payment_id'] );
819
+	switch (true) {
820
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
821
+			$payment    = new Give_Payment($tag_args['payment_id']);
822 822
 			$payment_id = $payment->number;
823 823
 			break;
824 824
 	}
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 	 * @param string $payment_id
832 832
 	 * @param array  $tag_args
833 833
 	 */
834
-	return apply_filters( 'give_email_tag_payment_id', $payment_id, $tag_args );
834
+	return apply_filters('give_email_tag_payment_id', $payment_id, $tag_args);
835 835
 }
836 836
 
837 837
 /**
@@ -843,15 +843,15 @@  discard block
 block discarded – undo
843 843
  *
844 844
  * @return string receipt_id
845 845
  */
846
-function give_email_tag_receipt_id( $tag_args ) {
846
+function give_email_tag_receipt_id($tag_args) {
847 847
 	$receipt_id = '';
848 848
 
849 849
 	// Backward compatibility.
850
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
850
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
851 851
 
852
-	switch ( true ) {
853
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
854
-			$payment    = new Give_Payment( $tag_args['payment_id'] );
852
+	switch (true) {
853
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
854
+			$payment    = new Give_Payment($tag_args['payment_id']);
855 855
 			$receipt_id = $payment->key;
856 856
 			break;
857 857
 	}
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 	 * @param string $receipt_id
865 865
 	 * @param array  $tag_args
866 866
 	 */
867
-	return apply_filters( 'give_email_tag_receipt_id', $receipt_id, $tag_args );
867
+	return apply_filters('give_email_tag_receipt_id', $receipt_id, $tag_args);
868 868
 }
869 869
 
870 870
 /**
@@ -876,23 +876,23 @@  discard block
 block discarded – undo
876 876
  *
877 877
  * @return string $form_title
878 878
  */
879
-function give_email_tag_donation( $tag_args ) {
879
+function give_email_tag_donation($tag_args) {
880 880
 	$donation_form_title = '';
881 881
 
882 882
 	// Backward compatibility.
883
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
883
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
884 884
 
885
-	switch ( true ) {
886
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
887
-			$payment             = new Give_Payment( $tag_args['payment_id'] );
888
-			$level_title         = give_has_variable_prices( $payment->form_id );
885
+	switch (true) {
886
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
887
+			$payment             = new Give_Payment($tag_args['payment_id']);
888
+			$level_title         = give_has_variable_prices($payment->form_id);
889 889
 			$separator           = $level_title ? '-' : '';
890
-			$donation_form_title = strip_tags( give_check_variable( give_get_donation_form_title(
890
+			$donation_form_title = strip_tags(give_check_variable(give_get_donation_form_title(
891 891
 				$payment,
892 892
 				array(
893 893
 					'separator' => $separator,
894 894
 				)
895
-			), 'empty', '' ) );
895
+			), 'empty', ''));
896 896
 			break;
897 897
 	}
898 898
 
@@ -920,17 +920,17 @@  discard block
 block discarded – undo
920 920
  *
921 921
  * @return string $form_title
922 922
  */
923
-function give_email_tag_form_title( $tag_args ) {
923
+function give_email_tag_form_title($tag_args) {
924 924
 	$donation_form_title = '';
925 925
 
926 926
 	// Backward compatibility.
927
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
927
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
928 928
 
929
-	switch ( true ) {
930
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
931
-			$payment             = new Give_Payment( $tag_args['payment_id'] );
929
+	switch (true) {
930
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
931
+			$payment             = new Give_Payment($tag_args['payment_id']);
932 932
 			$payment_meta        = $payment->payment_meta;
933
-			$donation_form_title = strip_tags( give_check_variable( $payment_meta, 'empty', '', 'form_title' ) );
933
+			$donation_form_title = strip_tags(give_check_variable($payment_meta, 'empty', '', 'form_title'));
934 934
 			break;
935 935
 	}
936 936
 
@@ -958,19 +958,19 @@  discard block
 block discarded – undo
958 958
  *
959 959
  * @return string gateway
960 960
  */
961
-function give_email_tag_payment_method( $tag_args ) {
961
+function give_email_tag_payment_method($tag_args) {
962 962
 	$payment_method = '';
963 963
 
964 964
 	// Backward compatibility.
965
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
965
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
966 966
 
967 967
 	// Backward compatibility.
968
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
968
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
969 969
 
970
-	switch ( true ) {
971
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
972
-			$payment        = new Give_Payment( $tag_args['payment_id'] );
973
-			$payment_method = give_get_gateway_checkout_label( $payment->gateway );
970
+	switch (true) {
971
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
972
+			$payment        = new Give_Payment($tag_args['payment_id']);
973
+			$payment_method = give_get_gateway_checkout_label($payment->gateway);
974 974
 			break;
975 975
 	}
976 976
 
@@ -1001,16 +1001,16 @@  discard block
 block discarded – undo
1001 1001
  *
1002 1002
  * @return string
1003 1003
  */
1004
-function give_email_tag_payment_total( $tag_args ) {
1004
+function give_email_tag_payment_total($tag_args) {
1005 1005
 	$payment_total = '';
1006 1006
 
1007 1007
 	// Backward compatibility.
1008
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
1008
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
1009 1009
 
1010
-	switch ( true ) {
1011
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
1012
-			$payment       = new Give_Payment( $tag_args['payment_id'] );
1013
-			$payment_total = give_currency_filter( $payment->total );
1010
+	switch (true) {
1011
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
1012
+			$payment       = new Give_Payment($tag_args['payment_id']);
1013
+			$payment_total = give_currency_filter($payment->total);
1014 1014
 			break;
1015 1015
 	}
1016 1016
 
@@ -1038,11 +1038,11 @@  discard block
 block discarded – undo
1038 1038
  *
1039 1039
  * @return string
1040 1040
  */
1041
-function give_email_tag_sitename( $tag_args = array() ) {
1042
-	$sitename = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
1041
+function give_email_tag_sitename($tag_args = array()) {
1042
+	$sitename = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
1043 1043
 
1044 1044
 	// Backward compatibility.
1045
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
1045
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
1046 1046
 
1047 1047
 	/**
1048 1048
 	 * Filter the {sitename} email template tag output.
@@ -1068,26 +1068,26 @@  discard block
 block discarded – undo
1068 1068
  *
1069 1069
  * @return string receipt_link
1070 1070
  */
1071
-function give_email_tag_receipt_link( $tag_args ) {
1071
+function give_email_tag_receipt_link($tag_args) {
1072 1072
 	// Backward compatibility.
1073
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
1073
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
1074 1074
 
1075
-	$receipt_url = give_get_receipt_url( give_check_variable( $tag_args, 'empty', 0, 'payment_id' ) );
1075
+	$receipt_url = give_get_receipt_url(give_check_variable($tag_args, 'empty', 0, 'payment_id'));
1076 1076
 
1077 1077
 	// Bailout.
1078
-	if ( give_get_option( 'email_template' ) === 'none' ) {
1078
+	if (give_get_option('email_template') === 'none') {
1079 1079
 		return $receipt_url;
1080 1080
 	}
1081 1081
 
1082 1082
 
1083
-	$receipt_url = esc_url( add_query_arg( array(
1084
-		'payment_key' => give_get_payment_key( $tag_args['payment_id'] ),
1085
-	), give_get_history_page_uri() ) );
1083
+	$receipt_url = esc_url(add_query_arg(array(
1084
+		'payment_key' => give_get_payment_key($tag_args['payment_id']),
1085
+	), give_get_history_page_uri()));
1086 1086
 
1087
-	$formatted   = sprintf(
1087
+	$formatted = sprintf(
1088 1088
 		'<a href="%1$s">%2$s</a>',
1089 1089
 		$receipt_url,
1090
-		__( 'View it in your browser &raquo;', 'give' )
1090
+		__('View it in your browser &raquo;', 'give')
1091 1091
 	);
1092 1092
 
1093 1093
 	/**
@@ -1116,11 +1116,11 @@  discard block
 block discarded – undo
1116 1116
  *
1117 1117
  * @return string receipt_url
1118 1118
  */
1119
-function give_email_tag_receipt_link_url( $tag_args ) {
1119
+function give_email_tag_receipt_link_url($tag_args) {
1120 1120
 	// Backward compatibility.
1121
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
1121
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
1122 1122
 
1123
-	$receipt_link_url = give_get_receipt_url( give_check_variable( $tag_args, 'empty', 0, 'payment_id' ) );
1123
+	$receipt_link_url = give_get_receipt_url(give_check_variable($tag_args, 'empty', 0, 'payment_id'));
1124 1124
 
1125 1125
 	/**
1126 1126
 	 * Filter the {receipt_link_url} email template tag output.
@@ -1147,13 +1147,13 @@  discard block
 block discarded – undo
1147 1147
  *
1148 1148
  * @return string
1149 1149
  */
1150
-function give_get_receipt_url( $payment_id ) {
1150
+function give_get_receipt_url($payment_id) {
1151 1151
 	$receipt_url = '';
1152 1152
 
1153
-	if ( $payment_id ) {
1154
-		$receipt_url = esc_url( add_query_arg( array(
1155
-			'payment_key' => give_get_payment_key( $payment_id ),
1156
-		), give_get_history_page_uri() ) );
1153
+	if ($payment_id) {
1154
+		$receipt_url = esc_url(add_query_arg(array(
1155
+			'payment_key' => give_get_payment_key($payment_id),
1156
+		), give_get_history_page_uri()));
1157 1157
 	}
1158 1158
 
1159 1159
 	return $receipt_url;
@@ -1169,22 +1169,22 @@  discard block
 block discarded – undo
1169 1169
  *
1170 1170
  * @return string
1171 1171
  */
1172
-function give_email_tag_email_access_link( $tag_args ) {
1172
+function give_email_tag_email_access_link($tag_args) {
1173 1173
 	$donor_id          = 0;
1174 1174
 	$donor             = array();
1175 1175
 	$email_access_link = '';
1176 1176
 
1177 1177
 	// Backward compatibility.
1178
-	$tag_args = __give_20_bc_str_type_email_tag_param( $tag_args );
1178
+	$tag_args = __give_20_bc_str_type_email_tag_param($tag_args);
1179 1179
 
1180
-	switch ( true ) {
1181
-		case ! empty( $tag_args['donor_id'] ):
1180
+	switch (true) {
1181
+		case ! empty($tag_args['donor_id']):
1182 1182
 			$donor_id = $tag_args['donor_id'];
1183
-			$donor    = Give()->donors->get_by( 'id', $tag_args['donor_id'] );
1183
+			$donor    = Give()->donors->get_by('id', $tag_args['donor_id']);
1184 1184
 			break;
1185 1185
 
1186
-		case ! empty( $tag_args['user_id'] ):
1187
-			$donor    = Give()->donors->get_by( 'user_id', $tag_args['user_id'] );
1186
+		case ! empty($tag_args['user_id']):
1187
+			$donor    = Give()->donors->get_by('user_id', $tag_args['user_id']);
1188 1188
 			$donor_id = $donor->id;
1189 1189
 			break;
1190 1190
 
@@ -1193,11 +1193,11 @@  discard block
 block discarded – undo
1193 1193
 	}
1194 1194
 
1195 1195
 	// Set email access link if donor exist.
1196
-	if ( $donor_id ) {
1197
-		$verify_key = wp_generate_password( 20, false );
1196
+	if ($donor_id) {
1197
+		$verify_key = wp_generate_password(20, false);
1198 1198
 
1199 1199
 		// Generate a new verify key
1200
-		Give()->email_access->set_verify_key( $donor_id, $donor->email, $verify_key );
1200
+		Give()->email_access->set_verify_key($donor_id, $donor->email, $verify_key);
1201 1201
 
1202 1202
 		$access_url = add_query_arg(
1203 1203
 			array(
@@ -1207,28 +1207,28 @@  discard block
 block discarded – undo
1207 1207
 		);
1208 1208
 
1209 1209
 		// Add Payment Key to email access url, if it exists.
1210
-		if ( ! empty( $_GET['payment_key'] ) ) {
1210
+		if ( ! empty($_GET['payment_key'])) {
1211 1211
 			$access_url = add_query_arg(
1212 1212
 				array(
1213
-					'payment_key' => give_clean( $_GET['payment_key'] ),
1213
+					'payment_key' => give_clean($_GET['payment_key']),
1214 1214
 				),
1215 1215
 				$access_url
1216 1216
 			);
1217 1217
 		}
1218 1218
 
1219
-		if ( empty( $tag_args['email_content_type'] ) || 'text/html' === $tag_args['email_content_type'] ) {
1219
+		if (empty($tag_args['email_content_type']) || 'text/html' === $tag_args['email_content_type']) {
1220 1220
 			$email_access_link = sprintf(
1221 1221
 				'<a href="%1$s" target="_blank">%2$s</a>',
1222
-				esc_url( $access_url ),
1223
-				__( 'View your donation history &raquo;', 'give' )
1222
+				esc_url($access_url),
1223
+				__('View your donation history &raquo;', 'give')
1224 1224
 			);
1225 1225
 
1226 1226
 		} else {
1227 1227
 
1228 1228
 			$email_access_link = sprintf(
1229 1229
 				'%1$s: %2$s',
1230
-				__( 'View your donation history', 'give' ),
1231
-				esc_url( $access_url )
1230
+				__('View your donation history', 'give'),
1231
+				esc_url($access_url)
1232 1232
 			);
1233 1233
 		}
1234 1234
 	}
@@ -1260,23 +1260,23 @@  discard block
 block discarded – undo
1260 1260
  *
1261 1261
  * @return array
1262 1262
  */
1263
-function __give_20_bc_str_type_email_tag_param( $tag_args ) {
1264
-	if ( ! is_array( $tag_args ) ) {
1265
-		switch ( true ) {
1266
-			case ( 'give_payment' === get_post_type( $tag_args ) ):
1267
-				$tag_args = array( 'payment_id' => $tag_args );
1263
+function __give_20_bc_str_type_email_tag_param($tag_args) {
1264
+	if ( ! is_array($tag_args)) {
1265
+		switch (true) {
1266
+			case ('give_payment' === get_post_type($tag_args)):
1267
+				$tag_args = array('payment_id' => $tag_args);
1268 1268
 				break;
1269 1269
 
1270
-			case ( ! is_wp_error( get_user_by( 'id', $tag_args ) ) ):
1271
-				$tag_args = array( 'user_id' => $tag_args );
1270
+			case ( ! is_wp_error(get_user_by('id', $tag_args))):
1271
+				$tag_args = array('user_id' => $tag_args);
1272 1272
 				break;
1273 1273
 
1274
-			case ( Give()->donors->get_by( 'id', $tag_args ) ):
1275
-				$tag_args = array( 'donor_id' => $tag_args );
1274
+			case (Give()->donors->get_by('id', $tag_args)):
1275
+				$tag_args = array('donor_id' => $tag_args);
1276 1276
 				break;
1277 1277
 
1278
-			case ( Give()->donors->get_by( 'user_id', $tag_args ) ):
1279
-				$tag_args = array( 'user_id' => $tag_args );
1278
+			case (Give()->donors->get_by('user_id', $tag_args)):
1279
+				$tag_args = array('user_id' => $tag_args);
1280 1280
 				break;
1281 1281
 		}
1282 1282
 	}
@@ -1294,39 +1294,39 @@  discard block
 block discarded – undo
1294 1294
  *
1295 1295
  * @return array
1296 1296
  */
1297
-function give_email_tag_reset_password_link( $tag_args, $payment_id ) {
1297
+function give_email_tag_reset_password_link($tag_args, $payment_id) {
1298 1298
 
1299 1299
 	$reset_password_url = '';
1300 1300
 
1301
-	switch ( true ) {
1302
-		case give_check_variable( $tag_args, 'isset', 0, 'payment_id' ):
1303
-			$payment    = new Give_Payment( $tag_args['payment_id'] );
1301
+	switch (true) {
1302
+		case give_check_variable($tag_args, 'isset', 0, 'payment_id'):
1303
+			$payment    = new Give_Payment($tag_args['payment_id']);
1304 1304
 			$payment_id = $payment->number;
1305 1305
 			break;
1306 1306
 
1307
-		case give_check_variable( $tag_args, 'isset', 0, 'user_id' ):
1308
-			$reset_password_url = give_get_reset_password_url( $tag_args['user_id'] );
1307
+		case give_check_variable($tag_args, 'isset', 0, 'user_id'):
1308
+			$reset_password_url = give_get_reset_password_url($tag_args['user_id']);
1309 1309
 			break;
1310 1310
 
1311
-		case give_check_variable( $tag_args, 'isset', 0, 'donor_id' ):
1311
+		case give_check_variable($tag_args, 'isset', 0, 'donor_id'):
1312 1312
 			/* @var Give_Donor $donor */
1313
-			$donor = new Give_Donor( $tag_args['user_id'], true );
1314
-			$reset_password_url = give_get_reset_password_url( $donor->user_id );
1313
+			$donor = new Give_Donor($tag_args['user_id'], true);
1314
+			$reset_password_url = give_get_reset_password_url($donor->user_id);
1315 1315
 			break;
1316 1316
 	}
1317 1317
 
1318
-	if( empty( $tag_args['email_content_type'] ) || 'text/html' === $tag_args['email_content_type'] ) {
1318
+	if (empty($tag_args['email_content_type']) || 'text/html' === $tag_args['email_content_type']) {
1319 1319
 		// Generate link, if Email content type is html.
1320 1320
 		$reset_password_link = sprintf(
1321 1321
 			'<a href="%1$s" target="_blank">%2$s</a>',
1322
-			esc_url( $reset_password_url ),
1323
-			__( 'Reset your password &raquo;', 'give' )
1322
+			esc_url($reset_password_url),
1323
+			__('Reset your password &raquo;', 'give')
1324 1324
 		);
1325
-	} else{
1325
+	} else {
1326 1326
 		$reset_password_link = sprintf(
1327 1327
 			'%1$s: %2$s',
1328
-			__( 'Reset your password', 'give' ),
1329
-			esc_url( $reset_password_url )
1328
+			__('Reset your password', 'give'),
1329
+			esc_url($reset_password_url)
1330 1330
 		);
1331 1331
 	}
1332 1332
 
@@ -1355,21 +1355,21 @@  discard block
 block discarded – undo
1355 1355
  *
1356 1356
  * @return mixed|string
1357 1357
  */
1358
-function give_get_reset_password_url( $user_id ) {
1358
+function give_get_reset_password_url($user_id) {
1359 1359
 	$reset_password_url = '';
1360 1360
 
1361 1361
 	// Proceed further only, if user_id exists.
1362
-	if ( $user_id ) {
1362
+	if ($user_id) {
1363 1363
 
1364 1364
 		// Get User Object Details.
1365
-		$user = get_user_by( 'ID', $user_id );
1365
+		$user = get_user_by('ID', $user_id);
1366 1366
 
1367 1367
 		// Prepare Reset Password URL.
1368
-		$reset_password_url = esc_url( add_query_arg( array(
1368
+		$reset_password_url = esc_url(add_query_arg(array(
1369 1369
 			'action' => 'rp',
1370
-			'key' => get_password_reset_key( $user ),
1370
+			'key' => get_password_reset_key($user),
1371 1371
 			'login' => $user->user_login,
1372
-		), wp_login_url() ) );
1372
+		), wp_login_url()));
1373 1373
 	}
1374 1374
 
1375 1375
 	return $reset_password_url;
@@ -1388,91 +1388,91 @@  discard block
 block discarded – undo
1388 1388
  *
1389 1389
  * @return mixed
1390 1390
  */
1391
-function __give_render_metadata_email_tag( $content, $tag_args ) {
1392
-	preg_match_all( "/{meta_([A-z0-9\-\_\ ]+)}/s", $content, $matches );
1391
+function __give_render_metadata_email_tag($content, $tag_args) {
1392
+	preg_match_all("/{meta_([A-z0-9\-\_\ ]+)}/s", $content, $matches);
1393 1393
 
1394
-	if ( ! empty( $matches[0] ) ) {
1394
+	if ( ! empty($matches[0])) {
1395 1395
 		$search = $replace = array();
1396
-		foreach ( $matches[0] as $index => $meta_tag ) {
1397
-			if ( in_array( $meta_tag, $search ) ) {
1396
+		foreach ($matches[0] as $index => $meta_tag) {
1397
+			if (in_array($meta_tag, $search)) {
1398 1398
 				continue;
1399 1399
 			}
1400 1400
 
1401 1401
 			$search[] = $meta_tag;
1402 1402
 
1403
-			$meta_tag     = str_replace( array( '{', 'meta_', '}' ), '', $meta_tag );
1404
-			$meta_tag_arr = array_map( 'trim', explode( ' ', $meta_tag, 2 ) );
1405
-			$meta_tag     = current( $meta_tag_arr );
1403
+			$meta_tag     = str_replace(array('{', 'meta_', '}'), '', $meta_tag);
1404
+			$meta_tag_arr = array_map('trim', explode(' ', $meta_tag, 2));
1405
+			$meta_tag     = current($meta_tag_arr);
1406 1406
 
1407
-			$meta_tag  = str_replace( array( '{', 'meta_', '}' ), '', $meta_tag );
1408
-			$type      = current( explode( '_', $meta_tag, 2 ) );
1409
-			$meta_name = preg_replace( "/^{$type}_/", '', $meta_tag );
1407
+			$meta_tag  = str_replace(array('{', 'meta_', '}'), '', $meta_tag);
1408
+			$type      = current(explode('_', $meta_tag, 2));
1409
+			$meta_name = preg_replace("/^{$type}_/", '', $meta_tag);
1410 1410
 
1411
-			switch ( $type ) {
1411
+			switch ($type) {
1412 1412
 				case 'donation':
1413 1413
 
1414 1414
 					//Bailout.
1415
-					if ( ! isset( $tag_args['payment_id'] ) ) {
1415
+					if ( ! isset($tag_args['payment_id'])) {
1416 1416
 						$replace[] = '';
1417 1417
 						continue;
1418 1418
 					}
1419 1419
 
1420
-					$meta_data = give_get_meta( absint( $tag_args['payment_id'] ), $meta_name, true, '' );
1420
+					$meta_data = give_get_meta(absint($tag_args['payment_id']), $meta_name, true, '');
1421 1421
 
1422
-					if ( ! isset( $meta_tag_arr[1] ) || ! is_array( $meta_data ) ) {
1422
+					if ( ! isset($meta_tag_arr[1]) || ! is_array($meta_data)) {
1423 1423
 						$replace[] = $meta_data;
1424
-					} elseif ( in_array( $meta_tag_arr[1], array_keys( $meta_data ) ) ) {
1425
-						$replace[] = $meta_data[ $meta_tag_arr[1] ];
1424
+					} elseif (in_array($meta_tag_arr[1], array_keys($meta_data))) {
1425
+						$replace[] = $meta_data[$meta_tag_arr[1]];
1426 1426
 					}
1427 1427
 
1428 1428
 					break;
1429 1429
 
1430 1430
 				case 'form':
1431
-					$form_id = isset( $tag_args['form_id'] ) ? absint( $tag_args['form_id'] ) : 0;
1431
+					$form_id = isset($tag_args['form_id']) ? absint($tag_args['form_id']) : 0;
1432 1432
 
1433 1433
 					// Bailout.
1434
-					if ( ! $form_id && isset( $tag_args['payment_id'] ) ) {
1435
-						$form_id = give_get_payment_form_id( $tag_args['payment_id'] );
1434
+					if ( ! $form_id && isset($tag_args['payment_id'])) {
1435
+						$form_id = give_get_payment_form_id($tag_args['payment_id']);
1436 1436
 					}
1437 1437
 
1438
-					$meta_data = give_get_meta( $form_id, $meta_name, true, '' );
1439
-					if ( ! isset( $meta_tag_arr[1] ) || ! is_array( $meta_data ) ) {
1438
+					$meta_data = give_get_meta($form_id, $meta_name, true, '');
1439
+					if ( ! isset($meta_tag_arr[1]) || ! is_array($meta_data)) {
1440 1440
 						$replace[] = $meta_data;
1441
-					} elseif ( in_array( $meta_tag_arr[1], array_keys( $meta_data ) ) ) {
1442
-						$replace[] = $meta_data[ $meta_tag_arr[1] ];
1441
+					} elseif (in_array($meta_tag_arr[1], array_keys($meta_data))) {
1442
+						$replace[] = $meta_data[$meta_tag_arr[1]];
1443 1443
 					}
1444 1444
 					break;
1445 1445
 
1446 1446
 				case 'donor':
1447
-					$donor_id = isset( $tag_args['donor_id'] ) ? absint( $tag_args['donor_id'] ) : 0;
1447
+					$donor_id = isset($tag_args['donor_id']) ? absint($tag_args['donor_id']) : 0;
1448 1448
 
1449 1449
 					// Bailout.
1450
-					if ( ! $donor_id ) {
1451
-						if ( isset( $tag_args['payment_id'] ) ) {
1452
-							$donor_id = give_get_payment_donor_id( $tag_args['payment_id'] );
1453
-						} elseif ( isset( $tag_args['user_id'] ) ) {
1454
-							$donor    = new Give_Donor( $tag_args['user_id'], true );
1450
+					if ( ! $donor_id) {
1451
+						if (isset($tag_args['payment_id'])) {
1452
+							$donor_id = give_get_payment_donor_id($tag_args['payment_id']);
1453
+						} elseif (isset($tag_args['user_id'])) {
1454
+							$donor    = new Give_Donor($tag_args['user_id'], true);
1455 1455
 							$donor_id = $donor->ID;
1456 1456
 						}
1457 1457
 					}
1458 1458
 
1459
-					$donor     = new Give_Donor( $donor_id );
1460
-					$meta_data = $donor->get_meta( $meta_name );
1461
-					if ( ! isset( $meta_tag_arr[1] ) || ! is_array( $meta_data ) ) {
1459
+					$donor     = new Give_Donor($donor_id);
1460
+					$meta_data = $donor->get_meta($meta_name);
1461
+					if ( ! isset($meta_tag_arr[1]) || ! is_array($meta_data)) {
1462 1462
 						$replace[] = $meta_data;
1463
-					} elseif ( in_array( $meta_tag_arr[1], array_keys(  $meta_data ) ) ) {
1464
-						$replace[] = $meta_data[ $meta_tag_arr[1] ];
1463
+					} elseif (in_array($meta_tag_arr[1], array_keys($meta_data))) {
1464
+						$replace[] = $meta_data[$meta_tag_arr[1]];
1465 1465
 					}
1466 1466
 
1467 1467
 					break;
1468 1468
 
1469 1469
 				default:
1470
-					$replace[] = end( $search );
1470
+					$replace[] = end($search);
1471 1471
 			}
1472 1472
 		}
1473 1473
 
1474
-		if ( ! empty( $search ) && ! empty( $replace ) ) {
1475
-			$content = str_replace( $search, $replace, $content );
1474
+		if ( ! empty($search) && ! empty($replace)) {
1475
+			$content = str_replace($search, $replace, $content);
1476 1476
 		}
1477 1477
 	}
1478 1478
 
@@ -1480,4 +1480,4 @@  discard block
 block discarded – undo
1480 1480
 	return $content;
1481 1481
 }
1482 1482
 
1483
-add_filter( 'give_email_template_tags', '__give_render_metadata_email_tag', 10, 2 );
1483
+add_filter('give_email_template_tags', '__give_render_metadata_email_tag', 10, 2);
Please login to merge, or discard this patch.
includes/emails/functions.php 1 patch
Spacing   +71 added lines, -71 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,16 +26,16 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return void
28 28
  */
29
-function give_email_donation_receipt( $payment_id, $admin_notice = true ) {
30
-	$payment = new Give_Payment( $payment_id );
29
+function give_email_donation_receipt($payment_id, $admin_notice = true) {
30
+	$payment = new Give_Payment($payment_id);
31 31
 
32 32
 	/**
33 33
 	 * Fire the action
34 34
 	 */
35
-	do_action( 'give_donation-receipt_email_notification', $payment_id );
35
+	do_action('give_donation-receipt_email_notification', $payment_id);
36 36
 
37 37
 	// If admin notifications are on, send the admin notice.
38
-	if ( $admin_notice && give_is_setting_enabled( Give_Email_Notification::get_instance('new-donation' )->get_notification_status() ) ) {
38
+	if ($admin_notice && give_is_setting_enabled(Give_Email_Notification::get_instance('new-donation')->get_notification_status())) {
39 39
 		/**
40 40
 		 * Fires in the donation email receipt.
41 41
 		 *
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		 * @param int   $payment_id   Payment id.
47 47
 		 * @param mixed $payment_data Payment meta data.
48 48
 		 */
49
-		do_action( 'give_new-donation_email_notification', $payment_id, $payment->payment_meta );
49
+		do_action('give_new-donation_email_notification', $payment_id, $payment->payment_meta);
50 50
 	}
51 51
 }
52 52
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  *
60 60
  * @return void
61 61
  */
62
-function give_admin_email_notice( $payment_id ) {
62
+function give_admin_email_notice($payment_id) {
63 63
 	/**
64 64
 	 * Fires in the donation email receipt.
65 65
 	 *
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
 	 * @param int   $payment_id   Payment id.
71 71
 	 * @param mixed $payment_data Payment meta data.
72 72
 	 */
73
-	do_action( 'give_new-donation_email_notification', $payment_id );
73
+	do_action('give_new-donation_email_notification', $payment_id);
74 74
 }
75 75
 
76
-add_action( 'give_admin_donation_email', 'give_admin_email_notice' );
76
+add_action('give_admin_donation_email', 'give_admin_email_notice');
77 77
 
78 78
 
79 79
 /**
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
  */
87 87
 function give_get_default_donation_notification_email() {
88 88
 
89
-	$default_email_body = __( 'Hi there,', 'give' ) . "\n\n";
90
-	$default_email_body .= __( '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";
91
-	$default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {name}' . "\n";
92
-	$default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
93
-	$default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
94
-	$default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n";
95
-	$default_email_body .= __( 'Thank you,', 'give' ) . "\n\n";
96
-	$default_email_body .= '{sitename}' . "\n";
89
+	$default_email_body = __('Hi there,', 'give')."\n\n";
90
+	$default_email_body .= __('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";
91
+	$default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {name}'."\n";
92
+	$default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n";
93
+	$default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n";
94
+	$default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n";
95
+	$default_email_body .= __('Thank you,', 'give')."\n\n";
96
+	$default_email_body .= '{sitename}'."\n";
97 97
 
98
-	return apply_filters( 'give_default_donation_notification_email', $default_email_body );
98
+	return apply_filters('give_default_donation_notification_email', $default_email_body);
99 99
 }
100 100
 
101 101
 
@@ -109,21 +109,21 @@  discard block
 block discarded – undo
109 109
  */
110 110
 function give_get_default_donation_receipt_email() {
111 111
 
112
-	$default_email_body = __( 'Dear', 'give' ) . " {name},\n\n";
113
-	$default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n";
114
-	$default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
115
-	$default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
116
-	$default_email_body .= '<strong>' . __( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n";
117
-	$default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
118
-	$default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n";
119
-	$default_email_body .= '<strong>' . __( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n";
120
-	$default_email_body .= '<strong>' . __( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n";
121
-	$default_email_body .= '{receipt_link}' . "\n\n";
112
+	$default_email_body = __('Dear', 'give')." {name},\n\n";
113
+	$default_email_body .= __('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n";
114
+	$default_email_body .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n";
115
+	$default_email_body .= '<strong>'.__('Donation:', 'give').'</strong> {donation}'."\n";
116
+	$default_email_body .= '<strong>'.__('Donation Date:', 'give').'</strong> {date}'."\n";
117
+	$default_email_body .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n";
118
+	$default_email_body .= '<strong>'.__('Payment Method:', 'give').'</strong> {payment_method}'."\n";
119
+	$default_email_body .= '<strong>'.__('Payment ID:', 'give').'</strong> {payment_id}'."\n";
120
+	$default_email_body .= '<strong>'.__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n";
121
+	$default_email_body .= '{receipt_link}'."\n\n";
122 122
 	$default_email_body .= "\n\n";
123
-	$default_email_body .= __( 'Sincerely,', 'give' ) . "\n";
124
-	$default_email_body .= '{sitename}' . "\n";
123
+	$default_email_body .= __('Sincerely,', 'give')."\n";
124
+	$default_email_body .= '{sitename}'."\n";
125 125
 
126
-	return apply_filters( 'give_default_donation_receipt_email', $default_email_body );
126
+	return apply_filters('give_default_donation_receipt_email', $default_email_body);
127 127
 }
128 128
 
129 129
 /**
@@ -136,22 +136,22 @@  discard block
 block discarded – undo
136 136
  *
137 137
  * @return array $email_names
138 138
  */
139
-function give_get_email_names( $user_info, $payment = false ) {
139
+function give_get_email_names($user_info, $payment = false) {
140 140
 	$email_names = array();
141 141
 
142
-	if ( is_a( $payment, 'Give_Payment' ) ) {
142
+	if (is_a($payment, 'Give_Payment')) {
143 143
 
144
-		if ( $payment->user_id > 0 ) {
144
+		if ($payment->user_id > 0) {
145 145
 
146
-			$user_data               = get_userdata( $payment->user_id );
146
+			$user_data               = get_userdata($payment->user_id);
147 147
 			$email_names['name']     = $payment->first_name;
148
-			$email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
148
+			$email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name);
149 149
 			$email_names['username'] = $user_data->user_login;
150 150
 
151
-		} elseif ( ! empty( $payment->first_name ) ) {
151
+		} elseif ( ! empty($payment->first_name)) {
152 152
 
153 153
 			$email_names['name']     = $payment->first_name;
154
-			$email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
154
+			$email_names['fullname'] = trim($payment->first_name.' '.$payment->last_name);
155 155
 			$email_names['username'] = $payment->first_name;
156 156
 
157 157
 		} else {
@@ -164,30 +164,30 @@  discard block
 block discarded – undo
164 164
 	} else {
165 165
 
166 166
 		// Support for old serialized data.
167
-		if ( is_serialized( $user_info ) ) {
167
+		if (is_serialized($user_info)) {
168 168
 
169 169
 			// Security check.
170
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
171
-			if ( ! empty( $matches ) ) {
170
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches);
171
+			if ( ! empty($matches)) {
172 172
 				return array(
173 173
 					'name'     => '',
174 174
 					'fullname' => '',
175 175
 					'username' => '',
176 176
 				);
177 177
 			} else {
178
-				$user_info = maybe_unserialize( $user_info );
178
+				$user_info = maybe_unserialize($user_info);
179 179
 			}
180 180
 
181 181
 		}
182 182
 
183
-		if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) {
184
-			$user_data               = get_userdata( $user_info['id'] );
183
+		if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) {
184
+			$user_data               = get_userdata($user_info['id']);
185 185
 			$email_names['name']     = $user_info['first_name'];
186
-			$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
186
+			$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
187 187
 			$email_names['username'] = $user_data->user_login;
188
-		} elseif ( isset( $user_info['first_name'] ) ) {
188
+		} elseif (isset($user_info['first_name'])) {
189 189
 			$email_names['name']     = $user_info['first_name'];
190
-			$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
190
+			$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
191 191
 			$email_names['username'] = $user_info['first_name'];
192 192
 		} else {
193 193
 			$email_names['name']     = $user_info['email'];
@@ -207,37 +207,37 @@  discard block
 block discarded – undo
207 207
  *
208 208
  * @since 1.8.14
209 209
  */
210
-function give_admin_email_user_donor_disconnection( $user_id, $donor_id ) {
210
+function give_admin_email_user_donor_disconnection($user_id, $donor_id) {
211 211
 
212
-	$user_id  = absint( $user_id );
213
-	$donor_id = absint( $donor_id );
212
+	$user_id  = absint($user_id);
213
+	$donor_id = absint($donor_id);
214 214
 
215 215
 	// Bail Out, if user id doesn't exists.
216
-	if ( empty( $user_id ) ) {
216
+	if (empty($user_id)) {
217 217
 		return;
218 218
 	}
219 219
 
220 220
 	// Bail Out, if donor id doesn't exists.
221
-	if ( empty( $donor_id ) ) {
221
+	if (empty($donor_id)) {
222 222
 		return;
223 223
 	}
224 224
 
225
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
225
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
226 226
 
227
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
227
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
228 228
 
229 229
 	/* translators: %s: payment id */
230
-	$subject = __( 'Attention: User tries to login whose Donor profile is disconnected!', 'give' );
230
+	$subject = __('Attention: User tries to login whose Donor profile is disconnected!', 'give');
231 231
 
232 232
 	/**
233 233
 	 * Filters the Donor-User Disconnection notification subject.
234 234
 	 *
235 235
 	 * @since 1.8.14
236 236
 	 */
237
-	$subject = apply_filters( 'give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags( $subject ) );
237
+	$subject = apply_filters('give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags($subject));
238 238
 
239
-	$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
240
-	$headers .= "Reply-To: " . $from_email . "\r\n";
239
+	$headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n";
240
+	$headers .= "Reply-To: ".$from_email."\r\n";
241 241
 	$headers .= "Content-Type: text/html; charset=utf-8\r\n";
242 242
 
243 243
 	/**
@@ -245,25 +245,25 @@  discard block
 block discarded – undo
245 245
 	 *
246 246
 	 * @since 1.8.14
247 247
 	 */
248
-	$headers = apply_filters( 'give_admin_donor_user_disconnection_notification_headers', $headers );
248
+	$headers = apply_filters('give_admin_donor_user_disconnection_notification_headers', $headers);
249 249
 
250
-	$message = __( 'Hi Admin,', 'give' ) . "\n\n";
251
-	$message .= __( 'This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give' ) . "\n\n";
252
-	$message .= __( 'Do you want to reconnect User and Donor profile again?', 'give' ) . "\n\n";
250
+	$message = __('Hi Admin,', 'give')."\n\n";
251
+	$message .= __('This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give')."\n\n";
252
+	$message .= __('Do you want to reconnect User and Donor profile again?', 'give')."\n\n";
253 253
 	$message .= sprintf(
254 254
 		'<a href="%1$s">%2$s</a>',
255
-		esc_url( admin_url() . 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&user_id=' . $user_id . '&give-message=reconnect-user' ),
256
-		__( 'Reconnect User', 'give' ) . "\n\n"
255
+		esc_url(admin_url().'edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&user_id='.$user_id.'&give-message=reconnect-user'),
256
+		__('Reconnect User', 'give')."\n\n"
257 257
 	);
258
-	$message .= __( 'Thank you,', 'give' ) . "\n\n";
259
-	$message .= '{sitename}' . "\n";
258
+	$message .= __('Thank you,', 'give')."\n\n";
259
+	$message .= '{sitename}'."\n";
260 260
 
261 261
 	$emails = Give()->emails;
262
-	$emails->__set( 'from_name', $from_name );
263
-	$emails->__set( 'from_email', $from_email );
264
-	$emails->__set( 'headers', $headers );
265
-	$emails->__set( 'heading', __( 'User - Donor Profile Disconnection', 'give' ) );
262
+	$emails->__set('from_name', $from_name);
263
+	$emails->__set('from_email', $from_email);
264
+	$emails->__set('headers', $headers);
265
+	$emails->__set('heading', __('User - Donor Profile Disconnection', 'give'));
266 266
 
267
-	$emails->send( give_get_admin_notice_emails(), $subject, give_do_email_tags( $message ) );
267
+	$emails->send(give_get_admin_notice_emails(), $subject, give_do_email_tags($message));
268 268
 
269 269
 }
Please login to merge, or discard this patch.