Completed
Pull Request — master (#1109)
by Rami
18:42
created
includes/admin/reporting/tools/class-give-tools-recount-form-stats.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @since 1.5
51 51
 	 * @global object $wpdb Used to query the database using the WordPress
52 52
 	 *   Database API
53
-	 * @return array $data The data for the CSV file
53
+	 * @return boolean $data The data for the CSV file
54 54
 	 */
55 55
 	public function get_data() {
56 56
 		global $wpdb;
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -62,23 +62,23 @@  discard block
 block discarded – undo
62 62
 	public function get_data() {
63 63
 		global $give_logs, $wpdb;
64 64
 
65
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
65
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
66 66
 
67
-		if ( $this->step == 1 ) {
68
-			$this->delete_data( 'give_temp_recount_form_stats' );
67
+		if ($this->step == 1) {
68
+			$this->delete_data('give_temp_recount_form_stats');
69 69
 		}
70 70
 
71
-		$totals = $this->get_stored_data( 'give_temp_recount_form_stats' );
71
+		$totals = $this->get_stored_data('give_temp_recount_form_stats');
72 72
 
73
-		if ( false === $totals ) {
73
+		if (false === $totals) {
74 74
 			$totals = array(
75 75
 				'earnings' => (float) 0,
76 76
 				'sales'    => 0,
77 77
 			);
78
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
78
+			$this->store_data('give_temp_recount_form_stats', $totals);
79 79
 		}
80 80
 
81
-		$args = apply_filters( 'give_recount_form_stats_args', array(
81
+		$args = apply_filters('give_recount_form_stats_args', array(
82 82
 			'post_parent'    => $this->form_id,
83 83
 			'post_type'      => 'give_log',
84 84
 			'posts_per_page' => $this->per_step,
@@ -86,49 +86,49 @@  discard block
 block discarded – undo
86 86
 			'paged'          => $this->step,
87 87
 			'log_type'       => 'sale',
88 88
 			'fields'         => 'ids',
89
-		) );
89
+		));
90 90
 
91
-		$log_ids              = $give_logs->get_connected_logs( $args, 'sale' );
91
+		$log_ids              = $give_logs->get_connected_logs($args, 'sale');
92 92
 		$this->_log_ids_debug = array();
93 93
 
94
-		if ( $log_ids ) {
95
-			$log_ids     = implode( ',', $log_ids );
96
-			$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" );
97
-			unset( $log_ids );
94
+		if ($log_ids) {
95
+			$log_ids     = implode(',', $log_ids);
96
+			$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)");
97
+			unset($log_ids);
98 98
 
99
-			$payment_ids = implode( ',', $payment_ids );
100
-			$payments    = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" );
101
-			unset( $payment_ids );
99
+			$payment_ids = implode(',', $payment_ids);
100
+			$payments    = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")");
101
+			unset($payment_ids);
102 102
 
103
-			foreach ( $payments as $payment ) {
103
+			foreach ($payments as $payment) {
104 104
 
105
-				$payment = new Give_Payment( $payment->ID );
105
+				$payment = new Give_Payment($payment->ID);
106 106
 
107 107
 				//Ensure acceptible status only
108
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
108
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
109 109
 					continue;
110 110
 				}
111 111
 
112 112
 				//Ensure only payments for this form are counted
113
-				if ( $payment->form_id != $this->form_id ) {
113
+				if ($payment->form_id != $this->form_id) {
114 114
 					continue;
115 115
 				}
116 116
 
117 117
 				$this->_log_ids_debug[] = $payment->ID;
118 118
 
119
-				$totals['sales'] ++;
119
+				$totals['sales']++;
120 120
 				$totals['earnings'] += $payment->total;
121 121
 
122 122
 			}
123 123
 
124
-			$this->store_data( 'give_temp_recount_form_stats', $totals );
124
+			$this->store_data('give_temp_recount_form_stats', $totals);
125 125
 
126 126
 			return true;
127 127
 		}
128 128
 
129 129
 
130
-		update_post_meta( $this->form_id, '_give_form_sales', $totals['sales'] );
131
-		update_post_meta( $this->form_id, '_give_form_earnings', $totals['earnings'] );
130
+		update_post_meta($this->form_id, '_give_form_sales', $totals['sales']);
131
+		update_post_meta($this->form_id, '_give_form_earnings', $totals['earnings']);
132 132
 
133 133
 		return false;
134 134
 
@@ -143,54 +143,54 @@  discard block
 block discarded – undo
143 143
 	public function get_percentage_complete() {
144 144
 		global $give_logs, $wpdb;
145 145
 
146
-		if ( $this->step == 1 ) {
147
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
146
+		if ($this->step == 1) {
147
+			$this->delete_data('give_recount_total_'.$this->form_id);
148 148
 		}
149 149
 
150
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
151
-		$total             = $this->get_stored_data( 'give_recount_total_' . $this->form_id );
150
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
151
+		$total             = $this->get_stored_data('give_recount_total_'.$this->form_id);
152 152
 
153
-		if ( false === $total ) {
153
+		if (false === $total) {
154 154
 			$total = 0;
155
-			$args  = apply_filters( 'give_recount_form_stats_total_args', array(
155
+			$args  = apply_filters('give_recount_form_stats_total_args', array(
156 156
 				'post_parent' => $this->form_id,
157 157
 				'post_type'   => 'give_log',
158 158
 				'post_status' => 'publish',
159 159
 				'log_type'    => 'sale',
160 160
 				'fields'      => 'ids',
161 161
 				'nopaging'    => true,
162
-			) );
162
+			));
163 163
 
164
-			$log_ids = $give_logs->get_connected_logs( $args, 'sale' );
164
+			$log_ids = $give_logs->get_connected_logs($args, 'sale');
165 165
 
166
-			if ( $log_ids ) {
167
-				$log_ids     = implode( ',', $log_ids );
168
-				$payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)" );
169
-				unset( $log_ids );
166
+			if ($log_ids) {
167
+				$log_ids     = implode(',', $log_ids);
168
+				$payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids)");
169
+				unset($log_ids);
170 170
 
171
-				$payment_ids = implode( ',', $payment_ids );
172
-				$payments    = $wpdb->get_results( "SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (" . $payment_ids . ")" );
173
-				unset( $payment_ids );
171
+				$payment_ids = implode(',', $payment_ids);
172
+				$payments    = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts WHERE ID IN (".$payment_ids.")");
173
+				unset($payment_ids);
174 174
 
175
-				foreach ( $payments as $payment ) {
176
-					if ( in_array( $payment->post_status, $accepted_statuses ) ) {
175
+				foreach ($payments as $payment) {
176
+					if (in_array($payment->post_status, $accepted_statuses)) {
177 177
 						continue;
178 178
 					}
179 179
 
180
-					$total ++;
180
+					$total++;
181 181
 				}
182 182
 			}
183 183
 
184
-			$this->store_data( 'give_recount_total_' . $this->form_id, $total );
184
+			$this->store_data('give_recount_total_'.$this->form_id, $total);
185 185
 		}
186 186
 
187 187
 		$percentage = 100;
188 188
 
189
-		if ( $total > 0 ) {
190
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
189
+		if ($total > 0) {
190
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
191 191
 		}
192 192
 
193
-		if ( $percentage > 100 ) {
193
+		if ($percentage > 100) {
194 194
 			$percentage = 100;
195 195
 		}
196 196
 
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @param array $request The Form Data passed into the batch processing
206 206
 	 */
207
-	public function set_properties( $request ) {
208
-		$this->form_id = isset( $request['form_id'] ) ? sanitize_text_field( $request['form_id'] ) : false;
207
+	public function set_properties($request) {
208
+		$this->form_id = isset($request['form_id']) ? sanitize_text_field($request['form_id']) : false;
209 209
 	}
210 210
 
211 211
 	/**
@@ -216,31 +216,31 @@  discard block
 block discarded – undo
216 216
 	 */
217 217
 	public function process_step() {
218 218
 
219
-		if ( ! $this->can_export() ) {
220
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
219
+		if ( ! $this->can_export()) {
220
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
221 221
 		}
222 222
 
223 223
 		$had_data = $this->get_data();
224 224
 
225
-		if ( $had_data ) {
225
+		if ($had_data) {
226 226
 			$this->done = false;
227 227
 
228 228
 			return true;
229 229
 		} else {
230
-			$this->delete_data( 'give_recount_total_' . $this->form_id );
231
-			$this->delete_data( 'give_temp_recount_form_stats' );
230
+			$this->delete_data('give_recount_total_'.$this->form_id);
231
+			$this->delete_data('give_temp_recount_form_stats');
232 232
 			$this->done    = true;
233
-			$this->message = sprintf( esc_html__( 'Donation counts and income amount statistics successfully recounted for "%s".', 'give' ), get_the_title( $this->form_id ) );
233
+			$this->message = sprintf(esc_html__('Donation counts and income amount statistics successfully recounted for "%s".', 'give'), get_the_title($this->form_id));
234 234
 
235 235
 			return false;
236 236
 		}
237 237
 	}
238 238
 
239 239
 	public function headers() {
240
-		ignore_user_abort( true );
240
+		ignore_user_abort(true);
241 241
 
242
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
243
-			set_time_limit( 0 );
242
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
243
+			set_time_limit(0);
244 244
 		}
245 245
 	}
246 246
 
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
 	 *
269 269
 	 * @return mixed       Returns the data from the database
270 270
 	 */
271
-	private function get_stored_data( $key ) {
271
+	private function get_stored_data($key) {
272 272
 		global $wpdb;
273
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
273
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
274 274
 
275
-		return empty( $value ) ? false : maybe_unserialize( $value );
275
+		return empty($value) ? false : maybe_unserialize($value);
276 276
 	}
277 277
 
278 278
 	/**
@@ -285,10 +285,10 @@  discard block
 block discarded – undo
285 285
 	 *
286 286
 	 * @return void
287 287
 	 */
288
-	private function store_data( $key, $value ) {
288
+	private function store_data($key, $value) {
289 289
 		global $wpdb;
290 290
 
291
-		$value = maybe_serialize( $value );
291
+		$value = maybe_serialize($value);
292 292
 
293 293
 		$data = array(
294 294
 			'option_name'  => $key,
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 			'%s',
303 303
 		);
304 304
 
305
-		$wpdb->replace( $wpdb->options, $data, $formats );
305
+		$wpdb->replace($wpdb->options, $data, $formats);
306 306
 	}
307 307
 
308 308
 	/**
@@ -314,9 +314,9 @@  discard block
 block discarded – undo
314 314
 	 *
315 315
 	 * @return void
316 316
 	 */
317
-	private function delete_data( $key ) {
317
+	private function delete_data($key) {
318 318
 		global $wpdb;
319
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
319
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
320 320
 	}
321 321
 
322 322
 }
Please login to merge, or discard this patch.
includes/admin/reporting/tools/class-give-tools-recount-income.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
 	 * @since 1.5
51 51
 	 * @global object $wpdb Used to query the database using the WordPress
52 52
 	 *   Database API
53
-	 * @return array $data The data for the CSV file
53
+	 * @return boolean $data The data for the CSV file
54 54
 	 */
55 55
 	public function get_data() {
56 56
 		global $wpdb;
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -54,50 +54,50 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function get_data() {
56 56
 
57
-		if ( $this->step == 1 ) {
58
-			$this->delete_data( 'give_temp_recount_income' );
57
+		if ($this->step == 1) {
58
+			$this->delete_data('give_temp_recount_income');
59 59
 		}
60 60
 
61
-		$total = get_option( 'give_temp_recount_income', false );
61
+		$total = get_option('give_temp_recount_income', false);
62 62
 
63
-		if ( false === $total ) {
63
+		if (false === $total) {
64 64
 			$total = (float) 0;
65
-			$this->store_data( 'give_temp_recount_income', $total );
65
+			$this->store_data('give_temp_recount_income', $total);
66 66
 		}
67 67
 
68
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
68
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
69 69
 
70
-		$args = apply_filters( 'give_recount_income_args', array(
70
+		$args = apply_filters('give_recount_income_args', array(
71 71
 			'number' => $this->per_step,
72 72
 			'page'   => $this->step,
73 73
 			'status' => $accepted_statuses,
74 74
 			'fields' => 'ids'
75
-		) );
75
+		));
76 76
 
77
-		$payments = give_get_payments( $args );
77
+		$payments = give_get_payments($args);
78 78
 
79
-		if ( ! empty( $payments ) ) {
79
+		if ( ! empty($payments)) {
80 80
 
81
-			foreach ( $payments as $payment ) {
81
+			foreach ($payments as $payment) {
82 82
 
83
-				$total += give_get_payment_amount( $payment );
83
+				$total += give_get_payment_amount($payment);
84 84
 
85 85
 			}
86 86
 
87
-			if ( $total < 0 ) {
87
+			if ($total < 0) {
88 88
 				$totals = 0;
89 89
 			}
90 90
 
91
-			$total = round( $total, give_currency_decimal_filter() );
91
+			$total = round($total, give_currency_decimal_filter());
92 92
 
93
-			$this->store_data( 'give_temp_recount_income', $total );
93
+			$this->store_data('give_temp_recount_income', $total);
94 94
 
95 95
 			return true;
96 96
 
97 97
 		}
98 98
 
99
-		update_option( 'give_income_total', $total );
100
-		set_transient( 'give_income_total', $total, 86400 );
99
+		update_option('give_income_total', $total);
100
+		set_transient('give_income_total', $total, 86400);
101 101
 
102 102
 		return false;
103 103
 
@@ -111,25 +111,25 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function get_percentage_complete() {
113 113
 
114
-		$total = $this->get_stored_data( 'give_recount_income_total' );
114
+		$total = $this->get_stored_data('give_recount_income_total');
115 115
 
116
-		if ( false === $total ) {
117
-			$args = apply_filters( 'give_recount_income_total_args', array() );
116
+		if (false === $total) {
117
+			$args = apply_filters('give_recount_income_total_args', array());
118 118
 
119
-			$counts = give_count_payments( $args );
120
-			$total  = absint( $counts->publish );
121
-			$total  = apply_filters( 'give_recount_store_income_total', $total );
119
+			$counts = give_count_payments($args);
120
+			$total  = absint($counts->publish);
121
+			$total  = apply_filters('give_recount_store_income_total', $total);
122 122
 
123
-			$this->store_data( 'give_recount_income_total', $total );
123
+			$this->store_data('give_recount_income_total', $total);
124 124
 		}
125 125
 
126 126
 		$percentage = 100;
127 127
 
128
-		if ( $total > 0 ) {
129
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
128
+		if ($total > 0) {
129
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
130 130
 		}
131 131
 
132
-		if ( $percentage > 100 ) {
132
+		if ($percentage > 100) {
133 133
 			$percentage = 100;
134 134
 		}
135 135
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 * @param array $request The Form Data passed into the batch processing
145 145
 	 */
146
-	public function set_properties( $request ) {
146
+	public function set_properties($request) {
147 147
 	}
148 148
 
149 149
 	/**
@@ -154,31 +154,31 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	public function process_step() {
156 156
 
157
-		if ( ! $this->can_export() ) {
158
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
157
+		if ( ! $this->can_export()) {
158
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
159 159
 		}
160 160
 
161 161
 		$had_data = $this->get_data();
162 162
 
163
-		if ( $had_data ) {
163
+		if ($had_data) {
164 164
 			$this->done = false;
165 165
 
166 166
 			return true;
167 167
 		} else {
168
-			$this->delete_data( 'give_recount_income_total' );
169
-			$this->delete_data( 'give_temp_recount_income' );
168
+			$this->delete_data('give_recount_income_total');
169
+			$this->delete_data('give_temp_recount_income');
170 170
 			$this->done    = true;
171
-			$this->message = esc_html__( 'Give income successfully recounted.', 'give' );
171
+			$this->message = esc_html__('Give income successfully recounted.', 'give');
172 172
 
173 173
 			return false;
174 174
 		}
175 175
 	}
176 176
 
177 177
 	public function headers() {
178
-		ignore_user_abort( true );
178
+		ignore_user_abort(true);
179 179
 
180
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
181
-			set_time_limit( 0 );
180
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
181
+			set_time_limit(0);
182 182
 		}
183 183
 	}
184 184
 
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @return mixed       Returns the data from the database
208 208
 	 */
209
-	private function get_stored_data( $key ) {
209
+	private function get_stored_data($key) {
210 210
 		global $wpdb;
211
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
211
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
212 212
 
213
-		return empty( $value ) ? false : maybe_unserialize( $value );
213
+		return empty($value) ? false : maybe_unserialize($value);
214 214
 	}
215 215
 
216 216
 	/**
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
 	 *
224 224
 	 * @return void
225 225
 	 */
226
-	private function store_data( $key, $value ) {
226
+	private function store_data($key, $value) {
227 227
 		global $wpdb;
228 228
 
229
-		$value = maybe_serialize( $value );
229
+		$value = maybe_serialize($value);
230 230
 
231 231
 		$data = array(
232 232
 			'option_name'  => $key,
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 			'%s',
241 241
 		);
242 242
 
243
-		$wpdb->replace( $wpdb->options, $data, $formats );
243
+		$wpdb->replace($wpdb->options, $data, $formats);
244 244
 	}
245 245
 
246 246
 	/**
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
 	 *
253 253
 	 * @return void
254 254
 	 */
255
-	private function delete_data( $key ) {
255
+	private function delete_data($key) {
256 256
 		global $wpdb;
257
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
257
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
258 258
 	}
259 259
 
260 260
 }
Please login to merge, or discard this patch.
includes/admin/reporting/export/class-batch-export-customers.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -206,6 +206,7 @@
 block discarded – undo
206 206
 	 * Set Donor Data
207 207
 	 *
208 208
 	 * @param $donor
209
+	 * @param integer $i
209 210
 	 */
210 211
 	private function set_donor_data( $i, $data, $donor ) {
211 212
 
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 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
 
@@ -46,16 +46,16 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @param array $request The Form Data passed into the batch processing
48 48
 	 */
49
-	public function set_properties( $request ) {
49
+	public function set_properties($request) {
50 50
 
51 51
 		//Set data from form submission
52
-		if ( isset( $_POST['form'] ) ) {
53
-			parse_str( $_POST['form'], $this->data );
52
+		if (isset($_POST['form'])) {
53
+			parse_str($_POST['form'], $this->data);
54 54
 		}
55 55
 
56 56
 		$this->form = $this->data['forms'];
57 57
 
58
-		$this->price_id = ! empty( $request['give_price_option'] ) && 0 !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null;
58
+		$this->price_id = ! empty($request['give_price_option']) && 0 !== $request['give_price_option'] ? absint($request['give_price_option']) : null;
59 59
 
60 60
 	}
61 61
 
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
 	public function csv_cols() {
70 70
 
71 71
 
72
-		$columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array();
72
+		$columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array();
73 73
 
74 74
 		//We need columns.
75
-		if ( empty( $columns ) ) {
75
+		if (empty($columns)) {
76 76
 			return false;
77 77
 		}
78 78
 
79
-		$cols = $this->get_cols( $columns );
79
+		$cols = $this->get_cols($columns);
80 80
 
81 81
 		return $cols;
82 82
 	}
@@ -84,38 +84,38 @@  discard block
 block discarded – undo
84 84
 	/**
85 85
 	 * @param $column
86 86
 	 */
87
-	private function get_cols( $columns ) {
87
+	private function get_cols($columns) {
88 88
 
89 89
 		$cols = array();
90 90
 
91
-		foreach ( $columns as $key => $value ) {
91
+		foreach ($columns as $key => $value) {
92 92
 
93
-			switch ( $key ) {
93
+			switch ($key) {
94 94
 				case 'full_name' :
95
-					$cols['full_name'] = esc_html__( 'Full Name', 'give' );
95
+					$cols['full_name'] = esc_html__('Full Name', 'give');
96 96
 					break;
97 97
 				case 'email' :
98
-					$cols['email'] = esc_html__( 'Email Address', 'give' );
98
+					$cols['email'] = esc_html__('Email Address', 'give');
99 99
 					break;
100 100
 				case 'address' :
101
-					$cols['address_line1']   = esc_html__( 'Address', 'give' );
102
-					$cols['address_line2']   = esc_html__( 'Address 2', 'give' );
103
-					$cols['address_city']    = esc_html__( 'City', 'give' );
104
-					$cols['address_state']   = esc_html__( 'State', 'give' );
105
-					$cols['address_zip']     = esc_html__( 'Zip', 'give' );
106
-					$cols['address_country'] = esc_html__( 'Country', 'give' );
101
+					$cols['address_line1']   = esc_html__('Address', 'give');
102
+					$cols['address_line2']   = esc_html__('Address 2', 'give');
103
+					$cols['address_city']    = esc_html__('City', 'give');
104
+					$cols['address_state']   = esc_html__('State', 'give');
105
+					$cols['address_zip']     = esc_html__('Zip', 'give');
106
+					$cols['address_country'] = esc_html__('Country', 'give');
107 107
 					break;
108 108
 				case 'userid' :
109
-					$cols['userid'] = esc_html__( 'User ID', 'give' );
109
+					$cols['userid'] = esc_html__('User ID', 'give');
110 110
 					break;
111 111
 				case 'date_first_donated' :
112
-					$cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' );
112
+					$cols['date_first_donated'] = esc_html__('First Donation Date', 'give');
113 113
 					break;
114 114
 				case 'donations' :
115
-					$cols['donations'] = esc_html__( 'Number of Donations', 'give' );
115
+					$cols['donations'] = esc_html__('Number of Donations', 'give');
116 116
 					break;
117 117
 				case 'donation_sum' :
118
-					$cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' );
118
+					$cols['donation_sum'] = esc_html__('Sum of Donations', 'give');
119 119
 					break;
120 120
 			}
121 121
 		}
@@ -138,20 +138,20 @@  discard block
 block discarded – undo
138 138
 
139 139
 		$i = 0;
140 140
 
141
-		if ( ! empty( $this->form ) ) {
141
+		if ( ! empty($this->form)) {
142 142
 
143 143
 			// Export donors of a specific product
144 144
 			global $give_logs;
145 145
 
146 146
 			$args = array(
147
-				'post_parent'    => absint( $this->form ),
147
+				'post_parent'    => absint($this->form),
148 148
 				'log_type'       => 'sale',
149 149
 				'posts_per_page' => 30,
150 150
 				'paged'          => $this->step
151 151
 			);
152 152
 
153 153
 			//Check for price option
154
-			if ( null !== $this->price_id ) {
154
+			if (null !== $this->price_id) {
155 155
 				$args['meta_query'] = array(
156 156
 					array(
157 157
 						'key'   => '_give_log_price_id',
@@ -160,33 +160,33 @@  discard block
 block discarded – undo
160 160
 				);
161 161
 			}
162 162
 
163
-			$logs = $give_logs->get_connected_logs( $args );
163
+			$logs = $give_logs->get_connected_logs($args);
164 164
 
165
-			if ( $logs ) {
166
-				foreach ( $logs as $log ) {
167
-					$payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true );
168
-					$payment    = new Give_Payment( $payment_id );
169
-					$donor      = Give()->customers->get_customer_by( 'id', $payment->customer_id );
170
-					$data[]     = $this->set_donor_data( $i, $data, $donor );
171
-					$i ++;
165
+			if ($logs) {
166
+				foreach ($logs as $log) {
167
+					$payment_id = get_post_meta($log->ID, '_give_log_payment_id', true);
168
+					$payment    = new Give_Payment($payment_id);
169
+					$donor      = Give()->customers->get_customer_by('id', $payment->customer_id);
170
+					$data[]     = $this->set_donor_data($i, $data, $donor);
171
+					$i++;
172 172
 				}
173 173
 			}
174 174
 
175 175
 		} else {
176 176
 
177 177
 			// Export all customers
178
-			$offset = 30 * ( $this->step - 1 );
179
-			$donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) );
178
+			$offset = 30 * ($this->step - 1);
179
+			$donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset));
180 180
 
181
-			foreach ( $donors as $donor ) {
181
+			foreach ($donors as $donor) {
182 182
 
183
-				$data[] = $this->set_donor_data( $i, $data, $donor );
184
-				$i ++;
183
+				$data[] = $this->set_donor_data($i, $data, $donor);
184
+				$i++;
185 185
 			}
186 186
 		}
187 187
 
188
-		$data = apply_filters( 'give_export_get_data', $data );
189
-		$data = apply_filters( 'give_export_get_data_' . $this->export_type, $data );
188
+		$data = apply_filters('give_export_get_data', $data);
189
+		$data = apply_filters('give_export_get_data_'.$this->export_type, $data);
190 190
 
191 191
 		return $data;
192 192
 	}
@@ -202,19 +202,19 @@  discard block
 block discarded – undo
202 202
 		$percentage = 0;
203 203
 
204 204
 		// We can't count the number when getting them for a specific form
205
-		if ( empty( $this->form ) ) {
205
+		if (empty($this->form)) {
206 206
 
207 207
 			$total = Give()->customers->count();
208 208
 
209
-			if ( $total > 0 ) {
209
+			if ($total > 0) {
210 210
 
211
-				$percentage = ( ( 30 * $this->step ) / $total ) * 100;
211
+				$percentage = ((30 * $this->step) / $total) * 100;
212 212
 
213 213
 			}
214 214
 
215 215
 		}
216 216
 
217
-		if ( $percentage > 100 ) {
217
+		if ($percentage > 100) {
218 218
 			$percentage = 100;
219 219
 		}
220 220
 
@@ -226,46 +226,46 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @param $donor
228 228
 	 */
229
-	private function set_donor_data( $i, $data, $donor ) {
229
+	private function set_donor_data($i, $data, $donor) {
230 230
 
231 231
 		$columns = $this->csv_cols();
232 232
 
233 233
 		//Set address variable
234 234
 		$address = '';
235
-		if ( isset( $donor->user_id ) && $donor->user_id > 0 ) {
236
-			$address = give_get_donor_address( $donor->user_id );
235
+		if (isset($donor->user_id) && $donor->user_id > 0) {
236
+			$address = give_get_donor_address($donor->user_id);
237 237
 		}
238 238
 
239 239
 		//Set columns
240
-		if ( ! empty( $columns['full_name'] ) ) {
241
-			$data[ $i ]['full_name'] = $donor->name;
240
+		if ( ! empty($columns['full_name'])) {
241
+			$data[$i]['full_name'] = $donor->name;
242 242
 		}
243
-		if ( ! empty( $columns['email'] ) ) {
244
-			$data[ $i ]['email'] = $donor->email;
243
+		if ( ! empty($columns['email'])) {
244
+			$data[$i]['email'] = $donor->email;
245 245
 		}
246
-		if ( ! empty( $columns['address_line1'] ) ) {
247
-
248
-			$data[ $i ]['address_line1']   = isset( $address['line1'] ) ? $address['line1'] : '';
249
-			$data[ $i ]['address_line2']   = isset( $address['line2'] ) ? $address['line2'] : '';
250
-			$data[ $i ]['address_city']    = isset( $address['city'] ) ? $address['city'] : '';
251
-			$data[ $i ]['address_state']   = isset( $address['state'] ) ? $address['state'] : '';
252
-			$data[ $i ]['address_zip']     = isset( $address['zip'] ) ? $address['zip'] : '';
253
-			$data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : '';
246
+		if ( ! empty($columns['address_line1'])) {
247
+
248
+			$data[$i]['address_line1']   = isset($address['line1']) ? $address['line1'] : '';
249
+			$data[$i]['address_line2']   = isset($address['line2']) ? $address['line2'] : '';
250
+			$data[$i]['address_city']    = isset($address['city']) ? $address['city'] : '';
251
+			$data[$i]['address_state']   = isset($address['state']) ? $address['state'] : '';
252
+			$data[$i]['address_zip']     = isset($address['zip']) ? $address['zip'] : '';
253
+			$data[$i]['address_country'] = isset($address['country']) ? $address['country'] : '';
254 254
 		}
255
-		if ( ! empty( $columns['userid'] ) ) {
256
-			$data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : '';
255
+		if ( ! empty($columns['userid'])) {
256
+			$data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : '';
257 257
 		}
258
-		if ( ! empty( $columns['date_first_donated'] ) ) {
259
-			$data[ $i ]['date_first_donated'] = date_i18n( get_option( 'date_format' ), strtotime( $donor->date_created ) );
258
+		if ( ! empty($columns['date_first_donated'])) {
259
+			$data[$i]['date_first_donated'] = date_i18n(get_option('date_format'), strtotime($donor->date_created));
260 260
 		}
261
-		if ( ! empty( $columns['donations'] ) ) {
262
-			$data[ $i ]['donations'] = $donor->purchase_count;
261
+		if ( ! empty($columns['donations'])) {
262
+			$data[$i]['donations'] = $donor->purchase_count;
263 263
 		}
264
-		if ( ! empty( $columns['donation_sum'] ) ) {
265
-			$data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value );
264
+		if ( ! empty($columns['donation_sum'])) {
265
+			$data[$i]['donation_sum'] = give_format_amount($donor->purchase_value);
266 266
 		}
267 267
 
268
-		return $data[ $i ];
268
+		return $data[$i];
269 269
 
270 270
 	}
271 271
 
Please login to merge, or discard this patch.
includes/forms/functions.php 3 patches
Spacing   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 
24 24
 	global $typenow;
25 25
 
26
-	if ( $typenow != 'give_forms' ) {
26
+	if ($typenow != 'give_forms') {
27 27
 		return true;
28 28
 	}
29 29
 
30 30
 	return false;
31 31
 }
32 32
 
33
-add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' );
33
+add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition');
34 34
 
35 35
 
36 36
 /**
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
  *
41 41
  * @return int|false
42 42
  */
43
-function get_form_id_from_args( $args ) {
43
+function get_form_id_from_args($args) {
44 44
 
45
-	if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) {
45
+	if (isset($args['form_id']) && $args['form_id'] != 0) {
46 46
 
47
-		return intval( $args['form_id'] );
47
+		return intval($args['form_id']);
48 48
 	}
49 49
 
50 50
 	return false;
@@ -59,23 +59,23 @@  discard block
 block discarded – undo
59 59
  *
60 60
  * @return bool
61 61
  */
62
-function give_is_float_labels_enabled( $args ) {
62
+function give_is_float_labels_enabled($args) {
63 63
 
64 64
 	$float_labels = '';
65 65
 
66
-	if ( ! empty( $args['float_labels'] ) ) {
66
+	if ( ! empty($args['float_labels'])) {
67 67
 		$float_labels = $args['float_labels'];
68 68
 	}
69 69
 
70
-	if ( empty( $float_labels ) ) {
71
-		$float_labels = get_post_meta( $args['form_id'], '_give_form_floating_labels', true );
70
+	if (empty($float_labels)) {
71
+		$float_labels = get_post_meta($args['form_id'], '_give_form_floating_labels', true);
72 72
 	}
73 73
 
74
-	if ( empty( $float_labels ) ) {
75
-		$float_labels = give_get_option( 'enable_floatlabels' ) ? 'enabled' : 'disabled';
74
+	if (empty($float_labels)) {
75
+		$float_labels = give_get_option('enable_floatlabels') ? 'enabled' : 'disabled';
76 76
 	}
77 77
 
78
-	return ( $float_labels == 'enabled' ) ? true : false;
78
+	return ($float_labels == 'enabled') ? true : false;
79 79
 }
80 80
 
81 81
 /**
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
 	$can_checkout = true;
92 92
 
93
-	return (bool) apply_filters( 'give_can_checkout', $can_checkout );
93
+	return (bool) apply_filters('give_can_checkout', $can_checkout);
94 94
 }
95 95
 
96 96
 /**
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
 function give_get_success_page_uri() {
104 104
 	global $give_options;
105 105
 
106
-	$success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' );
106
+	$success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url');
107 107
 
108
-	return apply_filters( 'give_get_success_page_uri', $success_page );
108
+	return apply_filters('give_get_success_page_uri', $success_page);
109 109
 }
110 110
 
111 111
 /**
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
  */
117 117
 function give_is_success_page() {
118 118
 	global $give_options;
119
-	$is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false;
119
+	$is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false;
120 120
 
121
-	return apply_filters( 'give_is_success_page', $is_success_page );
121
+	return apply_filters('give_is_success_page', $is_success_page);
122 122
 }
123 123
 
124 124
 /**
@@ -132,17 +132,17 @@  discard block
 block discarded – undo
132 132
  * @since       1.0
133 133
  * @return      void
134 134
  */
135
-function give_send_to_success_page( $query_string = null ) {
135
+function give_send_to_success_page($query_string = null) {
136 136
 
137 137
 	$redirect = give_get_success_page_uri();
138 138
 
139
-	if ( $query_string ) {
139
+	if ($query_string) {
140 140
 		$redirect .= $query_string;
141 141
 	}
142 142
 
143
-	$gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : '';
143
+	$gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : '';
144 144
 
145
-	wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) );
145
+	wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string));
146 146
 	give_die();
147 147
 }
148 148
 
@@ -159,25 +159,25 @@  discard block
 block discarded – undo
159 159
  * @since  1.0
160 160
  * @return Void
161 161
  */
162
-function give_send_back_to_checkout( $args = array() ) {
162
+function give_send_back_to_checkout($args = array()) {
163 163
 
164
-	$redirect = ( isset( $_POST['give-current-url'] ) ) ? $_POST['give-current-url'] : '';
165
-	$form_id  = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : 0;
164
+	$redirect = (isset($_POST['give-current-url'])) ? $_POST['give-current-url'] : '';
165
+	$form_id  = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : 0;
166 166
 
167 167
 	$defaults = array(
168 168
 		'form-id' => (int) $form_id
169 169
 	);
170 170
 
171 171
 	// Check for backward compatibility
172
-	if ( is_string( $args ) ) {
173
-		$args = str_replace( '?', '', $args );
172
+	if (is_string($args)) {
173
+		$args = str_replace('?', '', $args);
174 174
 	}
175 175
 
176
-	$args = wp_parse_args( $args, $defaults );
176
+	$args = wp_parse_args($args, $defaults);
177 177
 
178
-	$redirect = add_query_arg( $args, $redirect ) . '#give-form-' . $form_id . '-wrap';
178
+	$redirect = add_query_arg($args, $redirect).'#give-form-'.$form_id.'-wrap';
179 179
 
180
-	wp_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) );
180
+	wp_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args));
181 181
 	give_die();
182 182
 }
183 183
 
@@ -192,16 +192,16 @@  discard block
 block discarded – undo
192 192
  * @since       1.0
193 193
  * @return      string
194 194
  */
195
-function give_get_success_page_url( $query_string = null ) {
195
+function give_get_success_page_url($query_string = null) {
196 196
 
197
-	$success_page = give_get_option( 'success_page', 0 );
198
-	$success_page = get_permalink( $success_page );
197
+	$success_page = give_get_option('success_page', 0);
198
+	$success_page = get_permalink($success_page);
199 199
 
200
-	if ( $query_string ) {
200
+	if ($query_string) {
201 201
 		$success_page .= $query_string;
202 202
 	}
203 203
 
204
-	return apply_filters( 'give_success_page_url', $success_page );
204
+	return apply_filters('give_success_page_url', $success_page);
205 205
 
206 206
 }
207 207
 
@@ -215,15 +215,15 @@  discard block
 block discarded – undo
215 215
  *
216 216
  * @return mixed|void Full URL to the Transaction Failed page, if present, home page if it doesn't exist
217 217
  */
218
-function give_get_failed_transaction_uri( $extras = false ) {
218
+function give_get_failed_transaction_uri($extras = false) {
219 219
 	global $give_options;
220 220
 
221
-	$uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url();
222
-	if ( $extras ) {
221
+	$uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url();
222
+	if ($extras) {
223 223
 		$uri .= $extras;
224 224
 	}
225 225
 
226
-	return apply_filters( 'give_get_failed_transaction_uri', $uri );
226
+	return apply_filters('give_get_failed_transaction_uri', $uri);
227 227
 }
228 228
 
229 229
 /**
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
  */
235 235
 function give_is_failed_transaction_page() {
236 236
 	global $give_options;
237
-	$ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false;
237
+	$ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false;
238 238
 
239
-	return apply_filters( 'give_is_failure_page', $ret );
239
+	return apply_filters('give_is_failure_page', $ret);
240 240
 }
241 241
 
242 242
 /**
@@ -248,18 +248,18 @@  discard block
 block discarded – undo
248 248
  */
249 249
 function give_listen_for_failed_payments() {
250 250
 
251
-	$failed_page = give_get_option( 'failure_page', 0 );
251
+	$failed_page = give_get_option('failure_page', 0);
252 252
 
253
-	if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) {
253
+	if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) {
254 254
 
255
-		$payment_id = absint( $_GET['payment-id'] );
256
-		give_update_payment_status( $payment_id, 'failed' );
255
+		$payment_id = absint($_GET['payment-id']);
256
+		give_update_payment_status($payment_id, 'failed');
257 257
 
258 258
 	}
259 259
 
260 260
 }
261 261
 
262
-add_action( 'template_redirect', 'give_listen_for_failed_payments' );
262
+add_action('template_redirect', 'give_listen_for_failed_payments');
263 263
 
264 264
 
265 265
 /**
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
  * @since       1.0
273 273
  * @return      bool
274 274
  */
275
-function give_field_is_required( $field = '', $form_id ) {
275
+function give_field_is_required($field = '', $form_id) {
276 276
 
277
-	$required_fields = give_purchase_form_required_fields( $form_id );
277
+	$required_fields = give_purchase_form_required_fields($form_id);
278 278
 
279
-	return array_key_exists( $field, $required_fields );
279
+	return array_key_exists($field, $required_fields);
280 280
 }
281 281
 
282 282
 /**
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
  *
295 295
  * @return void
296 296
  */
297
-function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) {
297
+function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) {
298 298
 	global $give_logs;
299 299
 
300 300
 	$log_data = array(
301 301
 		'post_parent'   => $give_form_id,
302 302
 		'log_type'      => 'sale',
303
-		'post_date'     => isset( $sale_date ) ? $sale_date : null,
304
-		'post_date_gmt' => isset( $sale_date ) ? $sale_date : null
303
+		'post_date'     => isset($sale_date) ? $sale_date : null,
304
+		'post_date_gmt' => isset($sale_date) ? $sale_date : null
305 305
 	);
306 306
 
307 307
 	$log_meta = array(
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 		'price_id'   => (int) $price_id
310 310
 	);
311 311
 
312
-	$give_logs->insert_log( $log_data, $log_meta );
312
+	$give_logs->insert_log($log_data, $log_meta);
313 313
 }
314 314
 
315 315
 
@@ -323,11 +323,11 @@  discard block
 block discarded – undo
323 323
  *
324 324
  * @return bool|int
325 325
  */
326
-function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) {
326
+function give_increase_purchase_count($form_id = 0, $quantity = 1) {
327 327
 	$quantity = (int) $quantity;
328
-	$form     = new Give_Donate_Form( $form_id );
328
+	$form     = new Give_Donate_Form($form_id);
329 329
 
330
-	return $form->increase_sales( $quantity );
330
+	return $form->increase_sales($quantity);
331 331
 }
332 332
 
333 333
 /**
@@ -340,11 +340,11 @@  discard block
 block discarded – undo
340 340
  *
341 341
  * @return bool|int
342 342
  */
343
-function give_decrease_purchase_count( $form_id = 0, $quantity = 1 ) {
343
+function give_decrease_purchase_count($form_id = 0, $quantity = 1) {
344 344
 	$quantity = (int) $quantity;
345
-	$form     = new Give_Donate_Form( $form_id );
345
+	$form     = new Give_Donate_Form($form_id);
346 346
 
347
-	return $form->decrease_sales( $quantity );
347
+	return $form->decrease_sales($quantity);
348 348
 }
349 349
 
350 350
 /**
@@ -357,10 +357,10 @@  discard block
 block discarded – undo
357 357
  *
358 358
  * @return bool|int
359 359
  */
360
-function give_increase_earnings( $give_form_id = 0, $amount ) {
361
-	$form = new Give_Donate_Form( $give_form_id );
360
+function give_increase_earnings($give_form_id = 0, $amount) {
361
+	$form = new Give_Donate_Form($give_form_id);
362 362
 
363
-	return $form->increase_earnings( $amount );
363
+	return $form->increase_earnings($amount);
364 364
 }
365 365
 
366 366
 /**
@@ -373,10 +373,10 @@  discard block
 block discarded – undo
373 373
  *
374 374
  * @return bool|int
375 375
  */
376
-function give_decrease_earnings( $form_id = 0, $amount ) {
377
-	$form = new Give_Donate_Form( $form_id );
376
+function give_decrease_earnings($form_id = 0, $amount) {
377
+	$form = new Give_Donate_Form($form_id);
378 378
 
379
-	return $form->decrease_earnings( $amount );
379
+	return $form->decrease_earnings($amount);
380 380
 }
381 381
 
382 382
 
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
  *
390 390
  * @return int $earnings Earnings for a certain form
391 391
  */
392
-function give_get_form_earnings_stats( $form_id = 0 ) {
393
-	$give_form = new Give_Donate_Form( $form_id );
392
+function give_get_form_earnings_stats($form_id = 0) {
393
+	$give_form = new Give_Donate_Form($form_id);
394 394
 
395 395
 	return $give_form->earnings;
396 396
 }
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
  *
406 406
  * @return int $sales Amount of sales for a certain form
407 407
  */
408
-function give_get_form_sales_stats( $give_form_id = 0 ) {
409
-	$give_form = new Give_Donate_Form( $give_form_id );
408
+function give_get_form_sales_stats($give_form_id = 0) {
409
+	$give_form = new Give_Donate_Form($give_form_id);
410 410
 
411 411
 	return $give_form->sales;
412 412
 }
@@ -421,16 +421,16 @@  discard block
 block discarded – undo
421 421
  *
422 422
  * @return float $sales Average monthly sales
423 423
  */
424
-function give_get_average_monthly_form_sales( $form_id = 0 ) {
425
-	$sales        = give_get_form_sales_stats( $form_id );
426
-	$release_date = get_post_field( 'post_date', $form_id );
424
+function give_get_average_monthly_form_sales($form_id = 0) {
425
+	$sales        = give_get_form_sales_stats($form_id);
426
+	$release_date = get_post_field('post_date', $form_id);
427 427
 
428
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
428
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
429 429
 
430
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
430
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
431 431
 
432
-	if ( $months > 0 ) {
433
-		$sales = ( $sales / $months );
432
+	if ($months > 0) {
433
+		$sales = ($sales / $months);
434 434
 	}
435 435
 
436 436
 	return $sales;
@@ -446,16 +446,16 @@  discard block
 block discarded – undo
446 446
  *
447 447
  * @return float $earnings Average monthly earnings
448 448
  */
449
-function give_get_average_monthly_form_earnings( $form_id = 0 ) {
450
-	$earnings     = give_get_form_earnings_stats( $form_id );
451
-	$release_date = get_post_field( 'post_date', $form_id );
449
+function give_get_average_monthly_form_earnings($form_id = 0) {
450
+	$earnings     = give_get_form_earnings_stats($form_id);
451
+	$release_date = get_post_field('post_date', $form_id);
452 452
 
453
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
453
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
454 454
 
455
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
455
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
456 456
 
457
-	if ( $months > 0 ) {
458
-		$earnings = ( $earnings / $months );
457
+	if ($months > 0) {
458
+		$earnings = ($earnings / $months);
459 459
 	}
460 460
 
461 461
 	return $earnings < 0 ? 0 : $earnings;
@@ -475,25 +475,25 @@  discard block
 block discarded – undo
475 475
  *
476 476
  * @return string $price_name Name of the price option
477 477
  */
478
-function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) {
478
+function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) {
479 479
 
480
-	$prices     = give_get_variable_prices( $form_id );
480
+	$prices     = give_get_variable_prices($form_id);
481 481
 	$price_name = '';
482 482
 
483
-	foreach ( $prices as $price ) {
483
+	foreach ($prices as $price) {
484 484
 
485
-		if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) {
485
+		if (intval($price['_give_id']['level_id']) == intval($price_id)) {
486 486
 
487
-			$price_text     = isset( $price['_give_text'] ) ? $price['_give_text'] : '';
488
-			$price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'] ) );
489
-			$price_name     = ! empty( $price_text ) ? $price_text : $price_fallback;
487
+			$price_text     = isset($price['_give_text']) ? $price['_give_text'] : '';
488
+			$price_fallback = give_currency_filter(give_format_amount($price['_give_amount']));
489
+			$price_name     = ! empty($price_text) ? $price_text : $price_fallback;
490 490
 
491 491
 		}
492 492
 
493 493
 	}
494 494
 
495 495
 
496
-	return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id );
496
+	return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id);
497 497
 }
498 498
 
499 499
 
@@ -506,14 +506,14 @@  discard block
 block discarded – undo
506 506
  *
507 507
  * @return string $range A fully formatted price range
508 508
  */
509
-function give_price_range( $form_id = 0 ) {
510
-	$low   = give_get_lowest_price_option( $form_id );
511
-	$high  = give_get_highest_price_option( $form_id );
512
-	$range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>';
509
+function give_price_range($form_id = 0) {
510
+	$low   = give_get_lowest_price_option($form_id);
511
+	$high  = give_get_highest_price_option($form_id);
512
+	$range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>';
513 513
 	$range .= '<span class="give_price_range_sep">&nbsp;&ndash;&nbsp;</span>';
514
-	$range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>';
514
+	$range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>';
515 515
 
516
-	return apply_filters( 'give_price_range', $range, $form_id, $low, $high );
516
+	return apply_filters('give_price_range', $range, $form_id, $low, $high);
517 517
 }
518 518
 
519 519
 
@@ -528,36 +528,36 @@  discard block
 block discarded – undo
528 528
  *
529 529
  * @return int ID of the lowest price
530 530
  */
531
-function give_get_lowest_price_id( $form_id = 0 ) {
531
+function give_get_lowest_price_id($form_id = 0) {
532 532
 
533
-	if ( empty( $form_id ) ) {
533
+	if (empty($form_id)) {
534 534
 		$form_id = get_the_ID();
535 535
 	}
536 536
 
537
-	if ( ! give_has_variable_prices( $form_id ) ) {
538
-		return give_get_form_price( $form_id );
537
+	if ( ! give_has_variable_prices($form_id)) {
538
+		return give_get_form_price($form_id);
539 539
 	}
540 540
 
541
-	$prices = give_get_variable_prices( $form_id );
541
+	$prices = give_get_variable_prices($form_id);
542 542
 
543 543
 	$low    = 0.00;
544 544
 	$min_id = 1;
545 545
 
546
-	if ( ! empty( $prices ) ) {
546
+	if ( ! empty($prices)) {
547 547
 
548
-		foreach ( $prices as $key => $price ) {
548
+		foreach ($prices as $key => $price) {
549 549
 
550
-			if ( empty( $price['_give_amount'] ) ) {
550
+			if (empty($price['_give_amount'])) {
551 551
 				continue;
552 552
 			}
553 553
 
554
-			if ( ! isset( $min ) ) {
554
+			if ( ! isset($min)) {
555 555
 				$min = $price['_give_amount'];
556 556
 			} else {
557
-				$min = min( $min, $price['_give_amount'] );
557
+				$min = min($min, $price['_give_amount']);
558 558
 			}
559 559
 
560
-			if ( $price['_give_amount'] == $min ) {
560
+			if ($price['_give_amount'] == $min) {
561 561
 				$min_id = $price['_give_id']['level_id'];
562 562
 			}
563 563
 		}
@@ -575,43 +575,43 @@  discard block
 block discarded – undo
575 575
  *
576 576
  * @return float Amount of the lowest price
577 577
  */
578
-function give_get_lowest_price_option( $form_id = 0 ) {
579
-	if ( empty( $form_id ) ) {
578
+function give_get_lowest_price_option($form_id = 0) {
579
+	if (empty($form_id)) {
580 580
 		$form_id = get_the_ID();
581 581
 	}
582 582
 
583
-	if ( ! give_has_variable_prices( $form_id ) ) {
584
-		return give_get_form_price( $form_id );
583
+	if ( ! give_has_variable_prices($form_id)) {
584
+		return give_get_form_price($form_id);
585 585
 	}
586 586
 
587
-	$prices = give_get_variable_prices( $form_id );
587
+	$prices = give_get_variable_prices($form_id);
588 588
 
589 589
 	$low = 0.00;
590 590
 
591
-	if ( ! empty( $prices ) ) {
591
+	if ( ! empty($prices)) {
592 592
 
593
-		foreach ( $prices as $key => $price ) {
593
+		foreach ($prices as $key => $price) {
594 594
 
595
-			if ( empty( $price['_give_amount'] ) ) {
595
+			if (empty($price['_give_amount'])) {
596 596
 				continue;
597 597
 			}
598 598
 
599
-			if ( ! isset( $min ) ) {
599
+			if ( ! isset($min)) {
600 600
 				$min = $price['_give_amount'];
601 601
 			} else {
602
-				$min = min( $min, give_sanitize_amount( $price['_give_amount'] ) );
602
+				$min = min($min, give_sanitize_amount($price['_give_amount']));
603 603
 			}
604 604
 
605
-			if ( $price['_give_amount'] == $min ) {
605
+			if ($price['_give_amount'] == $min) {
606 606
 				$min_id = $key;
607 607
 			}
608 608
 		}
609 609
 
610
-		$low = $prices[ $min_id ]['_give_amount'];
610
+		$low = $prices[$min_id]['_give_amount'];
611 611
 
612 612
 	}
613 613
 
614
-	return give_sanitize_amount( $low );
614
+	return give_sanitize_amount($low);
615 615
 }
616 616
 
617 617
 /**
@@ -623,41 +623,41 @@  discard block
 block discarded – undo
623 623
  *
624 624
  * @return float Amount of the highest price
625 625
  */
626
-function give_get_highest_price_option( $form_id = 0 ) {
626
+function give_get_highest_price_option($form_id = 0) {
627 627
 
628
-	if ( empty( $form_id ) ) {
628
+	if (empty($form_id)) {
629 629
 		$form_id = get_the_ID();
630 630
 	}
631 631
 
632
-	if ( ! give_has_variable_prices( $form_id ) ) {
633
-		return give_get_form_price( $form_id );
632
+	if ( ! give_has_variable_prices($form_id)) {
633
+		return give_get_form_price($form_id);
634 634
 	}
635 635
 
636
-	$prices = give_get_variable_prices( $form_id );
636
+	$prices = give_get_variable_prices($form_id);
637 637
 
638 638
 	$high = 0.00;
639 639
 
640
-	if ( ! empty( $prices ) ) {
640
+	if ( ! empty($prices)) {
641 641
 
642 642
 		$max = 0;
643 643
 
644
-		foreach ( $prices as $key => $price ) {
645
-			if ( empty( $price['_give_amount'] ) ) {
644
+		foreach ($prices as $key => $price) {
645
+			if (empty($price['_give_amount'])) {
646 646
 				continue;
647 647
 			}
648
-			$give_amount = give_sanitize_amount( $price['_give_amount'] );
648
+			$give_amount = give_sanitize_amount($price['_give_amount']);
649 649
 
650
-			$max = max( $max, $give_amount );
650
+			$max = max($max, $give_amount);
651 651
 
652
-			if ( $give_amount == $max ) {
652
+			if ($give_amount == $max) {
653 653
 				$max_id = $key;
654 654
 			}
655 655
 		}
656 656
 
657
-		$high = $prices[ $max_id ]['_give_amount'];
657
+		$high = $prices[$max_id]['_give_amount'];
658 658
 	}
659 659
 
660
-	return give_sanitize_amount( $high );
660
+	return give_sanitize_amount($high);
661 661
 }
662 662
 
663 663
 /**
@@ -669,15 +669,15 @@  discard block
 block discarded – undo
669 669
  *
670 670
  * @return mixed string|int Price of the form
671 671
  */
672
-function give_get_form_price( $form_id = 0 ) {
672
+function give_get_form_price($form_id = 0) {
673 673
 
674
-	if ( empty( $form_id ) ) {
674
+	if (empty($form_id)) {
675 675
 		return false;
676 676
 	}
677 677
 
678
-	$form = new Give_Donate_Form( $form_id );
678
+	$form = new Give_Donate_Form($form_id);
679 679
 
680
-	return $form->__get( 'price' );
680
+	return $form->__get('price');
681 681
 }
682 682
 
683 683
 /**
@@ -689,15 +689,15 @@  discard block
 block discarded – undo
689 689
  *
690 690
  * @return mixed string|int Minimum price of the form
691 691
  */
692
-function give_get_form_minimum_price( $form_id = 0 ) {
692
+function give_get_form_minimum_price($form_id = 0) {
693 693
 
694
-	if ( empty( $form_id ) ) {
694
+	if (empty($form_id)) {
695 695
 		return false;
696 696
 	}
697 697
 
698
-	$form = new Give_Donate_Form( $form_id );
698
+	$form = new Give_Donate_Form($form_id);
699 699
 
700
-	return $form->__get( 'minimum_price' );
700
+	return $form->__get('minimum_price');
701 701
 
702 702
 }
703 703
 
@@ -712,52 +712,52 @@  discard block
 block discarded – undo
712 712
  *
713 713
  * @return int $formatted_price
714 714
  */
715
-function give_price( $form_id = 0, $echo = true, $price_id = false ) {
715
+function give_price($form_id = 0, $echo = true, $price_id = false) {
716 716
 
717
-	if ( empty( $form_id ) ) {
717
+	if (empty($form_id)) {
718 718
 		$form_id = get_the_ID();
719 719
 	}
720 720
 
721
-	if ( give_has_variable_prices( $form_id ) ) {
721
+	if (give_has_variable_prices($form_id)) {
722 722
 
723
-		$prices = give_get_variable_prices( $form_id );
723
+		$prices = give_get_variable_prices($form_id);
724 724
 
725
-		if ( false !== $price_id ) {
725
+		if (false !== $price_id) {
726 726
 
727 727
 			//loop through multi-prices to see which is default
728
-			foreach ( $prices as $price ) {
728
+			foreach ($prices as $price) {
729 729
 				//this is the default price
730
-				if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) {
730
+				if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
731 731
 					$price = (float) $price['_give_amount'];
732 732
 				};
733 733
 			}
734 734
 
735 735
 		} else {
736 736
 
737
-			$price = give_get_lowest_price_option( $form_id );
737
+			$price = give_get_lowest_price_option($form_id);
738 738
 		}
739 739
 
740
-		$price = give_sanitize_amount( $price );
740
+		$price = give_sanitize_amount($price);
741 741
 
742 742
 	} else {
743 743
 
744
-		$price = give_get_form_price( $form_id );
744
+		$price = give_get_form_price($form_id);
745 745
 
746 746
 	}
747 747
 
748
-	$price           = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id );
749
-	$formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>';
750
-	$formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price );
748
+	$price           = apply_filters('give_form_price', give_sanitize_amount($price), $form_id);
749
+	$formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>';
750
+	$formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price);
751 751
 
752
-	if ( $echo ) {
752
+	if ($echo) {
753 753
 		echo $formatted_price;
754 754
 	} else {
755 755
 		return $formatted_price;
756 756
 	}
757 757
 }
758 758
 
759
-add_filter( 'give_form_price', 'give_format_amount', 10 );
760
-add_filter( 'give_form_price', 'give_currency_filter', 20 );
759
+add_filter('give_form_price', 'give_format_amount', 10);
760
+add_filter('give_form_price', 'give_currency_filter', 20);
761 761
 
762 762
 
763 763
 /**
@@ -771,18 +771,18 @@  discard block
 block discarded – undo
771 771
  *
772 772
  * @return float $amount Amount of the price option
773 773
  */
774
-function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) {
775
-	$prices = give_get_variable_prices( $form_id );
774
+function give_get_price_option_amount($form_id = 0, $price_id = 0) {
775
+	$prices = give_get_variable_prices($form_id);
776 776
 
777 777
 	$amount = 0.00;
778 778
 
779
-	foreach ( $prices as $price ) {
780
-		if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) {
781
-			$amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00;
779
+	foreach ($prices as $price) {
780
+		if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) {
781
+			$amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00;
782 782
 		};
783 783
 	}
784 784
 
785
-	return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id );
785
+	return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id);
786 786
 }
787 787
 
788 788
 /**
@@ -794,13 +794,13 @@  discard block
 block discarded – undo
794 794
  *
795 795
  * @return mixed string|int Goal of the form
796 796
  */
797
-function give_get_form_goal( $form_id = 0 ) {
797
+function give_get_form_goal($form_id = 0) {
798 798
 
799
-	if ( empty( $form_id ) ) {
799
+	if (empty($form_id)) {
800 800
 		return false;
801 801
 	}
802 802
 
803
-	$form = new Give_Donate_Form( $form_id );
803
+	$form = new Give_Donate_Form($form_id);
804 804
 
805 805
 	return $form->goal;
806 806
 
@@ -816,27 +816,27 @@  discard block
 block discarded – undo
816 816
  *
817 817
  * @return string $formatted_goal
818 818
  */
819
-function give_goal( $form_id = 0, $echo = true ) {
819
+function give_goal($form_id = 0, $echo = true) {
820 820
 
821
-	if ( empty( $form_id ) ) {
821
+	if (empty($form_id)) {
822 822
 		$form_id = get_the_ID();
823 823
 	}
824 824
 
825
-	$goal = give_get_form_goal( $form_id );
825
+	$goal = give_get_form_goal($form_id);
826 826
 
827
-	$goal           = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id );
828
-	$formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>';
829
-	$formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal );
827
+	$goal           = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id);
828
+	$formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>';
829
+	$formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal);
830 830
 
831
-	if ( $echo ) {
831
+	if ($echo) {
832 832
 		echo $formatted_goal;
833 833
 	} else {
834 834
 		return $formatted_goal;
835 835
 	}
836 836
 }
837 837
 
838
-add_filter( 'give_form_goal', 'give_format_amount', 10 );
839
-add_filter( 'give_form_goal', 'give_currency_filter', 20 );
838
+add_filter('give_form_goal', 'give_format_amount', 10);
839
+add_filter('give_form_goal', 'give_currency_filter', 20);
840 840
 
841 841
 
842 842
 /**
@@ -846,13 +846,13 @@  discard block
 block discarded – undo
846 846
  * @global $give_options
847 847
  * @return bool $ret Whether or not the logged_in_only setting is set
848 848
  */
849
-function give_logged_in_only( $form_id ) {
849
+function give_logged_in_only($form_id) {
850 850
 
851
-	$form_option = get_post_meta( $form_id, '_give_logged_in_only', true );
851
+	$form_option = get_post_meta($form_id, '_give_logged_in_only', true);
852 852
 
853
-	$ret = ! empty( $form_option ) ? $form_option : false;
853
+	$ret = ! empty($form_option) ? $form_option : false;
854 854
 
855
-	return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id );
855
+	return (bool) apply_filters('give_logged_in_only', $ret, $form_id);
856 856
 
857 857
 }
858 858
 
@@ -864,10 +864,10 @@  discard block
 block discarded – undo
864 864
  *
865 865
  * @param $form_id
866 866
  */
867
-function give_show_login_register_option( $form_id ) {
867
+function give_show_login_register_option($form_id) {
868 868
 
869
-	$show_register_form = get_post_meta( $form_id, '_give_show_register_form', true );
869
+	$show_register_form = get_post_meta($form_id, '_give_show_register_form', true);
870 870
 
871
-	return apply_filters( 'give_show_register_form', $show_register_form, $form_id );
871
+	return apply_filters('give_show_register_form', $show_register_form, $form_id);
872 872
 
873 873
 }
874 874
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -781,7 +781,7 @@
 block discarded – undo
781 781
 	foreach ( $prices as $price ) {
782 782
 		if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) {
783 783
 			$amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00;
784
-            break;
784
+			break;
785 785
 		};
786 786
 	}
787 787
 
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
  * Used to redirect a user back to the purchase
157 157
  * page if there are errors present.
158 158
  *
159
- * @param array $args
159
+ * @param string $args
160 160
  *
161 161
  * @access public
162 162
  * @since  1.0
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
  *
391 391
  * @param int $form_id Give Form ID
392 392
  *
393
- * @return int $earnings Earnings for a certain form
393
+ * @return double $earnings Earnings for a certain form
394 394
  */
395 395
 function give_get_form_earnings_stats( $form_id = 0 ) {
396 396
 	$give_form = new Give_Donate_Form( $form_id );
Please login to merge, or discard this patch.
includes/error-tracking.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
  *
66 66
  * @since 1.0
67 67
  * @uses  Give_Session::get()
68
- * @return mixed array if errors are present, false if none found
68
+ * @return string array if errors are present, false if none found
69 69
  */
70 70
 function give_get_errors() {
71 71
 	return Give()->session->get( 'give_errors' );
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 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
 
@@ -29,33 +29,33 @@  discard block
 block discarded – undo
29 29
  *
30 30
  * @return void
31 31
  */
32
-function give_print_errors( $form_id ) {
32
+function give_print_errors($form_id) {
33 33
 
34 34
 	$errors = give_get_errors();
35 35
 
36
-	$request_form_id = isset( $_REQUEST['form-id'] ) ? intval( $_REQUEST['form-id'] ) : 0;
36
+	$request_form_id = isset($_REQUEST['form-id']) ? intval($_REQUEST['form-id']) : 0;
37 37
 
38 38
 	//Sanity checks first: Ensure that gateway returned errors display on the appropriate form
39
-	if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) {
39
+	if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) {
40 40
 		return;
41 41
 	}
42 42
 
43
-	if ( $errors ) {
44
-		$classes = apply_filters( 'give_error_class', array(
43
+	if ($errors) {
44
+		$classes = apply_filters('give_error_class', array(
45 45
 			'give_errors'
46
-		) );
47
-		echo '<div class="' . implode( ' ', $classes ) . '">';
46
+		));
47
+		echo '<div class="'.implode(' ', $classes).'">';
48 48
 		// Loop error codes and display errors
49
-		foreach ( $errors as $error_id => $error ) {
50
-			echo '<div class="give_error" id="give_error_' . $error_id . '"><p><strong>' . esc_html__( 'Error', 'give' ) . '</strong>: ' . $error . '</p></div>';
49
+		foreach ($errors as $error_id => $error) {
50
+			echo '<div class="give_error" id="give_error_'.$error_id.'"><p><strong>'.esc_html__('Error', 'give').'</strong>: '.$error.'</p></div>';
51 51
 		}
52 52
 		echo '</div>';
53 53
 		give_clear_errors();
54 54
 	}
55 55
 }
56 56
 
57
-add_action( 'give_purchase_form_before_personal_info', 'give_print_errors' );
58
-add_action( 'give_ajax_checkout_errors', 'give_print_errors' );
57
+add_action('give_purchase_form_before_personal_info', 'give_print_errors');
58
+add_action('give_ajax_checkout_errors', 'give_print_errors');
59 59
 
60 60
 /**
61 61
  * Get Errors
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
  * @return mixed array if errors are present, false if none found
69 69
  */
70 70
 function give_get_errors() {
71
-	return Give()->session->get( 'give_errors' );
71
+	return Give()->session->get('give_errors');
72 72
 }
73 73
 
74 74
 /**
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
  *
85 85
  * @return void
86 86
  */
87
-function give_set_error( $error_id, $error_message ) {
87
+function give_set_error($error_id, $error_message) {
88 88
 	$errors = give_get_errors();
89
-	if ( ! $errors ) {
89
+	if ( ! $errors) {
90 90
 		$errors = array();
91 91
 	}
92
-	$errors[ $error_id ] = $error_message;
93
-	Give()->session->set( 'give_errors', $errors );
92
+	$errors[$error_id] = $error_message;
93
+	Give()->session->set('give_errors', $errors);
94 94
 }
95 95
 
96 96
 /**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
  * @return void
102 102
  */
103 103
 function give_clear_errors() {
104
-	Give()->session->set( 'give_errors', null );
104
+	Give()->session->set('give_errors', null);
105 105
 }
106 106
 
107 107
 /**
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
  *
115 115
  * @return string
116 116
  */
117
-function give_unset_error( $error_id ) {
117
+function give_unset_error($error_id) {
118 118
 	$errors = give_get_errors();
119
-	if ( $errors ) {
120
-		unset( $errors[ $error_id ] );
121
-		Give()->session->set( 'give_errors', $errors );
119
+	if ($errors) {
120
+		unset($errors[$error_id]);
121
+		Give()->session->set('give_errors', $errors);
122 122
 	}
123 123
 }
124 124
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
  * @return void
130 130
  */
131 131
 function _give_die_handler() {
132
-	if ( defined( 'GIVE_UNIT_TESTS' ) ) {
132
+	if (defined('GIVE_UNIT_TESTS')) {
133 133
 		return '_give_die_handler';
134 134
 	} else {
135 135
 		die();
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
  * @since  1.0
145 145
  * @return void
146 146
  */
147
-function give_die( $message = '', $title = '', $status = 400 ) {
148
-	add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 );
149
-	add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 );
150
-	wp_die( $message, $title, array( 'response' => $status ) );
147
+function give_die($message = '', $title = '', $status = 400) {
148
+	add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3);
149
+	add_filter('wp_die_handler', '_give_die_handler', 10, 3);
150
+	wp_die($message, $title, array('response' => $status));
151 151
 }
152 152
 
153 153
 /**
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
  *
163 163
  * @return   string  $error
164 164
  */
165
-function give_output_error( $message, $echo = true, $error_id = 'warning' ) {
166
-	$error = '<div class="give_errors" id="give_error_' . $error_id . '"><p class="give_error  give_' . $error_id . '">' . $message . '</p></div>';
165
+function give_output_error($message, $echo = true, $error_id = 'warning') {
166
+	$error = '<div class="give_errors" id="give_error_'.$error_id.'"><p class="give_error  give_'.$error_id.'">'.$message.'</p></div>';
167 167
 
168
-	if ( $echo ) {
168
+	if ($echo) {
169 169
 		echo $error;
170 170
 	} else {
171 171
 		return $error;
Please login to merge, or discard this patch.
includes/login-register.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -33,20 +33,20 @@  discard block
 block discarded – undo
33 33
 		$login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url());
34 34
 	}
35 35
 
36
-    if ( empty( $logout_redirect ) ) {
37
-        $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
38
-    }
36
+	if ( empty( $logout_redirect ) ) {
37
+		$logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
38
+	}
39 39
 
40 40
 
41
-    // Add user_logout action to logout url.
42
-    $logout_redirect = add_query_arg(
43
-        array(
44
-            'give_action'       => 'user_logout',
45
-            'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ),
46
-            'give_logout_redirect' => urlencode( $logout_redirect )
47
-        ),
48
-        home_url('/')
49
-    );
41
+	// Add user_logout action to logout url.
42
+	$logout_redirect = add_query_arg(
43
+		array(
44
+			'give_action'       => 'user_logout',
45
+			'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ),
46
+			'give_logout_redirect' => urlencode( $logout_redirect )
47
+		),
48
+		home_url('/')
49
+	);
50 50
 
51 51
 	$give_login_redirect = $login_redirect;
52 52
 	$give_logout_redirect = $logout_redirect;
@@ -136,23 +136,23 @@  discard block
 block discarded – undo
136 136
  * @return void
137 137
  */
138 138
 function give_process_user_logout( $data ) {
139
-    if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) {
139
+	if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) {
140 140
 
141
-        // Prevent occurring of any custom action on wp_logout.
142
-        remove_all_actions( 'wp_logout' );
141
+		// Prevent occurring of any custom action on wp_logout.
142
+		remove_all_actions( 'wp_logout' );
143 143
 
144
-        // Before logout give action.
145
-        do_action( 'give_before_user_logout' );
144
+		// Before logout give action.
145
+		do_action( 'give_before_user_logout' );
146 146
 
147
-        // Logout user.
148
-        wp_logout();
147
+		// Logout user.
148
+		wp_logout();
149 149
 
150
-        // After logout give action.
151
-        do_action( 'give_after_user_logout' );
150
+		// After logout give action.
151
+		do_action( 'give_after_user_logout' );
152 152
 
153
-        wp_redirect( $data['give_logout_redirect'] );
154
-        give_die();
155
-    }
153
+		wp_redirect( $data['give_logout_redirect'] );
154
+		give_die();
155
+	}
156 156
 }
157 157
 
158 158
 add_action( 'give_user_logout', 'give_process_user_logout' );
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,15 +26,15 @@  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
-	global $give_login_redirect, $give_logout_redirect;;
29
+function give_login_form($login_redirect = '', $logout_redirect = '') {
30
+	global $give_login_redirect, $give_logout_redirect; ;
31 31
 
32
-	if ( empty( $login_redirect ) ) {
32
+	if (empty($login_redirect)) {
33 33
 		$login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url());
34 34
 	}
35 35
 
36
-    if ( empty( $logout_redirect ) ) {
37
-        $logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
36
+    if (empty($logout_redirect)) {
37
+        $logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url());
38 38
     }
39 39
 
40 40
 
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
     $logout_redirect = add_query_arg(
43 43
         array(
44 44
             'give_action'       => 'user_logout',
45
-            'give_logout_nonce' => wp_create_nonce( 'give-logout-nonce' ),
46
-            'give_logout_redirect' => urlencode( $logout_redirect )
45
+            'give_logout_nonce' => wp_create_nonce('give-logout-nonce'),
46
+            'give_logout_redirect' => urlencode($logout_redirect)
47 47
         ),
48 48
         home_url('/')
49 49
     );
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 
54 54
 	ob_start();
55 55
 
56
-	give_get_template_part( 'shortcode', 'login' );
56
+	give_get_template_part('shortcode', 'login');
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
 /**
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
  *
70 70
  * @return string Register form
71 71
  */
72
-function give_register_form( $redirect = '' ) {
72
+function give_register_form($redirect = '') {
73 73
 	global $give_options, $give_register_redirect;
74 74
 
75
-	if ( empty( $redirect ) ) {
75
+	if (empty($redirect)) {
76 76
 		$redirect = give_get_current_page_url();
77 77
 	}
78 78
 
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 
81 81
 	ob_start();
82 82
 
83
-	if ( ! is_user_logged_in() ) {
84
-		give_get_template_part( 'shortcode', 'register' );
83
+	if ( ! is_user_logged_in()) {
84
+		give_get_template_part('shortcode', 'register');
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_data->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_data->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', esc_html__( 'The password you entered is incorrect.', 'give' ) );
111
+				give_set_error('password_incorrect', esc_html__('The password you entered is incorrect.', 'give'));
112 112
 			}
113 113
 		} else {
114
-			give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) );
114
+			give_set_error('username_incorrect', esc_html__('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,27 +135,27 @@  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
         // Before logout give action.
145
-        do_action( 'give_before_user_logout' );
145
+        do_action('give_before_user_logout');
146 146
 
147 147
         // Logout user.
148 148
         wp_logout();
149 149
 
150 150
         // After logout give action.
151
-        do_action( 'give_after_user_logout' );
151
+        do_action('give_after_user_logout');
152 152
 
153
-        wp_redirect( $data['give_logout_redirect'] );
153
+        wp_redirect($data['give_logout_redirect']);
154 154
         give_die();
155 155
     }
156 156
 }
157 157
 
158
-add_action( 'give_user_logout', 'give_process_user_logout' );
158
+add_action('give_user_logout', 'give_process_user_logout');
159 159
 
160 160
 /**
161 161
  * Log User In
@@ -168,15 +168,15 @@  discard block
 block discarded – undo
168 168
  *
169 169
  * @return void
170 170
  */
171
-function give_log_user_in( $user_id, $user_login, $user_pass ) {
172
-	if ( $user_id < 1 ) {
171
+function give_log_user_in($user_id, $user_login, $user_pass) {
172
+	if ($user_id < 1) {
173 173
 		return;
174 174
 	}
175 175
 
176
-	wp_set_auth_cookie( $user_id );
177
-	wp_set_current_user( $user_id, $user_login );
178
-	do_action( 'wp_login', $user_login, get_userdata( $user_id ) );
179
-	do_action( 'give_log_user_in', $user_id, $user_login, $user_pass );
176
+	wp_set_auth_cookie($user_id);
177
+	wp_set_current_user($user_id, $user_login);
178
+	do_action('wp_login', $user_login, get_userdata($user_id));
179
+	do_action('give_log_user_in', $user_id, $user_login, $user_pass);
180 180
 }
181 181
 
182 182
 
@@ -189,70 +189,70 @@  discard block
 block discarded – undo
189 189
  *
190 190
  * @return void
191 191
  */
192
-function give_process_register_form( $data ) {
192
+function give_process_register_form($data) {
193 193
 
194
-	if ( is_user_logged_in() ) {
194
+	if (is_user_logged_in()) {
195 195
 		return;
196 196
 	}
197 197
 
198
-	if ( empty( $_POST['give_register_submit'] ) ) {
198
+	if (empty($_POST['give_register_submit'])) {
199 199
 		return;
200 200
 	}
201 201
 
202
-	do_action( 'give_pre_process_register_form' );
202
+	do_action('give_pre_process_register_form');
203 203
 
204
-	if ( empty( $data['give_user_login'] ) ) {
205
-		give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) );
204
+	if (empty($data['give_user_login'])) {
205
+		give_set_error('empty_username', esc_html__('Invalid username.', 'give'));
206 206
 	}
207 207
 
208
-	if ( username_exists( $data['give_user_login'] ) ) {
209
-		give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
208
+	if (username_exists($data['give_user_login'])) {
209
+		give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
210 210
 	}
211 211
 
212
-	if ( ! validate_username( $data['give_user_login'] ) ) {
213
-		give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
212
+	if ( ! validate_username($data['give_user_login'])) {
213
+		give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
214 214
 	}
215 215
 
216
-	if ( email_exists( $data['give_user_email'] ) ) {
217
-		give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) );
216
+	if (email_exists($data['give_user_email'])) {
217
+		give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give'));
218 218
 	}
219 219
 
220
-	if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) {
221
-		give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
220
+	if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) {
221
+		give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
222 222
 	}
223 223
 
224
-	if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) {
225
-		give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) );
224
+	if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) {
225
+		give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give'));
226 226
 	}
227 227
 
228
-	if ( empty( $_POST['give_user_pass'] ) ) {
229
-		give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) );
228
+	if (empty($_POST['give_user_pass'])) {
229
+		give_set_error('empty_password', esc_html__('Please enter a password.', 'give'));
230 230
 	}
231 231
 
232
-	if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) {
233
-		give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
232
+	if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) {
233
+		give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
234 234
 	}
235 235
 
236
-	do_action( 'give_process_register_form' );
236
+	do_action('give_process_register_form');
237 237
 
238 238
 	// Check for errors and redirect if none present
239 239
 	$errors = give_get_errors();
240 240
 
241
-	if ( empty( $errors ) ) {
241
+	if (empty($errors)) {
242 242
 
243
-		$redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] );
243
+		$redirect = apply_filters('give_register_redirect', $data['give_redirect']);
244 244
 
245
-		give_register_and_login_new_user( array(
245
+		give_register_and_login_new_user(array(
246 246
 			'user_login'      => $data['give_user_login'],
247 247
 			'user_pass'       => $data['give_user_pass'],
248 248
 			'user_email'      => $data['give_user_email'],
249
-			'user_registered' => date( 'Y-m-d H:i:s' ),
250
-			'role'            => get_option( 'default_role' )
251
-		) );
249
+			'user_registered' => date('Y-m-d H:i:s'),
250
+			'role'            => get_option('default_role')
251
+		));
252 252
 
253
-		wp_redirect( $redirect );
253
+		wp_redirect($redirect);
254 254
 		give_die();
255 255
 	}
256 256
 }
257 257
 
258
-add_action( 'give_user_register', 'give_process_register_form' );
259 258
\ No newline at end of file
259
+add_action('give_user_register', 'give_process_register_form');
260 260
\ No newline at end of file
Please login to merge, or discard this patch.
includes/shortcodes.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 		//validate display_style and float_labels value
93 93
 		if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) )
94
-		     || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
94
+			 || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
95 95
 		) {
96 96
 
97 97
 			$atts[ $key ] = '';
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
  */
170 170
 function give_login_form_shortcode( $atts, $content = null ) {
171 171
 	$atts = shortcode_atts( array(
172
-        // Add backward compatibility for redirect attribute.
173
-        'redirect'          => '',
172
+		// Add backward compatibility for redirect attribute.
173
+		'redirect'          => '',
174 174
 
175 175
 		'login-redirect'    => '',
176 176
 		'logout-redirect'   => '',
177 177
 	), $atts, 'give_login' );
178 178
 
179
-    // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
180
-    $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' );
179
+	// Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
180
+	$atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' );
181 181
 
182 182
 	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
183 183
 }
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 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,28 +25,28 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_donation_history() {
27 27
 
28
-	$email_access = give_get_option( 'email_access' );
28
+	$email_access = give_get_option('email_access');
29 29
 
30 30
 	//Is user logged in? Does a session exist? Does an email-access token exist?
31
-	if ( is_user_logged_in() || Give()->session->get_session_expiration() !== false || ( $email_access == 'on' && Give()->email_access->token_exists ) ) {
31
+	if (is_user_logged_in() || Give()->session->get_session_expiration() !== false || ($email_access == 'on' && Give()->email_access->token_exists)) {
32 32
 		ob_start();
33
-		give_get_template_part( 'history', 'donations' );
33
+		give_get_template_part('history', 'donations');
34 34
 
35 35
 		return ob_get_clean();
36 36
 	} //Is Email-based access enabled?
37
-	elseif ( $email_access == 'on' ) {
37
+	elseif ($email_access == 'on') {
38 38
 
39 39
 		ob_start();
40
-		give_get_template_part( 'email', 'login-form' );
40
+		give_get_template_part('email', 'login-form');
41 41
 
42 42
 		return ob_get_clean();
43 43
 	} else {
44
-		$message = esc_html__( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' );
45
-		echo apply_filters( 'give_donation_history_nonuser_message', give_output_error( $message, false ), $message );
44
+		$message = esc_html__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give');
45
+		echo apply_filters('give_donation_history_nonuser_message', give_output_error($message, false), $message);
46 46
 	}
47 47
 }
48 48
 
49
-add_shortcode( 'donation_history', 'give_donation_history' );
49
+add_shortcode('donation_history', 'give_donation_history');
50 50
 
51 51
 /**
52 52
  * Donation Form Shortcode
@@ -60,53 +60,53 @@  discard block
 block discarded – undo
60 60
  *
61 61
  * @return string
62 62
  */
63
-function give_form_shortcode( $atts, $content = null ) {
64
-	$atts = shortcode_atts( array(
63
+function give_form_shortcode($atts, $content = null) {
64
+	$atts = shortcode_atts(array(
65 65
 		'id'            => '',
66 66
 		'show_title'    => true,
67 67
 		'show_goal'     => true,
68 68
 		'show_content'  => '',
69 69
 		'float_labels'  => '',
70 70
 		'display_style' => '',
71
-	), $atts, 'give_form' );
71
+	), $atts, 'give_form');
72 72
 
73
-	foreach ( $atts as $key => $value ) {
73
+	foreach ($atts as $key => $value) {
74 74
 		//convert shortcode_atts values to booleans
75
-		if ( $key == 'show_title' ) {
76
-			$atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN );
77
-		} elseif ( $key == 'show_goal' ) {
78
-			$atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN );
75
+		if ($key == 'show_title') {
76
+			$atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN);
77
+		} elseif ($key == 'show_goal') {
78
+			$atts[$key] = filter_var($atts[$key], FILTER_VALIDATE_BOOLEAN);
79 79
 		}
80 80
 
81 81
 		//validate show_content value
82
-		if ( $key == 'show_content' ) {
83
-			if ( ! in_array( $value, array( 'none', 'above', 'below' ) ) ) {
84
-				$atts[ $key ] = '';
85
-			} else if ( $value == 'above' ) {
86
-				$atts[ $key ] = 'give_pre_form';
87
-			} else if ( $value == 'below' ) {
88
-				$atts[ $key ] = 'give_post_form';
82
+		if ($key == 'show_content') {
83
+			if ( ! in_array($value, array('none', 'above', 'below'))) {
84
+				$atts[$key] = '';
85
+			} else if ($value == 'above') {
86
+				$atts[$key] = 'give_pre_form';
87
+			} else if ($value == 'below') {
88
+				$atts[$key] = 'give_post_form';
89 89
 			}
90 90
 		}
91 91
 
92 92
 		//validate display_style and float_labels value
93
-		if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) )
94
-		     || ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
93
+		if (($key == 'display_style' && ! in_array($value, array('onpage', 'reveal', 'modal')))
94
+		     || ($key == 'float_labels' && ! in_array($value, array('enabled', 'disabled')))
95 95
 		) {
96 96
 
97
-			$atts[ $key ] = '';
97
+			$atts[$key] = '';
98 98
 		}
99 99
 	}
100 100
 
101 101
 	//get the Give Form
102 102
 	ob_start();
103
-	give_get_donation_form( $atts );
103
+	give_get_donation_form($atts);
104 104
 	$final_output = ob_get_clean();
105 105
 
106
-	return apply_filters( 'give_donate_form', $final_output, $atts );
106
+	return apply_filters('give_donate_form', $final_output, $atts);
107 107
 }
108 108
 
109
-add_shortcode( 'give_form', 'give_form_shortcode' );
109
+add_shortcode('give_form', 'give_form_shortcode');
110 110
 
111 111
 /**
112 112
  * Donation Form Goal Shortcode.
@@ -120,37 +120,37 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return string
122 122
  */
123
-function give_goal_shortcode( $atts, $content = null ) {
124
-	$atts = shortcode_atts( array(
123
+function give_goal_shortcode($atts, $content = null) {
124
+	$atts = shortcode_atts(array(
125 125
 		'id'        => '',
126 126
 		'show_text' => true,
127 127
 		'show_bar'  => true,
128
-	), $atts, 'give_goal' );
128
+	), $atts, 'give_goal');
129 129
 
130 130
 
131 131
 	//get the Give Form.
132 132
 	ob_start();
133 133
 
134 134
 	//Sanity check 1: ensure there is an ID Provided.
135
-	if ( empty( $atts['id'] ) ) {
136
-		give_output_error( esc_html__( 'Error: No Donation form ID for the shortcode provided.', 'give' ), true );
135
+	if (empty($atts['id'])) {
136
+		give_output_error(esc_html__('Error: No Donation form ID for the shortcode provided.', 'give'), true);
137 137
 	}
138 138
 
139 139
 	//Sanity check 2: Check that this form even has Goals enabled.
140
-	$goal_option = get_post_meta( $atts['id'], '_give_goal_option', true );
141
-	if ( empty( $goal_option ) || $goal_option !== 'yes' ) {
142
-		give_output_error( esc_html__( 'Error: This form does not have Goals enabled.', 'give' ), true );
140
+	$goal_option = get_post_meta($atts['id'], '_give_goal_option', true);
141
+	if (empty($goal_option) || $goal_option !== 'yes') {
142
+		give_output_error(esc_html__('Error: This form does not have Goals enabled.', 'give'), true);
143 143
 	} else {
144 144
 		//Passed all sanity checks: output Goal.
145
-		give_show_goal_progress( $atts['id'], $atts );
145
+		give_show_goal_progress($atts['id'], $atts);
146 146
 	}
147 147
 
148 148
 	$final_output = ob_get_clean();
149 149
 
150
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
150
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
151 151
 }
152 152
 
153
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
153
+add_shortcode('give_goal', 'give_goal_shortcode');
154 154
 
155 155
 
156 156
 /**
@@ -167,22 +167,22 @@  discard block
 block discarded – undo
167 167
  * @uses  give_login_form()
168 168
  * @return string
169 169
  */
170
-function give_login_form_shortcode( $atts, $content = null ) {
171
-	$atts = shortcode_atts( array(
170
+function give_login_form_shortcode($atts, $content = null) {
171
+	$atts = shortcode_atts(array(
172 172
         // Add backward compatibility for redirect attribute.
173 173
         'redirect'          => '',
174 174
 
175 175
 		'login-redirect'    => '',
176 176
 		'logout-redirect'   => '',
177
-	), $atts, 'give_login' );
177
+	), $atts, 'give_login');
178 178
 
179 179
     // Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
180
-    $atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect' ] ) ? $atts['redirect'] : '' );
180
+    $atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : '');
181 181
 
182
-	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
182
+	return give_login_form($atts['login-redirect'], $atts['logout-redirect']);
183 183
 }
184 184
 
185
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
185
+add_shortcode('give_login', 'give_login_form_shortcode');
186 186
 
187 187
 /**
188 188
  * Register Shortcode.
@@ -197,15 +197,15 @@  discard block
 block discarded – undo
197 197
  * @uses  give_register_form()
198 198
  * @return string
199 199
  */
200
-function give_register_form_shortcode( $atts, $content = null ) {
201
-	$atts = shortcode_atts( array(
200
+function give_register_form_shortcode($atts, $content = null) {
201
+	$atts = shortcode_atts(array(
202 202
 		'redirect' => '',
203
-	), $atts, 'give_register' );
203
+	), $atts, 'give_register');
204 204
 
205
-	return give_register_form( $atts['redirect'] );
205
+	return give_register_form($atts['redirect']);
206 206
 }
207 207
 
208
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
208
+add_shortcode('give_register', 'give_register_form_shortcode');
209 209
 
210 210
 
211 211
 /**
@@ -220,62 +220,62 @@  discard block
 block discarded – undo
220 220
  *
221 221
  * @return string
222 222
  */
223
-function give_receipt_shortcode( $atts, $content = null ) {
223
+function give_receipt_shortcode($atts, $content = null) {
224 224
 
225 225
 	global $give_receipt_args, $payment;
226 226
 
227
-	$give_receipt_args = shortcode_atts( array(
228
-		'error'          => esc_html__( 'Sorry, you are missing the payment key to view this donation receipt.', 'give' ),
227
+	$give_receipt_args = shortcode_atts(array(
228
+		'error'          => esc_html__('Sorry, you are missing the payment key to view this donation receipt.', 'give'),
229 229
 		'price'          => true,
230 230
 		'donor'          => true,
231 231
 		'date'           => true,
232 232
 		'payment_key'    => false,
233 233
 		'payment_method' => true,
234 234
 		'payment_id'     => true
235
-	), $atts, 'give_receipt' );
235
+	), $atts, 'give_receipt');
236 236
 
237 237
 	//set $session var
238 238
 	$session = give_get_purchase_session();
239 239
 
240 240
 	//set payment key var
241
-	if ( isset( $_GET['payment_key'] ) ) {
242
-		$payment_key = urldecode( $_GET['payment_key'] );
243
-	} elseif ( $session ) {
241
+	if (isset($_GET['payment_key'])) {
242
+		$payment_key = urldecode($_GET['payment_key']);
243
+	} elseif ($session) {
244 244
 		$payment_key = $session['purchase_key'];
245
-	} elseif ( $give_receipt_args['payment_key'] ) {
245
+	} elseif ($give_receipt_args['payment_key']) {
246 246
 		$payment_key = $give_receipt_args['payment_key'];
247 247
 	}
248 248
 
249
-	$email_access = give_get_option( 'email_access' );
249
+	$email_access = give_get_option('email_access');
250 250
 
251 251
 	// No payment_key found & Email Access is Turned on:
252
-	if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_access->token_exists ) {
252
+	if ( ! isset($payment_key) && $email_access == 'on' && ! Give()->email_access->token_exists) {
253 253
 
254 254
 		ob_start();
255 255
 
256
-		give_get_template_part( 'email-login-form' );
256
+		give_get_template_part('email-login-form');
257 257
 
258 258
 		return ob_get_clean();
259 259
 
260
-	} elseif ( ! isset( $payment_key ) ) {
260
+	} elseif ( ! isset($payment_key)) {
261 261
 
262
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
262
+		return give_output_error($give_receipt_args['error'], false, 'error');
263 263
 
264 264
 	}
265 265
 
266
-	$payment_id    = give_get_purchase_id_by_key( $payment_key );
267
-	$user_can_view = give_can_view_receipt( $payment_key );
266
+	$payment_id    = give_get_purchase_id_by_key($payment_key);
267
+	$user_can_view = give_can_view_receipt($payment_key);
268 268
 
269 269
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt.
270
-	if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists ) {
270
+	if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists) {
271 271
 
272 272
 		ob_start();
273 273
 
274
-		give_get_template_part( 'email-login-form' );
274
+		give_get_template_part('email-login-form');
275 275
 
276 276
 		return ob_get_clean();
277 277
 
278
-	} elseif ( ! $user_can_view ) {
278
+	} elseif ( ! $user_can_view) {
279 279
 
280 280
 		global $give_login_redirect;
281 281
 
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 
284 284
 		ob_start();
285 285
 
286
-		give_output_error( apply_filters( 'give_must_be_logged_in_error_message', esc_html__( 'You must be logged in to view this donation payment receipt.', 'give' ) ) );
286
+		give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation payment receipt.', 'give')));
287 287
 
288
-		give_get_template_part( 'shortcode', 'login' );
288
+		give_get_template_part('shortcode', 'login');
289 289
 
290 290
 		$login_form = ob_get_clean();
291 291
 
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 	 * or if user is logged in and the user can view sensitive shop data.
301 301
 	 *
302 302
 	 */
303
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
304
-		return give_output_error( $give_receipt_args['error'], false, 'error' );
303
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
304
+		return give_output_error($give_receipt_args['error'], false, 'error');
305 305
 	}
306 306
 
307 307
 	ob_start();
308 308
 
309
-	give_get_template_part( 'shortcode', 'receipt' );
309
+	give_get_template_part('shortcode', 'receipt');
310 310
 
311 311
 	$display = ob_get_clean();
312 312
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
 }
317 317
 
318
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
318
+add_shortcode('give_receipt', 'give_receipt_shortcode');
319 319
 
320 320
 /**
321 321
  * Profile Editor Shortcode.
@@ -335,18 +335,18 @@  discard block
 block discarded – undo
335 335
  *
336 336
  * @return string Output generated from the profile editor
337 337
  */
338
-function give_profile_editor_shortcode( $atts, $content = null ) {
338
+function give_profile_editor_shortcode($atts, $content = null) {
339 339
 
340 340
 	ob_start();
341 341
 
342
-	give_get_template_part( 'shortcode', 'profile-editor' );
342
+	give_get_template_part('shortcode', 'profile-editor');
343 343
 
344 344
 	$display = ob_get_clean();
345 345
 
346 346
 	return $display;
347 347
 }
348 348
 
349
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
349
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
350 350
 
351 351
 /**
352 352
  * Process Profile Updater Form.
@@ -359,30 +359,30 @@  discard block
 block discarded – undo
359 359
  *
360 360
  * @return bool
361 361
  */
362
-function give_process_profile_editor_updates( $data ) {
362
+function give_process_profile_editor_updates($data) {
363 363
 	// Profile field change request
364
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
364
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
365 365
 		return false;
366 366
 	}
367 367
 
368 368
 	// Nonce security
369
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
369
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
370 370
 		return false;
371 371
 	}
372 372
 
373 373
 	$user_id       = get_current_user_id();
374
-	$old_user_data = get_userdata( $user_id );
375
-
376
-	$display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
377
-	$first_name   = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
378
-	$last_name    = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
379
-	$email        = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
380
-	$line1        = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' );
381
-	$line2        = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' );
382
-	$city         = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' );
383
-	$state        = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' );
384
-	$zip          = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' );
385
-	$country      = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' );
374
+	$old_user_data = get_userdata($user_id);
375
+
376
+	$display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
377
+	$first_name   = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
378
+	$last_name    = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
379
+	$email        = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
380
+	$line1        = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : '');
381
+	$line2        = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : '');
382
+	$city         = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : '');
383
+	$state        = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : '');
384
+	$zip          = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : '');
385
+	$country      = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : '');
386 386
 
387 387
 	$userdata = array(
388 388
 		'ID'           => $user_id,
@@ -410,46 +410,46 @@  discard block
 block discarded – undo
410 410
 	 * @param int   $user_id  The ID of the user.
411 411
 	 * @param array $userdata User info, including ID, first name, last name, display name and email.
412 412
 	 */
413
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
413
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
414 414
 
415 415
 	// New password
416
-	if ( ! empty( $data['give_new_user_pass1'] ) ) {
417
-		if ( $data['give_new_user_pass1'] !== $data['give_new_user_pass2'] ) {
418
-			give_set_error( 'password_mismatch', esc_html__( 'The passwords you entered do not match. Please try again.', 'give' ) );
416
+	if ( ! empty($data['give_new_user_pass1'])) {
417
+		if ($data['give_new_user_pass1'] !== $data['give_new_user_pass2']) {
418
+			give_set_error('password_mismatch', esc_html__('The passwords you entered do not match. Please try again.', 'give'));
419 419
 		} else {
420 420
 			$userdata['user_pass'] = $data['give_new_user_pass1'];
421 421
 		}
422 422
 	}
423 423
 
424
-	if( empty( $email ) ) {
424
+	if (empty($email)) {
425 425
 		// Make sure email should not be empty.
426
-		give_set_error( 'email_empty', esc_html__( 'The email you entered is empty.', 'give' ) );
426
+		give_set_error('email_empty', esc_html__('The email you entered is empty.', 'give'));
427 427
 
428
-	}else if ( ! is_email( $email ) ){
428
+	} else if ( ! is_email($email)) {
429 429
 		// Make sure email should be valid.
430
-		give_set_error( 'email_not_valid', esc_html__( 'The email you entered is not valid. Please use another', 'give' ) );
430
+		give_set_error('email_not_valid', esc_html__('The email you entered is not valid. Please use another', 'give'));
431 431
 
432
-	}else if ( $email != $old_user_data->user_email ) {
432
+	} else if ($email != $old_user_data->user_email) {
433 433
 		// Make sure the new email doesn't belong to another user
434
-		if ( email_exists( $email ) ) {
435
-			give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) );
434
+		if (email_exists($email)) {
435
+			give_set_error('email_exists', esc_html__('The email you entered belongs to another user. Please use another.', 'give'));
436 436
 		}
437 437
 	}
438 438
 
439 439
 	// Check for errors
440 440
 	$errors = give_get_errors();
441 441
 
442
-	if ( $errors ) {
442
+	if ($errors) {
443 443
 		// Send back to the profile editor if there are errors
444
-		wp_redirect( $data['give_redirect'] );
444
+		wp_redirect($data['give_redirect']);
445 445
 		give_die();
446 446
 	}
447 447
 
448 448
 	// Update the user
449
-	$meta    = update_user_meta( $user_id, '_give_user_address', $address );
450
-	$updated = wp_update_user( $userdata );
449
+	$meta    = update_user_meta($user_id, '_give_user_address', $address);
450
+	$updated = wp_update_user($userdata);
451 451
 
452
-	if ( $updated ) {
452
+	if ($updated) {
453 453
 
454 454
 		/**
455 455
 		 * Fires after updating user profile.
@@ -459,13 +459,13 @@  discard block
 block discarded – undo
459 459
 		 * @param int   $user_id  The ID of the user.
460 460
 		 * @param array $userdata User info, including ID, first name, last name, display name and email.
461 461
 		 */
462
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
463
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
462
+		do_action('give_user_profile_updated', $user_id, $userdata);
463
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
464 464
 		give_die();
465 465
 	}
466 466
 
467 467
 	return false;
468 468
 }
469 469
 
470
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
470
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
471 471
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -425,11 +425,11 @@
 block discarded – undo
425 425
 		// Make sure email should not be empty.
426 426
 		give_set_error( 'email_empty', esc_html__( 'The email you entered is empty.', 'give' ) );
427 427
 
428
-	}else if ( ! is_email( $email ) ){
428
+	} else if ( ! is_email( $email ) ){
429 429
 		// Make sure email should be valid.
430 430
 		give_set_error( 'email_not_valid', esc_html__( 'The email you entered is not valid. Please use another', 'give' ) );
431 431
 
432
-	}else if ( $email != $old_user_data->user_email ) {
432
+	} else if ( $email != $old_user_data->user_email ) {
433 433
 		// Make sure the new email doesn't belong to another user
434 434
 		if ( email_exists( $email ) ) {
435 435
 			give_set_error( 'email_exists', esc_html__( 'The email you entered belongs to another user. Please use another.', 'give' ) );
Please login to merge, or discard this patch.
includes/price-functions.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return bool true if has variable prices, false otherwise
25 25
  */
26
-function give_has_variable_prices( $form_id = 0 ) {
26
+function give_has_variable_prices($form_id = 0) {
27 27
 
28
-	if ( empty( $form_id ) ) {
28
+	if (empty($form_id)) {
29 29
 		return false;
30 30
 	}
31 31
 
32
-	$form = new Give_Donate_Form( $form_id );
32
+	$form = new Give_Donate_Form($form_id);
33 33
 
34 34
 	return $form->has_variable_prices();
35 35
 }
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @return array Variable prices
46 46
  */
47
-function give_get_variable_prices( $form_id = 0 ) {
47
+function give_get_variable_prices($form_id = 0) {
48 48
 
49
-	if ( empty( $form_id ) ) {
49
+	if (empty($form_id)) {
50 50
 		return false;
51 51
 	}
52 52
 
53
-	$form = new Give_Donate_Form( $form_id );
53
+	$form = new Give_Donate_Form($form_id);
54 54
 
55 55
 	return $form->prices;
56 56
 
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
  *
68 68
  * @return string $default_price
69 69
  */
70
-function give_get_default_multilevel_amount( $form_id ) {
70
+function give_get_default_multilevel_amount($form_id) {
71 71
 	$default_price = '1.00';
72
-	$prices        = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id );
72
+	$prices        = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id);
73 73
 
74
-	foreach ( $prices as $price ) {
74
+	foreach ($prices as $price) {
75 75
 
76
-		if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) {
76
+		if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
77 77
 			$default_price = $price['_give_amount'];
78 78
 		}
79 79
 
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
  * @return string $default_price
95 95
  * @since      1.0
96 96
  */
97
-function give_get_default_form_amount( $form_id ) {
97
+function give_get_default_form_amount($form_id) {
98 98
 
99
-	if ( give_has_variable_prices( $form_id ) ) {
99
+	if (give_has_variable_prices($form_id)) {
100 100
 
101
-		$default_amount = give_get_default_multilevel_amount( $form_id );
101
+		$default_amount = give_get_default_multilevel_amount($form_id);
102 102
 
103 103
 	} else {
104 104
 
105
-		$default_amount = get_post_meta( $form_id, '_give_set_price', true );
105
+		$default_amount = get_post_meta($form_id, '_give_set_price', true);
106 106
 
107 107
 	}
108 108
 
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
  * 
124 124
  * @return bool
125 125
  */
126
-function give_is_custom_price_mode( $form_id = 0 ) {
126
+function give_is_custom_price_mode($form_id = 0) {
127 127
 
128
-	if ( empty( $form_id ) ) {
128
+	if (empty($form_id)) {
129 129
 		return false;
130 130
 	}
131 131
 
132
-	$form = new Give_Donate_Form( $form_id );
132
+	$form = new Give_Donate_Form($form_id);
133 133
 
134 134
 	return $form->is_custom_price_mode();
135 135
 }
136 136
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-customer.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -544,7 +544,7 @@
 block discarded – undo
544 544
 
545 545
         if( $payment_total_diff > 0 ) {
546 546
             $this->increase_value( $payment_total_diff );
547
-        }else{
547
+        } else{
548 548
             // Pass payment total difference as +ve value to decrease amount from user lifetime stat.
549 549
             $this->decrease_value( -$payment_total_diff );
550 550
         }
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -565,12 +565,12 @@  discard block
 block discarded – undo
565 565
 
566 566
 	/**
567 567
 	 * Decrease/Increase a customer's lifetime value.
568
-     *
569
-     * This function will update donation stat on basis of current amount and new amount donation difference.
570
-     * Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat.
571
-     *
568
+	 *
569
+	 * This function will update donation stat on basis of current amount and new amount donation difference.
570
+	 * Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat.
571
+	 *
572 572
 	 * @since  1.0
573
-     * @access public
573
+	 * @access public
574 574
 	 *
575 575
 	 * @param  float $curr_amount Current Donation amount.
576 576
 	 * @param  float $new_amount  New (changed) Donation amount.
@@ -578,35 +578,35 @@  discard block
 block discarded – undo
578 578
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
579 579
 	 */
580 580
 	public function update_donation_value( $curr_amount, $new_amount ) {
581
-        /**
582
-         * Payment total difference value can be:
583
-         *  zero   (in case amount not change)
584
-         *  or -ve (in case amount decrease)
585
-         *  or +ve (in case amount increase)
586
-         */
587
-        $payment_total_diff = $new_amount - $curr_amount;
588
-
589
-        // We do not need to update donation stat if donation did not change.
590
-        if( ! $payment_total_diff ) {
591
-            return false;
592
-        }
593
-
594
-
595
-        if( $payment_total_diff > 0 ) {
596
-            $this->increase_value( $payment_total_diff );
597
-        }else{
598
-            // Pass payment total difference as +ve value to decrease amount from user lifetime stat.
599
-            $this->decrease_value( -$payment_total_diff );
600
-        }
601
-
602
-        return $this->purchase_value;
581
+		/**
582
+		 * Payment total difference value can be:
583
+		 *  zero   (in case amount not change)
584
+		 *  or -ve (in case amount decrease)
585
+		 *  or +ve (in case amount increase)
586
+		 */
587
+		$payment_total_diff = $new_amount - $curr_amount;
588
+
589
+		// We do not need to update donation stat if donation did not change.
590
+		if( ! $payment_total_diff ) {
591
+			return false;
592
+		}
593
+
594
+
595
+		if( $payment_total_diff > 0 ) {
596
+			$this->increase_value( $payment_total_diff );
597
+		}else{
598
+			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
599
+			$this->decrease_value( -$payment_total_diff );
600
+		}
601
+
602
+		return $this->purchase_value;
603 603
 	}
604 604
 
605 605
 	/**
606 606
 	 * Get the parsed notes for a customer as an array.
607 607
 	 *
608 608
 	 * @since  1.0
609
-     * @access public
609
+	 * @access public
610 610
 	 *
611 611
 	 * @param  integer $length The number of notes to get.
612 612
 	 * @param  integer $paged  What note to start at.
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 	 * Get the total number of notes we have after parsing.
632 632
 	 *
633 633
 	 * @since  1.0
634
-     * @access public
634
+	 * @access public
635 635
 	 *
636 636
 	 * @return int The number of notes for the customer.
637 637
 	 */
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 	 * Add a note for the customer.
649 649
 	 *
650 650
 	 * @since  1.0
651
-     * @access public
651
+	 * @access public
652 652
 	 *
653 653
 	 * @param  string $note   The note to add. Default is empty.
654 654
 	 *
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 	 * Get the notes column for the customer
691 691
 	 *
692 692
 	 * @since  1.0
693
-     * @access private
693
+	 * @access private
694 694
 	 *
695 695
 	 * @return string The Notes for the customer, non-parsed.
696 696
 	 */
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
 	 * Sanitize the data for update/create
769 769
 	 *
770 770
 	 * @since  1.0
771
-     * @access private
771
+	 * @access private
772 772
 	 *
773 773
 	 * @param  array $data The data to sanitize.
774 774
 	 *
Please login to merge, or discard this patch.
Spacing   +141 added lines, -141 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
 
@@ -134,29 +134,29 @@  discard block
 block discarded – undo
134 134
 	 * @param  bool $_id_or_email 
135 135
 	 * @param  bool $by_user_id
136 136
 	 */
137
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
137
+	public function __construct($_id_or_email = false, $by_user_id = false) {
138 138
 
139 139
 		$this->db = new Give_DB_Customers;
140 140
 
141
-		if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) {
141
+		if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) {
142 142
 			return false;
143 143
 		}
144 144
 
145
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
145
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
146 146
 
147
-		if ( is_numeric( $_id_or_email ) ) {
147
+		if (is_numeric($_id_or_email)) {
148 148
 			$field = $by_user_id ? 'user_id' : 'id';
149 149
 		} else {
150 150
 			$field = 'email';
151 151
 		}
152 152
 
153
-		$customer = $this->db->get_customer_by( $field, $_id_or_email );
153
+		$customer = $this->db->get_customer_by($field, $_id_or_email);
154 154
 
155
-		if ( empty( $customer ) || ! is_object( $customer ) ) {
155
+		if (empty($customer) || ! is_object($customer)) {
156 156
 			return false;
157 157
 		}
158 158
 
159
-		$this->setup_customer( $customer );
159
+		$this->setup_customer($customer);
160 160
 
161 161
 	}
162 162
 
@@ -172,15 +172,15 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return bool             If the setup was successful or not.
174 174
 	 */
175
-	private function setup_customer( $customer ) {
175
+	private function setup_customer($customer) {
176 176
 
177
-		if ( ! is_object( $customer ) ) {
177
+		if ( ! is_object($customer)) {
178 178
 			return false;
179 179
 		}
180 180
 
181
-		foreach ( $customer as $key => $value ) {
181
+		foreach ($customer as $key => $value) {
182 182
 
183
-			switch ( $key ) {
183
+			switch ($key) {
184 184
 
185 185
 				case 'notes':
186 186
 					$this->$key = $this->get_notes();
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		}
196 196
 
197 197
 		// Customer ID and email are the only things that are necessary, make sure they exist
198
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
198
+		if ( ! empty($this->id) && ! empty($this->email)) {
199 199
 			return true;
200 200
 		}
201 201
 
@@ -209,16 +209,16 @@  discard block
 block discarded – undo
209 209
 	 * @since  1.0
210 210
 	 * @access public
211 211
 	 */
212
-	public function __get( $key ) {
212
+	public function __get($key) {
213 213
 
214
-		if ( method_exists( $this, 'get_' . $key ) ) {
214
+		if (method_exists($this, 'get_'.$key)) {
215 215
 
216
-			return call_user_func( array( $this, 'get_' . $key ) );
216
+			return call_user_func(array($this, 'get_'.$key));
217 217
 
218 218
 		} else {
219 219
 
220 220
 			/* translators: %s: property key */
221
-			return new WP_Error( 'give-customer-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
221
+			return new WP_Error('give-customer-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
222 222
 
223 223
 		}
224 224
 
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 	 *
235 235
 	 * @return mixed       False if not a valid creation, Customer ID if user is found or valid creation.
236 236
 	 */
237
-	public function create( $data = array() ) {
237
+	public function create($data = array()) {
238 238
 
239
-		if ( $this->id != 0 || empty( $data ) ) {
239
+		if ($this->id != 0 || empty($data)) {
240 240
 			return false;
241 241
 		}
242 242
 
@@ -244,34 +244,34 @@  discard block
 block discarded – undo
244 244
 			'payment_ids' => ''
245 245
 		);
246 246
 
247
-		$args = wp_parse_args( $data, $defaults );
248
-		$args = $this->sanitize_columns( $args );
247
+		$args = wp_parse_args($data, $defaults);
248
+		$args = $this->sanitize_columns($args);
249 249
 
250
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
250
+		if (empty($args['email']) || ! is_email($args['email'])) {
251 251
 			return false;
252 252
 		}
253 253
 
254
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
255
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
254
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
255
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
256 256
 		}
257 257
 
258
-		do_action( 'give_customer_pre_create', $args );
258
+		do_action('give_customer_pre_create', $args);
259 259
 
260 260
 		$created = false;
261 261
 
262 262
 		// The DB class 'add' implies an update if the customer being asked to be created already exists
263
-		if ( $this->db->add( $data ) ) {
263
+		if ($this->db->add($data)) {
264 264
 
265 265
 			// We've successfully added/updated the customer, reset the class vars with the new data
266
-			$customer = $this->db->get_customer_by( 'email', $args['email'] );
266
+			$customer = $this->db->get_customer_by('email', $args['email']);
267 267
 
268 268
 			// Setup the customer data with the values from DB
269
-			$this->setup_customer( $customer );
269
+			$this->setup_customer($customer);
270 270
 
271 271
 			$created = $this->id;
272 272
 		}
273 273
 
274
-		do_action( 'give_customer_post_create', $created, $args );
274
+		do_action('give_customer_post_create', $created, $args);
275 275
 
276 276
 		return $created;
277 277
 
@@ -287,27 +287,27 @@  discard block
 block discarded – undo
287 287
 	 *
288 288
 	 * @return bool        If the update was successful or not.
289 289
 	 */
290
-	public function update( $data = array() ) {
290
+	public function update($data = array()) {
291 291
 
292
-		if ( empty( $data ) ) {
292
+		if (empty($data)) {
293 293
 			return false;
294 294
 		}
295 295
 
296
-		$data = $this->sanitize_columns( $data );
296
+		$data = $this->sanitize_columns($data);
297 297
 
298
-		do_action( 'give_customer_pre_update', $this->id, $data );
298
+		do_action('give_customer_pre_update', $this->id, $data);
299 299
 
300 300
 		$updated = false;
301 301
 
302
-		if ( $this->db->update( $this->id, $data ) ) {
302
+		if ($this->db->update($this->id, $data)) {
303 303
 
304
-			$customer = $this->db->get_customer_by( 'id', $this->id );
305
-			$this->setup_customer( $customer );
304
+			$customer = $this->db->get_customer_by('id', $this->id);
305
+			$this->setup_customer($customer);
306 306
 
307 307
 			$updated = true;
308 308
 		}
309 309
 
310
-		do_action( 'give_customer_post_update', $updated, $this->id, $data );
310
+		do_action('give_customer_post_update', $updated, $this->id, $data);
311 311
 
312 312
 		return $updated;
313 313
 	}
@@ -325,44 +325,44 @@  discard block
 block discarded – undo
325 325
 	 *
326 326
 	 * @return bool            If the attachment was successfuly.
327 327
 	 */
328
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
328
+	public function attach_payment($payment_id = 0, $update_stats = true) {
329 329
 
330
-		if ( empty( $payment_id ) ) {
330
+		if (empty($payment_id)) {
331 331
 			return false;
332 332
 		}
333 333
 
334
-		if ( empty( $this->payment_ids ) ) {
334
+		if (empty($this->payment_ids)) {
335 335
 
336 336
 			$new_payment_ids = $payment_id;
337 337
 
338 338
 		} else {
339 339
 
340
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
340
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
341 341
 
342
-			if ( in_array( $payment_id, $payment_ids ) ) {
342
+			if (in_array($payment_id, $payment_ids)) {
343 343
 				$update_stats = false;
344 344
 			}
345 345
 
346 346
 			$payment_ids[] = $payment_id;
347 347
 
348
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
348
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
349 349
 
350 350
 		}
351 351
 
352
-		do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id );
352
+		do_action('give_customer_pre_attach_payment', $payment_id, $this->id);
353 353
 
354
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
354
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
355 355
 
356
-		if ( $payment_added ) {
356
+		if ($payment_added) {
357 357
 
358 358
 			$this->payment_ids = $new_payment_ids;
359 359
 
360 360
 			// We added this payment successfully, increment the stats
361
-			if ( $update_stats ) {
362
-				$payment_amount = give_get_payment_amount( $payment_id );
361
+			if ($update_stats) {
362
+				$payment_amount = give_get_payment_amount($payment_id);
363 363
 
364
-				if ( ! empty( $payment_amount ) ) {
365
-					$this->increase_value( $payment_amount );
364
+				if ( ! empty($payment_amount)) {
365
+					$this->increase_value($payment_amount);
366 366
 				}
367 367
 
368 368
 				$this->increase_purchase_count();
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 
371 371
 		}
372 372
 
373
-		do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id );
373
+		do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id);
374 374
 
375 375
 		return $payment_added;
376 376
 	}
@@ -388,50 +388,50 @@  discard block
 block discarded – undo
388 388
 	 *
389 389
 	 * @return boolean               If the removal was successful.
390 390
 	 */
391
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
391
+	public function remove_payment($payment_id = 0, $update_stats = true) {
392 392
 
393
-		if ( empty( $payment_id ) ) {
393
+		if (empty($payment_id)) {
394 394
 			return false;
395 395
 		}
396 396
 
397
-		$payment = new Give_Payment( $payment_id );
397
+		$payment = new Give_Payment($payment_id);
398 398
 
399
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
399
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
400 400
 			$update_stats = false;
401 401
 		}
402 402
 
403 403
 		$new_payment_ids = '';
404 404
 
405
-		if ( ! empty( $this->payment_ids ) ) {
405
+		if ( ! empty($this->payment_ids)) {
406 406
 
407
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
407
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
408 408
 
409
-			$pos = array_search( $payment_id, $payment_ids );
410
-			if ( false === $pos ) {
409
+			$pos = array_search($payment_id, $payment_ids);
410
+			if (false === $pos) {
411 411
 				return false;
412 412
 			}
413 413
 
414
-			unset( $payment_ids[ $pos ] );
415
-			$payment_ids = array_filter( $payment_ids );
414
+			unset($payment_ids[$pos]);
415
+			$payment_ids = array_filter($payment_ids);
416 416
 
417
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
417
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
418 418
 
419 419
 		}
420 420
 
421
-		do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id );
421
+		do_action('give_customer_pre_remove_payment', $payment_id, $this->id);
422 422
 
423
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
423
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
424 424
 
425
-		if ( $payment_removed ) {
425
+		if ($payment_removed) {
426 426
 
427 427
 			$this->payment_ids = $new_payment_ids;
428 428
 
429
-			if ( $update_stats ) {
429
+			if ($update_stats) {
430 430
 				// We removed this payment successfully, decrement the stats
431
-				$payment_amount = give_get_payment_amount( $payment_id );
431
+				$payment_amount = give_get_payment_amount($payment_id);
432 432
 
433
-				if ( ! empty( $payment_amount ) ) {
434
-					$this->decrease_value( $payment_amount );
433
+				if ( ! empty($payment_amount)) {
434
+					$this->decrease_value($payment_amount);
435 435
 				}
436 436
 
437 437
 				$this->decrease_purchase_count();
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 
440 440
 		}
441 441
 
442
-		do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id );
442
+		do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id);
443 443
 
444 444
 		return $payment_removed;
445 445
 
@@ -455,22 +455,22 @@  discard block
 block discarded – undo
455 455
 	 *
456 456
 	 * @return int            The purchase count.
457 457
 	 */
458
-	public function increase_purchase_count( $count = 1 ) {
458
+	public function increase_purchase_count($count = 1) {
459 459
 
460 460
 		// Make sure it's numeric and not negative.
461
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
461
+		if ( ! is_numeric($count) || $count != absint($count)) {
462 462
 			return false;
463 463
 		}
464 464
 
465 465
 		$new_total = (int) $this->purchase_count + (int) $count;
466 466
 
467
-		do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id );
467
+		do_action('give_customer_pre_increase_purchase_count', $count, $this->id);
468 468
 
469
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
469
+		if ($this->update(array('purchase_count' => $new_total))) {
470 470
 			$this->purchase_count = $new_total;
471 471
 		}
472 472
 
473
-		do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id );
473
+		do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id);
474 474
 
475 475
 		return $this->purchase_count;
476 476
 	}
@@ -485,26 +485,26 @@  discard block
 block discarded – undo
485 485
 	 *
486 486
 	 * @return mixed          If successful, the new count, otherwise false.
487 487
 	 */
488
-	public function decrease_purchase_count( $count = 1 ) {
488
+	public function decrease_purchase_count($count = 1) {
489 489
 
490 490
 		// Make sure it's numeric and not negative
491
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
491
+		if ( ! is_numeric($count) || $count != absint($count)) {
492 492
 			return false;
493 493
 		}
494 494
 
495 495
 		$new_total = (int) $this->purchase_count - (int) $count;
496 496
 
497
-		if ( $new_total < 0 ) {
497
+		if ($new_total < 0) {
498 498
 			$new_total = 0;
499 499
 		}
500 500
 
501
-		do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id );
501
+		do_action('give_customer_pre_decrease_purchase_count', $count, $this->id);
502 502
 
503
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
503
+		if ($this->update(array('purchase_count' => $new_total))) {
504 504
 			$this->purchase_count = $new_total;
505 505
 		}
506 506
 
507
-		do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id );
507
+		do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id);
508 508
 
509 509
 		return $this->purchase_count;
510 510
 	}
@@ -519,17 +519,17 @@  discard block
 block discarded – undo
519 519
 	 *
520 520
 	 * @return mixed        If successful, the new value, otherwise false.
521 521
 	 */
522
-	public function increase_value( $value = 0.00 ) {
522
+	public function increase_value($value = 0.00) {
523 523
 
524
-		$new_value = floatval( $this->purchase_value ) + $value;
524
+		$new_value = floatval($this->purchase_value) + $value;
525 525
 
526
-		do_action( 'give_customer_pre_increase_value', $value, $this->id );
526
+		do_action('give_customer_pre_increase_value', $value, $this->id);
527 527
 
528
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
528
+		if ($this->update(array('purchase_value' => $new_value))) {
529 529
 			$this->purchase_value = $new_value;
530 530
 		}
531 531
 
532
-		do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id );
532
+		do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id);
533 533
 
534 534
 		return $this->purchase_value;
535 535
 	}
@@ -544,21 +544,21 @@  discard block
 block discarded – undo
544 544
 	 *
545 545
 	 * @return mixed        If successful, the new value, otherwise false.
546 546
 	 */
547
-	public function decrease_value( $value = 0.00 ) {
547
+	public function decrease_value($value = 0.00) {
548 548
 
549
-		$new_value = floatval( $this->purchase_value ) - $value;
549
+		$new_value = floatval($this->purchase_value) - $value;
550 550
 
551
-		if ( $new_value < 0 ) {
551
+		if ($new_value < 0) {
552 552
 			$new_value = 0.00;
553 553
 		}
554 554
 
555
-		do_action( 'give_customer_pre_decrease_value', $value, $this->id );
555
+		do_action('give_customer_pre_decrease_value', $value, $this->id);
556 556
 
557
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
557
+		if ($this->update(array('purchase_value' => $new_value))) {
558 558
 			$this->purchase_value = $new_value;
559 559
 		}
560 560
 
561
-		do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id );
561
+		do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id);
562 562
 
563 563
 		return $this->purchase_value;
564 564
 	}
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 	 *
578 578
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
579 579
 	 */
580
-	public function update_donation_value( $curr_amount, $new_amount ) {
580
+	public function update_donation_value($curr_amount, $new_amount) {
581 581
         /**
582 582
          * Payment total difference value can be:
583 583
          *  zero   (in case amount not change)
@@ -587,14 +587,14 @@  discard block
 block discarded – undo
587 587
         $payment_total_diff = $new_amount - $curr_amount;
588 588
 
589 589
         // We do not need to update donation stat if donation did not change.
590
-        if( ! $payment_total_diff ) {
590
+        if ( ! $payment_total_diff) {
591 591
             return false;
592 592
         }
593 593
 
594 594
 
595
-        if( $payment_total_diff > 0 ) {
596
-            $this->increase_value( $payment_total_diff );
597
-        }else{
595
+        if ($payment_total_diff > 0) {
596
+            $this->increase_value($payment_total_diff);
597
+        } else {
598 598
             // Pass payment total difference as +ve value to decrease amount from user lifetime stat.
599 599
             $this->decrease_value( -$payment_total_diff );
600 600
         }
@@ -613,15 +613,15 @@  discard block
 block discarded – undo
613 613
 	 *
614 614
 	 * @return array           The notes requested.
615 615
 	 */
616
-	public function get_notes( $length = 20, $paged = 1 ) {
616
+	public function get_notes($length = 20, $paged = 1) {
617 617
 
618
-		$length = is_numeric( $length ) ? $length : 20;
619
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
618
+		$length = is_numeric($length) ? $length : 20;
619
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
620 620
 
621 621
 		$all_notes   = $this->get_raw_notes();
622
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
622
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
623 623
 
624
-		$desired_notes = array_slice( $notes_array, $offset, $length );
624
+		$desired_notes = array_slice($notes_array, $offset, $length);
625 625
 
626 626
 		return $desired_notes;
627 627
 
@@ -638,9 +638,9 @@  discard block
 block discarded – undo
638 638
 	public function get_notes_count() {
639 639
 
640 640
 		$all_notes   = $this->get_raw_notes();
641
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
641
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
642 642
 
643
-		return count( $notes_array );
643
+		return count($notes_array);
644 644
 
645 645
 	}
646 646
 
@@ -654,32 +654,32 @@  discard block
 block discarded – undo
654 654
 	 *
655 655
 	 * @return string|boolean The new note if added successfully, false otherwise.
656 656
 	 */
657
-	public function add_note( $note = '' ) {
657
+	public function add_note($note = '') {
658 658
 
659
-		$note = trim( $note );
660
-		if ( empty( $note ) ) {
659
+		$note = trim($note);
660
+		if (empty($note)) {
661 661
 			return false;
662 662
 		}
663 663
 
664 664
 		$notes = $this->get_raw_notes();
665 665
 
666
-		if ( empty( $notes ) ) {
666
+		if (empty($notes)) {
667 667
 			$notes = '';
668 668
 		}
669 669
 
670
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
671
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
672
-		$notes .= "\n\n" . $new_note;
670
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
671
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
672
+		$notes .= "\n\n".$new_note;
673 673
 
674
-		do_action( 'give_customer_pre_add_note', $new_note, $this->id );
674
+		do_action('give_customer_pre_add_note', $new_note, $this->id);
675 675
 
676
-		$updated = $this->update( array( 'notes' => $notes ) );
676
+		$updated = $this->update(array('notes' => $notes));
677 677
 
678
-		if ( $updated ) {
678
+		if ($updated) {
679 679
 			$this->notes = $this->get_notes();
680 680
 		}
681 681
 
682
-		do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id );
682
+		do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id);
683 683
 
684 684
 		// Return the formatted note, so we can test, as well as update any displays
685 685
 		return $new_note;
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 	 */
697 697
 	private function get_raw_notes() {
698 698
 
699
-		$all_notes = $this->db->get_column( 'notes', $this->id );
699
+		$all_notes = $this->db->get_column('notes', $this->id);
700 700
 
701 701
 		return $all_notes;
702 702
 
@@ -713,8 +713,8 @@  discard block
 block discarded – undo
713 713
 	 *
714 714
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is true.
715 715
 	 */
716
-	public function get_meta( $meta_key = '', $single = true ) {
717
-		return Give()->customer_meta->get_meta( $this->id, $meta_key, $single );
716
+	public function get_meta($meta_key = '', $single = true) {
717
+		return Give()->customer_meta->get_meta($this->id, $meta_key, $single);
718 718
 	}
719 719
 
720 720
 	/**
@@ -729,8 +729,8 @@  discard block
 block discarded – undo
729 729
 	 *
730 730
 	 * @return bool               False for failure. True for success.
731 731
 	 */
732
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
733
-		return Give()->customer_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
732
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
733
+		return Give()->customer_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
734 734
 	}
735 735
 
736 736
 	/**
@@ -745,8 +745,8 @@  discard block
 block discarded – undo
745 745
 	 *
746 746
 	 * @return bool               False on failure, true if success.
747 747
 	 */
748
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
749
-		return Give()->customer_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
748
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
749
+		return Give()->customer_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
750 750
 	}
751 751
 
752 752
 	/**
@@ -760,8 +760,8 @@  discard block
 block discarded – undo
760 760
 	 *
761 761
 	 * @return bool               False for failure. True for success.
762 762
 	 */
763
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
764
-		return Give()->customer_meta->delete_meta( $this->id, $meta_key, $meta_value );
763
+	public function delete_meta($meta_key = '', $meta_value = '') {
764
+		return Give()->customer_meta->delete_meta($this->id, $meta_key, $meta_value);
765 765
 	}
766 766
 
767 767
 	/**
@@ -774,51 +774,51 @@  discard block
 block discarded – undo
774 774
 	 *
775 775
 	 * @return array       The sanitized data, based off column defaults.
776 776
 	 */
777
-	private function sanitize_columns( $data ) {
777
+	private function sanitize_columns($data) {
778 778
 
779 779
 		$columns        = $this->db->get_columns();
780 780
 		$default_values = $this->db->get_column_defaults();
781 781
 
782
-		foreach ( $columns as $key => $type ) {
782
+		foreach ($columns as $key => $type) {
783 783
 
784 784
 			// Only sanitize data that we were provided
785
-			if ( ! array_key_exists( $key, $data ) ) {
785
+			if ( ! array_key_exists($key, $data)) {
786 786
 				continue;
787 787
 			}
788 788
 
789
-			switch ( $type ) {
789
+			switch ($type) {
790 790
 
791 791
 				case '%s':
792
-					if ( 'email' == $key ) {
793
-						$data[ $key ] = sanitize_email( $data[ $key ] );
794
-					} elseif ( 'notes' == $key ) {
795
-						$data[ $key ] = strip_tags( $data[ $key ] );
792
+					if ('email' == $key) {
793
+						$data[$key] = sanitize_email($data[$key]);
794
+					} elseif ('notes' == $key) {
795
+						$data[$key] = strip_tags($data[$key]);
796 796
 					} else {
797
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
797
+						$data[$key] = sanitize_text_field($data[$key]);
798 798
 					}
799 799
 					break;
800 800
 
801 801
 				case '%d':
802
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
803
-						$data[ $key ] = $default_values[ $key ];
802
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
803
+						$data[$key] = $default_values[$key];
804 804
 					} else {
805
-						$data[ $key ] = absint( $data[ $key ] );
805
+						$data[$key] = absint($data[$key]);
806 806
 					}
807 807
 					break;
808 808
 
809 809
 				case '%f':
810 810
 					// Convert what was given to a float
811
-					$value = floatval( $data[ $key ] );
811
+					$value = floatval($data[$key]);
812 812
 
813
-					if ( ! is_float( $value ) ) {
814
-						$data[ $key ] = $default_values[ $key ];
813
+					if ( ! is_float($value)) {
814
+						$data[$key] = $default_values[$key];
815 815
 					} else {
816
-						$data[ $key ] = $value;
816
+						$data[$key] = $value;
817 817
 					}
818 818
 					break;
819 819
 
820 820
 				default:
821
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
821
+					$data[$key] = sanitize_text_field($data[$key]);
822 822
 					break;
823 823
 
824 824
 			}
Please login to merge, or discard this patch.