Test Failed
Pull Request — master (#2289)
by
unknown
04:37
created
includes/admin/donors/class-donor-table.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -258,7 +258,7 @@
 block discarded – undo
258 258
 	 * @access public
259 259
 	 * @since  1.0
260 260
 	 *
261
-	 * @return mixed string If search is present, false otherwise.
261
+	 * @return string|false string If search is present, false otherwise.
262 262
 	 */
263 263
 	public function get_search() {
264 264
 		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 // Load WP_List_Table if not loaded.
20
-if ( ! class_exists( 'WP_List_Table' ) ) {
21
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
20
+if ( ! class_exists('WP_List_Table')) {
21
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
22 22
 }
23 23
 
24 24
 /**
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 	public function __construct() {
62 62
 
63 63
 		// Set parent defaults.
64
-		parent::__construct( array(
65
-			'singular' => __( 'Donor', 'give' ), // Singular name of the listed records.
66
-			'plural'   => __( 'Donors', 'give' ), // Plural name of the listed records.
64
+		parent::__construct(array(
65
+			'singular' => __('Donor', 'give'), // Singular name of the listed records.
66
+			'plural'   => __('Donors', 'give'), // Plural name of the listed records.
67 67
 			'ajax'     => false, // Does this table support ajax?.
68
-		) );
68
+		));
69 69
 
70 70
 	}
71 71
 
@@ -80,23 +80,23 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return void
82 82
 	 */
83
-	public function search_box( $text, $input_id ) {
84
-		$input_id = $input_id . '-search-input';
83
+	public function search_box($text, $input_id) {
84
+		$input_id = $input_id.'-search-input';
85 85
 
86
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
87
-			echo sprintf( '<input type="hidden" name="orderby" value="%1$s" />', esc_attr( $_REQUEST['orderby'] ) );
86
+		if ( ! empty($_REQUEST['orderby'])) {
87
+			echo sprintf('<input type="hidden" name="orderby" value="%1$s" />', esc_attr($_REQUEST['orderby']));
88 88
 		}
89 89
 
90
-		if ( ! empty( $_REQUEST['order'] ) ) {
91
-			echo sprintf( '<input type="hidden" name="order" value="%1$s" />', esc_attr( $_REQUEST['order'] ) );
90
+		if ( ! empty($_REQUEST['order'])) {
91
+			echo sprintf('<input type="hidden" name="order" value="%1$s" />', esc_attr($_REQUEST['order']));
92 92
 		}
93 93
 		?>
94 94
 		<p class="search-box" role="search">
95 95
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
96 96
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
97
-			<?php submit_button( $text, 'button', false, false, array(
97
+			<?php submit_button($text, 'button', false, false, array(
98 98
 				'ID' => 'search-submit',
99
-			) ); ?>
99
+			)); ?>
100 100
 		</p>
101 101
 		<?php
102 102
 	}
@@ -112,31 +112,31 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @return string Column Name.
114 114
 	 */
115
-	public function column_default( $donor, $column_name ) {
116
-		switch ( $column_name ) {
115
+	public function column_default($donor, $column_name) {
116
+		switch ($column_name) {
117 117
 
118 118
 			case 'num_donations' :
119 119
 				$value = sprintf(
120 120
 					'<a href="%s">%s</a>',
121
-					admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor['id'] ) ),
122
-					esc_html( $donor['num_donations'] )
121
+					admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor['id'])),
122
+					esc_html($donor['num_donations'])
123 123
 				);
124 124
 				break;
125 125
 
126 126
 			case 'amount_spent' :
127
-				$value = give_currency_filter( give_format_amount( $donor[ $column_name ], array( 'sanitize' => false ) ) );
127
+				$value = give_currency_filter(give_format_amount($donor[$column_name], array('sanitize' => false)));
128 128
 				break;
129 129
 
130 130
 			case 'date_created' :
131
-				$value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) );
131
+				$value = date_i18n(give_date_format(), strtotime($donor['date_created']));
132 132
 				break;
133 133
 
134 134
 			default:
135
-				$value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null;
135
+				$value = isset($donor[$column_name]) ? $donor[$column_name] : null;
136 136
 				break;
137 137
 		}
138 138
 
139
-		return apply_filters( "give_donors_column_{$column_name}", $value, $donor['id'] );
139
+		return apply_filters("give_donors_column_{$column_name}", $value, $donor['id']);
140 140
 
141 141
 	}
142 142
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @return string
152 152
 	 */
153
-	public function column_cb( $donor ){
153
+	public function column_cb($donor) {
154 154
 		return sprintf(
155 155
 			'<input type="checkbox" name="%1$s[]" value="%2$s" />',
156 156
 			$this->_args['singular'],
@@ -168,13 +168,13 @@  discard block
 block discarded – undo
168 168
 	 *
169 169
 	 * @return string
170 170
 	 */
171
-	public function column_name( $donor ) {
172
-		$name     = '#' . $donor['id'] . ' ';
173
-		$name     .= ! empty( $donor['name'] ) ? $donor['name'] : '<em>' . __( 'Unnamed Donor', 'give' ) . '</em>';
174
-		$view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] );
175
-		$actions  = $this->get_row_actions( $donor );
171
+	public function column_name($donor) {
172
+		$name     = '#'.$donor['id'].' ';
173
+		$name .= ! empty($donor['name']) ? $donor['name'] : '<em>'.__('Unnamed Donor', 'give').'</em>';
174
+		$view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']);
175
+		$actions  = $this->get_row_actions($donor);
176 176
 
177
-		return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions );
177
+		return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions);
178 178
 	}
179 179
 
180 180
 	/**
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
 	public function get_columns() {
189 189
 		$columns = array(
190 190
 			'cb'            => '<input type="checkbox" />', // Render a checkbox instead of text.
191
-			'name'          => __( 'Name', 'give' ),
192
-			'email'         => __( 'Email', 'give' ),
193
-			'num_donations' => __( 'Donations', 'give' ),
194
-			'amount_spent'  => __( 'Total Donated', 'give' ),
195
-			'date_created'  => __( 'Date Created', 'give' ),
191
+			'name'          => __('Name', 'give'),
192
+			'email'         => __('Email', 'give'),
193
+			'num_donations' => __('Donations', 'give'),
194
+			'amount_spent'  => __('Total Donated', 'give'),
195
+			'date_created'  => __('Date Created', 'give'),
196 196
 		);
197 197
 
198
-		return apply_filters( 'give_list_donors_columns', $columns );
198
+		return apply_filters('give_list_donors_columns', $columns);
199 199
 
200 200
 	}
201 201
 
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
 	public function get_sortable_columns() {
210 210
 
211 211
 		$columns = array(
212
-			'date_created'  => array( 'date_created', true ),
213
-			'name'          => array( 'name', true ),
214
-			'num_donations' => array( 'purchase_count', false ),
215
-			'amount_spent'  => array( 'purchase_value', false ),
212
+			'date_created'  => array('date_created', true),
213
+			'name'          => array('name', true),
214
+			'num_donations' => array('purchase_count', false),
215
+			'amount_spent'  => array('purchase_value', false),
216 216
 		);
217 217
 
218
-		return apply_filters( 'give_list_donors_sortable_columns', $columns );
218
+		return apply_filters('give_list_donors_sortable_columns', $columns);
219 219
 	}
220 220
 
221 221
 	/**
@@ -228,15 +228,15 @@  discard block
 block discarded – undo
228 228
 	 *
229 229
 	 * @return array An array of action links.
230 230
 	 */
231
-	public function get_row_actions( $donor ) {
231
+	public function get_row_actions($donor) {
232 232
 
233 233
 		$actions = array(
234
-			'view'   => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ),
235
-			'notes'  => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ),
236
-			'delete' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor['id'] ), sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ),
234
+			'view'   => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']), sprintf(esc_attr__('View "%s"', 'give'), $donor['name']), __('View Donor', 'give')),
235
+			'notes'  => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor['id']), sprintf(esc_attr__('Notes for "%s"', 'give'), $donor['name']), __('Notes', 'give')),
236
+			'delete' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor['id']), sprintf(esc_attr__('Delete "%s"', 'give'), $donor['name']), __('Delete', 'give')),
237 237
 		);
238 238
 
239
-		return apply_filters( 'give_donor_row_actions', $actions, $donor );
239
+		return apply_filters('give_donor_row_actions', $actions, $donor);
240 240
 
241 241
 	}
242 242
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	 * @return int Current page number.
250 250
 	 */
251 251
 	public function get_paged() {
252
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
252
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
253 253
 	}
254 254
 
255 255
 	/**
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @return mixed string If search is present, false otherwise.
262 262
 	 */
263 263
 	public function get_search() {
264
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
264
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
265 265
 	}
266 266
 
267 267
 	/**
@@ -288,32 +288,32 @@  discard block
 block discarded – undo
288 288
 	 * @return void
289 289
 	 */
290 290
 	public function process_bulk_action() {
291
-		$ids    = isset( $_GET['donor'] ) ? $_GET['donor'] : false;
291
+		$ids    = isset($_GET['donor']) ? $_GET['donor'] : false;
292 292
 		$action = $this->current_action();
293 293
 
294
-		if ( ! is_array( $ids ) ) {
295
-			$ids = array( $ids );
294
+		if ( ! is_array($ids)) {
295
+			$ids = array($ids);
296 296
 		}
297 297
 
298 298
 		// Bail Out, If Action is not set.
299
-		if ( empty( $action ) ) {
299
+		if (empty($action)) {
300 300
 			return;
301 301
 		}
302 302
 
303
-		foreach ( $ids as $id ) {
303
+		foreach ($ids as $id) {
304 304
 
305 305
 			// Detect when a bulk action is being triggered.
306
-			switch ( $this->current_action() ) {
306
+			switch ($this->current_action()) {
307 307
 
308 308
 				case 'delete':
309 309
 					$args = array(
310
-						'_wpnonce'                  => wp_create_nonce( 'delete-donor' ),
310
+						'_wpnonce'                  => wp_create_nonce('delete-donor'),
311 311
 						'customer_id'               => $id,
312 312
 						'give-donor-delete-confirm' => true,
313 313
 						'give-donor-delete-records' => true,
314 314
 						'redirect'                  => false,
315 315
 					);
316
-					give_donor_delete( $args );
316
+					give_donor_delete($args);
317 317
 					break;
318 318
 
319 319
 			} // End switch().
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 			 *
327 327
 			 * @since 1.8.16
328 328
 			 */
329
-			do_action( 'give_donors_table_do_bulk_action', $id, $this->current_action() );
329
+			do_action('give_donors_table_do_bulk_action', $id, $this->current_action());
330 330
 		} // End foreach().
331 331
 
332 332
 	}
@@ -339,20 +339,20 @@  discard block
 block discarded – undo
339 339
 	 * @access protected
340 340
 	 * @since  1.8.16
341 341
 	 */
342
-	protected function display_tablenav( $which ) {
343
-		if ( 'top' === $which ) {
344
-			$this->search_box( __( 'Search Donors', 'give' ), 'give-donors' );
345
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
342
+	protected function display_tablenav($which) {
343
+		if ('top' === $which) {
344
+			$this->search_box(__('Search Donors', 'give'), 'give-donors');
345
+			wp_nonce_field('bulk-'.$this->_args['plural']);
346 346
 		}
347 347
 		?>
348
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
349
-			<?php if ( $this->has_items() ): ?>
348
+		<div class="tablenav <?php echo esc_attr($which); ?>">
349
+			<?php if ($this->has_items()): ?>
350 350
 				<div class="alignleft actions bulkactions">
351
-					<?php $this->bulk_actions( $which ); ?>
351
+					<?php $this->bulk_actions($which); ?>
352 352
 				</div>
353 353
 			<?php endif;
354
-			$this->extra_tablenav( $which );
355
-			$this->pagination( $which );
354
+			$this->extra_tablenav($which);
355
+			$this->pagination($which);
356 356
 			?>
357 357
 			<br class="clear" />
358 358
 		</div>
@@ -373,13 +373,13 @@  discard block
 block discarded – undo
373 373
 
374 374
 		// Get donor query.
375 375
 		$args   = $this->get_donor_query();
376
-		$donors = Give()->donors->get_donors( $args );
376
+		$donors = Give()->donors->get_donors($args);
377 377
 
378
-		if ( $donors ) {
378
+		if ($donors) {
379 379
 
380
-			foreach ( $donors as $donor ) {
380
+			foreach ($donors as $donor) {
381 381
 
382
-				$user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0;
382
+				$user_id = ! empty($donor->user_id) ? intval($donor->user_id) : 0;
383 383
 
384 384
 				$data[] = array(
385 385
 					'id'            => $donor->id,
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 			}
394 394
 		}
395 395
 
396
-		return apply_filters( 'give_donors_column_query_data', $data );
396
+		return apply_filters('give_donors_column_query_data', $data);
397 397
 	}
398 398
 
399 399
 	/**
@@ -408,9 +408,9 @@  discard block
 block discarded – undo
408 408
 
409 409
 		$_donor_query['number'] = - 1;
410 410
 		$_donor_query['offset'] = 0;
411
-		$donors                 = Give()->donors->get_donors( $_donor_query );
411
+		$donors                 = Give()->donors->get_donors($_donor_query);
412 412
 
413
-		return count( $donors );
413
+		return count($donors);
414 414
 	}
415 415
 
416 416
 	/**
@@ -423,10 +423,10 @@  discard block
 block discarded – undo
423 423
 	 */
424 424
 	public function get_donor_query() {
425 425
 		$paged   = $this->get_paged();
426
-		$offset  = $this->per_page * ( $paged - 1 );
426
+		$offset  = $this->per_page * ($paged - 1);
427 427
 		$search  = $this->get_search();
428
-		$order   = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC';
429
-		$orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id';
428
+		$order   = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC';
429
+		$orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id';
430 430
 
431 431
 		$args = array(
432 432
 			'number'  => $this->per_page,
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
 			'orderby' => $orderby,
436 436
 		);
437 437
 
438
-		if ( $search ) {
439
-			if ( is_email( $search ) ) {
438
+		if ($search) {
439
+			if (is_email($search)) {
440 440
 				$args['email'] = $search;
441
-			} elseif ( is_numeric( $search ) ) {
441
+			} elseif (is_numeric($search)) {
442 442
 				$args['id'] = $search;
443 443
 			} else {
444 444
 				$args['name'] = $search;
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 		$hidden   = array(); // No hidden columns.
463 463
 		$sortable = $this->get_sortable_columns();
464 464
 
465
-		$this->_column_headers = array( $columns, $hidden, $sortable );
465
+		$this->_column_headers = array($columns, $hidden, $sortable);
466 466
 
467 467
 		$this->process_bulk_action();
468 468
 
@@ -470,10 +470,10 @@  discard block
 block discarded – undo
470 470
 
471 471
 		$this->total = $this->get_donor_count();
472 472
 
473
-		$this->set_pagination_args( array(
473
+		$this->set_pagination_args(array(
474 474
 			'total_items' => $this->total,
475 475
 			'per_page'    => $this->per_page,
476
-			'total_pages' => ceil( $this->total / $this->per_page ),
477
-		) );
476
+			'total_pages' => ceil($this->total / $this->per_page),
477
+		));
478 478
 	}
479 479
 }
Please login to merge, or discard this patch.
includes/admin/donors/donor-actions.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @since 1.0
23 23
  *
24
- * @return array|bool $output Response messages
24
+ * @return false|null $output Response messages
25 25
  */
26 26
 function give_edit_donor( $args ) {
27 27
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
  *
228 228
  * @since 1.0
229 229
  *
230
- * @return int Whether it was a successful deletion.
230
+ * @return false|null Whether it was a successful deletion.
231 231
  */
232 232
 function give_donor_delete( $args ) {
233 233
 
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
  *
522 522
  * @since  1.7
523 523
  *
524
- * @return bool|null
524
+ * @return false|null
525 525
  */
526 526
 function give_remove_donor_email() {
527 527
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
  *
566 566
  * @since  1.7
567 567
  *
568
- * @return bool|null
568
+ * @return false|null
569 569
  */
570 570
 function give_set_donor_primary_email() {
571 571
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
Please login to merge, or discard this patch.
Spacing   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array|bool $output Response messages
25 25
  */
26
-function give_edit_donor( $args ) {
26
+function give_edit_donor($args) {
27 27
 
28
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
28
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
29 29
 
30
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
31
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
30
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
31
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
32 32
 			'response' => 403,
33
-		) );
33
+		));
34 34
 	}
35 35
 
36
-	if ( empty( $args ) ) {
36
+	if (empty($args)) {
37 37
 		return false;
38 38
 	}
39 39
 
@@ -41,15 +41,15 @@  discard block
 block discarded – undo
41 41
 	$donor_id   = (int) $args['customerinfo']['id'];
42 42
 	$nonce      = $args['_wpnonce'];
43 43
 
44
-	if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) {
45
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
44
+	if ( ! wp_verify_nonce($nonce, 'edit-donor')) {
45
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
46 46
 			'response' => 400,
47
-		) );
47
+		));
48 48
 	}
49 49
 
50
-	$donor = new Give_Donor( $donor_id );
50
+	$donor = new Give_Donor($donor_id);
51 51
 
52
-	if ( empty( $donor->id ) ) {
52
+	if (empty($donor->id)) {
53 53
 		return false;
54 54
 	}
55 55
 
@@ -64,79 +64,79 @@  discard block
 block discarded – undo
64 64
 		'country' => '',
65 65
 	);
66 66
 
67
-	$donor_info = wp_parse_args( $donor_info, $defaults );
67
+	$donor_info = wp_parse_args($donor_info, $defaults);
68 68
 
69
-	if ( (int) $donor_info['user_id'] !== (int) $donor->user_id ) {
69
+	if ((int) $donor_info['user_id'] !== (int) $donor->user_id) {
70 70
 
71 71
 		// Make sure we don't already have this user attached to a donor.
72
-		if ( ! empty( $donor_info['user_id'] ) && false !== Give()->donors->get_donor_by( 'user_id', $donor_info['user_id'] ) ) {
73
-			give_set_error( 'give-invalid-donor-user_id', sprintf( __( 'The User ID #%d is already associated with a different donor.', 'give' ), $donor_info['user_id'] ) );
72
+		if ( ! empty($donor_info['user_id']) && false !== Give()->donors->get_donor_by('user_id', $donor_info['user_id'])) {
73
+			give_set_error('give-invalid-donor-user_id', sprintf(__('The User ID #%d is already associated with a different donor.', 'give'), $donor_info['user_id']));
74 74
 		}
75 75
 
76 76
 		// Make sure it's actually a user.
77
-		$user = get_user_by( 'id', $donor_info['user_id'] );
78
-		if ( ! empty( $donor_info['user_id'] ) && false === $user ) {
79
-			give_set_error( 'give-invalid-user_id', sprintf( __( 'The User ID #%d does not exist. Please assign an existing user.', 'give' ), $donor_info['user_id'] ) );
77
+		$user = get_user_by('id', $donor_info['user_id']);
78
+		if ( ! empty($donor_info['user_id']) && false === $user) {
79
+			give_set_error('give-invalid-user_id', sprintf(__('The User ID #%d does not exist. Please assign an existing user.', 'give'), $donor_info['user_id']));
80 80
 		}
81 81
 	}
82 82
 
83
-	if ( give_get_errors() ) {
83
+	if (give_get_errors()) {
84 84
 		return false;
85 85
 	}
86 86
 
87 87
 	// Setup the donor address, if present.
88 88
 	$address = array();
89
-	if ( intval( $donor_info['user_id'] ) > 0 ) {
90
-
91
-		$current_address = (array) get_user_meta( $donor_info['user_id'], '_give_user_address', true );
92
-
93
-		if ( is_array( $current_address ) && 0 < count( $current_address ) ) {
94
-			$current_address    = wp_parse_args( $current_address, $defaults );
95
-			$address['line1']   = ! empty( $donor_info['line1'] ) ? $donor_info['line1'] : $current_address['line1'];
96
-			$address['line2']   = ! empty( $donor_info['line2'] ) ? $donor_info['line2'] : $current_address['line2'];
97
-			$address['city']    = ! empty( $donor_info['city'] ) ? $donor_info['city'] : $current_address['city'];
98
-			$address['country'] = ! empty( $donor_info['country'] ) ? $donor_info['country'] : $current_address['country'];
99
-			$address['zip']     = ! empty( $donor_info['zip'] ) ? $donor_info['zip'] : $current_address['zip'];
100
-			$address['state']   = ! empty( $donor_info['state'] ) ? $donor_info['state'] : $current_address['state'];
89
+	if (intval($donor_info['user_id']) > 0) {
90
+
91
+		$current_address = (array) get_user_meta($donor_info['user_id'], '_give_user_address', true);
92
+
93
+		if (is_array($current_address) && 0 < count($current_address)) {
94
+			$current_address    = wp_parse_args($current_address, $defaults);
95
+			$address['line1']   = ! empty($donor_info['line1']) ? $donor_info['line1'] : $current_address['line1'];
96
+			$address['line2']   = ! empty($donor_info['line2']) ? $donor_info['line2'] : $current_address['line2'];
97
+			$address['city']    = ! empty($donor_info['city']) ? $donor_info['city'] : $current_address['city'];
98
+			$address['country'] = ! empty($donor_info['country']) ? $donor_info['country'] : $current_address['country'];
99
+			$address['zip']     = ! empty($donor_info['zip']) ? $donor_info['zip'] : $current_address['zip'];
100
+			$address['state']   = ! empty($donor_info['state']) ? $donor_info['state'] : $current_address['state'];
101 101
 		} else {
102
-			$address['line1']   = ! empty( $donor_info['line1'] ) ? $donor_info['line1'] : '';
103
-			$address['line2']   = ! empty( $donor_info['line2'] ) ? $donor_info['line2'] : '';
104
-			$address['city']    = ! empty( $donor_info['city'] ) ? $donor_info['city'] : '';
105
-			$address['country'] = ! empty( $donor_info['country'] ) ? $donor_info['country'] : '';
106
-			$address['zip']     = ! empty( $donor_info['zip'] ) ? $donor_info['zip'] : '';
107
-			$address['state']   = ! empty( $donor_info['state'] ) ? $donor_info['state'] : '';
102
+			$address['line1']   = ! empty($donor_info['line1']) ? $donor_info['line1'] : '';
103
+			$address['line2']   = ! empty($donor_info['line2']) ? $donor_info['line2'] : '';
104
+			$address['city']    = ! empty($donor_info['city']) ? $donor_info['city'] : '';
105
+			$address['country'] = ! empty($donor_info['country']) ? $donor_info['country'] : '';
106
+			$address['zip']     = ! empty($donor_info['zip']) ? $donor_info['zip'] : '';
107
+			$address['state']   = ! empty($donor_info['state']) ? $donor_info['state'] : '';
108 108
 		}
109 109
 
110 110
 	}
111 111
 
112 112
 	// Sanitize the inputs.
113 113
 	$donor_data            = array();
114
-	$donor_data['name']    = strip_tags( stripslashes( $donor_info['name'] ) );
114
+	$donor_data['name']    = strip_tags(stripslashes($donor_info['name']));
115 115
 	$donor_data['user_id'] = $donor_info['user_id'];
116 116
 
117
-	$donor_data = apply_filters( 'give_edit_donor_info', $donor_data, $donor_id );
118
-	$address    = apply_filters( 'give_edit_donor_address', $address, $donor_id );
117
+	$donor_data = apply_filters('give_edit_donor_info', $donor_data, $donor_id);
118
+	$address    = apply_filters('give_edit_donor_address', $address, $donor_id);
119 119
 
120
-	$donor_data = array_map( 'sanitize_text_field', $donor_data );
121
-	$address    = array_map( 'sanitize_text_field', $address );
120
+	$donor_data = array_map('sanitize_text_field', $donor_data);
121
+	$address    = array_map('sanitize_text_field', $address);
122 122
 
123
-	$output = give_connect_user_donor_profile( $donor, $donor_data, $address );
123
+	$output = give_connect_user_donor_profile($donor, $donor_data, $address);
124 124
 
125
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
126
-		header( 'Content-Type: application/json' );
127
-		echo json_encode( $output );
125
+	if (defined('DOING_AJAX') && DOING_AJAX) {
126
+		header('Content-Type: application/json');
127
+		echo json_encode($output);
128 128
 		wp_die();
129 129
 	}
130 130
 
131
-	if ( $output['success'] ) {
132
-		wp_redirect( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}&give-message=profile-updated" ) );
131
+	if ($output['success']) {
132
+		wp_redirect(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}&give-message=profile-updated"));
133 133
 	}
134 134
 
135 135
 	exit;
136 136
 
137 137
 }
138 138
 
139
-add_action( 'give_edit-donor', 'give_edit_donor', 10, 1 );
139
+add_action('give_edit-donor', 'give_edit_donor', 10, 1);
140 140
 
141 141
 /**
142 142
  * Save a donor note.
@@ -147,40 +147,40 @@  discard block
 block discarded – undo
147 147
  *
148 148
  * @return int The Note ID that was saved, or 0 if nothing was saved.
149 149
  */
150
-function give_donor_save_note( $args ) {
150
+function give_donor_save_note($args) {
151 151
 
152
-	$donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' );
152
+	$donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports');
153 153
 
154
-	if ( ! is_admin() || ! current_user_can( $donor_view_role ) ) {
155
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
154
+	if ( ! is_admin() || ! current_user_can($donor_view_role)) {
155
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
156 156
 			'response' => 403,
157
-		) );
157
+		));
158 158
 	}
159 159
 
160
-	if ( empty( $args ) ) {
160
+	if (empty($args)) {
161 161
 		return false;
162 162
 	}
163 163
 
164
-	$donor_note = trim( sanitize_text_field( $args['donor_note'] ) );
164
+	$donor_note = trim(sanitize_text_field($args['donor_note']));
165 165
 	$donor_id   = (int) $args['customer_id'];
166 166
 	$nonce      = $args['add_donor_note_nonce'];
167 167
 
168
-	if ( ! wp_verify_nonce( $nonce, 'add-donor-note' ) ) {
169
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
168
+	if ( ! wp_verify_nonce($nonce, 'add-donor-note')) {
169
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
170 170
 			'response' => 400,
171
-		) );
171
+		));
172 172
 	}
173 173
 
174
-	if ( empty( $donor_note ) ) {
175
-		give_set_error( 'empty-donor-note', __( 'A note is required.', 'give' ) );
174
+	if (empty($donor_note)) {
175
+		give_set_error('empty-donor-note', __('A note is required.', 'give'));
176 176
 	}
177 177
 
178
-	if ( give_get_errors() ) {
178
+	if (give_get_errors()) {
179 179
 		return false;
180 180
 	}
181 181
 
182
-	$donor    = new Give_Donor( $donor_id );
183
-	$new_note = $donor->add_note( $donor_note );
182
+	$donor    = new Give_Donor($donor_id);
183
+	$new_note = $donor->add_note($donor_note);
184 184
 
185 185
 	/**
186 186
 	 * Fires before inserting donor note.
@@ -190,22 +190,22 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @since 1.0
192 192
 	 */
193
-	do_action( 'give_pre_insert_donor_note', $donor_id, $new_note );
193
+	do_action('give_pre_insert_donor_note', $donor_id, $new_note);
194 194
 
195
-	if ( ! empty( $new_note ) && ! empty( $donor->id ) ) {
195
+	if ( ! empty($new_note) && ! empty($donor->id)) {
196 196
 
197 197
 		ob_start();
198 198
 		?>
199 199
 		<div class="donor-note-wrapper dashboard-comment-wrap comment-item">
200 200
 			<span class="note-content-wrap">
201
-				<?php echo stripslashes( $new_note ); ?>
201
+				<?php echo stripslashes($new_note); ?>
202 202
 			</span>
203 203
 		</div>
204 204
 		<?php
205 205
 		$output = ob_get_contents();
206 206
 		ob_end_clean();
207 207
 
208
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
208
+		if (defined('DOING_AJAX') && DOING_AJAX) {
209 209
 			echo $output;
210 210
 			exit;
211 211
 		}
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 
219 219
 }
220 220
 
221
-add_action( 'give_add-donor-note', 'give_donor_save_note', 10, 1 );
221
+add_action('give_add-donor-note', 'give_donor_save_note', 10, 1);
222 222
 
223 223
 /**
224 224
  * Delete a donor.
@@ -229,46 +229,46 @@  discard block
 block discarded – undo
229 229
  *
230 230
  * @return int Whether it was a successful deletion.
231 231
  */
232
-function give_donor_delete( $args ) {
232
+function give_donor_delete($args) {
233 233
 
234
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
234
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
235 235
 
236
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
237
-		wp_die( __( 'You do not have permission to delete donors.', 'give' ), __( 'Error', 'give' ), array(
236
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
237
+		wp_die(__('You do not have permission to delete donors.', 'give'), __('Error', 'give'), array(
238 238
 			'response' => 403,
239
-		) );
239
+		));
240 240
 	}
241 241
 
242
-	if ( empty( $args ) ) {
242
+	if (empty($args)) {
243 243
 		return false;
244 244
 	}
245 245
 
246 246
 	$defaults = array(
247 247
 		'redirect' => true,
248 248
 	);
249
-	wp_parse_args( $args, $defaults );
249
+	wp_parse_args($args, $defaults);
250 250
 
251 251
 	$donor_id    = (int) $args['customer_id'];
252
-	$confirm     = ! empty( $args['give-donor-delete-confirm'] ) ? true : false;
253
-	$remove_data = ! empty( $args['give-donor-delete-records'] ) ? true : false;
252
+	$confirm     = ! empty($args['give-donor-delete-confirm']) ? true : false;
253
+	$remove_data = ! empty($args['give-donor-delete-records']) ? true : false;
254 254
 	$nonce       = $args['_wpnonce'];
255 255
 
256
-	if ( ! wp_verify_nonce( $nonce, 'delete-donor' ) ) {
257
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
256
+	if ( ! wp_verify_nonce($nonce, 'delete-donor')) {
257
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
258 258
 			'response' => 400,
259
-		) );
259
+		));
260 260
 	}
261 261
 
262
-	if ( ! $confirm ) {
263
-		give_set_error( 'donor-delete-no-confirm', __( 'Please confirm you want to delete this donor.', 'give' ) );
262
+	if ( ! $confirm) {
263
+		give_set_error('donor-delete-no-confirm', __('Please confirm you want to delete this donor.', 'give'));
264 264
 	}
265 265
 
266
-	if ( give_get_errors() ) {
267
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id ) );
266
+	if (give_get_errors()) {
267
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id));
268 268
 		exit;
269 269
 	}
270 270
 
271
-	$donor = new Give_Donor( $donor_id );
271
+	$donor = new Give_Donor($donor_id);
272 272
 
273 273
 	/**
274 274
 	 * Fires before deleting donor.
@@ -279,53 +279,53 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @since 1.0
281 281
 	 */
282
-	do_action( 'give_pre_delete_donor', $donor_id, $confirm, $remove_data );
282
+	do_action('give_pre_delete_donor', $donor_id, $confirm, $remove_data);
283 283
 
284
-	if ( $donor->id > 0 ) {
284
+	if ($donor->id > 0) {
285 285
 
286
-		$payments_array = explode( ',', $donor->payment_ids );
287
-		$success        = Give()->donors->delete( $donor->id );
286
+		$payments_array = explode(',', $donor->payment_ids);
287
+		$success        = Give()->donors->delete($donor->id);
288 288
 
289
-		if ( $success ) {
289
+		if ($success) {
290 290
 
291
-			if ( $remove_data ) {
291
+			if ($remove_data) {
292 292
 
293 293
 				// Remove all donations, logs, etc.
294
-				foreach ( $payments_array as $payment_id ) {
295
-					give_delete_donation( $payment_id );
294
+				foreach ($payments_array as $payment_id) {
295
+					give_delete_donation($payment_id);
296 296
 				}
297 297
 			} else {
298 298
 
299 299
 				// Just set the donations to customer_id of 0.
300
-				foreach ( $payments_array as $payment_id ) {
301
-					give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 );
300
+				foreach ($payments_array as $payment_id) {
301
+					give_update_payment_meta($payment_id, '_give_payment_customer_id', 0);
302 302
 				}
303 303
 			}
304 304
 
305
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted' );
305
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted');
306 306
 
307 307
 		} else {
308 308
 
309
-			give_set_error( 'give-donor-delete-failed', __( 'Error deleting donor.', 'give' ) );
310
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor_id );
309
+			give_set_error('give-donor-delete-failed', __('Error deleting donor.', 'give'));
310
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor_id);
311 311
 
312 312
 		}
313 313
 	} else {
314 314
 
315
-		give_set_error( 'give-donor-delete-invalid-id', __( 'Invalid Donor ID.', 'give' ) );
316
-		$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' );
315
+		give_set_error('give-donor-delete-invalid-id', __('Invalid Donor ID.', 'give'));
316
+		$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors');
317 317
 
318 318
 	}
319 319
 
320 320
 	// Proceed Redirect, only if redirect argument is set to true.
321
-	if( $args['redirect'] ) {
322
-		wp_redirect( $redirect );
321
+	if ($args['redirect']) {
322
+		wp_redirect($redirect);
323 323
 		exit;
324 324
 	}
325 325
 
326 326
 }
327 327
 
328
-add_action( 'give_delete-donor', 'give_donor_delete', 10, 1 );
328
+add_action('give_delete-donor', 'give_donor_delete', 10, 1);
329 329
 
330 330
 /**
331 331
  * Disconnect a user ID from a donor
@@ -336,17 +336,17 @@  discard block
 block discarded – undo
336 336
  *
337 337
  * @return bool|array If the disconnect was successful.
338 338
  */
339
-function give_disconnect_donor_user_id( $args ) {
339
+function give_disconnect_donor_user_id($args) {
340 340
 
341
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
341
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
342 342
 
343
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
344
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
343
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
344
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
345 345
 			'response' => 403,
346
-		) );
346
+		));
347 347
 	}
348 348
 
349
-	if ( empty( $args ) ) {
349
+	if (empty($args)) {
350 350
 		return false;
351 351
 	}
352 352
 
@@ -354,14 +354,14 @@  discard block
 block discarded – undo
354 354
 
355 355
 	$nonce = $args['_wpnonce'];
356 356
 
357
-	if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) {
358
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
357
+	if ( ! wp_verify_nonce($nonce, 'edit-donor')) {
358
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
359 359
 			'response' => 400,
360
-		) );
360
+		));
361 361
 	}
362 362
 
363
-	$donor = new Give_Donor( $donor_id );
364
-	if ( empty( $donor->id ) ) {
363
+	$donor = new Give_Donor($donor_id);
364
+	if (empty($donor->id)) {
365 365
 		return false;
366 366
 	}
367 367
 
@@ -375,34 +375,34 @@  discard block
 block discarded – undo
375 375
 	 *
376 376
 	 * @since 1.0
377 377
 	 */
378
-	do_action( 'give_pre_donor_disconnect_user_id', $donor_id, $user_id );
378
+	do_action('give_pre_donor_disconnect_user_id', $donor_id, $user_id);
379 379
 
380 380
 	$output     = array();
381 381
 	$donor_args = array(
382 382
 		'user_id' => 0,
383 383
 	);
384 384
 
385
-	if ( $donor->update( $donor_args ) ) {
385
+	if ($donor->update($donor_args)) {
386 386
 		global $wpdb;
387 387
 
388
-		if ( ! empty( $donor->payment_ids ) ) {
389
-			$wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )" );
388
+		if ( ! empty($donor->payment_ids)) {
389
+			$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )");
390 390
 		}
391 391
 
392 392
 		// Set Donor Disconnection status true, if user and donor are disconnected with each other.
393
-		update_user_meta( $user_id, '_give_is_donor_disconnected', true );
394
-		update_user_meta( $user_id, '_give_disconnected_donor_id', $donor->id );
395
-		$donor->update_meta( '_give_disconnected_user_id', $user_id );
393
+		update_user_meta($user_id, '_give_is_donor_disconnected', true);
394
+		update_user_meta($user_id, '_give_disconnected_donor_id', $donor->id);
395
+		$donor->update_meta('_give_disconnected_user_id', $user_id);
396 396
 
397 397
 		$output['success'] = true;
398 398
 
399 399
 	} else {
400 400
 
401 401
 		$output['success'] = false;
402
-		give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) );
402
+		give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor.', 'give'));
403 403
 	}
404 404
 
405
-	$output['redirect'] = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' ) . $donor_id;
405
+	$output['redirect'] = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id=').$donor_id;
406 406
 
407 407
 	/**
408 408
 	 * Fires after disconnecting user ID from a donor.
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
 	 *
412 412
 	 * @since 1.0
413 413
 	 */
414
-	do_action( 'give_post_donor_disconnect_user_id', $donor_id );
414
+	do_action('give_post_donor_disconnect_user_id', $donor_id);
415 415
 
416
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
417
-		header( 'Content-Type: application/json' );
418
-		echo json_encode( $output );
416
+	if (defined('DOING_AJAX') && DOING_AJAX) {
417
+		header('Content-Type: application/json');
418
+		echo json_encode($output);
419 419
 		wp_die();
420 420
 	}
421 421
 
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 
424 424
 }
425 425
 
426
-add_action( 'give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1 );
426
+add_action('give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1);
427 427
 
428 428
 /**
429 429
  * Add an email address to the donor from within the admin and log a donor note.
@@ -434,86 +434,86 @@  discard block
 block discarded – undo
434 434
  *
435 435
  * @return mixed If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string).
436 436
  */
437
-function give_add_donor_email( $args ) {
437
+function give_add_donor_email($args) {
438 438
 
439 439
 	$donor_id = '';
440
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
440
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
441 441
 
442
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
443
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
442
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
443
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
444 444
 			'response' => 403,
445
-		) );
445
+		));
446 446
 	}
447 447
 
448 448
 	$output = array();
449
-	if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) {
449
+	if (empty($args) || empty($args['email']) || empty($args['customer_id'])) {
450 450
 		$output['success'] = false;
451
-		if ( empty( $args['email'] ) ) {
452
-			$output['message'] = __( 'Email address is required.', 'give' );
453
-		} elseif ( empty( $args['customer_id'] ) ) {
454
-			$output['message'] = __( 'Donor ID is required.', 'give' );
451
+		if (empty($args['email'])) {
452
+			$output['message'] = __('Email address is required.', 'give');
453
+		} elseif (empty($args['customer_id'])) {
454
+			$output['message'] = __('Donor ID is required.', 'give');
455 455
 		} else {
456
-			$output['message'] = __( 'An error has occurred. Please try again.', 'give' );
456
+			$output['message'] = __('An error has occurred. Please try again.', 'give');
457 457
 		}
458
-	} elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) {
458
+	} elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) {
459 459
 		$output = array(
460 460
 			'success' => false,
461
-			'message' => __( 'Nonce verification failed.', 'give' ),
461
+			'message' => __('Nonce verification failed.', 'give'),
462 462
 		);
463
-	} elseif ( ! is_email( $args['email'] ) ) {
463
+	} elseif ( ! is_email($args['email'])) {
464 464
 		$output = array(
465 465
 			'success' => false,
466
-			'message' => __( 'Invalid email.', 'give' ),
466
+			'message' => __('Invalid email.', 'give'),
467 467
 		);
468 468
 	} else {
469
-		$email    = sanitize_email( $args['email'] );
469
+		$email    = sanitize_email($args['email']);
470 470
 		$donor_id = (int) $args['customer_id'];
471 471
 		$primary  = 'true' === $args['primary'] ? true : false;
472
-		$donor    = new Give_Donor( $donor_id );
473
-		if ( false === $donor->add_email( $email, $primary ) ) {
474
-			if ( in_array( $email, $donor->emails ) ) {
472
+		$donor    = new Give_Donor($donor_id);
473
+		if (false === $donor->add_email($email, $primary)) {
474
+			if (in_array($email, $donor->emails)) {
475 475
 				$output = array(
476 476
 					'success' => false,
477
-					'message' => __( 'Email already associated with this donor.', 'give' ),
477
+					'message' => __('Email already associated with this donor.', 'give'),
478 478
 				);
479 479
 			} else {
480 480
 				$output = array(
481 481
 					'success' => false,
482
-					'message' => __( 'Email address is already associated with another donor.', 'give' ),
482
+					'message' => __('Email address is already associated with another donor.', 'give'),
483 483
 				);
484 484
 			}
485 485
 		} else {
486
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&give-message=email-added' );
486
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&give-message=email-added');
487 487
 			$output   = array(
488 488
 				'success'  => true,
489
-				'message'  => __( 'Email successfully added to donor.', 'give' ),
489
+				'message'  => __('Email successfully added to donor.', 'give'),
490 490
 				'redirect' => $redirect,
491 491
 			);
492 492
 
493 493
 			$user       = wp_get_current_user();
494
-			$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
495
-			$donor_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login );
496
-			$donor->add_note( $donor_note );
494
+			$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
495
+			$donor_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login);
496
+			$donor->add_note($donor_note);
497 497
 
498
-			if ( $primary ) {
499
-				$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login );
500
-				$donor->add_note( $donor_note );
498
+			if ($primary) {
499
+				$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login);
500
+				$donor->add_note($donor_note);
501 501
 			}
502 502
 		}
503 503
 	} // End if().
504 504
 
505
-	do_action( 'give_post_add_donor_email', $donor_id, $args );
505
+	do_action('give_post_add_donor_email', $donor_id, $args);
506 506
 
507
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
508
-		header( 'Content-Type: application/json' );
509
-		echo json_encode( $output );
507
+	if (defined('DOING_AJAX') && DOING_AJAX) {
508
+		header('Content-Type: application/json');
509
+		echo json_encode($output);
510 510
 		wp_die();
511 511
 	}
512 512
 
513 513
 	return $output;
514 514
 }
515 515
 
516
-add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 );
516
+add_action('give_add_donor_email', 'give_add_donor_email', 10, 1);
517 517
 
518 518
 
519 519
 /**
@@ -524,39 +524,39 @@  discard block
 block discarded – undo
524 524
  * @return bool|null
525 525
  */
526 526
 function give_remove_donor_email() {
527
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
527
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
528 528
 		return false;
529 529
 	}
530
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
530
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
531 531
 		return false;
532 532
 	}
533
-	if ( empty( $_GET['_wpnonce'] ) ) {
533
+	if (empty($_GET['_wpnonce'])) {
534 534
 		return false;
535 535
 	}
536 536
 
537 537
 	$nonce = $_GET['_wpnonce'];
538
-	if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) {
539
-		wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array(
538
+	if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) {
539
+		wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array(
540 540
 			'response' => 403,
541
-		) );
541
+		));
542 542
 	}
543 543
 
544
-	$donor = new Give_Donor( $_GET['id'] );
545
-	if ( $donor->remove_email( $_GET['email'] ) ) {
546
-		$url        = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
544
+	$donor = new Give_Donor($_GET['id']);
545
+	if ($donor->remove_email($_GET['email'])) {
546
+		$url        = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
547 547
 		$user       = wp_get_current_user();
548
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
549
-		$donor_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login );
550
-		$donor->add_note( $donor_note );
548
+		$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
549
+		$donor_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login);
550
+		$donor->add_note($donor_note);
551 551
 	} else {
552
-		$url = add_query_arg( 'give-message', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
552
+		$url = add_query_arg('give-message', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
553 553
 	}
554 554
 
555
-	wp_safe_redirect( $url );
555
+	wp_safe_redirect($url);
556 556
 	exit;
557 557
 }
558 558
 
559
-add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 );
559
+add_action('give_remove_donor_email', 'give_remove_donor_email', 10);
560 560
 
561 561
 
562 562
 /**
@@ -568,41 +568,41 @@  discard block
 block discarded – undo
568 568
  * @return bool|null
569 569
  */
570 570
 function give_set_donor_primary_email() {
571
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
571
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
572 572
 		return false;
573 573
 	}
574 574
 
575
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
575
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
576 576
 		return false;
577 577
 	}
578 578
 
579
-	if ( empty( $_GET['_wpnonce'] ) ) {
579
+	if (empty($_GET['_wpnonce'])) {
580 580
 		return false;
581 581
 	}
582 582
 
583 583
 	$nonce = $_GET['_wpnonce'];
584 584
 
585
-	if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) {
586
-		wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array(
585
+	if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) {
586
+		wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array(
587 587
 			'response' => 403,
588
-		) );
588
+		));
589 589
 	}
590 590
 
591
-	$donor = new Give_Donor( $_GET['id'] );
591
+	$donor = new Give_Donor($_GET['id']);
592 592
 
593
-	if ( $donor->set_primary_email( $_GET['email'] ) ) {
594
-		$url        = add_query_arg( 'give-message', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
593
+	if ($donor->set_primary_email($_GET['email'])) {
594
+		$url        = add_query_arg('give-message', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
595 595
 		$user       = wp_get_current_user();
596
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
597
-		$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login );
596
+		$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
597
+		$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $_GET['email'], $user_login);
598 598
 
599
-		$donor->add_note( $donor_note );
599
+		$donor->add_note($donor_note);
600 600
 	} else {
601
-		$url = add_query_arg( 'give-message', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
601
+		$url = add_query_arg('give-message', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
602 602
 	}
603 603
 
604
-	wp_safe_redirect( $url );
604
+	wp_safe_redirect($url);
605 605
 	exit;
606 606
 }
607 607
 
608
-add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 );
608
+add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10);
Please login to merge, or discard this patch.
includes/forms/functions.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
  *
156 156
  * Used to redirect a user back to the donation form if there are errors present.
157 157
  *
158
- * @param array $args
158
+ * @param string $args
159 159
  *
160 160
  * @access public
161 161
  * @since  1.0
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
  * @since  1.0
302 302
  * @since  1.8.16 Add security check
303 303
  *
304
- * @return bool
304
+ * @return false|null
305 305
  */
306 306
 function give_listen_for_failed_payments() {
307 307
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
  *
467 467
  * @param int $form_id Give Form ID
468 468
  *
469
- * @return int $earnings Earnings for a certain form
469
+ * @return double $earnings Earnings for a certain form
470 470
  */
471 471
 function give_get_form_earnings_stats( $form_id = 0 ) {
472 472
 	$give_form = new Give_Donate_Form( $form_id );
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
  *
737 737
  * @param int $form_id ID number of the form to retrieve the minimum price for
738 738
  *
739
- * @return mixed string|int Minimum price of the form
739
+ * @return string string|int Minimum price of the form
740 740
  */
741 741
 function give_get_form_minimum_price( $form_id = 0 ) {
742 742
 
Please login to merge, or discard this patch.
Spacing   +215 added lines, -216 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,14 +23,14 @@  discard block
 block discarded – undo
23 23
 
24 24
 	global $typenow;
25 25
 
26
-	if ( $typenow != 'give_forms' ) {
26
+	if ($typenow != 'give_forms') {
27 27
 		return true;
28 28
 	}
29 29
 
30 30
 	return false;
31 31
 }
32 32
 
33
-add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' );
33
+add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition');
34 34
 
35 35
 
36 36
 /**
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
  *
41 41
  * @return int|false
42 42
  */
43
-function get_form_id_from_args( $args ) {
43
+function get_form_id_from_args($args) {
44 44
 
45
-	if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) {
45
+	if (isset($args['form_id']) && $args['form_id'] != 0) {
46 46
 
47
-		return intval( $args['form_id'] );
47
+		return intval($args['form_id']);
48 48
 	}
49 49
 
50 50
 	return false;
@@ -59,23 +59,23 @@  discard block
 block discarded – undo
59 59
  *
60 60
  * @return bool
61 61
  */
62
-function give_is_float_labels_enabled( $args ) {
62
+function give_is_float_labels_enabled($args) {
63 63
 
64 64
 	$float_labels = '';
65 65
 
66
-	if ( ! empty( $args['float_labels'] ) ) {
66
+	if ( ! empty($args['float_labels'])) {
67 67
 		$float_labels = $args['float_labels'];
68 68
 	}
69 69
 
70
-	if ( empty( $float_labels ) ) {
71
-		$float_labels = give_get_meta( $args['form_id'], '_give_form_floating_labels', true );
70
+	if (empty($float_labels)) {
71
+		$float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true);
72 72
 	}
73 73
 
74
-	if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) {
75
-		$float_labels = give_get_option( 'floatlabels', 'disabled' );
74
+	if (empty($float_labels) || ('global' === $float_labels)) {
75
+		$float_labels = give_get_option('floatlabels', 'disabled');
76 76
 	}
77 77
 
78
-	return give_is_setting_enabled( $float_labels );
78
+	return give_is_setting_enabled($float_labels);
79 79
 }
80 80
 
81 81
 /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 	$can_checkout = true;
93 93
 
94
-	return (bool) apply_filters( 'give_can_checkout', $can_checkout );
94
+	return (bool) apply_filters('give_can_checkout', $can_checkout);
95 95
 }
96 96
 
97 97
 /**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 function give_get_success_page_uri() {
106 106
 	$give_options = give_get_settings();
107 107
 
108
-	$success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' );
108
+	$success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url');
109 109
 
110
-	return apply_filters( 'give_get_success_page_uri', $success_page );
110
+	return apply_filters('give_get_success_page_uri', $success_page);
111 111
 }
112 112
 
113 113
 /**
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
  */
120 120
 function give_is_success_page() {
121 121
 	$give_options    = give_get_settings();
122
-	$is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false;
122
+	$is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false;
123 123
 
124
-	return apply_filters( 'give_is_success_page', $is_success_page );
124
+	return apply_filters('give_is_success_page', $is_success_page);
125 125
 }
126 126
 
127 127
 /**
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
  * @since       1.0
136 136
  * @return      void
137 137
  */
138
-function give_send_to_success_page( $query_string = null ) {
138
+function give_send_to_success_page($query_string = null) {
139 139
 
140 140
 	$redirect = give_get_success_page_uri();
141 141
 
142
-	if ( $query_string ) {
142
+	if ($query_string) {
143 143
 		$redirect .= $query_string;
144 144
 	}
145 145
 
146
-	$gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : '';
146
+	$gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : '';
147 147
 
148
-	wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) );
148
+	wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string));
149 149
 	give_die();
150 150
 }
151 151
 
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
  * @since  1.0
162 162
  * @return Void
163 163
  */
164
-function give_send_back_to_checkout( $args = array() ) {
164
+function give_send_back_to_checkout($args = array()) {
165 165
 
166
-	$url     = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : '';
166
+	$url     = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : '';
167 167
 	$form_id = 0;
168 168
 
169 169
 	// Set the form_id.
170
-	if ( isset( $_POST['give-form-id'] ) ) {
171
-		$form_id = sanitize_text_field( $_POST['give-form-id'] );
170
+	if (isset($_POST['give-form-id'])) {
171
+		$form_id = sanitize_text_field($_POST['give-form-id']);
172 172
 	}
173 173
 
174 174
 	// Need a URL to continue. If none, redirect back to single form.
175
-	if ( empty( $url ) ) {
176
-		wp_safe_redirect( get_permalink( $form_id ) );
175
+	if (empty($url)) {
176
+		wp_safe_redirect(get_permalink($form_id));
177 177
 		give_die();
178 178
 	}
179 179
 
@@ -182,41 +182,41 @@  discard block
 block discarded – undo
182 182
 	);
183 183
 
184 184
 	// Set the $level_id.
185
-	if ( isset( $_POST['give-price-id'] ) ) {
186
-		$defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] );
185
+	if (isset($_POST['give-price-id'])) {
186
+		$defaults['level-id'] = sanitize_text_field($_POST['give-price-id']);
187 187
 	}
188 188
 
189 189
 	// Check for backward compatibility.
190
-	if ( is_string( $args ) ) {
191
-		$args = str_replace( '?', '', $args );
190
+	if (is_string($args)) {
191
+		$args = str_replace('?', '', $args);
192 192
 	}
193 193
 
194
-	$args = wp_parse_args( $args, $defaults );
194
+	$args = wp_parse_args($args, $defaults);
195 195
 
196 196
 	// Merge URL query with $args to maintain third-party URL parameters after redirect.
197
-	$url_data = wp_parse_url( $url );
197
+	$url_data = wp_parse_url($url);
198 198
 
199 199
 	// Check if an array to prevent notices before parsing.
200
-	if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) {
201
-		parse_str( $url_data['query'], $query );
200
+	if (isset($url_data['query']) && ! empty($url_data['query'])) {
201
+		parse_str($url_data['query'], $query);
202 202
 
203 203
 		// Precaution: don't allow any CC info.
204
-		unset( $query['card_number'] );
205
-		unset( $query['card_cvc'] );
204
+		unset($query['card_number']);
205
+		unset($query['card_cvc']);
206 206
 
207 207
 	} else {
208 208
 		// No $url_data so pass empty array.
209 209
 		$query = array();
210 210
 	}
211 211
 
212
-	$new_query        = array_merge( $args, $query );
213
-	$new_query_string = http_build_query( $new_query );
212
+	$new_query        = array_merge($args, $query);
213
+	$new_query_string = http_build_query($new_query);
214 214
 
215 215
 	// Assemble URL parts.
216
-	$redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' );
216
+	$redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap');
217 217
 
218 218
 	// Redirect them.
219
-	wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) );
219
+	wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args));
220 220
 	give_die();
221 221
 
222 222
 }
@@ -232,16 +232,16 @@  discard block
 block discarded – undo
232 232
  * @since       1.0
233 233
  * @return      string
234 234
  */
235
-function give_get_success_page_url( $query_string = null ) {
235
+function give_get_success_page_url($query_string = null) {
236 236
 
237
-	$success_page = give_get_option( 'success_page', 0 );
238
-	$success_page = get_permalink( $success_page );
237
+	$success_page = give_get_option('success_page', 0);
238
+	$success_page = get_permalink($success_page);
239 239
 
240
-	if ( $query_string ) {
240
+	if ($query_string) {
241 241
 		$success_page .= $query_string;
242 242
 	}
243 243
 
244
-	return apply_filters( 'give_success_page_url', $success_page );
244
+	return apply_filters('give_success_page_url', $success_page);
245 245
 
246 246
 }
247 247
 
@@ -254,32 +254,31 @@  discard block
 block discarded – undo
254 254
  *
255 255
  * @return mixed Full URL to the Failed Donation Page, if present, home page if it doesn't exist.
256 256
  */
257
-function give_get_failed_transaction_uri( $extras = false ) {
257
+function give_get_failed_transaction_uri($extras = false) {
258 258
 	$give_options = give_get_settings();
259 259
 
260 260
 	// Remove question mark.
261
-	if ( 0 === strpos( $extras, '?' ) ) {
262
-		$extras = substr( $extras, 1 );
261
+	if (0 === strpos($extras, '?')) {
262
+		$extras = substr($extras, 1);
263 263
 	}
264 264
 
265
-	$extras_args = wp_parse_args( $extras );
265
+	$extras_args = wp_parse_args($extras);
266 266
 
267 267
 	// Set nonce if payment id exist in extra params.
268
-	if ( array_key_exists( 'payment-id', $extras_args ) ) {
269
-		$extras_args['_wpnonce'] = wp_create_nonce( "give-failed-donation-{$extras_args['payment-id']}" );
270
-		$extras                  = http_build_query( $extras_args );
268
+	if (array_key_exists('payment-id', $extras_args)) {
269
+		$extras_args['_wpnonce'] = wp_create_nonce("give-failed-donation-{$extras_args['payment-id']}");
270
+		$extras                  = http_build_query($extras_args);
271 271
 	}
272 272
 
273
-	$uri = ! empty( $give_options['failure_page'] ) ?
274
-		trailingslashit( get_permalink( $give_options['failure_page'] ) ) :
275
-		home_url();
273
+	$uri = ! empty($give_options['failure_page']) ?
274
+		trailingslashit(get_permalink($give_options['failure_page'])) : home_url();
276 275
 
277 276
 
278
-	if ( $extras ) {
277
+	if ($extras) {
279 278
 		$uri .= "?{$extras}";
280 279
 	}
281 280
 
282
-	return apply_filters( 'give_get_failed_transaction_uri', $uri );
281
+	return apply_filters('give_get_failed_transaction_uri', $uri);
283 282
 }
284 283
 
285 284
 /**
@@ -290,9 +289,9 @@  discard block
 block discarded – undo
290 289
  */
291 290
 function give_is_failed_transaction_page() {
292 291
 	$give_options = give_get_settings();
293
-	$ret          = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false;
292
+	$ret          = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false;
294 293
 
295
-	return apply_filters( 'give_is_failure_page', $ret );
294
+	return apply_filters('give_is_failure_page', $ret);
296 295
 }
297 296
 
298 297
 /**
@@ -305,25 +304,25 @@  discard block
 block discarded – undo
305 304
  */
306 305
 function give_listen_for_failed_payments() {
307 306
 
308
-	$failed_page = give_get_option( 'failure_page', 0 );
309
-	$payment_id  = ! empty( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : 0;
310
-	$nonce       = ! empty( $_GET['_wpnonce'] ) ? give_clean( $_GET['_wpnonce'] ) : false;
307
+	$failed_page = give_get_option('failure_page', 0);
308
+	$payment_id  = ! empty($_GET['payment-id']) ? absint($_GET['payment-id']) : 0;
309
+	$nonce       = ! empty($_GET['_wpnonce']) ? give_clean($_GET['_wpnonce']) : false;
311 310
 
312 311
 	// Bailout.
313
-	if ( ! $failed_page || ! is_page( $failed_page ) || ! $payment_id || ! $nonce ) {
312
+	if ( ! $failed_page || ! is_page($failed_page) || ! $payment_id || ! $nonce) {
314 313
 		return false;
315 314
 	}
316 315
 
317 316
 	// Security check.
318
-	if ( ! wp_verify_nonce( $nonce, "give-failed-donation-{$payment_id}" ) ) {
319
-		wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ) );
317
+	if ( ! wp_verify_nonce($nonce, "give-failed-donation-{$payment_id}")) {
318
+		wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'));
320 319
 	}
321 320
 
322 321
 	// Set payment status to failure
323
-	give_update_payment_status( $payment_id, 'failed' );
322
+	give_update_payment_status($payment_id, 'failed');
324 323
 }
325 324
 
326
-add_action( 'template_redirect', 'give_listen_for_failed_payments' );
325
+add_action('template_redirect', 'give_listen_for_failed_payments');
327 326
 
328 327
 /**
329 328
  * Retrieve the Donation History page URI
@@ -336,9 +335,9 @@  discard block
 block discarded – undo
336 335
 function give_get_history_page_uri() {
337 336
 	$give_options = give_get_settings();
338 337
 
339
-	$history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' );
338
+	$history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url');
340 339
 
341
-	return apply_filters( 'give_get_history_page_uri', $history_page );
340
+	return apply_filters('give_get_history_page_uri', $history_page);
342 341
 }
343 342
 
344 343
 /**
@@ -351,11 +350,11 @@  discard block
 block discarded – undo
351 350
  * @since       1.0
352 351
  * @return      bool
353 352
  */
354
-function give_field_is_required( $field = '', $form_id ) {
353
+function give_field_is_required($field = '', $form_id) {
355 354
 
356
-	$required_fields = give_get_required_fields( $form_id );
355
+	$required_fields = give_get_required_fields($form_id);
357 356
 
358
-	return array_key_exists( $field, $required_fields );
357
+	return array_key_exists($field, $required_fields);
359 358
 }
360 359
 
361 360
 /**
@@ -373,14 +372,14 @@  discard block
 block discarded – undo
373 372
  *
374 373
  * @return void
375 374
  */
376
-function give_record_donation_in_log( $give_form_id = 0, $payment_id, $price_id = false, $donation_date = null ) {
375
+function give_record_donation_in_log($give_form_id = 0, $payment_id, $price_id = false, $donation_date = null) {
377 376
 	global $give_logs;
378 377
 
379 378
 	$log_data = array(
380 379
 		'post_parent'   => $give_form_id,
381 380
 		'log_type'      => 'sale',
382
-		'post_date'     => isset( $donation_date ) ? $donation_date : null,
383
-		'post_date_gmt' => isset( $donation_date ) ? $donation_date : null,
381
+		'post_date'     => isset($donation_date) ? $donation_date : null,
382
+		'post_date_gmt' => isset($donation_date) ? $donation_date : null,
384 383
 	);
385 384
 
386 385
 	$log_meta = array(
@@ -388,7 +387,7 @@  discard block
 block discarded – undo
388 387
 		'price_id'   => (int) $price_id,
389 388
 	);
390 389
 
391
-	$give_logs->insert_log( $log_data, $log_meta );
390
+	$give_logs->insert_log($log_data, $log_meta);
392 391
 }
393 392
 
394 393
 
@@ -402,11 +401,11 @@  discard block
 block discarded – undo
402 401
  *
403 402
  * @return bool|int
404 403
  */
405
-function give_increase_donation_count( $form_id = 0, $quantity = 1 ) {
404
+function give_increase_donation_count($form_id = 0, $quantity = 1) {
406 405
 	$quantity = (int) $quantity;
407
-	$form     = new Give_Donate_Form( $form_id );
406
+	$form     = new Give_Donate_Form($form_id);
408 407
 
409
-	return $form->increase_sales( $quantity );
408
+	return $form->increase_sales($quantity);
410 409
 }
411 410
 
412 411
 /**
@@ -419,11 +418,11 @@  discard block
 block discarded – undo
419 418
  *
420 419
  * @return bool|int
421 420
  */
422
-function give_decrease_donation_count( $form_id = 0, $quantity = 1 ) {
421
+function give_decrease_donation_count($form_id = 0, $quantity = 1) {
423 422
 	$quantity = (int) $quantity;
424
-	$form     = new Give_Donate_Form( $form_id );
423
+	$form     = new Give_Donate_Form($form_id);
425 424
 
426
-	return $form->decrease_sales( $quantity );
425
+	return $form->decrease_sales($quantity);
427 426
 }
428 427
 
429 428
 /**
@@ -436,10 +435,10 @@  discard block
 block discarded – undo
436 435
  *
437 436
  * @return bool|int
438 437
  */
439
-function give_increase_earnings( $give_form_id = 0, $amount ) {
440
-	$form = new Give_Donate_Form( $give_form_id );
438
+function give_increase_earnings($give_form_id = 0, $amount) {
439
+	$form = new Give_Donate_Form($give_form_id);
441 440
 
442
-	return $form->increase_earnings( $amount );
441
+	return $form->increase_earnings($amount);
443 442
 }
444 443
 
445 444
 /**
@@ -452,10 +451,10 @@  discard block
 block discarded – undo
452 451
  *
453 452
  * @return bool|int
454 453
  */
455
-function give_decrease_earnings( $form_id = 0, $amount ) {
456
-	$form = new Give_Donate_Form( $form_id );
454
+function give_decrease_earnings($form_id = 0, $amount) {
455
+	$form = new Give_Donate_Form($form_id);
457 456
 
458
-	return $form->decrease_earnings( $amount );
457
+	return $form->decrease_earnings($amount);
459 458
 }
460 459
 
461 460
 
@@ -468,8 +467,8 @@  discard block
 block discarded – undo
468 467
  *
469 468
  * @return int $earnings Earnings for a certain form
470 469
  */
471
-function give_get_form_earnings_stats( $form_id = 0 ) {
472
-	$give_form = new Give_Donate_Form( $form_id );
470
+function give_get_form_earnings_stats($form_id = 0) {
471
+	$give_form = new Give_Donate_Form($form_id);
473 472
 
474 473
 	return $give_form->earnings;
475 474
 }
@@ -484,8 +483,8 @@  discard block
 block discarded – undo
484 483
  *
485 484
  * @return int $sales Amount of sales for a certain form
486 485
  */
487
-function give_get_form_sales_stats( $give_form_id = 0 ) {
488
-	$give_form = new Give_Donate_Form( $give_form_id );
486
+function give_get_form_sales_stats($give_form_id = 0) {
487
+	$give_form = new Give_Donate_Form($give_form_id);
489 488
 
490 489
 	return $give_form->sales;
491 490
 }
@@ -500,16 +499,16 @@  discard block
 block discarded – undo
500 499
  *
501 500
  * @return float $sales Average monthly sales
502 501
  */
503
-function give_get_average_monthly_form_sales( $form_id = 0 ) {
504
-	$sales        = give_get_form_sales_stats( $form_id );
505
-	$release_date = get_post_field( 'post_date', $form_id );
502
+function give_get_average_monthly_form_sales($form_id = 0) {
503
+	$sales        = give_get_form_sales_stats($form_id);
504
+	$release_date = get_post_field('post_date', $form_id);
506 505
 
507
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
506
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
508 507
 
509
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
508
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
510 509
 
511
-	if ( $months > 0 ) {
512
-		$sales = ( $sales / $months );
510
+	if ($months > 0) {
511
+		$sales = ($sales / $months);
513 512
 	}
514 513
 
515 514
 	return $sales;
@@ -525,16 +524,16 @@  discard block
 block discarded – undo
525 524
  *
526 525
  * @return float $earnings Average monthly earnings
527 526
  */
528
-function give_get_average_monthly_form_earnings( $form_id = 0 ) {
529
-	$earnings     = give_get_form_earnings_stats( $form_id );
530
-	$release_date = get_post_field( 'post_date', $form_id );
527
+function give_get_average_monthly_form_earnings($form_id = 0) {
528
+	$earnings     = give_get_form_earnings_stats($form_id);
529
+	$release_date = get_post_field('post_date', $form_id);
531 530
 
532
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
531
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
533 532
 
534
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
533
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
535 534
 
536
-	if ( $months > 0 ) {
537
-		$earnings = ( $earnings / $months );
535
+	if ($months > 0) {
536
+		$earnings = ($earnings / $months);
538 537
 	}
539 538
 
540 539
 	return $earnings < 0 ? 0 : $earnings;
@@ -554,23 +553,23 @@  discard block
 block discarded – undo
554 553
  *
555 554
  * @return string $price_name Name of the price option
556 555
  */
557
-function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) {
556
+function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) {
558 557
 
559
-	$prices     = give_get_variable_prices( $form_id );
558
+	$prices     = give_get_variable_prices($form_id);
560 559
 	$price_name = '';
561 560
 
562
-	foreach ( $prices as $price ) {
561
+	foreach ($prices as $price) {
563 562
 
564
-		if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) {
563
+		if (intval($price['_give_id']['level_id']) == intval($price_id)) {
565 564
 
566
-			$price_text     = isset( $price['_give_text'] ) ? $price['_give_text'] : '';
567
-			$price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ), '', true );
568
-			$price_name     = ! empty( $price_text ) ? $price_text : $price_fallback;
565
+			$price_text     = isset($price['_give_text']) ? $price['_give_text'] : '';
566
+			$price_fallback = give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false)), '', true);
567
+			$price_name     = ! empty($price_text) ? $price_text : $price_fallback;
569 568
 
570 569
 		}
571 570
 	}
572 571
 
573
-	return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id );
572
+	return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id);
574 573
 }
575 574
 
576 575
 
@@ -584,25 +583,25 @@  discard block
 block discarded – undo
584 583
  *
585 584
  * @return string $range A fully formatted price range
586 585
  */
587
-function give_price_range( $form_id = 0, $formatted = true ) {
588
-	$low        = give_get_lowest_price_option( $form_id );
589
-	$high       = give_get_highest_price_option( $form_id );
590
-	$order_type = ! empty( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc';
586
+function give_price_range($form_id = 0, $formatted = true) {
587
+	$low        = give_get_lowest_price_option($form_id);
588
+	$high       = give_get_highest_price_option($form_id);
589
+	$order_type = ! empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc';
591 590
 
592 591
 	$range = sprintf(
593 592
 		'<span class="give_price_range_%1$s">%2$s</span><span class="give_price_range_sep">&nbsp;&ndash;&nbsp;</span><span class="give_price_range_%3$s">%4$s</span>',
594 593
 		'asc' === $order_type ? 'low' : 'high',
595
-		'asc' === $order_type ? give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ),
594
+		'asc' === $order_type ? give_currency_filter(give_format_amount($low, array('sanitize' => false))) : give_currency_filter(give_format_amount($high, array('sanitize' => false))),
596 595
 		'asc' === $order_type ? 'high' : 'low',
597
-		'asc' === $order_type ? give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) )
596
+		'asc' === $order_type ? give_currency_filter(give_format_amount($high, array('sanitize' => false))) : give_currency_filter(give_format_amount($low, array('sanitize' => false)))
598 597
 
599 598
 	);
600 599
 
601
-	if( ! $formatted ) {
602
-		$range = wp_strip_all_tags( $range );
600
+	if ( ! $formatted) {
601
+		$range = wp_strip_all_tags($range);
603 602
 	}
604 603
 
605
-	return apply_filters( 'give_price_range', $range, $form_id, $low, $high );
604
+	return apply_filters('give_price_range', $range, $form_id, $low, $high);
606 605
 }
607 606
 
608 607
 
@@ -617,35 +616,35 @@  discard block
 block discarded – undo
617 616
  *
618 617
  * @return int ID of the lowest price
619 618
  */
620
-function give_get_lowest_price_id( $form_id = 0 ) {
619
+function give_get_lowest_price_id($form_id = 0) {
621 620
 
622
-	if ( empty( $form_id ) ) {
621
+	if (empty($form_id)) {
623 622
 		$form_id = get_the_ID();
624 623
 	}
625 624
 
626
-	if ( ! give_has_variable_prices( $form_id ) ) {
627
-		return give_get_form_price( $form_id );
625
+	if ( ! give_has_variable_prices($form_id)) {
626
+		return give_get_form_price($form_id);
628 627
 	}
629 628
 
630
-	$prices = give_get_variable_prices( $form_id );
629
+	$prices = give_get_variable_prices($form_id);
631 630
 
632 631
 	$min = $min_id = 0;
633 632
 
634
-	if ( ! empty( $prices ) ) {
633
+	if ( ! empty($prices)) {
635 634
 
636
-		foreach ( $prices as $key => $price ) {
635
+		foreach ($prices as $key => $price) {
637 636
 
638
-			if ( empty( $price['_give_amount'] ) ) {
637
+			if (empty($price['_give_amount'])) {
639 638
 				continue;
640 639
 			}
641 640
 
642
-			if ( ! isset( $min ) ) {
641
+			if ( ! isset($min)) {
643 642
 				$min = $price['_give_amount'];
644 643
 			} else {
645
-				$min = min( $min, $price['_give_amount'] );
644
+				$min = min($min, $price['_give_amount']);
646 645
 			}
647 646
 
648
-			if ( $price['_give_amount'] == $min ) {
647
+			if ($price['_give_amount'] == $min) {
649 648
 				$min_id = $price['_give_id']['level_id'];
650 649
 			}
651 650
 		}
@@ -663,22 +662,22 @@  discard block
 block discarded – undo
663 662
  *
664 663
  * @return float Amount of the lowest price
665 664
  */
666
-function give_get_lowest_price_option( $form_id = 0 ) {
667
-	if ( empty( $form_id ) ) {
665
+function give_get_lowest_price_option($form_id = 0) {
666
+	if (empty($form_id)) {
668 667
 		$form_id = get_the_ID();
669 668
 	}
670 669
 
671
-	if ( ! give_has_variable_prices( $form_id ) ) {
672
-		return give_get_form_price( $form_id );
670
+	if ( ! give_has_variable_prices($form_id)) {
671
+		return give_get_form_price($form_id);
673 672
 	}
674 673
 
675
-	if ( ! ( $low = get_post_meta( $form_id, '_give_levels_minimum_amount', true ) ) ) {
674
+	if ( ! ($low = get_post_meta($form_id, '_give_levels_minimum_amount', true))) {
676 675
 		// Backward compatibility.
677
-		$prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' );
678
-		$low    = ! empty( $prices ) ? min( $prices ) : 0;
676
+		$prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount');
677
+		$low    = ! empty($prices) ? min($prices) : 0;
679 678
 	}
680 679
 
681
-	return give_maybe_sanitize_amount( $low );
680
+	return give_maybe_sanitize_amount($low);
682 681
 }
683 682
 
684 683
 /**
@@ -690,23 +689,23 @@  discard block
 block discarded – undo
690 689
  *
691 690
  * @return float Amount of the highest price
692 691
  */
693
-function give_get_highest_price_option( $form_id = 0 ) {
692
+function give_get_highest_price_option($form_id = 0) {
694 693
 
695
-	if ( empty( $form_id ) ) {
694
+	if (empty($form_id)) {
696 695
 		$form_id = get_the_ID();
697 696
 	}
698 697
 
699
-	if ( ! give_has_variable_prices( $form_id ) ) {
700
-		return give_get_form_price( $form_id );
698
+	if ( ! give_has_variable_prices($form_id)) {
699
+		return give_get_form_price($form_id);
701 700
 	}
702 701
 
703
-	if ( ! ( $high = get_post_meta( $form_id, '_give_levels_maximum_amount', true ) ) ) {
702
+	if ( ! ($high = get_post_meta($form_id, '_give_levels_maximum_amount', true))) {
704 703
 		// Backward compatibility.
705
-		$prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' );
706
-		$high   = ! empty( $prices ) ? max( $prices ) : 0;
704
+		$prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount');
705
+		$high   = ! empty($prices) ? max($prices) : 0;
707 706
 	}
708 707
 
709
-	return give_maybe_sanitize_amount( $high );
708
+	return give_maybe_sanitize_amount($high);
710 709
 }
711 710
 
712 711
 /**
@@ -718,15 +717,15 @@  discard block
 block discarded – undo
718 717
  *
719 718
  * @return mixed string|int Price of the form
720 719
  */
721
-function give_get_form_price( $form_id = 0 ) {
720
+function give_get_form_price($form_id = 0) {
722 721
 
723
-	if ( empty( $form_id ) ) {
722
+	if (empty($form_id)) {
724 723
 		return false;
725 724
 	}
726 725
 
727
-	$form = new Give_Donate_Form( $form_id );
726
+	$form = new Give_Donate_Form($form_id);
728 727
 
729
-	return $form->__get( 'price' );
728
+	return $form->__get('price');
730 729
 }
731 730
 
732 731
 /**
@@ -738,15 +737,15 @@  discard block
 block discarded – undo
738 737
  *
739 738
  * @return mixed string|int Minimum price of the form
740 739
  */
741
-function give_get_form_minimum_price( $form_id = 0 ) {
740
+function give_get_form_minimum_price($form_id = 0) {
742 741
 
743
-	if ( empty( $form_id ) ) {
742
+	if (empty($form_id)) {
744 743
 		return false;
745 744
 	}
746 745
 
747
-	$form = new Give_Donate_Form( $form_id );
746
+	$form = new Give_Donate_Form($form_id);
748 747
 
749
-	return $form->__get( 'minimum_price' );
748
+	return $form->__get('minimum_price');
750 749
 
751 750
 }
752 751
 
@@ -761,48 +760,48 @@  discard block
 block discarded – undo
761 760
  *
762 761
  * @return int $formatted_price
763 762
  */
764
-function give_price( $form_id = 0, $echo = true, $price_id = false ) {
763
+function give_price($form_id = 0, $echo = true, $price_id = false) {
765 764
 	$price = 0;
766 765
 
767
-	if ( empty( $form_id ) ) {
766
+	if (empty($form_id)) {
768 767
 		$form_id = get_the_ID();
769 768
 	}
770 769
 
771
-	if ( give_has_variable_prices( $form_id ) ) {
770
+	if (give_has_variable_prices($form_id)) {
772 771
 
773
-		$prices = give_get_variable_prices( $form_id );
772
+		$prices = give_get_variable_prices($form_id);
774 773
 
775
-		if ( false !== $price_id ) {
774
+		if (false !== $price_id) {
776 775
 
777 776
 			// loop through multi-prices to see which is default
778
-			foreach ( $prices as $price ) {
777
+			foreach ($prices as $price) {
779 778
 				// this is the default price
780
-				if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) {
779
+				if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
781 780
 					$price = (float) $price['_give_amount'];
782 781
 				};
783 782
 			}
784 783
 		} else {
785 784
 
786
-			$price = give_get_lowest_price_option( $form_id );
785
+			$price = give_get_lowest_price_option($form_id);
787 786
 		}
788 787
 	} else {
789 788
 
790
-		$price = give_get_form_price( $form_id );
789
+		$price = give_get_form_price($form_id);
791 790
 	}
792 791
 
793
-	$price           = apply_filters( 'give_form_price', give_maybe_sanitize_amount( $price ), $form_id );
794
-	$formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>';
795
-	$formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price );
792
+	$price           = apply_filters('give_form_price', give_maybe_sanitize_amount($price), $form_id);
793
+	$formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>';
794
+	$formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price);
796 795
 
797
-	if ( $echo ) {
796
+	if ($echo) {
798 797
 		echo $formatted_price;
799 798
 	} else {
800 799
 		return $formatted_price;
801 800
 	}
802 801
 }
803 802
 
804
-add_filter( 'give_form_price', 'give_format_amount', 10 );
805
-add_filter( 'give_form_price', 'give_currency_filter', 20 );
803
+add_filter('give_form_price', 'give_format_amount', 10);
804
+add_filter('give_form_price', 'give_currency_filter', 20);
806 805
 
807 806
 
808 807
 /**
@@ -815,19 +814,19 @@  discard block
 block discarded – undo
815 814
  *
816 815
  * @return float $amount Amount of the price option
817 816
  */
818
-function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) {
819
-	$prices = give_get_variable_prices( $form_id );
817
+function give_get_price_option_amount($form_id = 0, $price_id = 0) {
818
+	$prices = give_get_variable_prices($form_id);
820 819
 
821 820
 	$amount = 0.00;
822 821
 
823
-	foreach ( $prices as $price ) {
824
-		if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) {
825
-			$amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00;
822
+	foreach ($prices as $price) {
823
+		if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) {
824
+			$amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00;
826 825
 			break;
827 826
 		};
828 827
 	}
829 828
 
830
-	return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id );
829
+	return apply_filters('give_get_price_option_amount', give_maybe_sanitize_amount($amount), $form_id, $price_id);
831 830
 }
832 831
 
833 832
 /**
@@ -839,13 +838,13 @@  discard block
 block discarded – undo
839 838
  *
840 839
  * @return mixed string|int Goal of the form
841 840
  */
842
-function give_get_form_goal( $form_id = 0 ) {
841
+function give_get_form_goal($form_id = 0) {
843 842
 
844
-	if ( empty( $form_id ) ) {
843
+	if (empty($form_id)) {
845 844
 		return false;
846 845
 	}
847 846
 
848
-	$form = new Give_Donate_Form( $form_id );
847
+	$form = new Give_Donate_Form($form_id);
849 848
 
850 849
 	return $form->goal;
851 850
 
@@ -861,27 +860,27 @@  discard block
 block discarded – undo
861 860
  *
862 861
  * @return string $formatted_goal
863 862
  */
864
-function give_goal( $form_id = 0, $echo = true ) {
863
+function give_goal($form_id = 0, $echo = true) {
865 864
 
866
-	if ( empty( $form_id ) ) {
865
+	if (empty($form_id)) {
867 866
 		$form_id = get_the_ID();
868 867
 	}
869 868
 
870
-	$goal = give_get_form_goal( $form_id );
869
+	$goal = give_get_form_goal($form_id);
871 870
 
872
-	$goal           = apply_filters( 'give_form_goal', give_maybe_sanitize_amount( $goal ), $form_id );
873
-	$formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>';
874
-	$formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal );
871
+	$goal           = apply_filters('give_form_goal', give_maybe_sanitize_amount($goal), $form_id);
872
+	$formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>';
873
+	$formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal);
875 874
 
876
-	if ( $echo ) {
875
+	if ($echo) {
877 876
 		echo $formatted_goal;
878 877
 	} else {
879 878
 		return $formatted_goal;
880 879
 	}
881 880
 }
882 881
 
883
-add_filter( 'give_form_goal', 'give_format_amount', 10 );
884
-add_filter( 'give_form_goal', 'give_currency_filter', 20 );
882
+add_filter('give_form_goal', 'give_format_amount', 10);
883
+add_filter('give_form_goal', 'give_currency_filter', 20);
885 884
 
886 885
 
887 886
 /**
@@ -893,15 +892,15 @@  discard block
 block discarded – undo
893 892
  *
894 893
  * @return bool  $ret Whether or not the logged_in_only setting is set
895 894
  */
896
-function give_logged_in_only( $form_id ) {
895
+function give_logged_in_only($form_id) {
897 896
 	// If _give_logged_in_only is set to enable then guest can donate from that specific form.
898 897
 	// Otherwise it is member only donation form.
899
-	$val = give_get_meta( $form_id, '_give_logged_in_only', true );
900
-	$val = ! empty( $val ) ? $val : 'enabled';
898
+	$val = give_get_meta($form_id, '_give_logged_in_only', true);
899
+	$val = ! empty($val) ? $val : 'enabled';
901 900
 
902
-	$ret = ! give_is_setting_enabled( $val );
901
+	$ret = ! give_is_setting_enabled($val);
903 902
 
904
-	return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id );
903
+	return (bool) apply_filters('give_logged_in_only', $ret, $form_id);
905 904
 }
906 905
 
907 906
 
@@ -914,11 +913,11 @@  discard block
 block discarded – undo
914 913
  *
915 914
  * @return string
916 915
  */
917
-function give_show_login_register_option( $form_id ) {
916
+function give_show_login_register_option($form_id) {
918 917
 
919
-	$show_register_form = give_get_meta( $form_id, '_give_show_register_form', true );
918
+	$show_register_form = give_get_meta($form_id, '_give_show_register_form', true);
920 919
 
921
-	return apply_filters( 'give_show_register_form', $show_register_form, $form_id );
920
+	return apply_filters('give_show_register_form', $show_register_form, $form_id);
922 921
 
923 922
 }
924 923
 
@@ -934,12 +933,12 @@  discard block
 block discarded – undo
934 933
  *
935 934
  * @return array
936 935
  */
937
-function _give_get_prefill_form_field_values( $form_id ) {
936
+function _give_get_prefill_form_field_values($form_id) {
938 937
 	$logged_in_donor_info = array();
939 938
 
940
-	if ( is_user_logged_in() ) :
941
-		$donor_data    = get_userdata( get_current_user_id() );
942
-		$donor_address = get_user_meta( get_current_user_id(), '_give_user_address', true );
939
+	if (is_user_logged_in()) :
940
+		$donor_data    = get_userdata(get_current_user_id());
941
+		$donor_address = get_user_meta(get_current_user_id(), '_give_user_address', true);
943 942
 
944 943
 		$logged_in_donor_info = array(
945 944
 			// First name.
@@ -952,42 +951,42 @@  discard block
 block discarded – undo
952 951
 			'give_email'      => $donor_data->user_email,
953 952
 
954 953
 			// Street address 1.
955
-			'card_address'    => ( ! empty( $donor_address['line1'] ) ? $donor_address['line1'] : '' ),
954
+			'card_address'    => ( ! empty($donor_address['line1']) ? $donor_address['line1'] : ''),
956 955
 
957 956
 			// Street address 2.
958
-			'card_address_2'  => ( ! empty( $donor_address['line2'] ) ? $donor_address['line2'] : '' ),
957
+			'card_address_2'  => ( ! empty($donor_address['line2']) ? $donor_address['line2'] : ''),
959 958
 
960 959
 			// Country.
961
-			'billing_country' => ( ! empty( $donor_address['country'] ) ? $donor_address['country'] : '' ),
960
+			'billing_country' => ( ! empty($donor_address['country']) ? $donor_address['country'] : ''),
962 961
 
963 962
 			// State.
964
-			'card_state'      => ( ! empty( $donor_address['state'] ) ? $donor_address['state'] : '' ),
963
+			'card_state'      => ( ! empty($donor_address['state']) ? $donor_address['state'] : ''),
965 964
 
966 965
 			// City.
967
-			'card_city'       => ( ! empty( $donor_address['city'] ) ? $donor_address['city'] : '' ),
966
+			'card_city'       => ( ! empty($donor_address['city']) ? $donor_address['city'] : ''),
968 967
 
969 968
 			// Zipcode
970
-			'card_zip'        => ( ! empty( $donor_address['zip'] ) ? $donor_address['zip'] : '' ),
969
+			'card_zip'        => ( ! empty($donor_address['zip']) ? $donor_address['zip'] : ''),
971 970
 		);
972 971
 	endif;
973 972
 
974 973
 	// Bailout: Auto fill form field values only form form which donor is donating.
975 974
 	if (
976
-		empty( $_GET['form-id'] )
975
+		empty($_GET['form-id'])
977 976
 		|| ! $form_id
978
-		|| ( $form_id !== absint( $_GET['form-id'] ) )
977
+		|| ($form_id !== absint($_GET['form-id']))
979 978
 	) {
980 979
 		return $logged_in_donor_info;
981 980
 	}
982 981
 
983 982
 	// Get purchase data.
984
-	$give_purchase_data = Give()->session->get( 'give_purchase' );
983
+	$give_purchase_data = Give()->session->get('give_purchase');
985 984
 
986 985
 	// Get donor info from form data.
987
-	$give_donor_info_in_session = empty( $give_purchase_data['post_data'] )
986
+	$give_donor_info_in_session = empty($give_purchase_data['post_data'])
988 987
 		? array()
989 988
 		: $give_purchase_data['post_data'];
990 989
 
991 990
 	// Output.
992
-	return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info );
991
+	return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info);
993 992
 }
Please login to merge, or discard this patch.
includes/payments/functions.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
  *
706 706
  * @since 1.0
707 707
  *
708
- * @return int $earnings Earnings
708
+ * @return double $earnings Earnings
709 709
  */
710 710
 function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
711 711
 
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
  *
994 994
  * @since 1.0
995 995
  *
996
- * @return array $user_info User Info Meta Values.
996
+ * @return string $user_info User Info Meta Values.
997 997
  */
998 998
 function give_get_payment_meta_user_info( $payment_id ) {
999 999
 	$payment = new Give_Payment( $payment_id );
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
  *
1011 1011
  * @since 1.0
1012 1012
  *
1013
- * @return int $form_id Form ID.
1013
+ * @return string $form_id Form ID.
1014 1014
  */
1015 1015
 function give_get_payment_form_id( $payment_id ) {
1016 1016
 	$payment = new Give_Payment( $payment_id );
Please login to merge, or discard this patch.
Spacing   +418 added lines, -418 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
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
  *
44 44
  * @return array $payments Payments retrieved from the database
45 45
  */
46
-function give_get_payments( $args = array() ) {
46
+function give_get_payments($args = array()) {
47 47
 
48 48
 	// Fallback to post objects to ensure backwards compatibility.
49
-	if ( ! isset( $args['output'] ) ) {
49
+	if ( ! isset($args['output'])) {
50 50
 		$args['output'] = 'posts';
51 51
 	}
52 52
 
53
-	$args     = apply_filters( 'give_get_payments_args', $args );
54
-	$payments = new Give_Payments_Query( $args );
53
+	$args     = apply_filters('give_get_payments_args', $args);
54
+	$payments = new Give_Payments_Query($args);
55 55
 
56 56
 	return $payments->get_payments();
57 57
 }
@@ -66,48 +66,48 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return mixed
68 68
  */
69
-function give_get_payment_by( $field = '', $value = '' ) {
69
+function give_get_payment_by($field = '', $value = '') {
70 70
 
71
-	if ( empty( $field ) || empty( $value ) ) {
71
+	if (empty($field) || empty($value)) {
72 72
 		return false;
73 73
 	}
74 74
 
75
-	switch ( strtolower( $field ) ) {
75
+	switch (strtolower($field)) {
76 76
 
77 77
 		case 'id':
78
-			$payment = new Give_Payment( $value );
78
+			$payment = new Give_Payment($value);
79 79
 			$id      = $payment->ID;
80 80
 
81
-			if ( empty( $id ) ) {
81
+			if (empty($id)) {
82 82
 				return false;
83 83
 			}
84 84
 
85 85
 			break;
86 86
 
87 87
 		case 'key':
88
-			$payment = give_get_payments( array(
88
+			$payment = give_get_payments(array(
89 89
 				'meta_key'       => '_give_payment_purchase_key',
90 90
 				'meta_value'     => $value,
91 91
 				'posts_per_page' => 1,
92 92
 				'fields'         => 'ids',
93
-			) );
93
+			));
94 94
 
95
-			if ( $payment ) {
96
-				$payment = new Give_Payment( $payment[0] );
95
+			if ($payment) {
96
+				$payment = new Give_Payment($payment[0]);
97 97
 			}
98 98
 
99 99
 			break;
100 100
 
101 101
 		case 'payment_number':
102
-			$payment = give_get_payments( array(
102
+			$payment = give_get_payments(array(
103 103
 				'meta_key'       => '_give_payment_number',
104 104
 				'meta_value'     => $value,
105 105
 				'posts_per_page' => 1,
106 106
 				'fields'         => 'ids',
107
-			) );
107
+			));
108 108
 
109
-			if ( $payment ) {
110
-				$payment = new Give_Payment( $payment[0] );
109
+			if ($payment) {
110
+				$payment = new Give_Payment($payment[0]);
111 111
 			}
112 112
 
113 113
 			break;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			return false;
117 117
 	}// End switch().
118 118
 
119
-	if ( $payment ) {
119
+	if ($payment) {
120 120
 		return $payment;
121 121
 	}
122 122
 
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return int|bool Payment ID if payment is inserted, false otherwise.
134 134
  */
135
-function give_insert_payment( $payment_data = array() ) {
135
+function give_insert_payment($payment_data = array()) {
136 136
 
137
-	if ( empty( $payment_data ) ) {
137
+	if (empty($payment_data)) {
138 138
 		return false;
139 139
 	}
140 140
 
@@ -145,25 +145,25 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @param array $payment_data Arguments passed.
147 147
 	 */
148
-	$payment_data = apply_filters( 'give_pre_insert_payment', $payment_data );
148
+	$payment_data = apply_filters('give_pre_insert_payment', $payment_data);
149 149
 
150 150
 	$payment    = new Give_Payment();
151
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
152
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
153
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
154
-	$price_id   = give_get_payment_meta_price_id( $payment_data );
155
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
151
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
152
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
153
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
154
+	$price_id   = give_get_payment_meta_price_id($payment_data);
155
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
156 156
 
157 157
 	// Set properties.
158 158
 	$payment->total          = $payment_data['price'];
159
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
160
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency( $payment_data['give_form_id'], $payment_data );
159
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
160
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency($payment_data['give_form_id'], $payment_data);
161 161
 	$payment->user_info      = $payment_data['user_info'];
162 162
 	$payment->gateway        = $gateway;
163 163
 	$payment->form_title     = $form_title;
164 164
 	$payment->form_id        = $form_id;
165 165
 	$payment->price_id       = $price_id;
166
-	$payment->donor_id       = ( ! empty( $payment_data['donor_id'] ) ? $payment_data['donor_id'] : '' );
166
+	$payment->donor_id       = ( ! empty($payment_data['donor_id']) ? $payment_data['donor_id'] : '');
167 167
 	$payment->user_id        = $payment_data['user_info']['id'];
168 168
 	$payment->email          = $payment_data['user_email'];
169 169
 	$payment->first_name     = $payment_data['user_info']['first_name'];
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	$payment->email          = $payment_data['user_info']['email'];
172 172
 	$payment->ip             = give_get_ip();
173 173
 	$payment->key            = $payment_data['purchase_key'];
174
-	$payment->mode           = ( ! empty( $payment_data['mode'] ) ? (string) $payment_data['mode'] : ( give_is_test_mode() ? 'test' : 'live' ) );
175
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
174
+	$payment->mode           = ( ! empty($payment_data['mode']) ? (string) $payment_data['mode'] : (give_is_test_mode() ? 'test' : 'live'));
175
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
176 176
 
177 177
 	// Add the donation.
178 178
 	$args = array(
@@ -180,19 +180,19 @@  discard block
 block discarded – undo
180 180
 		'price_id' => $payment->price_id,
181 181
 	);
182 182
 
183
-	$payment->add_donation( $payment->form_id, $args );
183
+	$payment->add_donation($payment->form_id, $args);
184 184
 
185 185
 
186 186
 	// Set date if present.
187
-	if ( isset( $payment_data['post_date'] ) ) {
187
+	if (isset($payment_data['post_date'])) {
188 188
 		$payment->date = $payment_data['post_date'];
189 189
 	}
190 190
 
191 191
 	// Handle sequential payments.
192
-	if ( give_get_option( 'enable_sequential' ) ) {
192
+	if (give_get_option('enable_sequential')) {
193 193
 		$number          = give_get_next_payment_number();
194
-		$payment->number = give_format_payment_number( $number );
195
-		update_option( 'give_last_payment_number', $number );
194
+		$payment->number = give_format_payment_number($number);
195
+		update_option('give_last_payment_number', $number);
196 196
 	}
197 197
 
198 198
 	// Save payment.
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
 	 * @param int $payment_id The payment ID.
207 207
 	 * @param array $payment_data Arguments passed.
208 208
 	 */
209
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
209
+	do_action('give_insert_payment', $payment->ID, $payment_data);
210 210
 
211 211
 	// Return payment ID upon success.
212
-	if ( ! empty( $payment->ID ) ) {
212
+	if ( ! empty($payment->ID)) {
213 213
 		return $payment->ID;
214 214
 	}
215 215
 
@@ -225,10 +225,10 @@  discard block
 block discarded – undo
225 225
  *
226 226
  * @return bool|int
227 227
  */
228
-function give_create_payment( $payment_data ) {
228
+function give_create_payment($payment_data) {
229 229
 
230
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
231
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
230
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
231
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
232 232
 
233 233
 	// Collect payment data.
234 234
 	$insert_payment_data = array(
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		'date'            => $payment_data['date'],
240 240
 		'user_email'      => $payment_data['user_email'],
241 241
 		'purchase_key'    => $payment_data['purchase_key'],
242
-		'currency'        => give_get_currency( $form_id, $payment_data ),
242
+		'currency'        => give_get_currency($form_id, $payment_data),
243 243
 		'user_info'       => $payment_data['user_info'],
244 244
 		'status'          => 'pending',
245 245
 		'gateway'         => 'paypal',
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
 	 *
253 253
 	 * @param array $insert_payment_data
254 254
 	 */
255
-	$insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data );
255
+	$insert_payment_data = apply_filters('give_create_payment', $insert_payment_data);
256 256
 
257 257
 	// Record the pending payment.
258
-	return give_insert_payment( $insert_payment_data );
258
+	return give_insert_payment($insert_payment_data);
259 259
 }
260 260
 
261 261
 /**
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
  *
269 269
  * @return bool
270 270
  */
271
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
271
+function give_update_payment_status($payment_id, $new_status = 'publish') {
272 272
 
273 273
 	$updated = false;
274
-	$payment = new Give_Payment( $payment_id );
274
+	$payment = new Give_Payment($payment_id);
275 275
 
276
-	if ( $payment && $payment->ID > 0 ) {
276
+	if ($payment && $payment->ID > 0) {
277 277
 
278 278
 		$payment->status = $new_status;
279 279
 		$updated         = $payment->save();
@@ -295,38 +295,38 @@  discard block
 block discarded – undo
295 295
  *
296 296
  * @return void
297 297
  */
298
-function give_delete_donation( $payment_id = 0, $update_donor = true ) {
298
+function give_delete_donation($payment_id = 0, $update_donor = true) {
299 299
 	global $give_logs;
300 300
 
301
-	$payment  = new Give_Payment( $payment_id );
302
-	$amount   = give_get_payment_amount( $payment_id );
301
+	$payment  = new Give_Payment($payment_id);
302
+	$amount   = give_get_payment_amount($payment_id);
303 303
 	$status   = $payment->post_status;
304
-	$donor_id = give_get_payment_donor_id( $payment_id );
305
-	$donor    = new Give_Donor( $donor_id );
304
+	$donor_id = give_get_payment_donor_id($payment_id);
305
+	$donor    = new Give_Donor($donor_id);
306 306
 
307 307
 	// Only undo donations that aren't these statuses.
308
-	$dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array(
308
+	$dont_undo_statuses = apply_filters('give_undo_donation_statuses', array(
309 309
 		'pending',
310 310
 		'cancelled',
311
-	) );
311
+	));
312 312
 
313
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
314
-		give_undo_donation( $payment_id );
313
+	if ( ! in_array($status, $dont_undo_statuses)) {
314
+		give_undo_donation($payment_id);
315 315
 	}
316 316
 
317
-	if ( $status == 'publish' ) {
317
+	if ($status == 'publish') {
318 318
 
319 319
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
320
-		give_decrease_total_earnings( $amount );
320
+		give_decrease_total_earnings($amount);
321 321
 
322 322
 		// @todo: Refresh only range related stat cache
323 323
 		give_delete_donation_stats();
324 324
 
325
-		if ( $donor->id && $update_donor ) {
325
+		if ($donor->id && $update_donor) {
326 326
 
327 327
 			// Decrement the stats for the donor.
328 328
 			$donor->decrease_donation_count();
329
-			$donor->decrease_value( $amount );
329
+			$donor->decrease_value($amount);
330 330
 
331 331
 		}
332 332
 	}
@@ -338,25 +338,25 @@  discard block
 block discarded – undo
338 338
 	 *
339 339
 	 * @since 1.0
340 340
 	 */
341
-	do_action( 'give_payment_delete', $payment_id );
341
+	do_action('give_payment_delete', $payment_id);
342 342
 
343
-	if ( $donor->id && $update_donor ) {
343
+	if ($donor->id && $update_donor) {
344 344
 
345 345
 		// Remove the payment ID from the donor.
346
-		$donor->remove_payment( $payment_id );
346
+		$donor->remove_payment($payment_id);
347 347
 
348 348
 	}
349 349
 
350 350
 	// Remove the payment.
351
-	wp_delete_post( $payment_id, true );
351
+	wp_delete_post($payment_id, true);
352 352
 
353 353
 	// Remove related sale log entries.
354
-	$give_logs->delete_logs( null, 'sale', array(
354
+	$give_logs->delete_logs(null, 'sale', array(
355 355
 		array(
356 356
 			'key'   => '_give_log_payment_id',
357 357
 			'value' => $payment_id,
358 358
 		),
359
-	) );
359
+	));
360 360
 
361 361
 	/**
362 362
 	 * Fires after payment deleted.
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 *
366 366
 	 * @since 1.0
367 367
 	 */
368
-	do_action( 'give_payment_deleted', $payment_id );
368
+	do_action('give_payment_deleted', $payment_id);
369 369
 }
370 370
 
371 371
 /**
@@ -380,20 +380,20 @@  discard block
 block discarded – undo
380 380
  *
381 381
  * @return void
382 382
  */
383
-function give_undo_donation( $payment_id ) {
383
+function give_undo_donation($payment_id) {
384 384
 
385
-	$payment = new Give_Payment( $payment_id );
385
+	$payment = new Give_Payment($payment_id);
386 386
 
387
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
388
-	if ( true === $maybe_decrease_earnings ) {
387
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
388
+	if (true === $maybe_decrease_earnings) {
389 389
 		// Decrease earnings.
390
-		give_decrease_earnings( $payment->form_id, $payment->total );
390
+		give_decrease_earnings($payment->form_id, $payment->total);
391 391
 	}
392 392
 
393
-	$maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id );
394
-	if ( true === $maybe_decrease_donations ) {
393
+	$maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id);
394
+	if (true === $maybe_decrease_donations) {
395 395
 		// Decrease donation count.
396
-		give_decrease_donation_count( $payment->form_id );
396
+		give_decrease_donation_count($payment->form_id);
397 397
 	}
398 398
 
399 399
 }
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
  *
411 411
  * @return object $stats Contains the number of payments per payment status.
412 412
  */
413
-function give_count_payments( $args = array() ) {
413
+function give_count_payments($args = array()) {
414 414
 
415 415
 	global $wpdb;
416 416
 
@@ -422,18 +422,18 @@  discard block
 block discarded – undo
422 422
 		'form_id'    => null,
423 423
 	);
424 424
 
425
-	$args = wp_parse_args( $args, $defaults );
425
+	$args = wp_parse_args($args, $defaults);
426 426
 
427 427
 	$select = 'SELECT p.post_status,count( * ) AS num_posts';
428 428
 	$join   = '';
429
-	$where  = "WHERE p.post_type = 'give_payment' AND p.post_status IN ('" . implode( "','", give_get_payment_status_keys() ) . "')";
429
+	$where  = "WHERE p.post_type = 'give_payment' AND p.post_status IN ('".implode("','", give_get_payment_status_keys())."')";
430 430
 
431 431
 	// Count payments for a specific user.
432
-	if ( ! empty( $args['user'] ) ) {
432
+	if ( ! empty($args['user'])) {
433 433
 
434
-		if ( is_email( $args['user'] ) ) {
434
+		if (is_email($args['user'])) {
435 435
 			$field = 'email';
436
-		} elseif ( is_numeric( $args['user'] ) ) {
436
+		} elseif (is_numeric($args['user'])) {
437 437
 			$field = 'id';
438 438
 		} else {
439 439
 			$field = '';
@@ -441,107 +441,107 @@  discard block
 block discarded – undo
441 441
 
442 442
 		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
443 443
 
444
-		if ( ! empty( $field ) ) {
444
+		if ( ! empty($field)) {
445 445
 			$where .= "
446 446
 				AND m.meta_key = '_give_payment_user_{$field}'
447 447
 				AND m.meta_value = '{$args['user']}'";
448 448
 		}
449
-	} elseif ( ! empty( $args['donor'] ) ) {
449
+	} elseif ( ! empty($args['donor'])) {
450 450
 
451
-		$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
451
+		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
452 452
 		$where .= "
453 453
 			AND m.meta_key = '_give_payment_customer_id'
454 454
 			AND m.meta_value = '{$args['donor']}'";
455 455
 
456 456
 		// Count payments for a search.
457
-	} elseif ( ! empty( $args['s'] ) ) {
457
+	} elseif ( ! empty($args['s'])) {
458 458
 
459
-		if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) {
459
+		if (is_email($args['s']) || strlen($args['s']) == 32) {
460 460
 
461
-			if ( is_email( $args['s'] ) ) {
461
+			if (is_email($args['s'])) {
462 462
 				$field = '_give_payment_user_email';
463 463
 			} else {
464 464
 				$field = '_give_payment_purchase_key';
465 465
 			}
466 466
 
467
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
468
-			$where .= $wpdb->prepare( '
467
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
468
+			$where .= $wpdb->prepare('
469 469
                 AND m.meta_key = %s
470
-                AND m.meta_value = %s', $field, $args['s'] );
470
+                AND m.meta_value = %s', $field, $args['s']);
471 471
 
472
-		} elseif ( '#' == substr( $args['s'], 0, 1 ) ) {
472
+		} elseif ('#' == substr($args['s'], 0, 1)) {
473 473
 
474
-			$search = str_replace( '#:', '', $args['s'] );
475
-			$search = str_replace( '#', '', $search );
474
+			$search = str_replace('#:', '', $args['s']);
475
+			$search = str_replace('#', '', $search);
476 476
 
477 477
 			$select = 'SELECT p.post_status,count( * ) AS num_posts ';
478 478
 			$join   = '';
479
-			$where  = $wpdb->prepare( 'WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search );
479
+			$where  = $wpdb->prepare('WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search);
480 480
 
481
-		} elseif ( is_numeric( $args['s'] ) ) {
481
+		} elseif (is_numeric($args['s'])) {
482 482
 
483
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
484
-			$where .= $wpdb->prepare( "
483
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
484
+			$where .= $wpdb->prepare("
485 485
 				AND m.meta_key = '_give_payment_user_id'
486
-				AND m.meta_value = %d", $args['s'] );
486
+				AND m.meta_value = %d", $args['s']);
487 487
 
488 488
 		} else {
489
-			$search = $wpdb->esc_like( $args['s'] );
490
-			$search = '%' . $search . '%';
489
+			$search = $wpdb->esc_like($args['s']);
490
+			$search = '%'.$search.'%';
491 491
 
492
-			$where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search );
492
+			$where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search);
493 493
 		}// End if().
494 494
 	}// End if().
495 495
 
496
-	if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) {
496
+	if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) {
497 497
 
498
-		$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
499
-		$where .= $wpdb->prepare( '
498
+		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
499
+		$where .= $wpdb->prepare('
500 500
                 AND m.meta_key = %s
501
-                AND m.meta_value = %s', '_give_payment_form_id', $args['form_id'] );
501
+                AND m.meta_value = %s', '_give_payment_form_id', $args['form_id']);
502 502
 	}
503 503
 
504 504
 	// Limit payments count by date.
505
-	if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) {
505
+	if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) {
506 506
 
507
-		$date_parts = explode( '/', $args['start-date'] );
508
-		$month      = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0;
509
-		$day        = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0;
510
-		$year       = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0;
507
+		$date_parts = explode('/', $args['start-date']);
508
+		$month      = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0;
509
+		$day        = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0;
510
+		$year       = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0;
511 511
 
512
-		$is_date = checkdate( $month, $day, $year );
513
-		if ( false !== $is_date ) {
512
+		$is_date = checkdate($month, $day, $year);
513
+		if (false !== $is_date) {
514 514
 
515
-			$date  = new DateTime( $args['start-date'] );
516
-			$where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) );
515
+			$date = new DateTime($args['start-date']);
516
+			$where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d'));
517 517
 
518 518
 		}
519 519
 
520 520
 		// Fixes an issue with the payments list table counts when no end date is specified (with stats class).
521
-		if ( empty( $args['end-date'] ) ) {
521
+		if (empty($args['end-date'])) {
522 522
 			$args['end-date'] = $args['start-date'];
523 523
 		}
524 524
 	}
525 525
 
526
-	if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) {
526
+	if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) {
527 527
 
528
-		$date_parts = explode( '/', $args['end-date'] );
528
+		$date_parts = explode('/', $args['end-date']);
529 529
 
530
-		$month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0;
531
-		$day   = ! empty( $date_parts[1] ) ? $date_parts[1] : 0;
532
-		$year  = ! empty( $date_parts[2] ) ? $date_parts[2] : 0;
530
+		$month = ! empty($date_parts[0]) ? $date_parts[0] : 0;
531
+		$day   = ! empty($date_parts[1]) ? $date_parts[1] : 0;
532
+		$year  = ! empty($date_parts[2]) ? $date_parts[2] : 0;
533 533
 
534
-		$is_date = checkdate( $month, $day, $year );
535
-		if ( false !== $is_date ) {
534
+		$is_date = checkdate($month, $day, $year);
535
+		if (false !== $is_date) {
536 536
 
537
-			$date  = new DateTime( $args['end-date'] );
538
-			$where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) );
537
+			$date = new DateTime($args['end-date']);
538
+			$where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d'));
539 539
 
540 540
 		}
541 541
 	}
542 542
 
543
-	$where = apply_filters( 'give_count_payments_where', $where );
544
-	$join  = apply_filters( 'give_count_payments_join', $join );
543
+	$where = apply_filters('give_count_payments_where', $where);
544
+	$join  = apply_filters('give_count_payments_join', $join);
545 545
 
546 546
 	$query = "$select
547 547
 		FROM $wpdb->posts p
@@ -550,36 +550,36 @@  discard block
 block discarded – undo
550 550
 		GROUP BY p.post_status
551 551
 	";
552 552
 
553
-	$cache_key = md5( $query );
553
+	$cache_key = md5($query);
554 554
 
555
-	$count = wp_cache_get( $cache_key, 'counts' );
556
-	if ( false !== $count ) {
555
+	$count = wp_cache_get($cache_key, 'counts');
556
+	if (false !== $count) {
557 557
 		return $count;
558 558
 	}
559 559
 
560
-	$count = $wpdb->get_results( $query, ARRAY_A );
560
+	$count = $wpdb->get_results($query, ARRAY_A);
561 561
 
562 562
 	$stats    = array();
563 563
 	$statuses = get_post_stati();
564
-	if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) {
565
-		unset( $statuses['private'] );
564
+	if (isset($statuses['private']) && empty($args['s'])) {
565
+		unset($statuses['private']);
566 566
 	}
567 567
 
568
-	foreach ( $statuses as $state ) {
569
-		$stats[ $state ] = 0;
568
+	foreach ($statuses as $state) {
569
+		$stats[$state] = 0;
570 570
 	}
571 571
 
572
-	foreach ( (array) $count as $row ) {
572
+	foreach ((array) $count as $row) {
573 573
 
574
-		if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) {
574
+		if ('private' == $row['post_status'] && empty($args['s'])) {
575 575
 			continue;
576 576
 		}
577 577
 
578
-		$stats[ $row['post_status'] ] = $row['num_posts'];
578
+		$stats[$row['post_status']] = $row['num_posts'];
579 579
 	}
580 580
 
581 581
 	$stats = (object) $stats;
582
-	wp_cache_set( $cache_key, $stats, 'counts' );
582
+	wp_cache_set($cache_key, $stats, 'counts');
583 583
 
584 584
 	return $stats;
585 585
 }
@@ -594,11 +594,11 @@  discard block
 block discarded – undo
594 594
  *
595 595
  * @return bool $exists True if payment exists, false otherwise.
596 596
  */
597
-function give_check_for_existing_payment( $payment_id ) {
597
+function give_check_for_existing_payment($payment_id) {
598 598
 	$exists  = false;
599
-	$payment = new Give_Payment( $payment_id );
599
+	$payment = new Give_Payment($payment_id);
600 600
 
601
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
601
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
602 602
 		$exists = true;
603 603
 	}
604 604
 
@@ -615,41 +615,41 @@  discard block
 block discarded – undo
615 615
  *
616 616
  * @return bool|mixed True if payment status exists, false otherwise.
617 617
  */
618
-function give_get_payment_status( $payment, $return_label = false ) {
618
+function give_get_payment_status($payment, $return_label = false) {
619 619
 
620
-	if ( is_numeric( $payment ) ) {
620
+	if (is_numeric($payment)) {
621 621
 
622
-		$payment = new Give_Payment( $payment );
622
+		$payment = new Give_Payment($payment);
623 623
 
624
-		if ( ! $payment->ID > 0 ) {
624
+		if ( ! $payment->ID > 0) {
625 625
 			return false;
626 626
 		}
627 627
 
628 628
 	}
629 629
 
630
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
630
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
631 631
 		return false;
632 632
 	}
633 633
 
634 634
 	$statuses = give_get_payment_statuses();
635 635
 
636
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
636
+	if ( ! is_array($statuses) || empty($statuses)) {
637 637
 		return false;
638 638
 	}
639 639
 
640 640
 	// Get payment object if not already given.
641
-	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID );
641
+	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID);
642 642
 
643
-	if ( array_key_exists( $payment->status, $statuses ) ) {
644
-		if ( true === $return_label ) {
643
+	if (array_key_exists($payment->status, $statuses)) {
644
+		if (true === $return_label) {
645 645
 			// Return translated status label.
646
-			return $statuses[ $payment->status ];
646
+			return $statuses[$payment->status];
647 647
 		} else {
648 648
 			// Account that our 'publish' status is labeled 'Complete'
649 649
 			$post_status = 'publish' === $payment->status ? 'Complete' : $payment->post_status;
650 650
 
651 651
 			// Make sure we're matching cases, since they matter
652
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
652
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
653 653
 		}
654 654
 	}
655 655
 
@@ -665,18 +665,18 @@  discard block
 block discarded – undo
665 665
  */
666 666
 function give_get_payment_statuses() {
667 667
 	$payment_statuses = array(
668
-		'pending'     => __( 'Pending', 'give' ),
669
-		'publish'     => __( 'Complete', 'give' ),
670
-		'refunded'    => __( 'Refunded', 'give' ),
671
-		'failed'      => __( 'Failed', 'give' ),
672
-		'cancelled'   => __( 'Cancelled', 'give' ),
673
-		'abandoned'   => __( 'Abandoned', 'give' ),
674
-		'preapproval' => __( 'Pre-Approved', 'give' ),
675
-		'processing'  => __( 'Processing', 'give' ),
676
-		'revoked'     => __( 'Revoked', 'give' ),
668
+		'pending'     => __('Pending', 'give'),
669
+		'publish'     => __('Complete', 'give'),
670
+		'refunded'    => __('Refunded', 'give'),
671
+		'failed'      => __('Failed', 'give'),
672
+		'cancelled'   => __('Cancelled', 'give'),
673
+		'abandoned'   => __('Abandoned', 'give'),
674
+		'preapproval' => __('Pre-Approved', 'give'),
675
+		'processing'  => __('Processing', 'give'),
676
+		'revoked'     => __('Revoked', 'give'),
677 677
 	);
678 678
 
679
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
679
+	return apply_filters('give_payment_statuses', $payment_statuses);
680 680
 }
681 681
 
682 682
 /**
@@ -689,10 +689,10 @@  discard block
 block discarded – undo
689 689
  * @return array $payment_status All the available payment statuses.
690 690
  */
691 691
 function give_get_payment_status_keys() {
692
-	$statuses = array_keys( give_get_payment_statuses() );
693
-	asort( $statuses );
692
+	$statuses = array_keys(give_get_payment_statuses());
693
+	asort($statuses);
694 694
 
695
-	return array_values( $statuses );
695
+	return array_values($statuses);
696 696
 }
697 697
 
698 698
 /**
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
  *
708 708
  * @return int $earnings Earnings
709 709
  */
710
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
710
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
711 711
 
712 712
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
713 713
 	global $wpdb;
@@ -717,41 +717,41 @@  discard block
 block discarded – undo
717 717
 		'nopaging'               => true,
718 718
 		'year'                   => $year,
719 719
 		'monthnum'               => $month_num,
720
-		'post_status'            => array( 'publish' ),
720
+		'post_status'            => array('publish'),
721 721
 		'fields'                 => 'ids',
722 722
 		'update_post_term_cache' => false,
723 723
 	);
724
-	if ( ! empty( $day ) ) {
724
+	if ( ! empty($day)) {
725 725
 		$args['day'] = $day;
726 726
 	}
727 727
 
728
-	if ( isset( $hour ) ) {
728
+	if (isset($hour)) {
729 729
 		$args['hour'] = $hour;
730 730
 	}
731 731
 
732
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
733
-	$key  = Give_Cache::get_key( 'give_stats', $args );
732
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
733
+	$key  = Give_Cache::get_key('give_stats', $args);
734 734
 
735
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
735
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
736 736
 		$earnings = false;
737 737
 	} else {
738
-		$earnings = Give_Cache::get( $key );
738
+		$earnings = Give_Cache::get($key);
739 739
 	}
740 740
 
741
-	if ( false === $earnings ) {
742
-		$donations = get_posts( $args );
741
+	if (false === $earnings) {
742
+		$donations = get_posts($args);
743 743
 		$earnings  = 0;
744
-		if ( $donations ) {
745
-			$donations = implode( ',', $donations );
744
+		if ($donations) {
745
+			$donations = implode(',', $donations);
746 746
 
747
-			$earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" );
747
+			$earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})");
748 748
 
749 749
 		}
750 750
 		// Cache the results for one hour.
751
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
751
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
752 752
 	}
753 753
 
754
-	return round( $earnings, 2 );
754
+	return round($earnings, 2);
755 755
 }
756 756
 
757 757
 /**
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
  *
767 767
  * @return int $count Sales
768 768
  */
769
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
769
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
770 770
 
771 771
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
772 772
 	$args = array(
@@ -774,14 +774,14 @@  discard block
 block discarded – undo
774 774
 		'nopaging'               => true,
775 775
 		'year'                   => $year,
776 776
 		'fields'                 => 'ids',
777
-		'post_status'            => array( 'publish' ),
777
+		'post_status'            => array('publish'),
778 778
 		'update_post_meta_cache' => false,
779 779
 		'update_post_term_cache' => false,
780 780
 	);
781 781
 
782
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
782
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
783 783
 
784
-	if ( false === $show_free ) {
784
+	if (false === $show_free) {
785 785
 		$args['meta_query'] = array(
786 786
 			array(
787 787
 				'key'     => '_give_payment_total',
@@ -792,33 +792,33 @@  discard block
 block discarded – undo
792 792
 		);
793 793
 	}
794 794
 
795
-	if ( ! empty( $month_num ) ) {
795
+	if ( ! empty($month_num)) {
796 796
 		$args['monthnum'] = $month_num;
797 797
 	}
798 798
 
799
-	if ( ! empty( $day ) ) {
799
+	if ( ! empty($day)) {
800 800
 		$args['day'] = $day;
801 801
 	}
802 802
 
803
-	if ( isset( $hour ) ) {
803
+	if (isset($hour)) {
804 804
 		$args['hour'] = $hour;
805 805
 	}
806 806
 
807
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
807
+	$args = apply_filters('give_get_sales_by_date_args', $args);
808 808
 
809
-	$key = Give_Cache::get_key( 'give_stats', $args );
809
+	$key = Give_Cache::get_key('give_stats', $args);
810 810
 
811
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
811
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
812 812
 		$count = false;
813 813
 	} else {
814
-		$count = Give_Cache::get( $key );
814
+		$count = Give_Cache::get($key);
815 815
 	}
816 816
 
817
-	if ( false === $count ) {
818
-		$donations = new WP_Query( $args );
817
+	if (false === $count) {
818
+		$donations = new WP_Query($args);
819 819
 		$count     = (int) $donations->post_count;
820 820
 		// Cache the results for one hour.
821
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
821
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
822 822
 	}
823 823
 
824 824
 	return $count;
@@ -833,19 +833,19 @@  discard block
 block discarded – undo
833 833
  *
834 834
  * @return bool $ret True if complete, false otherwise.
835 835
  */
836
-function give_is_payment_complete( $payment_id ) {
837
-	$payment = new Give_Payment( $payment_id );
836
+function give_is_payment_complete($payment_id) {
837
+	$payment = new Give_Payment($payment_id);
838 838
 
839 839
 	$ret = false;
840 840
 
841
-	if ( $payment->ID > 0 ) {
841
+	if ($payment->ID > 0) {
842 842
 
843
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
843
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
844 844
 			$ret = true;
845 845
 		}
846 846
 	}
847 847
 
848
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
848
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
849 849
 }
850 850
 
851 851
 /**
@@ -871,49 +871,49 @@  discard block
 block discarded – undo
871 871
  *
872 872
  * @return float $total Total earnings.
873 873
  */
874
-function give_get_total_earnings( $recalculate = false ) {
874
+function give_get_total_earnings($recalculate = false) {
875 875
 
876
-	$total = get_option( 'give_earnings_total', 0 );
876
+	$total = get_option('give_earnings_total', 0);
877 877
 
878 878
 	// Calculate total earnings.
879
-	if ( ! $total || $recalculate ) {
879
+	if ( ! $total || $recalculate) {
880 880
 		global $wpdb;
881 881
 
882 882
 		$total = (float) 0;
883 883
 
884
-		$args = apply_filters( 'give_get_total_earnings_args', array(
884
+		$args = apply_filters('give_get_total_earnings_args', array(
885 885
 			'offset' => 0,
886
-			'number' => - 1,
887
-			'status' => array( 'publish' ),
886
+			'number' => -1,
887
+			'status' => array('publish'),
888 888
 			'fields' => 'ids',
889
-		) );
889
+		));
890 890
 
891
-		$payments = give_get_payments( $args );
892
-		if ( $payments ) {
891
+		$payments = give_get_payments($args);
892
+		if ($payments) {
893 893
 
894 894
 			/**
895 895
 			 * If performing a donation, we need to skip the very last payment in the database,
896 896
 			 * since it calls give_increase_total_earnings() on completion,
897 897
 			 * which results in duplicated earnings for the very first donation.
898 898
 			 */
899
-			if ( did_action( 'give_update_payment_status' ) ) {
900
-				array_pop( $payments );
899
+			if (did_action('give_update_payment_status')) {
900
+				array_pop($payments);
901 901
 			}
902 902
 
903
-			if ( ! empty( $payments ) ) {
904
-				$payments = implode( ',', $payments );
905
-				$total    += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" );
903
+			if ( ! empty($payments)) {
904
+				$payments = implode(',', $payments);
905
+				$total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})");
906 906
 			}
907 907
 		}
908 908
 
909
-		update_option( 'give_earnings_total', $total, 'no' );
909
+		update_option('give_earnings_total', $total, 'no');
910 910
 	}
911 911
 
912
-	if ( $total < 0 ) {
912
+	if ($total < 0) {
913 913
 		$total = 0; // Don't ever show negative earnings.
914 914
 	}
915 915
 
916
-	return apply_filters( 'give_total_earnings', round( $total, give_get_price_decimals() ), $total );
916
+	return apply_filters('give_total_earnings', round($total, give_get_price_decimals()), $total);
917 917
 }
918 918
 
919 919
 /**
@@ -925,10 +925,10 @@  discard block
 block discarded – undo
925 925
  *
926 926
  * @return float $total Total earnings.
927 927
  */
928
-function give_increase_total_earnings( $amount = 0 ) {
928
+function give_increase_total_earnings($amount = 0) {
929 929
 	$total = give_get_total_earnings();
930 930
 	$total += $amount;
931
-	update_option( 'give_earnings_total', $total );
931
+	update_option('give_earnings_total', $total);
932 932
 
933 933
 	return $total;
934 934
 }
@@ -942,13 +942,13 @@  discard block
 block discarded – undo
942 942
  *
943 943
  * @return float $total Total earnings.
944 944
  */
945
-function give_decrease_total_earnings( $amount = 0 ) {
945
+function give_decrease_total_earnings($amount = 0) {
946 946
 	$total = give_get_total_earnings();
947 947
 	$total -= $amount;
948
-	if ( $total < 0 ) {
948
+	if ($total < 0) {
949 949
 		$total = 0;
950 950
 	}
951
-	update_option( 'give_earnings_total', $total );
951
+	update_option('give_earnings_total', $total);
952 952
 
953 953
 	return $total;
954 954
 }
@@ -964,10 +964,10 @@  discard block
 block discarded – undo
964 964
  *
965 965
  * @return mixed $meta Payment Meta.
966 966
  */
967
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
968
-	$payment = new Give_Payment( $payment_id );
967
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
968
+	$payment = new Give_Payment($payment_id);
969 969
 
970
-	return $payment->get_meta( $meta_key, $single );
970
+	return $payment->get_meta($meta_key, $single);
971 971
 }
972 972
 
973 973
 /**
@@ -980,10 +980,10 @@  discard block
 block discarded – undo
980 980
  *
981 981
  * @return mixed Meta ID if successful, false if unsuccessful.
982 982
  */
983
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
984
-	$payment = new Give_Payment( $payment_id );
983
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
984
+	$payment = new Give_Payment($payment_id);
985 985
 
986
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
986
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
987 987
 }
988 988
 
989 989
 /**
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
  *
996 996
  * @return array $user_info User Info Meta Values.
997 997
  */
998
-function give_get_payment_meta_user_info( $payment_id ) {
999
-	$payment = new Give_Payment( $payment_id );
998
+function give_get_payment_meta_user_info($payment_id) {
999
+	$payment = new Give_Payment($payment_id);
1000 1000
 
1001 1001
 	return $payment->user_info;
1002 1002
 }
@@ -1012,8 +1012,8 @@  discard block
 block discarded – undo
1012 1012
  *
1013 1013
  * @return int $form_id Form ID.
1014 1014
  */
1015
-function give_get_payment_form_id( $payment_id ) {
1016
-	$payment = new Give_Payment( $payment_id );
1015
+function give_get_payment_form_id($payment_id) {
1016
+	$payment = new Give_Payment($payment_id);
1017 1017
 
1018 1018
 	return $payment->form_id;
1019 1019
 }
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
  *
1028 1028
  * @return string $email User email.
1029 1029
  */
1030
-function give_get_payment_user_email( $payment_id ) {
1031
-	$payment = new Give_Payment( $payment_id );
1030
+function give_get_payment_user_email($payment_id) {
1031
+	$payment = new Give_Payment($payment_id);
1032 1032
 
1033 1033
 	return $payment->email;
1034 1034
 }
@@ -1042,11 +1042,11 @@  discard block
 block discarded – undo
1042 1042
  *
1043 1043
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
1044 1044
  */
1045
-function give_is_guest_payment( $payment_id ) {
1046
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
1047
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
1045
+function give_is_guest_payment($payment_id) {
1046
+	$payment_user_id  = give_get_payment_user_id($payment_id);
1047
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
1048 1048
 
1049
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
1049
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
1050 1050
 }
1051 1051
 
1052 1052
 /**
@@ -1058,8 +1058,8 @@  discard block
 block discarded – undo
1058 1058
  *
1059 1059
  * @return int $user_id User ID.
1060 1060
  */
1061
-function give_get_payment_user_id( $payment_id ) {
1062
-	$payment = new Give_Payment( $payment_id );
1061
+function give_get_payment_user_id($payment_id) {
1062
+	$payment = new Give_Payment($payment_id);
1063 1063
 
1064 1064
 	return $payment->user_id;
1065 1065
 }
@@ -1073,8 +1073,8 @@  discard block
 block discarded – undo
1073 1073
  *
1074 1074
  * @return int $payment->customer_id Donor ID.
1075 1075
  */
1076
-function give_get_payment_donor_id( $payment_id ) {
1077
-	$payment = new Give_Payment( $payment_id );
1076
+function give_get_payment_donor_id($payment_id) {
1077
+	$payment = new Give_Payment($payment_id);
1078 1078
 
1079 1079
 	return $payment->customer_id;
1080 1080
 }
@@ -1088,8 +1088,8 @@  discard block
 block discarded – undo
1088 1088
  *
1089 1089
  * @return string $ip User IP.
1090 1090
  */
1091
-function give_get_payment_user_ip( $payment_id ) {
1092
-	$payment = new Give_Payment( $payment_id );
1091
+function give_get_payment_user_ip($payment_id) {
1092
+	$payment = new Give_Payment($payment_id);
1093 1093
 
1094 1094
 	return $payment->ip;
1095 1095
 }
@@ -1103,8 +1103,8 @@  discard block
 block discarded – undo
1103 1103
  *
1104 1104
  * @return string $date The date the payment was completed.
1105 1105
  */
1106
-function give_get_payment_completed_date( $payment_id = 0 ) {
1107
-	$payment = new Give_Payment( $payment_id );
1106
+function give_get_payment_completed_date($payment_id = 0) {
1107
+	$payment = new Give_Payment($payment_id);
1108 1108
 
1109 1109
 	return $payment->completed_date;
1110 1110
 }
@@ -1118,8 +1118,8 @@  discard block
 block discarded – undo
1118 1118
  *
1119 1119
  * @return string $gateway Gateway.
1120 1120
  */
1121
-function give_get_payment_gateway( $payment_id ) {
1122
-	$payment = new Give_Payment( $payment_id );
1121
+function give_get_payment_gateway($payment_id) {
1122
+	$payment = new Give_Payment($payment_id);
1123 1123
 
1124 1124
 	return $payment->gateway;
1125 1125
 }
@@ -1133,8 +1133,8 @@  discard block
 block discarded – undo
1133 1133
  *
1134 1134
  * @return string $currency The currency code.
1135 1135
  */
1136
-function give_get_payment_currency_code( $payment_id = 0 ) {
1137
-	$payment = new Give_Payment( $payment_id );
1136
+function give_get_payment_currency_code($payment_id = 0) {
1137
+	$payment = new Give_Payment($payment_id);
1138 1138
 
1139 1139
 	return $payment->currency;
1140 1140
 }
@@ -1148,10 +1148,10 @@  discard block
 block discarded – undo
1148 1148
  *
1149 1149
  * @return string $currency The currency name.
1150 1150
  */
1151
-function give_get_payment_currency( $payment_id = 0 ) {
1152
-	$currency = give_get_payment_currency_code( $payment_id );
1151
+function give_get_payment_currency($payment_id = 0) {
1152
+	$currency = give_get_payment_currency_code($payment_id);
1153 1153
 
1154
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1154
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1155 1155
 }
1156 1156
 
1157 1157
 /**
@@ -1163,8 +1163,8 @@  discard block
 block discarded – undo
1163 1163
  *
1164 1164
  * @return string $key Donation key.
1165 1165
  */
1166
-function give_get_payment_key( $payment_id = 0 ) {
1167
-	$payment = new Give_Payment( $payment_id );
1166
+function give_get_payment_key($payment_id = 0) {
1167
+	$payment = new Give_Payment($payment_id);
1168 1168
 
1169 1169
 	return $payment->key;
1170 1170
 }
@@ -1180,8 +1180,8 @@  discard block
 block discarded – undo
1180 1180
  *
1181 1181
  * @return string $number Payment order number.
1182 1182
  */
1183
-function give_get_payment_number( $payment_id = 0 ) {
1184
-	$payment = new Give_Payment( $payment_id );
1183
+function give_get_payment_number($payment_id = 0) {
1184
+	$payment = new Give_Payment($payment_id);
1185 1185
 
1186 1186
 	return $payment->number;
1187 1187
 }
@@ -1195,23 +1195,23 @@  discard block
 block discarded – undo
1195 1195
  *
1196 1196
  * @return string      The formatted payment number.
1197 1197
  */
1198
-function give_format_payment_number( $number ) {
1198
+function give_format_payment_number($number) {
1199 1199
 
1200
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1200
+	if ( ! give_get_option('enable_sequential')) {
1201 1201
 		return $number;
1202 1202
 	}
1203 1203
 
1204
-	if ( ! is_numeric( $number ) ) {
1204
+	if ( ! is_numeric($number)) {
1205 1205
 		return $number;
1206 1206
 	}
1207 1207
 
1208
-	$prefix  = give_get_option( 'sequential_prefix' );
1209
-	$number  = absint( $number );
1210
-	$postfix = give_get_option( 'sequential_postfix' );
1208
+	$prefix  = give_get_option('sequential_prefix');
1209
+	$number  = absint($number);
1210
+	$postfix = give_get_option('sequential_postfix');
1211 1211
 
1212
-	$formatted_number = $prefix . $number . $postfix;
1212
+	$formatted_number = $prefix.$number.$postfix;
1213 1213
 
1214
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1214
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1215 1215
 }
1216 1216
 
1217 1217
 /**
@@ -1225,17 +1225,17 @@  discard block
 block discarded – undo
1225 1225
  */
1226 1226
 function give_get_next_payment_number() {
1227 1227
 
1228
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1228
+	if ( ! give_get_option('enable_sequential')) {
1229 1229
 		return false;
1230 1230
 	}
1231 1231
 
1232
-	$number           = get_option( 'give_last_payment_number' );
1233
-	$start            = give_get_option( 'sequential_start', 1 );
1232
+	$number           = get_option('give_last_payment_number');
1233
+	$start            = give_get_option('sequential_start', 1);
1234 1234
 	$increment_number = true;
1235 1235
 
1236
-	if ( false !== $number ) {
1236
+	if (false !== $number) {
1237 1237
 
1238
-		if ( empty( $number ) ) {
1238
+		if (empty($number)) {
1239 1239
 
1240 1240
 			$number           = $start;
1241 1241
 			$increment_number = false;
@@ -1244,24 +1244,24 @@  discard block
 block discarded – undo
1244 1244
 	} else {
1245 1245
 
1246 1246
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason.
1247
-		$payments     = new Give_Payments_Query( array(
1247
+		$payments = new Give_Payments_Query(array(
1248 1248
 			'number'  => 1,
1249 1249
 			'order'   => 'DESC',
1250 1250
 			'orderby' => 'ID',
1251 1251
 			'output'  => 'posts',
1252 1252
 			'fields'  => 'ids',
1253
-		) );
1253
+		));
1254 1254
 		$last_payment = $payments->get_payments();
1255 1255
 
1256
-		if ( ! empty( $last_payment ) ) {
1256
+		if ( ! empty($last_payment)) {
1257 1257
 
1258
-			$number = give_get_payment_number( $last_payment[0] );
1258
+			$number = give_get_payment_number($last_payment[0]);
1259 1259
 
1260 1260
 		}
1261 1261
 
1262
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1262
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1263 1263
 
1264
-			$number = give_remove_payment_prefix_postfix( $number );
1264
+			$number = give_remove_payment_prefix_postfix($number);
1265 1265
 
1266 1266
 		} else {
1267 1267
 
@@ -1270,13 +1270,13 @@  discard block
 block discarded – undo
1270 1270
 		}
1271 1271
 	}// End if().
1272 1272
 
1273
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1273
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1274 1274
 
1275
-	if ( $increment_number ) {
1276
-		$number ++;
1275
+	if ($increment_number) {
1276
+		$number++;
1277 1277
 	}
1278 1278
 
1279
-	return apply_filters( 'give_get_next_payment_number', $number );
1279
+	return apply_filters('give_get_next_payment_number', $number);
1280 1280
 }
1281 1281
 
1282 1282
 /**
@@ -1288,25 +1288,25 @@  discard block
 block discarded – undo
1288 1288
  *
1289 1289
  * @return string The new Payment number without prefix and postfix.
1290 1290
  */
1291
-function give_remove_payment_prefix_postfix( $number ) {
1291
+function give_remove_payment_prefix_postfix($number) {
1292 1292
 
1293
-	$prefix  = give_get_option( 'sequential_prefix' );
1294
-	$postfix = give_get_option( 'sequential_postfix' );
1293
+	$prefix  = give_get_option('sequential_prefix');
1294
+	$postfix = give_get_option('sequential_postfix');
1295 1295
 
1296 1296
 	// Remove prefix.
1297
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1297
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1298 1298
 
1299 1299
 	// Remove the postfix.
1300
-	$length      = strlen( $number );
1301
-	$postfix_pos = strrpos( $number, $postfix );
1302
-	if ( false !== $postfix_pos ) {
1303
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1300
+	$length      = strlen($number);
1301
+	$postfix_pos = strrpos($number, $postfix);
1302
+	if (false !== $postfix_pos) {
1303
+		$number = substr_replace($number, '', $postfix_pos, $length);
1304 1304
 	}
1305 1305
 
1306 1306
 	// Ensure it's a whole number.
1307
-	$number = intval( $number );
1307
+	$number = intval($number);
1308 1308
 
1309
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1309
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1310 1310
 
1311 1311
 }
1312 1312
 
@@ -1322,10 +1322,10 @@  discard block
 block discarded – undo
1322 1322
  *
1323 1323
  * @return string $amount Fully formatted payment amount.
1324 1324
  */
1325
-function give_payment_amount( $payment_id = 0 ) {
1326
-	$amount = give_get_payment_amount( $payment_id );
1325
+function give_payment_amount($payment_id = 0) {
1326
+	$amount = give_get_payment_amount($payment_id);
1327 1327
 
1328
-	return give_currency_filter( give_format_amount( $amount, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) );
1328
+	return give_currency_filter(give_format_amount($amount, array('sanitize' => false)), give_get_payment_currency_code($payment_id));
1329 1329
 }
1330 1330
 
1331 1331
 /**
@@ -1338,11 +1338,11 @@  discard block
 block discarded – undo
1338 1338
  *
1339 1339
  * @return mixed
1340 1340
  */
1341
-function give_get_payment_amount( $payment_id ) {
1341
+function give_get_payment_amount($payment_id) {
1342 1342
 
1343
-	$payment = new Give_Payment( $payment_id );
1343
+	$payment = new Give_Payment($payment_id);
1344 1344
 
1345
-	return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id );
1345
+	return apply_filters('give_payment_amount', floatval($payment->total), $payment_id);
1346 1346
 }
1347 1347
 
1348 1348
 /**
@@ -1359,10 +1359,10 @@  discard block
 block discarded – undo
1359 1359
  *
1360 1360
  * @return array Fully formatted payment subtotal.
1361 1361
  */
1362
-function give_payment_subtotal( $payment_id = 0 ) {
1363
-	$subtotal = give_get_payment_subtotal( $payment_id );
1362
+function give_payment_subtotal($payment_id = 0) {
1363
+	$subtotal = give_get_payment_subtotal($payment_id);
1364 1364
 
1365
-	return give_currency_filter( give_format_amount( $subtotal, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) );
1365
+	return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), give_get_payment_currency_code($payment_id));
1366 1366
 }
1367 1367
 
1368 1368
 /**
@@ -1376,8 +1376,8 @@  discard block
 block discarded – undo
1376 1376
  *
1377 1377
  * @return float $subtotal Subtotal for payment (non formatted).
1378 1378
  */
1379
-function give_get_payment_subtotal( $payment_id = 0 ) {
1380
-	$payment = new Give_Payment( $payment_id );
1379
+function give_get_payment_subtotal($payment_id = 0) {
1380
+	$payment = new Give_Payment($payment_id);
1381 1381
 
1382 1382
 	return $payment->subtotal;
1383 1383
 }
@@ -1391,8 +1391,8 @@  discard block
 block discarded – undo
1391 1391
  *
1392 1392
  * @return string The donation ID.
1393 1393
  */
1394
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1395
-	$payment = new Give_Payment( $payment_id );
1394
+function give_get_payment_transaction_id($payment_id = 0) {
1395
+	$payment = new Give_Payment($payment_id);
1396 1396
 
1397 1397
 	return $payment->transaction_id;
1398 1398
 }
@@ -1407,15 +1407,15 @@  discard block
 block discarded – undo
1407 1407
  *
1408 1408
  * @return bool|mixed
1409 1409
  */
1410
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1410
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1411 1411
 
1412
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1412
+	if (empty($payment_id) || empty($transaction_id)) {
1413 1413
 		return false;
1414 1414
 	}
1415 1415
 
1416
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1416
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1417 1417
 
1418
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1418
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1419 1419
 }
1420 1420
 
1421 1421
 /**
@@ -1428,12 +1428,12 @@  discard block
 block discarded – undo
1428 1428
  *
1429 1429
  * @return int $purchase Donation ID.
1430 1430
  */
1431
-function give_get_purchase_id_by_key( $key ) {
1431
+function give_get_purchase_id_by_key($key) {
1432 1432
 	global $wpdb;
1433 1433
 
1434
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) );
1434
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key));
1435 1435
 
1436
-	if ( $purchase != null ) {
1436
+	if ($purchase != null) {
1437 1437
 		return $purchase;
1438 1438
 	}
1439 1439
 
@@ -1451,12 +1451,12 @@  discard block
 block discarded – undo
1451 1451
  *
1452 1452
  * @return int $purchase Donation ID.
1453 1453
  */
1454
-function give_get_purchase_id_by_transaction_id( $key ) {
1454
+function give_get_purchase_id_by_transaction_id($key) {
1455 1455
 	global $wpdb;
1456 1456
 
1457
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1457
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key));
1458 1458
 
1459
-	if ( $purchase != null ) {
1459
+	if ($purchase != null) {
1460 1460
 		return $purchase;
1461 1461
 	}
1462 1462
 
@@ -1473,23 +1473,23 @@  discard block
 block discarded – undo
1473 1473
  *
1474 1474
  * @return array $notes Donation Notes
1475 1475
  */
1476
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1476
+function give_get_payment_notes($payment_id = 0, $search = '') {
1477 1477
 
1478
-	if ( empty( $payment_id ) && empty( $search ) ) {
1478
+	if (empty($payment_id) && empty($search)) {
1479 1479
 		return false;
1480 1480
 	}
1481 1481
 
1482
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1483
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1482
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1483
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1484 1484
 
1485
-	$notes = get_comments( array(
1485
+	$notes = get_comments(array(
1486 1486
 		'post_id' => $payment_id,
1487 1487
 		'order'   => 'ASC',
1488 1488
 		'search'  => $search,
1489
-	) );
1489
+	));
1490 1490
 
1491
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1492
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1491
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1492
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1493 1493
 
1494 1494
 	return $notes;
1495 1495
 }
@@ -1505,8 +1505,8 @@  discard block
 block discarded – undo
1505 1505
  *
1506 1506
  * @return int The new note ID
1507 1507
  */
1508
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1509
-	if ( empty( $payment_id ) ) {
1508
+function give_insert_payment_note($payment_id = 0, $note = '') {
1509
+	if (empty($payment_id)) {
1510 1510
 		return false;
1511 1511
 	}
1512 1512
 
@@ -1518,14 +1518,14 @@  discard block
 block discarded – undo
1518 1518
 	 *
1519 1519
 	 * @since 1.0
1520 1520
 	 */
1521
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1521
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1522 1522
 
1523
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1523
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1524 1524
 		'comment_post_ID'      => $payment_id,
1525 1525
 		'comment_content'      => $note,
1526 1526
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1527
-		'comment_date'         => current_time( 'mysql' ),
1528
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1527
+		'comment_date'         => current_time('mysql'),
1528
+		'comment_date_gmt'     => current_time('mysql', 1),
1529 1529
 		'comment_approved'     => 1,
1530 1530
 		'comment_parent'       => 0,
1531 1531
 		'comment_author'       => '',
@@ -1534,7 +1534,7 @@  discard block
 block discarded – undo
1534 1534
 		'comment_author_email' => '',
1535 1535
 		'comment_type'         => 'give_payment_note',
1536 1536
 
1537
-	) ) );
1537
+	)));
1538 1538
 
1539 1539
 	/**
1540 1540
 	 * Fires after payment note inserted.
@@ -1545,7 +1545,7 @@  discard block
 block discarded – undo
1545 1545
 	 *
1546 1546
 	 * @since 1.0
1547 1547
 	 */
1548
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1548
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1549 1549
 
1550 1550
 	return $note_id;
1551 1551
 }
@@ -1560,8 +1560,8 @@  discard block
 block discarded – undo
1560 1560
  *
1561 1561
  * @return bool True on success, false otherwise.
1562 1562
  */
1563
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1564
-	if ( empty( $comment_id ) ) {
1563
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1564
+	if (empty($comment_id)) {
1565 1565
 		return false;
1566 1566
 	}
1567 1567
 
@@ -1573,9 +1573,9 @@  discard block
 block discarded – undo
1573 1573
 	 *
1574 1574
 	 * @since 1.0
1575 1575
 	 */
1576
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1576
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1577 1577
 
1578
-	$ret = wp_delete_comment( $comment_id, true );
1578
+	$ret = wp_delete_comment($comment_id, true);
1579 1579
 
1580 1580
 	/**
1581 1581
 	 * Fires after donation note deleted.
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
 	 *
1586 1586
 	 * @since 1.0
1587 1587
 	 */
1588
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1588
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1589 1589
 
1590 1590
 	return $ret;
1591 1591
 }
@@ -1600,32 +1600,32 @@  discard block
 block discarded – undo
1600 1600
  *
1601 1601
  * @return string
1602 1602
  */
1603
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1603
+function give_get_payment_note_html($note, $payment_id = 0) {
1604 1604
 
1605
-	if ( is_numeric( $note ) ) {
1606
-		$note = get_comment( $note );
1605
+	if (is_numeric($note)) {
1606
+		$note = get_comment($note);
1607 1607
 	}
1608 1608
 
1609
-	if ( ! empty( $note->user_id ) ) {
1610
-		$user = get_userdata( $note->user_id );
1609
+	if ( ! empty($note->user_id)) {
1610
+		$user = get_userdata($note->user_id);
1611 1611
 		$user = $user->display_name;
1612 1612
 	} else {
1613
-		$user = __( 'System', 'give' );
1613
+		$user = __('System', 'give');
1614 1614
 	}
1615 1615
 
1616
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1616
+	$date_format = give_date_format().', '.get_option('time_format');
1617 1617
 
1618
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1618
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1619 1619
 		'give-action' => 'delete_payment_note',
1620 1620
 		'note_id'     => $note->comment_ID,
1621 1621
 		'payment_id'  => $payment_id,
1622
-	) ), 'give_delete_payment_note_' . $note->comment_ID );
1622
+	)), 'give_delete_payment_note_'.$note->comment_ID);
1623 1623
 
1624
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1624
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1625 1625
 	$note_html .= '<p>';
1626
-	$note_html .= '<strong>' . $user . '</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>';
1626
+	$note_html .= '<strong>'.$user.'</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>';
1627 1627
 	$note_html .= $note->comment_content;
1628
-	$note_html .= '&nbsp;&ndash;&nbsp;<a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . __( 'Delete this donation note.', 'give' ) . '">' . __( 'Delete', 'give' ) . '</a>';
1628
+	$note_html .= '&nbsp;&ndash;&nbsp;<a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.__('Delete this donation note.', 'give').'">'.__('Delete', 'give').'</a>';
1629 1629
 	$note_html .= '</p>';
1630 1630
 	$note_html .= '</div>';
1631 1631
 
@@ -1643,18 +1643,18 @@  discard block
 block discarded – undo
1643 1643
  *
1644 1644
  * @return void
1645 1645
  */
1646
-function give_hide_payment_notes( $query ) {
1647
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1648
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1649
-		if ( ! is_array( $types ) ) {
1650
-			$types = array( $types );
1646
+function give_hide_payment_notes($query) {
1647
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1648
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1649
+		if ( ! is_array($types)) {
1650
+			$types = array($types);
1651 1651
 		}
1652 1652
 		$types[]                           = 'give_payment_note';
1653 1653
 		$query->query_vars['type__not_in'] = $types;
1654 1654
 	}
1655 1655
 }
1656 1656
 
1657
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1657
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1658 1658
 
1659 1659
 /**
1660 1660
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1666,15 +1666,15 @@  discard block
 block discarded – undo
1666 1666
  *
1667 1667
  * @return array $clauses Updated comment clauses.
1668 1668
  */
1669
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1670
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1669
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1670
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1671 1671
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1672 1672
 	}
1673 1673
 
1674 1674
 	return $clauses;
1675 1675
 }
1676 1676
 
1677
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1677
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1678 1678
 
1679 1679
 
1680 1680
 /**
@@ -1687,15 +1687,15 @@  discard block
 block discarded – undo
1687 1687
  *
1688 1688
  * @return string $where
1689 1689
  */
1690
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1690
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1691 1691
 	global $wpdb;
1692 1692
 
1693
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1693
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1694 1694
 
1695 1695
 	return $where;
1696 1696
 }
1697 1697
 
1698
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1698
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1699 1699
 
1700 1700
 
1701 1701
 /**
@@ -1709,32 +1709,32 @@  discard block
 block discarded – undo
1709 1709
  *
1710 1710
  * @return array|object Array of comment counts.
1711 1711
  */
1712
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1712
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1713 1713
 	global $wpdb, $pagenow;
1714 1714
 
1715
-	if ( 'index.php' != $pagenow ) {
1715
+	if ('index.php' != $pagenow) {
1716 1716
 		return $stats;
1717 1717
 	}
1718 1718
 
1719 1719
 	$post_id = (int) $post_id;
1720 1720
 
1721
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1721
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1722 1722
 		return $stats;
1723 1723
 	}
1724 1724
 
1725
-	$stats = wp_cache_get( "comments-{$post_id}", 'counts' );
1725
+	$stats = wp_cache_get("comments-{$post_id}", 'counts');
1726 1726
 
1727
-	if ( false !== $stats ) {
1727
+	if (false !== $stats) {
1728 1728
 		return $stats;
1729 1729
 	}
1730 1730
 
1731 1731
 	$where = 'WHERE comment_type != "give_payment_note"';
1732 1732
 
1733
-	if ( $post_id > 0 ) {
1734
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1733
+	if ($post_id > 0) {
1734
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1735 1735
 	}
1736 1736
 
1737
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1737
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1738 1738
 
1739 1739
 	$total    = 0;
1740 1740
 	$approved = array(
@@ -1744,30 +1744,30 @@  discard block
 block discarded – undo
1744 1744
 		'trash'        => 'trash',
1745 1745
 		'post-trashed' => 'post-trashed',
1746 1746
 	);
1747
-	foreach ( (array) $count as $row ) {
1747
+	foreach ((array) $count as $row) {
1748 1748
 		// Don't count post-trashed toward totals.
1749
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1749
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1750 1750
 			$total += $row['num_comments'];
1751 1751
 		}
1752
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1753
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1752
+		if (isset($approved[$row['comment_approved']])) {
1753
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1754 1754
 		}
1755 1755
 	}
1756 1756
 
1757 1757
 	$stats['total_comments'] = $total;
1758
-	foreach ( $approved as $key ) {
1759
-		if ( empty( $stats[ $key ] ) ) {
1760
-			$stats[ $key ] = 0;
1758
+	foreach ($approved as $key) {
1759
+		if (empty($stats[$key])) {
1760
+			$stats[$key] = 0;
1761 1761
 		}
1762 1762
 	}
1763 1763
 
1764 1764
 	$stats = (object) $stats;
1765
-	wp_cache_set( "comments-{$post_id}", $stats, 'counts' );
1765
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
1766 1766
 
1767 1767
 	return $stats;
1768 1768
 }
1769 1769
 
1770
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1770
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1771 1771
 
1772 1772
 
1773 1773
 /**
@@ -1780,9 +1780,9 @@  discard block
 block discarded – undo
1780 1780
  *
1781 1781
  * @return string $where Modified where clause.
1782 1782
  */
1783
-function give_filter_where_older_than_week( $where = '' ) {
1783
+function give_filter_where_older_than_week($where = '') {
1784 1784
 	// Payments older than one week.
1785
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1785
+	$start = date('Y-m-d', strtotime('-7 days'));
1786 1786
 	$where .= " AND post_date <= '{$start}'";
1787 1787
 
1788 1788
 	return $where;
@@ -1802,38 +1802,38 @@  discard block
 block discarded – undo
1802 1802
  *
1803 1803
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1804 1804
  */
1805
-function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) {
1805
+function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') {
1806 1806
 
1807
-	$form_id    = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
1808
-	$price_id   = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1809
-	$form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '';
1807
+	$form_id    = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
1808
+	$price_id   = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1809
+	$form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
1810 1810
 
1811
-	if ( $only_level == true ) {
1811
+	if ($only_level == true) {
1812 1812
 		$form_title = '';
1813 1813
 	}
1814 1814
 
1815 1815
 	// If multi-level, append to the form title.
1816
-	if ( give_has_variable_prices( $form_id ) ) {
1816
+	if (give_has_variable_prices($form_id)) {
1817 1817
 
1818 1818
 		// Only add separator if there is a form title.
1819
-		if ( ! empty( $form_title ) ) {
1820
-			$form_title .= ' ' . $separator . ' ';
1819
+		if ( ! empty($form_title)) {
1820
+			$form_title .= ' '.$separator.' ';
1821 1821
 		}
1822 1822
 
1823 1823
 		$form_title .= '<span class="donation-level-text-wrap">';
1824 1824
 
1825
-		if ( $price_id == 'custom' ) {
1826
-			$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
1827
-			$form_title         .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1825
+		if ($price_id == 'custom') {
1826
+			$custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true);
1827
+			$form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1828 1828
 		} else {
1829
-			$form_title .= give_get_price_option_name( $form_id, $price_id );
1829
+			$form_title .= give_get_price_option_name($form_id, $price_id);
1830 1830
 		}
1831 1831
 
1832 1832
 		$form_title .= '</span>';
1833 1833
 
1834 1834
 	}
1835 1835
 
1836
-	return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta );
1836
+	return apply_filters('give_get_payment_form_title', $form_title, $payment_meta);
1837 1837
 
1838 1838
 }
1839 1839
 
@@ -1847,19 +1847,19 @@  discard block
 block discarded – undo
1847 1847
  *
1848 1848
  * @return string $price_id
1849 1849
  */
1850
-function give_get_price_id( $form_id, $price ) {
1850
+function give_get_price_id($form_id, $price) {
1851 1851
 	$price_id = null;
1852 1852
 
1853
-	if ( give_has_variable_prices( $form_id ) ) {
1853
+	if (give_has_variable_prices($form_id)) {
1854 1854
 
1855
-		$levels = give_get_meta( $form_id, '_give_donation_levels', true );
1855
+		$levels = give_get_meta($form_id, '_give_donation_levels', true);
1856 1856
 
1857
-		foreach ( $levels as $level ) {
1857
+		foreach ($levels as $level) {
1858 1858
 
1859
-			$level_amount = give_maybe_sanitize_amount( $level['_give_amount'] );
1859
+			$level_amount = give_maybe_sanitize_amount($level['_give_amount']);
1860 1860
 
1861 1861
 			// Check that this indeed the recurring price.
1862
-			if ( $level_amount == $price ) {
1862
+			if ($level_amount == $price) {
1863 1863
 
1864 1864
 				$price_id = $level['_give_id']['level_id'];
1865 1865
 				break;
@@ -1867,13 +1867,13 @@  discard block
 block discarded – undo
1867 1867
 			}
1868 1868
 		}
1869 1869
 
1870
-		if( is_null( $price_id ) && give_is_custom_price_mode( $form_id ) ) {
1870
+		if (is_null($price_id) && give_is_custom_price_mode($form_id)) {
1871 1871
 			$price_id = 'custom';
1872 1872
 		}
1873 1873
 	}
1874 1874
 
1875 1875
 	// Price ID must be numeric or string.
1876
-	$price_id = ! is_numeric( $price_id ) && ! is_string( $price_id ) ? 0 : $price_id;
1876
+	$price_id = ! is_numeric($price_id) && ! is_string($price_id) ? 0 : $price_id;
1877 1877
 
1878 1878
 	return $price_id;
1879 1879
 }
@@ -1891,10 +1891,10 @@  discard block
 block discarded – undo
1891 1891
  *
1892 1892
  * @return string
1893 1893
  */
1894
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1895
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1894
+function give_get_form_dropdown($args = array(), $echo = false) {
1895
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1896 1896
 
1897
-	if ( ! $echo ) {
1897
+	if ( ! $echo) {
1898 1898
 		return $form_dropdown_html;
1899 1899
 	}
1900 1900
 
@@ -1911,17 +1911,17 @@  discard block
 block discarded – undo
1911 1911
  *
1912 1912
  * @return string|bool
1913 1913
  */
1914
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1914
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1915 1915
 
1916 1916
 	// Check for give form id.
1917
-	if ( empty( $args['id'] ) ) {
1917
+	if (empty($args['id'])) {
1918 1918
 		return false;
1919 1919
 	}
1920 1920
 
1921
-	$form = new Give_Donate_Form( $args['id'] );
1921
+	$form = new Give_Donate_Form($args['id']);
1922 1922
 
1923 1923
 	// Check if form has variable prices or not.
1924
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1924
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1925 1925
 		return false;
1926 1926
 	}
1927 1927
 
@@ -1929,24 +1929,24 @@  discard block
 block discarded – undo
1929 1929
 	$variable_price_options = array();
1930 1930
 
1931 1931
 	// Check if multi donation form support custom donation or not.
1932
-	if ( $form->is_custom_price_mode() ) {
1933
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1932
+	if ($form->is_custom_price_mode()) {
1933
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1934 1934
 	}
1935 1935
 
1936 1936
 	// Get variable price and ID from variable price array.
1937
-	foreach ( $variable_prices as $variable_price ) {
1938
-		$variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ) );
1937
+	foreach ($variable_prices as $variable_price) {
1938
+		$variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'], array('sanitize' => false)));
1939 1939
 	}
1940 1940
 
1941 1941
 	// Update options.
1942
-	$args = array_merge( $args, array(
1942
+	$args = array_merge($args, array(
1943 1943
 		'options' => $variable_price_options,
1944
-	) );
1944
+	));
1945 1945
 
1946 1946
 	// Generate select html.
1947
-	$form_dropdown_html = Give()->html->select( $args );
1947
+	$form_dropdown_html = Give()->html->select($args);
1948 1948
 
1949
-	if ( ! $echo ) {
1949
+	if ( ! $echo) {
1950 1950
 		return $form_dropdown_html;
1951 1951
 	}
1952 1952
 
@@ -1965,16 +1965,16 @@  discard block
 block discarded – undo
1965 1965
  *
1966 1966
  * @return string
1967 1967
  */
1968
-function give_get_payment_meta_price_id( $payment_meta ) {
1968
+function give_get_payment_meta_price_id($payment_meta) {
1969 1969
 
1970
-	if ( isset( $payment_meta['give_price_id'] ) ) {
1970
+	if (isset($payment_meta['give_price_id'])) {
1971 1971
 		$price_id = $payment_meta['give_price_id'];
1972
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
1972
+	} elseif (isset($payment_meta['price_id'])) {
1973 1973
 		$price_id = $payment_meta['price_id'];
1974 1974
 	} else {
1975
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1975
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1976 1976
 	}
1977 1977
 
1978
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id );
1978
+	return apply_filters('give_get_payment_meta_price_id', $price_id);
1979 1979
 
1980 1980
 }
Please login to merge, or discard this patch.
templates/email-login-form.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -7,24 +7,24 @@  discard block
 block discarded – undo
7 7
 
8 8
 global $give_access_form_outputted;
9 9
 $show_form = true;
10
-$email     = isset( $_POST['give_email'] ) ? $_POST['give_email'] : '';
10
+$email     = isset($_POST['give_email']) ? $_POST['give_email'] : '';
11 11
 
12 12
 // Declare Variables.
13
-$recaptcha_key    = give_get_option( 'recaptcha_key' );
14
-$recaptcha_secret = give_get_option( 'recaptcha_secret' );
15
-$enable_recaptcha = ( ! empty( $recaptcha_key ) && ! empty( $recaptcha_secret ) ) ? true : false;
16
-$access_token     = ! empty( $_GET['payment_key'] ) ? $_GET['payment_key'] : '';
13
+$recaptcha_key    = give_get_option('recaptcha_key');
14
+$recaptcha_secret = give_get_option('recaptcha_secret');
15
+$enable_recaptcha = ( ! empty($recaptcha_key) && ! empty($recaptcha_secret)) ? true : false;
16
+$access_token     = ! empty($_GET['payment_key']) ? $_GET['payment_key'] : '';
17 17
 
18 18
 // Only output the form once.
19
-if ( $give_access_form_outputted ) {
19
+if ($give_access_form_outputted) {
20 20
 	return;
21 21
 }
22 22
 
23 23
 // Form submission.
24
-if ( is_email( $email ) && wp_verify_nonce( $_POST['_wpnonce'], 'give' ) ) {
24
+if (is_email($email) && wp_verify_nonce($_POST['_wpnonce'], 'give')) {
25 25
 
26 26
 	// Use reCAPTCHA
27
-	if ( $enable_recaptcha ) {
27
+	if ($enable_recaptcha) {
28 28
 
29 29
 		$args = array(
30 30
 			'secret'   => $recaptcha_secret,
@@ -32,87 +32,87 @@  discard block
 block discarded – undo
32 32
 			'remoteip' => $_POST['give_ip'],
33 33
 		);
34 34
 
35
-		if ( ! empty( $args['response'] ) ) {
36
-			$request = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array(
35
+		if ( ! empty($args['response'])) {
36
+			$request = wp_remote_post('https://www.google.com/recaptcha/api/siteverify', array(
37 37
 				'body' => $args,
38
-			) );
39
-			if ( ! is_wp_error( $request ) || 200 == wp_remote_retrieve_response_code( $request ) ) {
38
+			));
39
+			if ( ! is_wp_error($request) || 200 == wp_remote_retrieve_response_code($request)) {
40 40
 
41
-				$response = json_decode( $request['body'], true );
41
+				$response = json_decode($request['body'], true);
42 42
 
43 43
 				// reCAPTCHA fail.
44
-				if ( ! $response['success'] ) {
45
-					give_set_error( 'give_recaptcha_test_failed', apply_filters( 'give_recaptcha_test_failed_message', __( 'reCAPTCHA test failed.', 'give' ) ) );
44
+				if ( ! $response['success']) {
45
+					give_set_error('give_recaptcha_test_failed', apply_filters('give_recaptcha_test_failed_message', __('reCAPTCHA test failed.', 'give')));
46 46
 				}
47 47
 			} else {
48 48
 
49 49
 				// Connection issue.
50
-				give_set_error( 'give_recaptcha_connection_issue', apply_filters( 'give_recaptcha_connection_issue_message', __( 'Unable to connect to reCAPTCHA server.', 'give' ) ) );
50
+				give_set_error('give_recaptcha_connection_issue', apply_filters('give_recaptcha_connection_issue_message', __('Unable to connect to reCAPTCHA server.', 'give')));
51 51
 
52 52
 			}
53 53
 		} // End if().
54 54
 		else {
55 55
 
56
-			give_set_error( 'give_recaptcha_failed', apply_filters( 'give_recaptcha_failed_message', __( 'It looks like the reCAPTCHA test has failed.', 'give' ) ) );
56
+			give_set_error('give_recaptcha_failed', apply_filters('give_recaptcha_failed_message', __('It looks like the reCAPTCHA test has failed.', 'give')));
57 57
 
58 58
 		}
59 59
 	}
60 60
 
61 61
 	// If no errors or only expired token key error - then send email.
62
-	if ( ! give_get_errors() ) {
62
+	if ( ! give_get_errors()) {
63 63
 
64 64
 		$payment_ids   = array();
65 65
 		$payment_match = false;
66 66
 
67
-		$donor = Give()->donors->get_donor_by( 'email', $email );
67
+		$donor = Give()->donors->get_donor_by('email', $email);
68 68
 
69
-		if( ! empty( $donor->payment_ids ) ) {
70
-			$payment_ids = explode( ',', $donor->payment_ids );
69
+		if ( ! empty($donor->payment_ids)) {
70
+			$payment_ids = explode(',', $donor->payment_ids);
71 71
 		}
72 72
 
73
-		foreach( $payment_ids AS $payment_id ) {
74
-			$payment = new Give_Payment( $payment_id );
73
+		foreach ($payment_ids AS $payment_id) {
74
+			$payment = new Give_Payment($payment_id);
75 75
 
76 76
 			// Make sure Donation Access Token matches with donation details of donor whose email is provided.
77
-			if ( $access_token === $payment->key ) {
77
+			if ($access_token === $payment->key) {
78 78
 				$payment_match = true;
79 79
 			}
80 80
 
81 81
 		}
82 82
 
83
-		if ( ! $payment_match ) {
84
-			give_set_error( 'give_email_access_token_not_match',  __( 'It looks like that email address provided and access token of the link does not match.', 'give' ) );
83
+		if ( ! $payment_match) {
84
+			give_set_error('give_email_access_token_not_match', __('It looks like that email address provided and access token of the link does not match.', 'give'));
85 85
 
86 86
 		} else {
87 87
 			// Set Verification for Access.
88
-			Give()->email_access->set_verify_key( $donor->id, $donor->email, $access_token );
88
+			Give()->email_access->set_verify_key($donor->id, $donor->email, $access_token);
89 89
 
90
-			wp_safe_redirect( esc_url( get_permalink( give_get_option( 'history_page' ) ) . '?give_nl=' . $access_token ) );
90
+			wp_safe_redirect(esc_url(get_permalink(give_get_option('history_page')).'?give_nl='.$access_token));
91 91
 		}
92 92
 
93 93
 	}
94 94
 } // End if().
95 95
 
96 96
 // Print any messages & errors.
97
-Give()->notices->render_frontend_notices( 0 );
97
+Give()->notices->render_frontend_notices(0);
98 98
 
99 99
 // Show the email login form?
100
-if ( $show_form ) { ?>
100
+if ($show_form) { ?>
101 101
 	<div class="give-form">
102 102
 
103 103
 		<?php
104
-		if ( ! give_get_errors() ) {
105
-			Give()->notices->print_frontend_notice( apply_filters( 'give_email_access_message', __( 'Please enter the email address you used for your donation.', 'give' ) ), true );
104
+		if ( ! give_get_errors()) {
105
+			Give()->notices->print_frontend_notice(apply_filters('give_email_access_message', __('Please enter the email address you used for your donation.', 'give')), true);
106 106
 		} ?>
107 107
 
108 108
 		<form method="post" action="" id="give-email-access-form">
109
-			<label for="give-email"><?php _e( 'Donation Email:', 'give' ); ?></label>
110
-			<input id="give-email" type="email" name="give_email" value="" placeholder="<?php _e( 'Email Address', 'give' ); ?>" />
111
-			<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'give' ); ?>" />
109
+			<label for="give-email"><?php _e('Donation Email:', 'give'); ?></label>
110
+			<input id="give-email" type="email" name="give_email" value="" placeholder="<?php _e('Email Address', 'give'); ?>" />
111
+			<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('give'); ?>" />
112 112
 
113 113
 			<?php
114 114
 			// Enable reCAPTCHA?
115
-			if ( $enable_recaptcha ) { ?>
115
+			if ($enable_recaptcha) { ?>
116 116
 
117 117
 				<script>
118 118
 					// IP verify for reCAPTCHA.
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 				<input type="hidden" name="give_ip" class="give_ip" value="" />
131 131
 			<?php } ?>
132 132
 
133
-			<input type="submit" class="give-submit" value="<?php _e( 'Verify Email', 'give' ); ?>" />
133
+			<input type="submit" class="give-submit" value="<?php _e('Verify Email', 'give'); ?>" />
134 134
 		</form>
135 135
 	</div>
136 136
 
Please login to merge, or discard this patch.
includes/class-notices.php 1 patch
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -53,21 +53,21 @@  discard block
 block discarded – undo
53 53
 	 * @since 1.8.9
54 54
 	 */
55 55
 	public function __construct() {
56
-		add_action( 'admin_notices', array( $this, 'render_admin_notices' ), 999 );
57
-		add_action( 'give_dismiss_notices', array( $this, 'dismiss_notices' ) );
56
+		add_action('admin_notices', array($this, 'render_admin_notices'), 999);
57
+		add_action('give_dismiss_notices', array($this, 'dismiss_notices'));
58 58
 
59
-		add_action( 'give_frontend_notices', array( $this, 'render_frontend_notices' ), 999 );
60
-		add_action( 'give_donation_form_before_personal_info', array( $this, 'render_frontend_notices' ) );
61
-		add_action( 'give_ajax_donation_errors', array( $this, 'render_frontend_notices' ) );
59
+		add_action('give_frontend_notices', array($this, 'render_frontend_notices'), 999);
60
+		add_action('give_donation_form_before_personal_info', array($this, 'render_frontend_notices'));
61
+		add_action('give_ajax_donation_errors', array($this, 'render_frontend_notices'));
62 62
 
63 63
 		/**
64 64
 		 * Backward compatibility for deprecated params.
65 65
 		 *
66 66
 		 * @since 1.8.14
67 67
 		 */
68
-		add_filter( 'give_register_notice_args', array( $this, 'bc_deprecated_params' ) );
69
-		add_filter( 'give_frontend_errors_args', array( $this, 'bc_deprecated_params' ) );
70
-		add_filter( 'give_frontend_notice_args', array( $this, 'bc_deprecated_params' ) );
68
+		add_filter('give_register_notice_args', array($this, 'bc_deprecated_params'));
69
+		add_filter('give_frontend_errors_args', array($this, 'bc_deprecated_params'));
70
+		add_filter('give_frontend_notice_args', array($this, 'bc_deprecated_params'));
71 71
 	}
72 72
 
73 73
 	/**
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return array
82 82
 	 */
83
-	public function bc_deprecated_params( $args ) {
83
+	public function bc_deprecated_params($args) {
84 84
 		/**
85 85
 		 *  Param: auto_dismissible
86 86
 		 *  deprecated in 1.8.14
87 87
 		 *
88 88
 		 *  Check if auto_dismissible is set and it true then unset and change dismissible parameter value to auto
89 89
 		 */
90
-		if ( isset( $args['auto_dismissible'] ) ) {
91
-			if ( ! empty( $args['auto_dismissible'] ) ) {
90
+		if (isset($args['auto_dismissible'])) {
91
+			if ( ! empty($args['auto_dismissible'])) {
92 92
 				$args['dismissible'] = 'auto';
93 93
 			}
94 94
 			// unset auto_dismissible as it has been deprecated.
95
-			unset( $args['auto_dismissible'] );
95
+			unset($args['auto_dismissible']);
96 96
 		}
97 97
 
98 98
 		return $args;
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return bool
110 110
 	 */
111
-	public function register_notice( $notice_args ) {
111
+	public function register_notice($notice_args) {
112 112
 		// Bailout.
113
-		if ( empty( $notice_args['id'] ) || array_key_exists( $notice_args['id'], self::$notices ) ) {
113
+		if (empty($notice_args['id']) || array_key_exists($notice_args['id'], self::$notices)) {
114 114
 			return false;
115 115
 		}
116 116
 
@@ -159,39 +159,39 @@  discard block
 block discarded – undo
159 159
 		 *
160 160
 		 * @since 1.8.14
161 161
 		 */
162
-		$notice_args = apply_filters( 'give_register_notice_args', $notice_args );
162
+		$notice_args = apply_filters('give_register_notice_args', $notice_args);
163 163
 
164 164
 		// Set extra dismiss links if any.
165
-		if ( false !== strpos( $notice_args['description'], 'data-dismiss-interval' ) ) {
165
+		if (false !== strpos($notice_args['description'], 'data-dismiss-interval')) {
166 166
 
167
-			preg_match_all( "/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link );
167
+			preg_match_all("/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link);
168 168
 
169
-			if ( ! empty( $extra_notice_dismiss_link ) ) {
170
-				$extra_notice_dismiss_links = array_chunk( current( $extra_notice_dismiss_link ), 3 );
171
-				foreach ( $extra_notice_dismiss_links as $extra_notice_dismiss_link ) {
169
+			if ( ! empty($extra_notice_dismiss_link)) {
170
+				$extra_notice_dismiss_links = array_chunk(current($extra_notice_dismiss_link), 3);
171
+				foreach ($extra_notice_dismiss_links as $extra_notice_dismiss_link) {
172 172
 					// Create array og key ==> value by parsing query string created after renaming data attributes.
173
-					$data_attribute_query_str = str_replace( array( 'data-', '-', '"' ), array(
173
+					$data_attribute_query_str = str_replace(array('data-', '-', '"'), array(
174 174
 						'',
175 175
 						'_',
176 176
 						'',
177
-					), implode( '&', $extra_notice_dismiss_link ) );
177
+					), implode('&', $extra_notice_dismiss_link));
178 178
 
179
-					$notice_args['extra_links'][] = wp_parse_args( $data_attribute_query_str );
179
+					$notice_args['extra_links'][] = wp_parse_args($data_attribute_query_str);
180 180
 				}
181 181
 			}
182 182
 		}
183 183
 
184 184
 
185
-		self::$notices[ $notice_args['id'] ] = $notice_args;
185
+		self::$notices[$notice_args['id']] = $notice_args;
186 186
 
187 187
 		// Auto set show param if not already set.
188
-		if ( ! isset( self::$notices[ $notice_args['id'] ]['show'] ) ) {
189
-			self::$notices[ $notice_args['id'] ]['show'] = $this->is_notice_dismissed( $notice_args ) ? false : true;
188
+		if ( ! isset(self::$notices[$notice_args['id']]['show'])) {
189
+			self::$notices[$notice_args['id']]['show'] = $this->is_notice_dismissed($notice_args) ? false : true;
190 190
 		}
191 191
 
192 192
 		// Auto set time interval for shortly.
193
-		if ( 'shortly' === self::$notices[ $notice_args['id'] ]['dismiss_interval'] ) {
194
-			self::$notices[ $notice_args['id'] ]['dismiss_interval_time'] = DAY_IN_SECONDS;
193
+		if ('shortly' === self::$notices[$notice_args['id']]['dismiss_interval']) {
194
+			self::$notices[$notice_args['id']]['dismiss_interval_time'] = DAY_IN_SECONDS;
195 195
 		}
196 196
 
197 197
 		return true;
@@ -205,51 +205,51 @@  discard block
 block discarded – undo
205 205
 	 */
206 206
 	public function render_admin_notices() {
207 207
 		// Bailout.
208
-		if ( empty( self::$notices ) ) {
208
+		if (empty(self::$notices)) {
209 209
 			return;
210 210
 		}
211 211
 
212 212
 		$output = '';
213 213
 
214
-		foreach ( self::$notices as $notice_id => $notice ) {
214
+		foreach (self::$notices as $notice_id => $notice) {
215 215
 			// Check flag set to true to show notice.
216
-			if ( ! $notice['show'] ) {
216
+			if ( ! $notice['show']) {
217 217
 				continue;
218 218
 			}
219 219
 
220 220
 
221 221
 			// Render custom html.
222
-			if( ! empty( $notice['description_html'] ) ) {
222
+			if ( ! empty($notice['description_html'])) {
223 223
 				$output .= "{$notice['description_html']} \n";
224 224
 				continue;
225 225
 			}
226 226
 
227 227
 			// Check if notice dismissible or not.
228
-			if ( ! self::$has_auto_dismissible_notice ) {
229
-				self::$has_auto_dismissible_notice = ( 'auto' === $notice['dismissible'] );
228
+			if ( ! self::$has_auto_dismissible_notice) {
229
+				self::$has_auto_dismissible_notice = ('auto' === $notice['dismissible']);
230 230
 			}
231 231
 
232 232
 			// Check if notice dismissible or not.
233
-			if ( ! self::$has_dismiss_interval_notice ) {
233
+			if ( ! self::$has_dismiss_interval_notice) {
234 234
 				self::$has_dismiss_interval_notice = $notice['dismiss_interval'];
235 235
 			}
236 236
 
237
-			$css_id = ( false === strpos( $notice['id'], 'give' ) ? "give-{$notice['id']}" : $notice['id'] );
237
+			$css_id = (false === strpos($notice['id'], 'give') ? "give-{$notice['id']}" : $notice['id']);
238 238
 
239
-			$css_class = 'give-notice notice ' . ( empty( $notice['dismissible'] ) ? 'non' : 'is' ) . "-dismissible {$notice['type']} notice-{$notice['type']}";
240
-			$output    .= sprintf(
241
-				'<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">' . " \n",
239
+			$css_class = 'give-notice notice '.(empty($notice['dismissible']) ? 'non' : 'is')."-dismissible {$notice['type']} notice-{$notice['type']}";
240
+			$output .= sprintf(
241
+				'<div id="%1$s" class="%2$s" data-dismissible="%3$s" data-dismissible-type="%4$s" data-dismiss-interval="%5$s" data-notice-id="%6$s" data-security="%7$s" data-dismiss-interval-time="%8$s" style="display: none">'." \n",
242 242
 				$css_id,
243 243
 				$css_class,
244
-				give_clean( $notice['dismissible'] ),
244
+				give_clean($notice['dismissible']),
245 245
 				$notice['dismissible_type'],
246 246
 				$notice['dismiss_interval'],
247 247
 				$notice['id'],
248
-				empty( $notice['dismissible_type'] ) ? '' : wp_create_nonce( "give_edit_{$notice_id}_notice" ),
248
+				empty($notice['dismissible_type']) ? '' : wp_create_nonce("give_edit_{$notice_id}_notice"),
249 249
 				$notice['dismiss_interval_time']
250 250
 			);
251 251
 
252
-			$output .= ( 0 === strpos( $notice['description'], '<div' ) || 0 === strpos( $notice['description'], '<p' ) ? $notice['description'] : "<p>{$notice['description']}</p>" );
252
+			$output .= (0 === strpos($notice['description'], '<div') || 0 === strpos($notice['description'], '<p') ? $notice['description'] : "<p>{$notice['description']}</p>");
253 253
 			$output .= "</div> \n";
254 254
 		}
255 255
 
@@ -267,18 +267,18 @@  discard block
 block discarded – undo
267 267
 	 *
268 268
 	 * @param int $form_id
269 269
 	 */
270
-	public function render_frontend_notices( $form_id = 0 ) {
270
+	public function render_frontend_notices($form_id = 0) {
271 271
 		$errors = give_get_errors();
272 272
 
273
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? absint( $_REQUEST['form-id'] ) : 0;
273
+		$request_form_id = isset($_REQUEST['form-id']) ? absint($_REQUEST['form-id']) : 0;
274 274
 
275 275
 		// Sanity checks first: Ensure that gateway returned errors display on the appropriate form.
276
-		if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) {
276
+		if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) {
277 277
 			return;
278 278
 		}
279 279
 
280
-		if ( $errors ) {
281
-			self::print_frontend_errors( $errors );
280
+		if ($errors) {
281
+			self::print_frontend_errors($errors);
282 282
 
283 283
 			give_clear_errors();
284 284
 		}
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @access private
292 292
 	 */
293 293
 	private function print_js() {
294
-		if ( self::$has_auto_dismissible_notice ) :
294
+		if (self::$has_auto_dismissible_notice) :
295 295
 			?>
296 296
 			<script>
297 297
 				jQuery(document).ready(function () {
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 			<?php
308 308
 		endif;
309 309
 
310
-		if ( self::$has_dismiss_interval_notice ) :
310
+		if (self::$has_dismiss_interval_notice) :
311 311
 			?>
312 312
 			<script>
313 313
 				jQuery(document).ready(function () {
@@ -386,29 +386,29 @@  discard block
 block discarded – undo
386 386
 	 * @access public
387 387
 	 */
388 388
 	public function dismiss_notices() {
389
-		$_post     = give_clean( $_POST );
390
-		$notice_id = esc_attr( $_post['notice_id'] );
389
+		$_post     = give_clean($_POST);
390
+		$notice_id = esc_attr($_post['notice_id']);
391 391
 
392 392
 		// Bailout.
393 393
 		if (
394
-			empty( $notice_id ) ||
395
-			empty( $_post['dismissible_type'] ) ||
396
-			empty( $_post['dismiss_interval'] ) ||
397
-			! check_ajax_referer( "give_edit_{$notice_id}_notice", '_wpnonce' )
394
+			empty($notice_id) ||
395
+			empty($_post['dismissible_type']) ||
396
+			empty($_post['dismiss_interval']) ||
397
+			! check_ajax_referer("give_edit_{$notice_id}_notice", '_wpnonce')
398 398
 		) {
399 399
 			wp_send_json_error();
400 400
 		}
401 401
 
402
-		$notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'] );
403
-		if ( 'user' === $_post['dismissible_type'] ) {
402
+		$notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval']);
403
+		if ('user' === $_post['dismissible_type']) {
404 404
 			$current_user = wp_get_current_user();
405
-			$notice_key   = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'], $current_user->ID );
405
+			$notice_key   = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval'], $current_user->ID);
406 406
 		}
407 407
 
408
-		$notice_dismiss_time = ! empty( $_post['dismiss_interval_time'] ) ? $_post['dismiss_interval_time'] : null;
408
+		$notice_dismiss_time = ! empty($_post['dismiss_interval_time']) ? $_post['dismiss_interval_time'] : null;
409 409
 
410 410
 		// Save option to hide notice.
411
-		Give_Cache::set( $notice_key, true, $notice_dismiss_time, true );
411
+		Give_Cache::set($notice_key, true, $notice_dismiss_time, true);
412 412
 
413 413
 		wp_send_json_success();
414 414
 	}
@@ -426,18 +426,18 @@  discard block
 block discarded – undo
426 426
 	 *
427 427
 	 * @return string
428 428
 	 */
429
-	public function get_notice_key( $notice_id, $dismiss_interval = null, $user_id = 0 ) {
429
+	public function get_notice_key($notice_id, $dismiss_interval = null, $user_id = 0) {
430 430
 		$notice_key = "_give_notice_{$notice_id}";
431 431
 
432
-		if ( ! empty( $dismiss_interval ) ) {
432
+		if ( ! empty($dismiss_interval)) {
433 433
 			$notice_key .= "_{$dismiss_interval}";
434 434
 		}
435 435
 
436
-		if ( $user_id ) {
436
+		if ($user_id) {
437 437
 			$notice_key .= "_{$user_id}";
438 438
 		}
439 439
 
440
-		$notice_key = sanitize_key( $notice_key );
440
+		$notice_key = sanitize_key($notice_key);
441 441
 
442 442
 		return $notice_key;
443 443
 	}
@@ -450,11 +450,11 @@  discard block
 block discarded – undo
450 450
 	 *
451 451
 	 * @return string
452 452
 	 */
453
-	public function get_dismiss_link( $notice_args ) {
453
+	public function get_dismiss_link($notice_args) {
454 454
 		$notice_args = wp_parse_args(
455 455
 			$notice_args,
456 456
 			array(
457
-				'title'                 => __( 'Click here', 'give' ),
457
+				'title'                 => __('Click here', 'give'),
458 458
 				'dismissible_type'      => '',
459 459
 				'dismiss_interval'      => '',
460 460
 				'dismiss_interval_time' => null,
@@ -481,31 +481,31 @@  discard block
 block discarded – undo
481 481
 	 *
482 482
 	 * @return bool|null
483 483
 	 */
484
-	public function is_notice_dismissed( $notice ) {
485
-		$notice_key          = $this->get_notice_key( $notice['id'], $notice['dismiss_interval'] );
484
+	public function is_notice_dismissed($notice) {
485
+		$notice_key          = $this->get_notice_key($notice['id'], $notice['dismiss_interval']);
486 486
 		$is_notice_dismissed = false;
487 487
 
488
-		if ( 'user' === $notice['dismissible_type'] ) {
488
+		if ('user' === $notice['dismissible_type']) {
489 489
 			$current_user = wp_get_current_user();
490
-			$notice_key   = Give()->notices->get_notice_key( $notice['id'], $notice['dismiss_interval'], $current_user->ID );
490
+			$notice_key   = Give()->notices->get_notice_key($notice['id'], $notice['dismiss_interval'], $current_user->ID);
491 491
 		}
492 492
 
493
-		$notice_data = Give_Cache::get( $notice_key, true );
493
+		$notice_data = Give_Cache::get($notice_key, true);
494 494
 
495 495
 		// Find notice dismiss link status if notice has extra dismissible links.
496
-		if ( ( empty( $notice_data ) || is_wp_error( $notice_data ) ) && ! empty( $notice['extra_links'] ) ) {
496
+		if ((empty($notice_data) || is_wp_error($notice_data)) && ! empty($notice['extra_links'])) {
497 497
 
498
-			foreach ( $notice['extra_links'] as $extra_link ) {
499
-				$new_notice_data = wp_parse_args( $extra_link, $notice );
500
-				unset( $new_notice_data['extra_links'] );
498
+			foreach ($notice['extra_links'] as $extra_link) {
499
+				$new_notice_data = wp_parse_args($extra_link, $notice);
500
+				unset($new_notice_data['extra_links']);
501 501
 
502
-				if ( $is_notice_dismissed = $this->is_notice_dismissed( $new_notice_data ) ) {
502
+				if ($is_notice_dismissed = $this->is_notice_dismissed($new_notice_data)) {
503 503
 					return $is_notice_dismissed;
504 504
 				}
505 505
 			}
506 506
 		}
507 507
 
508
-		$is_notice_dismissed = ! empty( $notice_data ) && ! is_wp_error( $notice_data );
508
+		$is_notice_dismissed = ! empty($notice_data) && ! is_wp_error($notice_data);
509 509
 
510 510
 		return $is_notice_dismissed;
511 511
 	}
@@ -519,9 +519,9 @@  discard block
 block discarded – undo
519 519
 	 *
520 520
 	 * @param array $errors
521 521
 	 */
522
-	public static function print_frontend_errors( $errors ) {
522
+	public static function print_frontend_errors($errors) {
523 523
 		// Bailout.
524
-		if ( ! $errors ) {
524
+		if ( ! $errors) {
525 525
 			return;
526 526
 		}
527 527
 
@@ -536,37 +536,37 @@  discard block
 block discarded – undo
536 536
 		);
537 537
 
538 538
 		// Note: we will remove give_errors class in future.
539
-		$classes = apply_filters( 'give_error_class', array( 'give_notices', 'give_errors' ) );
539
+		$classes = apply_filters('give_error_class', array('give_notices', 'give_errors'));
540 540
 
541
-		echo sprintf( '<div class="%s">', implode( ' ', $classes ) );
541
+		echo sprintf('<div class="%s">', implode(' ', $classes));
542 542
 
543 543
 		// Loop error codes and display errors.
544
-		foreach ( $errors as $error_id => $error ) {
544
+		foreach ($errors as $error_id => $error) {
545 545
 			// Backward compatibility v<1.8.11
546
-			if ( is_string( $error ) ) {
546
+			if (is_string($error)) {
547 547
 				$error = array(
548 548
 					'message'     => $error,
549 549
 					'notice_args' => array(),
550 550
 				);
551 551
 			}
552 552
 
553
-			$notice_args = wp_parse_args( $error['notice_args'], $default_notice_args );
553
+			$notice_args = wp_parse_args($error['notice_args'], $default_notice_args);
554 554
 
555 555
 			/**
556 556
 			 * Filter to modify Frontend Errors args before errors is display.
557 557
 			 *
558 558
 			 * @since 1.8.14
559 559
 			 */
560
-			$notice_args = apply_filters( 'give_frontend_errors_args', $notice_args );
560
+			$notice_args = apply_filters('give_frontend_errors_args', $notice_args);
561 561
 
562 562
 			echo sprintf(
563 563
 				'<div class="give_error give_notice" id="give_error_%1$s" data-dismissible="%2$s" data-dismiss-interval="%3$d">
564 564
 						<p><strong>%4$s</strong>: %5$s</p>
565 565
 					</div>',
566 566
 				$error_id,
567
-				give_clean( $notice_args['dismissible'] ),
568
-				absint( $notice_args['dismiss_interval'] ),
569
-				esc_html__( 'Error', 'give' ),
567
+				give_clean($notice_args['dismissible']),
568
+				absint($notice_args['dismiss_interval']),
569
+				esc_html__('Error', 'give'),
570 570
 				$error['message']
571 571
 			);
572 572
 		}
@@ -588,8 +588,8 @@  discard block
 block discarded – undo
588 588
 	 *
589 589
 	 * @return  string
590 590
 	 */
591
-	public static function print_frontend_notice( $message, $echo = true, $notice_type = 'warning', $notice_args = array() ) {
592
-		if ( empty( $message ) ) {
591
+	public static function print_frontend_notice($message, $echo = true, $notice_type = 'warning', $notice_args = array()) {
592
+		if (empty($message)) {
593 593
 			return '';
594 594
 		}
595 595
 
@@ -603,14 +603,14 @@  discard block
 block discarded – undo
603 603
 			'dismiss_interval' => 5000,
604 604
 		);
605 605
 
606
-		$notice_args = wp_parse_args( $notice_args, $default_notice_args );
606
+		$notice_args = wp_parse_args($notice_args, $default_notice_args);
607 607
 
608 608
 		/**
609 609
 		 * Filter to modify Frontend notice args before notices is display.
610 610
 		 *
611 611
 		 * @since 1.8.14
612 612
 		 */
613
-		$notice_args = apply_filters( 'give_frontend_notice_args', $notice_args );
613
+		$notice_args = apply_filters('give_frontend_notice_args', $notice_args);
614 614
 
615 615
 		// Note: we will remove give_errors class in future.
616 616
 		$error = sprintf(
@@ -620,12 +620,12 @@  discard block
 block discarded – undo
620 620
 				</p>
621 621
 			</div>',
622 622
 			$notice_type,
623
-			give_clean( $notice_args['dismissible'] ),
624
-			absint( $notice_args['dismiss_interval'] ),
623
+			give_clean($notice_args['dismissible']),
624
+			absint($notice_args['dismiss_interval']),
625 625
 			$message
626 626
 		);
627 627
 
628
-		if ( ! $echo ) {
628
+		if ( ! $echo) {
629 629
 			return $error;
630 630
 		}
631 631
 
Please login to merge, or discard this patch.
includes/admin/class-addon-activation-banner.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 // Exit if accessed directly.
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 	 *                               'testing'           => false, // (required) Never leave as "true" in production!!!
33 33
 	 *                               }
34 34
 	 */
35
-	function __construct( $_banner_details ) {
35
+	function __construct($_banner_details) {
36 36
 		$current_user = wp_get_current_user();
37 37
 
38 38
 		$this->plugin_activate_by   = 0;
39 39
 		$this->banner_details       = $_banner_details;
40
-		$this->test_mode            = ( $this->banner_details['testing'] == 'true' ) ? true : false;
41
-		$this->nag_meta_key         = 'give_addon_activation_ignore_' . sanitize_title( $this->banner_details['name'] );
42
-		$this->activate_by_meta_key = 'give_addon_' . sanitize_title( $this->banner_details['name'] ) . '_active_by_user';
40
+		$this->test_mode            = ($this->banner_details['testing'] == 'true') ? true : false;
41
+		$this->nag_meta_key         = 'give_addon_activation_ignore_'.sanitize_title($this->banner_details['name']);
42
+		$this->activate_by_meta_key = 'give_addon_'.sanitize_title($this->banner_details['name']).'_active_by_user';
43 43
 
44 44
 		//Get current user
45 45
 		$this->user_id = $current_user->ID;
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
 	public function init() {
63 63
 
64 64
 		//Testing?
65
-		if ( $this->test_mode ) {
66
-			delete_user_meta( $this->user_id, $this->nag_meta_key );
65
+		if ($this->test_mode) {
66
+			delete_user_meta($this->user_id, $this->nag_meta_key);
67 67
 		}
68 68
 
69 69
 		//Get the current page to add the notice to
70
-		add_action( 'current_screen', array( $this, 'give_addon_notice_ignore' ) );
71
-		add_action( 'admin_notices', array( $this, 'give_addon_activation_admin_notice' ) );
70
+		add_action('current_screen', array($this, 'give_addon_notice_ignore'));
71
+		add_action('admin_notices', array($this, 'give_addon_activation_admin_notice'));
72 72
 
73 73
 		// File path of addon must be included in banner detail other addon activate meta will not delete.
74 74
 		$file_name = $this->get_plugin_file_name();
75 75
 
76
-		if ( ! empty( $file_name ) ) {
77
-			add_action( 'deactivate_' . $file_name, array( $this, 'remove_addon_activate_meta' ) );
76
+		if ( ! empty($file_name)) {
77
+			add_action('deactivate_'.$file_name, array($this, 'remove_addon_activate_meta'));
78 78
 		}
79 79
 	}
80 80
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	private function is_plugin_page() {
90 90
 		$screen = get_current_screen();
91 91
 
92
-		return ( $screen->parent_file === 'plugins.php' );
92
+		return ($screen->parent_file === 'plugins.php');
93 93
 	}
94 94
 
95 95
 
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 	public function give_addon_activation_admin_notice() {
103 103
 
104 104
 		// Bailout.
105
-		if ( ! $this->is_plugin_page() || $this->user_id !== $this->plugin_activate_by ) {
105
+		if ( ! $this->is_plugin_page() || $this->user_id !== $this->plugin_activate_by) {
106 106
 			return;
107 107
 		}
108 108
 
109 109
 		// If the user hasn't already dismissed the alert, output activation banner.
110
-		if ( ! get_user_meta( $this->user_id, $this->nag_meta_key ) ) {
110
+		if ( ! get_user_meta($this->user_id, $this->nag_meta_key)) {
111 111
 
112 112
 			$this->print_css();
113 113
 
@@ -125,44 +125,44 @@  discard block
 block discarded – undo
125 125
 					<h3><?php
126 126
 						printf(
127 127
 						/* translators: %s: Add-on name */
128
-							esc_html__( "Thank you for installing Give's %s Add-on!", 'give' ),
129
-							'<span>' . $this->banner_details['name'] . '</span>'
128
+							esc_html__("Thank you for installing Give's %s Add-on!", 'give'),
129
+							'<span>'.$this->banner_details['name'].'</span>'
130 130
 						);
131 131
 						?></h3>
132 132
 
133 133
 					<a href="<?php
134 134
 					//The Dismiss Button.
135
-					$nag_admin_dismiss_url = 'plugins.php?' . $this->nag_meta_key . '=0';
136
-					echo admin_url( $nag_admin_dismiss_url ); ?>" class="dismiss"><span
135
+					$nag_admin_dismiss_url = 'plugins.php?'.$this->nag_meta_key.'=0';
136
+					echo admin_url($nag_admin_dismiss_url); ?>" class="dismiss"><span
137 137
 							class="dashicons dashicons-dismiss"></span></a>
138 138
 
139 139
 					<div class="alert-actions">
140 140
 
141 141
 						<?php //Point them to your settings page.
142
-						if ( isset( $this->banner_details['settings_url'] ) ) { ?>
142
+						if (isset($this->banner_details['settings_url'])) { ?>
143 143
 							<a href="<?php echo $this->banner_details['settings_url']; ?>">
144
-								<span class="dashicons dashicons-admin-settings"></span><?php esc_html_e( 'Go to Settings', 'give' ); ?>
144
+								<span class="dashicons dashicons-admin-settings"></span><?php esc_html_e('Go to Settings', 'give'); ?>
145 145
 							</a>
146 146
 						<?php } ?>
147 147
 
148 148
 						<?php
149 149
 						// Show them how to configure the Addon.
150
-						if ( isset( $this->banner_details['documentation_url'] ) ) { ?>
150
+						if (isset($this->banner_details['documentation_url'])) { ?>
151 151
 							<a href="<?php echo $this->banner_details['documentation_url'] ?>" target="_blank">
152 152
 								<span class="dashicons dashicons-media-text"></span><?php
153 153
 								printf(
154 154
 								/* translators: %s: Add-on name */
155
-									esc_html__( 'Documentation: %s Add-on', 'give' ),
155
+									esc_html__('Documentation: %s Add-on', 'give'),
156 156
 									$this->banner_details['name']
157 157
 								);
158 158
 								?></a>
159 159
 						<?php } ?>
160 160
 						<?php
161 161
 						//Let them signup for plugin updates
162
-						if ( isset( $this->banner_details['support_url'] ) ) { ?>
162
+						if (isset($this->banner_details['support_url'])) { ?>
163 163
 
164 164
 							<a href="<?php echo $this->banner_details['support_url'] ?>" target="_blank">
165
-								<span class="dashicons dashicons-sos"></span><?php esc_html_e( 'Get Support', 'give' ); ?>
165
+								<span class="dashicons dashicons-sos"></span><?php esc_html_e('Get Support', 'give'); ?>
166 166
 							</a>
167 167
 
168 168
 						<?php } ?>
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
 			
177 177
 			
178 178
 			// Register notice.
179
-			Give()->notices->register_notice( array(
180
-				'id'          => 'give_' . sanitize_title( $this->banner_details['name'] ) . '_notice',
179
+			Give()->notices->register_notice(array(
180
+				'id'          => 'give_'.sanitize_title($this->banner_details['name']).'_notice',
181 181
 				'type'        => 'updated',
182 182
 				'description_html' => $notice_html,
183 183
 				'show'        => true,
184
-			) );
184
+			));
185 185
 		}
186 186
 	}
187 187
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * @since 1.8.16
193 193
 	 * @access private
194 194
 	 */
195
-	private function print_css(){
195
+	private function print_css() {
196 196
 		?>
197 197
 		<style>
198 198
 			div.give-addon-alert.updated {
@@ -280,13 +280,13 @@  discard block
 block discarded – undo
280 280
 		 * If user clicks to ignore the notice, add that to their user meta the banner then checks whether this tag exists already or not.
281 281
 		 * See here: http://codex.wordpress.org/Function_Reference/add_user_meta
282 282
 		 */
283
-		if ( isset( $_GET[ $this->nag_meta_key ] ) && '0' == $_GET[ $this->nag_meta_key ] ) {
283
+		if (isset($_GET[$this->nag_meta_key]) && '0' == $_GET[$this->nag_meta_key]) {
284 284
 
285 285
 			//Get the global user
286 286
 			$current_user = wp_get_current_user();
287 287
 			$user_id      = $current_user->ID;
288 288
 
289
-			add_user_meta( $user_id, $this->nag_meta_key, 'true', true );
289
+			add_user_meta($user_id, $this->nag_meta_key, 'true', true);
290 290
 		}
291 291
 	}
292 292
 
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
 	 * @access private
298 298
 	 */
299 299
 	private function add_addon_activate_meta() {
300
-		$user_id                  = get_option( $this->activate_by_meta_key );
300
+		$user_id                  = get_option($this->activate_by_meta_key);
301 301
 		$this->plugin_activate_by = (int) $user_id;
302 302
 
303
-		if ( ! $user_id ) {
304
-			add_option( $this->activate_by_meta_key, $this->user_id, '', 'no' );
303
+		if ( ! $user_id) {
304
+			add_option($this->activate_by_meta_key, $this->user_id, '', 'no');
305 305
 			$this->plugin_activate_by = (int) $this->user_id;
306 306
 		}
307 307
 	}
@@ -314,10 +314,10 @@  discard block
 block discarded – undo
314 314
 	 * @access public
315 315
 	 */
316 316
 	public function remove_addon_activate_meta() {
317
-		$user_id = get_option( $this->activate_by_meta_key );
317
+		$user_id = get_option($this->activate_by_meta_key);
318 318
 
319
-		if ( $user_id ) {
320
-			delete_option( $this->activate_by_meta_key );
319
+		if ($user_id) {
320
+			delete_option($this->activate_by_meta_key);
321 321
 		}
322 322
 	}
323 323
 
@@ -330,39 +330,39 @@  discard block
 block discarded – undo
330 330
 	 * @return mixed
331 331
 	 */
332 332
 	private function get_plugin_file_name() {
333
-		$active_plugins = get_option( 'active_plugins' );
333
+		$active_plugins = get_option('active_plugins');
334 334
 		$file_name      = '';
335 335
 
336 336
 		try {
337 337
 
338 338
 			// Check addon file path.
339
-			if ( ! empty( $this->banner_details['file'] ) ) {
339
+			if ( ! empty($this->banner_details['file'])) {
340 340
 				$file_name = '';
341
-				if ( $file_path = explode( '/plugins/', $this->banner_details['file'] ) ) {
342
-					$file_path = array_pop( $file_path );
343
-					$file_name = current( explode( '/', $file_path ) );
341
+				if ($file_path = explode('/plugins/', $this->banner_details['file'])) {
342
+					$file_path = array_pop($file_path);
343
+					$file_name = current(explode('/', $file_path));
344 344
 				}
345 345
 
346
-				if ( empty( $file_name ) ) {
346
+				if (empty($file_name)) {
347 347
 					return false;
348 348
 				}
349 349
 
350
-				foreach ( $active_plugins as $plugin ) {
351
-					if ( false !== strpos( $plugin, $file_name ) ) {
350
+				foreach ($active_plugins as $plugin) {
351
+					if (false !== strpos($plugin, $file_name)) {
352 352
 						$file_name = $plugin;
353 353
 						break;
354 354
 					}
355 355
 				}
356
-			} elseif ( WP_DEBUG ) {
357
-				throw new Exception( __( "File path must be added within the {$this->banner_details['name']} add-on in the banner details.", 'give' ) );
356
+			} elseif (WP_DEBUG) {
357
+				throw new Exception(__("File path must be added within the {$this->banner_details['name']} add-on in the banner details.", 'give'));
358 358
 			}
359 359
 
360 360
 			// Check plugin path calculated by addon file path.
361
-			if ( empty( $file_name ) && WP_DEBUG ) {
362
-				throw new Exception( __( "Empty add-on plugin path for {$this->banner_details['name']} add-on.", 'give' ) );
361
+			if (empty($file_name) && WP_DEBUG) {
362
+				throw new Exception(__("Empty add-on plugin path for {$this->banner_details['name']} add-on.", 'give'));
363 363
 			}
364 364
 
365
-		} catch ( Exception $e ) {
365
+		} catch (Exception $e) {
366 366
 			echo $e->getMessage();
367 367
 		}
368 368
 
Please login to merge, or discard this patch.
includes/admin/reports/class-forms-report.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Forms_Report' ) ) :
16
+if ( ! class_exists('Give_Forms_Report')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Forms_Report.
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
 		 */
44 44
 		public function __construct() {
45 45
 			$this->id    = 'forms';
46
-			$this->label = esc_html__( 'Forms', 'give' );
46
+			$this->label = esc_html__('Forms', 'give');
47 47
 
48
-			add_filter( 'give-reports_tabs_array', array( $this, 'add_settings_page' ), 20 );
49
-			add_action( "give-reports_settings_{$this->id}_page", array( $this, 'output' ) );
50
-			add_action( 'give_admin_field_report_forms', array( $this, 'render_report_forms_field' ), 10, 2 );
48
+			add_filter('give-reports_tabs_array', array($this, 'add_settings_page'), 20);
49
+			add_action("give-reports_settings_{$this->id}_page", array($this, 'output'));
50
+			add_action('give_admin_field_report_forms', array($this, 'render_report_forms_field'), 10, 2);
51 51
 
52 52
 			// Do not use main form for this tab.
53
-			if( give_get_current_setting_tab() === $this->id ) {
54
-				add_action( 'give-reports_open_form', '__return_empty_string' );
55
-				add_action( 'give-reports_close_form', '__return_empty_string' );
53
+			if (give_get_current_setting_tab() === $this->id) {
54
+				add_action('give-reports_open_form', '__return_empty_string');
55
+				add_action('give-reports_close_form', '__return_empty_string');
56 56
 			}
57 57
 		}
58 58
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 		 * @param  array $pages List of pages.
64 64
 		 * @return array
65 65
 		 */
66
-		public function add_settings_page( $pages ) {
67
-			$pages[ $this->id ] = $this->label;
66
+		public function add_settings_page($pages) {
67
+			$pages[$this->id] = $this->label;
68 68
 
69 69
 			return $pages;
70 70
 		}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			 * @param  array $settings
87 87
 			 */
88 88
 			$settings = apply_filters(
89
-				'give_get_settings_' . $this->id,
89
+				'give_get_settings_'.$this->id,
90 90
 				array(
91 91
 					array(
92 92
 						'id'   => 'give_reports_forms',
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 					),
96 96
 					array(
97 97
 						'id'   => 'forms',
98
-						'name' => esc_html__( 'Forms', 'give' ),
98
+						'name' => esc_html__('Forms', 'give'),
99 99
 						'type' => 'report_forms',
100 100
 					),
101 101
 					array(
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		public function output() {
120 120
 			$settings = $this->get_settings();
121 121
 
122
-			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
122
+			Give_Admin_Settings::output_fields($settings, 'give_settings');
123 123
 		}
124 124
 
125 125
 		/**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 		 * @param $field
132 132
 		 * @param $option_value
133 133
 		 */
134
-		public function render_report_forms_field( $field, $option_value ) {
135
-			do_action( 'give_reports_view_forms');
134
+		public function render_report_forms_field($field, $option_value) {
135
+			do_action('give_reports_view_forms');
136 136
 		}
137 137
 	}
138 138
 
Please login to merge, or discard this patch.
includes/admin/reports/reports.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 // Exit if accessed directly.
19
-if ( ! defined( 'ABSPATH' ) ) {
19
+if ( ! defined('ABSPATH')) {
20 20
 	exit;
21 21
 }
22 22
 
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
  * @return void
30 30
  */
31 31
 function give_reports_page() {
32
-	$current_page = admin_url( 'edit.php?post_type=give_forms&page=give-reports' );
33
-	$active_tab   = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';
32
+	$current_page = admin_url('edit.php?post_type=give_forms&page=give-reports');
33
+	$active_tab   = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';
34 34
 	$views        = give_reports_default_views();
35 35
 	?>
36 36
 	<div class="wrap give-settings-page">
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
 		<h1 class="screen-reader-text"><?php echo get_admin_page_title(); ?></h1>
39 39
 
40 40
 		<h2 class="nav-tab-wrapper">
41
-			<?php foreach ( $views as $tab => $label ) { ?>
42
-				<a href="<?php echo esc_url( add_query_arg( array(
41
+			<?php foreach ($views as $tab => $label) { ?>
42
+				<a href="<?php echo esc_url(add_query_arg(array(
43 43
 					'tab'              => $tab,
44 44
 					'settings-updated' => false,
45
-				), $current_page ) ); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php echo esc_html( $label ); ?></a>
45
+				), $current_page)); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php echo esc_html($label); ?></a>
46 46
 			<?php } ?>
47
-			<?php if ( current_user_can( 'export_give_reports' ) ) { ?>
48
-				<a href="<?php echo esc_url( add_query_arg( array(
47
+			<?php if (current_user_can('export_give_reports')) { ?>
48
+				<a href="<?php echo esc_url(add_query_arg(array(
49 49
 					'tab'              => 'export',
50 50
 					'settings-updated' => false,
51
-				), $current_page ) ); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php esc_html_e( 'Export', 'give' ); ?></a>
51
+				), $current_page)); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php esc_html_e('Export', 'give'); ?></a>
52 52
 			<?php }
53 53
 			/**
54 54
 			 * Fires in the report tabs.
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 			 *
58 58
 			 * @since 1.0
59 59
 			 */
60
-			do_action( 'give_reports_tabs' );
60
+			do_action('give_reports_tabs');
61 61
 			?>
62 62
 		</h2>
63 63
 
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
 		 *
68 68
 		 * @since 1.0
69 69
 		 */
70
-		do_action( 'give_reports_page_top' );
70
+		do_action('give_reports_page_top');
71 71
 
72 72
 		// Set $active_tab prior to hook firing.
73
-		if ( in_array( $active_tab, array_keys( $views ) ) ) {
73
+		if (in_array($active_tab, array_keys($views))) {
74 74
 			$active_tab = 'reports';
75 75
 		}
76 76
 
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 		 *
80 80
 		 * @since 1.0
81 81
 		 */
82
-		do_action( "give_reports_tab_{$active_tab}" );
82
+		do_action("give_reports_tab_{$active_tab}");
83 83
 
84 84
 		/**
85 85
 		 * Fires after the report page.
86 86
 		 *
87 87
 		 * @since 1.0
88 88
 		 */
89
-		do_action( 'give_reports_page_bottom' );
89
+		do_action('give_reports_page_bottom');
90 90
 		?>
91 91
 	</div><!-- .wrap -->
92 92
 	<?php
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
  */
101 101
 function give_reports_default_views() {
102 102
 	$views = array(
103
-		'earnings' => esc_html__( 'Income', 'give' ),
104
-		'forms'    => esc_html__( 'Forms', 'give' ),
105
-		'gateways' => esc_html__( 'Donation Methods', 'give' ),
103
+		'earnings' => esc_html__('Income', 'give'),
104
+		'forms'    => esc_html__('Forms', 'give'),
105
+		'gateways' => esc_html__('Donation Methods', 'give'),
106 106
 	);
107 107
 
108
-	$views = apply_filters( 'give_report_views', $views );
108
+	$views = apply_filters('give_report_views', $views);
109 109
 
110 110
 	return $views;
111 111
 }
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
  * @since 1.0
121 121
  * @return string $view Report View
122 122
  */
123
-function give_get_reporting_view( $default = 'earnings' ) {
123
+function give_get_reporting_view($default = 'earnings') {
124 124
 
125
-	if ( ! isset( $_GET['view'] ) || ! in_array( $_GET['view'], array_keys( give_reports_default_views() ) ) ) {
125
+	if ( ! isset($_GET['view']) || ! in_array($_GET['view'], array_keys(give_reports_default_views()))) {
126 126
 		$view = $default;
127 127
 	} else {
128 128
 		$view = $_GET['view'];
129 129
 	}
130 130
 
131
-	return apply_filters( 'give_get_reporting_view', $view );
131
+	return apply_filters('give_get_reporting_view', $view);
132 132
 }
133 133
 
134 134
 /**
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
  */
140 140
 function give_reports_tab_reports() {
141 141
 
142
-	if( ! current_user_can( 'view_give_reports' ) ) {
143
-		wp_die( __( 'You do not have permission to access this report', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
142
+	if ( ! current_user_can('view_give_reports')) {
143
+		wp_die(__('You do not have permission to access this report', 'give'), __('Error', 'give'), array('response' => 403));
144 144
 	}
145 145
 
146 146
 	$current_view = 'earnings';
147 147
 	$views        = give_reports_default_views();
148 148
 
149
-	if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $views ) ) {
149
+	if (isset($_GET['tab']) && array_key_exists($_GET['tab'], $views)) {
150 150
 		$current_view = $_GET['tab'];
151 151
 	}
152 152
 
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @since 1.0
157 157
 	 */
158
-	do_action( "give_reports_view_{$current_view}" );
158
+	do_action("give_reports_view_{$current_view}");
159 159
 }
160 160
 
161
-add_action( 'give_reports_tab_reports', 'give_reports_tab_reports' );
161
+add_action('give_reports_tab_reports', 'give_reports_tab_reports');
162 162
 
163 163
 /**
164 164
  * Renders the Reports Page Views Drop Downs
@@ -168,19 +168,19 @@  discard block
 block discarded – undo
168 168
  */
169 169
 function give_report_views() {
170 170
 	$views        = give_reports_default_views();
171
-	$current_view = isset( $_GET['view'] ) ? $_GET['view'] : 'earnings';
171
+	$current_view = isset($_GET['view']) ? $_GET['view'] : 'earnings';
172 172
 	/**
173 173
 	 * Fires before the report page actions form.
174 174
 	 *
175 175
 	 * @since 1.0
176 176
 	 */
177
-	do_action( 'give_report_view_actions_before' );
177
+	do_action('give_report_view_actions_before');
178 178
 	?>
179 179
 	<form id="give-reports-filter" method="get">
180 180
 		<select id="give-reports-view" name="view">
181
-			<option value="-1"><?php esc_html_e( 'Report Type', 'give' ); ?></option>
182
-			<?php foreach ( $views as $view_id => $label ) : ?>
183
-				<option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option>
181
+			<option value="-1"><?php esc_html_e('Report Type', 'give'); ?></option>
182
+			<?php foreach ($views as $view_id => $label) : ?>
183
+				<option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option>
184 184
 			<?php endforeach; ?>
185 185
 		</select>
186 186
 
@@ -192,12 +192,12 @@  discard block
 block discarded – undo
192 192
 		 *
193 193
 		 * @since 1.0
194 194
 		 */
195
-		do_action( 'give_report_view_actions' );
195
+		do_action('give_report_view_actions');
196 196
 		?>
197 197
 
198 198
 		<input type="hidden" name="post_type" value="give_forms"/>
199 199
 		<input type="hidden" name="page" value="give-reports"/>
200
-		<?php submit_button( esc_html__( 'Show', 'give' ), 'secondary', 'submit', false ); ?>
200
+		<?php submit_button(esc_html__('Show', 'give'), 'secondary', 'submit', false); ?>
201 201
 	</form>
202 202
 	<?php
203 203
 	/**
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @since 1.0
207 207
 	 */
208
-	do_action( 'give_report_view_actions_after' );
208
+	do_action('give_report_view_actions_after');
209 209
 }
210 210
 
211 211
 /**
@@ -218,11 +218,11 @@  discard block
 block discarded – undo
218 218
  */
219 219
 function give_reports_forms_table() {
220 220
 
221
-	if ( isset( $_GET['form-id'] ) ) {
221
+	if (isset($_GET['form-id'])) {
222 222
 		return;
223 223
 	}
224 224
 
225
-	include( dirname( __FILE__ ) . '/class-form-reports-table.php' );
225
+	include(dirname(__FILE__).'/class-form-reports-table.php');
226 226
 
227 227
 	$give_table = new Give_Form_Reports_Table();
228 228
 	$give_table->prepare_items();
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	<?php
235 235
 }
236 236
 
237
-add_action( 'give_reports_view_forms', 'give_reports_forms_table' );
237
+add_action('give_reports_view_forms', 'give_reports_forms_table');
238 238
 
239 239
 /**
240 240
  * Renders the detailed report for a specific give form.
@@ -243,20 +243,20 @@  discard block
 block discarded – undo
243 243
  * @return void
244 244
  */
245 245
 function give_reports_form_details() {
246
-	if ( ! isset( $_GET['form-id'] ) ) {
246
+	if ( ! isset($_GET['form-id'])) {
247 247
 		return;
248 248
 	}
249 249
 	?>
250 250
 	<div class="tablenav top reports-forms-details-wrap">
251 251
 		<div class="actions bulkactions">
252
-			<button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e( 'Go Back', 'give' ); ?></button>
252
+			<button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e('Go Back', 'give'); ?></button>
253 253
 		</div>
254 254
 	</div>
255 255
 	<?php
256
-	give_reports_graph_of_form( absint( $_GET['form-id'] ) );
256
+	give_reports_graph_of_form(absint($_GET['form-id']));
257 257
 }
258 258
 
259
-add_action( 'give_reports_view_forms', 'give_reports_form_details' );
259
+add_action('give_reports_view_forms', 'give_reports_form_details');
260 260
 
261 261
 /**
262 262
  * Renders the Gateways Table
@@ -267,14 +267,14 @@  discard block
 block discarded – undo
267 267
  * @return void
268 268
  */
269 269
 function give_reports_gateways_table() {
270
-	include( dirname( __FILE__ ) . '/class-gateways-reports-table.php' );
270
+	include(dirname(__FILE__).'/class-gateways-reports-table.php');
271 271
 
272 272
 	$give_table = new Give_Gateway_Reports_Table();
273 273
 	$give_table->prepare_items();
274 274
 	$give_table->display();
275 275
 }
276 276
 
277
-add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' );
277
+add_action('give_reports_view_gateways', 'give_reports_gateways_table');
278 278
 
279 279
 /**
280 280
  * Renders the Reports Earnings Graphs
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
 function give_reports_earnings() {
286 286
 	?>
287 287
 	<div class="tablenav top reports-table-nav">
288
-		<h2 class="reports-earnings-title"><?php esc_html_e( 'Income Report', 'give' ); ?></h2>
288
+		<h2 class="reports-earnings-title"><?php esc_html_e('Income Report', 'give'); ?></h2>
289 289
 	</div>
290 290
 	<?php
291 291
 	give_reports_graph();
292 292
 }
293 293
 
294
-add_action( 'give_reports_view_earnings', 'give_reports_earnings' );
294
+add_action('give_reports_view_earnings', 'give_reports_earnings');
295 295
 
296 296
 
297 297
 /**
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
  */
303 303
 function give_estimated_monthly_stats() {
304 304
 
305
-	$estimated = Give_Cache::get( 'give_estimated_monthly_stats', true );
305
+	$estimated = Give_Cache::get('give_estimated_monthly_stats', true);
306 306
 
307
-	if ( false === $estimated ) {
307
+	if (false === $estimated) {
308 308
 
309 309
 		$estimated = array(
310 310
 			'earnings' => 0,
@@ -313,22 +313,22 @@  discard block
 block discarded – undo
313 313
 
314 314
 		$stats = new Give_Payment_Stats;
315 315
 
316
-		$to_date_earnings = $stats->get_earnings( 0, 'this_month' );
317
-		$to_date_sales    = $stats->get_sales( 0, 'this_month' );
316
+		$to_date_earnings = $stats->get_earnings(0, 'this_month');
317
+		$to_date_sales    = $stats->get_sales(0, 'this_month');
318 318
 
319
-		$current_day   = date( 'd', current_time( 'timestamp' ) );
320
-		$current_month = date( 'n', current_time( 'timestamp' ) );
321
-		$current_year  = date( 'Y', current_time( 'timestamp' ) );
322
-		$days_in_month = cal_days_in_month( CAL_GREGORIAN, $current_month, $current_year );
319
+		$current_day   = date('d', current_time('timestamp'));
320
+		$current_month = date('n', current_time('timestamp'));
321
+		$current_year  = date('Y', current_time('timestamp'));
322
+		$days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year);
323 323
 
324
-		$estimated['earnings'] = ( $to_date_earnings / $current_day ) * $days_in_month;
325
-		$estimated['sales']    = ( $to_date_sales / $current_day ) * $days_in_month;
324
+		$estimated['earnings'] = ($to_date_earnings / $current_day) * $days_in_month;
325
+		$estimated['sales']    = ($to_date_sales / $current_day) * $days_in_month;
326 326
 
327 327
 		// Cache for one day
328
-		Give_Cache::set( 'give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true );
328
+		Give_Cache::set('give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true);
329 329
 	}
330 330
 
331
-	return maybe_unserialize( $estimated );
331
+	return maybe_unserialize($estimated);
332 332
 }
333 333
 
334 334
 /**
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 function give_reports_set_form_method() {
342 342
 	return 'get';
343 343
 }
344
-add_filter( 'give-reports_form_method_tab_forms', 'give_reports_set_form_method', 10 );
345
-add_filter( 'give-reports_form_method_tab_donors', 'give_reports_set_form_method', 10 );
344
+add_filter('give-reports_form_method_tab_forms', 'give_reports_set_form_method', 10);
345
+add_filter('give-reports_form_method_tab_donors', 'give_reports_set_form_method', 10);
346 346
 
347 347
 // @TODO: After release 1.8 Donations -> Reports generates with new setting api, so we can remove some old code from this file.
Please login to merge, or discard this patch.