Completed
Push — master ( a66a0d...c1a519 )
by Devin
36:15 queued 16:19
created
includes/class-give-db-customers.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @param int $user_id
283 283
 	 * @param $old_user_data
284 284
 	 *
285
-	 * @return bool
285
+	 * @return false|null
286 286
 	 */
287 287
 	public function update_customer_email_on_user_update( $user_id = 0, $old_user_data ) {
288 288
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 	 * @since  1.0
332 332
 	 *
333 333
 	 * @param  string $field id or email
334
-	 * @param  mixed  $value The Customer ID or email to search
334
+	 * @param  integer  $value The Customer ID or email to search
335 335
 	 *
336 336
 	 * @return mixed          Upon success, an object of the customer. Upon failure, NULL
337 337
 	 */
Please login to merge, or discard this patch.
Spacing   +128 added lines, -128 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
 
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 
34 34
 		global $wpdb;
35 35
 
36
-		$this->table_name  = $wpdb->prefix . 'give_customers';
36
+		$this->table_name  = $wpdb->prefix.'give_customers';
37 37
 		$this->primary_key = 'id';
38 38
 		$this->version     = '1.0';
39 39
 		
40
-		add_action( 'profile_update', array( $this, 'update_customer_email_on_user_update' ), 10, 2 );
40
+		add_action('profile_update', array($this, 'update_customer_email_on_user_update'), 10, 2);
41 41
 
42 42
 	}
43 43
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			'purchase_value' => 0.00,
77 77
 			'purchase_count' => 0,
78 78
 			'notes'          => '',
79
-			'date_created'   => date( 'Y-m-d H:i:s' ),
79
+			'date_created'   => date('Y-m-d H:i:s'),
80 80
 		);
81 81
 	}
82 82
 
@@ -86,40 +86,40 @@  discard block
 block discarded – undo
86 86
 	 * @access  public
87 87
 	 * @since   1.0
88 88
 	 */
89
-	public function add( $data = array() ) {
89
+	public function add($data = array()) {
90 90
 
91 91
 		$defaults = array(
92 92
 			'payment_ids' => ''
93 93
 		);
94 94
 
95
-		$args = wp_parse_args( $data, $defaults );
95
+		$args = wp_parse_args($data, $defaults);
96 96
 
97
-		if ( empty( $args['email'] ) ) {
97
+		if (empty($args['email'])) {
98 98
 			return false;
99 99
 		}
100 100
 
101
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
102
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
101
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
102
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
103 103
 		}
104 104
 
105
-		$customer = $this->get_customer_by( 'email', $args['email'] );
105
+		$customer = $this->get_customer_by('email', $args['email']);
106 106
 
107
-		if ( $customer ) {
107
+		if ($customer) {
108 108
 			// update an existing customer
109 109
 
110 110
 			// Update the payment IDs attached to the customer
111
-			if ( ! empty( $args['payment_ids'] ) ) {
111
+			if ( ! empty($args['payment_ids'])) {
112 112
 
113
-				if ( empty( $customer->payment_ids ) ) {
113
+				if (empty($customer->payment_ids)) {
114 114
 
115 115
 					$customer->payment_ids = $args['payment_ids'];
116 116
 
117 117
 				} else {
118 118
 
119
-					$existing_ids          = array_map( 'absint', explode( ',', $customer->payment_ids ) );
120
-					$payment_ids           = array_map( 'absint', explode( ',', $args['payment_ids'] ) );
121
-					$payment_ids           = array_merge( $payment_ids, $existing_ids );
122
-					$customer->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
119
+					$existing_ids          = array_map('absint', explode(',', $customer->payment_ids));
120
+					$payment_ids           = array_map('absint', explode(',', $args['payment_ids']));
121
+					$payment_ids           = array_merge($payment_ids, $existing_ids);
122
+					$customer->payment_ids = implode(',', array_unique(array_values($payment_ids)));
123 123
 
124 124
 				}
125 125
 
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
 
128 128
 			}
129 129
 
130
-			$this->update( $customer->id, $args );
130
+			$this->update($customer->id, $args);
131 131
 
132 132
 			return $customer->id;
133 133
 
134 134
 		} else {
135 135
 
136
-			return $this->insert( $args, 'customer' );
136
+			return $this->insert($args, 'customer');
137 137
 
138 138
 		}
139 139
 
@@ -152,20 +152,20 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @return bool|false|int
154 154
 	 */
155
-	public function delete( $_id_or_email = false ) {
155
+	public function delete($_id_or_email = false) {
156 156
 
157
-		if ( empty( $_id_or_email ) ) {
157
+		if (empty($_id_or_email)) {
158 158
 			return false;
159 159
 		}
160 160
 
161
-		$column   = is_email( $_id_or_email ) ? 'email' : 'id';
162
-		$customer = $this->get_customer_by( $column, $_id_or_email );
161
+		$column   = is_email($_id_or_email) ? 'email' : 'id';
162
+		$customer = $this->get_customer_by($column, $_id_or_email);
163 163
 
164
-		if ( $customer->id > 0 ) {
164
+		if ($customer->id > 0) {
165 165
 
166 166
 			global $wpdb;
167 167
 
168
-			return $wpdb->delete( $this->table_name, array( 'id' => $customer->id ), array( '%d' ) );
168
+			return $wpdb->delete($this->table_name, array('id' => $customer->id), array('%d'));
169 169
 
170 170
 		} else {
171 171
 			return false;
@@ -179,14 +179,14 @@  discard block
 block discarded – undo
179 179
 	 * @access  public
180 180
 	 * @since   1.0
181 181
 	 */
182
-	public function exists( $value = '', $field = 'email' ) {
182
+	public function exists($value = '', $field = 'email') {
183 183
 		
184 184
 		$columns = $this->get_columns();
185
-		if ( ! array_key_exists( $field, $columns ) ) {
185
+		if ( ! array_key_exists($field, $columns)) {
186 186
 			return false;
187 187
 		}
188 188
 
189
-		return (bool) $this->get_column_by( 'id', $field, $value );
189
+		return (bool) $this->get_column_by('id', $field, $value);
190 190
 
191 191
 	}
192 192
 
@@ -196,16 +196,16 @@  discard block
 block discarded – undo
196 196
 	 * @access  public
197 197
 	 * @since   1.0
198 198
 	 */
199
-	public function attach_payment( $customer_id = 0, $payment_id = 0 ) {
199
+	public function attach_payment($customer_id = 0, $payment_id = 0) {
200 200
 
201
-		$customer = new Give_Customer( $customer_id );
201
+		$customer = new Give_Customer($customer_id);
202 202
 
203
-		if ( empty( $customer->id ) ) {
203
+		if (empty($customer->id)) {
204 204
 			return false;
205 205
 		}
206 206
 
207 207
 		// Attach the payment, but don't increment stats, as this function previously did not
208
-		return $customer->attach_payment( $payment_id, false );
208
+		return $customer->attach_payment($payment_id, false);
209 209
 
210 210
 	}
211 211
 
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
 	 * @access  public
216 216
 	 * @since   1.0
217 217
 	 */
218
-	public function remove_payment( $customer_id = 0, $payment_id = 0 ) {
218
+	public function remove_payment($customer_id = 0, $payment_id = 0) {
219 219
 
220
-		$customer = new Give_Customer( $customer_id );
220
+		$customer = new Give_Customer($customer_id);
221 221
 
222
-		if ( ! $customer ) {
222
+		if ( ! $customer) {
223 223
 			return false;
224 224
 		}
225 225
 
226 226
 		// Remove the payment, but don't decrease stats, as this function previously did not
227
-		return $customer->remove_payment( $payment_id, false );
227
+		return $customer->remove_payment($payment_id, false);
228 228
 
229 229
 	}
230 230
 
@@ -236,18 +236,18 @@  discard block
 block discarded – undo
236 236
 	 *
237 237
 	 * @return bool
238 238
 	 */
239
-	public function increment_stats( $customer_id = 0, $amount = 0.00 ) {
239
+	public function increment_stats($customer_id = 0, $amount = 0.00) {
240 240
 
241
-		$customer = new Give_Customer( $customer_id );
241
+		$customer = new Give_Customer($customer_id);
242 242
 
243
-		if ( empty( $customer->id ) ) {
243
+		if (empty($customer->id)) {
244 244
 			return false;
245 245
 		}
246 246
 
247 247
 		$increased_count = $customer->increase_purchase_count();
248
-		$increased_value = $customer->increase_value( $amount );
248
+		$increased_value = $customer->increase_value($amount);
249 249
 
250
-		return ( $increased_count && $increased_value ) ? true : false;
250
+		return ($increased_count && $increased_value) ? true : false;
251 251
 
252 252
 	}
253 253
 
@@ -257,18 +257,18 @@  discard block
 block discarded – undo
257 257
 	 * @access  public
258 258
 	 * @since   1.0
259 259
 	 */
260
-	public function decrement_stats( $customer_id = 0, $amount = 0.00 ) {
260
+	public function decrement_stats($customer_id = 0, $amount = 0.00) {
261 261
 
262
-		$customer = new Give_Customer( $customer_id );
262
+		$customer = new Give_Customer($customer_id);
263 263
 
264
-		if ( ! $customer ) {
264
+		if ( ! $customer) {
265 265
 			return false;
266 266
 		}
267 267
 
268 268
 		$decreased_count = $customer->decrease_purchase_count();
269
-		$decreased_value = $customer->decrease_value( $amount );
269
+		$decreased_value = $customer->decrease_value($amount);
270 270
 
271
-		return ( $decreased_count && $decreased_value ) ? true : false;
271
+		return ($decreased_count && $decreased_value) ? true : false;
272 272
 
273 273
 	}
274 274
 
@@ -284,37 +284,37 @@  discard block
 block discarded – undo
284 284
 	 *
285 285
 	 * @return bool
286 286
 	 */
287
-	public function update_customer_email_on_user_update( $user_id = 0, $old_user_data ) {
287
+	public function update_customer_email_on_user_update($user_id = 0, $old_user_data) {
288 288
 
289
-		$customer = new Give_Customer( $user_id, true );
289
+		$customer = new Give_Customer($user_id, true);
290 290
 
291
-		if( ! $customer ) {
291
+		if ( ! $customer) {
292 292
 			return false;
293 293
 		}
294 294
 
295
-		$user = get_userdata( $user_id );
295
+		$user = get_userdata($user_id);
296 296
 
297
-		if( ! empty( $user ) && $user->user_email !== $customer->email ) {
297
+		if ( ! empty($user) && $user->user_email !== $customer->email) {
298 298
 
299
-			if( ! $this->get_customer_by( 'email', $user->user_email ) ) {
299
+			if ( ! $this->get_customer_by('email', $user->user_email)) {
300 300
 
301
-				$success = $this->update( $customer->id, array( 'email' => $user->user_email ) );
301
+				$success = $this->update($customer->id, array('email' => $user->user_email));
302 302
 
303
-				if( $success ) {
303
+				if ($success) {
304 304
 					// Update some payment meta if we need to
305
-					$payments_array = explode( ',', $customer->payment_ids );
305
+					$payments_array = explode(',', $customer->payment_ids);
306 306
 
307
-					if( ! empty( $payments_array ) ) {
307
+					if ( ! empty($payments_array)) {
308 308
 
309
-						foreach ( $payments_array as $payment_id ) {
309
+						foreach ($payments_array as $payment_id) {
310 310
 
311
-							give_update_payment_meta( $payment_id, 'email', $user->user_email );
311
+							give_update_payment_meta($payment_id, 'email', $user->user_email);
312 312
 
313 313
 						}
314 314
 
315 315
 					}
316 316
 
317
-					do_action( 'give_update_customer_email_on_user_update', $user, $customer );
317
+					do_action('give_update_customer_email_on_user_update', $user, $customer);
318 318
 
319 319
 				}
320 320
 
@@ -335,45 +335,45 @@  discard block
 block discarded – undo
335 335
 	 *
336 336
 	 * @return mixed          Upon success, an object of the customer. Upon failure, NULL
337 337
 	 */
338
-	public function get_customer_by( $field = 'id', $value = 0 ) {
338
+	public function get_customer_by($field = 'id', $value = 0) {
339 339
 		global $wpdb;
340 340
 
341
-		if ( empty( $field ) || empty( $value ) ) {
341
+		if (empty($field) || empty($value)) {
342 342
 			return null;
343 343
 		}
344 344
 
345
-		if ( 'id' == $field || 'user_id' == $field ) {
345
+		if ('id' == $field || 'user_id' == $field) {
346 346
 			// Make sure the value is numeric to avoid casting objects, for example,
347 347
 			// to int 1.
348
-			if ( ! is_numeric( $value ) ) {
348
+			if ( ! is_numeric($value)) {
349 349
 				return false;
350 350
 			}
351 351
 
352
-			$value = intval( $value );
352
+			$value = intval($value);
353 353
 
354
-			if ( $value < 1 ) {
354
+			if ($value < 1) {
355 355
 				return false;
356 356
 			}
357 357
 
358
-		} elseif ( 'email' === $field ) {
358
+		} elseif ('email' === $field) {
359 359
 
360
-			if ( ! is_email( $value ) ) {
360
+			if ( ! is_email($value)) {
361 361
 				return false;
362 362
 			}
363 363
 
364
-			$value = trim( $value );
364
+			$value = trim($value);
365 365
 		}
366 366
 
367
-		if ( ! $value ) {
367
+		if ( ! $value) {
368 368
 			return false;
369 369
 		}
370 370
 
371
-		switch ( $field ) {
371
+		switch ($field) {
372 372
 			case 'id':
373 373
 				$db_field = 'id';
374 374
 				break;
375 375
 			case 'email':
376
-				$value    = sanitize_text_field( $value );
376
+				$value    = sanitize_text_field($value);
377 377
 				$db_field = 'email';
378 378
 				break;
379 379
 			case 'user_id':
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 				return false;
384 384
 		}
385 385
 
386
-		if ( ! $customer = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value ) ) ) {
386
+		if ( ! $customer = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value))) {
387 387
 			return false;
388 388
 		}
389 389
 
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 	 * @access  public
397 397
 	 * @since   1.0
398 398
 	 */
399
-	public function get_customers( $args = array() ) {
399
+	public function get_customers($args = array()) {
400 400
 
401 401
 		global $wpdb;
402 402
 
@@ -408,21 +408,21 @@  discard block
 block discarded – undo
408 408
 			'order'   => 'DESC'
409 409
 		);
410 410
 
411
-		$args = wp_parse_args( $args, $defaults );
411
+		$args = wp_parse_args($args, $defaults);
412 412
 
413
-		if ( $args['number'] < 1 ) {
413
+		if ($args['number'] < 1) {
414 414
 			$args['number'] = 999999999999;
415 415
 		}
416 416
 
417 417
 		$where = ' WHERE 1=1 ';
418 418
 
419 419
 		// specific customers
420
-		if ( ! empty( $args['id'] ) ) {
420
+		if ( ! empty($args['id'])) {
421 421
 
422
-			if ( is_array( $args['id'] ) ) {
423
-				$ids = implode( ',', array_map( 'intval', $args['id'] ) );
422
+			if (is_array($args['id'])) {
423
+				$ids = implode(',', array_map('intval', $args['id']));
424 424
 			} else {
425
-				$ids = intval( $args['id'] );
425
+				$ids = intval($args['id']);
426 426
 			}
427 427
 
428 428
 			$where .= " AND `id` IN( {$ids} ) ";
@@ -430,12 +430,12 @@  discard block
 block discarded – undo
430 430
 		}
431 431
 
432 432
 		// customers for specific user accounts
433
-		if ( ! empty( $args['user_id'] ) ) {
433
+		if ( ! empty($args['user_id'])) {
434 434
 
435
-			if ( is_array( $args['user_id'] ) ) {
436
-				$user_ids = implode( ',', array_map( 'intval', $args['user_id'] ) );
435
+			if (is_array($args['user_id'])) {
436
+				$user_ids = implode(',', array_map('intval', $args['user_id']));
437 437
 			} else {
438
-				$user_ids = intval( $args['user_id'] );
438
+				$user_ids = intval($args['user_id']);
439 439
 			}
440 440
 
441 441
 			$where .= " AND `user_id` IN( {$user_ids} ) ";
@@ -443,41 +443,41 @@  discard block
 block discarded – undo
443 443
 		}
444 444
 
445 445
 		//specific customers by email
446
-		if( ! empty( $args['email'] ) ) {
446
+		if ( ! empty($args['email'])) {
447 447
 
448
-			if( is_array( $args['email'] ) ) {
448
+			if (is_array($args['email'])) {
449 449
 
450
-				$emails_count       = count( $args['email'] );
451
-				$emails_placeholder = array_fill( 0, $emails_count, '%s' );
452
-				$emails             = implode( ', ', $emails_placeholder );
450
+				$emails_count       = count($args['email']);
451
+				$emails_placeholder = array_fill(0, $emails_count, '%s');
452
+				$emails             = implode(', ', $emails_placeholder);
453 453
 
454
-				$where .= $wpdb->prepare( " AND `email` IN( $emails ) ", $args['email'] );
454
+				$where .= $wpdb->prepare(" AND `email` IN( $emails ) ", $args['email']);
455 455
 			} else {
456
-				$where .= $wpdb->prepare( " AND `email` = %s ", $args['email'] );
456
+				$where .= $wpdb->prepare(" AND `email` = %s ", $args['email']);
457 457
 			}
458 458
 		}
459 459
 
460 460
 		// specific customers by name
461
-		if( ! empty( $args['name'] ) ) {
462
-			$where .= $wpdb->prepare( " AND `name` LIKE '%%%%" . '%s' . "%%%%' ", $args['name'] );
461
+		if ( ! empty($args['name'])) {
462
+			$where .= $wpdb->prepare(" AND `name` LIKE '%%%%".'%s'."%%%%' ", $args['name']);
463 463
 		}
464 464
 
465 465
 		// Customers created for a specific date or in a date range
466
-		if ( ! empty( $args['date'] ) ) {
466
+		if ( ! empty($args['date'])) {
467 467
 
468
-			if ( is_array( $args['date'] ) ) {
468
+			if (is_array($args['date'])) {
469 469
 
470
-				if ( ! empty( $args['date']['start'] ) ) {
470
+				if ( ! empty($args['date']['start'])) {
471 471
 
472
-					$start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
472
+					$start = date('Y-m-d H:i:s', strtotime($args['date']['start']));
473 473
 
474 474
 					$where .= " AND `date_created` >= '{$start}'";
475 475
 
476 476
 				}
477 477
 
478
-				if ( ! empty( $args['date']['end'] ) ) {
478
+				if ( ! empty($args['date']['end'])) {
479 479
 
480
-					$end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
480
+					$end = date('Y-m-d H:i:s', strtotime($args['date']['end']));
481 481
 
482 482
 					$where .= " AND `date_created` <= '{$end}'";
483 483
 
@@ -485,31 +485,31 @@  discard block
 block discarded – undo
485 485
 
486 486
 			} else {
487 487
 
488
-				$year  = date( 'Y', strtotime( $args['date'] ) );
489
-				$month = date( 'm', strtotime( $args['date'] ) );
490
-				$day   = date( 'd', strtotime( $args['date'] ) );
488
+				$year  = date('Y', strtotime($args['date']));
489
+				$month = date('m', strtotime($args['date']));
490
+				$day   = date('d', strtotime($args['date']));
491 491
 
492 492
 				$where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )";
493 493
 			}
494 494
 
495 495
 		}
496 496
 
497
-		$args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby'];
497
+		$args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby'];
498 498
 
499
-		if ( 'purchase_value' == $args['orderby'] ) {
499
+		if ('purchase_value' == $args['orderby']) {
500 500
 			$args['orderby'] = 'purchase_value+0';
501 501
 		}
502 502
 
503
-		$cache_key = md5( 'give_customers_' . serialize( $args ) );
503
+		$cache_key = md5('give_customers_'.serialize($args));
504 504
 
505
-		$customers = wp_cache_get( $cache_key, 'customers' );
505
+		$customers = wp_cache_get($cache_key, 'customers');
506 506
 
507
-		$args['orderby'] = esc_sql( $args['orderby'] );
508
-		$args['order']   = esc_sql( $args['order'] );
507
+		$args['orderby'] = esc_sql($args['orderby']);
508
+		$args['order']   = esc_sql($args['order']);
509 509
 
510
-		if ( $customers === false ) {
511
-			$customers = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM  $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ) );
512
-			wp_cache_set( $cache_key, $customers, 'customers', 3600 );
510
+		if ($customers === false) {
511
+			$customers = $wpdb->get_results($wpdb->prepare("SELECT * FROM  $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number'])));
512
+			wp_cache_set($cache_key, $customers, 'customers', 3600);
513 513
 		}
514 514
 
515 515
 		return $customers;
@@ -523,26 +523,26 @@  discard block
 block discarded – undo
523 523
 	 * @access  public
524 524
 	 * @since   1.0
525 525
 	 */
526
-	public function count( $args = array() ) {
526
+	public function count($args = array()) {
527 527
 
528 528
 		global $wpdb;
529 529
 
530 530
 		$where = ' WHERE 1=1 ';
531 531
 
532
-		if ( ! empty( $args['date'] ) ) {
532
+		if ( ! empty($args['date'])) {
533 533
 
534
-			if ( is_array( $args['date'] ) ) {
534
+			if (is_array($args['date'])) {
535 535
 
536
-				$start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
537
-				$end   = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
536
+				$start = date('Y-m-d H:i:s', strtotime($args['date']['start']));
537
+				$end   = date('Y-m-d H:i:s', strtotime($args['date']['end']));
538 538
 
539 539
 				$where .= " AND `date_created` >= '{$start}' AND `date_created` <= '{$end}'";
540 540
 
541 541
 			} else {
542 542
 
543
-				$year  = date( 'Y', strtotime( $args['date'] ) );
544
-				$month = date( 'm', strtotime( $args['date'] ) );
545
-				$day   = date( 'd', strtotime( $args['date'] ) );
543
+				$year  = date('Y', strtotime($args['date']));
544
+				$month = date('m', strtotime($args['date']));
545
+				$day   = date('d', strtotime($args['date']));
546 546
 
547 547
 				$where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )";
548 548
 			}
@@ -550,16 +550,16 @@  discard block
 block discarded – undo
550 550
 		}
551 551
 
552 552
 
553
-		$cache_key = md5( 'give_customers_count' . serialize( $args ) );
553
+		$cache_key = md5('give_customers_count'.serialize($args));
554 554
 
555
-		$count = wp_cache_get( $cache_key, 'customers' );
555
+		$count = wp_cache_get($cache_key, 'customers');
556 556
 
557
-		if ( $count === false ) {
558
-			$count = $wpdb->get_var( "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};" );
559
-			wp_cache_set( $cache_key, $count, 'customers', 3600 );
557
+		if ($count === false) {
558
+			$count = $wpdb->get_var("SELECT COUNT($this->primary_key) FROM ".$this->table_name."{$where};");
559
+			wp_cache_set($cache_key, $count, 'customers', 3600);
560 560
 		}
561 561
 
562
-		return absint( $count );
562
+		return absint($count);
563 563
 
564 564
 	}
565 565
 
@@ -573,9 +573,9 @@  discard block
 block discarded – undo
573 573
 
574 574
 		global $wpdb;
575 575
 
576
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
576
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
577 577
 
578
-		$sql = "CREATE TABLE " . $this->table_name . " (
578
+		$sql = "CREATE TABLE ".$this->table_name." (
579 579
 		id bigint(20) NOT NULL AUTO_INCREMENT,
580 580
 		user_id bigint(20) NOT NULL,
581 581
 		email varchar(50) NOT NULL,
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
 		KEY user (user_id)
591 591
 		) CHARACTER SET utf8 COLLATE utf8_general_ci;";
592 592
 
593
-		dbDelta( $sql );
593
+		dbDelta($sql);
594 594
 
595
-		update_option( $this->table_name . '_db_version', $this->version );
595
+		update_option($this->table_name.'_db_version', $this->version);
596 596
 	}
597 597
 }
Please login to merge, or discard this patch.