Completed
Pull Request — master (#1832)
by Devin
04:50
created
includes/actions.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -216,7 +216,6 @@
 block discarded – undo
216 216
 /**
217 217
  * Set Donation Amount for Multi Level Donation Forms
218 218
  *
219
- * @param int    $form_id
220 219
  * @param object $form
221 220
  *
222 221
  * @since 1.8.9
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 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
 
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_get_actions() {
27 27
 
28
-	$_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null;
28
+	$_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null;
29 29
 
30 30
 	// Add backward compatibility to give-action param ( $_GET )
31
-	if(  empty( $_get_action ) ) {
32
-		$_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null;
31
+	if (empty($_get_action)) {
32
+		$_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null;
33 33
 	}
34 34
 
35
-	if ( isset( $_get_action ) ) {
35
+	if (isset($_get_action)) {
36 36
 		/**
37 37
 		 * Fires in WordPress init or admin init, when give_action is present in $_GET.
38 38
 		 *
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 		 *
41 41
 		 * @param array $_GET Array of HTTP GET variables.
42 42
 		 */
43
-		do_action( "give_{$_get_action}", $_GET );
43
+		do_action("give_{$_get_action}", $_GET);
44 44
 	}
45 45
 
46 46
 }
47 47
 
48
-add_action( 'init', 'give_get_actions' );
48
+add_action('init', 'give_get_actions');
49 49
 
50 50
 /**
51 51
  * Hooks Give actions, when present in the $_POST super global. Every give_action
@@ -58,15 +58,15 @@  discard block
 block discarded – undo
58 58
  */
59 59
 function give_post_actions() {
60 60
 
61
-	$_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null;
61
+	$_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null;
62 62
 
63 63
 
64 64
 	// Add backward compatibility to give-action param ( $_POST ).
65
-	if(  empty( $_post_action ) ) {
66
-		$_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null;
65
+	if (empty($_post_action)) {
66
+		$_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null;
67 67
 	}
68 68
 
69
-	if ( isset( $_post_action ) ) {
69
+	if (isset($_post_action)) {
70 70
 		/**
71 71
 		 * Fires in WordPress init or admin init, when give_action is present in $_POST.
72 72
 		 *
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 		 *
75 75
 		 * @param array $_POST Array of HTTP POST variables.
76 76
 		 */
77
-		do_action( "give_{$_post_action}", $_POST );
77
+		do_action("give_{$_post_action}", $_POST);
78 78
 	}
79 79
 
80 80
 }
81 81
 
82
-add_action( 'init', 'give_post_actions' );
82
+add_action('init', 'give_post_actions');
83 83
 
84 84
 /**
85 85
  * Connect WordPress user with Donor.
@@ -89,28 +89,28 @@  discard block
 block discarded – undo
89 89
  * @param  array $user_data User Data
90 90
  * @return void
91 91
  */
92
-function give_connect_donor_to_wpuser( $user_id, $user_data ){
92
+function give_connect_donor_to_wpuser($user_id, $user_data) {
93 93
 	/* @var Give_Donor $donor */
94
-	$donor = new Give_Donor( $user_data['user_email'] );
94
+	$donor = new Give_Donor($user_data['user_email']);
95 95
 
96 96
 	// Validate donor id and check if do nor is already connect to wp user or not.
97
-	if( $donor->id && ! $donor->user_id ) {
97
+	if ($donor->id && ! $donor->user_id) {
98 98
 
99 99
 		// Update donor user_id.
100
-		if( $donor->update( array( 'user_id' => $user_id ) ) ) {
101
-			$donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id );
102
-			$donor->add_note( $donor_note );
100
+		if ($donor->update(array('user_id' => $user_id))) {
101
+			$donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id);
102
+			$donor->add_note($donor_note);
103 103
 
104 104
 			// Update user_id meta in payments.
105
-			if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) {
106
-				foreach ( $donations as $donation  ) {
107
-					give_update_meta( $donation, '_give_payment_user_id', $user_id );
105
+			if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) {
106
+				foreach ($donations as $donation) {
107
+					give_update_meta($donation, '_give_payment_user_id', $user_id);
108 108
 				}
109 109
 			}
110 110
 		}
111 111
 	}
112 112
 }
113
-add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 );
113
+add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2);
114 114
 
115 115
 
116 116
 /**
@@ -124,24 +124,24 @@  discard block
 block discarded – undo
124 124
 function give_validate_license_when_site_migrated() {
125 125
 	// Store current site address if not already stored.
126 126
 	$homeurl = home_url();
127
-	if( ! get_option( 'give_site_address_before_migrate' ) ) {
127
+	if ( ! get_option('give_site_address_before_migrate')) {
128 128
 		// Update site address.
129
-		update_option( 'give_site_address_before_migrate', $homeurl );
129
+		update_option('give_site_address_before_migrate', $homeurl);
130 130
 
131 131
 		return;
132 132
 	}
133 133
 
134
-	if( $homeurl !== get_option( 'give_site_address_before_migrate' ) ) {
134
+	if ($homeurl !== get_option('give_site_address_before_migrate')) {
135 135
 		// Immediately run cron.
136
-		wp_schedule_single_event( time() , 'give_validate_license_when_site_migrated' );
136
+		wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated');
137 137
 
138 138
 		// Update site address.
139
-		update_option( 'give_site_address_before_migrate', home_url() );
139
+		update_option('give_site_address_before_migrate', home_url());
140 140
 	}
141 141
 
142 142
 }
143
-add_action( 'init', 'give_validate_license_when_site_migrated' );
144
-add_action( 'admin_init', 'give_validate_license_when_site_migrated' );
143
+add_action('init', 'give_validate_license_when_site_migrated');
144
+add_action('admin_init', 'give_validate_license_when_site_migrated');
145 145
 
146 146
 
147 147
 /**
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
  * @since 1.8
151 151
  * @param $data
152 152
  */
153
-function give_donor_batch_export_complete( $data ) {
153
+function give_donor_batch_export_complete($data) {
154 154
 	// Remove donor ids cache.
155
-	if(
156
-		isset( $data['class'] )
155
+	if (
156
+		isset($data['class'])
157 157
 		&& 'Give_Batch_Donors_Export' === $data['class']
158
-		&& ! empty( $data['forms'] )
159
-		&& isset( $data['give_export_option']['query_id'] )
158
+		&& ! empty($data['forms'])
159
+		&& isset($data['give_export_option']['query_id'])
160 160
 	) {
161
-		Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) );
161
+		Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id']));
162 162
 	}
163 163
 }
164
-add_action('give_file_export_complete', 'give_donor_batch_export_complete' );
164
+add_action('give_file_export_complete', 'give_donor_batch_export_complete');
165 165
 
166 166
 /**
167 167
  * Print css for wordpress setting pages.
@@ -172,12 +172,12 @@  discard block
 block discarded – undo
172 172
 	/* @var WP_Screen $screen */
173 173
 	$screen = get_current_screen();
174 174
 
175
-	if( ! ( $screen instanceof WP_Screen ) ) {
175
+	if ( ! ($screen instanceof WP_Screen)) {
176 176
 		return false;
177 177
 	}
178 178
 
179
-	switch ( true ) {
180
-		case ( 'plugins' === $screen->base ):
179
+	switch (true) {
180
+		case ('plugins' === $screen->base):
181 181
 			?>
182 182
 			<style>
183 183
 				tr.active.update + tr.give-addon-notice-tr td{
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			<?php
211 211
 	}
212 212
 }
213
-add_action( 'admin_head', 'give_admin_quick_css' );
213
+add_action('admin_head', 'give_admin_quick_css');
214 214
 
215 215
 
216 216
 /**
@@ -223,25 +223,25 @@  discard block
 block discarded – undo
223 223
  *
224 224
  * @return void
225 225
  */
226
-function give_set_donation_levels_max_min_amount( $form_id ) {
226
+function give_set_donation_levels_max_min_amount($form_id) {
227 227
 	if (
228
-		( 'set' === $_POST['_give_price_option'] ) ||
229
-		( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) ||
230
-		! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) )
228
+		('set' === $_POST['_give_price_option']) ||
229
+		(in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) ||
230
+		! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount'))
231 231
 	) {
232 232
 		// Delete old meta.
233
-		give_delete_meta( $form_id, '_give_levels_minimum_amount' );
234
-		give_delete_meta( $form_id, '_give_levels_maximum_amount' );
233
+		give_delete_meta($form_id, '_give_levels_minimum_amount');
234
+		give_delete_meta($form_id, '_give_levels_maximum_amount');
235 235
 
236 236
 		return;
237 237
 	}
238 238
 
239
-	$min_amount = min( $donation_levels_amounts );
240
-	$max_amount = max( $donation_levels_amounts );
239
+	$min_amount = min($donation_levels_amounts);
240
+	$max_amount = max($donation_levels_amounts);
241 241
 
242 242
 	// Set Minimum and Maximum amount for Multi Level Donation Forms
243
-	give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 );
244
-	give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount? give_sanitize_amount( $max_amount ) : 0 );
243
+	give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0);
244
+	give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0);
245 245
 }
246 246
 
247
-add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 );
248 247
\ No newline at end of file
248
+add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30);
249 249
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/donors/donor-actions.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
  *
273 273
  * @param  array $args The $_POST array being passed.
274 274
  *
275
- * @return int Whether it was a successful deletion.
275
+ * @return false|null Whether it was a successful deletion.
276 276
  */
277 277
 function give_donor_delete( $args ) {
278 278
 
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
  * Remove an email address to the donor from within the admin and log a donor note and redirect back to the donor interface for feedback.
547 547
  *
548 548
  * @since  1.7
549
- * @return bool|null
549
+ * @return false|null
550 550
  */
551 551
 function give_remove_donor_email() {
552 552
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
  * and redirect back to the donor interface for feedback
590 590
  *
591 591
  * @since  1.7
592
- * @return bool|null
592
+ * @return false|null
593 593
  */
594 594
 function give_set_donor_primary_email() {
595 595
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
Please login to merge, or discard this patch.
Spacing   +193 added lines, -193 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
 
@@ -58,70 +58,70 @@  discard block
 block discarded – undo
58 58
 		'user_id' => 0,
59 59
 	);
60 60
 
61
-	$donor_info = wp_parse_args( $donor_info, $defaults );
61
+	$donor_info = wp_parse_args($donor_info, $defaults);
62 62
 
63
-	if ( (int) $donor_info['user_id'] !== (int) $donor->user_id ) {
63
+	if ((int) $donor_info['user_id'] !== (int) $donor->user_id) {
64 64
 
65 65
 		// Make sure we don't already have this user attached to a donor.
66
-		if ( ! empty( $donor_info['user_id'] ) && false !== Give()->donors->get_donor_by( 'user_id', $donor_info['user_id'] ) ) {
67
-			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'] ) );
66
+		if ( ! empty($donor_info['user_id']) && false !== Give()->donors->get_donor_by('user_id', $donor_info['user_id'])) {
67
+			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']));
68 68
 		}
69 69
 
70 70
 		// Make sure it's actually a user.
71
-		$user = get_user_by( 'id', $donor_info['user_id'] );
72
-		if ( ! empty( $donor_info['user_id'] ) && false === $user ) {
73
-			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'] ) );
71
+		$user = get_user_by('id', $donor_info['user_id']);
72
+		if ( ! empty($donor_info['user_id']) && false === $user) {
73
+			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']));
74 74
 		}
75 75
 	}
76 76
 
77 77
 	// Record this for later.
78 78
 	$previous_user_id = $donor->user_id;
79 79
 
80
-	if ( give_get_errors() ) {
80
+	if (give_get_errors()) {
81 81
 		return false;
82 82
 	}
83 83
 
84 84
 	// Setup the donor address, if present.
85 85
 	$address = array();
86
-	if ( intval( $donor_info['user_id'] ) > 0 ) {
86
+	if (intval($donor_info['user_id']) > 0) {
87 87
 
88
-		$current_address = get_user_meta( $donor_info['user_id'], '_give_user_address', true );
88
+		$current_address = get_user_meta($donor_info['user_id'], '_give_user_address', true);
89 89
 
90
-		if ( false === $current_address ) {
91
-			$address['line1']   = isset( $donor_info['line1'] ) ? $donor_info['line1'] : '';
92
-			$address['line2']   = isset( $donor_info['line2'] ) ? $donor_info['line2'] : '';
93
-			$address['city']    = isset( $donor_info['city'] ) ? $donor_info['city'] : '';
94
-			$address['country'] = isset( $donor_info['country'] ) ? $donor_info['country'] : '';
95
-			$address['zip']     = isset( $donor_info['zip'] ) ? $donor_info['zip'] : '';
96
-			$address['state']   = isset( $donor_info['state'] ) ? $donor_info['state'] : '';
90
+		if (false === $current_address) {
91
+			$address['line1']   = isset($donor_info['line1']) ? $donor_info['line1'] : '';
92
+			$address['line2']   = isset($donor_info['line2']) ? $donor_info['line2'] : '';
93
+			$address['city']    = isset($donor_info['city']) ? $donor_info['city'] : '';
94
+			$address['country'] = isset($donor_info['country']) ? $donor_info['country'] : '';
95
+			$address['zip']     = isset($donor_info['zip']) ? $donor_info['zip'] : '';
96
+			$address['state']   = isset($donor_info['state']) ? $donor_info['state'] : '';
97 97
 		} else {
98
-			$current_address    = wp_parse_args( $current_address, array(
98
+			$current_address    = wp_parse_args($current_address, array(
99 99
 				'line1',
100 100
 				'line2',
101 101
 				'city',
102 102
 				'zip',
103 103
 				'state',
104 104
 				'country',
105
-			) );
106
-			$address['line1']   = isset( $donor_info['line1'] ) ? $donor_info['line1'] : $current_address['line1'];
107
-			$address['line2']   = isset( $donor_info['line2'] ) ? $donor_info['line2'] : $current_address['line2'];
108
-			$address['city']    = isset( $donor_info['city'] ) ? $donor_info['city'] : $current_address['city'];
109
-			$address['country'] = isset( $donor_info['country'] ) ? $donor_info['country'] : $current_address['country'];
110
-			$address['zip']     = isset( $donor_info['zip'] ) ? $donor_info['zip'] : $current_address['zip'];
111
-			$address['state']   = isset( $donor_info['state'] ) ? $donor_info['state'] : $current_address['state'];
105
+			));
106
+			$address['line1']   = isset($donor_info['line1']) ? $donor_info['line1'] : $current_address['line1'];
107
+			$address['line2']   = isset($donor_info['line2']) ? $donor_info['line2'] : $current_address['line2'];
108
+			$address['city']    = isset($donor_info['city']) ? $donor_info['city'] : $current_address['city'];
109
+			$address['country'] = isset($donor_info['country']) ? $donor_info['country'] : $current_address['country'];
110
+			$address['zip']     = isset($donor_info['zip']) ? $donor_info['zip'] : $current_address['zip'];
111
+			$address['state']   = isset($donor_info['state']) ? $donor_info['state'] : $current_address['state'];
112 112
 		}
113 113
 	}
114 114
 
115 115
 	// Sanitize the inputs
116 116
 	$donor_data            = array();
117
-	$donor_data['name']    = strip_tags( stripslashes( $donor_info['name'] ) );
117
+	$donor_data['name']    = strip_tags(stripslashes($donor_info['name']));
118 118
 	$donor_data['user_id'] = $donor_info['user_id'];
119 119
 
120
-	$donor_data = apply_filters( 'give_edit_donor_info', $donor_data, $donor_id );
121
-	$address    = apply_filters( 'give_edit_donor_address', $address, $donor_id );
120
+	$donor_data = apply_filters('give_edit_donor_info', $donor_data, $donor_id);
121
+	$address    = apply_filters('give_edit_donor_address', $address, $donor_id);
122 122
 
123
-	$donor_data = array_map( 'sanitize_text_field', $donor_data );
124
-	$address    = array_map( 'sanitize_text_field', $address );
123
+	$donor_data = array_map('sanitize_text_field', $donor_data);
124
+	$address    = array_map('sanitize_text_field', $address);
125 125
 
126 126
 	/**
127 127
 	 * Fires before editing a donor.
@@ -132,27 +132,27 @@  discard block
 block discarded – undo
132 132
 	 * @param array $donor_data The donor data.
133 133
 	 * @param array $address    The donor's address.
134 134
 	 */
135
-	do_action( 'give_pre_edit_donor', $donor_id, $donor_data, $address );
135
+	do_action('give_pre_edit_donor', $donor_id, $donor_data, $address);
136 136
 
137 137
 	$output = array();
138 138
 
139
-	if ( $donor->update( $donor_data ) ) {
139
+	if ($donor->update($donor_data)) {
140 140
 
141
-		if ( ! empty( $donor->user_id ) && $donor->user_id > 0 ) {
142
-			update_user_meta( $donor->user_id, '_give_user_address', $address );
141
+		if ( ! empty($donor->user_id) && $donor->user_id > 0) {
142
+			update_user_meta($donor->user_id, '_give_user_address', $address);
143 143
 		}
144 144
 
145 145
 		// Update some donation meta if we need to.
146
-		$payments_array = explode( ',', $donor->payment_ids );
146
+		$payments_array = explode(',', $donor->payment_ids);
147 147
 
148
-		if ( $donor->user_id != $previous_user_id ) {
149
-			foreach ( $payments_array as $payment_id ) {
150
-				give_update_payment_meta( $payment_id, '_give_payment_user_id', $donor->user_id );
148
+		if ($donor->user_id != $previous_user_id) {
149
+			foreach ($payments_array as $payment_id) {
150
+				give_update_payment_meta($payment_id, '_give_payment_user_id', $donor->user_id);
151 151
 			}
152 152
 		}
153 153
 
154 154
 		$output['success']       = true;
155
-		$donor_data              = array_merge( $donor_data, $address );
155
+		$donor_data              = array_merge($donor_data, $address);
156 156
 		$output['customer_info'] = $donor_data;
157 157
 
158 158
 	} else {
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
 	 * @param int   $donor_id   The ID of the donor.
170 170
 	 * @param array $donor_data The donor data.
171 171
 	 */
172
-	do_action( 'give_post_edit_donor', $donor_id, $donor_data );
172
+	do_action('give_post_edit_donor', $donor_id, $donor_data);
173 173
 
174
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
175
-		header( 'Content-Type: application/json' );
176
-		echo json_encode( $output );
174
+	if (defined('DOING_AJAX') && DOING_AJAX) {
175
+		header('Content-Type: application/json');
176
+		echo json_encode($output);
177 177
 		wp_die();
178 178
 	}
179 179
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 
182 182
 }
183 183
 
184
-add_action( 'give_edit-donor', 'give_edit_donor', 10, 1 );
184
+add_action('give_edit-donor', 'give_edit_donor', 10, 1);
185 185
 
186 186
 /**
187 187
  * Save a donor note.
@@ -192,40 +192,40 @@  discard block
 block discarded – undo
192 192
  *
193 193
  * @return int         The Note ID that was saved, or 0 if nothing was saved.
194 194
  */
195
-function give_donor_save_note( $args ) {
195
+function give_donor_save_note($args) {
196 196
 
197
-	$donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' );
197
+	$donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports');
198 198
 
199
-	if ( ! is_admin() || ! current_user_can( $donor_view_role ) ) {
200
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
199
+	if ( ! is_admin() || ! current_user_can($donor_view_role)) {
200
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
201 201
 			'response' => 403,
202
-		) );
202
+		));
203 203
 	}
204 204
 
205
-	if ( empty( $args ) ) {
205
+	if (empty($args)) {
206 206
 		return false;
207 207
 	}
208 208
 
209
-	$donor_note = trim( sanitize_text_field( $args['donor_note'] ) );
209
+	$donor_note = trim(sanitize_text_field($args['donor_note']));
210 210
 	$donor_id   = (int) $args['customer_id'];
211 211
 	$nonce      = $args['add_donor_note_nonce'];
212 212
 
213
-	if ( ! wp_verify_nonce( $nonce, 'add-donor-note' ) ) {
214
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
213
+	if ( ! wp_verify_nonce($nonce, 'add-donor-note')) {
214
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
215 215
 			'response' => 400,
216
-		) );
216
+		));
217 217
 	}
218 218
 
219
-	if ( empty( $donor_note ) ) {
220
-		give_set_error( 'empty-donor-note', __( 'A note is required.', 'give' ) );
219
+	if (empty($donor_note)) {
220
+		give_set_error('empty-donor-note', __('A note is required.', 'give'));
221 221
 	}
222 222
 
223
-	if ( give_get_errors() ) {
223
+	if (give_get_errors()) {
224 224
 		return false;
225 225
 	}
226 226
 
227
-	$donor    = new Give_Donor( $donor_id );
228
-	$new_note = $donor->add_note( $donor_note );
227
+	$donor    = new Give_Donor($donor_id);
228
+	$new_note = $donor->add_note($donor_note);
229 229
 
230 230
 	/**
231 231
 	 * Fires before inserting donor note.
@@ -235,22 +235,22 @@  discard block
 block discarded – undo
235 235
 	 * @param int    $donor_id The ID of the donor.
236 236
 	 * @param string $new_note Note content.
237 237
 	 */
238
-	do_action( 'give_pre_insert_donor_note', $donor_id, $new_note );
238
+	do_action('give_pre_insert_donor_note', $donor_id, $new_note);
239 239
 
240
-	if ( ! empty( $new_note ) && ! empty( $donor->id ) ) {
240
+	if ( ! empty($new_note) && ! empty($donor->id)) {
241 241
 
242 242
 		ob_start();
243 243
 		?>
244 244
 		<div class="donor-note-wrapper dashboard-comment-wrap comment-item">
245 245
 			<span class="note-content-wrap">
246
-				<?php echo stripslashes( $new_note ); ?>
246
+				<?php echo stripslashes($new_note); ?>
247 247
 			</span>
248 248
 		</div>
249 249
 		<?php
250 250
 		$output = ob_get_contents();
251 251
 		ob_end_clean();
252 252
 
253
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
253
+		if (defined('DOING_AJAX') && DOING_AJAX) {
254 254
 			echo $output;
255 255
 			exit;
256 256
 		}
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 
264 264
 }
265 265
 
266
-add_action( 'give_add-donor-note', 'give_donor_save_note', 10, 1 );
266
+add_action('give_add-donor-note', 'give_donor_save_note', 10, 1);
267 267
 
268 268
 /**
269 269
  * Delete a donor.
@@ -274,41 +274,41 @@  discard block
 block discarded – undo
274 274
  *
275 275
  * @return int Whether it was a successful deletion.
276 276
  */
277
-function give_donor_delete( $args ) {
277
+function give_donor_delete($args) {
278 278
 
279
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
279
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
280 280
 
281
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
282
-		wp_die( __( 'You do not have permission to delete donors.', 'give' ), __( 'Error', 'give' ), array(
281
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
282
+		wp_die(__('You do not have permission to delete donors.', 'give'), __('Error', 'give'), array(
283 283
 			'response' => 403,
284
-		) );
284
+		));
285 285
 	}
286 286
 
287
-	if ( empty( $args ) ) {
287
+	if (empty($args)) {
288 288
 		return false;
289 289
 	}
290 290
 
291 291
 	$donor_id    = (int) $args['customer_id'];
292
-	$confirm     = ! empty( $args['give-donor-delete-confirm'] ) ? true : false;
293
-	$remove_data = ! empty( $args['give-donor-delete-records'] ) ? true : false;
292
+	$confirm     = ! empty($args['give-donor-delete-confirm']) ? true : false;
293
+	$remove_data = ! empty($args['give-donor-delete-records']) ? true : false;
294 294
 	$nonce       = $args['_wpnonce'];
295 295
 
296
-	if ( ! wp_verify_nonce( $nonce, 'delete-donor' ) ) {
297
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
296
+	if ( ! wp_verify_nonce($nonce, 'delete-donor')) {
297
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
298 298
 			'response' => 400,
299
-		) );
299
+		));
300 300
 	}
301 301
 
302
-	if ( ! $confirm ) {
303
-		give_set_error( 'donor-delete-no-confirm', __( 'Please confirm you want to delete this donor.', 'give' ) );
302
+	if ( ! $confirm) {
303
+		give_set_error('donor-delete-no-confirm', __('Please confirm you want to delete this donor.', 'give'));
304 304
 	}
305 305
 
306
-	if ( give_get_errors() ) {
307
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id ) );
306
+	if (give_get_errors()) {
307
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id));
308 308
 		exit;
309 309
 	}
310 310
 
311
-	$donor = new Give_Donor( $donor_id );
311
+	$donor = new Give_Donor($donor_id);
312 312
 
313 313
 	/**
314 314
 	 * Fires before deleting donor.
@@ -319,50 +319,50 @@  discard block
 block discarded – undo
319 319
 	 * @param bool $confirm     Delete confirmation.
320 320
 	 * @param bool $remove_data Records delete confirmation.
321 321
 	 */
322
-	do_action( 'give_pre_delete_donor', $donor_id, $confirm, $remove_data );
322
+	do_action('give_pre_delete_donor', $donor_id, $confirm, $remove_data);
323 323
 
324
-	if ( $donor->id > 0 ) {
324
+	if ($donor->id > 0) {
325 325
 
326
-		$payments_array = explode( ',', $donor->payment_ids );
327
-		$success        = Give()->donors->delete( $donor->id );
326
+		$payments_array = explode(',', $donor->payment_ids);
327
+		$success        = Give()->donors->delete($donor->id);
328 328
 
329
-		if ( $success ) {
329
+		if ($success) {
330 330
 
331
-			if ( $remove_data ) {
331
+			if ($remove_data) {
332 332
 
333 333
 				// Remove all donations, logs, etc
334
-				foreach ( $payments_array as $payment_id ) {
335
-					give_delete_donation( $payment_id );
334
+				foreach ($payments_array as $payment_id) {
335
+					give_delete_donation($payment_id);
336 336
 				}
337 337
 			} else {
338 338
 
339 339
 				// Just set the donations to customer_id of 0
340
-				foreach ( $payments_array as $payment_id ) {
341
-					give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 );
340
+				foreach ($payments_array as $payment_id) {
341
+					give_update_payment_meta($payment_id, '_give_payment_customer_id', 0);
342 342
 				}
343 343
 			}
344 344
 
345
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted' );
345
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted');
346 346
 
347 347
 		} else {
348 348
 
349
-			give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) );
350
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor_id );
349
+			give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give'));
350
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor_id);
351 351
 
352 352
 		}
353 353
 	} else {
354 354
 
355
-		give_set_error( 'give-donor-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) );
356
-		$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' );
355
+		give_set_error('give-donor-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give'));
356
+		$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors');
357 357
 
358 358
 	}
359 359
 
360
-	wp_redirect( $redirect );
360
+	wp_redirect($redirect);
361 361
 	exit;
362 362
 
363 363
 }
364 364
 
365
-add_action( 'give_delete-donor', 'give_donor_delete', 10, 1 );
365
+add_action('give_delete-donor', 'give_donor_delete', 10, 1);
366 366
 
367 367
 /**
368 368
  * Disconnect a user ID from a donor
@@ -373,17 +373,17 @@  discard block
 block discarded – undo
373 373
  *
374 374
  * @return bool|array        If the disconnect was successful.
375 375
  */
376
-function give_disconnect_donor_user_id( $args ) {
376
+function give_disconnect_donor_user_id($args) {
377 377
 
378
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
378
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
379 379
 
380
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
381
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
380
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
381
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
382 382
 			'response' => 403,
383
-		) );
383
+		));
384 384
 	}
385 385
 
386
-	if ( empty( $args ) ) {
386
+	if (empty($args)) {
387 387
 		return false;
388 388
 	}
389 389
 
@@ -391,14 +391,14 @@  discard block
 block discarded – undo
391 391
 
392 392
 	$nonce = $args['_wpnonce'];
393 393
 
394
-	if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) {
395
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
394
+	if ( ! wp_verify_nonce($nonce, 'edit-donor')) {
395
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
396 396
 			'response' => 400,
397
-		) );
397
+		));
398 398
 	}
399 399
 
400
-	$donor = new Give_Donor( $donor_id );
401
-	if ( empty( $donor->id ) ) {
400
+	$donor = new Give_Donor($donor_id);
401
+	if (empty($donor->id)) {
402 402
 		return false;
403 403
 	}
404 404
 
@@ -412,18 +412,18 @@  discard block
 block discarded – undo
412 412
 	 * @param int $donor_id The ID of the donor.
413 413
 	 * @param int $user_id  The ID of the user.
414 414
 	 */
415
-	do_action( 'give_pre_donor_disconnect_user_id', $donor_id, $user_id );
415
+	do_action('give_pre_donor_disconnect_user_id', $donor_id, $user_id);
416 416
 
417 417
 	$output     = array();
418 418
 	$donor_args = array(
419 419
 		'user_id' => 0,
420 420
 	);
421 421
 
422
-	if ( $donor->update( $donor_args ) ) {
422
+	if ($donor->update($donor_args)) {
423 423
 		global $wpdb;
424 424
 
425
-		if ( ! empty( $donor->payment_ids ) ) {
426
-			$wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )" );
425
+		if ( ! empty($donor->payment_ids)) {
426
+			$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )");
427 427
 		}
428 428
 
429 429
 		$output['success'] = true;
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 	} else {
432 432
 
433 433
 		$output['success'] = false;
434
-		give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) );
434
+		give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor.', 'give'));
435 435
 	}
436 436
 
437 437
 	/**
@@ -441,11 +441,11 @@  discard block
 block discarded – undo
441 441
 	 *
442 442
 	 * @param int $donor_id The ID of the donor.
443 443
 	 */
444
-	do_action( 'give_post_donor_disconnect_user_id', $donor_id );
444
+	do_action('give_post_donor_disconnect_user_id', $donor_id);
445 445
 
446
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
447
-		header( 'Content-Type: application/json' );
448
-		echo json_encode( $output );
446
+	if (defined('DOING_AJAX') && DOING_AJAX) {
447
+		header('Content-Type: application/json');
448
+		echo json_encode($output);
449 449
 		wp_die();
450 450
 	}
451 451
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 
454 454
 }
455 455
 
456
-add_action( 'give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1 );
456
+add_action('give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1);
457 457
 
458 458
 /**
459 459
  * Add an email address to the donor from within the admin and log a donor note.
@@ -464,82 +464,82 @@  discard block
 block discarded – undo
464 464
  *
465 465
  * @return mixed        If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string).
466 466
  */
467
-function give_add_donor_email( $args ) {
468
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
467
+function give_add_donor_email($args) {
468
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
469 469
 
470
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
471
-		wp_die( __( 'You do not have permission to edit this donor.', 'edit' ) );
470
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
471
+		wp_die(__('You do not have permission to edit this donor.', 'edit'));
472 472
 	}
473 473
 
474 474
 	$output = array();
475
-	if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) {
475
+	if (empty($args) || empty($args['email']) || empty($args['customer_id'])) {
476 476
 		$output['success'] = false;
477
-		if ( empty( $args['email'] ) ) {
478
-			$output['message'] = __( 'Email address is required.', 'give' );
479
-		} elseif ( empty( $args['customer_id'] ) ) {
480
-			$output['message'] = __( 'Donor ID is required.', 'give' );
477
+		if (empty($args['email'])) {
478
+			$output['message'] = __('Email address is required.', 'give');
479
+		} elseif (empty($args['customer_id'])) {
480
+			$output['message'] = __('Donor ID is required.', 'give');
481 481
 		} else {
482
-			$output['message'] = __( 'An error has occurred. Please try again.', 'give' );
482
+			$output['message'] = __('An error has occurred. Please try again.', 'give');
483 483
 		}
484
-	} elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) {
484
+	} elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) {
485 485
 		$output = array(
486 486
 			'success' => false,
487
-			'message' => esc_html__( 'Nonce verification failed.', 'give' ),
487
+			'message' => esc_html__('Nonce verification failed.', 'give'),
488 488
 		);
489
-	} elseif ( ! is_email( $args['email'] ) ) {
489
+	} elseif ( ! is_email($args['email'])) {
490 490
 		$output = array(
491 491
 			'success' => false,
492
-			'message' => esc_html__( 'Invalid email.', 'give' ),
492
+			'message' => esc_html__('Invalid email.', 'give'),
493 493
 		);
494 494
 	} else {
495
-		$email    = sanitize_email( $args['email'] );
495
+		$email    = sanitize_email($args['email']);
496 496
 		$donor_id = (int) $args['customer_id'];
497 497
 		$primary  = 'true' === $args['primary'] ? true : false;
498
-		$donor    = new Give_Donor( $donor_id );
499
-		if ( false === $donor->add_email( $email, $primary ) ) {
500
-			if ( in_array( $email, $donor->emails ) ) {
498
+		$donor    = new Give_Donor($donor_id);
499
+		if (false === $donor->add_email($email, $primary)) {
500
+			if (in_array($email, $donor->emails)) {
501 501
 				$output = array(
502 502
 					'success' => false,
503
-					'message' => __( 'Email already associated with this donor.', 'give' ),
503
+					'message' => __('Email already associated with this donor.', 'give'),
504 504
 				);
505 505
 			} else {
506 506
 				$output = array(
507 507
 					'success' => false,
508
-					'message' => __( 'Email address is already associated with another donor.', 'give' ),
508
+					'message' => __('Email address is already associated with another donor.', 'give'),
509 509
 				);
510 510
 			}
511 511
 		} else {
512
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&give-message=email-added' );
512
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&give-message=email-added');
513 513
 			$output   = array(
514 514
 				'success'  => true,
515
-				'message'  => __( 'Email successfully added to donor.', 'give' ),
515
+				'message'  => __('Email successfully added to donor.', 'give'),
516 516
 				'redirect' => $redirect,
517 517
 			);
518 518
 
519 519
 			$user       = wp_get_current_user();
520
-			$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
521
-			$donor_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login );
522
-			$donor->add_note( $donor_note );
520
+			$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
521
+			$donor_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login);
522
+			$donor->add_note($donor_note);
523 523
 
524
-			if ( $primary ) {
525
-				$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login );
526
-				$donor->add_note( $donor_note );
524
+			if ($primary) {
525
+				$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login);
526
+				$donor->add_note($donor_note);
527 527
 			}
528 528
 		}
529 529
 	}// End if().
530 530
 
531
-	do_action( 'give_post_add_donor_email', $donor_id, $args );
531
+	do_action('give_post_add_donor_email', $donor_id, $args);
532 532
 
533
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
534
-		header( 'Content-Type: application/json' );
535
-		echo json_encode( $output );
533
+	if (defined('DOING_AJAX') && DOING_AJAX) {
534
+		header('Content-Type: application/json');
535
+		echo json_encode($output);
536 536
 		wp_die();
537 537
 	}
538 538
 
539 539
 	return $output;
540 540
 }
541 541
 
542
-add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 );
542
+add_action('give_add_donor_email', 'give_add_donor_email', 10, 1);
543 543
 
544 544
 
545 545
 /**
@@ -549,39 +549,39 @@  discard block
 block discarded – undo
549 549
  * @return bool|null
550 550
  */
551 551
 function give_remove_donor_email() {
552
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
552
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
553 553
 		return false;
554 554
 	}
555
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
555
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
556 556
 		return false;
557 557
 	}
558
-	if ( empty( $_GET['_wpnonce'] ) ) {
558
+	if (empty($_GET['_wpnonce'])) {
559 559
 		return false;
560 560
 	}
561 561
 
562 562
 	$nonce = $_GET['_wpnonce'];
563
-	if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) {
564
-		wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array(
563
+	if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) {
564
+		wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array(
565 565
 			'response' => 403,
566
-		) );
566
+		));
567 567
 	}
568 568
 
569
-	$donor = new Give_Donor( $_GET['id'] );
570
-	if ( $donor->remove_email( $_GET['email'] ) ) {
571
-		$url        = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
569
+	$donor = new Give_Donor($_GET['id']);
570
+	if ($donor->remove_email($_GET['email'])) {
571
+		$url        = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
572 572
 		$user       = wp_get_current_user();
573
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
574
-		$donor_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login );
575
-		$donor->add_note( $donor_note );
573
+		$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
574
+		$donor_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login);
575
+		$donor->add_note($donor_note);
576 576
 	} else {
577
-		$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 ) );
577
+		$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));
578 578
 	}
579 579
 
580
-	wp_safe_redirect( $url );
580
+	wp_safe_redirect($url);
581 581
 	exit;
582 582
 }
583 583
 
584
-add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 );
584
+add_action('give_remove_donor_email', 'give_remove_donor_email', 10);
585 585
 
586 586
 
587 587
 /**
@@ -592,41 +592,41 @@  discard block
 block discarded – undo
592 592
  * @return bool|null
593 593
  */
594 594
 function give_set_donor_primary_email() {
595
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
595
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
596 596
 		return false;
597 597
 	}
598 598
 
599
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
599
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
600 600
 		return false;
601 601
 	}
602 602
 
603
-	if ( empty( $_GET['_wpnonce'] ) ) {
603
+	if (empty($_GET['_wpnonce'])) {
604 604
 		return false;
605 605
 	}
606 606
 
607 607
 	$nonce = $_GET['_wpnonce'];
608 608
 
609
-	if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) {
610
-		wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array(
609
+	if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) {
610
+		wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array(
611 611
 			'response' => 403,
612
-		) );
612
+		));
613 613
 	}
614 614
 
615
-	$donor = new Give_Donor( $_GET['id'] );
615
+	$donor = new Give_Donor($_GET['id']);
616 616
 
617
-	if ( $donor->set_primary_email( $_GET['email'] ) ) {
618
-		$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 ) );
617
+	if ($donor->set_primary_email($_GET['email'])) {
618
+		$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));
619 619
 		$user       = wp_get_current_user();
620
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' );
621
-		$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login );
620
+		$user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give');
621
+		$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $_GET['email'], $user_login);
622 622
 
623
-		$donor->add_note( $donor_note );
623
+		$donor->add_note($donor_note);
624 624
 	} else {
625
-		$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 ) );
625
+		$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));
626 626
 	}
627 627
 
628
-	wp_safe_redirect( $url );
628
+	wp_safe_redirect($url);
629 629
 	exit;
630 630
 }
631 631
 
632
-add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 );
632
+add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10);
Please login to merge, or discard this patch.
includes/api/class-give-api.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 *
217 217
 	 * @access public
218 218
 	 * @since  1.1
219
-	 * @return array
219
+	 * @return string
220 220
 	 */
221 221
 	public function get_versions() {
222 222
 		return $this->versions;
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	 * @uses   Give_API::invalid_key()
303 303
 	 * @uses   Give_API::invalid_auth()
304 304
 	 * @since  1.1
305
-	 * @return bool
305
+	 * @return false|null
306 306
 	 */
307 307
 	private function validate_request() {
308 308
 		global $wp_query;
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 	 *
695 695
 	 * @param array $args Arguments to override defaults
696 696
 	 *
697
-	 * @return array $dates
697
+	 * @return integer|null $dates
698 698
 	 */
699 699
 	public function get_dates( $args = array() ) {
700 700
 		$dates = array();
Please login to merge, or discard this patch.
Spacing   +512 added lines, -512 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -141,27 +141,27 @@  discard block
 block discarded – undo
141 141
 			'v1' => 'GIVE_API_V1',
142 142
 		);
143 143
 
144
-		foreach ( $this->get_versions() as $version => $class ) {
145
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php';
144
+		foreach ($this->get_versions() as $version => $class) {
145
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php';
146 146
 		}
147 147
 
148
-		add_action( 'init', array( $this, 'add_endpoint' ) );
149
-		add_action( 'wp', array( $this, 'process_query' ), - 1 );
150
-		add_filter( 'query_vars', array( $this, 'query_vars' ) );
151
-		add_action( 'show_user_profile', array( $this, 'user_key_field' ) );
152
-		add_action( 'edit_user_profile', array( $this, 'user_key_field' ) );
153
-		add_action( 'personal_options_update', array( $this, 'update_key' ) );
154
-		add_action( 'edit_user_profile_update', array( $this, 'update_key' ) );
155
-		add_action( 'give_process_api_key', array( $this, 'process_api_key' ) );
148
+		add_action('init', array($this, 'add_endpoint'));
149
+		add_action('wp', array($this, 'process_query'), - 1);
150
+		add_filter('query_vars', array($this, 'query_vars'));
151
+		add_action('show_user_profile', array($this, 'user_key_field'));
152
+		add_action('edit_user_profile', array($this, 'user_key_field'));
153
+		add_action('personal_options_update', array($this, 'update_key'));
154
+		add_action('edit_user_profile_update', array($this, 'update_key'));
155
+		add_action('give_process_api_key', array($this, 'process_api_key'));
156 156
 
157 157
 		// Setup a backwards compatibility check for user API Keys
158
-		add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 );
158
+		add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4);
159 159
 
160 160
 		// Determine if JSON_PRETTY_PRINT is available
161
-		$this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null;
161
+		$this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
162 162
 
163 163
 		// Allow API request logging to be turned off
164
-		$this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests );
164
+		$this->log_requests = apply_filters('give_api_log_requests', $this->log_requests);
165 165
 
166 166
 		// Setup Give_Payment_Stats instance
167 167
 		$this->stats = new Give_Payment_Stats();
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 	 *
178 178
 	 * @since  1.1
179 179
 	 */
180
-	public function add_endpoint( $rewrite_rules ) {
181
-		add_rewrite_endpoint( 'give-api', EP_ALL );
180
+	public function add_endpoint($rewrite_rules) {
181
+		add_rewrite_endpoint('give-api', EP_ALL);
182 182
 	}
183 183
 
184 184
 	/**
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 *
192 192
 	 * @return string[] $vars New query vars
193 193
 	 */
194
-	public function query_vars( $vars ) {
194
+	public function query_vars($vars) {
195 195
 
196 196
 		$vars[] = 'token';
197 197
 		$vars[] = 'key';
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	public function get_default_version() {
244 244
 
245
-		$version = get_option( 'give_default_api_version' );
245
+		$version = get_option('give_default_api_version');
246 246
 
247
-		if ( defined( 'GIVE_API_VERSION' ) ) {
247
+		if (defined('GIVE_API_VERSION')) {
248 248
 			$version = GIVE_API_VERSION;
249
-		} elseif ( ! $version ) {
249
+		} elseif ( ! $version) {
250 250
 			$version = 'v1';
251 251
 		}
252 252
 
@@ -267,14 +267,14 @@  discard block
 block discarded – undo
267 267
 
268 268
 		$version = $wp_query->query_vars['give-api'];
269 269
 
270
-		if ( strpos( $version, '/' ) ) {
270
+		if (strpos($version, '/')) {
271 271
 
272
-			$version = explode( '/', $version );
273
-			$version = strtolower( $version[0] );
272
+			$version = explode('/', $version);
273
+			$version = strtolower($version[0]);
274 274
 
275
-			$wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] );
275
+			$wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']);
276 276
 
277
-			if ( array_key_exists( $version, $this->versions ) ) {
277
+			if (array_key_exists($version, $this->versions)) {
278 278
 
279 279
 				$this->queried_version = $version;
280 280
 
@@ -310,26 +310,26 @@  discard block
 block discarded – undo
310 310
 		$this->override = false;
311 311
 
312 312
 		// Make sure we have both user and api key
313
-		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] !== 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) {
313
+		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] !== 'forms' || ! empty($wp_query->query_vars['token']))) {
314 314
 
315
-			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
315
+			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) {
316 316
 				$this->missing_auth();
317 317
 				return false;
318 318
 			}
319 319
 
320 320
 			// Retrieve the user by public API key and ensure they exist
321
-			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {
321
+			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) {
322 322
 
323 323
 				$this->invalid_key();
324 324
 				return false;
325 325
 
326 326
 			} else {
327 327
 
328
-				$token  = urldecode( $wp_query->query_vars['token'] );
329
-				$secret = $this->get_user_secret_key( $user );
330
-				$public = urldecode( $wp_query->query_vars['key'] );
328
+				$token  = urldecode($wp_query->query_vars['token']);
329
+				$secret = $this->get_user_secret_key($user);
330
+				$public = urldecode($wp_query->query_vars['key']);
331 331
 
332
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
332
+				if (hash_equals(md5($secret.$public), $token)) {
333 333
 					$this->is_valid_request = true;
334 334
 				} else {
335 335
 					$this->invalid_auth();
@@ -337,9 +337,9 @@  discard block
 block discarded – undo
337 337
 				}
338 338
 
339 339
 			}
340
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] === 'forms' ) {
340
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] === 'forms') {
341 341
 			$this->is_valid_request = true;
342
-			$wp_query->set( 'key', 'public' );
342
+			$wp_query->set('key', 'public');
343 343
 		}
344 344
 	}
345 345
 
@@ -355,25 +355,25 @@  discard block
 block discarded – undo
355 355
 	 *
356 356
 	 * @return bool if user ID is found, false otherwise
357 357
 	 */
358
-	public function get_user( $key = '' ) {
358
+	public function get_user($key = '') {
359 359
 		global $wpdb, $wp_query;
360 360
 
361
-		if ( empty( $key ) ) {
362
-			$key = urldecode( $wp_query->query_vars['key'] );
361
+		if (empty($key)) {
362
+			$key = urldecode($wp_query->query_vars['key']);
363 363
 		}
364 364
 
365
-		if ( empty( $key ) ) {
365
+		if (empty($key)) {
366 366
 			return false;
367 367
 		}
368 368
 
369
-		$user = Give_Cache::get( md5( 'give_api_user_' . $key ), true );
369
+		$user = Give_Cache::get(md5('give_api_user_'.$key), true);
370 370
 
371
-		if ( false === $user ) {
372
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
373
-			Give_Cache::set( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS, true );
371
+		if (false === $user) {
372
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
373
+			Give_Cache::set(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS, true);
374 374
 		}
375 375
 
376
-		if ( $user != null ) {
376
+		if ($user != null) {
377 377
 			$this->user_id = $user;
378 378
 
379 379
 			return $user;
@@ -389,19 +389,19 @@  discard block
 block discarded – undo
389 389
 	 *
390 390
 	 * @return mixed|null|string
391 391
 	 */
392
-	public function get_user_public_key( $user_id = 0 ) {
392
+	public function get_user_public_key($user_id = 0) {
393 393
 		global $wpdb;
394 394
 
395
-		if ( empty( $user_id ) ) {
395
+		if (empty($user_id)) {
396 396
 			return '';
397 397
 		}
398 398
 
399
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
400
-		$user_public_key = Give_Cache::get( $cache_key, true );
399
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
400
+		$user_public_key = Give_Cache::get($cache_key, true);
401 401
 
402
-		if ( empty( $user_public_key ) ) {
403
-			$user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) );
404
-			Give_Cache::set( $cache_key, $user_public_key, HOUR_IN_SECONDS, true );
402
+		if (empty($user_public_key)) {
403
+			$user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id));
404
+			Give_Cache::set($cache_key, $user_public_key, HOUR_IN_SECONDS, true);
405 405
 		}
406 406
 
407 407
 		return $user_public_key;
@@ -414,19 +414,19 @@  discard block
 block discarded – undo
414 414
 	 *
415 415
 	 * @return mixed|null|string
416 416
 	 */
417
-	public function get_user_secret_key( $user_id = 0 ) {
417
+	public function get_user_secret_key($user_id = 0) {
418 418
 		global $wpdb;
419 419
 
420
-		if ( empty( $user_id ) ) {
420
+		if (empty($user_id)) {
421 421
 			return '';
422 422
 		}
423 423
 
424
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
425
-		$user_secret_key = Give_Cache::get( $cache_key, true );
424
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
425
+		$user_secret_key = Give_Cache::get($cache_key, true);
426 426
 
427
-		if ( empty( $user_secret_key ) ) {
428
-			$user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) );
429
-			Give_Cache::set( $cache_key, $user_secret_key, HOUR_IN_SECONDS, true );
427
+		if (empty($user_secret_key)) {
428
+			$user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id));
429
+			Give_Cache::set($cache_key, $user_secret_key, HOUR_IN_SECONDS, true);
430 430
 		}
431 431
 
432 432
 		return $user_secret_key;
@@ -442,10 +442,10 @@  discard block
 block discarded – undo
442 442
 	 */
443 443
 	private function missing_auth() {
444 444
 		$error          = array();
445
-		$error['error'] = esc_html__( 'You must specify both a token and API key.', 'give' );
445
+		$error['error'] = esc_html__('You must specify both a token and API key.', 'give');
446 446
 
447 447
 		$this->data = $error;
448
-		$this->output( 401 );
448
+		$this->output(401);
449 449
 	}
450 450
 
451 451
 	/**
@@ -459,10 +459,10 @@  discard block
 block discarded – undo
459 459
 	 */
460 460
 	private function invalid_auth() {
461 461
 		$error          = array();
462
-		$error['error'] = esc_html__( 'Your request could not be authenticated.', 'give' );
462
+		$error['error'] = esc_html__('Your request could not be authenticated.', 'give');
463 463
 
464 464
 		$this->data = $error;
465
-		$this->output( 403 );
465
+		$this->output(403);
466 466
 	}
467 467
 
468 468
 	/**
@@ -476,10 +476,10 @@  discard block
 block discarded – undo
476 476
 	 */
477 477
 	private function invalid_key() {
478 478
 		$error          = array();
479
-		$error['error'] = esc_html__( 'Invalid API key.', 'give' );
479
+		$error['error'] = esc_html__('Invalid API key.', 'give');
480 480
 
481 481
 		$this->data = $error;
482
-		$this->output( 403 );
482
+		$this->output(403);
483 483
 	}
484 484
 
485 485
 	/**
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 	 */
493 493
 	private function invalid_version() {
494 494
 		$error          = array();
495
-		$error['error'] = esc_html__( 'Invalid API version.', 'give' );
495
+		$error['error'] = esc_html__('Invalid API version.', 'give');
496 496
 
497 497
 		$this->data = $error;
498
-		$this->output( 404 );
498
+		$this->output(404);
499 499
 	}
500 500
 
501 501
 	/**
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
 		global $wp_query;
512 512
 
513 513
 		// Start logging how long the request takes for logging
514
-		$before = microtime( true );
514
+		$before = microtime(true);
515 515
 
516 516
 		// Check for give-api var. Get out if not present
517
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
517
+		if (empty($wp_query->query_vars['give-api'])) {
518 518
 			return;
519 519
 		}
520 520
 
@@ -528,45 +528,45 @@  discard block
 block discarded – undo
528 528
 		$this->validate_request();
529 529
 
530 530
 		// Only proceed if no errors have been noted
531
-		if ( ! $this->is_valid_request ) {
531
+		if ( ! $this->is_valid_request) {
532 532
 			return;
533 533
 		}
534 534
 
535
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
536
-			define( 'GIVE_DOING_API', true );
535
+		if ( ! defined('GIVE_DOING_API')) {
536
+			define('GIVE_DOING_API', true);
537 537
 		}
538 538
 
539 539
 		$data         = array();
540 540
 		$this->routes = new $this->versions[$this->get_queried_version()];
541 541
 		$this->routes->validate_request();
542 542
 
543
-		switch ( $this->endpoint ) :
543
+		switch ($this->endpoint) :
544 544
 
545 545
 			case 'stats' :
546 546
 
547
-				$data = $this->routes->get_stats( array(
548
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
549
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
550
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
551
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
552
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
553
-				) );
547
+				$data = $this->routes->get_stats(array(
548
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
549
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
550
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
551
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
552
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
553
+				));
554 554
 
555 555
 				break;
556 556
 
557 557
 			case 'forms' :
558 558
 
559
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
559
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
560 560
 
561
-				$data = $this->routes->get_forms( $form );
561
+				$data = $this->routes->get_forms($form);
562 562
 
563 563
 				break;
564 564
 
565 565
 			case 'donors' :
566 566
 
567
-				$donor = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
567
+				$donor = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
568 568
 
569
-				$data = $this->routes->get_donors( $donor );
569
+				$data = $this->routes->get_donors($donor);
570 570
 
571 571
 				break;
572 572
 
@@ -579,25 +579,25 @@  discard block
 block discarded – undo
579 579
 				 * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
580 580
 				 * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
581 581
 				 */
582
-				$data = $this->routes->get_recent_donations( array(
583
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
584
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
585
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
586
-				) );
582
+				$data = $this->routes->get_recent_donations(array(
583
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
584
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
585
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
586
+				));
587 587
 
588 588
 				break;
589 589
 
590 590
 		endswitch;
591 591
 
592 592
 		// Allow extensions to setup their own return data
593
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
593
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
594 594
 
595
-		$after                       = microtime( true );
596
-		$request_time                = ( $after - $before );
595
+		$after                       = microtime(true);
596
+		$request_time                = ($after - $before);
597 597
 		$this->data['request_speed'] = $request_time;
598 598
 
599 599
 		// Log this API request, if enabled. We log it here because we have access to errors.
600
-		$this->log_request( $this->data );
600
+		$this->log_request($this->data);
601 601
 
602 602
 		// Send out data to the output function
603 603
 		$this->output();
@@ -627,25 +627,25 @@  discard block
 block discarded – undo
627 627
 		global $wp_query;
628 628
 
629 629
 		// Whitelist our query options
630
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
630
+		$accepted = apply_filters('give_api_valid_query_modes', array(
631 631
 			'stats',
632 632
 			'forms',
633 633
 			'donors',
634 634
 			'donations',
635
-		) );
635
+		));
636 636
 
637
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
638
-		$query = str_replace( $this->queried_version . '/', '', $query );
637
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
638
+		$query = str_replace($this->queried_version.'/', '', $query);
639 639
 
640 640
 		$error = array();
641 641
 
642 642
 		// Make sure our query is valid
643
-		if ( ! in_array( $query, $accepted ) ) {
644
-			$error['error'] = esc_html__( 'Invalid query.', 'give' );
643
+		if ( ! in_array($query, $accepted)) {
644
+			$error['error'] = esc_html__('Invalid query.', 'give');
645 645
 
646 646
 			$this->data = $error;
647 647
 			// 400 is Bad Request
648
-			$this->output( 400 );
648
+			$this->output(400);
649 649
 		}
650 650
 
651 651
 		$this->endpoint = $query;
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	public function get_paged() {
663 663
 		global $wp_query;
664 664
 
665
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
665
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
666 666
 	}
667 667
 
668 668
 
@@ -677,13 +677,13 @@  discard block
 block discarded – undo
677 677
 	public function per_page() {
678 678
 		global $wp_query;
679 679
 
680
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
680
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
681 681
 
682
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
682
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
683 683
 			$per_page = 99999999;
684 684
 		} // End if().
685 685
 
686
-		return apply_filters( 'give_api_results_per_page', $per_page );
686
+		return apply_filters('give_api_results_per_page', $per_page);
687 687
 	}
688 688
 
689 689
 	/**
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 	 *
697 697
 	 * @return array $dates
698 698
 	 */
699
-	public function get_dates( $args = array() ) {
699
+	public function get_dates($args = array()) {
700 700
 		$dates = array();
701 701
 
702 702
 		$defaults = array(
@@ -707,60 +707,60 @@  discard block
 block discarded – undo
707 707
 			'enddate'   => null,
708 708
 		);
709 709
 
710
-		$args = wp_parse_args( $args, $defaults );
710
+		$args = wp_parse_args($args, $defaults);
711 711
 
712
-		$current_time = current_time( 'timestamp' );
712
+		$current_time = current_time('timestamp');
713 713
 
714
-		if ( 'range' === $args['date'] ) {
715
-			$startdate          = strtotime( $args['startdate'] );
716
-			$enddate            = strtotime( $args['enddate'] );
717
-			$dates['day_start'] = date( 'd', $startdate );
718
-			$dates['day_end']   = date( 'd', $enddate );
719
-			$dates['m_start']   = date( 'n', $startdate );
720
-			$dates['m_end']     = date( 'n', $enddate );
721
-			$dates['year']      = date( 'Y', $startdate );
722
-			$dates['year_end']  = date( 'Y', $enddate );
714
+		if ('range' === $args['date']) {
715
+			$startdate          = strtotime($args['startdate']);
716
+			$enddate            = strtotime($args['enddate']);
717
+			$dates['day_start'] = date('d', $startdate);
718
+			$dates['day_end']   = date('d', $enddate);
719
+			$dates['m_start']   = date('n', $startdate);
720
+			$dates['m_end']     = date('n', $enddate);
721
+			$dates['year']      = date('Y', $startdate);
722
+			$dates['year_end']  = date('Y', $enddate);
723 723
 		} else {
724 724
 			// Modify dates based on predefined ranges
725
-			switch ( $args['date'] ) :
725
+			switch ($args['date']) :
726 726
 
727 727
 				case 'this_month' :
728 728
 					$dates['day']     = null;
729
-					$dates['m_start'] = date( 'n', $current_time );
730
-					$dates['m_end']   = date( 'n', $current_time );
731
-					$dates['year']    = date( 'Y', $current_time );
729
+					$dates['m_start'] = date('n', $current_time);
730
+					$dates['m_end']   = date('n', $current_time);
731
+					$dates['year']    = date('Y', $current_time);
732 732
 					break;
733 733
 
734 734
 				case 'last_month' :
735 735
 					$dates['day']     = null;
736
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
736
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
737 737
 					$dates['m_end']   = $dates['m_start'];
738
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
738
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
739 739
 					break;
740 740
 
741 741
 				case 'today' :
742
-					$dates['day']     = date( 'd', $current_time );
743
-					$dates['m_start'] = date( 'n', $current_time );
744
-					$dates['m_end']   = date( 'n', $current_time );
745
-					$dates['year']    = date( 'Y', $current_time );
742
+					$dates['day']     = date('d', $current_time);
743
+					$dates['m_start'] = date('n', $current_time);
744
+					$dates['m_end']   = date('n', $current_time);
745
+					$dates['year']    = date('Y', $current_time);
746 746
 					break;
747 747
 
748 748
 				case 'yesterday' :
749 749
 
750
-					$year  = date( 'Y', $current_time );
751
-					$month = date( 'n', $current_time );
752
-					$day   = date( 'd', $current_time );
750
+					$year  = date('Y', $current_time);
751
+					$month = date('n', $current_time);
752
+					$day   = date('d', $current_time);
753 753
 
754
-					if ( $month == 1 && $day == 1 ) {
754
+					if ($month == 1 && $day == 1) {
755 755
 
756
-						$year  -= 1;
756
+						$year -= 1;
757 757
 						$month = 12;
758
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
758
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
759 759
 
760
-					} elseif ( $month > 1 && $day == 1 ) {
760
+					} elseif ($month > 1 && $day == 1) {
761 761
 
762 762
 						$month -= 1;
763
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
763
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
764 764
 
765 765
 					} else {
766 766
 
@@ -776,65 +776,65 @@  discard block
 block discarded – undo
776 776
 					break;
777 777
 
778 778
 				case 'this_quarter' :
779
-					$month_now = date( 'n', $current_time );
779
+					$month_now = date('n', $current_time);
780 780
 
781 781
 					$dates['day'] = null;
782 782
 
783
-					if ( $month_now <= 3 ) {
783
+					if ($month_now <= 3) {
784 784
 
785 785
 						$dates['m_start'] = 1;
786 786
 						$dates['m_end']   = 3;
787
-						$dates['year']    = date( 'Y', $current_time );
787
+						$dates['year']    = date('Y', $current_time);
788 788
 
789
-					} elseif ( $month_now <= 6 ) {
789
+					} elseif ($month_now <= 6) {
790 790
 
791 791
 						$dates['m_start'] = 4;
792 792
 						$dates['m_end']   = 6;
793
-						$dates['year']    = date( 'Y', $current_time );
793
+						$dates['year']    = date('Y', $current_time);
794 794
 
795
-					} elseif ( $month_now <= 9 ) {
795
+					} elseif ($month_now <= 9) {
796 796
 
797 797
 						$dates['m_start'] = 7;
798 798
 						$dates['m_end']   = 9;
799
-						$dates['year']    = date( 'Y', $current_time );
799
+						$dates['year']    = date('Y', $current_time);
800 800
 
801 801
 					} else {
802 802
 
803 803
 						$dates['m_start'] = 10;
804 804
 						$dates['m_end']   = 12;
805
-						$dates['year']    = date( 'Y', $current_time );
805
+						$dates['year']    = date('Y', $current_time);
806 806
 
807 807
 					}
808 808
 					break;
809 809
 
810 810
 				case 'last_quarter' :
811
-					$month_now = date( 'n', $current_time );
811
+					$month_now = date('n', $current_time);
812 812
 
813 813
 					$dates['day'] = null;
814 814
 
815
-					if ( $month_now <= 3 ) {
815
+					if ($month_now <= 3) {
816 816
 
817 817
 						$dates['m_start'] = 10;
818 818
 						$dates['m_end']   = 12;
819
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
819
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
820 820
 
821
-					} elseif ( $month_now <= 6 ) {
821
+					} elseif ($month_now <= 6) {
822 822
 
823 823
 						$dates['m_start'] = 1;
824 824
 						$dates['m_end']   = 3;
825
-						$dates['year']    = date( 'Y', $current_time );
825
+						$dates['year']    = date('Y', $current_time);
826 826
 
827
-					} elseif ( $month_now <= 9 ) {
827
+					} elseif ($month_now <= 9) {
828 828
 
829 829
 						$dates['m_start'] = 4;
830 830
 						$dates['m_end']   = 6;
831
-						$dates['year']    = date( 'Y', $current_time );
831
+						$dates['year']    = date('Y', $current_time);
832 832
 
833 833
 					} else {
834 834
 
835 835
 						$dates['m_start'] = 7;
836 836
 						$dates['m_end']   = 9;
837
-						$dates['year']    = date( 'Y', $current_time );
837
+						$dates['year']    = date('Y', $current_time);
838 838
 
839 839
 					}
840 840
 					break;
@@ -843,14 +843,14 @@  discard block
 block discarded – undo
843 843
 					$dates['day']     = null;
844 844
 					$dates['m_start'] = null;
845 845
 					$dates['m_end']   = null;
846
-					$dates['year']    = date( 'Y', $current_time );
846
+					$dates['year']    = date('Y', $current_time);
847 847
 					break;
848 848
 
849 849
 				case 'last_year' :
850 850
 					$dates['day']     = null;
851 851
 					$dates['m_start'] = null;
852 852
 					$dates['m_end']   = null;
853
-					$dates['year']    = date( 'Y', $current_time ) - 1;
853
+					$dates['year']    = date('Y', $current_time) - 1;
854 854
 					break;
855 855
 
856 856
 			endswitch;
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 		 *
864 864
 		 * @param array $dates The dates used for retrieving earnings.
865 865
 		 */
866
-		return apply_filters( 'give_api_stat_dates', $dates );
866
+		return apply_filters('give_api_stat_dates', $dates);
867 867
 	}
868 868
 
869 869
 	/**
@@ -877,78 +877,78 @@  discard block
 block discarded – undo
877 877
 	 *
878 878
 	 * @return array $donors Multidimensional array of the donors.
879 879
 	 */
880
-	public function get_donors( $donor = null ) {
880
+	public function get_donors($donor = null) {
881 881
 
882 882
 		$donors = array();
883 883
 		$error  = array();
884
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
884
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
885 885
 			return $donors;
886 886
 		}
887 887
 
888 888
 		$paged    = $this->get_paged();
889 889
 		$per_page = $this->per_page();
890
-		$offset   = $per_page * ( $paged - 1 );
890
+		$offset   = $per_page * ($paged - 1);
891 891
 
892
-		if ( is_numeric( $donor ) ) {
892
+		if (is_numeric($donor)) {
893 893
 			$field = 'id';
894 894
 		} else {
895 895
 			$field = 'email';
896 896
 		}
897 897
 
898
-		$donor_query = Give()->donors->get_donors( array(
898
+		$donor_query = Give()->donors->get_donors(array(
899 899
 			'number' => $per_page,
900 900
 			'offset' => $offset,
901 901
 			$field   => $donor,
902
-		) );
902
+		));
903 903
 		$donor_count = 0;
904 904
 
905
-		if ( $donor_query ) {
905
+		if ($donor_query) {
906 906
 
907
-			foreach ( $donor_query as $donor_obj ) {
907
+			foreach ($donor_query as $donor_obj) {
908 908
 
909
-				$names      = explode( ' ', $donor_obj->name );
910
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
909
+				$names      = explode(' ', $donor_obj->name);
910
+				$first_name = ! empty($names[0]) ? $names[0] : '';
911 911
 				$last_name  = '';
912
-				if ( ! empty( $names[1] ) ) {
913
-					unset( $names[0] );
914
-					$last_name = implode( ' ', $names );
912
+				if ( ! empty($names[1])) {
913
+					unset($names[0]);
914
+					$last_name = implode(' ', $names);
915 915
 				}
916 916
 
917
-				$donors['donors'][ $donor_count ]['info']['user_id']      = '';
918
-				$donors['donors'][ $donor_count ]['info']['username']     = '';
919
-				$donors['donors'][ $donor_count ]['info']['display_name'] = '';
920
-				$donors['donors'][ $donor_count ]['info']['donor_id']     = $donor_obj->id;
921
-				$donors['donors'][ $donor_count ]['info']['first_name']   = $first_name;
922
-				$donors['donors'][ $donor_count ]['info']['last_name']    = $last_name;
923
-				$donors['donors'][ $donor_count ]['info']['email']        = $donor_obj->email;
917
+				$donors['donors'][$donor_count]['info']['user_id']      = '';
918
+				$donors['donors'][$donor_count]['info']['username']     = '';
919
+				$donors['donors'][$donor_count]['info']['display_name'] = '';
920
+				$donors['donors'][$donor_count]['info']['donor_id']     = $donor_obj->id;
921
+				$donors['donors'][$donor_count]['info']['first_name']   = $first_name;
922
+				$donors['donors'][$donor_count]['info']['last_name']    = $last_name;
923
+				$donors['donors'][$donor_count]['info']['email']        = $donor_obj->email;
924 924
 
925
-				if ( ! empty( $donor_obj->user_id ) ) {
925
+				if ( ! empty($donor_obj->user_id)) {
926 926
 
927
-					$user_data = get_userdata( $donor_obj->user_id );
927
+					$user_data = get_userdata($donor_obj->user_id);
928 928
 
929 929
 					// Donor with registered account.
930
-					$donors['donors'][ $donor_count ]['info']['user_id']      = $donor_obj->user_id;
931
-					$donors['donors'][ $donor_count ]['info']['username']     = $user_data->user_login;
932
-					$donors['donors'][ $donor_count ]['info']['display_name'] = $user_data->display_name;
930
+					$donors['donors'][$donor_count]['info']['user_id']      = $donor_obj->user_id;
931
+					$donors['donors'][$donor_count]['info']['username']     = $user_data->user_login;
932
+					$donors['donors'][$donor_count]['info']['display_name'] = $user_data->display_name;
933 933
 
934 934
 				}
935 935
 
936
-				$donors['donors'][ $donor_count ]['stats']['total_donations'] = $donor_obj->purchase_count;
937
-				$donors['donors'][ $donor_count ]['stats']['total_spent']     = $donor_obj->purchase_value;
936
+				$donors['donors'][$donor_count]['stats']['total_donations'] = $donor_obj->purchase_count;
937
+				$donors['donors'][$donor_count]['stats']['total_spent']     = $donor_obj->purchase_value;
938 938
 
939
-				$donor_count ++;
939
+				$donor_count++;
940 940
 
941 941
 			}
942
-		} elseif ( $donor ) {
942
+		} elseif ($donor) {
943 943
 
944 944
 			$error['error'] = sprintf( /* translators: %s: donor */
945
-				esc_html__( 'Donor %s not found.', 'give' ), $donor );
945
+				esc_html__('Donor %s not found.', 'give'), $donor );
946 946
 
947 947
 			return $error;
948 948
 
949 949
 		} else {
950 950
 
951
-			$error['error'] = esc_html__( 'No donors found.', 'give' );
951
+			$error['error'] = esc_html__('No donors found.', 'give');
952 952
 
953 953
 			return $error;
954 954
 
@@ -967,37 +967,37 @@  discard block
 block discarded – undo
967 967
 	 *
968 968
 	 * @return array $donors Multidimensional array of the forms.
969 969
 	 */
970
-	public function get_forms( $form = null ) {
970
+	public function get_forms($form = null) {
971 971
 
972 972
 		$forms = array();
973 973
 		$error = array();
974 974
 
975
-		if ( $form == null ) {
975
+		if ($form == null) {
976 976
 			$forms['forms'] = array();
977 977
 
978
-			$form_list = get_posts( array(
978
+			$form_list = get_posts(array(
979 979
 				'post_type'        => 'give_forms',
980 980
 				'posts_per_page'   => $this->per_page(),
981 981
 				'suppress_filters' => true,
982 982
 				'paged'            => $this->get_paged(),
983
-			) );
983
+			));
984 984
 
985
-			if ( $form_list ) {
985
+			if ($form_list) {
986 986
 				$i = 0;
987
-				foreach ( $form_list as $form_info ) {
988
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
989
-					$i ++;
987
+				foreach ($form_list as $form_info) {
988
+					$forms['forms'][$i] = $this->get_form_data($form_info);
989
+					$i++;
990 990
 				}
991 991
 			}
992 992
 		} else {
993
-			if ( get_post_type( $form ) == 'give_forms' ) {
994
-				$form_info = get_post( $form );
993
+			if (get_post_type($form) == 'give_forms') {
994
+				$form_info = get_post($form);
995 995
 
996
-				$forms['forms'][0] = $this->get_form_data( $form_info );
996
+				$forms['forms'][0] = $this->get_form_data($form_info);
997 997
 
998 998
 			} else {
999 999
 				$error['error'] = sprintf( /* translators: %s: form */
1000
-					esc_html__( 'Form %s not found.', 'give' ), $form );
1000
+					esc_html__('Form %s not found.', 'give'), $form );
1001 1001
 
1002 1002
 				return $error;
1003 1003
 			}
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 	 *
1016 1016
 	 * @return array                Array of post data to return back in the API.
1017 1017
 	 */
1018
-	private function get_form_data( $form_info ) {
1018
+	private function get_form_data($form_info) {
1019 1019
 
1020 1020
 		$form = array();
1021 1021
 
@@ -1025,60 +1025,60 @@  discard block
 block discarded – undo
1025 1025
 		$form['info']['create_date']   = $form_info->post_date;
1026 1026
 		$form['info']['modified_date'] = $form_info->post_modified;
1027 1027
 		$form['info']['status']        = $form_info->post_status;
1028
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1029
-		$form['info']['content']       = give_get_meta( $form_info->ID, '_give_form_content', true );
1030
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
1028
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1029
+		$form['info']['content']       = give_get_meta($form_info->ID, '_give_form_content', true);
1030
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1031 1031
 
1032
-		if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) {
1033
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1034
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1032
+		if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) {
1033
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1034
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1035 1035
 		}
1036
-		if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) {
1037
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1036
+		if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) {
1037
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1038 1038
 		}
1039 1039
 
1040 1040
 		// Check whether any goal is to be achieved for the donation form.
1041
-		$goal_option = give_get_meta( $form_info->ID, '_give_goal_option', true );
1042
-		$goal_amount = give_get_meta( $form_info->ID, '_give_set_goal', true );
1043
-		if ( give_is_setting_enabled( $goal_option ) && $goal_amount ) {
1044
-			$total_income = give_get_form_earnings_stats( $form_info->ID );
1045
-			$goal_percentage_completed = ( $total_income < $goal_amount ) ? round( ( $total_income / $goal_amount ) * 100, 2 ) : 100;
1046
-			$form['goal']['amount']               = isset( $goal_amount ) ? $goal_amount : '';
1047
-			$form['goal']['percentage_completed'] = isset( $goal_percentage_completed ) ? $goal_percentage_completed : '';
1041
+		$goal_option = give_get_meta($form_info->ID, '_give_goal_option', true);
1042
+		$goal_amount = give_get_meta($form_info->ID, '_give_set_goal', true);
1043
+		if (give_is_setting_enabled($goal_option) && $goal_amount) {
1044
+			$total_income = give_get_form_earnings_stats($form_info->ID);
1045
+			$goal_percentage_completed = ($total_income < $goal_amount) ? round(($total_income / $goal_amount) * 100, 2) : 100;
1046
+			$form['goal']['amount']               = isset($goal_amount) ? $goal_amount : '';
1047
+			$form['goal']['percentage_completed'] = isset($goal_percentage_completed) ? $goal_percentage_completed : '';
1048 1048
 		}
1049 1049
 
1050
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1051
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1052
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1053
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1054
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1050
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1051
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1052
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1053
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1054
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1055 1055
 		}
1056 1056
 
1057 1057
 		$counter = 0;
1058
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1059
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1060
-				$counter ++;
1058
+		if (give_has_variable_prices($form_info->ID)) {
1059
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1060
+				$counter++;
1061 1061
 				// multi-level item
1062
-				$level                                     = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1063
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1062
+				$level                                     = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1063
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1064 1064
 
1065 1065
 			}
1066 1066
 		} else {
1067
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1067
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1068 1068
 		}
1069 1069
 
1070
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1070
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1071 1071
 
1072 1072
 			/**
1073 1073
 			 * Fires when generating API sensitive data.
1074 1074
 			 *
1075 1075
 			 * @since 1.1
1076 1076
 			 */
1077
-			do_action( 'give_api_sensitive_data' );
1077
+			do_action('give_api_sensitive_data');
1078 1078
 
1079 1079
 		}
1080 1080
 
1081
-		return apply_filters( 'give_api_forms_form', $form );
1081
+		return apply_filters('give_api_forms_form', $form);
1082 1082
 
1083 1083
 	}
1084 1084
 
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
 	 *
1094 1094
 	 * @return array
1095 1095
 	 */
1096
-	public function get_stats( $args = array() ) {
1096
+	public function get_stats($args = array()) {
1097 1097
 		$defaults = array(
1098 1098
 			'type'      => null,
1099 1099
 			'form'      => null,
@@ -1102,9 +1102,9 @@  discard block
 block discarded – undo
1102 1102
 			'enddate'   => null,
1103 1103
 		);
1104 1104
 
1105
-		$args = wp_parse_args( $args, $defaults );
1105
+		$args = wp_parse_args($args, $defaults);
1106 1106
 
1107
-		$dates = $this->get_dates( $args );
1107
+		$dates = $this->get_dates($args);
1108 1108
 
1109 1109
 		$stats    = array();
1110 1110
 		$earnings = array(
@@ -1115,40 +1115,40 @@  discard block
 block discarded – undo
1115 1115
 		);
1116 1116
 		$error    = array();
1117 1117
 
1118
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1118
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1119 1119
 			return $stats;
1120 1120
 		}
1121 1121
 
1122
-		if ( $args['type'] == 'donations' ) {
1122
+		if ($args['type'] == 'donations') {
1123 1123
 
1124
-			if ( $args['form'] == null ) {
1125
-				if ( $args['date'] == null ) {
1124
+			if ($args['form'] == null) {
1125
+				if ($args['date'] == null) {
1126 1126
 					$sales = $this->get_default_sales_stats();
1127
-				} elseif ( $args['date'] === 'range' ) {
1127
+				} elseif ($args['date'] === 'range') {
1128 1128
 					// Return donations for a date range.
1129 1129
 					// Ensure the end date is later than the start date.
1130
-					if ( $args['enddate'] < $args['startdate'] ) {
1131
-						$error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' );
1130
+					if ($args['enddate'] < $args['startdate']) {
1131
+						$error['error'] = esc_html__('The end date must be later than the start date.', 'give');
1132 1132
 					}
1133 1133
 
1134 1134
 					// Ensure both the start and end date are specified
1135
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1136
-						$error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' );
1135
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1136
+						$error['error'] = esc_html__('Invalid or no date range specified.', 'give');
1137 1137
 					}
1138 1138
 
1139 1139
 					$total = 0;
1140 1140
 
1141 1141
 					// Loop through the years
1142 1142
 					$y = $dates['year'];
1143
-					while ( $y <= $dates['year_end'] ) :
1143
+					while ($y <= $dates['year_end']) :
1144 1144
 
1145
-						if ( $dates['year'] == $dates['year_end'] ) {
1145
+						if ($dates['year'] == $dates['year_end']) {
1146 1146
 							$month_start = $dates['m_start'];
1147 1147
 							$month_end   = $dates['m_end'];
1148
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1148
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1149 1149
 							$month_start = $dates['m_start'];
1150 1150
 							$month_end   = 12;
1151
-						} elseif ( $y == $dates['year_end'] ) {
1151
+						} elseif ($y == $dates['year_end']) {
1152 1152
 							$month_start = 1;
1153 1153
 							$month_end   = $dates['m_end'];
1154 1154
 						} else {
@@ -1157,116 +1157,116 @@  discard block
 block discarded – undo
1157 1157
 						}
1158 1158
 
1159 1159
 						$i = $month_start;
1160
-						while ( $i <= $month_end ) :
1160
+						while ($i <= $month_end) :
1161 1161
 
1162
-							if ( $i == $dates['m_start'] ) {
1162
+							if ($i == $dates['m_start']) {
1163 1163
 								$d = $dates['day_start'];
1164 1164
 							} else {
1165 1165
 								$d = 1;
1166 1166
 							}
1167 1167
 
1168
-							if ( $i == $dates['m_end'] ) {
1168
+							if ($i == $dates['m_end']) {
1169 1169
 								$num_of_days = $dates['day_end'];
1170 1170
 							} else {
1171
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1171
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1172 1172
 							}
1173 1173
 
1174
-							while ( $d <= $num_of_days ) :
1175
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1176
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1177
-								if ( ! isset( $sales['sales'][ $date_key ] ) ) {
1178
-									$sales['sales'][ $date_key ] = 0;
1174
+							while ($d <= $num_of_days) :
1175
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1176
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1177
+								if ( ! isset($sales['sales'][$date_key])) {
1178
+									$sales['sales'][$date_key] = 0;
1179 1179
 								}
1180
-								$sales['sales'][ $date_key ] += $sale_count;
1180
+								$sales['sales'][$date_key] += $sale_count;
1181 1181
 								$total                       += $sale_count;
1182
-								$d ++;
1182
+								$d++;
1183 1183
 							endwhile;
1184
-							$i ++;
1184
+							$i++;
1185 1185
 						endwhile;
1186 1186
 
1187
-						$y ++;
1187
+						$y++;
1188 1188
 					endwhile;
1189 1189
 
1190 1190
 					$sales['totals'] = $total;
1191 1191
 				} else {
1192
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1192
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1193 1193
 						$sales_count = 0;
1194 1194
 
1195 1195
 						// Loop through the months
1196 1196
 						$month = $dates['m_start'];
1197 1197
 
1198
-						while ( $month <= $dates['m_end'] ) :
1199
-							$sales_count += give_get_sales_by_date( null, $month, $dates['year'] );
1200
-							$month ++;
1198
+						while ($month <= $dates['m_end']) :
1199
+							$sales_count += give_get_sales_by_date(null, $month, $dates['year']);
1200
+							$month++;
1201 1201
 						endwhile;
1202 1202
 
1203
-						$sales['donations'][ $args['date'] ] = $sales_count;
1203
+						$sales['donations'][$args['date']] = $sales_count;
1204 1204
 					} else {
1205
-						$sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1205
+						$sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1206 1206
 					}
1207 1207
 				}// End if().
1208
-			} elseif ( $args['form'] == 'all' ) {
1209
-				$forms = get_posts( array(
1208
+			} elseif ($args['form'] == 'all') {
1209
+				$forms = get_posts(array(
1210 1210
 					'post_type' => 'give_forms',
1211 1211
 					'nopaging'  => true,
1212
-				) );
1213
-				$i     = 0;
1214
-				foreach ( $forms as $form_info ) {
1215
-					$sales['donations'][ $i ] = array(
1216
-						$form_info->post_name => give_get_form_sales_stats( $form_info->ID ),
1212
+				));
1213
+				$i = 0;
1214
+				foreach ($forms as $form_info) {
1215
+					$sales['donations'][$i] = array(
1216
+						$form_info->post_name => give_get_form_sales_stats($form_info->ID),
1217 1217
 					);
1218
-					$i ++;
1218
+					$i++;
1219 1219
 				}
1220 1220
 			} else {
1221
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1222
-					$form_info             = get_post( $args['form'] );
1221
+				if (get_post_type($args['form']) == 'give_forms') {
1222
+					$form_info             = get_post($args['form']);
1223 1223
 					$sales['donations'][0] = array(
1224
-						$form_info->post_name => give_get_form_sales_stats( $args['form'] ),
1224
+						$form_info->post_name => give_get_form_sales_stats($args['form']),
1225 1225
 					);
1226 1226
 				} else {
1227 1227
 					$error['error'] = sprintf( /* translators: %s: form */
1228
-						esc_html__( 'Form %s not found.', 'give' ), $args['form'] );
1228
+						esc_html__('Form %s not found.', 'give'), $args['form'] );
1229 1229
 				}
1230 1230
 			}// End if().
1231 1231
 
1232
-			if ( ! empty( $error ) ) {
1232
+			if ( ! empty($error)) {
1233 1233
 				return $error;
1234 1234
 			}
1235 1235
 
1236 1236
 			return $sales;
1237 1237
 
1238
-		} elseif ( $args['type'] == 'earnings' ) {
1239
-			if ( $args['form'] == null ) {
1240
-				if ( $args['date'] == null ) {
1238
+		} elseif ($args['type'] == 'earnings') {
1239
+			if ($args['form'] == null) {
1240
+				if ($args['date'] == null) {
1241 1241
 					$earnings = $this->get_default_earnings_stats();
1242
-				} elseif ( $args['date'] === 'range' ) {
1242
+				} elseif ($args['date'] === 'range') {
1243 1243
 					// Return sales for a date range
1244 1244
 					// Ensure the end date is later than the start date
1245
-					if ( $args['enddate'] < $args['startdate'] ) {
1246
-						$error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' );
1245
+					if ($args['enddate'] < $args['startdate']) {
1246
+						$error['error'] = esc_html__('The end date must be later than the start date.', 'give');
1247 1247
 					}
1248 1248
 
1249 1249
 					// Ensure both the start and end date are specified
1250
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1251
-						$error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' );
1250
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1251
+						$error['error'] = esc_html__('Invalid or no date range specified.', 'give');
1252 1252
 					}
1253 1253
 
1254 1254
 					$total = (float) 0.00;
1255 1255
 
1256 1256
 					// Loop through the years
1257 1257
 					$y = $dates['year'];
1258
-					if ( ! isset( $earnings['earnings'] ) ) {
1258
+					if ( ! isset($earnings['earnings'])) {
1259 1259
 						$earnings['earnings'] = array();
1260 1260
 					}
1261
-					while ( $y <= $dates['year_end'] ) :
1261
+					while ($y <= $dates['year_end']) :
1262 1262
 
1263
-						if ( $dates['year'] == $dates['year_end'] ) {
1263
+						if ($dates['year'] == $dates['year_end']) {
1264 1264
 							$month_start = $dates['m_start'];
1265 1265
 							$month_end   = $dates['m_end'];
1266
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1266
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1267 1267
 							$month_start = $dates['m_start'];
1268 1268
 							$month_end   = 12;
1269
-						} elseif ( $y == $dates['year_end'] ) {
1269
+						} elseif ($y == $dates['year_end']) {
1270 1270
 							$month_start = 1;
1271 1271
 							$month_end   = $dates['m_end'];
1272 1272
 						} else {
@@ -1275,94 +1275,94 @@  discard block
 block discarded – undo
1275 1275
 						}
1276 1276
 
1277 1277
 						$i = $month_start;
1278
-						while ( $i <= $month_end ) :
1278
+						while ($i <= $month_end) :
1279 1279
 
1280
-							if ( $i == $dates['m_start'] ) {
1280
+							if ($i == $dates['m_start']) {
1281 1281
 								$d = $dates['day_start'];
1282 1282
 							} else {
1283 1283
 								$d = 1;
1284 1284
 							}
1285 1285
 
1286
-							if ( $i == $dates['m_end'] ) {
1286
+							if ($i == $dates['m_end']) {
1287 1287
 								$num_of_days = $dates['day_end'];
1288 1288
 							} else {
1289
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1289
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1290 1290
 							}
1291 1291
 
1292
-							while ( $d <= $num_of_days ) :
1293
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1294
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1295
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1296
-									$earnings['earnings'][ $date_key ] = 0;
1292
+							while ($d <= $num_of_days) :
1293
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1294
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1295
+								if ( ! isset($earnings['earnings'][$date_key])) {
1296
+									$earnings['earnings'][$date_key] = 0;
1297 1297
 								}
1298
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1298
+								$earnings['earnings'][$date_key] += $earnings_stat;
1299 1299
 								$total                             += $earnings_stat;
1300
-								$d ++;
1300
+								$d++;
1301 1301
 							endwhile;
1302 1302
 
1303
-							$i ++;
1303
+							$i++;
1304 1304
 						endwhile;
1305 1305
 
1306
-						$y ++;
1306
+						$y++;
1307 1307
 					endwhile;
1308 1308
 
1309 1309
 					$earnings['totals'] = $total;
1310 1310
 				} else {
1311
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1311
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1312 1312
 						$earnings_count = (float) 0.00;
1313 1313
 
1314 1314
 						// Loop through the months
1315 1315
 						$month = $dates['m_start'];
1316 1316
 
1317
-						while ( $month <= $dates['m_end'] ) :
1318
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1319
-							$month ++;
1317
+						while ($month <= $dates['m_end']) :
1318
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1319
+							$month++;
1320 1320
 						endwhile;
1321 1321
 
1322
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1322
+						$earnings['earnings'][$args['date']] = $earnings_count;
1323 1323
 					} else {
1324
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1324
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1325 1325
 					}
1326 1326
 				}// End if().
1327
-			} elseif ( $args['form'] == 'all' ) {
1328
-				$forms = get_posts( array(
1327
+			} elseif ($args['form'] == 'all') {
1328
+				$forms = get_posts(array(
1329 1329
 					'post_type' => 'give_forms',
1330 1330
 					'nopaging'  => true,
1331
-				) );
1331
+				));
1332 1332
 
1333 1333
 				$i = 0;
1334
-				foreach ( $forms as $form_info ) {
1335
-					$earnings['earnings'][ $i ] = array(
1336
-						$form_info->post_name => give_get_form_earnings_stats( $form_info->ID ),
1334
+				foreach ($forms as $form_info) {
1335
+					$earnings['earnings'][$i] = array(
1336
+						$form_info->post_name => give_get_form_earnings_stats($form_info->ID),
1337 1337
 					);
1338
-					$i ++;
1338
+					$i++;
1339 1339
 				}
1340 1340
 			} else {
1341
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1342
-					$form_info               = get_post( $args['form'] );
1341
+				if (get_post_type($args['form']) == 'give_forms') {
1342
+					$form_info               = get_post($args['form']);
1343 1343
 					$earnings['earnings'][0] = array(
1344
-						$form_info->post_name => give_get_form_earnings_stats( $args['form'] ),
1344
+						$form_info->post_name => give_get_form_earnings_stats($args['form']),
1345 1345
 					);
1346 1346
 				} else {
1347 1347
 					$error['error'] = sprintf( /* translators: %s: form */
1348
-						esc_html__( 'Form %s not found.', 'give' ), $args['form'] );
1348
+						esc_html__('Form %s not found.', 'give'), $args['form'] );
1349 1349
 				}
1350 1350
 			}// End if().
1351 1351
 
1352
-			if ( ! empty( $error ) ) {
1352
+			if ( ! empty($error)) {
1353 1353
 				return $error;
1354 1354
 			}
1355 1355
 
1356 1356
 			return $earnings;
1357
-		} elseif ( $args['type'] == 'donors' ) {
1357
+		} elseif ($args['type'] == 'donors') {
1358 1358
 			$donors                             = new Give_DB_Donors();
1359 1359
 			$stats['donations']['total_donors'] = $donors->count();
1360 1360
 
1361 1361
 			return $stats;
1362 1362
 
1363
-		} elseif ( empty( $args['type'] ) ) {
1364
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1365
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1363
+		} elseif (empty($args['type'])) {
1364
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1365
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1366 1366
 
1367 1367
 			return array(
1368 1368
 				'stats' => $stats,
@@ -1380,7 +1380,7 @@  discard block
 block discarded – undo
1380 1380
 	 *
1381 1381
 	 * @return array
1382 1382
 	 */
1383
-	public function get_recent_donations( $args = array() ) {
1383
+	public function get_recent_donations($args = array()) {
1384 1384
 		global $wp_query;
1385 1385
 
1386 1386
 		$defaults = array(
@@ -1389,22 +1389,22 @@  discard block
 block discarded – undo
1389 1389
 			'enddate'   => null,
1390 1390
 		);
1391 1391
 
1392
-		$args = wp_parse_args( $args, $defaults );
1392
+		$args = wp_parse_args($args, $defaults);
1393 1393
 
1394 1394
 		$sales = array();
1395 1395
 
1396
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1396
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1397 1397
 			return $sales;
1398 1398
 		}
1399 1399
 
1400
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1400
+		if (isset($wp_query->query_vars['id'])) {
1401 1401
 			$query   = array();
1402
-			$query[] = new Give_Payment( $wp_query->query_vars['id'] );
1403
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1402
+			$query[] = new Give_Payment($wp_query->query_vars['id']);
1403
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1404 1404
 			$query   = array();
1405
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1406
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1407
-			$args  = array(
1405
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1406
+		} elseif (isset($wp_query->query_vars['email'])) {
1407
+			$args = array(
1408 1408
 				'fields'     => 'ids',
1409 1409
 				'meta_key'   => '_give_payment_user_email',
1410 1410
 				'meta_value' => $wp_query->query_vars['email'],
@@ -1412,11 +1412,11 @@  discard block
 block discarded – undo
1412 1412
 				'page'       => $this->get_paged(),
1413 1413
 				'status'     => 'publish',
1414 1414
 			);
1415
-			$query = give_get_payments( $args );
1416
-		} elseif ( isset( $wp_query->query_vars['date'] ) ) {
1415
+			$query = give_get_payments($args);
1416
+		} elseif (isset($wp_query->query_vars['date'])) {
1417 1417
 
1418
-			$current_time = current_time( 'timestamp' );
1419
-			$dates        = $this->get_dates( $args );
1418
+			$current_time = current_time('timestamp');
1419
+			$dates        = $this->get_dates($args);
1420 1420
 
1421 1421
 			/**
1422 1422
 			 *  Switch case for date query argument
@@ -1427,27 +1427,27 @@  discard block
 block discarded – undo
1427 1427
 			 * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
1428 1428
 			 * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
1429 1429
 			 */
1430
-			switch ( $wp_query->query_vars['date'] ) {
1430
+			switch ($wp_query->query_vars['date']) {
1431 1431
 
1432 1432
 				case 'today':
1433 1433
 
1434 1434
 					// Set and Format Start and End Date to be date of today.
1435
-					$start_date = $end_date = date( 'Y/m/d', $current_time );
1435
+					$start_date = $end_date = date('Y/m/d', $current_time);
1436 1436
 
1437 1437
 					break;
1438 1438
 
1439 1439
 				case 'yesterday':
1440 1440
 
1441 1441
 					// Set and Format Start and End Date to be date of yesterday.
1442
-					$start_date = $end_date = date( 'Y/m', $current_time ) . '/' . ( date( 'd', $current_time ) - 1 );
1442
+					$start_date = $end_date = date('Y/m', $current_time).'/'.(date('d', $current_time) - 1);
1443 1443
 
1444 1444
 					break;
1445 1445
 
1446 1446
 				case 'range':
1447 1447
 
1448 1448
 					// Format Start Date and End Date for filtering payment based on date range.
1449
-					$start_date = $dates['year'] . '/' . $dates['m_start'] . '/' . $dates['day_start'];
1450
-					$end_date   = $dates['year_end'] . '/' . $dates['m_end'] . '/' . $dates['day_end'];
1449
+					$start_date = $dates['year'].'/'.$dates['m_start'].'/'.$dates['day_start'];
1450
+					$end_date   = $dates['year_end'].'/'.$dates['m_end'].'/'.$dates['day_end'];
1451 1451
 
1452 1452
 					break;
1453 1453
 
@@ -1462,7 +1462,7 @@  discard block
 block discarded – undo
1462 1462
 				'status'     => 'publish',
1463 1463
 			);
1464 1464
 
1465
-			$query = give_get_payments( $args );
1465
+			$query = give_get_payments($args);
1466 1466
 		} else {
1467 1467
 			$args  = array(
1468 1468
 				'fields' => 'ids',
@@ -1470,14 +1470,14 @@  discard block
 block discarded – undo
1470 1470
 				'page'   => $this->get_paged(),
1471 1471
 				'status' => 'publish',
1472 1472
 			);
1473
-			$query = give_get_payments( $args );
1473
+			$query = give_get_payments($args);
1474 1474
 		}// End if().
1475
-		if ( $query ) {
1475
+		if ($query) {
1476 1476
 			$i = 0;
1477
-			foreach ( $query as $payment ) {
1477
+			foreach ($query as $payment) {
1478 1478
 
1479
-				if ( is_numeric( $payment ) ) {
1480
-					$payment      = new Give_Payment( $payment );
1479
+				if (is_numeric($payment)) {
1480
+					$payment      = new Give_Payment($payment);
1481 1481
 					$payment_meta = $payment->get_meta();
1482 1482
 					$user_info    = $payment->user_info;
1483 1483
 				} else {
@@ -1487,40 +1487,40 @@  discard block
 block discarded – undo
1487 1487
 				$payment_meta = $payment->get_meta();
1488 1488
 				$user_info    = $payment->user_info;
1489 1489
 
1490
-				$first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1491
-				$last_name  = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1492
-
1493
-				$sales['donations'][ $i ]['ID']             = $payment->number;
1494
-				$sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id;
1495
-				$sales['donations'][ $i ]['key']            = $payment->key;
1496
-				$sales['donations'][ $i ]['total']          = $payment->total;
1497
-				$sales['donations'][ $i ]['gateway']        = $payment->gateway;
1498
-				$sales['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1499
-				$sales['donations'][ $i ]['fname']          = $first_name;
1500
-				$sales['donations'][ $i ]['lname']          = $last_name;
1501
-				$sales['donations'][ $i ]['email']          = $payment->email;
1502
-				$sales['donations'][ $i ]['date']           = $payment->date;
1503
-
1504
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1505
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1506
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1507
-
1508
-				$sales['donations'][ $i ]['form']['id']    = $form_id;
1509
-				$sales['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1510
-				$sales['donations'][ $i ]['form']['price'] = $price;
1511
-
1512
-				if ( give_has_variable_prices( $form_id ) ) {
1513
-					if ( isset( $payment_meta['price_id'] ) ) {
1514
-						$price_name                                     = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1515
-						$sales['donations'][ $i ]['form']['price_name'] = $price_name;
1516
-						$sales['donations'][ $i ]['form']['price_id']   = $price_id;
1517
-						$sales['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1490
+				$first_name = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1491
+				$last_name  = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1492
+
1493
+				$sales['donations'][$i]['ID']             = $payment->number;
1494
+				$sales['donations'][$i]['transaction_id'] = $payment->transaction_id;
1495
+				$sales['donations'][$i]['key']            = $payment->key;
1496
+				$sales['donations'][$i]['total']          = $payment->total;
1497
+				$sales['donations'][$i]['gateway']        = $payment->gateway;
1498
+				$sales['donations'][$i]['name']           = $first_name.' '.$last_name;
1499
+				$sales['donations'][$i]['fname']          = $first_name;
1500
+				$sales['donations'][$i]['lname']          = $last_name;
1501
+				$sales['donations'][$i]['email']          = $payment->email;
1502
+				$sales['donations'][$i]['date']           = $payment->date;
1503
+
1504
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1505
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1506
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1507
+
1508
+				$sales['donations'][$i]['form']['id']    = $form_id;
1509
+				$sales['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1510
+				$sales['donations'][$i]['form']['price'] = $price;
1511
+
1512
+				if (give_has_variable_prices($form_id)) {
1513
+					if (isset($payment_meta['price_id'])) {
1514
+						$price_name                                     = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1515
+						$sales['donations'][$i]['form']['price_name'] = $price_name;
1516
+						$sales['donations'][$i]['form']['price_id']   = $price_id;
1517
+						$sales['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1518 1518
 
1519 1519
 					}
1520 1520
 				}
1521 1521
 
1522 1522
 				// Add custom meta to API
1523
-				foreach ( $payment_meta as $meta_key => $meta_value ) {
1523
+				foreach ($payment_meta as $meta_key => $meta_value) {
1524 1524
 
1525 1525
 					$exceptions = array(
1526 1526
 						'form_title',
@@ -1533,19 +1533,19 @@  discard block
 block discarded – undo
1533 1533
 					);
1534 1534
 
1535 1535
 					// Don't clutter up results with dupes
1536
-					if ( in_array( $meta_key, $exceptions ) ) {
1536
+					if (in_array($meta_key, $exceptions)) {
1537 1537
 						continue;
1538 1538
 					}
1539 1539
 
1540
-					$sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1540
+					$sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1541 1541
 
1542 1542
 				}
1543 1543
 
1544
-				$i ++;
1544
+				$i++;
1545 1545
 			}// End foreach().
1546 1546
 		}// End if().
1547 1547
 
1548
-		return apply_filters( 'give_api_donations_endpoint', $sales );
1548
+		return apply_filters('give_api_donations_endpoint', $sales);
1549 1549
 	}
1550 1550
 
1551 1551
 	/**
@@ -1561,9 +1561,9 @@  discard block
 block discarded – undo
1561 1561
 	public function get_output_format() {
1562 1562
 		global $wp_query;
1563 1563
 
1564
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1564
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1565 1565
 
1566
-		return apply_filters( 'give_api_output_format', $format );
1566
+		return apply_filters('give_api_output_format', $format);
1567 1567
 	}
1568 1568
 
1569 1569
 
@@ -1580,8 +1580,8 @@  discard block
 block discarded – undo
1580 1580
 	 *
1581 1581
 	 * @return void
1582 1582
 	 */
1583
-	private function log_request( $data = array() ) {
1584
-		if ( ! $this->log_requests ) {
1583
+	private function log_request($data = array()) {
1584
+		if ( ! $this->log_requests) {
1585 1585
 			return;
1586 1586
 		}
1587 1587
 
@@ -1597,36 +1597,36 @@  discard block
 block discarded – undo
1597 1597
 
1598 1598
 		$query = array(
1599 1599
 			'give-api'    => $wp_query->query_vars['give-api'],
1600
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1601
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1602
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1603
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1604
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1605
-			'donor'       => isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null,
1606
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1607
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1608
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1609
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1610
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1611
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1600
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1601
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1602
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1603
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1604
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1605
+			'donor'       => isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null,
1606
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1607
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1608
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1609
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1610
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1611
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1612 1612
 		);
1613 1613
 
1614 1614
 		$log_data = array(
1615 1615
 			'log_type'     => 'api_request',
1616
-			'post_excerpt' => http_build_query( $query ),
1617
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1616
+			'post_excerpt' => http_build_query($query),
1617
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1618 1618
 		);
1619 1619
 
1620 1620
 		$log_meta = array(
1621 1621
 			'request_ip' => give_get_ip(),
1622 1622
 			'user'       => $this->user_id,
1623
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1624
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1623
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1624
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1625 1625
 			'time'       => $data['request_speed'],
1626 1626
 			'version'    => $this->get_queried_version(),
1627 1627
 		);
1628 1628
 
1629
-		$give_logs->insert_log( $log_data, $log_meta );
1629
+		$give_logs->insert_log($log_data, $log_meta);
1630 1630
 	}
1631 1631
 
1632 1632
 
@@ -1650,11 +1650,11 @@  discard block
 block discarded – undo
1650 1650
 	 *
1651 1651
 	 * @param int       $status_code
1652 1652
 	 */
1653
-	public function output( $status_code = 200 ) {
1653
+	public function output($status_code = 200) {
1654 1654
 
1655 1655
 		$format = $this->get_output_format();
1656 1656
 
1657
-		status_header( $status_code );
1657
+		status_header($status_code);
1658 1658
 
1659 1659
 		/**
1660 1660
 		 * Fires before outputting the API.
@@ -1665,25 +1665,25 @@  discard block
 block discarded – undo
1665 1665
 		 * @param Give_API $this   The Give_API object.
1666 1666
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1667 1667
 		 */
1668
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1668
+		do_action('give_api_output_before', $this->data, $this, $format);
1669 1669
 
1670
-		switch ( $format ) :
1670
+		switch ($format) :
1671 1671
 
1672 1672
 			case 'xml' :
1673 1673
 
1674
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1675
-				$xml = Array2XML::createXML( 'give', $this->data );
1674
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1675
+				$xml = Array2XML::createXML('give', $this->data);
1676 1676
 				echo $xml->saveXML();
1677 1677
 
1678 1678
 				break;
1679 1679
 
1680 1680
 			case 'json' :
1681 1681
 
1682
-				header( 'Content-Type: application/json' );
1683
-				if ( ! empty( $this->pretty_print ) ) {
1684
-					echo json_encode( $this->data, $this->pretty_print );
1682
+				header('Content-Type: application/json');
1683
+				if ( ! empty($this->pretty_print)) {
1684
+					echo json_encode($this->data, $this->pretty_print);
1685 1685
 				} else {
1686
-					echo json_encode( $this->data );
1686
+					echo json_encode($this->data);
1687 1687
 				}
1688 1688
 
1689 1689
 				break;
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
 				 * @param array    $data Response data to return.
1699 1699
 				 * @param Give_API $this The Give_API object.
1700 1700
 				 */
1701
-				do_action( "give_api_output_{$format}", $this->data, $this );
1701
+				do_action("give_api_output_{$format}", $this->data, $this);
1702 1702
 
1703 1703
 				break;
1704 1704
 
@@ -1713,7 +1713,7 @@  discard block
 block discarded – undo
1713 1713
 		 * @param Give_API $this   The Give_API object.
1714 1714
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1715 1715
 		 */
1716
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1716
+		do_action('give_api_output_after', $this->data, $this, $format);
1717 1717
 
1718 1718
 		give_die();
1719 1719
 	}
@@ -1730,40 +1730,40 @@  discard block
 block discarded – undo
1730 1730
 	 *
1731 1731
 	 * @return void
1732 1732
 	 */
1733
-	function user_key_field( $user ) {
1733
+	function user_key_field($user) {
1734 1734
 
1735
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1736
-			$user = get_userdata( $user->ID );
1735
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1736
+			$user = get_userdata($user->ID);
1737 1737
 			?>
1738 1738
 			<table class="form-table">
1739 1739
 				<tbody>
1740 1740
 				<tr>
1741 1741
 					<th>
1742
-						<?php esc_html_e( 'Give API Keys', 'give' ); ?>
1742
+						<?php esc_html_e('Give API Keys', 'give'); ?>
1743 1743
 					</th>
1744 1744
 					<td>
1745 1745
 						<?php
1746
-						$public_key = $this->get_user_public_key( $user->ID );
1747
-						$secret_key = $this->get_user_secret_key( $user->ID );
1746
+						$public_key = $this->get_user_public_key($user->ID);
1747
+						$secret_key = $this->get_user_secret_key($user->ID);
1748 1748
 						?>
1749
-						<?php if ( empty( $user->give_user_public_key ) ) { ?>
1749
+						<?php if (empty($user->give_user_public_key)) { ?>
1750 1750
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1751
-							<span class="description"><?php esc_html_e( 'Generate API Key', 'give' ); ?></span>
1751
+							<span class="description"><?php esc_html_e('Generate API Key', 'give'); ?></span>
1752 1752
 						<?php } else { ?>
1753
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Public key:', 'give' ); ?>
1753
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Public key:', 'give'); ?>
1754 1754
 								&nbsp;</strong>
1755
-							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>"/>
1755
+							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>"/>
1756 1756
 							<br/>
1757
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Secret key:', 'give' ); ?>
1757
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Secret key:', 'give'); ?>
1758 1758
 								&nbsp;</strong>
1759
-							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>"/>
1759
+							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>"/>
1760 1760
 							<br/>
1761
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Token:', 'give' ); ?>
1761
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Token:', 'give'); ?>
1762 1762
 								&nbsp;</strong>
1763
-							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>"/>
1763
+							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>"/>
1764 1764
 							<br/>
1765 1765
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1766
-							<span class="description"><label for="give_set_api_key"><?php esc_html_e( 'Revoke API Keys', 'give' ); ?></label></span>
1766
+							<span class="description"><label for="give_set_api_key"><?php esc_html_e('Revoke API Keys', 'give'); ?></label></span>
1767 1767
 						<?php } ?>
1768 1768
 					</td>
1769 1769
 				</tr>
@@ -1782,61 +1782,61 @@  discard block
 block discarded – undo
1782 1782
 	 *
1783 1783
 	 * @return void
1784 1784
 	 */
1785
-	public function process_api_key( $args ) {
1785
+	public function process_api_key($args) {
1786 1786
 
1787
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1788
-			wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array(
1787
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1788
+			wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array(
1789 1789
 				'response' => 403,
1790
-			) );
1790
+			));
1791 1791
 		}
1792 1792
 
1793
-		if ( empty( $args['user_id'] ) ) {
1794
-			wp_die( __( 'User ID Required.', 'give' ), __( 'Error', 'give' ), array(
1793
+		if (empty($args['user_id'])) {
1794
+			wp_die(__('User ID Required.', 'give'), __('Error', 'give'), array(
1795 1795
 				'response' => 401,
1796
-			) );
1796
+			));
1797 1797
 		}
1798 1798
 
1799
-		if ( is_numeric( $args['user_id'] ) ) {
1800
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1799
+		if (is_numeric($args['user_id'])) {
1800
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1801 1801
 		} else {
1802
-			$userdata = get_user_by( 'login', $args['user_id'] );
1802
+			$userdata = get_user_by('login', $args['user_id']);
1803 1803
 			$user_id  = $userdata->ID;
1804 1804
 		}
1805
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1805
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1806 1806
 
1807
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1808
-			wp_die( sprintf( /* translators: %s: process */
1809
-				esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), esc_html__( 'Error', 'give' ), array(
1807
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1808
+			wp_die(sprintf( /* translators: %s: process */
1809
+				esc_html__('You do not have permission to %s API keys for this user.', 'give'), $process ), esc_html__('Error', 'give'), array(
1810 1810
 				'response' => 403,
1811
-			) );
1812
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1813
-			wp_die( sprintf( /* translators: %s: process */
1814
-				esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), esc_html__( 'Error', 'give' ), array(
1811
+			));
1812
+		} elseif ( ! current_user_can('manage_give_settings')) {
1813
+			wp_die(sprintf( /* translators: %s: process */
1814
+				esc_html__('You do not have permission to %s API keys for this user.', 'give'), $process ), esc_html__('Error', 'give'), array(
1815 1815
 				'response' => 403,
1816
-			) );
1816
+			));
1817 1817
 		}
1818 1818
 
1819
-		switch ( $process ) {
1819
+		switch ($process) {
1820 1820
 			case 'generate':
1821
-				if ( $this->generate_api_key( $user_id ) ) {
1822
-					Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1823
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1821
+				if ($this->generate_api_key($user_id)) {
1822
+					Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1823
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1824 1824
 					exit();
1825 1825
 				} else {
1826
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1826
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1827 1827
 					exit();
1828 1828
 				}
1829 1829
 				break;
1830 1830
 			case 'regenerate':
1831
-				$this->generate_api_key( $user_id, true );
1832
-				Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1833
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1831
+				$this->generate_api_key($user_id, true);
1832
+				Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1833
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1834 1834
 				exit();
1835 1835
 				break;
1836 1836
 			case 'revoke':
1837
-				$this->revoke_api_key( $user_id );
1838
-				Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1839
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1837
+				$this->revoke_api_key($user_id);
1838
+				Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1839
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1840 1840
 				exit();
1841 1841
 				break;
1842 1842
 			default;
@@ -1855,34 +1855,34 @@  discard block
 block discarded – undo
1855 1855
 	 *
1856 1856
 	 * @return boolean True if (re)generated succesfully, false otherwise.
1857 1857
 	 */
1858
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1858
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1859 1859
 
1860
-		if ( empty( $user_id ) ) {
1860
+		if (empty($user_id)) {
1861 1861
 			return false;
1862 1862
 		}
1863 1863
 
1864
-		$user = get_userdata( $user_id );
1864
+		$user = get_userdata($user_id);
1865 1865
 
1866
-		if ( ! $user ) {
1866
+		if ( ! $user) {
1867 1867
 			return false;
1868 1868
 		}
1869 1869
 
1870
-		$public_key = $this->get_user_public_key( $user_id );
1871
-		$secret_key = $this->get_user_secret_key( $user_id );
1870
+		$public_key = $this->get_user_public_key($user_id);
1871
+		$secret_key = $this->get_user_secret_key($user_id);
1872 1872
 
1873
-		if ( empty( $public_key ) || $regenerate == true ) {
1874
-			$new_public_key = $this->generate_public_key( $user->user_email );
1875
-			$new_secret_key = $this->generate_private_key( $user->ID );
1873
+		if (empty($public_key) || $regenerate == true) {
1874
+			$new_public_key = $this->generate_public_key($user->user_email);
1875
+			$new_secret_key = $this->generate_private_key($user->ID);
1876 1876
 		} else {
1877 1877
 			return false;
1878 1878
 		}
1879 1879
 
1880
-		if ( $regenerate == true ) {
1881
-			$this->revoke_api_key( $user->ID );
1880
+		if ($regenerate == true) {
1881
+			$this->revoke_api_key($user->ID);
1882 1882
 		}
1883 1883
 
1884
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1885
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1884
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1885
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1886 1886
 
1887 1887
 		return true;
1888 1888
 	}
@@ -1897,26 +1897,26 @@  discard block
 block discarded – undo
1897 1897
 	 *
1898 1898
 	 * @return bool
1899 1899
 	 */
1900
-	public function revoke_api_key( $user_id = 0 ) {
1900
+	public function revoke_api_key($user_id = 0) {
1901 1901
 
1902
-		if ( empty( $user_id ) ) {
1902
+		if (empty($user_id)) {
1903 1903
 			return false;
1904 1904
 		}
1905 1905
 
1906
-		$user = get_userdata( $user_id );
1906
+		$user = get_userdata($user_id);
1907 1907
 
1908
-		if ( ! $user ) {
1908
+		if ( ! $user) {
1909 1909
 			return false;
1910 1910
 		}
1911 1911
 
1912
-		$public_key = $this->get_user_public_key( $user_id );
1913
-		$secret_key = $this->get_user_secret_key( $user_id );
1914
-		if ( ! empty( $public_key ) ) {
1915
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_' . $public_key ) ) );
1916
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_public_key' . $user_id ) ) );
1917
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_secret_key' . $user_id ) ) );
1918
-			delete_user_meta( $user_id, $public_key );
1919
-			delete_user_meta( $user_id, $secret_key );
1912
+		$public_key = $this->get_user_public_key($user_id);
1913
+		$secret_key = $this->get_user_secret_key($user_id);
1914
+		if ( ! empty($public_key)) {
1915
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_'.$public_key)));
1916
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_public_key'.$user_id)));
1917
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_secret_key'.$user_id)));
1918
+			delete_user_meta($user_id, $public_key);
1919
+			delete_user_meta($user_id, $secret_key);
1920 1920
 		} else {
1921 1921
 			return false;
1922 1922
 		}
@@ -1941,22 +1941,22 @@  discard block
 block discarded – undo
1941 1941
 	 *
1942 1942
 	 * @return void
1943 1943
 	 */
1944
-	public function update_key( $user_id ) {
1945
-		if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) {
1944
+	public function update_key($user_id) {
1945
+		if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) {
1946 1946
 
1947
-			$user = get_userdata( $user_id );
1947
+			$user = get_userdata($user_id);
1948 1948
 
1949
-			$public_key = $this->get_user_public_key( $user_id );
1950
-			$secret_key = $this->get_user_secret_key( $user_id );
1949
+			$public_key = $this->get_user_public_key($user_id);
1950
+			$secret_key = $this->get_user_secret_key($user_id);
1951 1951
 
1952
-			if ( empty( $public_key ) ) {
1953
-				$new_public_key = $this->generate_public_key( $user->user_email );
1954
-				$new_secret_key = $this->generate_private_key( $user->ID );
1952
+			if (empty($public_key)) {
1953
+				$new_public_key = $this->generate_public_key($user->user_email);
1954
+				$new_secret_key = $this->generate_private_key($user->ID);
1955 1955
 
1956
-				update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1957
-				update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1956
+				update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1957
+				update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1958 1958
 			} else {
1959
-				$this->revoke_api_key( $user_id );
1959
+				$this->revoke_api_key($user_id);
1960 1960
 			}
1961 1961
 		}
1962 1962
 	}
@@ -1971,9 +1971,9 @@  discard block
 block discarded – undo
1971 1971
 	 *
1972 1972
 	 * @return string
1973 1973
 	 */
1974
-	private function generate_public_key( $user_email = '' ) {
1975
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1976
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
1974
+	private function generate_public_key($user_email = '') {
1975
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1976
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
1977 1977
 
1978 1978
 		return $public;
1979 1979
 	}
@@ -1988,9 +1988,9 @@  discard block
 block discarded – undo
1988 1988
 	 *
1989 1989
 	 * @return string
1990 1990
 	 */
1991
-	private function generate_private_key( $user_id = 0 ) {
1992
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1993
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
1991
+	private function generate_private_key($user_id = 0) {
1992
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1993
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
1994 1994
 
1995 1995
 		return $secret;
1996 1996
 	}
@@ -2005,8 +2005,8 @@  discard block
 block discarded – undo
2005 2005
 	 *
2006 2006
 	 * @return string
2007 2007
 	 */
2008
-	public function get_token( $user_id = 0 ) {
2009
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
2008
+	public function get_token($user_id = 0) {
2009
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
2010 2010
 	}
2011 2011
 
2012 2012
 	/**
@@ -2020,9 +2020,9 @@  discard block
 block discarded – undo
2020 2020
 
2021 2021
 		// Default sales return
2022 2022
 		$sales                               = array();
2023
-		$sales['donations']['today']         = $this->stats->get_sales( 0, 'today' );
2024
-		$sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
2025
-		$sales['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
2023
+		$sales['donations']['today']         = $this->stats->get_sales(0, 'today');
2024
+		$sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
2025
+		$sales['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
2026 2026
 		$sales['donations']['totals']        = give_get_total_donations();
2027 2027
 
2028 2028
 		return $sales;
@@ -2039,9 +2039,9 @@  discard block
 block discarded – undo
2039 2039
 
2040 2040
 		// Default earnings return
2041 2041
 		$earnings                              = array();
2042
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
2043
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
2044
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
2042
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
2043
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
2044
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
2045 2045
 		$earnings['earnings']['totals']        = give_get_total_earnings();
2046 2046
 
2047 2047
 		return $earnings;
@@ -2061,25 +2061,25 @@  discard block
 block discarded – undo
2061 2061
 	 *
2062 2062
 	 * @return string            The API key/secret for the user supplied
2063 2063
 	 */
2064
-	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) {
2064
+	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) {
2065 2065
 
2066
-		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) {
2066
+		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') {
2067 2067
 			return $check;
2068 2068
 		}
2069 2069
 
2070 2070
 		$return = $check;
2071 2071
 
2072
-		switch ( $meta_key ) {
2072
+		switch ($meta_key) {
2073 2073
 			case 'give_user_public_key':
2074
-				$return = Give()->api->get_user_public_key( $object_id );
2074
+				$return = Give()->api->get_user_public_key($object_id);
2075 2075
 				break;
2076 2076
 			case 'give_user_secret_key':
2077
-				$return = Give()->api->get_user_secret_key( $object_id );
2077
+				$return = Give()->api->get_user_secret_key($object_id);
2078 2078
 				break;
2079 2079
 		}
2080 2080
 
2081
-		if ( ! $single ) {
2082
-			$return = array( $return );
2081
+		if ( ! $single) {
2082
+			$return = array($return);
2083 2083
 		}
2084 2084
 
2085 2085
 		return $return;
Please login to merge, or discard this patch.
includes/class-give-db-donors.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @since  1.0
162 162
 	 * @access public
163 163
 	 *
164
-	 * @param  bool|string|int $_id_or_email
164
+	 * @param  integer $_id_or_email
165 165
 	 *
166 166
 	 * @return bool|int
167 167
 	 */
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * @param  int          $user_id       User ID.
317 317
 	 * @param  WP_User|bool $old_user_data User data.
318 318
 	 *
319
-	 * @return bool
319
+	 * @return false|null
320 320
 	 */
321 321
 	public function update_donor_email_on_user_update( $user_id = 0, $old_user_data = false ) {
322 322
 
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 * @access public
374 374
 	 *
375 375
 	 * @param  string $field ID or email. Default is 'id'.
376
-	 * @param  mixed  $value The Customer ID or email to search. Default is 0.
376
+	 * @param  integer  $value The Customer ID or email to search. Default is 0.
377 377
 	 *
378 378
 	 * @return mixed         Upon success, an object of the donor. Upon failure, NULL
379 379
 	 */
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -449,13 +449,13 @@  discard block
 block discarded – undo
449 449
 	 *
450 450
 	 * @since  1.0
451 451
 	 * @access public
452
-     *
453
-     * @param  array $args
454
-     *
455
-     * @return array|object|null Customers array or object. Null if not found.
452
+	 *
453
+	 * @param  array $args
454
+	 *
455
+	 * @return array|object|null Customers array or object. Null if not found.
456 456
 	 */
457 457
 	public function get_donors( $args = array() ) {
458
-        /* @var WPDB $wpdb */
458
+		/* @var WPDB $wpdb */
459 459
 		global $wpdb;
460 460
 
461 461
 		$defaults = array(
@@ -580,13 +580,13 @@  discard block
 block discarded – undo
580 580
 	 *
581 581
 	 * @since  1.0
582 582
 	 * @access public
583
-     *
584
-     * @param  array $args
585
-     *
586
-     * @return int         Total number of donors.
583
+	 *
584
+	 * @param  array $args
585
+	 *
586
+	 * @return int         Total number of donors.
587 587
 	 */
588 588
 	public function count( $args = array() ) {
589
-        /* @var WPDB $wpdb */
589
+		/* @var WPDB $wpdb */
590 590
 		global $wpdb;
591 591
 
592 592
 		$where = ' WHERE 1=1 ';
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 		/* @var WPDB $wpdb */
36 36
 		global $wpdb;
37 37
 
38
-		$this->table_name  = $wpdb->prefix . 'give_customers';
38
+		$this->table_name  = $wpdb->prefix.'give_customers';
39 39
 		$this->primary_key = 'id';
40 40
 		$this->version     = '1.0';
41 41
 		
42
-		add_action( 'profile_update', array( $this, 'update_donor_email_on_user_update' ), 10, 2 );
42
+		add_action('profile_update', array($this, 'update_donor_email_on_user_update'), 10, 2);
43 43
 
44 44
 		// Install table.
45 45
 		$this->register_table();
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 			'purchase_value' => 0.00,
86 86
 			'purchase_count' => 0,
87 87
 			'notes'          => '',
88
-			'date_created'   => date( 'Y-m-d H:i:s' ),
88
+			'date_created'   => date('Y-m-d H:i:s'),
89 89
 		);
90 90
 	}
91 91
 
@@ -99,40 +99,40 @@  discard block
 block discarded – undo
99 99
 	 *
100 100
 	 * @return int|bool
101 101
 	 */
102
-	public function add( $data = array() ) {
102
+	public function add($data = array()) {
103 103
 
104 104
 		$defaults = array(
105 105
 			'payment_ids' => ''
106 106
 		);
107 107
 
108
-		$args = wp_parse_args( $data, $defaults );
108
+		$args = wp_parse_args($data, $defaults);
109 109
 
110
-		if ( empty( $args['email'] ) ) {
110
+		if (empty($args['email'])) {
111 111
 			return false;
112 112
 		}
113 113
 
114
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
115
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
114
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
115
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
116 116
 		}
117 117
 
118
-		$donor = $this->get_donor_by( 'email', $args['email'] );
118
+		$donor = $this->get_donor_by('email', $args['email']);
119 119
 
120 120
 		// update an existing donor.
121
-		if ( $donor ) {
121
+		if ($donor) {
122 122
 
123 123
 			// Update the payment IDs attached to the donor
124
-			if ( ! empty( $args['payment_ids'] ) ) {
124
+			if ( ! empty($args['payment_ids'])) {
125 125
 
126
-				if ( empty( $donor->payment_ids ) ) {
126
+				if (empty($donor->payment_ids)) {
127 127
 
128 128
 					$donor->payment_ids = $args['payment_ids'];
129 129
 
130 130
 				} else {
131 131
 
132
-					$existing_ids          = array_map( 'absint', explode( ',', $donor->payment_ids ) );
133
-					$payment_ids           = array_map( 'absint', explode( ',', $args['payment_ids'] ) );
134
-					$payment_ids           = array_merge( $payment_ids, $existing_ids );
135
-					$donor->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
132
+					$existing_ids          = array_map('absint', explode(',', $donor->payment_ids));
133
+					$payment_ids           = array_map('absint', explode(',', $args['payment_ids']));
134
+					$payment_ids           = array_merge($payment_ids, $existing_ids);
135
+					$donor->payment_ids = implode(',', array_unique(array_values($payment_ids)));
136 136
 
137 137
 				}
138 138
 
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
 
141 141
 			}
142 142
 
143
-			$this->update( $donor->id, $args );
143
+			$this->update($donor->id, $args);
144 144
 
145 145
 			return $donor->id;
146 146
 
147 147
 		} else {
148 148
 
149
-			return $this->insert( $args, 'donor' );
149
+			return $this->insert($args, 'donor');
150 150
 
151 151
 		}
152 152
 
@@ -165,20 +165,20 @@  discard block
 block discarded – undo
165 165
 	 *
166 166
 	 * @return bool|int
167 167
 	 */
168
-	public function delete( $_id_or_email = false ) {
168
+	public function delete($_id_or_email = false) {
169 169
 
170
-		if ( empty( $_id_or_email ) ) {
170
+		if (empty($_id_or_email)) {
171 171
 			return false;
172 172
 		}
173 173
 
174
-		$column   = is_email( $_id_or_email ) ? 'email' : 'id';
175
-		$donor = $this->get_donor_by( $column, $_id_or_email );
174
+		$column = is_email($_id_or_email) ? 'email' : 'id';
175
+		$donor = $this->get_donor_by($column, $_id_or_email);
176 176
 
177
-		if ( $donor->id > 0 ) {
177
+		if ($donor->id > 0) {
178 178
 
179 179
 			global $wpdb;
180 180
 
181
-			return $wpdb->delete( $this->table_name, array( 'id' => $donor->id ), array( '%d' ) );
181
+			return $wpdb->delete($this->table_name, array('id' => $donor->id), array('%d'));
182 182
 
183 183
 		} else {
184 184
 			return false;
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 	 *
198 198
 	 * @return bool          True is exists, false otherwise.
199 199
 	 */
200
-	public function exists( $value = '', $field = 'email' ) {
200
+	public function exists($value = '', $field = 'email') {
201 201
 		
202 202
 		$columns = $this->get_columns();
203
-		if ( ! array_key_exists( $field, $columns ) ) {
203
+		if ( ! array_key_exists($field, $columns)) {
204 204
 			return false;
205 205
 		}
206 206
 
207
-		return (bool) $this->get_column_by( 'id', $field, $value );
207
+		return (bool) $this->get_column_by('id', $field, $value);
208 208
 
209 209
 	}
210 210
 
@@ -219,16 +219,16 @@  discard block
 block discarded – undo
219 219
 	 *
220 220
 	 * @return bool
221 221
 	 */
222
-	public function attach_payment( $donor_id = 0, $payment_id = 0 ) {
222
+	public function attach_payment($donor_id = 0, $payment_id = 0) {
223 223
 
224
-		$donor = new Give_Donor( $donor_id );
224
+		$donor = new Give_Donor($donor_id);
225 225
 
226
-		if ( empty( $donor->id ) ) {
226
+		if (empty($donor->id)) {
227 227
 			return false;
228 228
 		}
229 229
 
230 230
 		// Attach the payment, but don't increment stats, as this function previously did not
231
-		return $donor->attach_payment( $payment_id, false );
231
+		return $donor->attach_payment($payment_id, false);
232 232
 
233 233
 	}
234 234
 
@@ -243,16 +243,16 @@  discard block
 block discarded – undo
243 243
 	 *
244 244
 	 * @return bool
245 245
 	 */
246
-	public function remove_payment( $donor_id = 0, $payment_id = 0 ) {
246
+	public function remove_payment($donor_id = 0, $payment_id = 0) {
247 247
 
248
-		$donor = new Give_Donor( $donor_id );
248
+		$donor = new Give_Donor($donor_id);
249 249
 
250
-		if ( ! $donor ) {
250
+		if ( ! $donor) {
251 251
 			return false;
252 252
 		}
253 253
 
254 254
 		// Remove the payment, but don't decrease stats, as this function previously did not
255
-		return $donor->remove_payment( $payment_id, false );
255
+		return $donor->remove_payment($payment_id, false);
256 256
 
257 257
 	}
258 258
 
@@ -266,18 +266,18 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return bool
268 268
 	 */
269
-	public function increment_stats( $donor_id = 0, $amount = 0.00 ) {
269
+	public function increment_stats($donor_id = 0, $amount = 0.00) {
270 270
 
271
-		$donor = new Give_Donor( $donor_id );
271
+		$donor = new Give_Donor($donor_id);
272 272
 
273
-		if ( empty( $donor->id ) ) {
273
+		if (empty($donor->id)) {
274 274
 			return false;
275 275
 		}
276 276
 
277 277
 		$increased_count = $donor->increase_purchase_count();
278
-		$increased_value = $donor->increase_value( $amount );
278
+		$increased_value = $donor->increase_value($amount);
279 279
 
280
-		return ( $increased_count && $increased_value ) ? true : false;
280
+		return ($increased_count && $increased_value) ? true : false;
281 281
 
282 282
 	}
283 283
 
@@ -292,18 +292,18 @@  discard block
 block discarded – undo
292 292
 	 *
293 293
 	 * @return bool
294 294
 	 */
295
-	public function decrement_stats( $donor_id = 0, $amount = 0.00 ) {
295
+	public function decrement_stats($donor_id = 0, $amount = 0.00) {
296 296
 
297
-		$donor = new Give_Donor( $donor_id );
297
+		$donor = new Give_Donor($donor_id);
298 298
 
299
-		if ( ! $donor ) {
299
+		if ( ! $donor) {
300 300
 			return false;
301 301
 		}
302 302
 
303 303
 		$decreased_count = $donor->decrease_donation_count();
304
-		$decreased_value = $donor->decrease_value( $amount );
304
+		$decreased_value = $donor->decrease_value($amount);
305 305
 
306
-		return ( $decreased_count && $decreased_value ) ? true : false;
306
+		return ($decreased_count && $decreased_value) ? true : false;
307 307
 
308 308
 	}
309 309
 
@@ -318,31 +318,31 @@  discard block
 block discarded – undo
318 318
 	 *
319 319
 	 * @return bool
320 320
 	 */
321
-	public function update_donor_email_on_user_update( $user_id = 0, $old_user_data = false ) {
321
+	public function update_donor_email_on_user_update($user_id = 0, $old_user_data = false) {
322 322
 
323
-		$donor = new Give_Donor( $user_id, true );
323
+		$donor = new Give_Donor($user_id, true);
324 324
 
325
-		if( ! $donor ) {
325
+		if ( ! $donor) {
326 326
 			return false;
327 327
 		}
328 328
 
329
-		$user = get_userdata( $user_id );
329
+		$user = get_userdata($user_id);
330 330
 
331
-		if( ! empty( $user ) && $user->user_email !== $donor->email ) {
331
+		if ( ! empty($user) && $user->user_email !== $donor->email) {
332 332
 
333
-			if( ! $this->get_donor_by( 'email', $user->user_email ) ) {
333
+			if ( ! $this->get_donor_by('email', $user->user_email)) {
334 334
 
335
-				$success = $this->update( $donor->id, array( 'email' => $user->user_email ) );
335
+				$success = $this->update($donor->id, array('email' => $user->user_email));
336 336
 
337
-				if( $success ) {
337
+				if ($success) {
338 338
 					// Update some payment meta if we need to
339
-					$payments_array = explode( ',', $donor->payment_ids );
339
+					$payments_array = explode(',', $donor->payment_ids);
340 340
 
341
-					if( ! empty( $payments_array ) ) {
341
+					if ( ! empty($payments_array)) {
342 342
 
343
-						foreach ( $payments_array as $payment_id ) {
343
+						foreach ($payments_array as $payment_id) {
344 344
 
345
-							give_update_payment_meta( $payment_id, 'email', $user->user_email );
345
+							give_update_payment_meta($payment_id, 'email', $user->user_email);
346 346
 
347 347
 						}
348 348
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 					 * @param  WP_User       $user     WordPress User object.
357 357
 					 * @param  Give_Donor $donor Give donor object.
358 358
 					 */
359
-					do_action( 'give_update_donor_email_on_user_update', $user, $donor );
359
+					do_action('give_update_donor_email_on_user_update', $user, $donor);
360 360
 
361 361
 				}
362 362
 
@@ -377,46 +377,46 @@  discard block
 block discarded – undo
377 377
 	 *
378 378
 	 * @return mixed         Upon success, an object of the donor. Upon failure, NULL
379 379
 	 */
380
-	public function get_donor_by( $field = 'id', $value = 0 ) {
380
+	public function get_donor_by($field = 'id', $value = 0) {
381 381
 		/* @var WPDB $wpdb */
382 382
 		global $wpdb;
383 383
 
384
-		if ( empty( $field ) || empty( $value ) ) {
384
+		if (empty($field) || empty($value)) {
385 385
 			return null;
386 386
 		}
387 387
 
388
-		if ( 'id' == $field || 'user_id' == $field ) {
388
+		if ('id' == $field || 'user_id' == $field) {
389 389
 			// Make sure the value is numeric to avoid casting objects, for example,
390 390
 			// to int 1.
391
-			if ( ! is_numeric( $value ) ) {
391
+			if ( ! is_numeric($value)) {
392 392
 				return false;
393 393
 			}
394 394
 
395
-			$value = intval( $value );
395
+			$value = intval($value);
396 396
 
397
-			if ( $value < 1 ) {
397
+			if ($value < 1) {
398 398
 				return false;
399 399
 			}
400 400
 
401
-		} elseif ( 'email' === $field ) {
401
+		} elseif ('email' === $field) {
402 402
 
403
-			if ( ! is_email( $value ) ) {
403
+			if ( ! is_email($value)) {
404 404
 				return false;
405 405
 			}
406 406
 
407
-			$value = trim( $value );
407
+			$value = trim($value);
408 408
 		}
409 409
 
410
-		if ( ! $value ) {
410
+		if ( ! $value) {
411 411
 			return false;
412 412
 		}
413 413
 
414
-		switch ( $field ) {
414
+		switch ($field) {
415 415
 			case 'id':
416 416
 				$db_field = 'id';
417 417
 				break;
418 418
 			case 'email':
419
-				$value    = sanitize_text_field( $value );
419
+				$value    = sanitize_text_field($value);
420 420
 				$db_field = 'email';
421 421
 				break;
422 422
 			case 'user_id':
@@ -426,15 +426,15 @@  discard block
 block discarded – undo
426 426
 				return false;
427 427
 		}
428 428
 
429
-		if ( ! $donor = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value ) ) ) {
429
+		if ( ! $donor = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value))) {
430 430
 
431 431
 			// Look for donor from an additional email.
432
-			if( 'email' === $field ) {
433
-				$meta_table  = Give()->donor_meta->table_name;
434
-				$donor_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value ) );
432
+			if ('email' === $field) {
433
+				$meta_table = Give()->donor_meta->table_name;
434
+				$donor_id = $wpdb->get_var($wpdb->prepare("SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value));
435 435
 
436
-				if( ! empty( $donor_id ) ) {
437
-					return $this->get( $donor_id );
436
+				if ( ! empty($donor_id)) {
437
+					return $this->get($donor_id);
438 438
  				}
439 439
  			}
440 440
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
      *
455 455
      * @return array|object|null Customers array or object. Null if not found.
456 456
 	 */
457
-	public function get_donors( $args = array() ) {
457
+	public function get_donors($args = array()) {
458 458
         /* @var WPDB $wpdb */
459 459
 		global $wpdb;
460 460
 
@@ -466,21 +466,21 @@  discard block
 block discarded – undo
466 466
 			'order'   => 'DESC'
467 467
 		);
468 468
 
469
-		$args = wp_parse_args( $args, $defaults );
469
+		$args = wp_parse_args($args, $defaults);
470 470
 
471
-		if ( $args['number'] < 1 ) {
471
+		if ($args['number'] < 1) {
472 472
 			$args['number'] = 999999999999;
473 473
 		}
474 474
 
475 475
 		$where = ' WHERE 1=1 ';
476 476
 
477 477
 		// specific donors.
478
-		if ( ! empty( $args['id'] ) ) {
478
+		if ( ! empty($args['id'])) {
479 479
 
480
-			if ( is_array( $args['id'] ) ) {
481
-				$ids = implode( ',', array_map( 'intval', $args['id'] ) );
480
+			if (is_array($args['id'])) {
481
+				$ids = implode(',', array_map('intval', $args['id']));
482 482
 			} else {
483
-				$ids = intval( $args['id'] );
483
+				$ids = intval($args['id']);
484 484
 			}
485 485
 
486 486
 			$where .= " AND `id` IN( {$ids} ) ";
@@ -488,12 +488,12 @@  discard block
 block discarded – undo
488 488
 		}
489 489
 
490 490
 		// donors for specific user accounts
491
-		if ( ! empty( $args['user_id'] ) ) {
491
+		if ( ! empty($args['user_id'])) {
492 492
 
493
-			if ( is_array( $args['user_id'] ) ) {
494
-				$user_ids = implode( ',', array_map( 'intval', $args['user_id'] ) );
493
+			if (is_array($args['user_id'])) {
494
+				$user_ids = implode(',', array_map('intval', $args['user_id']));
495 495
 			} else {
496
-				$user_ids = intval( $args['user_id'] );
496
+				$user_ids = intval($args['user_id']);
497 497
 			}
498 498
 
499 499
 			$where .= " AND `user_id` IN( {$user_ids} ) ";
@@ -501,41 +501,41 @@  discard block
 block discarded – undo
501 501
 		}
502 502
 
503 503
 		//specific donors by email
504
-		if( ! empty( $args['email'] ) ) {
504
+		if ( ! empty($args['email'])) {
505 505
 
506
-			if( is_array( $args['email'] ) ) {
506
+			if (is_array($args['email'])) {
507 507
 
508
-				$emails_count       = count( $args['email'] );
509
-				$emails_placeholder = array_fill( 0, $emails_count, '%s' );
510
-				$emails             = implode( ', ', $emails_placeholder );
508
+				$emails_count       = count($args['email']);
509
+				$emails_placeholder = array_fill(0, $emails_count, '%s');
510
+				$emails             = implode(', ', $emails_placeholder);
511 511
 
512
-				$where .= $wpdb->prepare( " AND `email` IN( $emails ) ", $args['email'] );
512
+				$where .= $wpdb->prepare(" AND `email` IN( $emails ) ", $args['email']);
513 513
 			} else {
514
-				$where .= $wpdb->prepare( " AND `email` = %s ", $args['email'] );
514
+				$where .= $wpdb->prepare(" AND `email` = %s ", $args['email']);
515 515
 			}
516 516
 		}
517 517
 
518 518
 		// specific donors by name
519
-		if( ! empty( $args['name'] ) ) {
520
-			$where .= $wpdb->prepare( " AND `name` LIKE '%%%%" . '%s' . "%%%%' ", $args['name'] );
519
+		if ( ! empty($args['name'])) {
520
+			$where .= $wpdb->prepare(" AND `name` LIKE '%%%%".'%s'."%%%%' ", $args['name']);
521 521
 		}
522 522
 
523 523
 		// Donors created for a specific date or in a date range
524
-		if ( ! empty( $args['date'] ) ) {
524
+		if ( ! empty($args['date'])) {
525 525
 
526
-			if ( is_array( $args['date'] ) ) {
526
+			if (is_array($args['date'])) {
527 527
 
528
-				if ( ! empty( $args['date']['start'] ) ) {
528
+				if ( ! empty($args['date']['start'])) {
529 529
 
530
-					$start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
530
+					$start = date('Y-m-d H:i:s', strtotime($args['date']['start']));
531 531
 
532 532
 					$where .= " AND `date_created` >= '{$start}'";
533 533
 
534 534
 				}
535 535
 
536
-				if ( ! empty( $args['date']['end'] ) ) {
536
+				if ( ! empty($args['date']['end'])) {
537 537
 
538
-					$end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
538
+					$end = date('Y-m-d H:i:s', strtotime($args['date']['end']));
539 539
 
540 540
 					$where .= " AND `date_created` <= '{$end}'";
541 541
 
@@ -543,31 +543,31 @@  discard block
 block discarded – undo
543 543
 
544 544
 			} else {
545 545
 
546
-				$year  = date( 'Y', strtotime( $args['date'] ) );
547
-				$month = date( 'm', strtotime( $args['date'] ) );
548
-				$day   = date( 'd', strtotime( $args['date'] ) );
546
+				$year  = date('Y', strtotime($args['date']));
547
+				$month = date('m', strtotime($args['date']));
548
+				$day   = date('d', strtotime($args['date']));
549 549
 
550 550
 				$where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )";
551 551
 			}
552 552
 
553 553
 		}
554 554
 
555
-		$args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby'];
555
+		$args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby'];
556 556
 
557
-		if ( 'purchase_value' == $args['orderby'] ) {
557
+		if ('purchase_value' == $args['orderby']) {
558 558
 			$args['orderby'] = 'purchase_value+0';
559 559
 		}
560 560
 
561
-		$cache_key = md5( 'give_donors_' . serialize( $args ) );
561
+		$cache_key = md5('give_donors_'.serialize($args));
562 562
 
563
-		$donors = wp_cache_get( $cache_key, 'donors' );
563
+		$donors = wp_cache_get($cache_key, 'donors');
564 564
 
565
-		$args['orderby'] = esc_sql( $args['orderby'] );
566
-		$args['order']   = esc_sql( $args['order'] );
565
+		$args['orderby'] = esc_sql($args['orderby']);
566
+		$args['order']   = esc_sql($args['order']);
567 567
 
568
-		if ( $donors === false ) {
569
-			$donors = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM  $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ) );
570
-			wp_cache_set( $cache_key, $donors, 'donors', 3600 );
568
+		if ($donors === false) {
569
+			$donors = $wpdb->get_results($wpdb->prepare("SELECT * FROM  $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number'])));
570
+			wp_cache_set($cache_key, $donors, 'donors', 3600);
571 571
 		}
572 572
 
573 573
 		return $donors;
@@ -585,26 +585,26 @@  discard block
 block discarded – undo
585 585
      *
586 586
      * @return int         Total number of donors.
587 587
 	 */
588
-	public function count( $args = array() ) {
588
+	public function count($args = array()) {
589 589
         /* @var WPDB $wpdb */
590 590
 		global $wpdb;
591 591
 
592 592
 		$where = ' WHERE 1=1 ';
593 593
 
594
-		if ( ! empty( $args['date'] ) ) {
594
+		if ( ! empty($args['date'])) {
595 595
 
596
-			if ( is_array( $args['date'] ) ) {
596
+			if (is_array($args['date'])) {
597 597
 
598
-				$start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
599
-				$end   = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
598
+				$start = date('Y-m-d H:i:s', strtotime($args['date']['start']));
599
+				$end   = date('Y-m-d H:i:s', strtotime($args['date']['end']));
600 600
 
601 601
 				$where .= " AND `date_created` >= '{$start}' AND `date_created` <= '{$end}'";
602 602
 
603 603
 			} else {
604 604
 
605
-				$year  = date( 'Y', strtotime( $args['date'] ) );
606
-				$month = date( 'm', strtotime( $args['date'] ) );
607
-				$day   = date( 'd', strtotime( $args['date'] ) );
605
+				$year  = date('Y', strtotime($args['date']));
606
+				$month = date('m', strtotime($args['date']));
607
+				$day   = date('d', strtotime($args['date']));
608 608
 
609 609
 				$where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )";
610 610
 			}
@@ -612,16 +612,16 @@  discard block
 block discarded – undo
612 612
 		}
613 613
 
614 614
 
615
-		$cache_key = md5( 'give_donors_count' . serialize( $args ) );
615
+		$cache_key = md5('give_donors_count'.serialize($args));
616 616
 
617
-		$count = wp_cache_get( $cache_key, 'donors' );
617
+		$count = wp_cache_get($cache_key, 'donors');
618 618
 
619
-		if ( $count === false ) {
620
-			$count = $wpdb->get_var( "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};" );
621
-			wp_cache_set( $cache_key, $count, 'donors', 3600 );
619
+		if ($count === false) {
620
+			$count = $wpdb->get_var("SELECT COUNT($this->primary_key) FROM ".$this->table_name."{$where};");
621
+			wp_cache_set($cache_key, $count, 'donors', 3600);
622 622
 		}
623 623
 
624
-		return absint( $count );
624
+		return absint($count);
625 625
 
626 626
 	}
627 627
 
@@ -635,9 +635,9 @@  discard block
 block discarded – undo
635 635
 	 */
636 636
 	public function create_table() {
637 637
 
638
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
638
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
639 639
 
640
-		$sql = "CREATE TABLE " . $this->table_name . " (
640
+		$sql = "CREATE TABLE ".$this->table_name." (
641 641
 		id bigint(20) NOT NULL AUTO_INCREMENT,
642 642
 		user_id bigint(20) NOT NULL,
643 643
 		email varchar(50) NOT NULL,
@@ -652,9 +652,9 @@  discard block
 block discarded – undo
652 652
 		KEY user (user_id)
653 653
 		) CHARACTER SET utf8 COLLATE utf8_general_ci;";
654 654
 
655
-		dbDelta( $sql );
655
+		dbDelta($sql);
656 656
 
657
-		update_option( $this->table_name . '_db_version', $this->version );
657
+		update_option($this->table_name.'_db_version', $this->version);
658 658
 	}
659 659
 	
660 660
 	/**
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	 * @return bool Returns if the donors table was installed and upgrade routine run.
667 667
 	 */
668 668
 	public function installed() {
669
-		return $this->table_exists( $this->table_name );
669
+		return $this->table_exists($this->table_name);
670 670
 	}
671 671
 
672 672
 }
Please login to merge, or discard this patch.
includes/class-give-license-handler.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 		 * @access private
704 704
 		 * @since  1.7
705 705
 		 *
706
-		 * @return bool
706
+		 * @return false|null
707 707
 		 */
708 708
 		private function __remove_license_key_from_subscriptions() {
709 709
 			$subscriptions = get_option( 'give_subscriptions', array() );
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 		 * @param $plugin_data
737 737
 		 * @param $status
738 738
 		 *
739
-		 * @return bool
739
+		 * @return false|null
740 740
 		 */
741 741
 		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
742 742
 			// Bailout.
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 		 *
759 759
 		 * @since  1.8.7
760 760
 		 * @access public
761
-		 * @return array
761
+		 * @return string
762 762
 		 */
763 763
 		public function license_state_message() {
764 764
 			$message_data = array();
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  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
 
17
-if ( ! class_exists( 'Give_License' ) ) :
17
+if ( ! class_exists('Give_License')) :
18 18
 
19 19
 	/**
20 20
 	 * Give_License Class
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
 		 * @param string $_checkout_url
143 143
 		 * @param string $_account_url
144 144
 		 */
145
-		public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) {
145
+		public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) {
146 146
 
147 147
 			$give_options = give_get_settings();
148 148
 
149 149
 			$this->file             = $_file;
150 150
 			$this->item_name        = $_item_name;
151
-			$this->item_shortname   = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
151
+			$this->item_shortname   = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
152 152
 			$this->version          = $_version;
153
-			$this->license          = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
154
-			$this->license_data     = get_option( $this->item_shortname . '_license_active' );
153
+			$this->license          = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
154
+			$this->license_data     = get_option($this->item_shortname.'_license_active');
155 155
 			$this->author           = $_author;
156
-			$this->api_url          = is_null( $_api_url ) ? $this->api_url : $_api_url;
157
-			$this->checkout_url     = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url;
158
-			$this->account_url      = is_null( $_account_url ) ? $this->account_url : $_account_url;
156
+			$this->api_url          = is_null($_api_url) ? $this->api_url : $_api_url;
157
+			$this->checkout_url     = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url;
158
+			$this->account_url      = is_null($_account_url) ? $this->account_url : $_account_url;
159 159
 			$this->auto_updater_obj = null;
160 160
 
161 161
 			// Setup hooks
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		 */
177 177
 		private function includes() {
178 178
 
179
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
179
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
180 180
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
181 181
 			}
182 182
 		}
@@ -194,30 +194,30 @@  discard block
 block discarded – undo
194 194
 		private function hooks() {
195 195
 
196 196
 			// Register settings
197
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
197
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
198 198
 
199 199
 			// Activate license key on settings save
200
-			add_action( 'admin_init', array( $this, 'activate_license' ) );
200
+			add_action('admin_init', array($this, 'activate_license'));
201 201
 
202 202
 			// Deactivate license key
203
-			add_action( 'admin_init', array( $this, 'deactivate_license' ) );
203
+			add_action('admin_init', array($this, 'deactivate_license'));
204 204
 
205 205
 			// Updater
206
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
207
-			add_action( 'admin_notices', array( $this, 'notices' ) );
206
+			add_action('admin_init', array($this, 'auto_updater'), 0);
207
+			add_action('admin_notices', array($this, 'notices'));
208 208
 
209 209
 			// Check license weekly.
210
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) );
211
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) );
210
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check'));
211
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check'));
212 212
 
213 213
 			// Check subscription weekly.
214
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) );
215
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) );
214
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check'));
215
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check'));
216 216
 
217 217
 			// Show addon notice on plugin page.
218
-			$plugin_name = explode( 'plugins/', $this->file );
219
-			$plugin_name = end( $plugin_name );
220
-			add_action( "after_plugin_row_{$plugin_name}", array( $this, 'plugin_page_notices' ), 10, 3 );
218
+			$plugin_name = explode('plugins/', $this->file);
219
+			$plugin_name = end($plugin_name);
220
+			add_action("after_plugin_row_{$plugin_name}", array($this, 'plugin_page_notices'), 10, 3);
221 221
 
222 222
 		}
223 223
 
@@ -257,16 +257,16 @@  discard block
 block discarded – undo
257 257
 		 *
258 258
 		 * @return array           License settings.
259 259
 		 */
260
-		public function settings( $settings ) {
260
+		public function settings($settings) {
261 261
 
262 262
 			$give_license_settings = array(
263 263
 				array(
264 264
 					'name'    => $this->item_name,
265
-					'id'      => $this->item_shortname . '_license_key',
265
+					'id'      => $this->item_shortname.'_license_key',
266 266
 					'desc'    => '',
267 267
 					'type'    => 'license_key',
268 268
 					'options' => array(
269
-						'license'      => get_option( $this->item_shortname . '_license_active' ),
269
+						'license'      => get_option($this->item_shortname.'_license_active'),
270 270
 						'shortname'    => $this->item_shortname,
271 271
 						'item_name'    => $this->item_name,
272 272
 						'api_url'      => $this->api_url,
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 				),
278 278
 			);
279 279
 
280
-			return array_merge( $settings, $give_license_settings );
280
+			return array_merge($settings, $give_license_settings);
281 281
 		}
282 282
 
283 283
 		/**
@@ -292,18 +292,18 @@  discard block
 block discarded – undo
292 292
 		 *
293 293
 		 * @return array           License settings content.
294 294
 		 */
295
-		public function license_settings_content( $settings ) {
295
+		public function license_settings_content($settings) {
296 296
 
297 297
 			$give_license_settings = array(
298 298
 				array(
299
-					'name' => __( 'Add-on Licenses', 'give' ),
299
+					'name' => __('Add-on Licenses', 'give'),
300 300
 					'desc' => '<hr>',
301 301
 					'type' => 'give_title',
302 302
 					'id'   => 'give_title',
303 303
 				),
304 304
 			);
305 305
 
306
-			return array_merge( $settings, $give_license_settings );
306
+			return array_merge($settings, $give_license_settings);
307 307
 		}
308 308
 
309 309
 		/**
@@ -318,56 +318,56 @@  discard block
 block discarded – undo
318 318
 		 */
319 319
 		public function activate_license() {
320 320
 			// Bailout.
321
-			if( ! $this->__is_user_can_edit_license() ) {
321
+			if ( ! $this->__is_user_can_edit_license()) {
322 322
 				return;
323 323
 			}
324 324
 
325 325
 			// Allow third party addon developers to handle license activation.
326
-			if ( $this->__is_third_party_addon() ) {
327
-				do_action( 'give_activate_license', $this );
326
+			if ($this->__is_third_party_addon()) {
327
+				do_action('give_activate_license', $this);
328 328
 
329 329
 				return;
330 330
 			}
331 331
 
332 332
 			// Delete previous license setting if a empty license key submitted.
333
-			if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
334
-				delete_option( $this->item_shortname . '_license_active' );
333
+			if (empty($_POST[$this->item_shortname.'_license_key'])) {
334
+				delete_option($this->item_shortname.'_license_active');
335 335
 
336 336
 				return;
337 337
 			}
338 338
 
339 339
 			// Do not simultaneously activate add-ons if the user want to deactivate a specific add-on.
340
-			foreach ( $_POST as $key => $value ) {
341
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
340
+			foreach ($_POST as $key => $value) {
341
+				if (false !== strpos($key, 'license_key_deactivate')) {
342 342
 					// Don't activate a key when deactivating a different key
343 343
 					return;
344 344
 				}
345 345
 			}
346 346
 
347 347
 			// Check if plugin previously installed.
348
-			if ( $this->is_valid_license() ) {
348
+			if ($this->is_valid_license()) {
349 349
 				return;
350 350
 			}
351 351
 
352 352
 			// Get license key.
353
-			$this->license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
353
+			$this->license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
354 354
 
355 355
 			// Delete previous license key from subscription if previously added.
356 356
 			$this->__remove_license_key_from_subscriptions();
357 357
 
358 358
 			// Make sure there are no api errors
359
-			if ( ! ( $license_data = $this->get_license_info( 'activate_license' ) ) ) {
359
+			if ( ! ($license_data = $this->get_license_info('activate_license'))) {
360 360
 				return;
361 361
 			}
362 362
 
363 363
 			// Tell WordPress to look for updates
364
-			set_site_transient( 'update_plugins', null );
364
+			set_site_transient('update_plugins', null);
365 365
 
366 366
 			// Add license data.
367
-			update_option( $this->item_shortname . '_license_active', $license_data );
367
+			update_option($this->item_shortname.'_license_active', $license_data);
368 368
 
369 369
 			// Add license key.
370
-			give_update_option( "{$this->item_shortname}_license_key", $this->license );
370
+			give_update_option("{$this->item_shortname}_license_key", $this->license);
371 371
 
372 372
 			// Check subscription for license key and store this to db (if any).
373 373
 			$this->__single_subscription_check();
@@ -385,33 +385,33 @@  discard block
 block discarded – undo
385 385
 		 */
386 386
 		public function deactivate_license() {
387 387
 			// Bailout.
388
-			if( ! $this->__is_user_can_edit_license() ) {
388
+			if ( ! $this->__is_user_can_edit_license()) {
389 389
 				return;
390 390
 			}
391 391
 
392 392
 			// Allow third party add-on developers to handle license deactivation.
393
-			if ( $this->__is_third_party_addon() ) {
394
-				do_action( 'give_deactivate_license', $this );
393
+			if ($this->__is_third_party_addon()) {
394
+				do_action('give_deactivate_license', $this);
395 395
 
396 396
 				return;
397 397
 			}
398 398
 
399 399
 			// Run on deactivate button press
400
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
400
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
401 401
 
402 402
 				// Make sure there are no api errors
403
-				if ( ! ( $license_data = $this->get_license_info( 'deactivate_license' ) ) ) {
403
+				if ( ! ($license_data = $this->get_license_info('deactivate_license'))) {
404 404
 					return;
405 405
 				}
406 406
 
407 407
 				// Ensure deactivated successfully.
408
-				if ( isset( $license_data->success ) ) {
408
+				if (isset($license_data->success)) {
409 409
 
410 410
 					// Remove license data.
411
-					delete_option( $this->item_shortname . '_license_active' );
411
+					delete_option($this->item_shortname.'_license_active');
412 412
 
413 413
 					// Delete licence data.
414
-					give_delete_option( $this->item_shortname . '_license_key' );
414
+					give_delete_option($this->item_shortname.'_license_key');
415 415
 
416 416
 					// Remove license key from subscriptions if exist.
417 417
 					$this->__remove_license_key_from_subscriptions();
@@ -431,25 +431,25 @@  discard block
 block discarded – undo
431 431
 		public function weekly_license_check() {
432 432
 
433 433
 			if (
434
-				! empty( $_POST['give_settings'] ) ||
435
-				empty( $this->license )
434
+				! empty($_POST['give_settings']) ||
435
+				empty($this->license)
436 436
 			) {
437 437
 				return;
438 438
 			}
439 439
 
440 440
 			// Allow third party add-on developers to handle their license check.
441
-			if ( $this->__is_third_party_addon() ) {
442
-				do_action( 'give_weekly_license_check', $this );
441
+			if ($this->__is_third_party_addon()) {
442
+				do_action('give_weekly_license_check', $this);
443 443
 
444 444
 				return;
445 445
 			}
446 446
 
447 447
 			// Make sure there are no api errors
448
-			if ( ! ( $license_data = $this->get_license_info( 'check_license' ) ) ) {
448
+			if ( ! ($license_data = $this->get_license_info('check_license'))) {
449 449
 				return;
450 450
 			}
451 451
 
452
-			update_option( $this->item_shortname . '_license_active', $license_data );
452
+			update_option($this->item_shortname.'_license_active', $license_data);
453 453
 
454 454
 			return;
455 455
 		}
@@ -465,21 +465,21 @@  discard block
 block discarded – undo
465 465
 		public function weekly_subscription_check() {
466 466
 			// Bailout.
467 467
 			if (
468
-				! empty( $_POST['give_settings'] ) ||
469
-				empty( $this->license )
468
+				! empty($_POST['give_settings']) ||
469
+				empty($this->license)
470 470
 			) {
471 471
 				return;
472 472
 			}
473 473
 
474 474
 			// Remove old subscription data.
475
-			if ( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp', 1 ) ) {
476
-				delete_option( 'give_subscriptions' );
477
-				update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp', 1 ) ) );
475
+			if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) {
476
+				delete_option('give_subscriptions');
477
+				update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1)));
478 478
 			}
479 479
 
480 480
 			// Allow third party add-on developers to handle their subscription check.
481
-			if ( $this->__is_third_party_addon() ) {
482
-				do_action( 'give_weekly_subscription_check', $this );
481
+			if ($this->__is_third_party_addon()) {
482
+				do_action('give_weekly_subscription_check', $this);
483 483
 
484 484
 				return;
485 485
 			}
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 		 * @return void
497 497
 		 */
498 498
 		private function __single_subscription_check() {
499
-			if ( empty( $this->license ) ) {
499
+			if (empty($this->license)) {
500 500
 				return;
501 501
 			}
502 502
 
@@ -504,29 +504,29 @@  discard block
 block discarded – undo
504 504
 			// Do not get confused with edd_action check_subscription.
505 505
 			// By default edd software licensing api does not have api to check subscription.
506 506
 			// This is a custom feature to check subscriptions.
507
-			if ( ! ( $subscription_data = $this->get_license_info( 'check_subscription', true ) ) ) {
507
+			if ( ! ($subscription_data = $this->get_license_info('check_subscription', true))) {
508 508
 				return;
509 509
 			}
510 510
 
511 511
 
512
-			if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
513
-				$subscriptions = get_option( 'give_subscriptions', array() );
512
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
513
+				$subscriptions = get_option('give_subscriptions', array());
514 514
 
515 515
 				// Update subscription data only if subscription does not exist already.
516
-				$subscriptions[ $subscription_data['id'] ]            = $subscription_data;
516
+				$subscriptions[$subscription_data['id']] = $subscription_data;
517 517
 
518 518
 
519 519
 				// Initiate default set of license for subscription.
520
-				if( ! isset( $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
521
-					$subscriptions[ $subscription_data['id']]['licenses'] = array();
520
+				if ( ! isset($subscriptions[$subscription_data['id']]['licenses'])) {
521
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
522 522
 				}
523 523
 
524 524
 				// Store licenses for subscription.
525
-				if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
526
-					$subscriptions[ $subscription_data['id']]['licenses'][] = $this->license;
525
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
526
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
527 527
 				}
528 528
 
529
-				update_option( 'give_subscriptions', $subscriptions );
529
+				update_option('give_subscriptions', $subscriptions);
530 530
 			}
531 531
 		}
532 532
 
@@ -540,12 +540,12 @@  discard block
 block discarded – undo
540 540
 		 */
541 541
 		public function notices() {
542 542
 
543
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
543
+			if ( ! current_user_can('manage_give_settings')) {
544 544
 				return;
545 545
 			}
546 546
 
547 547
 			// Do not show licenses notices on license tab.
548
-			if ( 'licenses' === give_get_current_setting_tab() ) {
548
+			if ('licenses' === give_get_current_setting_tab()) {
549 549
 				return;
550 550
 			}
551 551
 
@@ -554,112 +554,112 @@  discard block
 block discarded – undo
554 554
 			static $addon_license_key_in_subscriptions;
555 555
 
556 556
 			// Set default value.
557
-			$addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array();
557
+			$addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array();
558 558
 			$messages                           = array();
559 559
 
560 560
 			if (
561
-				empty( $this->license )
562
-				&& empty( $showed_invalid_message )
561
+				empty($this->license)
562
+				&& empty($showed_invalid_message)
563 563
 			) {
564 564
 
565
-				Give()->notices->register_notice( array(
565
+				Give()->notices->register_notice(array(
566 566
 					'id'               => 'give-invalid-license',
567 567
 					'type'             => 'error',
568 568
 					'description'      => sprintf(
569
-						__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
570
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
569
+						__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
570
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
571 571
 					),
572 572
 					'dismissible_type' => 'user',
573 573
 					'dismiss_interval' => 'shortly',
574
-				) );
574
+				));
575 575
 
576 576
 				$showed_invalid_message = true;
577 577
 
578 578
 			}
579 579
 
580 580
 			// Get subscriptions.
581
-			$subscriptions = get_option( 'give_subscriptions' );
581
+			$subscriptions = get_option('give_subscriptions');
582 582
 
583 583
 			// Show subscription messages.
584
-			if ( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) {
584
+			if ( ! empty($subscriptions) && ! $showed_subscriptions_message) {
585 585
 
586
-				foreach ( $subscriptions as $subscription ) {
586
+				foreach ($subscriptions as $subscription) {
587 587
 					// Subscription expires timestamp.
588
-					$subscription_expires = strtotime( $subscription['expires'] );
588
+					$subscription_expires = strtotime($subscription['expires']);
589 589
 
590 590
 					// Start showing subscriptions message before one week of renewal date.
591
-					if ( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) {
591
+					if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) {
592 592
 						continue;
593 593
 					}
594 594
 
595 595
 					// Check if subscription message already exist in messages.
596
-					if ( array_key_exists( $subscription['id'], $messages ) ) {
596
+					if (array_key_exists($subscription['id'], $messages)) {
597 597
 						continue;
598 598
 					}
599 599
 
600 600
 					// Check if license already expired.
601
-					if ( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {
602
-						Give()->notices->register_notice( array(
601
+					if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {
602
+						Give()->notices->register_notice(array(
603 603
 							'id'               => "give-expired-subscription-{$subscription['id']}",
604 604
 							'type'             => 'error',
605 605
 							'description'      => sprintf(
606
-								__( 'Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give' ),
607
-								urldecode( $subscription['invoice_url'] ),
606
+								__('Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give'),
607
+								urldecode($subscription['invoice_url']),
608 608
 								$subscription['payment_id'],
609 609
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
610 610
 								Give()->notices->get_dismiss_link(array(
611
-									'title' => __( 'Click here if already renewed', 'give' ),
611
+									'title' => __('Click here if already renewed', 'give'),
612 612
 									'dismissible_type'      => 'user',
613 613
 									'dismiss_interval'      => 'permanent',
614 614
 								))
615 615
 							),
616 616
 							'dismissible_type' => 'user',
617 617
 							'dismiss_interval' => 'shortly',
618
-						) );
618
+						));
619 619
 					} else {
620
-						Give()->notices->register_notice( array(
620
+						Give()->notices->register_notice(array(
621 621
 							'id'               => "give-expires-subscription-{$subscription['id']}",
622 622
 							'type'             => 'error',
623 623
 							'description'      => sprintf(
624
-								__( 'Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give' ),
625
-								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
626
-								urldecode( $subscription['invoice_url'] ),
624
+								__('Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give'),
625
+								human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])),
626
+								urldecode($subscription['invoice_url']),
627 627
 								$subscription['payment_id'],
628 628
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
629 629
 								Give()->notices->get_dismiss_link(array(
630
-									'title' => __( 'Click here if already renewed', 'give' ),
630
+									'title' => __('Click here if already renewed', 'give'),
631 631
 									'dismissible_type'      => 'user',
632 632
 									'dismiss_interval'      => 'permanent',
633 633
 								))
634 634
 							),
635 635
 							'dismissible_type' => 'user',
636 636
 							'dismiss_interval' => 'shortly',
637
-						) );
637
+						));
638 638
 					}
639 639
 
640 640
 					// Stop validation for these license keys.
641
-					$addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] );
641
+					$addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']);
642 642
 				}// End foreach().
643 643
 				$showed_subscriptions_message = true;
644 644
 			}// End if().
645 645
 
646 646
 			// Show non subscription addon messages.
647 647
 			if (
648
-				! in_array( $this->license, $addon_license_key_in_subscriptions )
648
+				! in_array($this->license, $addon_license_key_in_subscriptions)
649 649
 				&& ! $this->is_valid_license()
650
-				&& empty( $showed_invalid_message )
650
+				&& empty($showed_invalid_message)
651 651
 			) {
652 652
 
653
-				Give()->notices->register_notice( array(
653
+				Give()->notices->register_notice(array(
654 654
 					'id'               => 'give-invalid-license',
655 655
 					'type'             => 'error',
656 656
 					'description'      => sprintf(
657
-						__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
658
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
657
+						__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
658
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
659 659
 					),
660 660
 					'dismissible_type' => 'user',
661 661
 					'dismiss_interval' => 'shortly',
662
-				) );
662
+				));
663 663
 
664 664
 				$showed_invalid_message = true;
665 665
 
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 		 * @return bool
676 676
 		 */
677 677
 		public function is_valid_license() {
678
-			if ( apply_filters( 'give_is_valid_license', ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' ) && 'valid' === $this->license_data->license ) ) ) {
678
+			if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) {
679 679
 				return true;
680 680
 			}
681 681
 
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 		 * @return bool
692 692
 		 */
693 693
 		private function __is_third_party_addon() {
694
-			return ( false === strpos( $this->api_url, 'givewp.com/' ) );
694
+			return (false === strpos($this->api_url, 'givewp.com/'));
695 695
 		}
696 696
 
697 697
 		/**
@@ -706,25 +706,25 @@  discard block
 block discarded – undo
706 706
 		 * @return bool
707 707
 		 */
708 708
 		private function __remove_license_key_from_subscriptions() {
709
-			$subscriptions = get_option( 'give_subscriptions', array() );
709
+			$subscriptions = get_option('give_subscriptions', array());
710 710
 
711 711
 			// Bailout.
712
-			if ( empty( $this->license ) ) {
712
+			if (empty($this->license)) {
713 713
 				return false;
714 714
 			}
715 715
 
716
-			if ( ! empty( $subscriptions ) ) {
717
-				foreach ( $subscriptions as $subscription_id => $subscription ) {
718
-					$license_index = array_search( $this->license, $subscription['licenses'] );
719
-					if ( false !== $license_index ) {
716
+			if ( ! empty($subscriptions)) {
717
+				foreach ($subscriptions as $subscription_id => $subscription) {
718
+					$license_index = array_search($this->license, $subscription['licenses']);
719
+					if (false !== $license_index) {
720 720
 						// Remove license key.
721
-						unset( $subscriptions[ $subscription_id ]['licenses'][ $license_index ] );
721
+						unset($subscriptions[$subscription_id]['licenses'][$license_index]);
722 722
 
723 723
 						// Rearrange license keys.
724
-						$subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] );
724
+						$subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']);
725 725
 
726 726
 						// Update subscription information.
727
-						update_option( 'give_subscriptions', $subscriptions );
727
+						update_option('give_subscriptions', $subscriptions);
728 728
 						break;
729 729
 					}
730 730
 				}
@@ -738,17 +738,17 @@  discard block
 block discarded – undo
738 738
 		 *
739 739
 		 * @return bool
740 740
 		 */
741
-		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
741
+		public function plugin_page_notices($plugin_file, $plugin_data, $status) {
742 742
 			// Bailout.
743
-			if ( $this->is_valid_license() ) {
743
+			if ($this->is_valid_license()) {
744 744
 				return false;
745 745
 			}
746 746
 
747 747
 			$update_notice_wrap = '<tr class="give-addon-notice-tr active"><td colspan="3" class="colspanchange"><div class="notice inline notice-warning notice-alt give-invalid-license"><p><span class="dashicons dashicons-info"></span> %s</p></div></td></tr>';
748 748
 			$message            = $this->license_state_message();
749 749
 
750
-			if ( ! empty( $message['message'] ) ) {
751
-				echo sprintf( $update_notice_wrap, $message['message'] );
750
+			if ( ! empty($message['message'])) {
751
+				echo sprintf($update_notice_wrap, $message['message']);
752 752
 			}
753 753
 		}
754 754
 
@@ -763,11 +763,11 @@  discard block
 block discarded – undo
763 763
 		public function license_state_message() {
764 764
 			$message_data = array();
765 765
 
766
-			if ( ! $this->is_valid_license() ) {
766
+			if ( ! $this->is_valid_license()) {
767 767
 
768 768
 				$message_data['message'] = sprintf(
769 769
 					'Please <a href="%1$s">activate your license</a> to receive updates and support for the %2$s add-on.',
770
-					esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) ),
770
+					esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')),
771 771
 					$this->item_name
772 772
 				);
773 773
 			}
@@ -782,18 +782,18 @@  discard block
 block discarded – undo
782 782
 		 * @since 1.8.9
783 783
 		 * @access private
784 784
 		 */
785
-		private function __is_user_can_edit_license(){
785
+		private function __is_user_can_edit_license() {
786 786
 			// Bailout.
787 787
 			if (
788
-				empty( $_POST[ $this->item_shortname . '_license_key' ] ) ||
789
-				! current_user_can( 'manage_give_settings' )
788
+				empty($_POST[$this->item_shortname.'_license_key']) ||
789
+				! current_user_can('manage_give_settings')
790 790
 			) {
791 791
 				return false;
792 792
 			}
793 793
 
794 794
 			// Security check.
795
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
796
-				wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
795
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
796
+				wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
797 797
 			}
798 798
 
799 799
 			return true;
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
 		 *
812 812
 		 * @return mixed
813 813
 		 */
814
-		public function get_license_info( $edd_action = '', $response_in_array = false ) {
815
-			if( empty( $edd_action ) ) {
814
+		public function get_license_info($edd_action = '', $response_in_array = false) {
815
+			if (empty($edd_action)) {
816 816
 				return false;
817 817
 			}
818 818
 
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 			$api_params = array(
821 821
 				'edd_action' => $edd_action, // never change from "edd_" to "give_"!
822 822
 				'license'    => $this->license,
823
-				'item_name'  => urlencode( $this->item_name ),
823
+				'item_name'  => urlencode($this->item_name),
824 824
 				'url'        => home_url(),
825 825
 			);
826 826
 
@@ -835,11 +835,11 @@  discard block
 block discarded – undo
835 835
 			);
836 836
 
837 837
 			// Make sure there are no errors
838
-			if ( is_wp_error( $response ) ) {
838
+			if (is_wp_error($response)) {
839 839
 				return false;
840 840
 			}
841 841
 
842
-			return json_decode( wp_remote_retrieve_body( $response ), $response_in_array );
842
+			return json_decode(wp_remote_retrieve_body($response), $response_in_array);
843 843
 		}
844 844
 	}
845 845
 
Please login to merge, or discard this patch.
includes/class-notices.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -435,7 +435,7 @@
 block discarded – undo
435 435
 	 * @since  1.8.9
436 436
 	 * @access public
437 437
 	 *
438
-	 * @param $errors
438
+	 * @param string $errors
439 439
 	 */
440 440
 	static function print_frontend_errors( $errors ) {
441 441
 		if ( ! $errors ) {
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 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,12 +53,12 @@  discard block
 block discarded – undo
53 53
 	 * @since 1.0
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
 	/**
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return bool
73 73
 	 */
74
-	public function register_notice( $notice_args ) {
74
+	public function register_notice($notice_args) {
75 75
 		// Bailout.
76
-		if ( empty( $notice_args['id'] ) || array_key_exists( $notice_args['id'], self::$notices ) ) {
76
+		if (empty($notice_args['id']) || array_key_exists($notice_args['id'], self::$notices)) {
77 77
 			return false;
78 78
 		}
79 79
 
@@ -100,36 +100,36 @@  discard block
 block discarded – undo
100 100
 		);
101 101
 
102 102
 		// Set extra dismiss links if any.
103
-		if ( false !== strpos( $notice_args['description'], 'data-dismiss-interval' ) ) {
103
+		if (false !== strpos($notice_args['description'], 'data-dismiss-interval')) {
104 104
 
105
-			preg_match_all( "/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link );
105
+			preg_match_all("/data-([^\"]*)=\"([^\"]*)\"/", $notice_args['description'], $extra_notice_dismiss_link);
106 106
 
107
-			if ( ! empty( $extra_notice_dismiss_link ) ) {
108
-				$extra_notice_dismiss_links = array_chunk( current( $extra_notice_dismiss_link ), 3 );
109
-				foreach ( $extra_notice_dismiss_links as $extra_notice_dismiss_link ) {
107
+			if ( ! empty($extra_notice_dismiss_link)) {
108
+				$extra_notice_dismiss_links = array_chunk(current($extra_notice_dismiss_link), 3);
109
+				foreach ($extra_notice_dismiss_links as $extra_notice_dismiss_link) {
110 110
 					// Create array og key ==> value by parsing query string created after renaming data attributes.
111
-					$data_attribute_query_str = str_replace( array( 'data-', '-', '"' ), array(
111
+					$data_attribute_query_str = str_replace(array('data-', '-', '"'), array(
112 112
 						'',
113 113
 						'_',
114 114
 						'',
115
-					), implode( '&', $extra_notice_dismiss_link ) );
115
+					), implode('&', $extra_notice_dismiss_link));
116 116
 
117
-					$notice_args['extra_links'][] = wp_parse_args( $data_attribute_query_str );
117
+					$notice_args['extra_links'][] = wp_parse_args($data_attribute_query_str);
118 118
 				}
119 119
 			}
120 120
 		}
121 121
 
122 122
 
123
-		self::$notices[ $notice_args['id'] ] = $notice_args;
123
+		self::$notices[$notice_args['id']] = $notice_args;
124 124
 
125 125
 		// Auto set show param if not already set.
126
-		if ( ! isset( self::$notices[ $notice_args['id'] ]['show'] ) ) {
127
-			self::$notices[ $notice_args['id'] ]['show'] = $this->is_notice_dismissed( $notice_args ) ? false : true;
126
+		if ( ! isset(self::$notices[$notice_args['id']]['show'])) {
127
+			self::$notices[$notice_args['id']]['show'] = $this->is_notice_dismissed($notice_args) ? false : true;
128 128
 		}
129 129
 
130 130
 		// Auto set time interval for shortly.
131
-		if ( 'shortly' === self::$notices[ $notice_args['id'] ]['dismiss_interval'] ) {
132
-			self::$notices[ $notice_args['id'] ]['dismiss_interval_time'] = DAY_IN_SECONDS;
131
+		if ('shortly' === self::$notices[$notice_args['id']]['dismiss_interval']) {
132
+			self::$notices[$notice_args['id']]['dismiss_interval_time'] = DAY_IN_SECONDS;
133 133
 		}
134 134
 
135 135
 		return true;
@@ -143,44 +143,44 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	public function render_admin_notices() {
145 145
 		// Bailout.
146
-		if ( empty( self::$notices ) ) {
146
+		if (empty(self::$notices)) {
147 147
 			return;
148 148
 		}
149 149
 
150 150
 		$output = '';
151 151
 
152
-		foreach ( self::$notices as $notice_id => $notice ) {
152
+		foreach (self::$notices as $notice_id => $notice) {
153 153
 			// Check flag set to true to show notice.
154
-			if ( ! $notice['show'] ) {
154
+			if ( ! $notice['show']) {
155 155
 				continue;
156 156
 			}
157 157
 
158 158
 			// Check if notice dismissible or not.
159
-			if ( ! self::$has_auto_dismissible_notice ) {
159
+			if ( ! self::$has_auto_dismissible_notice) {
160 160
 				self::$has_auto_dismissible_notice = $notice['auto_dismissible'];
161 161
 			}
162 162
 
163 163
 			// Check if notice dismissible or not.
164
-			if ( ! self::$has_dismiss_interval_notice ) {
164
+			if ( ! self::$has_dismiss_interval_notice) {
165 165
 				self::$has_dismiss_interval_notice = $notice['dismiss_interval'];
166 166
 			}
167 167
 
168
-			$css_id = ( false === strpos( $notice['id'], 'give' ) ? "give-{$notice['id']}" : $notice['id'] );
168
+			$css_id = (false === strpos($notice['id'], 'give') ? "give-{$notice['id']}" : $notice['id']);
169 169
 
170 170
 			$css_class = "give-notice notice is-dismissible {$notice['type']} notice-{$notice['type']}";
171
-			$output    .= sprintf(
172
-				'<div id="%1$s" class="%2$s" data-auto-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">' . " \n",
171
+			$output .= sprintf(
172
+				'<div id="%1$s" class="%2$s" data-auto-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">'." \n",
173 173
 				$css_id,
174 174
 				$css_class,
175 175
 				$notice['auto_dismissible'],
176 176
 				$notice['dismissible_type'],
177 177
 				$notice['dismiss_interval'],
178 178
 				$notice['id'],
179
-				empty( $notice['dismissible_type'] ) ? '' : wp_create_nonce( "give_edit_{$notice_id}_notice" ),
179
+				empty($notice['dismissible_type']) ? '' : wp_create_nonce("give_edit_{$notice_id}_notice"),
180 180
 				$notice['dismiss_interval_time']
181 181
 			);
182 182
 
183
-			$output .= ( 0 === strpos( $notice['description'], '<div' ) || 0 === strpos( $notice['description'], '<p' ) ? $notice['description'] : "<p>{$notice['description']}</p>" );
183
+			$output .= (0 === strpos($notice['description'], '<div') || 0 === strpos($notice['description'], '<p') ? $notice['description'] : "<p>{$notice['description']}</p>");
184 184
 			$output .= "</div> \n";
185 185
 		}
186 186
 
@@ -198,18 +198,18 @@  discard block
 block discarded – undo
198 198
 	 *
199 199
 	 * @param int $form_id
200 200
 	 */
201
-	public function render_frontend_notices( $form_id = 0 ) {
201
+	public function render_frontend_notices($form_id = 0) {
202 202
 		$errors = give_get_errors();
203 203
 
204
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? intval( $_REQUEST['form-id'] ) : 0;
204
+		$request_form_id = isset($_REQUEST['form-id']) ? intval($_REQUEST['form-id']) : 0;
205 205
 
206 206
 		// Sanity checks first: Ensure that gateway returned errors display on the appropriate form.
207
-		if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) {
207
+		if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) {
208 208
 			return;
209 209
 		}
210 210
 
211
-		if ( $errors ) {
212
-			self::print_frontend_errors( $errors );
211
+		if ($errors) {
212
+			self::print_frontend_errors($errors);
213 213
 
214 214
 			give_clear_errors();
215 215
 		}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 * @access private
223 223
 	 */
224 224
 	private function print_js() {
225
-		if ( self::$has_auto_dismissible_notice ) :
225
+		if (self::$has_auto_dismissible_notice) :
226 226
 			?>
227 227
 			<script>
228 228
 				jQuery(document).ready(function () {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 			<?php
239 239
 		endif;
240 240
 
241
-		if ( self::$has_dismiss_interval_notice ) :
241
+		if (self::$has_dismiss_interval_notice) :
242 242
 			?>
243 243
 			<script>
244 244
 				jQuery(document).ready(function () {
@@ -304,29 +304,29 @@  discard block
 block discarded – undo
304 304
 	 * @access public
305 305
 	 */
306 306
 	public function dismiss_notices() {
307
-		$_post     = give_clean( $_POST );
308
-		$notice_id = esc_attr( $_post['notice_id'] );
307
+		$_post     = give_clean($_POST);
308
+		$notice_id = esc_attr($_post['notice_id']);
309 309
 
310 310
 		// Bailout.
311 311
 		if (
312
-			empty( $notice_id ) ||
313
-			empty( $_post['dismissible_type'] ) ||
314
-			empty( $_post['dismiss_interval'] ) ||
315
-			! check_ajax_referer( "give_edit_{$notice_id}_notice", '_wpnonce' )
312
+			empty($notice_id) ||
313
+			empty($_post['dismissible_type']) ||
314
+			empty($_post['dismiss_interval']) ||
315
+			! check_ajax_referer("give_edit_{$notice_id}_notice", '_wpnonce')
316 316
 		) {
317 317
 			wp_send_json_error();
318 318
 		}
319 319
 
320
-		$notice_key = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'] );
321
-		if ( 'user' === $_post['dismissible_type'] ) {
320
+		$notice_key = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval']);
321
+		if ('user' === $_post['dismissible_type']) {
322 322
 			$current_user = wp_get_current_user();
323
-			$notice_key   = Give()->notices->get_notice_key( $notice_id, $_post['dismiss_interval'], $current_user->ID );
323
+			$notice_key   = Give()->notices->get_notice_key($notice_id, $_post['dismiss_interval'], $current_user->ID);
324 324
 		}
325 325
 
326
-		$notice_dismiss_time = ! empty( $_post['dismiss_interval_time'] ) ? $_post['dismiss_interval_time'] : null;
326
+		$notice_dismiss_time = ! empty($_post['dismiss_interval_time']) ? $_post['dismiss_interval_time'] : null;
327 327
 
328 328
 		// Save option to hide notice.
329
-		Give_Cache::set( $notice_key, true, $notice_dismiss_time, true );
329
+		Give_Cache::set($notice_key, true, $notice_dismiss_time, true);
330 330
 
331 331
 		wp_send_json_success();
332 332
 	}
@@ -344,18 +344,18 @@  discard block
 block discarded – undo
344 344
 	 *
345 345
 	 * @return string
346 346
 	 */
347
-	public function get_notice_key( $notice_id, $dismiss_interval = null, $user_id = 0 ) {
347
+	public function get_notice_key($notice_id, $dismiss_interval = null, $user_id = 0) {
348 348
 		$notice_key = "_give_notice_{$notice_id}";
349 349
 
350
-		if ( ! empty( $dismiss_interval ) ) {
350
+		if ( ! empty($dismiss_interval)) {
351 351
 			$notice_key .= "_{$dismiss_interval}";
352 352
 		}
353 353
 
354
-		if ( $user_id ) {
354
+		if ($user_id) {
355 355
 			$notice_key .= "_{$user_id}";
356 356
 		}
357 357
 
358
-		$notice_key = sanitize_key( $notice_key );
358
+		$notice_key = sanitize_key($notice_key);
359 359
 
360 360
 		return $notice_key;
361 361
 	}
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
 	 *
369 369
 	 * @return string
370 370
 	 */
371
-	public function get_dismiss_link( $notice_args ) {
371
+	public function get_dismiss_link($notice_args) {
372 372
 		$notice_args = wp_parse_args(
373 373
 			$notice_args,
374 374
 			array(
375
-				'title'                 => __( 'Click here', 'give' ),
375
+				'title'                 => __('Click here', 'give'),
376 376
 				'dismissible_type'      => '',
377 377
 				'dismiss_interval'      => '',
378 378
 				'dismiss_interval_time' => null,
@@ -399,31 +399,31 @@  discard block
 block discarded – undo
399 399
 	 *
400 400
 	 * @return bool|null
401 401
 	 */
402
-	public function is_notice_dismissed( $notice ) {
403
-		$notice_key          = $this->get_notice_key( $notice['id'], $notice['dismiss_interval'] );
402
+	public function is_notice_dismissed($notice) {
403
+		$notice_key          = $this->get_notice_key($notice['id'], $notice['dismiss_interval']);
404 404
 		$is_notice_dismissed = false;
405 405
 
406
-		if ( 'user' === $notice['dismissible_type'] ) {
406
+		if ('user' === $notice['dismissible_type']) {
407 407
 			$current_user = wp_get_current_user();
408
-			$notice_key   = Give()->notices->get_notice_key( $notice['id'], $notice['dismiss_interval'], $current_user->ID );
408
+			$notice_key   = Give()->notices->get_notice_key($notice['id'], $notice['dismiss_interval'], $current_user->ID);
409 409
 		}
410 410
 
411
-		$notice_data = Give_Cache::get( $notice_key, true );
411
+		$notice_data = Give_Cache::get($notice_key, true);
412 412
 
413 413
 		// Find notice dismiss link status if notice has extra dismissible links.
414
-		if ( ( empty( $notice_data ) || is_wp_error( $notice_data ) ) && ! empty( $notice['extra_links'] ) ) {
414
+		if ((empty($notice_data) || is_wp_error($notice_data)) && ! empty($notice['extra_links'])) {
415 415
 
416
-			foreach ( $notice['extra_links'] as $extra_link ) {
417
-				$new_notice_data = wp_parse_args( $extra_link, $notice );
418
-				unset( $new_notice_data['extra_links'] );
416
+			foreach ($notice['extra_links'] as $extra_link) {
417
+				$new_notice_data = wp_parse_args($extra_link, $notice);
418
+				unset($new_notice_data['extra_links']);
419 419
 
420
-				if ( $is_notice_dismissed = $this->is_notice_dismissed( $new_notice_data ) ) {
420
+				if ($is_notice_dismissed = $this->is_notice_dismissed($new_notice_data)) {
421 421
 					return $is_notice_dismissed;
422 422
 				}
423 423
 			}
424 424
 		}
425 425
 
426
-		$is_notice_dismissed = ! empty( $notice_data ) && ! is_wp_error( $notice_data );
426
+		$is_notice_dismissed = ! empty($notice_data) && ! is_wp_error($notice_data);
427 427
 
428 428
 		return $is_notice_dismissed;
429 429
 	}
@@ -437,21 +437,21 @@  discard block
 block discarded – undo
437 437
 	 *
438 438
 	 * @param $errors
439 439
 	 */
440
-	static function print_frontend_errors( $errors ) {
441
-		if ( ! $errors ) {
440
+	static function print_frontend_errors($errors) {
441
+		if ( ! $errors) {
442 442
 			return;
443 443
 		}
444 444
 
445 445
 		// Note: we will remove give_errors class in future.
446
-		$classes = apply_filters( 'give_error_class', array( 'give_notices', 'give_errors' ) );
446
+		$classes = apply_filters('give_error_class', array('give_notices', 'give_errors'));
447 447
 
448
-		echo sprintf( '<div class="%s">', implode( ' ', $classes ) );
448
+		echo sprintf('<div class="%s">', implode(' ', $classes));
449 449
 
450 450
 		// Loop error codes and display errors.
451
-		foreach ( $errors as $error_id => $error ) {
452
-			echo sprintf( '<div class="give_error" id="give_error_%1$s"><p><strong>%2$s</strong>: %3$s</p></div>',
451
+		foreach ($errors as $error_id => $error) {
452
+			echo sprintf('<div class="give_error" id="give_error_%1$s"><p><strong>%2$s</strong>: %3$s</p></div>',
453 453
 				$error_id,
454
-				esc_html__( 'Error', 'give' ),
454
+				esc_html__('Error', 'give'),
455 455
 				$error
456 456
 			);
457 457
 		}
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 	 *
473 473
 	 * @return  string
474 474
 	 */
475
-	static function print_frontend_notice( $message, $echo = true, $notice_type = 'warning' ) {
476
-		if ( empty( $message ) ) {
475
+	static function print_frontend_notice($message, $echo = true, $notice_type = 'warning') {
476
+		if (empty($message)) {
477 477
 			return '';
478 478
 		}
479 479
 
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 			$message
485 485
 		);
486 486
 
487
-		if ( ! $echo ) {
487
+		if ( ! $echo) {
488 488
 			return $error;
489 489
 		}
490 490
 
Please login to merge, or discard this patch.
includes/login-register.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
  * @param string $user_login Username
175 175
  * @param string $user_pass  Password
176 176
  *
177
- * @return bool
177
+ * @return false|null
178 178
  */
179 179
 function give_log_user_in( $user_id, $user_login, $user_pass ) {
180 180
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
  *
216 216
  * @param array $data Data sent from the register form
217 217
  *
218
- * @return bool
218
+ * @return false|null
219 219
  */
220 220
 function give_process_register_form( $data ) {
221 221
 
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,23 +26,23 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return string Login form
28 28
  */
29
-function give_login_form( $login_redirect = '', $logout_redirect = '' ) {
30
-	if ( empty( $login_redirect ) ) {
31
-		$login_redirect = add_query_arg( 'give-login-success', 'true', give_get_current_page_url() );
29
+function give_login_form($login_redirect = '', $logout_redirect = '') {
30
+	if (empty($login_redirect)) {
31
+		$login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url());
32 32
 	}
33 33
 
34
-	if ( empty( $logout_redirect ) ) {
35
-		$logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
34
+	if (empty($logout_redirect)) {
35
+		$logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url());
36 36
 	}
37 37
 
38 38
 	// Add user_logout action to logout url.
39 39
 	$logout_redirect = add_query_arg(
40 40
 		array(
41 41
 			'give_action'          => 'user_logout',
42
-			'give_logout_nonce'    => wp_create_nonce( 'give-logout-nonce' ),
43
-			'give_logout_redirect' => urlencode( $logout_redirect ),
42
+			'give_logout_nonce'    => wp_create_nonce('give-logout-nonce'),
43
+			'give_logout_redirect' => urlencode($logout_redirect),
44 44
 		),
45
-		home_url( '/' )
45
+		home_url('/')
46 46
 	);
47 47
 
48 48
 	ob_start();
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		)
56 56
 	);
57 57
 
58
-	return apply_filters( 'give_login_form', ob_get_clean() );
58
+	return apply_filters('give_login_form', ob_get_clean());
59 59
 }
60 60
 
61 61
 /**
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
  *
69 69
  * @return string Register form
70 70
  */
71
-function give_register_form( $redirect = '' ) {
72
-	if ( empty( $redirect ) ) {
71
+function give_register_form($redirect = '') {
72
+	if (empty($redirect)) {
73 73
 		$redirect = give_get_current_page_url();
74 74
 	}
75 75
 
76 76
 	ob_start();
77 77
 
78
-	if ( ! is_user_logged_in() ) {
78
+	if ( ! is_user_logged_in()) {
79 79
 		give_get_template(
80 80
 			'shortcode-register',
81 81
 			array(
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 	}
86 86
 
87
-	return apply_filters( 'give_register_form', ob_get_clean() );
87
+	return apply_filters('give_register_form', ob_get_clean());
88 88
 }
89 89
 
90 90
 /**
@@ -96,34 +96,34 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return void
98 98
  */
99
-function give_process_login_form( $data ) {
100
-	if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) {
101
-		$user_data = get_user_by( 'login', $data['give_user_login'] );
102
-		if ( ! $user_data ) {
103
-			$user_data = get_user_by( 'email', $data['give_user_login'] );
99
+function give_process_login_form($data) {
100
+	if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) {
101
+		$user_data = get_user_by('login', $data['give_user_login']);
102
+		if ( ! $user_data) {
103
+			$user_data = get_user_by('email', $data['give_user_login']);
104 104
 		}
105
-		if ( $user_data ) {
105
+		if ($user_data) {
106 106
 			$user_ID    = $user_data->ID;
107 107
 			$user_email = $user_data->user_email;
108
-			if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_ID ) ) {
109
-				give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] );
108
+			if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_ID)) {
109
+				give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']);
110 110
 			} else {
111
-				give_set_error( 'password_incorrect', __( 'The password you entered is incorrect.', 'give' ) );
111
+				give_set_error('password_incorrect', __('The password you entered is incorrect.', 'give'));
112 112
 			}
113 113
 		} else {
114
-			give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
114
+			give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
115 115
 		}
116 116
 		// Check for errors and redirect if none present
117 117
 		$errors = give_get_errors();
118
-		if ( ! $errors ) {
119
-			$redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID );
120
-			wp_redirect( $redirect );
118
+		if ( ! $errors) {
119
+			$redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID);
120
+			wp_redirect($redirect);
121 121
 			give_die();
122 122
 		}
123 123
 	}
124 124
 }
125 125
 
126
-add_action( 'give_user_login', 'give_process_login_form' );
126
+add_action('give_user_login', 'give_process_login_form');
127 127
 
128 128
 
129 129
 /**
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
  *
136 136
  * @return void
137 137
  */
138
-function give_process_user_logout( $data ) {
139
-	if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) {
138
+function give_process_user_logout($data) {
139
+	if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) {
140 140
 
141 141
 		// Prevent occurring of any custom action on wp_logout.
142
-		remove_all_actions( 'wp_logout' );
142
+		remove_all_actions('wp_logout');
143 143
 
144 144
 		/**
145 145
 		 * Fires before processing user logout.
146 146
 		 *
147 147
 		 * @since 1.0
148 148
 		 */
149
-		do_action( 'give_before_user_logout' );
149
+		do_action('give_before_user_logout');
150 150
 
151 151
 		// Logout user.
152 152
 		wp_logout();
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
 		 *
157 157
 		 * @since 1.0
158 158
 		 */
159
-		do_action( 'give_after_user_logout' );
159
+		do_action('give_after_user_logout');
160 160
 
161
-		wp_redirect( $data['give_logout_redirect'] );
161
+		wp_redirect($data['give_logout_redirect']);
162 162
 		give_die();
163 163
 	}
164 164
 }
165 165
 
166
-add_action( 'give_user_logout', 'give_process_user_logout' );
166
+add_action('give_user_logout', 'give_process_user_logout');
167 167
 
168 168
 /**
169 169
  * Log User In
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
  *
177 177
  * @return bool
178 178
  */
179
-function give_log_user_in( $user_id, $user_login, $user_pass ) {
179
+function give_log_user_in($user_id, $user_login, $user_pass) {
180 180
 
181
-	if ( $user_id < 1 ) {
181
+	if ($user_id < 1) {
182 182
 		return false;
183 183
 	}
184 184
 
185
-	wp_set_auth_cookie( $user_id );
186
-	wp_set_current_user( $user_id, $user_login );
185
+	wp_set_auth_cookie($user_id);
186
+	wp_set_current_user($user_id, $user_login);
187 187
 
188 188
 	/**
189 189
 	 * Fires after the user has successfully logged in.
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * @param string  $user_login Username.
194 194
 	 * @param WP_User $$user      WP_User object of the logged-in user.
195 195
 	 */
196
-	do_action( 'wp_login', $user_login, get_userdata( $user_id ) );
196
+	do_action('wp_login', $user_login, get_userdata($user_id));
197 197
 
198 198
 	/**
199 199
 	 * Fires after give user has successfully logged in.
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @param string $user_login Username.
205 205
 	 * @param string $user_pass  User password.
206 206
 	 */
207
-	do_action( 'give_log_user_in', $user_id, $user_login, $user_pass );
207
+	do_action('give_log_user_in', $user_id, $user_login, $user_pass);
208 208
 }
209 209
 
210 210
 
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return bool
219 219
  */
220
-function give_process_register_form( $data ) {
220
+function give_process_register_form($data) {
221 221
 
222
-	if ( is_user_logged_in() ) {
222
+	if (is_user_logged_in()) {
223 223
 		return false;
224 224
 	}
225 225
 
226
-	if ( empty( $_POST['give_register_submit'] ) ) {
226
+	if (empty($_POST['give_register_submit'])) {
227 227
 		return false;
228 228
 	}
229 229
 
@@ -232,38 +232,38 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @since 1.0
234 234
 	 */
235
-	do_action( 'give_pre_process_register_form' );
235
+	do_action('give_pre_process_register_form');
236 236
 
237
-	if ( empty( $data['give_user_login'] ) ) {
238
-		give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) );
237
+	if (empty($data['give_user_login'])) {
238
+		give_set_error('empty_username', esc_html__('Invalid username.', 'give'));
239 239
 	}
240 240
 
241
-	if ( username_exists( $data['give_user_login'] ) ) {
242
-		give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
241
+	if (username_exists($data['give_user_login'])) {
242
+		give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
243 243
 	}
244 244
 
245
-	if ( ! validate_username( $data['give_user_login'] ) ) {
246
-		give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
245
+	if ( ! validate_username($data['give_user_login'])) {
246
+		give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
247 247
 	}
248 248
 
249
-	if ( email_exists( $data['give_user_email'] ) ) {
250
-		give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) );
249
+	if (email_exists($data['give_user_email'])) {
250
+		give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give'));
251 251
 	}
252 252
 
253
-	if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) {
254
-		give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
253
+	if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) {
254
+		give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
255 255
 	}
256 256
 
257
-	if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) {
258
-		give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) );
257
+	if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) {
258
+		give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give'));
259 259
 	}
260 260
 
261
-	if ( empty( $_POST['give_user_pass'] ) ) {
262
-		give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) );
261
+	if (empty($_POST['give_user_pass'])) {
262
+		give_set_error('empty_password', esc_html__('Please enter a password.', 'give'));
263 263
 	}
264 264
 
265
-	if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) {
266
-		give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
265
+	if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) {
266
+		give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
267 267
 	}
268 268
 
269 269
 	/**
@@ -271,26 +271,26 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * @since 1.0
273 273
 	 */
274
-	do_action( 'give_process_register_form' );
274
+	do_action('give_process_register_form');
275 275
 
276 276
 	// Check for errors and redirect if none present
277 277
 	$errors = give_get_errors();
278 278
 
279
-	if ( empty( $errors ) ) {
279
+	if (empty($errors)) {
280 280
 
281
-		$redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] );
281
+		$redirect = apply_filters('give_register_redirect', $data['give_redirect']);
282 282
 
283
-		give_register_and_login_new_user( array(
283
+		give_register_and_login_new_user(array(
284 284
 			'user_login'      => $data['give_user_login'],
285 285
 			'user_pass'       => $data['give_user_pass'],
286 286
 			'user_email'      => $data['give_user_email'],
287
-			'user_registered' => date( 'Y-m-d H:i:s' ),
288
-			'role'            => get_option( 'default_role' ),
289
-		) );
287
+			'user_registered' => date('Y-m-d H:i:s'),
288
+			'role'            => get_option('default_role'),
289
+		));
290 290
 
291
-		wp_redirect( $redirect );
291
+		wp_redirect($redirect);
292 292
 		give_die();
293 293
 	}
294 294
 }
295 295
 
296
-add_action( 'give_user_register', 'give_process_register_form' );
296
+add_action('give_user_register', 'give_process_register_form');
Please login to merge, or discard this patch.
includes/payments/class-payment-stats.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param  $end_date   string|bool  The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month`
37 37
 	 * @param  $status     string|array The sale status(es) to count. Only valid when retrieving global stats
38 38
 	 *
39
-	 * @return float|int                Total amount of donations based on the passed arguments.
39
+	 * @return string                Total amount of donations based on the passed arguments.
40 40
 	 */
41 41
 	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
42 42
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @param  $end_date    string|bool The end date for which we'd like to filter the donations stats. If false, method will use the default end date of `this_month`.
84 84
 	 * @param  $gateway_id  string|bool The gateway to get earnings for such as 'paypal' or 'stripe'.
85 85
 	 *
86
-	 * @return float|int                Total amount of donations based on the passed arguments.
86
+	 * @return string                Total amount of donations based on the passed arguments.
87 87
 	 */
88 88
 	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
89 89
 		$this->setup_dates( $start_date, $end_date );
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * @param  $end_date    string|bool The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month`
169 169
 	 * @param  $gateway_id  string|bool The gateway to get earnings for such as 'paypal' or 'stripe'
170 170
 	 *
171
-	 * @return float|int                Total amount of donations based on the passed arguments.
171
+	 * @return string                Total amount of donations based on the passed arguments.
172 172
 	 */
173 173
 	public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
174 174
 
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 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
 
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return float|int                Total amount of donations based on the passed arguments.
40 40
 	 */
41
-	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
41
+	public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') {
42 42
 
43
-		$this->setup_dates( $start_date, $end_date );
43
+		$this->setup_dates($start_date, $end_date);
44 44
 
45 45
 		// Make sure start date is valid
46
-		if ( is_wp_error( $this->start_date ) ) {
46
+		if (is_wp_error($this->start_date)) {
47 47
 			return $this->start_date;
48 48
 		}
49 49
 
50 50
 		// Make sure end date is valid
51
-		if ( is_wp_error( $this->end_date ) ) {
51
+		if (is_wp_error($this->end_date)) {
52 52
 			return $this->end_date;
53 53
 		}
54 54
 
@@ -57,18 +57,18 @@  discard block
 block discarded – undo
57 57
 			'start_date' => $this->start_date,
58 58
 			'end_date'   => $this->end_date,
59 59
 			'fields'     => 'ids',
60
-			'number'     => - 1,
60
+			'number'     => -1,
61 61
 		);
62 62
 
63
-		if ( ! empty( $form_id ) ) {
63
+		if ( ! empty($form_id)) {
64 64
 			$args['give_forms'] = $form_id;
65 65
 		}
66 66
 
67 67
 		/* @var Give_Payments_Query $payments */
68
-		$payments = new Give_Payments_Query( $args );
68
+		$payments = new Give_Payments_Query($args);
69 69
 		$payments = $payments->get_payments();
70 70
 
71
-		return count( $payments );
71
+		return count($payments);
72 72
 	}
73 73
 
74 74
 
@@ -85,16 +85,16 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return float|int                Total amount of donations based on the passed arguments.
87 87
 	 */
88
-	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
89
-		$this->setup_dates( $start_date, $end_date );
88
+	public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
89
+		$this->setup_dates($start_date, $end_date);
90 90
 
91 91
 		// Make sure start date is valid
92
-		if ( is_wp_error( $this->start_date ) ) {
92
+		if (is_wp_error($this->start_date)) {
93 93
 			return $this->start_date;
94 94
 		}
95 95
 
96 96
 		// Make sure end date is valid
97
-		if ( is_wp_error( $this->end_date ) ) {
97
+		if (is_wp_error($this->end_date)) {
98 98
 			return $this->end_date;
99 99
 		}
100 100
 
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 			'start_date' => $this->start_date,
105 105
 			'end_date'   => $this->end_date,
106 106
 			'fields'     => 'ids',
107
-			'number'     => - 1,
107
+			'number'     => -1,
108 108
 		);
109 109
 
110 110
 
111 111
 		// Filter by Gateway ID meta_key
112
-		if ( $gateway_id ) {
112
+		if ($gateway_id) {
113 113
 			$args['meta_query'][] = array(
114 114
 				'key'   => '_give_payment_gateway',
115 115
 				'value' => $gateway_id,
@@ -117,43 +117,43 @@  discard block
 block discarded – undo
117 117
 		}
118 118
 
119 119
 		// Filter by Gateway ID meta_key
120
-		if ( $form_id ) {
120
+		if ($form_id) {
121 121
 			$args['meta_query'][] = array(
122 122
 				'key'   => '_give_payment_form_id',
123 123
 				'value' => $form_id,
124 124
 			);
125 125
 		}
126 126
 
127
-		if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) {
127
+		if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) {
128 128
 			$args['meta_query']['relation'] = 'AND';
129 129
 		}
130 130
 
131
-		$args = apply_filters( 'give_stats_earnings_args', $args );
132
-		$key  = Give_Cache::get_key( 'give_stats', $args );
131
+		$args = apply_filters('give_stats_earnings_args', $args);
132
+		$key  = Give_Cache::get_key('give_stats', $args);
133 133
 
134 134
 		//Set transient for faster stats
135
-		$earnings = Give_Cache::get( $key );
135
+		$earnings = Give_Cache::get($key);
136 136
 
137
-		if ( false === $earnings ) {
137
+		if (false === $earnings) {
138 138
 
139 139
 			$this->timestamp = false;
140
-			$payments        = new Give_Payments_Query( $args );
140
+			$payments        = new Give_Payments_Query($args);
141 141
 			$payments        = $payments->get_payments();
142 142
 			$earnings        = 0;
143 143
 
144
-			if ( ! empty( $payments ) ) {
145
-				foreach ( $payments as $payment ) {
146
-					$earnings += give_get_payment_amount( $payment->ID );
144
+			if ( ! empty($payments)) {
145
+				foreach ($payments as $payment) {
146
+					$earnings += give_get_payment_amount($payment->ID);
147 147
 				}
148 148
 
149 149
 			}
150 150
 
151 151
 			// Cache the results for one hour
152
-			Give_Cache::set( $key, $earnings, 60 * 60 );
152
+			Give_Cache::set($key, $earnings, 60 * 60);
153 153
 		}
154 154
 
155 155
 		//return earnings
156
-		return round( $earnings, give_currency_decimal_filter() );
156
+		return round($earnings, give_currency_decimal_filter());
157 157
 
158 158
 	}
159 159
 
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @return float|int                Total amount of donations based on the passed arguments.
172 172
 	 */
173
-	public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
173
+	public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
174 174
 
175
-		$this->setup_dates( $start_date, $end_date );
175
+		$this->setup_dates($start_date, $end_date);
176 176
 
177 177
 		// Make sure start date is valid
178
-		if ( is_wp_error( $this->start_date ) ) {
178
+		if (is_wp_error($this->start_date)) {
179 179
 			return $this->start_date;
180 180
 		}
181 181
 
182 182
 		// Make sure end date is valid
183
-		if ( is_wp_error( $this->end_date ) ) {
183
+		if (is_wp_error($this->end_date)) {
184 184
 			return $this->end_date;
185 185
 		}
186 186
 
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 			'start_date' => $this->start_date,
191 191
 			'end_date'   => $this->end_date,
192 192
 			'fields'     => 'ids',
193
-			'number'     => - 1,
193
+			'number'     => -1,
194 194
 		);
195 195
 
196 196
 
197 197
 		// Filter by Gateway ID meta_key
198
-		if ( $gateway_id ) {
198
+		if ($gateway_id) {
199 199
 			$args['meta_query'][] = array(
200 200
 				'key'   => '_give_payment_gateway',
201 201
 				'value' => $gateway_id,
@@ -203,19 +203,19 @@  discard block
 block discarded – undo
203 203
 		}
204 204
 
205 205
 		// Filter by Gateway ID meta_key
206
-		if ( $form_id ) {
206
+		if ($form_id) {
207 207
 			$args['meta_query'][] = array(
208 208
 				'key'   => '_give_payment_form_id',
209 209
 				'value' => $form_id,
210 210
 			);
211 211
 		}
212 212
 
213
-		if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) {
213
+		if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) {
214 214
 			$args['meta_query']['relation'] = 'AND';
215 215
 		}
216 216
 
217
-		$args = apply_filters( 'give_stats_earnings_args', $args );
218
-		$key  = Give_Cache::get_key( 'give_stats', $args );
217
+		$args = apply_filters('give_stats_earnings_args', $args);
218
+		$key  = Give_Cache::get_key('give_stats', $args);
219 219
 
220 220
 		//return earnings
221 221
 		return $key;
@@ -232,16 +232,16 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @return array       Best selling forms
234 234
 	 */
235
-	public function get_best_selling( $number = 10 ) {
235
+	public function get_best_selling($number = 10) {
236 236
 
237 237
 		global $wpdb;
238 238
 
239
-		$give_forms = $wpdb->get_results( $wpdb->prepare(
239
+		$give_forms = $wpdb->get_results($wpdb->prepare(
240 240
 			"SELECT post_id as form_id, max(meta_value) as sales
241 241
 				FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0
242 242
 				GROUP BY meta_value+0
243 243
 				DESC LIMIT %d;", $number
244
-		) );
244
+		));
245 245
 
246 246
 		return $give_forms;
247 247
 	}
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
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
  * @param  int $year      Year number. Default is null.
682 682
  * @param  int $hour      Hour number. Default is null.
683 683
  *
684
- * @return int $earnings  Earnings
684
+ * @return double $earnings  Earnings
685 685
  */
686 686
 function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
687 687
 
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
  *
971 971
  * @param int $payment_id Payment ID.
972 972
  *
973
- * @return array $user_info User Info Meta Values.
973
+ * @return string $user_info User Info Meta Values.
974 974
  */
975 975
 function give_get_payment_meta_user_info( $payment_id ) {
976 976
 	$payment = new Give_Payment( $payment_id );
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
  *
988 988
  * @param int $payment_id Payment ID.
989 989
  *
990
- * @return int $form_id Form ID.
990
+ * @return string $form_id Form ID.
991 991
  */
992 992
 function give_get_payment_form_id( $payment_id ) {
993 993
 	$payment = new Give_Payment( $payment_id );
Please login to merge, or discard this patch.
Spacing   +404 added lines, -404 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
 	}
118 118
 
119
-	if ( $payment ) {
119
+	if ($payment) {
120 120
 		return $payment;
121 121
 	}
122 122
 
@@ -132,23 +132,23 @@  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
 
141 141
 	$payment    = new Give_Payment();
142
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
143
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
144
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
145
-	$price_id   = give_get_payment_meta_price_id( $payment_data );
146
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
142
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
143
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
144
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
145
+	$price_id   = give_get_payment_meta_price_id($payment_data);
146
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
147 147
 
148 148
 	// Set properties.
149 149
 	$payment->total          = $payment_data['price'];
150
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
151
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency();
150
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
151
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency();
152 152
 	$payment->user_info      = $payment_data['user_info'];
153 153
 	$payment->gateway        = $gateway;
154 154
 	$payment->form_title     = $form_title;
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	$payment->ip             = give_get_ip();
163 163
 	$payment->key            = $payment_data['purchase_key'];
164 164
 	$payment->mode           = give_is_test_mode() ? 'test' : 'live';
165
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
165
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
166 166
 
167 167
 	// Add the donation.
168 168
 	$args = array(
@@ -170,22 +170,22 @@  discard block
 block discarded – undo
170 170
 		'price_id' => $payment->price_id,
171 171
 	);
172 172
 
173
-	$payment->add_donation( $payment->form_id, $args );
173
+	$payment->add_donation($payment->form_id, $args);
174 174
 
175 175
 	// Set date if present.
176
-	if ( isset( $payment_data['post_date'] ) ) {
176
+	if (isset($payment_data['post_date'])) {
177 177
 		$payment->date = $payment_data['post_date'];
178 178
 	}
179 179
 
180 180
 	// Handle sequential payments.
181
-	if ( give_get_option( 'enable_sequential' ) ) {
181
+	if (give_get_option('enable_sequential')) {
182 182
 		$number          = give_get_next_payment_number();
183
-		$payment->number = give_format_payment_number( $number );
184
-		update_option( 'give_last_payment_number', $number );
183
+		$payment->number = give_format_payment_number($number);
184
+		update_option('give_last_payment_number', $number);
185 185
 	}
186 186
 
187 187
 	// Clear the user's donation cache.
188
-	delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' );
188
+	delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases');
189 189
 
190 190
 	// Save payment.
191 191
 	$payment->save();
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	 * @param int   $payment_id   The payment ID.
199 199
 	 * @param array $payment_data Arguments passed.
200 200
 	 */
201
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
201
+	do_action('give_insert_payment', $payment->ID, $payment_data);
202 202
 
203 203
 	// Return payment ID upon success.
204
-	if ( ! empty( $payment->ID ) ) {
204
+	if ( ! empty($payment->ID)) {
205 205
 		return $payment->ID;
206 206
 	}
207 207
 
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return bool|int
219 219
  */
220
-function give_create_payment( $payment_data ) {
220
+function give_create_payment($payment_data) {
221 221
 
222
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
223
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
222
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
223
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
224 224
 
225 225
 	// Collect payment data.
226 226
 	$insert_payment_data = array(
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 	 *
245 245
 	 * @param array $insert_payment_data
246 246
 	 */
247
-	$insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data );
247
+	$insert_payment_data = apply_filters('give_create_payment', $insert_payment_data);
248 248
 
249 249
 	// Record the pending payment.
250
-	return give_insert_payment( $insert_payment_data );
250
+	return give_insert_payment($insert_payment_data);
251 251
 }
252 252
 
253 253
 /**
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
  *
261 261
  * @return bool
262 262
  */
263
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
263
+function give_update_payment_status($payment_id, $new_status = 'publish') {
264 264
 
265
-	$payment         = new Give_Payment( $payment_id );
265
+	$payment         = new Give_Payment($payment_id);
266 266
 	$payment->status = $new_status;
267 267
 	$updated         = $payment->save();
268 268
 
@@ -281,38 +281,38 @@  discard block
 block discarded – undo
281 281
  *
282 282
  * @return void
283 283
  */
284
-function give_delete_donation( $payment_id = 0, $update_donor = true ) {
284
+function give_delete_donation($payment_id = 0, $update_donor = true) {
285 285
 	global $give_logs;
286 286
 
287
-	$payment  = new Give_Payment( $payment_id );
288
-	$amount   = give_get_payment_amount( $payment_id );
287
+	$payment  = new Give_Payment($payment_id);
288
+	$amount   = give_get_payment_amount($payment_id);
289 289
 	$status   = $payment->post_status;
290
-	$donor_id = give_get_payment_donor_id( $payment_id );
291
-	$donor    = new Give_Donor( $donor_id );
290
+	$donor_id = give_get_payment_donor_id($payment_id);
291
+	$donor    = new Give_Donor($donor_id);
292 292
 
293 293
 	// Only undo donations that aren't these statuses.
294
-	$dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array(
294
+	$dont_undo_statuses = apply_filters('give_undo_donation_statuses', array(
295 295
 		'pending',
296 296
 		'cancelled',
297
-	) );
297
+	));
298 298
 
299
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
300
-		give_undo_donation( $payment_id );
299
+	if ( ! in_array($status, $dont_undo_statuses)) {
300
+		give_undo_donation($payment_id);
301 301
 	}
302 302
 
303
-	if ( $status == 'publish' ) {
303
+	if ($status == 'publish') {
304 304
 
305 305
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
306
-		give_decrease_total_earnings( $amount );
306
+		give_decrease_total_earnings($amount);
307 307
 
308 308
 		// @todo: Refresh only range related stat cache
309 309
 		give_delete_donation_stats();
310 310
 
311
-		if ( $donor->id && $update_donor ) {
311
+		if ($donor->id && $update_donor) {
312 312
 
313 313
 			// Decrement the stats for the donor.
314 314
 			$donor->decrease_donation_count();
315
-			$donor->decrease_value( $amount );
315
+			$donor->decrease_value($amount);
316 316
 
317 317
 		}
318 318
 	}
@@ -324,25 +324,25 @@  discard block
 block discarded – undo
324 324
 	 *
325 325
 	 * @param int $payment_id Payment ID.
326 326
 	 */
327
-	do_action( 'give_payment_delete', $payment_id );
327
+	do_action('give_payment_delete', $payment_id);
328 328
 
329
-	if ( $donor->id && $update_donor ) {
329
+	if ($donor->id && $update_donor) {
330 330
 
331 331
 		// Remove the payment ID from the donor.
332
-		$donor->remove_payment( $payment_id );
332
+		$donor->remove_payment($payment_id);
333 333
 
334 334
 	}
335 335
 
336 336
 	// Remove the payment.
337
-	wp_delete_post( $payment_id, true );
337
+	wp_delete_post($payment_id, true);
338 338
 
339 339
 	// Remove related sale log entries.
340
-	$give_logs->delete_logs( null, 'sale', array(
340
+	$give_logs->delete_logs(null, 'sale', array(
341 341
 		array(
342 342
 			'key'   => '_give_log_payment_id',
343 343
 			'value' => $payment_id,
344 344
 		),
345
-	) );
345
+	));
346 346
 
347 347
 	/**
348 348
 	 * Fires after payment deleted.
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	 *
352 352
 	 * @param int $payment_id Payment ID.
353 353
 	 */
354
-	do_action( 'give_payment_deleted', $payment_id );
354
+	do_action('give_payment_deleted', $payment_id);
355 355
 }
356 356
 
357 357
 /**
@@ -366,20 +366,20 @@  discard block
 block discarded – undo
366 366
  *
367 367
  * @return void
368 368
  */
369
-function give_undo_donation( $payment_id ) {
369
+function give_undo_donation($payment_id) {
370 370
 
371
-	$payment = new Give_Payment( $payment_id );
371
+	$payment = new Give_Payment($payment_id);
372 372
 
373
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
374
-	if ( true === $maybe_decrease_earnings ) {
373
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
374
+	if (true === $maybe_decrease_earnings) {
375 375
 		// Decrease earnings.
376
-		give_decrease_earnings( $payment->form_id, $payment->total );
376
+		give_decrease_earnings($payment->form_id, $payment->total);
377 377
 	}
378 378
 
379
-	$maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id );
380
-	if ( true === $maybe_decrease_donations ) {
379
+	$maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id);
380
+	if (true === $maybe_decrease_donations) {
381 381
 		// Decrease donation count.
382
-		give_decrease_donation_count( $payment->form_id );
382
+		give_decrease_donation_count($payment->form_id);
383 383
 	}
384 384
 
385 385
 }
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
  *
397 397
  * @return object $stats Contains the number of payments per payment status.
398 398
  */
399
-function give_count_payments( $args = array() ) {
399
+function give_count_payments($args = array()) {
400 400
 
401 401
 	global $wpdb;
402 402
 
@@ -408,18 +408,18 @@  discard block
 block discarded – undo
408 408
 		'form_id'    => null,
409 409
 	);
410 410
 
411
-	$args = wp_parse_args( $args, $defaults );
411
+	$args = wp_parse_args($args, $defaults);
412 412
 
413 413
 	$select = 'SELECT p.post_status,count( * ) AS num_posts';
414 414
 	$join   = '';
415 415
 	$where  = "WHERE p.post_type = 'give_payment'";
416 416
 
417 417
 	// Count payments for a specific user.
418
-	if ( ! empty( $args['user'] ) ) {
418
+	if ( ! empty($args['user'])) {
419 419
 
420
-		if ( is_email( $args['user'] ) ) {
420
+		if (is_email($args['user'])) {
421 421
 			$field = 'email';
422
-		} elseif ( is_numeric( $args['user'] ) ) {
422
+		} elseif (is_numeric($args['user'])) {
423 423
 			$field = 'id';
424 424
 		} else {
425 425
 			$field = '';
@@ -427,106 +427,106 @@  discard block
 block discarded – undo
427 427
 
428 428
 		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
429 429
 
430
-		if ( ! empty( $field ) ) {
430
+		if ( ! empty($field)) {
431 431
 			$where .= "
432 432
 				AND m.meta_key = '_give_payment_user_{$field}'
433 433
 				AND m.meta_value = '{$args['user']}'";
434 434
 		}
435 435
 
436 436
 
437
-	} elseif ( ! empty( $args['donor'] ) ) {
437
+	} elseif ( ! empty($args['donor'])) {
438 438
 
439
-		$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
439
+		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
440 440
 		$where .= "
441 441
 			AND m.meta_key = '_give_payment_customer_id'
442 442
 			AND m.meta_value = '{$args['donor']}'";
443 443
 
444 444
 		// Count payments for a search.
445
-	} elseif ( ! empty( $args['s'] ) ) {
445
+	} elseif ( ! empty($args['s'])) {
446 446
 
447
-		if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) {
447
+		if (is_email($args['s']) || strlen($args['s']) == 32) {
448 448
 
449
-			if ( is_email( $args['s'] ) ) {
449
+			if (is_email($args['s'])) {
450 450
 				$field = '_give_payment_user_email';
451 451
 			} else {
452 452
 				$field = '_give_payment_purchase_key';
453 453
 			}
454 454
 
455
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
456
-			$where .= $wpdb->prepare( '
455
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
456
+			$where .= $wpdb->prepare('
457 457
                 AND m.meta_key = %s
458
-                AND m.meta_value = %s', $field, $args['s'] );
458
+                AND m.meta_value = %s', $field, $args['s']);
459 459
 
460
-		} elseif ( '#' == substr( $args['s'], 0, 1 ) ) {
460
+		} elseif ('#' == substr($args['s'], 0, 1)) {
461 461
 
462
-			$search = str_replace( '#:', '', $args['s'] );
463
-			$search = str_replace( '#', '', $search );
462
+			$search = str_replace('#:', '', $args['s']);
463
+			$search = str_replace('#', '', $search);
464 464
 
465 465
 			$select = 'SELECT p.post_status,count( * ) AS num_posts ';
466 466
 			$join   = '';
467
-			$where  = $wpdb->prepare( 'WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search );
467
+			$where  = $wpdb->prepare('WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search);
468 468
 
469 469
 
470
-		} elseif ( is_numeric( $args['s'] ) ) {
470
+		} elseif (is_numeric($args['s'])) {
471 471
 
472
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
473
-			$where .= $wpdb->prepare( "
472
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
473
+			$where .= $wpdb->prepare("
474 474
 				AND m.meta_key = '_give_payment_user_id'
475
-				AND m.meta_value = %d", $args['s'] );
475
+				AND m.meta_value = %d", $args['s']);
476 476
 
477 477
 		} else {
478
-			$search = $wpdb->esc_like( $args['s'] );
479
-			$search = '%' . $search . '%';
478
+			$search = $wpdb->esc_like($args['s']);
479
+			$search = '%'.$search.'%';
480 480
 
481
-			$where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search );
481
+			$where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search);
482 482
 		}
483 483
 	}
484 484
 
485
-	if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) {
486
-		$where .= $wpdb->prepare( ' AND p.post_parent = %d', $args['form_id'] );
485
+	if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) {
486
+		$where .= $wpdb->prepare(' AND p.post_parent = %d', $args['form_id']);
487 487
 	}
488 488
 
489 489
 	// Limit payments count by date.
490
-	if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) {
490
+	if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) {
491 491
 
492
-		$date_parts = explode( '/', $args['start-date'] );
493
-		$month      = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0;
494
-		$day        = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0;
495
-		$year       = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0;
492
+		$date_parts = explode('/', $args['start-date']);
493
+		$month      = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0;
494
+		$day        = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0;
495
+		$year       = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0;
496 496
 
497
-		$is_date = checkdate( $month, $day, $year );
498
-		if ( false !== $is_date ) {
497
+		$is_date = checkdate($month, $day, $year);
498
+		if (false !== $is_date) {
499 499
 
500
-			$date  = new DateTime( $args['start-date'] );
501
-			$where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) );
500
+			$date = new DateTime($args['start-date']);
501
+			$where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d'));
502 502
 
503 503
 		}
504 504
 
505 505
 		// Fixes an issue with the payments list table counts when no end date is specified (with stats class).
506
-		if ( empty( $args['end-date'] ) ) {
506
+		if (empty($args['end-date'])) {
507 507
 			$args['end-date'] = $args['start-date'];
508 508
 		}
509 509
 	}
510 510
 
511
-	if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) {
511
+	if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) {
512 512
 
513
-		$date_parts = explode( '/', $args['end-date'] );
513
+		$date_parts = explode('/', $args['end-date']);
514 514
 
515
-		$month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0;
516
-		$day   = ! empty( $date_parts[1] ) ? $date_parts[1] : 0;
517
-		$year  = ! empty( $date_parts[2] ) ? $date_parts[2] : 0;
515
+		$month = ! empty($date_parts[0]) ? $date_parts[0] : 0;
516
+		$day   = ! empty($date_parts[1]) ? $date_parts[1] : 0;
517
+		$year  = ! empty($date_parts[2]) ? $date_parts[2] : 0;
518 518
 
519
-		$is_date = checkdate( $month, $day, $year );
520
-		if ( false !== $is_date ) {
519
+		$is_date = checkdate($month, $day, $year);
520
+		if (false !== $is_date) {
521 521
 
522
-			$date  = new DateTime( $args['end-date'] );
523
-			$where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) );
522
+			$date = new DateTime($args['end-date']);
523
+			$where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d'));
524 524
 
525 525
 		}
526 526
 	}
527 527
 
528
-	$where = apply_filters( 'give_count_payments_where', $where );
529
-	$join  = apply_filters( 'give_count_payments_join', $join );
528
+	$where = apply_filters('give_count_payments_where', $where);
529
+	$join  = apply_filters('give_count_payments_join', $join);
530 530
 
531 531
 	$query = "$select
532 532
 		FROM $wpdb->posts p
@@ -535,36 +535,36 @@  discard block
 block discarded – undo
535 535
 		GROUP BY p.post_status
536 536
 	";
537 537
 
538
-	$cache_key = md5( $query );
538
+	$cache_key = md5($query);
539 539
 
540
-	$count = wp_cache_get( $cache_key, 'counts' );
541
-	if ( false !== $count ) {
540
+	$count = wp_cache_get($cache_key, 'counts');
541
+	if (false !== $count) {
542 542
 		return $count;
543 543
 	}
544 544
 
545
-	$count = $wpdb->get_results( $query, ARRAY_A );
545
+	$count = $wpdb->get_results($query, ARRAY_A);
546 546
 
547 547
 	$stats    = array();
548 548
 	$statuses = get_post_stati();
549
-	if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) {
550
-		unset( $statuses['private'] );
549
+	if (isset($statuses['private']) && empty($args['s'])) {
550
+		unset($statuses['private']);
551 551
 	}
552 552
 
553
-	foreach ( $statuses as $state ) {
554
-		$stats[ $state ] = 0;
553
+	foreach ($statuses as $state) {
554
+		$stats[$state] = 0;
555 555
 	}
556 556
 
557
-	foreach ( (array) $count as $row ) {
557
+	foreach ((array) $count as $row) {
558 558
 
559
-		if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) {
559
+		if ('private' == $row['post_status'] && empty($args['s'])) {
560 560
 			continue;
561 561
 		}
562 562
 
563
-		$stats[ $row['post_status'] ] = $row['num_posts'];
563
+		$stats[$row['post_status']] = $row['num_posts'];
564 564
 	}
565 565
 
566 566
 	$stats = (object) $stats;
567
-	wp_cache_set( $cache_key, $stats, 'counts' );
567
+	wp_cache_set($cache_key, $stats, 'counts');
568 568
 
569 569
 	return $stats;
570 570
 }
@@ -579,11 +579,11 @@  discard block
 block discarded – undo
579 579
  *
580 580
  * @return bool $exists True if payment exists, false otherwise.
581 581
  */
582
-function give_check_for_existing_payment( $payment_id ) {
582
+function give_check_for_existing_payment($payment_id) {
583 583
 	$exists  = false;
584
-	$payment = new Give_Payment( $payment_id );
584
+	$payment = new Give_Payment($payment_id);
585 585
 
586
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
586
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
587 587
 		$exists = true;
588 588
 	}
589 589
 
@@ -601,31 +601,31 @@  discard block
 block discarded – undo
601 601
  *
602 602
  * @return bool|mixed True if payment status exists, false otherwise.
603 603
  */
604
-function give_get_payment_status( $payment, $return_label = false ) {
604
+function give_get_payment_status($payment, $return_label = false) {
605 605
 
606
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
606
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
607 607
 		return false;
608 608
 	}
609 609
 
610 610
 	$statuses = give_get_payment_statuses();
611 611
 
612
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
612
+	if ( ! is_array($statuses) || empty($statuses)) {
613 613
 		return false;
614 614
 	}
615 615
 
616 616
 	// Get payment object if no already given.
617
-	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID );
617
+	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID);
618 618
 
619
-	if ( array_key_exists( $payment->status, $statuses ) ) {
620
-		if ( true === $return_label ) {
619
+	if (array_key_exists($payment->status, $statuses)) {
620
+		if (true === $return_label) {
621 621
 			// Return translated status label.
622
-			return $statuses[ $payment->status ];
622
+			return $statuses[$payment->status];
623 623
 		} else {
624 624
 			// Account that our 'publish' status is labeled 'Complete'
625 625
 			$post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status;
626 626
 
627 627
 			// Make sure we're matching cases, since they matter
628
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
628
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
629 629
 		}
630 630
 	}
631 631
 
@@ -641,18 +641,18 @@  discard block
 block discarded – undo
641 641
  */
642 642
 function give_get_payment_statuses() {
643 643
 	$payment_statuses = array(
644
-		'pending'     => __( 'Pending', 'give' ),
645
-		'publish'     => __( 'Complete', 'give' ),
646
-		'refunded'    => __( 'Refunded', 'give' ),
647
-		'failed'      => __( 'Failed', 'give' ),
648
-		'cancelled'   => __( 'Cancelled', 'give' ),
649
-		'abandoned'   => __( 'Abandoned', 'give' ),
650
-		'preapproval' => __( 'Pre-Approved', 'give' ),
651
-		'processing'  => __( 'Processing', 'give' ),
652
-		'revoked'     => __( 'Revoked', 'give' ),
644
+		'pending'     => __('Pending', 'give'),
645
+		'publish'     => __('Complete', 'give'),
646
+		'refunded'    => __('Refunded', 'give'),
647
+		'failed'      => __('Failed', 'give'),
648
+		'cancelled'   => __('Cancelled', 'give'),
649
+		'abandoned'   => __('Abandoned', 'give'),
650
+		'preapproval' => __('Pre-Approved', 'give'),
651
+		'processing'  => __('Processing', 'give'),
652
+		'revoked'     => __('Revoked', 'give'),
653 653
 	);
654 654
 
655
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
655
+	return apply_filters('give_payment_statuses', $payment_statuses);
656 656
 }
657 657
 
658 658
 /**
@@ -665,10 +665,10 @@  discard block
 block discarded – undo
665 665
  * @return array $payment_status All the available payment statuses.
666 666
  */
667 667
 function give_get_payment_status_keys() {
668
-	$statuses = array_keys( give_get_payment_statuses() );
669
-	asort( $statuses );
668
+	$statuses = array_keys(give_get_payment_statuses());
669
+	asort($statuses);
670 670
 
671
-	return array_values( $statuses );
671
+	return array_values($statuses);
672 672
 }
673 673
 
674 674
 /**
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
  *
684 684
  * @return int $earnings  Earnings
685 685
  */
686
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
686
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
687 687
 
688 688
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
689 689
 	global $wpdb;
@@ -693,41 +693,41 @@  discard block
 block discarded – undo
693 693
 		'nopaging'               => true,
694 694
 		'year'                   => $year,
695 695
 		'monthnum'               => $month_num,
696
-		'post_status'            => array( 'publish' ),
696
+		'post_status'            => array('publish'),
697 697
 		'fields'                 => 'ids',
698 698
 		'update_post_term_cache' => false,
699 699
 	);
700
-	if ( ! empty( $day ) ) {
700
+	if ( ! empty($day)) {
701 701
 		$args['day'] = $day;
702 702
 	}
703 703
 
704
-	if ( ! empty( $hour ) ) {
704
+	if ( ! empty($hour)) {
705 705
 		$args['hour'] = $hour;
706 706
 	}
707 707
 
708
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
709
-	$key  = Give_Cache::get_key( 'give_stats', $args );
708
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
709
+	$key  = Give_Cache::get_key('give_stats', $args);
710 710
 
711
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
711
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
712 712
 		$earnings = false;
713 713
 	} else {
714
-		$earnings = Give_Cache::get( $key );
714
+		$earnings = Give_Cache::get($key);
715 715
 	}
716 716
 
717
-	if ( false === $earnings ) {
718
-		$donations = get_posts( $args );
717
+	if (false === $earnings) {
718
+		$donations = get_posts($args);
719 719
 		$earnings  = 0;
720
-		if ( $donations ) {
721
-			$donations = implode( ',', $donations );
720
+		if ($donations) {
721
+			$donations = implode(',', $donations);
722 722
 
723
-			$earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" );
723
+			$earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})");
724 724
 
725 725
 		}
726 726
 		// Cache the results for one hour.
727
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
727
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
728 728
 	}
729 729
 
730
-	return round( $earnings, 2 );
730
+	return round($earnings, 2);
731 731
 }
732 732
 
733 733
 /**
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
  *
743 743
  * @return int $count     Sales
744 744
  */
745
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
745
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
746 746
 
747 747
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
748 748
 	$args = array(
@@ -750,14 +750,14 @@  discard block
 block discarded – undo
750 750
 		'nopaging'               => true,
751 751
 		'year'                   => $year,
752 752
 		'fields'                 => 'ids',
753
-		'post_status'            => array( 'publish' ),
753
+		'post_status'            => array('publish'),
754 754
 		'update_post_meta_cache' => false,
755 755
 		'update_post_term_cache' => false,
756 756
 	);
757 757
 
758
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
758
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
759 759
 
760
-	if ( false === $show_free ) {
760
+	if (false === $show_free) {
761 761
 		$args['meta_query'] = array(
762 762
 			array(
763 763
 				'key'     => '_give_payment_total',
@@ -768,33 +768,33 @@  discard block
 block discarded – undo
768 768
 		);
769 769
 	}
770 770
 
771
-	if ( ! empty( $month_num ) ) {
771
+	if ( ! empty($month_num)) {
772 772
 		$args['monthnum'] = $month_num;
773 773
 	}
774 774
 
775
-	if ( ! empty( $day ) ) {
775
+	if ( ! empty($day)) {
776 776
 		$args['day'] = $day;
777 777
 	}
778 778
 
779
-	if ( ! empty( $hour ) ) {
779
+	if ( ! empty($hour)) {
780 780
 		$args['hour'] = $hour;
781 781
 	}
782 782
 
783
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
783
+	$args = apply_filters('give_get_sales_by_date_args', $args);
784 784
 
785
-	$key = Give_Cache::get_key( 'give_stats', $args );
785
+	$key = Give_Cache::get_key('give_stats', $args);
786 786
 
787
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
787
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
788 788
 		$count = false;
789 789
 	} else {
790
-		$count = Give_Cache::get( $key );
790
+		$count = Give_Cache::get($key);
791 791
 	}
792 792
 
793
-	if ( false === $count ) {
794
-		$donations = new WP_Query( $args );
793
+	if (false === $count) {
794
+		$donations = new WP_Query($args);
795 795
 		$count     = (int) $donations->post_count;
796 796
 		// Cache the results for one hour.
797
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
797
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
798 798
 	}
799 799
 
800 800
 	return $count;
@@ -809,19 +809,19 @@  discard block
 block discarded – undo
809 809
  *
810 810
  * @return bool $ret True if complete, false otherwise.
811 811
  */
812
-function give_is_payment_complete( $payment_id ) {
813
-	$payment = new Give_Payment( $payment_id );
812
+function give_is_payment_complete($payment_id) {
813
+	$payment = new Give_Payment($payment_id);
814 814
 
815 815
 	$ret = false;
816 816
 
817
-	if ( $payment->ID > 0 ) {
817
+	if ($payment->ID > 0) {
818 818
 
819
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
819
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
820 820
 			$ret = true;
821 821
 		}
822 822
 	}
823 823
 
824
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
824
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
825 825
 }
826 826
 
827 827
 /**
@@ -847,49 +847,49 @@  discard block
 block discarded – undo
847 847
  *
848 848
  * @return float $total Total earnings.
849 849
  */
850
-function give_get_total_earnings( $recalculate = false ) {
850
+function give_get_total_earnings($recalculate = false) {
851 851
 
852
-	$total = get_option( 'give_earnings_total', 0 );
852
+	$total = get_option('give_earnings_total', 0);
853 853
 
854 854
 	// Calculate total earnings.
855
-	if ( ! $total || $recalculate ) {
855
+	if ( ! $total || $recalculate) {
856 856
 		global $wpdb;
857 857
 
858 858
 		$total = (float) 0;
859 859
 
860
-		$args = apply_filters( 'give_get_total_earnings_args', array(
860
+		$args = apply_filters('give_get_total_earnings_args', array(
861 861
 			'offset' => 0,
862
-			'number' => - 1,
863
-			'status' => array( 'publish' ),
862
+			'number' => -1,
863
+			'status' => array('publish'),
864 864
 			'fields' => 'ids',
865
-		) );
865
+		));
866 866
 
867
-		$payments = give_get_payments( $args );
868
-		if ( $payments ) {
867
+		$payments = give_get_payments($args);
868
+		if ($payments) {
869 869
 
870 870
 			/**
871 871
 			 * If performing a donation, we need to skip the very last payment in the database,
872 872
 			 * since it calls give_increase_total_earnings() on completion,
873 873
 			 * which results in duplicated earnings for the very first donation.
874 874
 			 */
875
-			if ( did_action( 'give_update_payment_status' ) ) {
876
-				array_pop( $payments );
875
+			if (did_action('give_update_payment_status')) {
876
+				array_pop($payments);
877 877
 			}
878 878
 
879
-			if ( ! empty( $payments ) ) {
880
-				$payments = implode( ',', $payments );
881
-				$total    += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" );
879
+			if ( ! empty($payments)) {
880
+				$payments = implode(',', $payments);
881
+				$total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})");
882 882
 			}
883 883
 		}
884 884
 
885
-		update_option( 'give_earnings_total', $total, 'no' );
885
+		update_option('give_earnings_total', $total, 'no');
886 886
 	}
887 887
 
888
-	if ( $total < 0 ) {
888
+	if ($total < 0) {
889 889
 		$total = 0; // Don't ever show negative earnings.
890 890
 	}
891 891
 
892
-	return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) );
892
+	return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter()));
893 893
 }
894 894
 
895 895
 /**
@@ -902,10 +902,10 @@  discard block
 block discarded – undo
902 902
  *
903 903
  * @return float $total  Total earnings.
904 904
  */
905
-function give_increase_total_earnings( $amount = 0 ) {
905
+function give_increase_total_earnings($amount = 0) {
906 906
 	$total = give_get_total_earnings();
907 907
 	$total += $amount;
908
-	update_option( 'give_earnings_total', $total );
908
+	update_option('give_earnings_total', $total);
909 909
 
910 910
 	return $total;
911 911
 }
@@ -919,13 +919,13 @@  discard block
 block discarded – undo
919 919
  *
920 920
  * @return float $total Total earnings.
921 921
  */
922
-function give_decrease_total_earnings( $amount = 0 ) {
922
+function give_decrease_total_earnings($amount = 0) {
923 923
 	$total = give_get_total_earnings();
924 924
 	$total -= $amount;
925
-	if ( $total < 0 ) {
925
+	if ($total < 0) {
926 926
 		$total = 0;
927 927
 	}
928
-	update_option( 'give_earnings_total', $total );
928
+	update_option('give_earnings_total', $total);
929 929
 
930 930
 	return $total;
931 931
 }
@@ -941,10 +941,10 @@  discard block
 block discarded – undo
941 941
  *
942 942
  * @return mixed $meta Payment Meta.
943 943
  */
944
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
945
-	$payment = new Give_Payment( $payment_id );
944
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
945
+	$payment = new Give_Payment($payment_id);
946 946
 
947
-	return $payment->get_meta( $meta_key, $single );
947
+	return $payment->get_meta($meta_key, $single);
948 948
 }
949 949
 
950 950
 /**
@@ -957,10 +957,10 @@  discard block
 block discarded – undo
957 957
  *
958 958
  * @return mixed Meta ID if successful, false if unsuccessful.
959 959
  */
960
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
961
-	$payment = new Give_Payment( $payment_id );
960
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
961
+	$payment = new Give_Payment($payment_id);
962 962
 
963
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
963
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
964 964
 }
965 965
 
966 966
 /**
@@ -972,8 +972,8 @@  discard block
 block discarded – undo
972 972
  *
973 973
  * @return array $user_info User Info Meta Values.
974 974
  */
975
-function give_get_payment_meta_user_info( $payment_id ) {
976
-	$payment = new Give_Payment( $payment_id );
975
+function give_get_payment_meta_user_info($payment_id) {
976
+	$payment = new Give_Payment($payment_id);
977 977
 
978 978
 	return $payment->user_info;
979 979
 }
@@ -989,8 +989,8 @@  discard block
 block discarded – undo
989 989
  *
990 990
  * @return int $form_id Form ID.
991 991
  */
992
-function give_get_payment_form_id( $payment_id ) {
993
-	$payment = new Give_Payment( $payment_id );
992
+function give_get_payment_form_id($payment_id) {
993
+	$payment = new Give_Payment($payment_id);
994 994
 
995 995
 	return $payment->form_id;
996 996
 }
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
  *
1005 1005
  * @return string $email User email.
1006 1006
  */
1007
-function give_get_payment_user_email( $payment_id ) {
1008
-	$payment = new Give_Payment( $payment_id );
1007
+function give_get_payment_user_email($payment_id) {
1008
+	$payment = new Give_Payment($payment_id);
1009 1009
 
1010 1010
 	return $payment->email;
1011 1011
 }
@@ -1019,11 +1019,11 @@  discard block
 block discarded – undo
1019 1019
  *
1020 1020
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
1021 1021
  */
1022
-function give_is_guest_payment( $payment_id ) {
1023
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
1024
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
1022
+function give_is_guest_payment($payment_id) {
1023
+	$payment_user_id  = give_get_payment_user_id($payment_id);
1024
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
1025 1025
 
1026
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
1026
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
1027 1027
 }
1028 1028
 
1029 1029
 /**
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
  *
1036 1036
  * @return int $user_id User ID.
1037 1037
  */
1038
-function give_get_payment_user_id( $payment_id ) {
1039
-	$payment = new Give_Payment( $payment_id );
1038
+function give_get_payment_user_id($payment_id) {
1039
+	$payment = new Give_Payment($payment_id);
1040 1040
 
1041 1041
 	return $payment->user_id;
1042 1042
 }
@@ -1050,8 +1050,8 @@  discard block
 block discarded – undo
1050 1050
  *
1051 1051
  * @return int $payment->customer_id Donor ID.
1052 1052
  */
1053
-function give_get_payment_donor_id( $payment_id ) {
1054
-	$payment = new Give_Payment( $payment_id );
1053
+function give_get_payment_donor_id($payment_id) {
1054
+	$payment = new Give_Payment($payment_id);
1055 1055
 
1056 1056
 	return $payment->customer_id;
1057 1057
 }
@@ -1065,8 +1065,8 @@  discard block
 block discarded – undo
1065 1065
  *
1066 1066
  * @return string $ip User IP.
1067 1067
  */
1068
-function give_get_payment_user_ip( $payment_id ) {
1069
-	$payment = new Give_Payment( $payment_id );
1068
+function give_get_payment_user_ip($payment_id) {
1069
+	$payment = new Give_Payment($payment_id);
1070 1070
 
1071 1071
 	return $payment->ip;
1072 1072
 }
@@ -1080,8 +1080,8 @@  discard block
 block discarded – undo
1080 1080
  *
1081 1081
  * @return string $date The date the payment was completed.
1082 1082
  */
1083
-function give_get_payment_completed_date( $payment_id = 0 ) {
1084
-	$payment = new Give_Payment( $payment_id );
1083
+function give_get_payment_completed_date($payment_id = 0) {
1084
+	$payment = new Give_Payment($payment_id);
1085 1085
 
1086 1086
 	return $payment->completed_date;
1087 1087
 }
@@ -1095,8 +1095,8 @@  discard block
 block discarded – undo
1095 1095
  *
1096 1096
  * @return string $gateway Gateway.
1097 1097
  */
1098
-function give_get_payment_gateway( $payment_id ) {
1099
-	$payment = new Give_Payment( $payment_id );
1098
+function give_get_payment_gateway($payment_id) {
1099
+	$payment = new Give_Payment($payment_id);
1100 1100
 
1101 1101
 	return $payment->gateway;
1102 1102
 }
@@ -1110,8 +1110,8 @@  discard block
 block discarded – undo
1110 1110
  *
1111 1111
  * @return string $currency The currency code.
1112 1112
  */
1113
-function give_get_payment_currency_code( $payment_id = 0 ) {
1114
-	$payment = new Give_Payment( $payment_id );
1113
+function give_get_payment_currency_code($payment_id = 0) {
1114
+	$payment = new Give_Payment($payment_id);
1115 1115
 
1116 1116
 	return $payment->currency;
1117 1117
 }
@@ -1125,10 +1125,10 @@  discard block
 block discarded – undo
1125 1125
  *
1126 1126
  * @return string $currency The currency name.
1127 1127
  */
1128
-function give_get_payment_currency( $payment_id = 0 ) {
1129
-	$currency = give_get_payment_currency_code( $payment_id );
1128
+function give_get_payment_currency($payment_id = 0) {
1129
+	$currency = give_get_payment_currency_code($payment_id);
1130 1130
 
1131
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1131
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1132 1132
 }
1133 1133
 
1134 1134
 /**
@@ -1140,8 +1140,8 @@  discard block
 block discarded – undo
1140 1140
  *
1141 1141
  * @return string $key Donation key.
1142 1142
  */
1143
-function give_get_payment_key( $payment_id = 0 ) {
1144
-	$payment = new Give_Payment( $payment_id );
1143
+function give_get_payment_key($payment_id = 0) {
1144
+	$payment = new Give_Payment($payment_id);
1145 1145
 
1146 1146
 	return $payment->key;
1147 1147
 }
@@ -1157,8 +1157,8 @@  discard block
 block discarded – undo
1157 1157
  *
1158 1158
  * @return string $number Payment order number.
1159 1159
  */
1160
-function give_get_payment_number( $payment_id = 0 ) {
1161
-	$payment = new Give_Payment( $payment_id );
1160
+function give_get_payment_number($payment_id = 0) {
1161
+	$payment = new Give_Payment($payment_id);
1162 1162
 
1163 1163
 	return $payment->number;
1164 1164
 }
@@ -1172,23 +1172,23 @@  discard block
 block discarded – undo
1172 1172
  *
1173 1173
  * @return string      The formatted payment number.
1174 1174
  */
1175
-function give_format_payment_number( $number ) {
1175
+function give_format_payment_number($number) {
1176 1176
 
1177
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1177
+	if ( ! give_get_option('enable_sequential')) {
1178 1178
 		return $number;
1179 1179
 	}
1180 1180
 
1181
-	if ( ! is_numeric( $number ) ) {
1181
+	if ( ! is_numeric($number)) {
1182 1182
 		return $number;
1183 1183
 	}
1184 1184
 
1185
-	$prefix  = give_get_option( 'sequential_prefix' );
1186
-	$number  = absint( $number );
1187
-	$postfix = give_get_option( 'sequential_postfix' );
1185
+	$prefix  = give_get_option('sequential_prefix');
1186
+	$number  = absint($number);
1187
+	$postfix = give_get_option('sequential_postfix');
1188 1188
 
1189
-	$formatted_number = $prefix . $number . $postfix;
1189
+	$formatted_number = $prefix.$number.$postfix;
1190 1190
 
1191
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1191
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1192 1192
 }
1193 1193
 
1194 1194
 /**
@@ -1201,17 +1201,17 @@  discard block
 block discarded – undo
1201 1201
  */
1202 1202
 function give_get_next_payment_number() {
1203 1203
 
1204
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1204
+	if ( ! give_get_option('enable_sequential')) {
1205 1205
 		return false;
1206 1206
 	}
1207 1207
 
1208
-	$number           = get_option( 'give_last_payment_number' );
1209
-	$start            = give_get_option( 'sequential_start', 1 );
1208
+	$number           = get_option('give_last_payment_number');
1209
+	$start            = give_get_option('sequential_start', 1);
1210 1210
 	$increment_number = true;
1211 1211
 
1212
-	if ( false !== $number ) {
1212
+	if (false !== $number) {
1213 1213
 
1214
-		if ( empty( $number ) ) {
1214
+		if (empty($number)) {
1215 1215
 
1216 1216
 			$number           = $start;
1217 1217
 			$increment_number = false;
@@ -1220,24 +1220,24 @@  discard block
 block discarded – undo
1220 1220
 	} else {
1221 1221
 
1222 1222
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason.
1223
-		$payments     = new Give_Payments_Query( array(
1223
+		$payments = new Give_Payments_Query(array(
1224 1224
 			'number'  => 1,
1225 1225
 			'order'   => 'DESC',
1226 1226
 			'orderby' => 'ID',
1227 1227
 			'output'  => 'posts',
1228 1228
 			'fields'  => 'ids',
1229
-		) );
1229
+		));
1230 1230
 		$last_payment = $payments->get_payments();
1231 1231
 
1232
-		if ( ! empty( $last_payment ) ) {
1232
+		if ( ! empty($last_payment)) {
1233 1233
 
1234
-			$number = give_get_payment_number( $last_payment[0] );
1234
+			$number = give_get_payment_number($last_payment[0]);
1235 1235
 
1236 1236
 		}
1237 1237
 
1238
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1238
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1239 1239
 
1240
-			$number = give_remove_payment_prefix_postfix( $number );
1240
+			$number = give_remove_payment_prefix_postfix($number);
1241 1241
 
1242 1242
 		} else {
1243 1243
 
@@ -1246,13 +1246,13 @@  discard block
 block discarded – undo
1246 1246
 		}
1247 1247
 	}
1248 1248
 
1249
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1249
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1250 1250
 
1251
-	if ( $increment_number ) {
1252
-		$number ++;
1251
+	if ($increment_number) {
1252
+		$number++;
1253 1253
 	}
1254 1254
 
1255
-	return apply_filters( 'give_get_next_payment_number', $number );
1255
+	return apply_filters('give_get_next_payment_number', $number);
1256 1256
 }
1257 1257
 
1258 1258
 /**
@@ -1264,25 +1264,25 @@  discard block
 block discarded – undo
1264 1264
  *
1265 1265
  * @return string The new Payment number without prefix and postfix.
1266 1266
  */
1267
-function give_remove_payment_prefix_postfix( $number ) {
1267
+function give_remove_payment_prefix_postfix($number) {
1268 1268
 
1269
-	$prefix  = give_get_option( 'sequential_prefix' );
1270
-	$postfix = give_get_option( 'sequential_postfix' );
1269
+	$prefix  = give_get_option('sequential_prefix');
1270
+	$postfix = give_get_option('sequential_postfix');
1271 1271
 
1272 1272
 	// Remove prefix.
1273
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1273
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1274 1274
 
1275 1275
 	// Remove the postfix.
1276
-	$length      = strlen( $number );
1277
-	$postfix_pos = strrpos( $number, $postfix );
1278
-	if ( false !== $postfix_pos ) {
1279
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1276
+	$length      = strlen($number);
1277
+	$postfix_pos = strrpos($number, $postfix);
1278
+	if (false !== $postfix_pos) {
1279
+		$number = substr_replace($number, '', $postfix_pos, $length);
1280 1280
 	}
1281 1281
 
1282 1282
 	// Ensure it's a whole number.
1283
-	$number = intval( $number );
1283
+	$number = intval($number);
1284 1284
 
1285
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1285
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1286 1286
 
1287 1287
 }
1288 1288
 
@@ -1299,10 +1299,10 @@  discard block
 block discarded – undo
1299 1299
  *
1300 1300
  * @return string $amount Fully formatted payment amount.
1301 1301
  */
1302
-function give_payment_amount( $payment_id = 0 ) {
1303
-	$amount = give_get_payment_amount( $payment_id );
1302
+function give_payment_amount($payment_id = 0) {
1303
+	$amount = give_get_payment_amount($payment_id);
1304 1304
 
1305
-	return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) );
1305
+	return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id));
1306 1306
 }
1307 1307
 
1308 1308
 /**
@@ -1315,11 +1315,11 @@  discard block
 block discarded – undo
1315 1315
  *
1316 1316
  * @return mixed
1317 1317
  */
1318
-function give_get_payment_amount( $payment_id ) {
1318
+function give_get_payment_amount($payment_id) {
1319 1319
 
1320
-	$payment = new Give_Payment( $payment_id );
1320
+	$payment = new Give_Payment($payment_id);
1321 1321
 
1322
-	return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id );
1322
+	return apply_filters('give_payment_amount', floatval($payment->total), $payment_id);
1323 1323
 }
1324 1324
 
1325 1325
 /**
@@ -1336,10 +1336,10 @@  discard block
 block discarded – undo
1336 1336
  *
1337 1337
  * @return array Fully formatted payment subtotal.
1338 1338
  */
1339
-function give_payment_subtotal( $payment_id = 0 ) {
1340
-	$subtotal = give_get_payment_subtotal( $payment_id );
1339
+function give_payment_subtotal($payment_id = 0) {
1340
+	$subtotal = give_get_payment_subtotal($payment_id);
1341 1341
 
1342
-	return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) );
1342
+	return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id));
1343 1343
 }
1344 1344
 
1345 1345
 /**
@@ -1353,8 +1353,8 @@  discard block
 block discarded – undo
1353 1353
  *
1354 1354
  * @return float $subtotal Subtotal for payment (non formatted).
1355 1355
  */
1356
-function give_get_payment_subtotal( $payment_id = 0 ) {
1357
-	$payment = new Give_Payment( $payment_id );
1356
+function give_get_payment_subtotal($payment_id = 0) {
1357
+	$payment = new Give_Payment($payment_id);
1358 1358
 
1359 1359
 	return $payment->subtotal;
1360 1360
 }
@@ -1368,8 +1368,8 @@  discard block
 block discarded – undo
1368 1368
  *
1369 1369
  * @return string The donation ID.
1370 1370
  */
1371
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1372
-	$payment = new Give_Payment( $payment_id );
1371
+function give_get_payment_transaction_id($payment_id = 0) {
1372
+	$payment = new Give_Payment($payment_id);
1373 1373
 
1374 1374
 	return $payment->transaction_id;
1375 1375
 }
@@ -1384,15 +1384,15 @@  discard block
 block discarded – undo
1384 1384
  *
1385 1385
  * @return bool|mixed
1386 1386
  */
1387
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1387
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1388 1388
 
1389
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1389
+	if (empty($payment_id) || empty($transaction_id)) {
1390 1390
 		return false;
1391 1391
 	}
1392 1392
 
1393
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1393
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1394 1394
 
1395
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1395
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1396 1396
 }
1397 1397
 
1398 1398
 /**
@@ -1405,12 +1405,12 @@  discard block
 block discarded – undo
1405 1405
  *
1406 1406
  * @return int $purchase Donation ID.
1407 1407
  */
1408
-function give_get_purchase_id_by_key( $key ) {
1408
+function give_get_purchase_id_by_key($key) {
1409 1409
 	global $wpdb;
1410 1410
 
1411
-	$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 ) );
1411
+	$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));
1412 1412
 
1413
-	if ( $purchase != null ) {
1413
+	if ($purchase != null) {
1414 1414
 		return $purchase;
1415 1415
 	}
1416 1416
 
@@ -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_transaction_id( $key ) {
1431
+function give_get_purchase_id_by_transaction_id($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_transaction_id' 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_transaction_id' 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
 
@@ -1450,19 +1450,19 @@  discard block
 block discarded – undo
1450 1450
  *
1451 1451
  * @return array $notes Donation Notes
1452 1452
  */
1453
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1453
+function give_get_payment_notes($payment_id = 0, $search = '') {
1454 1454
 
1455
-	if ( empty( $payment_id ) && empty( $search ) ) {
1455
+	if (empty($payment_id) && empty($search)) {
1456 1456
 		return false;
1457 1457
 	}
1458 1458
 
1459
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1460
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1459
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1460
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1461 1461
 
1462
-	$notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) );
1462
+	$notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search));
1463 1463
 
1464
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1465
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1464
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1465
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1466 1466
 
1467 1467
 	return $notes;
1468 1468
 }
@@ -1478,8 +1478,8 @@  discard block
 block discarded – undo
1478 1478
  *
1479 1479
  * @return int The new note ID
1480 1480
  */
1481
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1482
-	if ( empty( $payment_id ) ) {
1481
+function give_insert_payment_note($payment_id = 0, $note = '') {
1482
+	if (empty($payment_id)) {
1483 1483
 		return false;
1484 1484
 	}
1485 1485
 
@@ -1491,14 +1491,14 @@  discard block
 block discarded – undo
1491 1491
 	 * @param int    $payment_id Payment ID.
1492 1492
 	 * @param string $note       The note.
1493 1493
 	 */
1494
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1494
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1495 1495
 
1496
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1496
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1497 1497
 		'comment_post_ID'      => $payment_id,
1498 1498
 		'comment_content'      => $note,
1499 1499
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1500
-		'comment_date'         => current_time( 'mysql' ),
1501
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1500
+		'comment_date'         => current_time('mysql'),
1501
+		'comment_date_gmt'     => current_time('mysql', 1),
1502 1502
 		'comment_approved'     => 1,
1503 1503
 		'comment_parent'       => 0,
1504 1504
 		'comment_author'       => '',
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
 		'comment_author_email' => '',
1508 1508
 		'comment_type'         => 'give_payment_note',
1509 1509
 
1510
-	) ) );
1510
+	)));
1511 1511
 
1512 1512
 	/**
1513 1513
 	 * Fires after payment note inserted.
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
 	 * @param int    $payment_id Payment ID.
1519 1519
 	 * @param string $note       The note.
1520 1520
 	 */
1521
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1521
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1522 1522
 
1523 1523
 	return $note_id;
1524 1524
 }
@@ -1533,8 +1533,8 @@  discard block
 block discarded – undo
1533 1533
  *
1534 1534
  * @return bool True on success, false otherwise.
1535 1535
  */
1536
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1537
-	if ( empty( $comment_id ) ) {
1536
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1537
+	if (empty($comment_id)) {
1538 1538
 		return false;
1539 1539
 	}
1540 1540
 
@@ -1546,9 +1546,9 @@  discard block
 block discarded – undo
1546 1546
 	 * @param int $comment_id Note ID.
1547 1547
 	 * @param int $payment_id Payment ID.
1548 1548
 	 */
1549
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1549
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1550 1550
 
1551
-	$ret = wp_delete_comment( $comment_id, true );
1551
+	$ret = wp_delete_comment($comment_id, true);
1552 1552
 
1553 1553
 	/**
1554 1554
 	 * Fires after donation note deleted.
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
 	 * @param int $comment_id Note ID.
1559 1559
 	 * @param int $payment_id Payment ID.
1560 1560
 	 */
1561
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1561
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1562 1562
 
1563 1563
 	return $ret;
1564 1564
 }
@@ -1573,32 +1573,32 @@  discard block
 block discarded – undo
1573 1573
  *
1574 1574
  * @return string
1575 1575
  */
1576
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1576
+function give_get_payment_note_html($note, $payment_id = 0) {
1577 1577
 
1578
-	if ( is_numeric( $note ) ) {
1579
-		$note = get_comment( $note );
1578
+	if (is_numeric($note)) {
1579
+		$note = get_comment($note);
1580 1580
 	}
1581 1581
 
1582
-	if ( ! empty( $note->user_id ) ) {
1583
-		$user = get_userdata( $note->user_id );
1582
+	if ( ! empty($note->user_id)) {
1583
+		$user = get_userdata($note->user_id);
1584 1584
 		$user = $user->display_name;
1585 1585
 	} else {
1586
-		$user = esc_html__( 'System', 'give' );
1586
+		$user = esc_html__('System', 'give');
1587 1587
 	}
1588 1588
 
1589
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1589
+	$date_format = give_date_format().', '.get_option('time_format');
1590 1590
 
1591
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1591
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1592 1592
 		'give-action' => 'delete_payment_note',
1593 1593
 		'note_id'     => $note->comment_ID,
1594 1594
 		'payment_id'  => $payment_id,
1595
-	) ), 'give_delete_payment_note_' . $note->comment_ID );
1595
+	)), 'give_delete_payment_note_'.$note->comment_ID);
1596 1596
 
1597
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1597
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1598 1598
 	$note_html .= '<p>';
1599
-	$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/>';
1599
+	$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/>';
1600 1600
 	$note_html .= $note->comment_content;
1601
-	$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="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>';
1601
+	$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="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>';
1602 1602
 	$note_html .= '</p>';
1603 1603
 	$note_html .= '</div>';
1604 1604
 
@@ -1616,18 +1616,18 @@  discard block
 block discarded – undo
1616 1616
  *
1617 1617
  * @return void
1618 1618
  */
1619
-function give_hide_payment_notes( $query ) {
1620
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1621
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1622
-		if ( ! is_array( $types ) ) {
1623
-			$types = array( $types );
1619
+function give_hide_payment_notes($query) {
1620
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1621
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1622
+		if ( ! is_array($types)) {
1623
+			$types = array($types);
1624 1624
 		}
1625 1625
 		$types[]                           = 'give_payment_note';
1626 1626
 		$query->query_vars['type__not_in'] = $types;
1627 1627
 	}
1628 1628
 }
1629 1629
 
1630
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1630
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1631 1631
 
1632 1632
 /**
1633 1633
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1639,15 +1639,15 @@  discard block
 block discarded – undo
1639 1639
  *
1640 1640
  * @return array $clauses Updated comment clauses.
1641 1641
  */
1642
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1643
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1642
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1643
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1644 1644
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1645 1645
 	}
1646 1646
 
1647 1647
 	return $clauses;
1648 1648
 }
1649 1649
 
1650
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1650
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1651 1651
 
1652 1652
 
1653 1653
 /**
@@ -1660,15 +1660,15 @@  discard block
 block discarded – undo
1660 1660
  *
1661 1661
  * @return string $where
1662 1662
  */
1663
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1663
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1664 1664
 	global $wpdb;
1665 1665
 
1666
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1666
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1667 1667
 
1668 1668
 	return $where;
1669 1669
 }
1670 1670
 
1671
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1671
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1672 1672
 
1673 1673
 
1674 1674
 /**
@@ -1682,32 +1682,32 @@  discard block
 block discarded – undo
1682 1682
  *
1683 1683
  * @return array Array of comment counts.
1684 1684
  */
1685
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1685
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1686 1686
 	global $wpdb, $pagenow;
1687 1687
 
1688
-	if ( 'index.php' != $pagenow ) {
1688
+	if ('index.php' != $pagenow) {
1689 1689
 		return $stats;
1690 1690
 	}
1691 1691
 
1692 1692
 	$post_id = (int) $post_id;
1693 1693
 
1694
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1694
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1695 1695
 		return $stats;
1696 1696
 	}
1697 1697
 
1698
-	$stats = wp_cache_get( "comments-{$post_id}", 'counts' );
1698
+	$stats = wp_cache_get("comments-{$post_id}", 'counts');
1699 1699
 
1700
-	if ( false !== $stats ) {
1700
+	if (false !== $stats) {
1701 1701
 		return $stats;
1702 1702
 	}
1703 1703
 
1704 1704
 	$where = 'WHERE comment_type != "give_payment_note"';
1705 1705
 
1706
-	if ( $post_id > 0 ) {
1707
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1706
+	if ($post_id > 0) {
1707
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1708 1708
 	}
1709 1709
 
1710
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1710
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1711 1711
 
1712 1712
 	$total    = 0;
1713 1713
 	$approved = array(
@@ -1717,30 +1717,30 @@  discard block
 block discarded – undo
1717 1717
 		'trash'        => 'trash',
1718 1718
 		'post-trashed' => 'post-trashed',
1719 1719
 	);
1720
-	foreach ( (array) $count as $row ) {
1720
+	foreach ((array) $count as $row) {
1721 1721
 		// Don't count post-trashed toward totals.
1722
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1722
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1723 1723
 			$total += $row['num_comments'];
1724 1724
 		}
1725
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1726
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1725
+		if (isset($approved[$row['comment_approved']])) {
1726
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1727 1727
 		}
1728 1728
 	}
1729 1729
 
1730 1730
 	$stats['total_comments'] = $total;
1731
-	foreach ( $approved as $key ) {
1732
-		if ( empty( $stats[ $key ] ) ) {
1733
-			$stats[ $key ] = 0;
1731
+	foreach ($approved as $key) {
1732
+		if (empty($stats[$key])) {
1733
+			$stats[$key] = 0;
1734 1734
 		}
1735 1735
 	}
1736 1736
 
1737 1737
 	$stats = (object) $stats;
1738
-	wp_cache_set( "comments-{$post_id}", $stats, 'counts' );
1738
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
1739 1739
 
1740 1740
 	return $stats;
1741 1741
 }
1742 1742
 
1743
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1743
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1744 1744
 
1745 1745
 
1746 1746
 /**
@@ -1753,9 +1753,9 @@  discard block
 block discarded – undo
1753 1753
  *
1754 1754
  * @return string $where Modified where clause.
1755 1755
  */
1756
-function give_filter_where_older_than_week( $where = '' ) {
1756
+function give_filter_where_older_than_week($where = '') {
1757 1757
 	// Payments older than one week.
1758
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1758
+	$start = date('Y-m-d', strtotime('-7 days'));
1759 1759
 	$where .= " AND post_date <= '{$start}'";
1760 1760
 
1761 1761
 	return $where;
@@ -1775,38 +1775,38 @@  discard block
 block discarded – undo
1775 1775
  *
1776 1776
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1777 1777
  */
1778
-function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) {
1778
+function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') {
1779 1779
 
1780
-	$form_id    = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
1781
-	$price_id   = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1782
-	$form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '';
1780
+	$form_id    = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
1781
+	$price_id   = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1782
+	$form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
1783 1783
 
1784
-	if ( $only_level == true ) {
1784
+	if ($only_level == true) {
1785 1785
 		$form_title = '';
1786 1786
 	}
1787 1787
 
1788 1788
 	//If multi-level, append to the form title.
1789
-	if ( give_has_variable_prices( $form_id ) ) {
1789
+	if (give_has_variable_prices($form_id)) {
1790 1790
 
1791 1791
 		//Only add separator if there is a form title.
1792
-		if ( ! empty( $form_title ) ) {
1793
-			$form_title .= ' ' . $separator . ' ';
1792
+		if ( ! empty($form_title)) {
1793
+			$form_title .= ' '.$separator.' ';
1794 1794
 		}
1795 1795
 
1796 1796
 		$form_title .= '<span class="donation-level-text-wrap">';
1797 1797
 
1798
-		if ( $price_id == 'custom' ) {
1799
-			$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
1800
-			$form_title         .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1798
+		if ($price_id == 'custom') {
1799
+			$custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true);
1800
+			$form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1801 1801
 		} else {
1802
-			$form_title .= give_get_price_option_name( $form_id, $price_id );
1802
+			$form_title .= give_get_price_option_name($form_id, $price_id);
1803 1803
 		}
1804 1804
 
1805 1805
 		$form_title .= '</span>';
1806 1806
 
1807 1807
 	}
1808 1808
 
1809
-	return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta );
1809
+	return apply_filters('give_get_payment_form_title', $form_title, $payment_meta);
1810 1810
 
1811 1811
 }
1812 1812
 
@@ -1820,20 +1820,20 @@  discard block
 block discarded – undo
1820 1820
  *
1821 1821
  * @return string $price_id
1822 1822
  */
1823
-function give_get_price_id( $form_id, $price ) {
1823
+function give_get_price_id($form_id, $price) {
1824 1824
 
1825 1825
 	$price_id = 0;
1826 1826
 
1827
-	if ( give_has_variable_prices( $form_id ) ) {
1827
+	if (give_has_variable_prices($form_id)) {
1828 1828
 
1829
-		$levels = maybe_unserialize( give_get_meta( $form_id, '_give_donation_levels', true ) );
1829
+		$levels = maybe_unserialize(give_get_meta($form_id, '_give_donation_levels', true));
1830 1830
 
1831
-		foreach ( $levels as $level ) {
1831
+		foreach ($levels as $level) {
1832 1832
 
1833
-			$level_amount = (float) give_sanitize_amount( $level['_give_amount'] );
1833
+			$level_amount = (float) give_sanitize_amount($level['_give_amount']);
1834 1834
 
1835 1835
 			// Check that this indeed the recurring price.
1836
-			if ( $level_amount == $price ) {
1836
+			if ($level_amount == $price) {
1837 1837
 
1838 1838
 				$price_id = $level['_give_id']['level_id'];
1839 1839
 
@@ -1858,10 +1858,10 @@  discard block
 block discarded – undo
1858 1858
  *
1859 1859
  * @return string
1860 1860
  */
1861
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1862
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1861
+function give_get_form_dropdown($args = array(), $echo = false) {
1862
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1863 1863
 
1864
-	if ( ! $echo ) {
1864
+	if ( ! $echo) {
1865 1865
 		return $form_dropdown_html;
1866 1866
 	}
1867 1867
 
@@ -1878,17 +1878,17 @@  discard block
 block discarded – undo
1878 1878
  *
1879 1879
  * @return string|bool
1880 1880
  */
1881
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1881
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1882 1882
 
1883 1883
 	// Check for give form id.
1884
-	if ( empty( $args['id'] ) ) {
1884
+	if (empty($args['id'])) {
1885 1885
 		return false;
1886 1886
 	}
1887 1887
 
1888
-	$form = new Give_Donate_Form( $args['id'] );
1888
+	$form = new Give_Donate_Form($args['id']);
1889 1889
 
1890 1890
 	// Check if form has variable prices or not.
1891
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1891
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1892 1892
 		return false;
1893 1893
 	}
1894 1894
 
@@ -1896,22 +1896,22 @@  discard block
 block discarded – undo
1896 1896
 	$variable_price_options = array();
1897 1897
 
1898 1898
 	// Check if multi donation form support custom donation or not.
1899
-	if ( $form->is_custom_price_mode() ) {
1900
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1899
+	if ($form->is_custom_price_mode()) {
1900
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1901 1901
 	}
1902 1902
 
1903 1903
 	// Get variable price and ID from variable price array.
1904
-	foreach ( $variable_prices as $variable_price ) {
1905
-		$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'] ) );
1904
+	foreach ($variable_prices as $variable_price) {
1905
+		$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']));
1906 1906
 	}
1907 1907
 
1908 1908
 	// Update options.
1909
-	$args = array_merge( $args, array( 'options' => $variable_price_options ) );
1909
+	$args = array_merge($args, array('options' => $variable_price_options));
1910 1910
 
1911 1911
 	// Generate select html.
1912
-	$form_dropdown_html = Give()->html->select( $args );
1912
+	$form_dropdown_html = Give()->html->select($args);
1913 1913
 
1914
-	if ( ! $echo ) {
1914
+	if ( ! $echo) {
1915 1915
 		return $form_dropdown_html;
1916 1916
 	}
1917 1917
 
@@ -1930,16 +1930,16 @@  discard block
 block discarded – undo
1930 1930
  *
1931 1931
  * @return string
1932 1932
  */
1933
-function give_get_payment_meta_price_id( $payment_meta ) {
1933
+function give_get_payment_meta_price_id($payment_meta) {
1934 1934
 
1935
-	if ( isset( $payment_meta['give_price_id'] ) ) {
1935
+	if (isset($payment_meta['give_price_id'])) {
1936 1936
 		$price_id = $payment_meta['give_price_id'];
1937
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
1937
+	} elseif (isset($payment_meta['price_id'])) {
1938 1938
 		$price_id = $payment_meta['price_id'];
1939 1939
 	} else {
1940
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1940
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1941 1941
 	}
1942 1942
 
1943
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id );
1943
+	return apply_filters('give_get_payment_meta_price_id', $price_id);
1944 1944
 
1945 1945
 }
1946 1946
\ No newline at end of file
Please login to merge, or discard this patch.