Test Failed
Push — master ( f49c98...c5285d )
by Devin
01:02
created
includes/admin/emails/abstract-email-notification.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -600,7 +600,7 @@
 block discarded – undo
600 600
 		 *
601 601
 		 * @param int $form_id
602 602
 		 *
603
-		 * @return array|string
603
+		 * @return string
604 604
 		 */
605 605
 		public function get_preview_email_recipient( $form_id = null ) {
606 606
 			$recipients = $this->get_recipient( $form_id );
Please login to merge, or discard this patch.
Spacing   +156 added lines, -157 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if access directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19
-if ( ! class_exists( 'Give_Email_Notification' ) ) :
19
+if ( ! class_exists('Give_Email_Notification')) :
20 20
 
21 21
 	/**
22 22
 	 * Give_Email_Notification
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
 		 *
94 94
 		 * @return Give_Email_Notification
95 95
 		 */
96
-		public static function get_instance( $email_notification_id = '' ) {
96
+		public static function get_instance($email_notification_id = '') {
97 97
 			$class = '';
98 98
 
99
-			if ( ! empty( $email_notification_id ) ) {
99
+			if ( ! empty($email_notification_id)) {
100 100
 				/* @var Give_Email_Notification $class */
101
-				foreach ( self::$singleton as $class ) {
102
-					if ( $email_notification_id === $class->config['id'] ) {
103
-						$class = get_class( $class );
101
+				foreach (self::$singleton as $class) {
102
+					if ($email_notification_id === $class->config['id']) {
103
+						$class = get_class($class);
104 104
 						break;
105 105
 					}
106 106
 				}
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 				$class = get_called_class();
109 109
 			}
110 110
 
111
-			if ( ! empty( $class ) && ( ! array_key_exists( $class, self::$singleton ) || is_null( self::$singleton[ $class ] ) ) ) {
112
-				self::$singleton[ $class ] = new $class();
111
+			if ( ! empty($class) && ( ! array_key_exists($class, self::$singleton) || is_null(self::$singleton[$class]))) {
112
+				self::$singleton[$class] = new $class();
113 113
 			}
114 114
 
115
-			return ( isset( self::$singleton[ $class ] ) ? self::$singleton[ $class ] : null );
115
+			return (isset(self::$singleton[$class]) ? self::$singleton[$class] : null);
116 116
 		}
117 117
 
118 118
 		/**
@@ -123,35 +123,35 @@  discard block
 block discarded – undo
123 123
 		 *
124 124
 		 * @param array $config
125 125
 		 */
126
-		public function load( $config ) {
126
+		public function load($config) {
127 127
 			// Set notification configuration.
128
-			$this->config = wp_parse_args( $config, $this->config );
128
+			$this->config = wp_parse_args($config, $this->config);
129 129
 
130 130
 			// Set email preview header status.
131 131
 			$this->config['has_preview_header'] = $this->config['has_preview'] && $this->config['has_preview_header'] ? true : false;
132 132
 
133 133
 			// Set email content type
134
-			$this->config['content_type'] = empty( $this->config['content_type'] ) || ! in_array( $this->config['content_type'], array(
134
+			$this->config['content_type'] = empty($this->config['content_type']) || ! in_array($this->config['content_type'], array(
135 135
 				'text/html',
136 136
 				'text/plain',
137
-			) )
137
+			))
138 138
 				? Give()->emails->get_content_type()
139 139
 				: $this->config['content_type'];
140
-			$this->config['content_type'] = give_get_option( Give_Email_Setting_Field::get_prefix( $this ) . 'email_content_type', $this->config['content_type'] );
140
+			$this->config['content_type'] = give_get_option(Give_Email_Setting_Field::get_prefix($this).'email_content_type', $this->config['content_type']);
141 141
 
142 142
 			// Set email template type.
143
-			$this->config['email_template'] = empty( $this->config['email_template'] )
144
-				? give_get_option( 'email_template' )
143
+			$this->config['email_template'] = empty($this->config['email_template'])
144
+				? give_get_option('email_template')
145 145
 				: $this->config['email_template'];
146 146
 
147 147
 			// Set recipient group name.
148
-			$this->config['recipient_group_name'] = empty( $this->config['recipient_group_name'] )
149
-				? ( ! Give_Email_Notification_Util::has_recipient_field( $this ) ? __( 'Donor', 'give' ) : '' )
148
+			$this->config['recipient_group_name'] = empty($this->config['recipient_group_name'])
149
+				? ( ! Give_Email_Notification_Util::has_recipient_field($this) ? __('Donor', 'give') : '')
150 150
 				: $this->config['recipient_group_name'];
151 151
 
152 152
 			// Non notification status editable notice.
153
-			$this->config['notices']['non-notification-status-editable'] = empty( $this->config['notices']['non-notification-status-editable'] )
154
-				? __( 'You can not edit notification status from here.', 'give' )
153
+			$this->config['notices']['non-notification-status-editable'] = empty($this->config['notices']['non-notification-status-editable'])
154
+				? __('You can not edit notification status from here.', 'give')
155 155
 				: $this->config['notices']['non-notification-status-editable'];
156 156
 
157 157
 			/**
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 			 * @param                         array                   Give_Email_Notification::config
163 163
 			 * @param Give_Email_Notification $this
164 164
 			 */
165
-			$this->config = apply_filters( 'give_email_api_notification_config', $this->config, $this );
165
+			$this->config = apply_filters('give_email_api_notification_config', $this->config, $this);
166 166
 
167 167
 			// Setup filters.
168 168
 			$this->setup_filters();
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		 */
178 178
 		private function setup_filters() {
179 179
 			// Apply filter only for current email notification section.
180
-			if ( give_get_current_setting_section() === $this->config['id'] ) {
180
+			if (give_get_current_setting_section() === $this->config['id']) {
181 181
 				// Initialize email context for email notification.
182 182
 				$this->config['email_tag_context'] = apply_filters(
183 183
 					"give_{$this->config['id']}_email_tag_context",
@@ -187,23 +187,23 @@  discard block
 block discarded – undo
187 187
 			}
188 188
 
189 189
 			// Setup setting fields.
190
-			if( $this->config['show_on_emails_setting_page'] ) {
191
-				add_filter( 'give_get_settings_emails', array( $this, 'add_setting_fields' ), 10, 2 );
190
+			if ($this->config['show_on_emails_setting_page']) {
191
+				add_filter('give_get_settings_emails', array($this, 'add_setting_fields'), 10, 2);
192 192
 			}
193 193
 
194
-			if ( $this->config['form_metabox_setting'] ) {
194
+			if ($this->config['form_metabox_setting']) {
195 195
 				add_filter(
196 196
 					'give_email_notification_options_metabox_fields',
197
-					array( $this, 'add_metabox_setting_field' ),
197
+					array($this, 'add_metabox_setting_field'),
198 198
 					10,
199 199
 					2
200 200
 				);
201 201
 			}
202 202
 
203
-			if( $this->config['has_recipient_field'] ) {
203
+			if ($this->config['has_recipient_field']) {
204 204
 				add_action(
205 205
 						"give_save__give_{$this->config['id']}_recipient",
206
-						array( $this, 'validate_form_recipient_field_value' ),
206
+						array($this, 'validate_form_recipient_field_value'),
207 207
 						10,
208 208
 						3
209 209
 				);
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 		 *
242 242
 		 * @return array
243 243
 		 */
244
-		public function add_section( $sections ) {
245
-			$sections[ $this->config['id'] ] = $this->config['label'];
244
+		public function add_section($sections) {
245
+			$sections[$this->config['id']] = $this->config['label'];
246 246
 
247 247
 			return $sections;
248 248
 		}
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 		 *
257 257
 		 * @return bool
258 258
 		 */
259
-		public function hide_section( $hide_section ) {
259
+		public function hide_section($hide_section) {
260 260
 			$hide_section = true;
261 261
 
262 262
 			return $hide_section;
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
 		 *
273 273
 		 * @return  array
274 274
 		 */
275
-		public function add_setting_fields( $settings ) {
276
-			if ( $this->config['id'] === give_get_current_setting_section() ) {
275
+		public function add_setting_fields($settings) {
276
+			if ($this->config['id'] === give_get_current_setting_section()) {
277 277
 				$settings = $this->get_setting_fields();
278 278
 			}
279 279
 
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
 		 *
292 292
 		 * @return array
293 293
 		 */
294
-		public function get_setting_fields( $form_id = null ) {
295
-			return Give_Email_Setting_Field::get_setting_fields( $this, $form_id );
294
+		public function get_setting_fields($form_id = null) {
295
+			return Give_Email_Setting_Field::get_setting_fields($this, $form_id);
296 296
 		}
297 297
 
298 298
 
@@ -307,13 +307,13 @@  discard block
 block discarded – undo
307 307
 		 *
308 308
 		 * @return array
309 309
 		 */
310
-		public function add_metabox_setting_field( $settings, $form_id ) {
310
+		public function add_metabox_setting_field($settings, $form_id) {
311 311
 
312
-			if( Give_Email_Notification_Util::is_email_notification_active( $this ) ) {
312
+			if (Give_Email_Notification_Util::is_email_notification_active($this)) {
313 313
 				$settings[] = array(
314 314
 					'id'     => $this->config['id'],
315 315
 					'title'  => $this->config['label'],
316
-					'fields' => $this->get_setting_fields( $form_id ),
316
+					'fields' => $this->get_setting_fields($form_id),
317 317
 				);
318 318
 			}
319 319
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 		 *
332 332
 		 * @return array
333 333
 		 */
334
-		public function get_extra_setting_fields( $form_id = null ) {
334
+		public function get_extra_setting_fields($form_id = null) {
335 335
 			return array();
336 336
 		}
337 337
 
@@ -348,11 +348,11 @@  discard block
 block discarded – undo
348 348
 		 *
349 349
 		 * @return string|array
350 350
 		 */
351
-		public function get_recipient( $form_id = null ) {
352
-			if ( empty( $this->recipient_email ) && $this->config['has_recipient_field'] ) {
351
+		public function get_recipient($form_id = null) {
352
+			if (empty($this->recipient_email) && $this->config['has_recipient_field']) {
353 353
 				$this->recipient_email = Give_Email_Notification_Util::get_value(
354 354
 						$this,
355
-						Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'recipient',
355
+						Give_Email_Setting_Field::get_prefix($this, $form_id).'recipient',
356 356
 						$form_id
357 357
 				);
358 358
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 				 * @since 1.0
364 364
 				 * @deprecated 2.0
365 365
 				 */
366
-				$this->recipient_email = apply_filters( 'give_admin_notice_emails', $this->recipient_email, $this, $form_id );
366
+				$this->recipient_email = apply_filters('give_admin_notice_emails', $this->recipient_email, $this, $form_id);
367 367
 			}
368 368
 
369 369
 			/**
@@ -393,10 +393,10 @@  discard block
 block discarded – undo
393 393
 		 *
394 394
 		 * @return bool
395 395
 		 */
396
-		public function get_notification_status( $form_id = null ) {
397
-			$notification_status = empty( $form_id )
398
-				? give_get_option( "{$this->config['id']}_notification", $this->config['notification_status'] )
399
-				: give_get_meta( $form_id, Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'notification', true, 'global' );
396
+		public function get_notification_status($form_id = null) {
397
+			$notification_status = empty($form_id)
398
+				? give_get_option("{$this->config['id']}_notification", $this->config['notification_status'])
399
+				: give_get_meta($form_id, Give_Email_Setting_Field::get_prefix($this, $form_id).'notification', true, 'global');
400 400
 
401 401
 			/**
402 402
 			 * Filter the notification status.
@@ -421,11 +421,11 @@  discard block
 block discarded – undo
421 421
 		 *
422 422
 		 * @return string
423 423
 		 */
424
-		function get_email_subject( $form_id = null ) {
424
+		function get_email_subject($form_id = null) {
425 425
 			$subject = wp_strip_all_tags(
426 426
 				Give_Email_Notification_Util::get_value(
427 427
 					$this,
428
-					Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_subject',
428
+					Give_Email_Setting_Field::get_prefix($this, $form_id).'email_subject',
429 429
 					$form_id,
430 430
 					$this->config['default_email_subject']
431 431
 				)
@@ -454,10 +454,10 @@  discard block
 block discarded – undo
454 454
 		 *
455 455
 		 * @return string
456 456
 		 */
457
-		public function get_email_message( $form_id = null ) {
457
+		public function get_email_message($form_id = null) {
458 458
 			$message = Give_Email_Notification_Util::get_value(
459 459
 				$this,
460
-				Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message',
460
+				Give_Email_Setting_Field::get_prefix($this, $form_id).'email_message',
461 461
 				$form_id,
462 462
 				$this->config['default_email_message']
463 463
 			);
@@ -486,10 +486,10 @@  discard block
 block discarded – undo
486 486
 		 *
487 487
 		 * @return string
488 488
 		 */
489
-		public function get_email_content_type( $form_id ) {
489
+		public function get_email_content_type($form_id) {
490 490
 			$content_type = Give_Email_Notification_Util::get_value(
491 491
 				$this,
492
-				Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_content_type',
492
+				Give_Email_Setting_Field::get_prefix($this, $form_id).'email_content_type',
493 493
 				$form_id,
494 494
 				$this->config['content_type']
495 495
 			);
@@ -517,15 +517,14 @@  discard block
 block discarded – undo
517 517
 		 *
518 518
 		 * @return string
519 519
 		 */
520
-		public function get_email_template( $form_id ) {
521
-			$email_template = give_get_meta( $form_id, '_give_email_template', true );
520
+		public function get_email_template($form_id) {
521
+			$email_template = give_get_meta($form_id, '_give_email_template', true);
522 522
 			$email_template = Give_Email_Notification_Util::get_value(
523 523
 				$this,
524
-				Give_Email_Setting_Field::get_prefix( $this, $form_id ) .'email_template',
524
+				Give_Email_Setting_Field::get_prefix($this, $form_id).'email_template',
525 525
 				$form_id,
526
-				! empty( $email_template ) && Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ?
527
-					$email_template :
528
-					$this->config['email_template']
526
+				! empty($email_template) && Give_Email_Notification_Util::can_use_form_email_options($this, $form_id) ?
527
+					$email_template : $this->config['email_template']
529 528
 			);
530 529
 
531 530
 			/**
@@ -552,34 +551,34 @@  discard block
 block discarded – undo
552 551
 		 *
553 552
 		 * @return array
554 553
 		 */
555
-		public function get_allowed_email_tags( $formatted = false ) {
554
+		public function get_allowed_email_tags($formatted = false) {
556 555
 			// Get all email tags.
557 556
 			$email_tags = Give()->email_tags->get_tags();
558 557
 
559 558
 			// Skip if all email template tags context setup exit.
560
-			if ( $this->config['email_tag_context'] && 'all' !== $this->config['email_tag_context'] ) {
561
-				if ( is_array( $this->config['email_tag_context'] ) ) {
562
-					foreach ( $email_tags as $index => $email_tag ) {
563
-						if ( in_array( $email_tag['context'], $this->config['email_tag_context'] ) ) {
559
+			if ($this->config['email_tag_context'] && 'all' !== $this->config['email_tag_context']) {
560
+				if (is_array($this->config['email_tag_context'])) {
561
+					foreach ($email_tags as $index => $email_tag) {
562
+						if (in_array($email_tag['context'], $this->config['email_tag_context'])) {
564 563
 							continue;
565 564
 						}
566 565
 
567
-						unset( $email_tags[ $index ] );
566
+						unset($email_tags[$index]);
568 567
 					}
569 568
 				} else {
570
-					foreach ( $email_tags as $index => $email_tag ) {
571
-						if ( $this->config['email_tag_context'] === $email_tag['context'] ) {
569
+					foreach ($email_tags as $index => $email_tag) {
570
+						if ($this->config['email_tag_context'] === $email_tag['context']) {
572 571
 							continue;
573 572
 						}
574 573
 
575
-						unset( $email_tags[ $index ] );
574
+						unset($email_tags[$index]);
576 575
 					}
577 576
 				}
578 577
 			}
579 578
 
580
-			if ( count( $email_tags ) && $formatted ) : ob_start() ?>
579
+			if (count($email_tags) && $formatted) : ob_start() ?>
581 580
 				<div class="give-email-tags-wrap">
582
-					<?php foreach ( $email_tags as $email_tag ) : ?>
581
+					<?php foreach ($email_tags as $email_tag) : ?>
583 582
 						<span class="give_<?php echo $email_tag['tag']; ?>_tag">
584 583
 							<code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?>
585 584
 						</span>
@@ -602,8 +601,8 @@  discard block
 block discarded – undo
602 601
 		 *
603 602
 		 * @return array|string
604 603
 		 */
605
-		public function get_preview_email_recipient( $form_id = null ) {
606
-			$recipients = $this->get_recipient( $form_id );
604
+		public function get_preview_email_recipient($form_id = null) {
605
+			$recipients = $this->get_recipient($form_id);
607 606
 
608 607
 			/**
609 608
 			 * Filter the preview email recipients.
@@ -613,7 +612,7 @@  discard block
 block discarded – undo
613 612
 			 * @param string|array            $recipients List of recipients.
614 613
 			 * @param Give_Email_Notification $this
615 614
 			 */
616
-			$recipients = apply_filters( 'give_get_preview_email_recipient', $recipients, $this, $form_id );
615
+			$recipients = apply_filters('give_get_preview_email_recipient', $recipients, $this, $form_id);
617 616
 
618 617
 			return $recipients;
619 618
 		}
@@ -628,13 +627,13 @@  discard block
 block discarded – undo
628 627
 		 *
629 628
 		 * @return array
630 629
 		 */
631
-		public function get_email_attachments( $form_id = null ) {
630
+		public function get_email_attachments($form_id = null) {
632 631
 			/**
633 632
 			 * Filter the attachment.
634 633
 			 *
635 634
 			 * @since 2.0
636 635
 			 */
637
-			return apply_filters( "give_{$this->config['id']}_get_email_attachments", array(), $this, $form_id );
636
+			return apply_filters("give_{$this->config['id']}_get_email_attachments", array(), $this, $form_id);
638 637
 		}
639 638
 
640 639
 
@@ -646,37 +645,37 @@  discard block
 block discarded – undo
646 645
 		 */
647 646
 		public function send_preview_email() {
648 647
 			// Get form id
649
-			$form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null;
648
+			$form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null;
650 649
 
651 650
 			// setup email data.
652 651
 			$this->setup_email_data();
653 652
 
654 653
 			$attachments  = $this->get_email_attachments();
655
-			$message      = $this->preview_email_template_tags( $this->get_email_message( $form_id ) );
656
-			$subject      = $this->preview_email_template_tags( $this->get_email_subject( $form_id ) );
657
-			$content_type = $this->get_email_content_type( $form_id );
654
+			$message      = $this->preview_email_template_tags($this->get_email_message($form_id));
655
+			$subject      = $this->preview_email_template_tags($this->get_email_subject($form_id));
656
+			$content_type = $this->get_email_content_type($form_id);
658 657
 
659 658
 			// Setup email content type.
660
-			Give()->emails->__set( 'content_type', $content_type );
661
-			Give()->emails->__set( 'html', true );
659
+			Give()->emails->__set('content_type', $content_type);
660
+			Give()->emails->__set('html', true);
662 661
 
663 662
 			// Setup email template
664
-			Give()->emails->__set( 'template', $this->get_email_template( $form_id ) );
663
+			Give()->emails->__set('template', $this->get_email_template($form_id));
665 664
 
666 665
 			// Format plain content type email.
667
-			if ( 'text/plain' === $content_type ) {
668
-				Give()->emails->__set( 'html', false );
669
-				Give()->emails->__set( 'template', 'none' );
670
-				$message = strip_tags( $message );
666
+			if ('text/plain' === $content_type) {
667
+				Give()->emails->__set('html', false);
668
+				Give()->emails->__set('template', 'none');
669
+				$message = strip_tags($message);
671 670
 			}
672 671
 
673
-			if ( Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ) {
672
+			if (Give_Email_Notification_Util::can_use_form_email_options($this, $form_id)) {
674 673
 				Give()->emails->form_id      = $form_id;
675
-				Give()->emails->from_name    = give_get_meta( $form_id, '_give_from_name', true );
676
-				Give()->emails->from_address = give_get_meta( $form_id, '_give_from_email', true );
674
+				Give()->emails->from_name    = give_get_meta($form_id, '_give_from_name', true);
675
+				Give()->emails->from_address = give_get_meta($form_id, '_give_from_email', true);
677 676
 			}
678 677
 
679
-			return Give()->emails->send( $this->get_preview_email_recipient( $form_id ), $subject, $message, $attachments );
678
+			return Give()->emails->send($this->get_preview_email_recipient($form_id), $subject, $message, $attachments);
680 679
 		}
681 680
 
682 681
 
@@ -697,7 +696,7 @@  discard block
 block discarded – undo
697 696
 		 *
698 697
 		 * @return bool
699 698
 		 */
700
-		public function send_email_notification( $email_tag_args = array() ) {
699
+		public function send_email_notification($email_tag_args = array()) {
701 700
 			// Add email content type email tags.
702 701
 			$email_tag_args['email_content_type'] = $this->config['content_type'];
703 702
 
@@ -706,16 +705,16 @@  discard block
 block discarded – undo
706 705
 			 *
707 706
 			 * @since 2.0
708 707
 			 */
709
-			$email_tag_args = apply_filters( "give_{$this->config['id']}_email_tag_args", $email_tag_args, $this );
708
+			$email_tag_args = apply_filters("give_{$this->config['id']}_email_tag_args", $email_tag_args, $this);
710 709
 
711 710
 			// Get form id.
712
-			$form_id = ! empty( $email_tag_args['form_id'] )
713
-				? absint( $email_tag_args['form_id'] )
714
-				: ( ! empty( $email_tag_args['payment_id'] ) ? give_get_payment_form_id( $email_tag_args['payment_id'] ) : null );
711
+			$form_id = ! empty($email_tag_args['form_id'])
712
+				? absint($email_tag_args['form_id'])
713
+				: ( ! empty($email_tag_args['payment_id']) ? give_get_payment_form_id($email_tag_args['payment_id']) : null);
715 714
 
716 715
 
717 716
 			// Do not send email if notification is disable.
718
-			if ( ! Give_Email_Notification_Util::is_email_notification_active( $this, $form_id ) ) {
717
+			if ( ! Give_Email_Notification_Util::is_email_notification_active($this, $form_id)) {
719 718
 				return false;
720 719
 			}
721 720
 
@@ -724,41 +723,41 @@  discard block
 block discarded – undo
724 723
 			 *
725 724
 			 * @since 2.0
726 725
 			 */
727
-			do_action( "give_{$this->config['id']}_email_send_before", $this, $form_id );
726
+			do_action("give_{$this->config['id']}_email_send_before", $this, $form_id);
728 727
 
729 728
 			$attachments  = $this->get_email_attachments();
730
-			$message      = give_do_email_tags( $this->get_email_message( $form_id ), $email_tag_args );
731
-			$subject      = give_do_email_tags( $this->get_email_subject( $form_id ), $email_tag_args );
732
-			$content_type = $this->get_email_content_type( $form_id );
729
+			$message      = give_do_email_tags($this->get_email_message($form_id), $email_tag_args);
730
+			$subject      = give_do_email_tags($this->get_email_subject($form_id), $email_tag_args);
731
+			$content_type = $this->get_email_content_type($form_id);
733 732
 
734 733
 			// Setup email content type.
735
-			Give()->emails->__set( 'content_type', $content_type );
736
-			Give()->emails->__set( 'html', true );
734
+			Give()->emails->__set('content_type', $content_type);
735
+			Give()->emails->__set('html', true);
737 736
 
738 737
 			// Set email template.
739
-			Give()->emails->__set( 'template', $this->get_email_template( $form_id ) );
738
+			Give()->emails->__set('template', $this->get_email_template($form_id));
740 739
 
741
-			if ( 'text/plain' === $content_type ) {
742
-				Give()->emails->__set( 'html', false );
743
-				Give()->emails->__set( 'template', 'none' );
744
-				$message = strip_tags( $message );
740
+			if ('text/plain' === $content_type) {
741
+				Give()->emails->__set('html', false);
742
+				Give()->emails->__set('template', 'none');
743
+				$message = strip_tags($message);
745 744
 			}
746 745
 
747
-			if ( Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ) {
746
+			if (Give_Email_Notification_Util::can_use_form_email_options($this, $form_id)) {
748 747
 				Give()->emails->form_id      = $form_id;
749
-				Give()->emails->from_name    = give_get_meta( $form_id, '_give_from_name', true );
750
-				Give()->emails->from_address = give_get_meta( $form_id, '_give_from_email', true );
748
+				Give()->emails->from_name    = give_get_meta($form_id, '_give_from_name', true);
749
+				Give()->emails->from_address = give_get_meta($form_id, '_give_from_email', true);
751 750
 			}
752 751
 
753 752
 			// Send email.
754
-			$email_status = Give()->emails->send( $this->get_recipient( $form_id ), $subject, $message, $attachments );
753
+			$email_status = Give()->emails->send($this->get_recipient($form_id), $subject, $message, $attachments);
755 754
 
756 755
 			/**
757 756
 			 * Fire action after after email send.
758 757
 			 *
759 758
 			 * @since 2.0
760 759
 			 */
761
-			do_action( "give_{$this->config['id']}_email_send_after", $email_status, $this, $form_id );
760
+			do_action("give_{$this->config['id']}_email_send_after", $email_status, $this, $form_id);
762 761
 
763 762
 			return $email_status;
764 763
 		}
@@ -773,67 +772,67 @@  discard block
 block discarded – undo
773 772
 		 *
774 773
 		 * @return string
775 774
 		 */
776
-		public function preview_email_template_tags( $message ) {
775
+		public function preview_email_template_tags($message) {
777 776
 			// Set Payment.
778
-			$payment_id = give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'preview_id' );
779
-			$payment    = $payment_id ? new Give_Payment( $payment_id ) : new stdClass();
777
+			$payment_id = give_check_variable(give_clean($_GET), 'isset_empty', 0, 'preview_id');
778
+			$payment    = $payment_id ? new Give_Payment($payment_id) : new stdClass();
780 779
 
781 780
 			// Set donor.
782 781
 			$user_id = $payment_id
783 782
 				? $payment->user_id
784
-				: give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'user_id' );
783
+				: give_check_variable(give_clean($_GET), 'isset_empty', 0, 'user_id');
785 784
 			$user_id = $user_id ? $user_id : wp_get_current_user()->ID;
786 785
 
787 786
 			// Set receipt.
788
-			$receipt_id = strtolower( md5( uniqid() ) );
787
+			$receipt_id = strtolower(md5(uniqid()));
789 788
 
790
-			$receipt_link_url = esc_url( add_query_arg( array(
789
+			$receipt_link_url = esc_url(add_query_arg(array(
791 790
 				'payment_key' => $receipt_id,
792
-			), give_get_history_page_uri() ) );
791
+			), give_get_history_page_uri()));
793 792
 
794 793
 			$receipt_link = sprintf(
795 794
 				'<a href="%1$s">%2$s</a>',
796 795
 				$receipt_link_url,
797
-				esc_html__( 'View the receipt in your browser &raquo;', 'give' )
796
+				esc_html__('View the receipt in your browser &raquo;', 'give')
798 797
 			);
799 798
 
800 799
 			// Set default values for tags.
801 800
 			$this->config['preview_email_tags_values'] = wp_parse_args(
802 801
 				$this->config['preview_email_tags_values'],
803 802
 				array(
804
-					'name'              => give_email_tag_first_name( array(
803
+					'name'              => give_email_tag_first_name(array(
805 804
 						'payment_id' => $payment_id,
806 805
 						'user_id'    => $user_id,
807
-					) ),
808
-					'fullname'          => give_email_tag_fullname( array(
806
+					)),
807
+					'fullname'          => give_email_tag_fullname(array(
809 808
 						'payment_id' => $payment_id,
810 809
 						'user_id'    => $user_id,
811
-					) ),
812
-					'username'          => give_email_tag_username( array(
810
+					)),
811
+					'username'          => give_email_tag_username(array(
813 812
 						'payment_id' => $payment_id,
814 813
 						'user_id'    => $user_id,
815
-					) ),
816
-					'user_email'        => give_email_tag_user_email( array(
814
+					)),
815
+					'user_email'        => give_email_tag_user_email(array(
817 816
 						'payment_id' => $payment_id,
818 817
 						'user_id'    => $user_id,
819
-					) ),
820
-					'payment_total'     => $payment_id ? give_email_tag_payment_total( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ),
821
-					'amount'            => $payment_id ? give_email_tag_amount( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ),
822
-					'price'             => $payment_id ? give_email_tag_price( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ),
823
-					'payment_method'    => $payment_id ? give_email_tag_payment_method( array( 'payment_id' => $payment_id ) ) : __( 'PayPal', 'give' ),
818
+					)),
819
+					'payment_total'     => $payment_id ? give_email_tag_payment_total(array('payment_id' => $payment_id)) : give_currency_filter('10.50'),
820
+					'amount'            => $payment_id ? give_email_tag_amount(array('payment_id' => $payment_id)) : give_currency_filter('10.50'),
821
+					'price'             => $payment_id ? give_email_tag_price(array('payment_id' => $payment_id)) : give_currency_filter('10.50'),
822
+					'payment_method'    => $payment_id ? give_email_tag_payment_method(array('payment_id' => $payment_id)) : __('PayPal', 'give'),
824 823
 					'receipt_id'        => $receipt_id,
825
-					'payment_id'        => $payment_id ? $payment_id : rand( 2000, 2050 ),
824
+					'payment_id'        => $payment_id ? $payment_id : rand(2000, 2050),
826 825
 					'receipt_link_url'  => $receipt_link_url,
827 826
 					'receipt_link'      => $receipt_link,
828
-					'date'              => $payment_id ? date( give_date_format(), strtotime( $payment->date ) ) : date( give_date_format(), current_time( 'timestamp' ) ),
829
-					'donation'          => $payment_id ? give_email_tag_donation( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title', 'give' ),
830
-					'form_title'        => $payment_id ? give_email_tag_form_title( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ),
831
-					'sitename'          => $payment_id ? give_email_tag_sitename( array( 'payment_id' => $payment_id ) ) : get_bloginfo( 'name' ),
827
+					'date'              => $payment_id ? date(give_date_format(), strtotime($payment->date)) : date(give_date_format(), current_time('timestamp')),
828
+					'donation'          => $payment_id ? give_email_tag_donation(array('payment_id' => $payment_id)) : esc_html__('Sample Donation Form Title', 'give'),
829
+					'form_title'        => $payment_id ? give_email_tag_form_title(array('payment_id' => $payment_id)) : esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'),
830
+					'sitename'          => $payment_id ? give_email_tag_sitename(array('payment_id' => $payment_id)) : get_bloginfo('name'),
832 831
 					'pdf_receipt'       => sprintf(
833 832
 						'<a href="#">%s</a>',
834
-						__( 'Download Receipt', 'give' )
833
+						__('Download Receipt', 'give')
835 834
 					),
836
-					'billing_address'   => $payment_id ? give_email_tag_billing_address( array( 'payment_id' => $payment_id ) ) : '',
835
+					'billing_address'   => $payment_id ? give_email_tag_billing_address(array('payment_id' => $payment_id)) : '',
837 836
 					'email_access_link' => sprintf(
838 837
 						'<a href="%1$s">%2$s</a>',
839 838
 						add_query_arg(
@@ -842,20 +841,20 @@  discard block
 block discarded – undo
842 841
 							),
843 842
 							give_get_history_page_uri()
844 843
 						),
845
-						__( 'View your donation history &raquo;', 'give' )
844
+						__('View your donation history &raquo;', 'give')
846 845
 					),
847
-					'reset_password_link' => $user_id ? give_email_tag_reset_password_link( array( 'user_id' => $user_id ), $payment_id ) : '',
846
+					'reset_password_link' => $user_id ? give_email_tag_reset_password_link(array('user_id' => $user_id), $payment_id) : '',
848 847
 				)
849 848
 			);
850 849
 
851 850
 			// Decode tags.
852
-			foreach ( $this->config['preview_email_tags_values'] as $preview_tag => $value ) {
853
-				if ( isset( $this->config['preview_email_tags_values'][ $preview_tag ] ) ) {
854
-					$message = str_replace( "{{$preview_tag}}", $this->config['preview_email_tags_values'][ $preview_tag ], $message );
851
+			foreach ($this->config['preview_email_tags_values'] as $preview_tag => $value) {
852
+				if (isset($this->config['preview_email_tags_values'][$preview_tag])) {
853
+					$message = str_replace("{{$preview_tag}}", $this->config['preview_email_tags_values'][$preview_tag], $message);
855 854
 				}
856 855
 			}
857 856
 
858
-			return apply_filters( 'give_email_preview_template_tags', $message );
857
+			return apply_filters('give_email_preview_template_tags', $message);
859 858
 		}
860 859
 
861 860
 		/**
@@ -880,17 +879,17 @@  discard block
 block discarded – undo
880 879
 		 * @param $post_id
881 880
 		 *
882 881
 		 */
883
-		public function validate_form_recipient_field_value( $form_meta_key, $form_meta_value, $post_id ) {
882
+		public function validate_form_recipient_field_value($form_meta_key, $form_meta_value, $post_id) {
884 883
 			// Get valid emails.
885
-			$new_form_meta_value = array_filter( $form_meta_value, function ( $value ) {
886
-				return ! empty( $value['email'] ) && is_email( $value['email'] );
884
+			$new_form_meta_value = array_filter($form_meta_value, function($value) {
885
+				return ! empty($value['email']) && is_email($value['email']);
887 886
 			} );
888 887
 
889 888
 			// Remove duplicate emails from array.
890 889
 			$email_arr = array();
891
-			foreach ( $new_form_meta_value as $index => $email ) {
892
-				if( in_array( $email['email'], $email_arr  ) ) {
893
-					unset( $new_form_meta_value[$index] );
890
+			foreach ($new_form_meta_value as $index => $email) {
891
+				if (in_array($email['email'], $email_arr)) {
892
+					unset($new_form_meta_value[$index]);
894 893
 					continue;
895 894
 				}
896 895
 
@@ -899,25 +898,25 @@  discard block
 block discarded – undo
899 898
 
900 899
 			$update = false;
901 900
 
902
-			if ( empty( $new_form_meta_value ) ) {
901
+			if (empty($new_form_meta_value)) {
903 902
 				// Set default recipient.
904 903
 				$form_meta_value = array(
905 904
 					array(
906
-						'email' => get_bloginfo( 'admin_email' )
905
+						'email' => get_bloginfo('admin_email')
907 906
 					),
908 907
 				);
909 908
 
910 909
 				$update = true;
911 910
 
912
-			} elseif ( count( $new_form_meta_value ) !== count( $form_meta_value ) ) {
911
+			} elseif (count($new_form_meta_value) !== count($form_meta_value)) {
913 912
 				// Filter recipient emails.
914 913
 				$form_meta_value = $new_form_meta_value;
915 914
 
916 915
 				$update = true;
917 916
 			}
918 917
 
919
-			if( $update ) {
920
-				give_update_meta( $post_id, $form_meta_key, $form_meta_value );
918
+			if ($update) {
919
+				give_update_meta($post_id, $form_meta_key, $form_meta_value);
921 920
 			}
922 921
 		}
923 922
 	}
Please login to merge, or discard this patch.
includes/admin/emails/class-donor-register-email.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@
 block discarded – undo
120 120
 		 * @param string                    $email_preview_header
121 121
 		 * @param Give_Donor_Register_Email $email
122 122
 		 *
123
-		 * @return bool
123
+		 * @return string|null
124 124
 		 */
125 125
 		public function email_preview_header( $email_preview_header, $email ) {
126 126
 			// Bailout.
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if access directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17
-if ( ! class_exists( 'Give_Donor_Register_Email' ) ) :
17
+if ( ! class_exists('Give_Donor_Register_Email')) :
18 18
 
19 19
 	/**
20 20
 	 * Give_Donor_Register_Email
@@ -31,34 +31,34 @@  discard block
 block discarded – undo
31 31
 		 * @since   2.0
32 32
 		 */
33 33
 		public function init() {
34
-			$this->load( array(
34
+			$this->load(array(
35 35
 				'id'                    => 'donor-register',
36
-				'label'                 => __( 'User Registration Information', 'give' ),
37
-				'description'           => __( 'Sent to the donor when they register for an account on the site.', 'give' ),
36
+				'label'                 => __('User Registration Information', 'give'),
37
+				'description'           => __('Sent to the donor when they register for an account on the site.', 'give'),
38 38
 				'notification_status'   => 'enabled',
39 39
 				'email_tag_contex'      => 'donor',
40 40
 				'form_metabox_setting'  => false,
41
-				'recipient_group_name'  => __( 'Donor', 'give' ),
42
-				'email_tag_context'     => array( 'donor', 'general' ),
41
+				'recipient_group_name'  => __('Donor', 'give'),
42
+				'email_tag_context'     => array('donor', 'general'),
43 43
 				'default_email_subject' => sprintf(
44 44
 				/* translators: %s: site name */
45
-					esc_attr__( '[%s] Your username and password', 'give' ),
46
-					get_bloginfo( 'name' )
45
+					esc_attr__('[%s] Your username and password', 'give'),
46
+					get_bloginfo('name')
47 47
 				),
48 48
 				'default_email_message' => $this->get_default_email_message(),
49
-			) );
49
+			));
50 50
 
51 51
 			// Setup action hook.
52 52
 			add_action(
53 53
 				"give_{$this->config['id']}_email_notification",
54
-				array( $this, 'setup_email_notification' ),
54
+				array($this, 'setup_email_notification'),
55 55
 				10,
56 56
 				2
57 57
 			);
58 58
 
59 59
 			add_filter(
60 60
 				'give_email_preview_header',
61
-				array( $this, 'email_preview_header' ),
61
+				array($this, 'email_preview_header'),
62 62
 				10,
63 63
 				2
64 64
 			);
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
 		 * @return string
74 74
 		 */
75 75
 		function get_default_email_message() {
76
-			$message = esc_attr__( 'Username: {username}', 'give' ) . "\r\n\r\n";
76
+			$message = esc_attr__('Username: {username}', 'give')."\r\n\r\n";
77 77
 
78
-			$message .= __( 'To reset your password, simply click the link below which will take you to a web page where you can create a new password.', 'give' ) . "\r\n";
79
-			$message .= '{reset_password_link}' . "\r\n\r\n";
78
+			$message .= __('To reset your password, simply click the link below which will take you to a web page where you can create a new password.', 'give')."\r\n";
79
+			$message .= '{reset_password_link}'."\r\n\r\n";
80 80
 
81
-			$message .= __( 'After resetting password, Please login to your account with link below.', 'give' ) . "\r\n";
82
-			$message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login &raquo;', 'give' ) . '</a>' . "\r\n";
81
+			$message .= __('After resetting password, Please login to your account with link below.', 'give')."\r\n";
82
+			$message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login &raquo;', 'give').'</a>'."\r\n";
83 83
 
84 84
 			/**
85 85
 			 * Filter the default email message
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		 * @since 2.0
99 99
 		 */
100 100
 		public function setup_email_data() {
101
-			Give()->emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) );
101
+			Give()->emails->__set('heading', esc_html__('New User Registration', 'give'));
102 102
 		}
103 103
 
104 104
 		/**
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
 		 *
113 113
 		 * @return string
114 114
 		 */
115
-		public function setup_email_notification( $user_id, $user_data ) {
115
+		public function setup_email_notification($user_id, $user_data) {
116 116
 			$this->setup_email_data();
117 117
 
118 118
 			$this->recipient_email = $user_data['user_email'];
119
-			$this->send_email_notification( array(
119
+			$this->send_email_notification(array(
120 120
 				'user_id' => $user_id,
121
-			) );
121
+			));
122 122
 		}
123 123
 
124 124
 		/**
@@ -132,42 +132,42 @@  discard block
 block discarded – undo
132 132
 		 *
133 133
 		 * @return bool
134 134
 		 */
135
-		public function email_preview_header( $email_preview_header, $email ) {
135
+		public function email_preview_header($email_preview_header, $email) {
136 136
 			// Bailout.
137
-			if ( $this->config['id'] !== $email->config['id'] ) {
137
+			if ($this->config['id'] !== $email->config['id']) {
138 138
 				return $email_preview_header;
139 139
 			}
140 140
 
141 141
 			// Payment receipt switcher
142
-			$user_id = give_check_variable( give_clean( $_GET ), 'isset', 0, 'user_id' );
142
+			$user_id = give_check_variable(give_clean($_GET), 'isset', 0, 'user_id');
143 143
 
144 144
 			// Get payments.
145 145
 			$donors  = new Give_API();
146
-			$donors  = give_check_variable( $donors->get_donors(), 'empty', array(), 'donors' );
146
+			$donors  = give_check_variable($donors->get_donors(), 'empty', array(), 'donors');
147 147
 			$options = array();
148 148
 
149 149
 			// Default option.
150
-			$options[0] = esc_html__( 'No donor(s) found.', 'give' );
150
+			$options[0] = esc_html__('No donor(s) found.', 'give');
151 151
 
152 152
 			// Provide nice human readable options.
153
-			if ( $donors ) {
154
-				$options[0] = esc_html__( '- Select a donor -', 'give' );
155
-				foreach ( $donors as $donor ) {
153
+			if ($donors) {
154
+				$options[0] = esc_html__('- Select a donor -', 'give');
155
+				foreach ($donors as $donor) {
156 156
 					// Exclude customers for which wp user not exist.
157
-					if ( ! $donor['info']['user_id'] ) {
157
+					if ( ! $donor['info']['user_id']) {
158 158
 						continue;
159 159
 					}
160
-					$options[ $donor['info']['user_id'] ] = esc_html( '#' . $donor['info']['donor_id'] . ' - ' . $donor['info']['email'] );
160
+					$options[$donor['info']['user_id']] = esc_html('#'.$donor['info']['donor_id'].' - '.$donor['info']['email']);
161 161
 				}
162 162
 			}
163 163
 
164
-			$request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] );
164
+			$request_url_data = wp_parse_url($_SERVER['REQUEST_URI']);
165 165
 			$query            = $request_url_data['query'];
166 166
 
167 167
 			// Remove user id query param if set from request url.
168
-			$query = remove_query_arg( array( 'user_id' ), $query );
168
+			$query = remove_query_arg(array('user_id'), $query);
169 169
 
170
-			$request_url = home_url( '/?' . str_replace( '', '', $query ) );
170
+			$request_url = home_url('/?'.str_replace('', '', $query));
171 171
 			?>
172 172
 
173 173
 			<!-- Start constructing HTML output.-->
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 				</script>
186 186
 
187 187
 				<label for="give_preview_email_user_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">
188
-					<?php echo esc_html__( 'Preview email with a donor:', 'give' ); ?>
188
+					<?php echo esc_html__('Preview email with a donor:', 'give'); ?>
189 189
 				</label>
190 190
 
191 191
 				<?php
192 192
 				// The select field with 100 latest transactions
193
-				echo Give()->html->select( array(
193
+				echo Give()->html->select(array(
194 194
 					'name'             => 'preview_email_user_id',
195 195
 					'selected'         => $user_id,
196 196
 					'id'               => 'give_preview_email_user_id',
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 					'select_atts'      => 'onchange="change_preview()"',
201 201
 					'show_option_all'  => false,
202 202
 					'show_option_none' => false,
203
-				) );
203
+				));
204 204
 				?>
205 205
 			</div>
206 206
 			<?php
Please login to merge, or discard this patch.
includes/admin/emails/class-email-notification-util.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -178,7 +178,7 @@
 block discarded – undo
178 178
 	 * @param Give_Email_Notification $email
179 179
 	 * @param int $form_id
180 180
 	 *
181
-	 * @return string
181
+	 * @return boolean
182 182
 	 */
183 183
 	public static function is_email_notification_active( Give_Email_Notification $email, $form_id = null ) {
184 184
 		$notification_status = $email->get_notification_status( $form_id );
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 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 access directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * @return static
47 47
 	 */
48 48
 	static function get_instance() {
49
-		if ( null === static::$instance ) {
49
+		if (null === static::$instance) {
50 50
 			self::$instance = new static();
51 51
 		}
52 52
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return bool
66 66
 	 */
67
-	public static function has_preview( Give_Email_Notification $email ) {
67
+	public static function has_preview(Give_Email_Notification $email) {
68 68
 		return $email->config['has_preview'];
69 69
 	}
70 70
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @return bool
80 80
 	 */
81
-	public static function has_recipient_field( Give_Email_Notification $email ) {
81
+	public static function has_recipient_field(Give_Email_Notification $email) {
82 82
 		return $email->config['has_recipient_field'];
83 83
 	}
84 84
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return bool
94 94
 	 */
95
-	public static function is_notification_status_editable( Give_Email_Notification $email ) {
95
+	public static function is_notification_status_editable(Give_Email_Notification $email) {
96 96
 		$user_can_edit = $email->config['notification_status_editable'];
97 97
 
98 98
 		return (bool) $user_can_edit;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return bool
110 110
 	 */
111
-	public static function is_content_type_editable( Give_Email_Notification $email ) {
111
+	public static function is_content_type_editable(Give_Email_Notification $email) {
112 112
 		return $email->config['content_type_editable'];
113 113
 	}
114 114
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return bool
124 124
 	 */
125
-	public static function is_email_preview_has_header( Give_Email_Notification $email ) {
125
+	public static function is_email_preview_has_header(Give_Email_Notification $email) {
126 126
 		return $email->config['has_preview_header'];
127 127
 	}
128 128
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @return bool
138 138
 	 */
139
-	public static function is_email_preview( Give_Email_Notification $email ) {
139
+	public static function is_email_preview(Give_Email_Notification $email) {
140 140
 		return $email->config['has_preview'];
141 141
 	}
142 142
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @return bool
152 152
 	 */
153
-	public static function is_show_on_emails_setting_page( Give_Email_Notification $email ){
153
+	public static function is_show_on_emails_setting_page(Give_Email_Notification $email) {
154 154
 		return $email->config['show_on_emails_setting_page'];
155 155
 	}
156 156
 
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
 	 *
166 166
 	 * @return bool
167 167
 	 */
168
-	public static function can_use_form_email_options( Give_Email_Notification $email, $form_id = null ){
169
-		return give_is_setting_enabled( give_get_meta( $form_id, '_give_email_options', true ) );
168
+	public static function can_use_form_email_options(Give_Email_Notification $email, $form_id = null) {
169
+		return give_is_setting_enabled(give_get_meta($form_id, '_give_email_options', true));
170 170
 	}
171 171
 
172 172
 	/**
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @return string
182 182
 	 */
183
-	public static function is_email_notification_active( Give_Email_Notification $email, $form_id = null ) {
184
-		$notification_status = $email->get_notification_status( $form_id );
183
+	public static function is_email_notification_active(Give_Email_Notification $email, $form_id = null) {
184
+		$notification_status = $email->get_notification_status($form_id);
185 185
 
186 186
 
187
-		$notification_status = empty( $form_id )
188
-			? give_is_setting_enabled( $notification_status )
189
-			: give_is_setting_enabled( give_get_option( "{$email->config['id']}_notification", $email->config['notification_status'] ) ) && give_is_setting_enabled( $notification_status, array( 'enabled', 'global' ) );
187
+		$notification_status = empty($form_id)
188
+			? give_is_setting_enabled($notification_status)
189
+			: give_is_setting_enabled(give_get_option("{$email->config['id']}_notification", $email->config['notification_status'])) && give_is_setting_enabled($notification_status, array('enabled', 'global'));
190 190
 			// To check if email notification is active or not on a per-form basis, email notification must be globally active—otherwise it will be considered disabled.
191 191
 
192 192
 		return $notification_status;
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
 		$is_preview = false;
204 204
 
205 205
 		if (
206
-			current_user_can( 'manage_give_settings' )
207
-			&& ! empty( $_GET['give_action'] )
206
+			current_user_can('manage_give_settings')
207
+			&& ! empty($_GET['give_action'])
208 208
 			&& 'preview_email' === $_GET['give_action']
209 209
 		) {
210 210
 			$is_preview = true;
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 		$is_preview = false;
225 225
 
226 226
 		if (
227
-			current_user_can( 'manage_give_settings' )
228
-			&& ! empty( $_GET['give_action'] )
227
+			current_user_can('manage_give_settings')
228
+			&& ! empty($_GET['give_action'])
229 229
 			&& 'send_preview_email' === $_GET['give_action']
230 230
 		) {
231 231
 			$is_preview = true;
@@ -245,13 +245,13 @@  discard block
 block discarded – undo
245 245
 	 *
246 246
 	 * @return string
247 247
 	 */
248
-	public static function get_formatted_email_type( $content_type ) {
248
+	public static function get_formatted_email_type($content_type) {
249 249
 		$email_contents = array(
250
-			'text/html'  => __( 'HTML', 'give' ),
251
-			'text/plain' => __( 'Plain', 'give' ),
250
+			'text/html'  => __('HTML', 'give'),
251
+			'text/plain' => __('Plain', 'give'),
252 252
 		);
253 253
 
254
-		return $email_contents[ $content_type ];
254
+		return $email_contents[$content_type];
255 255
 	}
256 256
 
257 257
 
@@ -268,40 +268,40 @@  discard block
 block discarded – undo
268 268
 	 *
269 269
 	 * @return mixed
270 270
 	 */
271
-	public static function get_value( Give_Email_Notification $email, $option_name, $form_id = null, $default = false ) {
271
+	public static function get_value(Give_Email_Notification $email, $option_name, $form_id = null, $default = false) {
272 272
 		// If form id set then option name can be contain _give_ prefix which is only used for meta key,
273 273
 		// So make sure you are using correct option name.
274
-		$global_option_name = ( 0 === strpos( $option_name, '_give_' )
275
-			? str_replace( '_give_', '', $option_name )
276
-			: $option_name );
277
-		$option_value = give_get_option( $global_option_name, $default );
274
+		$global_option_name = (0 === strpos($option_name, '_give_')
275
+			? str_replace('_give_', '', $option_name)
276
+			: $option_name);
277
+		$option_value = give_get_option($global_option_name, $default);
278 278
 
279 279
 		if (
280
-			! empty( $form_id )
280
+			! empty($form_id)
281 281
 			&& give_is_setting_enabled(
282 282
 				give_get_meta(
283 283
 					$form_id,
284
-					Give_Email_Setting_Field::get_prefix( $email, $form_id ) . 'notification',
284
+					Give_Email_Setting_Field::get_prefix($email, $form_id).'notification',
285 285
 					true,
286 286
 					'global'
287 287
 				)
288 288
 			)
289 289
 		) {
290
-			$option_value = get_post_meta( $form_id, $option_name, true );
290
+			$option_value = get_post_meta($form_id, $option_name, true);
291 291
 
292 292
 			// Get only email field value from recipients setting.
293
-			if( Give_Email_Setting_Field::get_prefix( $email, $form_id ) . 'recipient' === $option_name ) {
294
-				$option_value = wp_list_pluck( $option_value, 'email' );
293
+			if (Give_Email_Setting_Field::get_prefix($email, $form_id).'recipient' === $option_name) {
294
+				$option_value = wp_list_pluck($option_value, 'email');
295 295
 			}
296 296
 		}
297 297
 
298
-		$option_value = empty( $option_value ) ? $default : $option_value;
298
+		$option_value = empty($option_value) ? $default : $option_value;
299 299
 
300 300
 		/**
301 301
 		 * Filter the setting value
302 302
 		 *
303 303
 		 * @since 2.0
304 304
 		 */
305
-		return apply_filters( 'give_email_setting_value', $option_value, $option_name, $email, $form_id, $default );
305
+		return apply_filters('give_email_setting_value', $option_value, $option_name, $email, $form_id, $default);
306 306
 	}
307 307
 }
Please login to merge, or discard this patch.
includes/admin/emails/class-email-notifications.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @since  2.0
233 233
 	 * @access public
234
-	 * @return bool|null
234
+	 * @return false|null
235 235
 	 */
236 236
 	public function preview_email() {
237 237
 		// Bailout.
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 *
370 370
 	 * @since  2.0
371 371
 	 * @access public
372
-	 * @return bool|null
372
+	 * @return false|null
373 373
 	 */
374 374
 	public function send_preview_email() {
375 375
 		// Bailout.
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 * @return static
53 53
 	 */
54 54
 	static function get_instance() {
55
-		if ( null === static::$instance ) {
55
+		if (null === static::$instance) {
56 56
 			self::$instance = new static();
57 57
 		}
58 58
 
@@ -66,31 +66,31 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function init() {
68 68
 		// Load files.
69
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/ajax-handler.php';
70
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-setting-field.php';
71
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/filters.php';
69
+		require_once GIVE_PLUGIN_DIR.'includes/admin/emails/ajax-handler.php';
70
+		require_once GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-setting-field.php';
71
+		require_once GIVE_PLUGIN_DIR.'includes/admin/emails/filters.php';
72 72
 
73 73
 		// Load email notifications.
74 74
 		$this->add_emails_notifications();
75 75
 
76
-		add_filter( 'give_metabox_form_data_settings', array( $this, 'add_metabox_setting_fields' ), 10, 2 );
77
-		add_action( 'init', array( $this, 'preview_email' ) );
78
-		add_action( 'init', array( $this, 'send_preview_email' ) );
79
-		add_action( 'init', array( $this, 'validate_settings' ) );
76
+		add_filter('give_metabox_form_data_settings', array($this, 'add_metabox_setting_fields'), 10, 2);
77
+		add_action('init', array($this, 'preview_email'));
78
+		add_action('init', array($this, 'send_preview_email'));
79
+		add_action('init', array($this, 'validate_settings'));
80 80
 
81 81
 		/* @var Give_Email_Notification $email */
82
-		foreach ( $this->get_email_notifications() as $email ) {
82
+		foreach ($this->get_email_notifications() as $email) {
83 83
 			// Setup email section.
84
-			if( Give_Email_Notification_Util::is_show_on_emails_setting_page( $email ) ) {
85
-				add_filter( 'give_get_sections_emails', array( $email, 'add_section' ) );
86
-				add_filter( "give_hide_section_{$email->config['id']}_on_emails_page", array( $email, 'hide_section' ) );
84
+			if (Give_Email_Notification_Util::is_show_on_emails_setting_page($email)) {
85
+				add_filter('give_get_sections_emails', array($email, 'add_section'));
86
+				add_filter("give_hide_section_{$email->config['id']}_on_emails_page", array($email, 'hide_section'));
87 87
 			}
88 88
 
89 89
 			// Setup email preview.
90
-			if ( Give_Email_Notification_Util::is_email_preview_has_header( $email ) ) {
91
-				add_action( "give_{$email->config['id']}_email_preview", array( $this, 'email_preview_header' ) );
92
-				add_filter( "give_{$email->config['id']}_email_preview_data", array( $this, 'email_preview_data' ) );
93
-				add_filter( "give_{$email->config['id']}_email_preview_message", array( $this, 'email_preview_message' ), 1, 2 );
90
+			if (Give_Email_Notification_Util::is_email_preview_has_header($email)) {
91
+				add_action("give_{$email->config['id']}_email_preview", array($this, 'email_preview_header'));
92
+				add_filter("give_{$email->config['id']}_email_preview_data", array($this, 'email_preview_data'));
93
+				add_filter("give_{$email->config['id']}_email_preview_message", array($this, 'email_preview_message'), 1, 2);
94 94
 			}
95 95
 		}
96 96
 	}
@@ -107,64 +107,64 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @return array
109 109
 	 */
110
-	public function add_metabox_setting_fields( $settings, $post_id ) {
110
+	public function add_metabox_setting_fields($settings, $post_id) {
111 111
 		$emails = $this->get_email_notifications();
112 112
 
113 113
 		// Bailout.
114
-		if ( empty( $emails ) ) {
114
+		if (empty($emails)) {
115 115
 			return $settings;
116 116
 		}
117 117
 
118 118
 		// Email notification setting.
119 119
 		$settings['email_notification_options'] = array(
120 120
 			'id'         => 'email_notification_options',
121
-			'title'      => __( 'Email Notifications', 'give' ),
121
+			'title'      => __('Email Notifications', 'give'),
122 122
 			'icon-html' => '<span class="dashicons dashicons-email-alt"></span>',
123 123
 			'fields'     => array(
124 124
 				array(
125
-					'name'        => __( 'Email Options', 'give' ),
126
-					'description' => __( '', 'give' ),
125
+					'name'        => __('Email Options', 'give'),
126
+					'description' => __('', 'give'),
127 127
 					'id'          => '_give_email_options',
128 128
 					'type'        => 'radio_inline',
129 129
 					'default'     => 'global',
130 130
 					'options'     => array(
131
-						'global'   => __( 'Global Options' ),
132
-						'enabled'  => __( 'Customize', 'give' ),
131
+						'global'   => __('Global Options'),
132
+						'enabled'  => __('Customize', 'give'),
133 133
 					),
134 134
 				),
135 135
 				array(
136 136
 					'id'      => '_give_email_template',
137
-					'name'    => esc_html__( 'Email Template', 'give' ),
138
-					'desc'    => esc_html__( 'Choose your template from the available registered template types.', 'give' ),
137
+					'name'    => esc_html__('Email Template', 'give'),
138
+					'desc'    => esc_html__('Choose your template from the available registered template types.', 'give'),
139 139
 					'type'    => 'select',
140 140
 					'default' => 'default',
141 141
 					'options' => give_get_email_templates(),
142 142
 				),
143 143
 				array(
144 144
 					'id'   => '_give_email_logo',
145
-					'name' => esc_html__( 'Logo', 'give' ),
146
-					'desc' => esc_html__( 'Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give' ),
145
+					'name' => esc_html__('Logo', 'give'),
146
+					'desc' => esc_html__('Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give'),
147 147
 					'type' => 'file',
148 148
 				),
149 149
 				array(
150 150
 					'id'      => '_give_from_name',
151
-					'name'    => esc_html__( 'From Name', 'give' ),
152
-					'desc'    => esc_html__( 'The name which appears in the "From" field in all Give donation emails.', 'give' ),
153
-					'default' => get_bloginfo( 'name' ),
151
+					'name'    => esc_html__('From Name', 'give'),
152
+					'desc'    => esc_html__('The name which appears in the "From" field in all Give donation emails.', 'give'),
153
+					'default' => get_bloginfo('name'),
154 154
 					'type'    => 'text',
155 155
 				),
156 156
 				array(
157 157
 					'id'      => '_give_from_email',
158
-					'name'    => esc_html__( 'From Email', 'give' ),
159
-					'desc'    => esc_html__( 'Email address from which all Give emails are sent from. This will act as the "from" and "reply-to" email address.', 'give' ),
160
-					'default' => get_bloginfo( 'admin_email' ),
158
+					'name'    => esc_html__('From Email', 'give'),
159
+					'desc'    => esc_html__('Email address from which all Give emails are sent from. This will act as the "from" and "reply-to" email address.', 'give'),
160
+					'default' => get_bloginfo('admin_email'),
161 161
 					'type'    => 'text',
162 162
 				),
163 163
 				array(
164 164
 					'name'  => 'email_notification_docs',
165 165
 					'type'  => 'docs_link',
166 166
 					'url'   => 'http://docs.givewp.com/email-notification',
167
-					'title' => __( 'Email Notification', 'give' ),
167
+					'title' => __('Email Notification', 'give'),
168 168
 				),
169 169
 			),
170 170
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 			 *
174 174
 			 * @since 2.0
175 175
 			 */
176
-			'sub-fields' => apply_filters( 'give_email_notification_options_metabox_fields', array(), $post_id ),
176
+			'sub-fields' => apply_filters('give_email_notification_options_metabox_fields', array(), $post_id),
177 177
 		);
178 178
 
179 179
 		return $settings;
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
 	 */
188 188
 	private function add_emails_notifications() {
189 189
 		$this->emails = array(
190
-			include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-new-donation-email.php',
191
-			include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-donation-receipt-email.php',
192
-			include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-new-offline-donation-email.php',
193
-			include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-offline-donation-instruction-email.php',
194
-			include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-new-donor-register-email.php',
195
-			include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-donor-register-email.php',
196
-			include GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-access-email.php',
190
+			include GIVE_PLUGIN_DIR.'includes/admin/emails/class-new-donation-email.php',
191
+			include GIVE_PLUGIN_DIR.'includes/admin/emails/class-donation-receipt-email.php',
192
+			include GIVE_PLUGIN_DIR.'includes/admin/emails/class-new-offline-donation-email.php',
193
+			include GIVE_PLUGIN_DIR.'includes/admin/emails/class-offline-donation-instruction-email.php',
194
+			include GIVE_PLUGIN_DIR.'includes/admin/emails/class-new-donor-register-email.php',
195
+			include GIVE_PLUGIN_DIR.'includes/admin/emails/class-donor-register-email.php',
196
+			include GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-access-email.php',
197 197
 		);
198 198
 
199 199
 		/**
@@ -201,15 +201,15 @@  discard block
 block discarded – undo
201 201
 		 *
202 202
 		 * @since 2.0
203 203
 		 */
204
-		$this->emails = apply_filters( 'give_email_notifications', $this->emails, $this );
204
+		$this->emails = apply_filters('give_email_notifications', $this->emails, $this);
205 205
 
206 206
 		// Bailout.
207
-		if ( empty( $this->emails ) ) {
207
+		if (empty($this->emails)) {
208 208
 			return;
209 209
 		}
210 210
 
211 211
 		// Initiate email notifications.
212
-		foreach ( $this->emails as $email ) {
212
+		foreach ($this->emails as $email) {
213 213
 			$email->init();
214 214
 		}
215 215
 	}
@@ -236,41 +236,41 @@  discard block
 block discarded – undo
236 236
 	 */
237 237
 	public function preview_email() {
238 238
 		// Bailout.
239
-		if ( ! Give_Email_Notification_Util::can_preview_email() ) {
239
+		if ( ! Give_Email_Notification_Util::can_preview_email()) {
240 240
 			return false;
241 241
 		}
242 242
 
243 243
 		// Security check.
244
-		give_validate_nonce( $_GET['_wpnonce'], 'give-preview-email' );
244
+		give_validate_nonce($_GET['_wpnonce'], 'give-preview-email');
245 245
 
246 246
 		// Get email type.
247
-		$email_type = isset( $_GET['email_type'] ) ? esc_attr( $_GET['email_type'] ) : '';
247
+		$email_type = isset($_GET['email_type']) ? esc_attr($_GET['email_type']) : '';
248 248
 
249 249
 		/* @var Give_Email_Notification $email */
250
-		foreach ( $this->get_email_notifications() as $email ) {
251
-			if ( $email_type !== $email->config['id'] ) {
250
+		foreach ($this->get_email_notifications() as $email) {
251
+			if ($email_type !== $email->config['id']) {
252 252
 				continue;
253 253
 			}
254 254
 
255 255
 			// Set form id.
256
-			$form_id = empty( $_GET['form_id']  ) ? null : absint( $_GET['form_id'] );
256
+			$form_id = empty($_GET['form_id']) ? null : absint($_GET['form_id']);
257 257
 
258 258
 			// Call setup email data to apply filter and other thing to email.
259 259
 			$email->setup_email_data();
260 260
 
261 261
 			// Decode message.
262
-			$email_message = $email->preview_email_template_tags( $email->get_email_message( $form_id ) );
262
+			$email_message = $email->preview_email_template_tags($email->get_email_message($form_id));
263 263
 
264 264
 			// Set email template.
265
-			Give()->emails->html    = true;
266
-			Give()->emails->__set( 'template', $email->get_email_template( $form_id ) );
265
+			Give()->emails->html = true;
266
+			Give()->emails->__set('template', $email->get_email_template($form_id));
267 267
 
268
-			if ( 'text/plain' === $email->config['content_type'] ) {
268
+			if ('text/plain' === $email->config['content_type']) {
269 269
 				// Give()->emails->__set( 'html', false );
270
-				Give()->emails->__set( 'template', 'none' );
270
+				Give()->emails->__set('template', 'none');
271 271
 			}
272 272
 
273
-			if ( $email_message = Give()->emails->build_email( $email_message ) ) {
273
+			if ($email_message = Give()->emails->build_email($email_message)) {
274 274
 
275 275
 				/**
276 276
 				 * Filter the email preview data
@@ -279,14 +279,14 @@  discard block
 block discarded – undo
279 279
 				 *
280 280
 				 * @param array
281 281
 				 */
282
-				$email_preview_data = apply_filters( "give_{$email_type}_email_preview_data", array() );
282
+				$email_preview_data = apply_filters("give_{$email_type}_email_preview_data", array());
283 283
 
284 284
 				/**
285 285
 				 * Fire the give_{$email_type}_email_preview action
286 286
 				 *
287 287
 				 * @since 2.0
288 288
 				 */
289
-				do_action( "give_{$email_type}_email_preview", $email );
289
+				do_action("give_{$email_type}_email_preview", $email);
290 290
 
291 291
 				/**
292 292
 				 * Filter the email message
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 				 * @param array                   $email_preview_data
298 298
 				 * @param Give_Email_Notification $email
299 299
 				 */
300
-				echo apply_filters( "give_{$email_type}_email_preview_message", $email_message, $email_preview_data, $email );
300
+				echo apply_filters("give_{$email_type}_email_preview_message", $email_message, $email_preview_data, $email);
301 301
 
302 302
 				exit();
303 303
 			}
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 	 *
314 314
 	 * @param Give_Email_Notification $email
315 315
 	 */
316
-	public function email_preview_header( $email ) {
316
+	public function email_preview_header($email) {
317 317
 		/**
318 318
 		 * Filter the all email preview headers.
319 319
 		 *
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 		 *
322 322
 		 * @param Give_Email_Notification $email
323 323
 		 */
324
-		$email_preview_header = apply_filters( 'give_email_preview_header', give_get_preview_email_header(), $email );
324
+		$email_preview_header = apply_filters('give_email_preview_header', give_get_preview_email_header(), $email);
325 325
 
326 326
 		echo $email_preview_header;
327 327
 	}
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * @return array
338 338
 	 */
339
-	public function email_preview_data( $email_preview_data ) {
340
-		$email_preview_data['payment_id'] = absint( give_check_variable( give_clean( $_GET ), 'isset', 0, 'preview_id' ) );
341
-		$email_preview_data['user_id']    = absint( give_check_variable( give_clean( $_GET ), 'isset', 0, 'user_id' ) );
339
+	public function email_preview_data($email_preview_data) {
340
+		$email_preview_data['payment_id'] = absint(give_check_variable(give_clean($_GET), 'isset', 0, 'preview_id'));
341
+		$email_preview_data['user_id']    = absint(give_check_variable(give_clean($_GET), 'isset', 0, 'user_id'));
342 342
 
343 343
 		return $email_preview_data;
344 344
 	}
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 	 *
355 355
 	 * @return string
356 356
 	 */
357
-	public function email_preview_message( $email_message, $email_preview_data ) {
357
+	public function email_preview_message($email_message, $email_preview_data) {
358 358
 		if (
359
-			! empty( $email_preview_data['payment_id'] )
360
-			|| ! empty( $email_preview_data['user_id'] )
359
+			! empty($email_preview_data['payment_id'])
360
+			|| ! empty($email_preview_data['user_id'])
361 361
 		) {
362
-			$email_message = give_do_email_tags( $email_message, $email_preview_data );
362
+			$email_message = give_do_email_tags($email_message, $email_preview_data);
363 363
 		}
364 364
 
365 365
 		return $email_message;
@@ -374,26 +374,26 @@  discard block
 block discarded – undo
374 374
 	 */
375 375
 	public function send_preview_email() {
376 376
 		// Bailout.
377
-		if ( ! Give_Email_Notification_Util::can_send_preview_email() ) {
377
+		if ( ! Give_Email_Notification_Util::can_send_preview_email()) {
378 378
 			return false;
379 379
 		}
380 380
 
381 381
 		// Security check.
382
-		give_validate_nonce( $_GET['_wpnonce'], 'give-send-preview-email' );
382
+		give_validate_nonce($_GET['_wpnonce'], 'give-send-preview-email');
383 383
 
384 384
 		// Get email type.
385
-		$email_type = give_check_variable( give_clean( $_GET ), 'isset', '', 'email_type' );
385
+		$email_type = give_check_variable(give_clean($_GET), 'isset', '', 'email_type');
386 386
 
387 387
 		/* @var Give_Email_Notification $email */
388
-		foreach ( $this->get_email_notifications() as $email ) {
389
-			if ( $email_type === $email->config['id'] && Give_Email_Notification_Util::is_email_preview( $email ) ) {
388
+		foreach ($this->get_email_notifications() as $email) {
389
+			if ($email_type === $email->config['id'] && Give_Email_Notification_Util::is_email_preview($email)) {
390 390
 				$email->send_preview_email();
391 391
 				break;
392 392
 			}
393 393
 		}
394 394
 
395 395
 		// Remove the test email query arg.
396
-		wp_redirect( remove_query_arg( 'give_action' ) );
396
+		wp_redirect(remove_query_arg('give_action'));
397 397
 		exit;
398 398
 	}
399 399
 
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 * @access public
406 406
 	 */
407 407
 	public function load() {
408
-		add_action( 'init', array( $this, 'init' ), -1 );
408
+		add_action('init', array($this, 'init'), -1);
409 409
 	}
410 410
 
411 411
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 		if (
421 421
 			! Give_Admin_Settings::is_saving_settings() ||
422 422
 			'emails' !== give_get_current_setting_tab() ||
423
-			! isset( $_GET['section'] )
423
+			! isset($_GET['section'])
424 424
 		) {
425 425
 			return;
426 426
 		}
@@ -428,18 +428,18 @@  discard block
 block discarded – undo
428 428
 		// Get email type.
429 429
 		$email_type = give_get_current_setting_section();
430 430
 
431
-		if ( ! empty( $_POST["{$email_type}_recipient"] ) ) {
432
-			$_POST["{$email_type}_recipient"] = array_unique( array_filter( $_POST["{$email_type}_recipient"] ) );
431
+		if ( ! empty($_POST["{$email_type}_recipient"])) {
432
+			$_POST["{$email_type}_recipient"] = array_unique(array_filter($_POST["{$email_type}_recipient"]));
433 433
 		}
434 434
 	}
435 435
 }
436 436
 
437 437
 // Helper class.
438
-require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/abstract-email-notification.php';
439
-require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-notification-util.php';
438
+require_once GIVE_PLUGIN_DIR.'includes/admin/emails/abstract-email-notification.php';
439
+require_once GIVE_PLUGIN_DIR.'includes/admin/emails/class-email-notification-util.php';
440 440
 
441 441
 // Add backward compatibility.
442
-require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/backward-compatibility.php';
442
+require_once GIVE_PLUGIN_DIR.'includes/admin/emails/backward-compatibility.php';
443 443
 
444 444
 /**
445 445
  * Initialize functionality.
Please login to merge, or discard this patch.
includes/admin/payments/class-payments-table.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 	/**
529 529
 	 * Get donor email html.
530 530
 	 *
531
-	 * @param object $payment Contains all the data of the payment.
531
+	 * @param Give_Payment $payment Contains all the data of the payment.
532 532
 	 *
533 533
 	 * @access public
534 534
 	 * @since  1.0
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 	/**
557 557
 	 * Get Row Actions
558 558
 	 *
559
-	 * @param object $payment Payment Data.
559
+	 * @param Give_Payment $payment Payment Data.
560 560
 	 *
561 561
 	 * @since 1.6
562 562
 	 *
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 	/**
678 678
 	 * Get donor html.
679 679
 	 *
680
-	 * @param object $payment Contains all the data of the payment.
680
+	 * @param Give_Payment $payment Contains all the data of the payment.
681 681
 	 *
682 682
 	 * @access public
683 683
 	 * @since  1.0
Please login to merge, or discard this patch.
Spacing   +216 added lines, -217 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load WP_List_Table if not loaded.
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
 		// Set parent defaults.
137 137
 		parent::__construct(
138 138
 			array(
139
-				'singular' => give_get_forms_label_singular(),    // Singular name of the listed records.
140
-				'plural'   => give_get_forms_label_plural(),      // Plural name of the listed records.
141
-				'ajax'     => false,                              // Does this table support ajax?
139
+				'singular' => give_get_forms_label_singular(), // Singular name of the listed records.
140
+				'plural'   => give_get_forms_label_plural(), // Plural name of the listed records.
141
+				'ajax'     => false, // Does this table support ajax?
142 142
 			)
143 143
 		);
144 144
 
145 145
 		$this->process_bulk_action();
146 146
 		$this->get_payment_counts();
147
-		$this->base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' );
147
+		$this->base_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history');
148 148
 	}
149 149
 
150 150
 	/**
@@ -153,31 +153,31 @@  discard block
 block discarded – undo
153 153
 	 * @return void
154 154
 	 */
155 155
 	public function advanced_filters() {
156
-		$start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null;
157
-		$end_date   = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : null;
158
-		$status     = isset( $_GET['status'] ) ? sanitize_text_field( $_GET['status'] ) : '';
159
-		$donor      = isset( $_GET['donor'] ) ? sanitize_text_field( $_GET['donor'] ) : '';
160
-		$search     = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
161
-		$form_id    = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0;
156
+		$start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null;
157
+		$end_date   = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : null;
158
+		$status     = isset($_GET['status']) ? sanitize_text_field($_GET['status']) : '';
159
+		$donor      = isset($_GET['donor']) ? sanitize_text_field($_GET['donor']) : '';
160
+		$search     = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : '';
161
+		$form_id    = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : 0;
162 162
 		?>
163 163
 		<div id="give-payment-filters" class="give-filters">
164
-			<?php $this->search_box( __( 'Search', 'give' ), 'give-payments' ); ?>
164
+			<?php $this->search_box(__('Search', 'give'), 'give-payments'); ?>
165 165
 			<div id="give-payment-date-filters">
166 166
 				<div class="give-filter give-filter-half">
167 167
 					<label for="start-date"
168
-					       class="give-start-date-label"><?php _e( 'Start Date', 'give' ); ?></label>
168
+					       class="give-start-date-label"><?php _e('Start Date', 'give'); ?></label>
169 169
 					<input type="text" id="start-date" name="start-date" class="give_datepicker"
170 170
 					       value="<?php echo $start_date; ?>" placeholder="mm/dd/yyyy"/>
171 171
 				</div>
172 172
 				<div class="give-filter give-filter-half">
173
-					<label for="end-date" class="give-end-date-label"><?php _e( 'End Date', 'give' ); ?></label>
173
+					<label for="end-date" class="give-end-date-label"><?php _e('End Date', 'give'); ?></label>
174 174
 					<input type="text" id="end-date" name="end-date" class="give_datepicker"
175 175
 					       value="<?php echo $end_date; ?>" placeholder="mm/dd/yyyy"/>
176 176
 				</div>
177 177
 			</div>
178 178
 			<div id="give-payment-form-filter" class="give-filter">
179 179
 				<label for="give-donation-forms-filter"
180
-				       class="give-donation-forms-filter-label"><?php _e( 'Form', 'give' ); ?></label>
180
+				       class="give-donation-forms-filter-label"><?php _e('Form', 'give'); ?></label>
181 181
 				<?php
182 182
 				// Filter Donations by Donation Forms.
183 183
 				echo Give()->html->forms_dropdown(
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 						'class'    => 'give-donation-forms-filter',
188 188
 						'selected' => $form_id, // Make sure to have $form_id set to 0, if there is no selection.
189 189
 						'chosen'   => true,
190
-						'number'   => - 1,
190
+						'number'   => -1,
191 191
 					)
192 192
 				);
193 193
 				?>
@@ -199,21 +199,21 @@  discard block
 block discarded – undo
199 199
 			 *
200 200
 			 * @since 1.8.18
201 201
 			 */
202
-			do_action( 'give_payment_table_advanced_filters' );
202
+			do_action('give_payment_table_advanced_filters');
203 203
 			?>
204 204
 
205
-			<?php if ( ! empty( $status ) ) : ?>
206
-				<input type="hidden" name="status" value="<?php echo esc_attr( $status ); ?>"/>
205
+			<?php if ( ! empty($status)) : ?>
206
+				<input type="hidden" name="status" value="<?php echo esc_attr($status); ?>"/>
207 207
 			<?php endif; ?>
208 208
 
209 209
 			<div class="give-filter">
210
-				<?php submit_button( __( 'Apply', 'give' ), 'secondary', '', false ); ?>
210
+				<?php submit_button(__('Apply', 'give'), 'secondary', '', false); ?>
211 211
 				<?php
212 212
 				// Clear active filters button.
213
-				if ( ! empty( $start_date ) || ! empty( $end_date ) || ! empty( $donor ) || ! empty( $search ) || ! empty( $status ) || ! empty( $form_id ) ) :
213
+				if ( ! empty($start_date) || ! empty($end_date) || ! empty($donor) || ! empty($search) || ! empty($status) || ! empty($form_id)) :
214 214
 					?>
215
-					<a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"
216
-					   class="button give-clear-filters-button"><?php _e( 'Clear Filters', 'give' ); ?></a>
215
+					<a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"
216
+					   class="button give-clear-filters-button"><?php _e('Clear Filters', 'give'); ?></a>
217 217
 				<?php endif; ?>
218 218
 			</div>
219 219
 		</div>
@@ -232,18 +232,18 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @return void
234 234
 	 */
235
-	public function search_box( $text, $input_id ) {
236
-		if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
235
+	public function search_box($text, $input_id) {
236
+		if (empty($_REQUEST['s']) && ! $this->has_items()) {
237 237
 			return;
238 238
 		}
239 239
 
240
-		$input_id = $input_id . '-search-input';
240
+		$input_id = $input_id.'-search-input';
241 241
 
242
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
243
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
242
+		if ( ! empty($_REQUEST['orderby'])) {
243
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
244 244
 		}
245
-		if ( ! empty( $_REQUEST['order'] ) ) {
246
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
245
+		if ( ! empty($_REQUEST['order'])) {
246
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
247 247
 		}
248 248
 		?>
249 249
 		<div class="give-filter give-filter-search" role="search">
@@ -255,13 +255,13 @@  discard block
 block discarded – undo
255 255
 			 *
256 256
 			 * @since 1.7
257 257
 			 */
258
-			do_action( 'give_payment_history_search' );
258
+			do_action('give_payment_history_search');
259 259
 			?>
260 260
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
261 261
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
262
-			<?php submit_button( $text, 'button', false, false, array(
262
+			<?php submit_button($text, 'button', false, false, array(
263 263
 				'ID' => 'search-submit',
264
-			) ); ?><br/>
264
+			)); ?><br/>
265 265
 		</div>
266 266
 		<?php
267 267
 	}
@@ -276,48 +276,48 @@  discard block
 block discarded – undo
276 276
 	 */
277 277
 	public function get_views() {
278 278
 
279
-		$current = isset( $_GET['status'] ) ? $_GET['status'] : '';
279
+		$current = isset($_GET['status']) ? $_GET['status'] : '';
280 280
 		$views   = array();
281 281
 		$tabs    = array(
282 282
 			'all'         => array(
283 283
 				'total_count',
284
-				__( 'All', 'give' ),
284
+				__('All', 'give'),
285 285
 			),
286 286
 			'publish'     => array(
287 287
 				'complete_count',
288
-				__( 'Completed', 'give' ),
288
+				__('Completed', 'give'),
289 289
 			),
290 290
 			'pending'     => array(
291 291
 				'pending_count',
292
-				__( 'Pending', 'give' ),
292
+				__('Pending', 'give'),
293 293
 			),
294 294
 			'processing'  => array(
295 295
 				'processing_count',
296
-				__( 'Processing', 'give' ),
296
+				__('Processing', 'give'),
297 297
 			),
298 298
 			'refunded'    => array(
299 299
 				'refunded_count',
300
-				__( 'Refunded', 'give' ),
300
+				__('Refunded', 'give'),
301 301
 			),
302 302
 			'revoked'     => array(
303 303
 				'revoked_count',
304
-				__( 'Revoked', 'give' ),
304
+				__('Revoked', 'give'),
305 305
 			),
306 306
 			'failed'      => array(
307 307
 				'failed_count',
308
-				__( 'Failed', 'give' ),
308
+				__('Failed', 'give'),
309 309
 			),
310 310
 			'cancelled'   => array(
311 311
 				'cancelled_count',
312
-				__( 'Cancelled', 'give' ),
312
+				__('Cancelled', 'give'),
313 313
 			),
314 314
 			'abandoned'   => array(
315 315
 				'abandoned_count',
316
-				__( 'Abandoned', 'give' ),
316
+				__('Abandoned', 'give'),
317 317
 			),
318 318
 			'preapproval' => array(
319 319
 				'preapproval_count',
320
-				__( 'Preapproval Pending', 'give' ),
320
+				__('Preapproval Pending', 'give'),
321 321
 			),
322 322
 		);
323 323
 
@@ -326,12 +326,12 @@  discard block
 block discarded – undo
326 326
 		 *
327 327
 		 * @since 1.8.18
328 328
 		 */
329
-		$args = (array) apply_filters( 'give_payments_table_status_remove_query_arg', array( 'paged', '_wpnonce', '_wp_http_referer' ) );
329
+		$args = (array) apply_filters('give_payments_table_status_remove_query_arg', array('paged', '_wpnonce', '_wp_http_referer'));
330 330
 
331 331
 		// Build URL.
332
-		$staus_url = remove_query_arg( $args );
332
+		$staus_url = remove_query_arg($args);
333 333
 
334
-		foreach ( $tabs as $key => $tab ) {
334
+		foreach ($tabs as $key => $tab) {
335 335
 			$count_key = $tab[0];
336 336
 			$name      = $tab[1];
337 337
 			$count     = $this->$count_key;
@@ -346,16 +346,15 @@  discard block
 block discarded – undo
346 346
 			 *
347 347
 			 * @since 1.8.12
348 348
 			 */
349
-			if ( 'all' === $key || $key === $current || apply_filters( 'give_payments_table_show_all_status', 0 < $count, $key, $count ) ) {
349
+			if ('all' === $key || $key === $current || apply_filters('give_payments_table_show_all_status', 0 < $count, $key, $count)) {
350 350
 
351 351
 				$staus_url = 'all' === $key ?
352
-					add_query_arg( array( 'status' => false ), $staus_url ) :
353
-					add_query_arg( array( 'status' => $key ), $staus_url );
352
+					add_query_arg(array('status' => false), $staus_url) : add_query_arg(array('status' => $key), $staus_url);
354 353
 
355
-				$views[ $key ] = sprintf(
354
+				$views[$key] = sprintf(
356 355
 					'<a href="%s"%s>%s&nbsp;<span class="count">(%s)</span></a>',
357
-					esc_url( $staus_url ),
358
-					( ( 'all' === $key && empty( $current ) ) ) ? ' class="current"' : ( $current == $key ? 'class="current"' : '' ),
356
+					esc_url($staus_url),
357
+					(('all' === $key && empty($current))) ? ' class="current"' : ($current == $key ? 'class="current"' : ''),
359 358
 					$name,
360 359
 					$count
361 360
 				);
@@ -370,7 +369,7 @@  discard block
 block discarded – undo
370 369
 		 * @param array $views
371 370
 		 * @param Give_Payment_History_Table
372 371
 		 */
373
-		return apply_filters( 'give_payments_table_views', $views, $this );
372
+		return apply_filters('give_payments_table_views', $views, $this);
374 373
 	}
375 374
 
376 375
 	/**
@@ -384,18 +383,18 @@  discard block
 block discarded – undo
384 383
 	public function get_columns() {
385 384
 		$columns = array(
386 385
 			'cb'            => '<input type="checkbox" />', // Render a checkbox instead of text.
387
-			'donation'      => __( 'Donation', 'give' ),
388
-			'donation_form' => __( 'Donation Form', 'give' ),
389
-			'status'        => __( 'Status', 'give' ),
390
-			'date'          => __( 'Date', 'give' ),
391
-			'amount'        => __( 'Amount', 'give' ),
386
+			'donation'      => __('Donation', 'give'),
387
+			'donation_form' => __('Donation Form', 'give'),
388
+			'status'        => __('Status', 'give'),
389
+			'date'          => __('Date', 'give'),
390
+			'amount'        => __('Amount', 'give'),
392 391
 		);
393 392
 
394
-		if ( current_user_can( 'view_give_payments' ) ) {
395
-			$columns['details'] = __( 'Details', 'give' );
393
+		if (current_user_can('view_give_payments')) {
394
+			$columns['details'] = __('Details', 'give');
396 395
 		}
397 396
 
398
-		return apply_filters( 'give_payments_table_columns', $columns );
397
+		return apply_filters('give_payments_table_columns', $columns);
399 398
 	}
400 399
 
401 400
 	/**
@@ -408,14 +407,14 @@  discard block
 block discarded – undo
408 407
 	 */
409 408
 	public function get_sortable_columns() {
410 409
 		$columns = array(
411
-			'donation'      => array( 'ID', true ),
412
-			'donation_form' => array( 'donation_form', false ),
413
-			'status'        => array( 'status', false ),
414
-			'amount'        => array( 'amount', false ),
415
-			'date'          => array( 'date', false ),
410
+			'donation'      => array('ID', true),
411
+			'donation_form' => array('donation_form', false),
412
+			'status'        => array('status', false),
413
+			'amount'        => array('amount', false),
414
+			'date'          => array('date', false),
416 415
 		);
417 416
 
418
-		return apply_filters( 'give_payments_table_sortable_columns', $columns );
417
+		return apply_filters('give_payments_table_sortable_columns', $columns);
419 418
 	}
420 419
 
421 420
 	/**
@@ -441,43 +440,43 @@  discard block
 block discarded – undo
441 440
 	 *
442 441
 	 * @return string Column Name
443 442
 	 */
444
-	public function column_default( $payment, $column_name ) {
443
+	public function column_default($payment, $column_name) {
445 444
 
446
-		$single_donation_url = esc_url( add_query_arg( 'id', $payment->ID, admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details' ) ) );
447
-		$row_actions         = $this->get_row_actions( $payment );
445
+		$single_donation_url = esc_url(add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details')));
446
+		$row_actions         = $this->get_row_actions($payment);
448 447
 		$value               = '';
449 448
 
450
-		switch ( $column_name ) {
449
+		switch ($column_name) {
451 450
 			case 'donation' :
452
-				if ( current_user_can( 'view_give_payments' ) ) {
453
-					$value = Give()->tooltips->render_link( array(
454
-						'label'       => sprintf( __( 'View Donation #%s', 'give' ), $payment->ID ),
451
+				if (current_user_can('view_give_payments')) {
452
+					$value = Give()->tooltips->render_link(array(
453
+						'label'       => sprintf(__('View Donation #%s', 'give'), $payment->ID),
455 454
 						'tag_content' => "#$payment->ID",
456 455
 						'link'        => $single_donation_url,
457
-					) );
456
+					));
458 457
 				} else {
459 458
 					$value = "#{$payment->ID}";
460 459
 				}
461 460
 
462 461
 				$value .= sprintf(
463 462
 					'&nbsp;%1$s&nbsp;%2$s<br>',
464
-					__( 'by', 'give' ),
465
-					$this->get_donor( $payment )
463
+					__('by', 'give'),
464
+					$this->get_donor($payment)
466 465
 				);
467 466
 
468
-				$value .= $this->get_donor_email( $payment );
469
-				$value .= $this->row_actions( $row_actions );
467
+				$value .= $this->get_donor_email($payment);
468
+				$value .= $this->row_actions($row_actions);
470 469
 				break;
471 470
 
472 471
 			case 'amount':
473
-				$amount = ! empty( $payment->total ) ? $payment->total : 0;
474
-				$value  = give_donation_amount( $payment, true );
475
-				$value .= sprintf( '<br><small>%1$s %2$s</small>', __( 'via', 'give' ), give_get_gateway_admin_label( $payment->gateway ) );
472
+				$amount = ! empty($payment->total) ? $payment->total : 0;
473
+				$value  = give_donation_amount($payment, true);
474
+				$value .= sprintf('<br><small>%1$s %2$s</small>', __('via', 'give'), give_get_gateway_admin_label($payment->gateway));
476 475
 				break;
477 476
 
478 477
 			case 'donation_form':
479
-				$form_title = empty( $payment->form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $payment->form_id ) : $payment->form_title;
480
-				$value      = '<a href="' . admin_url( 'post.php?post=' . $payment->form_id . '&action=edit' ) . '">' . $form_title . '</a>';
478
+				$form_title = empty($payment->form_title) ? sprintf(__('Untitled (#%s)', 'give'), $payment->form_id) : $payment->form_title;
479
+				$value      = '<a href="'.admin_url('post.php?post='.$payment->form_id.'&action=edit').'">'.$form_title.'</a>';
481 480
 				$level      = give_get_donation_form_title(
482 481
 					$payment,
483 482
 					array(
@@ -485,44 +484,44 @@  discard block
 block discarded – undo
485 484
 					)
486 485
 				);
487 486
 
488
-				if ( ! empty( $level ) ) {
487
+				if ( ! empty($level)) {
489 488
 					$value .= $level;
490 489
 				}
491 490
 
492 491
 				break;
493 492
 
494 493
 			case 'date':
495
-				$date  = strtotime( $payment->date );
496
-				$value = date_i18n( give_date_format(), $date );
494
+				$date  = strtotime($payment->date);
495
+				$value = date_i18n(give_date_format(), $date);
497 496
 				break;
498 497
 
499 498
 			case 'status':
500
-				$value = $this->get_payment_status( $payment );
499
+				$value = $this->get_payment_status($payment);
501 500
 				break;
502 501
 
503 502
 
504 503
 			case 'details' :
505
-				if ( current_user_can( 'view_give_payments' ) ) {
506
-					$value = Give()->tooltips->render_link( array(
507
-						'label'       => sprintf( __( 'View Donation #%s', 'give' ), $payment->ID ),
504
+				if (current_user_can('view_give_payments')) {
505
+					$value = Give()->tooltips->render_link(array(
506
+						'label'       => sprintf(__('View Donation #%s', 'give'), $payment->ID),
508 507
 						'tag_content' => '<span class="dashicons dashicons-visibility"></span>',
509 508
 						'link'        => $single_donation_url,
510 509
 						'attributes'  => array(
511 510
 							'class' => 'give-payment-details-link button button-small',
512 511
 						),
513
-					) );
512
+					));
514 513
 
515 514
 					$value = "<div class=\"give-payment-details-link-wrap\">{$value}</div>";
516 515
 				}
517 516
 				break;
518 517
 
519 518
 			default:
520
-				$value = isset( $payment->$column_name ) ? $payment->$column_name : '';
519
+				$value = isset($payment->$column_name) ? $payment->$column_name : '';
521 520
 				break;
522 521
 
523 522
 		}// End switch().
524 523
 
525
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, $column_name );
524
+		return apply_filters('give_payments_table_column', $value, $payment->ID, $column_name);
526 525
 	}
527 526
 
528 527
 	/**
@@ -535,22 +534,22 @@  discard block
 block discarded – undo
535 534
 	 *
536 535
 	 * @return string Data shown in the Email column
537 536
 	 */
538
-	public function get_donor_email( $payment ) {
537
+	public function get_donor_email($payment) {
539 538
 
540
-		$email = give_get_payment_user_email( $payment->ID );
539
+		$email = give_get_payment_user_email($payment->ID);
541 540
 
542
-		if ( empty( $email ) ) {
543
-			$email = __( '(unknown)', 'give' );
541
+		if (empty($email)) {
542
+			$email = __('(unknown)', 'give');
544 543
 		}
545 544
 
546 545
 
547
-		$value = Give()->tooltips->render_link( array(
546
+		$value = Give()->tooltips->render_link(array(
548 547
 			'link'        => "mailto:{$email}",
549
-			'label'       => __( 'Email donor', 'give' ),
548
+			'label'       => __('Email donor', 'give'),
550 549
 			'tag_content' => $email,
551
-		) );
550
+		));
552 551
 
553
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'email' );
552
+		return apply_filters('give_payments_table_column', $value, $payment->ID, 'email');
554 553
 	}
555 554
 
556 555
 	/**
@@ -562,18 +561,18 @@  discard block
 block discarded – undo
562 561
 	 *
563 562
 	 * @return array $actions
564 563
 	 */
565
-	function get_row_actions( $payment ) {
564
+	function get_row_actions($payment) {
566 565
 
567 566
 		$actions = array();
568
-		$email   = give_get_payment_user_email( $payment->ID );
567
+		$email   = give_get_payment_user_email($payment->ID);
569 568
 
570 569
 		// Add search term string back to base URL.
571
-		$search_terms = ( isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '' );
572
-		if ( ! empty( $search_terms ) ) {
573
-			$this->base_url = add_query_arg( 's', $search_terms, $this->base_url );
570
+		$search_terms = (isset($_GET['s']) ? trim($_GET['s']) : '');
571
+		if ( ! empty($search_terms)) {
572
+			$this->base_url = add_query_arg('s', $search_terms, $this->base_url);
574 573
 		}
575 574
 
576
-		if ( give_is_payment_complete( $payment->ID ) && ! empty( $email ) ) {
575
+		if (give_is_payment_complete($payment->ID) && ! empty($email)) {
577 576
 
578 577
 			$actions['email_links'] = sprintf(
579 578
 				'<a class="resend-single-donation-receipt" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url(
@@ -583,12 +582,12 @@  discard block
 block discarded – undo
583 582
 						'purchase_id' => $payment->ID,
584 583
 					), $this->base_url
585 584
 				), 'give_payment_nonce'
586
-			), sprintf( __( 'Resend Donation %s Receipt', 'give' ), $payment->ID ), __( 'Resend Receipt', 'give' )
585
+			), sprintf(__('Resend Donation %s Receipt', 'give'), $payment->ID), __('Resend Receipt', 'give')
587 586
 			);
588 587
 
589 588
 		}
590 589
 
591
-		if ( current_user_can( 'view_give_payments' ) ) {
590
+		if (current_user_can('view_give_payments')) {
592 591
 			$actions['delete'] = sprintf(
593 592
 				'<a class="delete-single-donation" href="%1$s" aria-label="%2$s">%3$s</a>',
594 593
 				wp_nonce_url(
@@ -598,11 +597,11 @@  discard block
 block discarded – undo
598 597
 							'purchase_id' => $payment->ID,
599 598
 						), $this->base_url
600 599
 					), 'give_donation_nonce'
601
-				), sprintf( __( 'Delete Donation %s', 'give' ), $payment->ID ), __( 'Delete', 'give' )
600
+				), sprintf(__('Delete Donation %s', 'give'), $payment->ID), __('Delete', 'give')
602 601
 			);
603 602
 		}
604 603
 
605
-		return apply_filters( 'give_payment_row_actions', $actions, $payment );
604
+		return apply_filters('give_payment_row_actions', $actions, $payment);
606 605
 	}
607 606
 
608 607
 
@@ -616,30 +615,30 @@  discard block
 block discarded – undo
616 615
 	 *
617 616
 	 * @return string Data shown in the Email column
618 617
 	 */
619
-	function get_payment_status( $payment ) {
618
+	function get_payment_status($payment) {
620 619
 		$value = sprintf(
621 620
 			'<div class="give-donation-status status-%1$s"><span class="give-donation-status-icon"></span>&nbsp;%2$s</div>',
622
-			sanitize_title( give_get_payment_status( $payment, true ) ),
623
-			give_get_payment_status( $payment, true )
621
+			sanitize_title(give_get_payment_status($payment, true)),
622
+			give_get_payment_status($payment, true)
624 623
 		);
625 624
 
626
-		if ( $payment->mode == 'test' ) {
627
-			$value .= Give()->tooltips->render_span( array(
628
-				'label'       => __( 'This donation was made in test mode.', 'give' ),
629
-				'tag_content' => __( 'Test', 'give' ),
625
+		if ($payment->mode == 'test') {
626
+			$value .= Give()->tooltips->render_span(array(
627
+				'label'       => __('This donation was made in test mode.', 'give'),
628
+				'tag_content' => __('Test', 'give'),
630 629
 				'attributes'  => array(
631 630
 					'class' => 'give-item-label give-item-label-orange give-test-mode-transactions-label',
632 631
 				),
633 632
 
634 633
 
635
-			) );
634
+			));
636 635
 		}
637 636
 
638
-		if ( true === $payment->import && true === (bool) apply_filters( 'give_payment_show_importer_label', false ) ) {
637
+		if (true === $payment->import && true === (bool) apply_filters('give_payment_show_importer_label', false)) {
639 638
 			$value .= sprintf(
640 639
 				'&nbsp;<span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="%1$s">%2$s</span>',
641
-				__( 'This donation was imported.', 'give' ),
642
-				__( 'Import', 'give' )
640
+				__('This donation was imported.', 'give'),
641
+				__('Import', 'give')
643 642
 			);
644 643
 		}
645 644
 
@@ -656,8 +655,8 @@  discard block
 block discarded – undo
656 655
 	 *
657 656
 	 * @return string Displays a checkbox.
658 657
 	 */
659
-	public function column_cb( $payment ) {
660
-		return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID );
658
+	public function column_cb($payment) {
659
+		return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID);
661 660
 	}
662 661
 
663 662
 	/**
@@ -670,8 +669,8 @@  discard block
 block discarded – undo
670 669
 	 *
671 670
 	 * @return string Displays a checkbox.
672 671
 	 */
673
-	public function get_payment_id( $payment ) {
674
-		return '<span class="give-payment-id">' . give_get_payment_number( $payment->ID ) . '</span>';
672
+	public function get_payment_id($payment) {
673
+		return '<span class="give-payment-id">'.give_get_payment_number($payment->ID).'</span>';
675 674
 	}
676 675
 
677 676
 	/**
@@ -684,32 +683,32 @@  discard block
 block discarded – undo
684 683
 	 *
685 684
 	 * @return string Data shown in the User column
686 685
 	 */
687
-	public function get_donor( $payment ) {
686
+	public function get_donor($payment) {
688 687
 
689
-		$donor_id           = give_get_payment_donor_id( $payment->ID );
690
-		$donor_billing_name = give_get_donor_name_by( $payment->ID, 'donation' );
691
-		$donor_name         = give_get_donor_name_by( $donor_id, 'donor' );
688
+		$donor_id           = give_get_payment_donor_id($payment->ID);
689
+		$donor_billing_name = give_get_donor_name_by($payment->ID, 'donation');
690
+		$donor_name         = give_get_donor_name_by($donor_id, 'donor');
692 691
 
693 692
 		$value = '';
694
-		if ( ! empty( $donor_id ) ) {
693
+		if ( ! empty($donor_id)) {
695 694
 
696 695
 			// Check whether the donor name and WP_User name is same or not.
697
-			if ( sanitize_title( $donor_billing_name ) !== sanitize_title( $donor_name ) ) {
698
-				$value .= $donor_billing_name . ' (';
696
+			if (sanitize_title($donor_billing_name) !== sanitize_title($donor_name)) {
697
+				$value .= $donor_billing_name.' (';
699 698
 			}
700 699
 
701
-			$value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id" ) ) . '">' . $donor_name . '</a>';
700
+			$value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id")).'">'.$donor_name.'</a>';
702 701
 
703 702
 			// Check whether the donor name and WP_User name is same or not.
704
-			if ( sanitize_title( $donor_billing_name ) != sanitize_title( $donor_name ) ) {
703
+			if (sanitize_title($donor_billing_name) != sanitize_title($donor_name)) {
705 704
 				$value .= ')';
706 705
 			}
707 706
 		} else {
708
-			$email  = give_get_payment_user_email( $payment->ID );
709
-			$value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-payment-history&s=$email" ) ) . '">' . __( '(donor missing)', 'give' ) . '</a>';
707
+			$email  = give_get_payment_user_email($payment->ID);
708
+			$value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-payment-history&s=$email")).'">'.__('(donor missing)', 'give').'</a>';
710 709
 		}
711 710
 
712
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'donor' );
711
+		return apply_filters('give_payments_table_column', $value, $payment->ID, 'donor');
713 712
 	}
714 713
 
715 714
 	/**
@@ -722,20 +721,20 @@  discard block
 block discarded – undo
722 721
 	 */
723 722
 	public function get_bulk_actions() {
724 723
 		$actions = array(
725
-			'delete'                 => __( 'Delete', 'give' ),
726
-			'set-status-publish'     => __( 'Set To Completed', 'give' ),
727
-			'set-status-pending'     => __( 'Set To Pending', 'give' ),
728
-			'set-status-processing'  => __( 'Set To Processing', 'give' ),
729
-			'set-status-refunded'    => __( 'Set To Refunded', 'give' ),
730
-			'set-status-revoked'     => __( 'Set To Revoked', 'give' ),
731
-			'set-status-failed'      => __( 'Set To Failed', 'give' ),
732
-			'set-status-cancelled'   => __( 'Set To Cancelled', 'give' ),
733
-			'set-status-abandoned'   => __( 'Set To Abandoned', 'give' ),
734
-			'set-status-preapproval' => __( 'Set To Preapproval', 'give' ),
735
-			'resend-receipt'         => __( 'Resend Email Receipts', 'give' ),
724
+			'delete'                 => __('Delete', 'give'),
725
+			'set-status-publish'     => __('Set To Completed', 'give'),
726
+			'set-status-pending'     => __('Set To Pending', 'give'),
727
+			'set-status-processing'  => __('Set To Processing', 'give'),
728
+			'set-status-refunded'    => __('Set To Refunded', 'give'),
729
+			'set-status-revoked'     => __('Set To Revoked', 'give'),
730
+			'set-status-failed'      => __('Set To Failed', 'give'),
731
+			'set-status-cancelled'   => __('Set To Cancelled', 'give'),
732
+			'set-status-abandoned'   => __('Set To Abandoned', 'give'),
733
+			'set-status-preapproval' => __('Set To Preapproval', 'give'),
734
+			'resend-receipt'         => __('Resend Email Receipts', 'give'),
736 735
 		);
737 736
 
738
-		return apply_filters( 'give_payments_table_bulk_actions', $actions );
737
+		return apply_filters('give_payments_table_bulk_actions', $actions);
739 738
 	}
740 739
 
741 740
 	/**
@@ -747,59 +746,59 @@  discard block
 block discarded – undo
747 746
 	 * @return void
748 747
 	 */
749 748
 	public function process_bulk_action() {
750
-		$ids    = isset( $_GET['payment'] ) ? $_GET['payment'] : false;
749
+		$ids    = isset($_GET['payment']) ? $_GET['payment'] : false;
751 750
 		$action = $this->current_action();
752 751
 
753
-		if ( ! is_array( $ids ) ) {
754
-			$ids = array( $ids );
752
+		if ( ! is_array($ids)) {
753
+			$ids = array($ids);
755 754
 		}
756 755
 
757
-		if ( empty( $action ) ) {
756
+		if (empty($action)) {
758 757
 			return;
759 758
 		}
760 759
 
761
-		foreach ( $ids as $id ) {
760
+		foreach ($ids as $id) {
762 761
 
763 762
 			// Detect when a bulk action is being triggered.
764
-			switch ( $this->current_action() ) {
763
+			switch ($this->current_action()) {
765 764
 
766 765
 				case 'delete':
767
-					give_delete_donation( $id );
766
+					give_delete_donation($id);
768 767
 					break;
769 768
 
770 769
 				case 'set-status-publish':
771
-					give_update_payment_status( $id, 'publish' );
770
+					give_update_payment_status($id, 'publish');
772 771
 					break;
773 772
 
774 773
 				case 'set-status-pending':
775
-					give_update_payment_status( $id, 'pending' );
774
+					give_update_payment_status($id, 'pending');
776 775
 					break;
777 776
 
778 777
 				case 'set-status-processing':
779
-					give_update_payment_status( $id, 'processing' );
778
+					give_update_payment_status($id, 'processing');
780 779
 					break;
781 780
 
782 781
 				case 'set-status-refunded':
783
-					give_update_payment_status( $id, 'refunded' );
782
+					give_update_payment_status($id, 'refunded');
784 783
 					break;
785 784
 				case 'set-status-revoked':
786
-					give_update_payment_status( $id, 'revoked' );
785
+					give_update_payment_status($id, 'revoked');
787 786
 					break;
788 787
 
789 788
 				case 'set-status-failed':
790
-					give_update_payment_status( $id, 'failed' );
789
+					give_update_payment_status($id, 'failed');
791 790
 					break;
792 791
 
793 792
 				case 'set-status-cancelled':
794
-					give_update_payment_status( $id, 'cancelled' );
793
+					give_update_payment_status($id, 'cancelled');
795 794
 					break;
796 795
 
797 796
 				case 'set-status-abandoned':
798
-					give_update_payment_status( $id, 'abandoned' );
797
+					give_update_payment_status($id, 'abandoned');
799 798
 					break;
800 799
 
801 800
 				case 'set-status-preapproval':
802
-					give_update_payment_status( $id, 'preapproval' );
801
+					give_update_payment_status($id, 'preapproval');
803 802
 					break;
804 803
 
805 804
 				case 'resend-receipt':
@@ -808,7 +807,7 @@  discard block
 block discarded – undo
808 807
 					 *
809 808
 					 * @since 2.0
810 809
 					 */
811
-					do_action( 'give_donation-receipt_email_notification', $id );
810
+					do_action('give_donation-receipt_email_notification', $id);
812 811
 					break;
813 812
 			}// End switch().
814 813
 
@@ -820,7 +819,7 @@  discard block
 block discarded – undo
820 819
 			 *
821 820
 			 * @since 1.7
822 821
 			 */
823
-			do_action( 'give_payments_table_do_bulk_action', $id, $this->current_action() );
822
+			do_action('give_payments_table_do_bulk_action', $id, $this->current_action());
824 823
 		}// End foreach().
825 824
 
826 825
 	}
@@ -837,32 +836,32 @@  discard block
 block discarded – undo
837 836
 
838 837
 		$args = array();
839 838
 
840
-		if ( isset( $_GET['user'] ) ) {
841
-			$args['user'] = urldecode( $_GET['user'] );
842
-		} elseif ( isset( $_GET['donor'] ) ) {
843
-			$args['donor'] = absint( $_GET['donor'] );
844
-		} elseif ( isset( $_GET['s'] ) ) {
845
-			$is_user = strpos( $_GET['s'], strtolower( 'user:' ) ) !== false;
846
-			if ( $is_user ) {
847
-				$args['user'] = absint( trim( str_replace( 'user:', '', strtolower( $_GET['s'] ) ) ) );
848
-				unset( $args['s'] );
839
+		if (isset($_GET['user'])) {
840
+			$args['user'] = urldecode($_GET['user']);
841
+		} elseif (isset($_GET['donor'])) {
842
+			$args['donor'] = absint($_GET['donor']);
843
+		} elseif (isset($_GET['s'])) {
844
+			$is_user = strpos($_GET['s'], strtolower('user:')) !== false;
845
+			if ($is_user) {
846
+				$args['user'] = absint(trim(str_replace('user:', '', strtolower($_GET['s']))));
847
+				unset($args['s']);
849 848
 			} else {
850
-				$args['s'] = sanitize_text_field( $_GET['s'] );
849
+				$args['s'] = sanitize_text_field($_GET['s']);
851 850
 			}
852 851
 		}
853 852
 
854
-		if ( ! empty( $_GET['start-date'] ) ) {
855
-			$args['start-date'] = urldecode( $_GET['start-date'] );
853
+		if ( ! empty($_GET['start-date'])) {
854
+			$args['start-date'] = urldecode($_GET['start-date']);
856 855
 		}
857 856
 
858
-		if ( ! empty( $_GET['end-date'] ) ) {
859
-			$args['end-date'] = urldecode( $_GET['end-date'] );
857
+		if ( ! empty($_GET['end-date'])) {
858
+			$args['end-date'] = urldecode($_GET['end-date']);
860 859
 		}
861 860
 
862
-		$args['form_id'] = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null;
863
-		$args['gateway'] = ! empty( $_GET['gateway'] ) ? give_clean( $_GET['gateway'] ) : null;
861
+		$args['form_id'] = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null;
862
+		$args['gateway'] = ! empty($_GET['gateway']) ? give_clean($_GET['gateway']) : null;
864 863
 
865
-		$payment_count           = give_count_payments( $args );
864
+		$payment_count           = give_count_payments($args);
866 865
 		$this->complete_count    = $payment_count->publish;
867 866
 		$this->pending_count     = $payment_count->pending;
868 867
 		$this->processing_count  = $payment_count->processing;
@@ -873,7 +872,7 @@  discard block
 block discarded – undo
873 872
 		$this->abandoned_count   = $payment_count->abandoned;
874 873
 		$this->preapproval_count = $payment_count->preapproval;
875 874
 
876
-		foreach ( $payment_count as $count ) {
875
+		foreach ($payment_count as $count) {
877 876
 			$this->total_count += $count;
878 877
 		}
879 878
 
@@ -891,25 +890,25 @@  discard block
 block discarded – undo
891 890
 	public function payments_data() {
892 891
 
893 892
 		$per_page   = $this->per_page;
894
-		$orderby    = isset( $_GET['orderby'] ) ? urldecode( $_GET['orderby'] ) : 'ID';
895
-		$order      = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC';
896
-		$user       = isset( $_GET['user'] ) ? $_GET['user'] : null;
897
-		$donor      = isset( $_GET['donor'] ) ? $_GET['donor'] : null;
898
-		$status     = isset( $_GET['status'] ) ? $_GET['status'] : give_get_payment_status_keys();
899
-		$meta_key   = isset( $_GET['meta_key'] ) ? $_GET['meta_key'] : null;
900
-		$year       = isset( $_GET['year'] ) ? $_GET['year'] : null;
901
-		$month      = isset( $_GET['m'] ) ? $_GET['m'] : null;
902
-		$day        = isset( $_GET['day'] ) ? $_GET['day'] : null;
903
-		$search     = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null;
904
-		$start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null;
905
-		$end_date   = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : $start_date;
906
-		$form_id    = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null;
907
-		$gateway    = ! empty( $_GET['gateway'] ) ? give_clean( $_GET['gateway'] ) : null;
893
+		$orderby    = isset($_GET['orderby']) ? urldecode($_GET['orderby']) : 'ID';
894
+		$order      = isset($_GET['order']) ? $_GET['order'] : 'DESC';
895
+		$user       = isset($_GET['user']) ? $_GET['user'] : null;
896
+		$donor      = isset($_GET['donor']) ? $_GET['donor'] : null;
897
+		$status     = isset($_GET['status']) ? $_GET['status'] : give_get_payment_status_keys();
898
+		$meta_key   = isset($_GET['meta_key']) ? $_GET['meta_key'] : null;
899
+		$year       = isset($_GET['year']) ? $_GET['year'] : null;
900
+		$month      = isset($_GET['m']) ? $_GET['m'] : null;
901
+		$day        = isset($_GET['day']) ? $_GET['day'] : null;
902
+		$search     = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null;
903
+		$start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null;
904
+		$end_date   = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : $start_date;
905
+		$form_id    = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null;
906
+		$gateway    = ! empty($_GET['gateway']) ? give_clean($_GET['gateway']) : null;
908 907
 
909 908
 		$args = array(
910 909
 			'output'     => 'payments',
911 910
 			'number'     => $per_page,
912
-			'page'       => isset( $_GET['paged'] ) ? $_GET['paged'] : null,
911
+			'page'       => isset($_GET['paged']) ? $_GET['paged'] : null,
913 912
 			'orderby'    => $orderby,
914 913
 			'order'      => $order,
915 914
 			'user'       => $user,
@@ -926,9 +925,9 @@  discard block
 block discarded – undo
926 925
 			'give_forms' => $form_id,
927 926
 		);
928 927
 
929
-		if ( is_string( $search ) && false !== strpos( $search, 'txn:' ) ) {
928
+		if (is_string($search) && false !== strpos($search, 'txn:')) {
930 929
 			$args['search_in_notes'] = true;
931
-			$args['s']               = trim( str_replace( 'txn:', '', $args['s'] ) );
930
+			$args['s']               = trim(str_replace('txn:', '', $args['s']));
932 931
 		}
933 932
 
934 933
 		/**
@@ -936,9 +935,9 @@  discard block
 block discarded – undo
936 935
 		 *
937 936
 		 * @since 1.8.18
938 937
 		 */
939
-		$args = (array) apply_filters( 'give_payment_table_payments_query', $args );
938
+		$args = (array) apply_filters('give_payment_table_payments_query', $args);
940 939
 
941
-		$p_query = new Give_Payments_Query( $args );
940
+		$p_query = new Give_Payments_Query($args);
942 941
 
943 942
 		return $p_query->get_payments();
944 943
 
@@ -959,17 +958,17 @@  discard block
 block discarded – undo
959 958
 	 */
960 959
 	public function prepare_items() {
961 960
 
962
-		wp_reset_vars( array( 'action', 'payment', 'orderby', 'order', 's' ) );
961
+		wp_reset_vars(array('action', 'payment', 'orderby', 'order', 's'));
963 962
 
964 963
 		$columns  = $this->get_columns();
965 964
 		$hidden   = array(); // No hidden columns.
966 965
 		$sortable = $this->get_sortable_columns();
967 966
 		$data     = $this->payments_data();
968
-		$status   = isset( $_GET['status'] ) ? $_GET['status'] : 'any';
967
+		$status   = isset($_GET['status']) ? $_GET['status'] : 'any';
969 968
 
970
-		$this->_column_headers = array( $columns, $hidden, $sortable );
969
+		$this->_column_headers = array($columns, $hidden, $sortable);
971 970
 
972
-		switch ( $status ) {
971
+		switch ($status) {
973 972
 			case 'publish':
974 973
 				$total_items = $this->complete_count;
975 974
 				break;
@@ -1002,8 +1001,8 @@  discard block
 block discarded – undo
1002 1001
 				break;
1003 1002
 			default:
1004 1003
 				// Retrieve the count of the non-default-Give status.
1005
-				$count       = wp_count_posts( 'give_payment' );
1006
-				$total_items = isset( $count->{$status} ) ? $count->{$status} : 0;
1004
+				$count       = wp_count_posts('give_payment');
1005
+				$total_items = isset($count->{$status} ) ? $count->{$status} : 0;
1007 1006
 				break;
1008 1007
 		}
1009 1008
 
@@ -1014,7 +1013,7 @@  discard block
 block discarded – undo
1014 1013
 		 *
1015 1014
 		 * @since 1.8.19
1016 1015
 		 */
1017
-		$total_items = (int) apply_filters( 'give_payment_table_pagination_total_count', $total_items, $this );
1016
+		$total_items = (int) apply_filters('give_payment_table_pagination_total_count', $total_items, $this);
1018 1017
 
1019 1018
 		$this->set_pagination_args(
1020 1019
 			array(
@@ -1022,7 +1021,7 @@  discard block
 block discarded – undo
1022 1021
 				// We have to calculate the total number of items.
1023 1022
 				'per_page'    => $this->per_page,
1024 1023
 				// We have to determine how many items to show on a page.
1025
-				'total_pages' => ceil( $total_items / $this->per_page ),
1024
+				'total_pages' => ceil($total_items / $this->per_page),
1026 1025
 				// We have to calculate the total number of pages.
1027 1026
 			)
1028 1027
 		);
Please login to merge, or discard this patch.
includes/admin/tools/logs/class-api-requests-logs-list-table.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -187,7 +187,7 @@
 block discarded – undo
187 187
 	 * @access public
188 188
 	 * @since  1.0
189 189
 	 *
190
-	 * @return string|bool String if search is present, false otherwise
190
+	 * @return string|false String if search is present, false otherwise
191 191
 	 */
192 192
 	public function get_search() {
193 193
 		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 		global $status, $page;
46 46
 
47 47
 		// Set parent defaults
48
-		parent::__construct( array(
49
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
50
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
51
-			'ajax'     => false,// Does this table support ajax?
52
-		) );
48
+		parent::__construct(array(
49
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
50
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
51
+			'ajax'     => false, // Does this table support ajax?
52
+		));
53 53
 	}
54 54
 
55 55
 	/**
@@ -63,20 +63,20 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @return void
65 65
 	 */
66
-	public function search_box( $text, $input_id ) {
67
-		$input_id = $input_id . '-search-input';
66
+	public function search_box($text, $input_id) {
67
+		$input_id = $input_id.'-search-input';
68 68
 
69
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
70
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
69
+		if ( ! empty($_REQUEST['orderby'])) {
70
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
71 71
 		}
72
-		if ( ! empty( $_REQUEST['order'] ) ) {
73
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
72
+		if ( ! empty($_REQUEST['order'])) {
73
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
74 74
 		}
75 75
 		?>
76 76
 		<p class="search-box" role="search">
77 77
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
78 78
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
79
-			<?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?>
79
+			<?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?>
80 80
 		</p>
81 81
 		<?php
82 82
 	}
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function get_columns() {
93 93
 		$columns = array(
94
-			'ID'      => __( 'Log ID', 'give' ),
95
-			'ip'      => __( 'Request IP', 'give' ),
96
-			'date'    => __( 'Date', 'give' ),
97
-			'details' => __( 'Request Details', 'give' ),
94
+			'ID'      => __('Log ID', 'give'),
95
+			'ip'      => __('Request IP', 'give'),
96
+			'date'    => __('Date', 'give'),
97
+			'details' => __('Request Details', 'give'),
98 98
 		);
99 99
 
100 100
 		return $columns;
@@ -111,10 +111,10 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @return string Column Name
113 113
 	 */
114
-	public function column_default( $item, $column_name ) {
115
-		switch ( $column_name ) {
114
+	public function column_default($item, $column_name) {
115
+		switch ($column_name) {
116 116
 			default:
117
-				return esc_attr( $item[ $column_name ] );
117
+				return esc_attr($item[$column_name]);
118 118
 		}
119 119
 	}
120 120
 
@@ -128,52 +128,52 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @return void
130 130
 	 */
131
-	public function column_details( $item ) {
132
-		echo Give()->tooltips->render_link( array(
133
-			'label'       => __( 'View Request', 'give' ),
131
+	public function column_details($item) {
132
+		echo Give()->tooltips->render_link(array(
133
+			'label'       => __('View Request', 'give'),
134 134
 			'tag_content' => '<span class="dashicons dashicons-visibility"></span>',
135 135
 			'link'        => "#TB_inline?width=640&amp;inlineId=log-details-{$item['ID']}",
136 136
 			'attributes'  => array(
137 137
 				'class' => 'thickbox give-error-log-details-link button button-small',
138 138
 			),
139
-		) );
139
+		));
140 140
 		?>
141 141
 		<div id="log-details-<?php echo $item['ID']; ?>" style="display:none;">
142 142
 			<?php
143 143
 			// Print API Request.
144 144
 			echo sprintf(
145 145
 				'<p><strong>%1$s</strong></p><div>%2$s</div>',
146
-				__( 'API Request:', 'give' ),
147
-				Give()->logs->logmeta_db->get_meta( $item['ID'], '_give_log_api_query', true )
146
+				__('API Request:', 'give'),
147
+				Give()->logs->logmeta_db->get_meta($item['ID'], '_give_log_api_query', true)
148 148
 			);
149 149
 
150 150
 			// Print Log Content, if not empty.
151
-			if ( ! empty( $item['log_content'] ) ) {
151
+			if ( ! empty($item['log_content'])) {
152 152
 				echo sprintf(
153 153
 					'<p><strong>%1$s</strong></p><div>%2$s</div>',
154
-					__( 'Error', 'give' ),
155
-					esc_html( $item['log_content'] )
154
+					__('Error', 'give'),
155
+					esc_html($item['log_content'])
156 156
 				);
157 157
 			}
158 158
 
159 159
 			// Print User who requested data using API.
160 160
 			echo sprintf(
161 161
 				'<p><strong>%1$s</strong></p><div>%2$s</div>',
162
-				__( 'API User:', 'give' ),
163
-				Give()->logs->logmeta_db->get_meta( $item['ID'], '_give_log_user', true )
162
+				__('API User:', 'give'),
163
+				Give()->logs->logmeta_db->get_meta($item['ID'], '_give_log_user', true)
164 164
 			);
165 165
 
166 166
 			// Print the logged key used by API.
167 167
 			echo sprintf(
168 168
 				'<p><strong>%1$s</strong></p><div>%2$s</div>',
169
-				__( 'API Key:', 'give' ),
170
-				Give()->logs->logmeta_db->get_meta( $item['ID'], '_give_log_key', true )
169
+				__('API Key:', 'give'),
170
+				Give()->logs->logmeta_db->get_meta($item['ID'], '_give_log_key', true)
171 171
 			);
172 172
 
173 173
 			// Print the API Request Date.
174 174
 			echo sprintf(
175 175
 				'<p><strong>%1$s</strong></p><div>%2$s</div>',
176
-				__( 'Request Date:', 'give' ),
176
+				__('Request Date:', 'give'),
177 177
 				$item['log_date']
178 178
 			);
179 179
 			?>
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @return string|bool String if search is present, false otherwise
191 191
 	 */
192 192
 	public function get_search() {
193
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
193
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
194 194
 	}
195 195
 
196 196
 
@@ -206,19 +206,19 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @param string $which
208 208
 	 */
209
-	protected function display_tablenav( $which ) {
210
-		if ( 'top' === $which ) {
211
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
209
+	protected function display_tablenav($which) {
210
+		if ('top' === $which) {
211
+			wp_nonce_field('bulk-'.$this->_args['plural']);
212 212
 		}
213 213
 		?>
214
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
214
+		<div class="tablenav <?php echo esc_attr($which); ?>">
215 215
 
216 216
 			<div class="alignleft actions bulkactions">
217
-				<?php $this->bulk_actions( $which ); ?>
217
+				<?php $this->bulk_actions($which); ?>
218 218
 			</div>
219 219
 			<?php
220
-			$this->extra_tablenav( $which );
221
-			$this->pagination( $which );
220
+			$this->extra_tablenav($which);
221
+			$this->pagination($which);
222 222
 			?>
223 223
 
224 224
 			<br class="clear"/>
@@ -241,40 +241,40 @@  discard block
 block discarded – undo
241 241
 		$meta_query = array();
242 242
 		$search     = $this->get_search();
243 243
 
244
-		if ( $search ) {
245
-			if ( filter_var( $search, FILTER_VALIDATE_IP ) ) {
244
+		if ($search) {
245
+			if (filter_var($search, FILTER_VALIDATE_IP)) {
246 246
 
247 247
 				// This is an IP address search.
248 248
 				$key = '_give_log_request_ip';
249 249
 
250
-			} elseif ( is_email( $search ) ) {
250
+			} elseif (is_email($search)) {
251 251
 
252 252
 				// This is an email search.
253
-				$userdata = get_user_by( 'email', $search );
253
+				$userdata = get_user_by('email', $search);
254 254
 
255
-				if ( $userdata ) {
255
+				if ($userdata) {
256 256
 					$search = $userdata->ID;
257 257
 				}
258 258
 
259 259
 				$key = '_give_log_user';
260 260
 
261
-			} elseif ( 32 === strlen( $search ) ) {
261
+			} elseif (32 === strlen($search)) {
262 262
 
263 263
 				// Look for an API key.
264 264
 				$key = '_give_log_key';
265 265
 
266
-			} elseif ( stristr( $search, 'token:' ) ) {
266
+			} elseif (stristr($search, 'token:')) {
267 267
 
268 268
 				// Look for an API token.
269
-				$search = str_ireplace( 'token:', '', $search );
269
+				$search = str_ireplace('token:', '', $search);
270 270
 				$key    = '_give_log_token';
271 271
 
272 272
 			} else {
273 273
 
274 274
 				// This is (probably) a user ID search.
275
-				$userdata = get_userdata( $search );
275
+				$userdata = get_userdata($search);
276 276
 
277
-				if ( $userdata ) {
277
+				if ($userdata) {
278 278
 					$search = $userdata->ID;
279 279
 				}
280 280
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	 * @return int Current page number
303 303
 	 */
304 304
 	public function get_paged() {
305
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
305
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
306 306
 	}
307 307
 
308 308
 	/**
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 *
316 316
 	 * @return void
317 317
 	 */
318
-	function bulk_actions( $which = '' ) {
318
+	function bulk_actions($which = '') {
319 319
 		give_log_views();
320 320
 	}
321 321
 
@@ -337,14 +337,14 @@  discard block
 block discarded – undo
337 337
 			'posts_per_page' => $this->per_page,
338 338
 		);
339 339
 
340
-		$logs = Give()->logs->get_connected_logs( $log_query );
340
+		$logs = Give()->logs->get_connected_logs($log_query);
341 341
 
342
-		if ( $logs ) {
343
-			foreach ( $logs as $log ) {
342
+		if ($logs) {
343
+			foreach ($logs as $log) {
344 344
 
345 345
 				$logs_data[] = array(
346 346
 					'ID'          => $log->ID,
347
-					'ip'          => Give()->logs->logmeta_db->get_meta( $log->ID, '_give_log_request_ip', true ),
347
+					'ip'          => Give()->logs->logmeta_db->get_meta($log->ID, '_give_log_request_ip', true),
348 348
 					'date'        => $log->log_date,
349 349
 					'log_content' => $log->log_content,
350 350
 					'log_date'    => $log->log_date,
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
 		$columns               = $this->get_columns();
373 373
 		$hidden                = array(); // No hidden columns
374 374
 		$sortable              = $this->get_sortable_columns();
375
-		$this->_column_headers = array( $columns, $hidden, $sortable );
375
+		$this->_column_headers = array($columns, $hidden, $sortable);
376 376
 		$this->items           = $this->get_logs();
377
-		$total_items           = Give()->logs->get_log_count( 0, 'api_request' );
377
+		$total_items           = Give()->logs->get_log_count(0, 'api_request');
378 378
 
379
-		$this->set_pagination_args( array(
379
+		$this->set_pagination_args(array(
380 380
 				'total_items' => $total_items,
381 381
 				'per_page'    => $this->per_page,
382
-				'total_pages' => ceil( $total_items / $this->per_page ),
382
+				'total_pages' => ceil($total_items / $this->per_page),
383 383
 			)
384 384
 		);
385 385
 	}
Please login to merge, or discard this patch.
includes/class-give-cache.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @param  string $cache_key
123 123
 	 * @param  bool   $custom_key
124
-	 * @param  mixed  $query_args
124
+	 * @param  string  $query_args
125 125
 	 *
126 126
 	 * @return mixed
127 127
 	 */
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @param bool  $force If set to true then all cached values will be delete instead of only expired
239 239
 	 *
240
-	 * @return bool
240
+	 * @return false|null
241 241
 	 */
242 242
 	public static function delete_all_expired( $force = false ) {
243 243
 		global $wpdb;
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 	 * @since  2.0
670 670
 	 * @access private
671 671
 	 *
672
-	 * @param $group
672
+	 * @param string $group
673 673
 	 *
674 674
 	 * @return mixed
675 675
 	 */
Please login to merge, or discard this patch.
Spacing   +125 added lines, -125 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
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * @return static
54 54
 	 */
55 55
 	public static function get_instance() {
56
-		if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give_Cache ) ) {
56
+		if ( ! isset(self::$instance) && ! (self::$instance instanceof Give_Cache)) {
57 57
 			self::$instance = new Give_Cache();
58 58
 		}
59 59
 
@@ -68,17 +68,17 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function setup() {
70 70
 		// Currently enable cache only for backend.
71
-		self::$instance->is_cache = give_is_setting_enabled( give_get_option( 'cache', 'enabled' ) ) && is_admin();
71
+		self::$instance->is_cache = give_is_setting_enabled(give_get_option('cache', 'enabled')) && is_admin();
72 72
 
73 73
 		// weekly delete all expired cache.
74
-		Give_Cron::add_weekly_event( array( $this, 'delete_all_expired' ) );
74
+		Give_Cron::add_weekly_event(array($this, 'delete_all_expired'));
75 75
 
76
-		add_action( 'save_post_give_forms', array( $this, 'delete_form_related_cache' ) );
77
-		add_action( 'save_post_give_payment', array( $this, 'delete_payment_related_cache' ) );
78
-		add_action( 'give_deleted_give-donors_cache', array( $this, 'delete_donor_related_cache' ), 10, 3 );
79
-		add_action( 'give_deleted_give-donations_cache', array( $this, 'delete_donations_related_cache' ), 10, 3 );
76
+		add_action('save_post_give_forms', array($this, 'delete_form_related_cache'));
77
+		add_action('save_post_give_payment', array($this, 'delete_payment_related_cache'));
78
+		add_action('give_deleted_give-donors_cache', array($this, 'delete_donor_related_cache'), 10, 3);
79
+		add_action('give_deleted_give-donations_cache', array($this, 'delete_donations_related_cache'), 10, 3);
80 80
 
81
-		add_action( 'give_save_settings_give_settings', array( $this, 'flush_cache' ) );
81
+		add_action('give_save_settings_give_settings', array($this, 'flush_cache'));
82 82
 	}
83 83
 
84 84
 	/**
@@ -92,18 +92,18 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return string
94 94
 	 */
95
-	public static function get_key( $action, $query_args = null, $is_prefix = true ) {
95
+	public static function get_key($action, $query_args = null, $is_prefix = true) {
96 96
 		// Bailout.
97
-		if ( empty( $action ) ) {
98
-			return new WP_Error( 'give_invalid_cache_key_action', __( 'Do not pass empty action to generate cache key.', 'give' ) );
97
+		if (empty($action)) {
98
+			return new WP_Error('give_invalid_cache_key_action', __('Do not pass empty action to generate cache key.', 'give'));
99 99
 		}
100 100
 
101 101
 		// Set cache key.
102 102
 		$cache_key = $is_prefix ? "give_cache_{$action}" : $action;
103 103
 
104 104
 		// Bailout.
105
-		if ( ! empty( $query_args ) ) {
106
-			$cache_key = "{$cache_key}_" . substr( md5( serialize( $query_args ) ), 0, 15 );
105
+		if ( ! empty($query_args)) {
106
+			$cache_key = "{$cache_key}_".substr(md5(serialize($query_args)), 0, 15);
107 107
 		}
108 108
 
109 109
 		/**
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		 *
112 112
 		 * @since 2.0
113 113
 		 */
114
-		return apply_filters( 'give_get_cache_key', $cache_key, $action, $query_args );
114
+		return apply_filters('give_get_cache_key', $cache_key, $action, $query_args);
115 115
 	}
116 116
 
117 117
 	/**
@@ -125,26 +125,26 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @return mixed
127 127
 	 */
128
-	public static function get( $cache_key, $custom_key = false, $query_args = array() ) {
129
-		if ( ! self::is_valid_cache_key( $cache_key ) ) {
130
-			if ( ! $custom_key ) {
131
-				return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) );
128
+	public static function get($cache_key, $custom_key = false, $query_args = array()) {
129
+		if ( ! self::is_valid_cache_key($cache_key)) {
130
+			if ( ! $custom_key) {
131
+				return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give'));
132 132
 			}
133 133
 
134
-			$cache_key = self::get_key( $cache_key, $query_args );
134
+			$cache_key = self::get_key($cache_key, $query_args);
135 135
 		}
136 136
 
137
-		$option = get_option( $cache_key );
137
+		$option = get_option($cache_key);
138 138
 
139 139
 		// Backward compatibility (<1.8.7).
140
-		if ( ! is_array( $option ) || empty( $option ) || ! array_key_exists( 'expiration', $option ) ) {
140
+		if ( ! is_array($option) || empty($option) || ! array_key_exists('expiration', $option)) {
141 141
 			return $option;
142 142
 		}
143 143
 
144 144
 		// Get current time.
145
-		$current_time = current_time( 'timestamp', 1 );
145
+		$current_time = current_time('timestamp', 1);
146 146
 
147
-		if ( empty( $option['expiration'] ) || ( $current_time < $option['expiration'] ) ) {
147
+		if (empty($option['expiration']) || ($current_time < $option['expiration'])) {
148 148
 			$option = $option['data'];
149 149
 		} else {
150 150
 			$option = false;
@@ -166,23 +166,23 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @return mixed
168 168
 	 */
169
-	public static function set( $cache_key, $data, $expiration = null, $custom_key = false, $query_args = array() ) {
170
-		if ( ! self::is_valid_cache_key( $cache_key ) ) {
171
-			if ( ! $custom_key ) {
172
-				return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) );
169
+	public static function set($cache_key, $data, $expiration = null, $custom_key = false, $query_args = array()) {
170
+		if ( ! self::is_valid_cache_key($cache_key)) {
171
+			if ( ! $custom_key) {
172
+				return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give'));
173 173
 			}
174 174
 
175
-			$cache_key = self::get_key( $cache_key, $query_args );
175
+			$cache_key = self::get_key($cache_key, $query_args);
176 176
 		}
177 177
 
178 178
 		$option_value = array(
179 179
 			'data'       => $data,
180
-			'expiration' => ! is_null( $expiration )
181
-				? ( $expiration + current_time( 'timestamp', 1 ) )
180
+			'expiration' => ! is_null($expiration)
181
+				? ($expiration + current_time('timestamp', 1))
182 182
 				: null,
183 183
 		);
184 184
 
185
-		$result = update_option( $cache_key, $option_value, 'no' );
185
+		$result = update_option($cache_key, $option_value, 'no');
186 186
 
187 187
 		return $result;
188 188
 	}
@@ -198,27 +198,27 @@  discard block
 block discarded – undo
198 198
 	 *
199 199
 	 * @return bool|WP_Error
200 200
 	 */
201
-	public static function delete( $cache_keys ) {
201
+	public static function delete($cache_keys) {
202 202
 		$result       = true;
203 203
 		$invalid_keys = array();
204 204
 
205
-		if ( ! empty( $cache_keys ) ) {
206
-			$cache_keys = is_array( $cache_keys ) ? $cache_keys : array( $cache_keys );
205
+		if ( ! empty($cache_keys)) {
206
+			$cache_keys = is_array($cache_keys) ? $cache_keys : array($cache_keys);
207 207
 
208
-			foreach ( $cache_keys as $cache_key ) {
209
-				if ( ! self::is_valid_cache_key( $cache_key ) ) {
208
+			foreach ($cache_keys as $cache_key) {
209
+				if ( ! self::is_valid_cache_key($cache_key)) {
210 210
 					$invalid_keys[] = $cache_key;
211 211
 					$result         = false;
212 212
 				}
213 213
 
214
-				delete_option( $cache_key );
214
+				delete_option($cache_key);
215 215
 			}
216 216
 		}
217 217
 
218
-		if ( ! $result ) {
218
+		if ( ! $result) {
219 219
 			$result = new WP_Error(
220 220
 				'give_invalid_cache_key',
221
-				__( 'Cache key format should be give_cache_*', 'give' ),
221
+				__('Cache key format should be give_cache_*', 'give'),
222 222
 				$invalid_keys
223 223
 			);
224 224
 		}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 *
240 240
 	 * @return bool
241 241
 	 */
242
-	public static function delete_all_expired( $force = false ) {
242
+	public static function delete_all_expired($force = false) {
243 243
 		global $wpdb;
244 244
 		$options = $wpdb->get_results(
245 245
 			$wpdb->prepare(
@@ -253,30 +253,30 @@  discard block
 block discarded – undo
253 253
 		);
254 254
 
255 255
 		// Bailout.
256
-		if ( empty( $options ) ) {
256
+		if (empty($options)) {
257 257
 			return false;
258 258
 		}
259 259
 
260
-		$current_time = current_time( 'timestamp', 1 );
260
+		$current_time = current_time('timestamp', 1);
261 261
 
262 262
 		// Delete log cache.
263
-		foreach ( $options as $option ) {
264
-			$option['option_value'] = maybe_unserialize( $option['option_value'] );
263
+		foreach ($options as $option) {
264
+			$option['option_value'] = maybe_unserialize($option['option_value']);
265 265
 
266 266
 			if (
267 267
 				(
268
-					! self::is_valid_cache_key( $option['option_name'] )
269
-					|| ! is_array( $option['option_value'] ) // Backward compatibility (<1.8.7).
270
-					|| ! array_key_exists( 'expiration', $option['option_value'] ) // Backward compatibility (<1.8.7).
271
-					|| empty( $option['option_value']['expiration'] )
272
-					|| ( $current_time < $option['option_value']['expiration'] )
268
+					! self::is_valid_cache_key($option['option_name'])
269
+					|| ! is_array($option['option_value']) // Backward compatibility (<1.8.7).
270
+					|| ! array_key_exists('expiration', $option['option_value']) // Backward compatibility (<1.8.7).
271
+					|| empty($option['option_value']['expiration'])
272
+					|| ($current_time < $option['option_value']['expiration'])
273 273
 				)
274 274
 				&& ! $force
275 275
 			) {
276 276
 				continue;
277 277
 			}
278 278
 
279
-			self::delete( $option['option_name'] );
279
+			self::delete($option['option_name']);
280 280
 		}
281 281
 	}
282 282
 
@@ -294,16 +294,16 @@  discard block
 block discarded – undo
294 294
 	 *
295 295
 	 * @return array
296 296
 	 */
297
-	public static function get_options_like( $option_name, $fields = false ) {
297
+	public static function get_options_like($option_name, $fields = false) {
298 298
 		global $wpdb;
299 299
 
300
-		if ( empty( $option_name ) ) {
300
+		if (empty($option_name)) {
301 301
 			return array();
302 302
 		}
303 303
 
304 304
 		$field_names = $fields ? 'option_name, option_value' : 'option_name';
305 305
 
306
-		if ( $fields ) {
306
+		if ($fields) {
307 307
 			$options = $wpdb->get_results(
308 308
 				$wpdb->prepare(
309 309
 					"SELECT {$field_names }
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 			);
328 328
 		}
329 329
 
330
-		if ( ! empty( $options ) && $fields ) {
331
-			foreach ( $options as $index => $option ) {
332
-				$option['option_value'] = maybe_unserialize( $option['option_value'] );
333
-				$options[ $index ]      = $option;
330
+		if ( ! empty($options) && $fields) {
331
+			foreach ($options as $index => $option) {
332
+				$option['option_value'] = maybe_unserialize($option['option_value']);
333
+				$options[$index]      = $option;
334 334
 			}
335 335
 		}
336 336
 
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @return bool
349 349
 	 */
350
-	public static function is_valid_cache_key( $cache_key ) {
351
-		$is_valid = ( false !== strpos( $cache_key, 'give_cache_' ) );
350
+	public static function is_valid_cache_key($cache_key) {
351
+		$is_valid = (false !== strpos($cache_key, 'give_cache_'));
352 352
 
353 353
 
354 354
 		/**
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 		 *
357 357
 		 * @since 2.0
358 358
 		 */
359
-		return apply_filters( 'give_is_valid_cache_key', $is_valid, $cache_key );
359
+		return apply_filters('give_is_valid_cache_key', $is_valid, $cache_key);
360 360
 	}
361 361
 
362 362
 
@@ -371,14 +371,14 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return mixed
373 373
 	 */
374
-	public static function get_group( $id, $group = '' ) {
374
+	public static function get_group($id, $group = '') {
375 375
 		$cached_data = null;
376 376
 
377 377
 		// Bailout.
378
-		if ( self::$instance->is_cache && ! empty( $id ) ) {
379
-			$group = self::$instance->filter_group_name( $group );
378
+		if (self::$instance->is_cache && ! empty($id)) {
379
+			$group = self::$instance->filter_group_name($group);
380 380
 
381
-			$cached_data = wp_cache_get( $id, $group );
381
+			$cached_data = wp_cache_get($id, $group);
382 382
 			$cached_data = false !== $cached_data ? $cached_data : null;
383 383
 		}
384 384
 
@@ -398,17 +398,17 @@  discard block
 block discarded – undo
398 398
 	 *
399 399
 	 * @return bool
400 400
 	 */
401
-	public static function set_group( $id, $data, $group = '', $expire = 0 ) {
401
+	public static function set_group($id, $data, $group = '', $expire = 0) {
402 402
 		$status = false;
403 403
 
404 404
 		// Bailout.
405
-		if ( ! self::$instance->is_cache || empty( $id ) ) {
405
+		if ( ! self::$instance->is_cache || empty($id)) {
406 406
 			return $status;
407 407
 		}
408 408
 
409
-		$group = self::$instance->filter_group_name( $group );
409
+		$group = self::$instance->filter_group_name($group);
410 410
 
411
-		$status = wp_cache_set( $id, $data, $group, $expire );
411
+		$status = wp_cache_set($id, $data, $group, $expire);
412 412
 
413 413
 		return $status;
414 414
 	}
@@ -424,15 +424,15 @@  discard block
 block discarded – undo
424 424
 	 *
425 425
 	 * @return bool
426 426
 	 */
427
-	public static function set_db_query( $id, $data ) {
427
+	public static function set_db_query($id, $data) {
428 428
 		$status = false;
429 429
 
430 430
 		// Bailout.
431
-		if ( ! self::$instance->is_cache || empty( $id ) ) {
431
+		if ( ! self::$instance->is_cache || empty($id)) {
432 432
 			return $status;
433 433
 		}
434 434
 
435
-		return self::set_group( $id, $data, 'give-db-queries', 0 );
435
+		return self::set_group($id, $data, 'give-db-queries', 0);
436 436
 	}
437 437
 
438 438
 	/**
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 	 *
446 446
 	 * @return mixed
447 447
 	 */
448
-	public static function get_db_query( $id ) {
449
-		return self::get_group( $id, 'give-db-queries' );
448
+	public static function get_db_query($id) {
449
+		return self::get_group($id, 'give-db-queries');
450 450
 	}
451 451
 
452 452
 	/**
@@ -461,20 +461,20 @@  discard block
 block discarded – undo
461 461
 	 *
462 462
 	 * @return bool
463 463
 	 */
464
-	public static function delete_group( $ids, $group = '', $expire = 0 ) {
464
+	public static function delete_group($ids, $group = '', $expire = 0) {
465 465
 		$status = false;
466 466
 
467 467
 		// Bailout.
468
-		if ( ! self::$instance->is_cache || empty( $ids ) ) {
468
+		if ( ! self::$instance->is_cache || empty($ids)) {
469 469
 			return $status;
470 470
 		}
471 471
 
472
-		$group = self::$instance->filter_group_name( $group );
472
+		$group = self::$instance->filter_group_name($group);
473 473
 
474 474
 		// Delete single or multiple cache items from cache.
475
-		if ( ! is_array( $ids ) ) {
476
-			$status = wp_cache_delete( $ids, $group, $expire );
477
-			self::$instance->get_incrementer( true );
475
+		if ( ! is_array($ids)) {
476
+			$status = wp_cache_delete($ids, $group, $expire);
477
+			self::$instance->get_incrementer(true);
478 478
 
479 479
 			/**
480 480
 			 * Fire action when cache deleted for specific id.
@@ -485,12 +485,12 @@  discard block
 block discarded – undo
485 485
 			 * @param string $group
486 486
 			 * @param int    $expire
487 487
 			 */
488
-			do_action( "give_deleted_{$group}_cache", $ids, $group, $expire, $status );
488
+			do_action("give_deleted_{$group}_cache", $ids, $group, $expire, $status);
489 489
 
490 490
 		} else {
491
-			foreach ( $ids as $id ) {
492
-				$status = wp_cache_delete( $id, $group, $expire );
493
-				self::$instance->get_incrementer( true );
491
+			foreach ($ids as $id) {
492
+				$status = wp_cache_delete($id, $group, $expire);
493
+				self::$instance->get_incrementer(true);
494 494
 
495 495
 				/**
496 496
 				 * Fire action when cache deleted for specific id .
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 				 * @param string $group
502 502
 				 * @param int    $expire
503 503
 				 */
504
-				do_action( "give_deleted_{$group}_cache", $id, $group, $expire, $status );
504
+				do_action("give_deleted_{$group}_cache", $id, $group, $expire, $status);
505 505
 			}
506 506
 		}
507 507
 
@@ -518,30 +518,30 @@  discard block
 block discarded – undo
518 518
 	 *
519 519
 	 * @param int $form_id
520 520
 	 */
521
-	public function delete_form_related_cache( $form_id ) {
521
+	public function delete_form_related_cache($form_id) {
522 522
 		// If this is just a revision, don't send the email.
523
-		if ( wp_is_post_revision( $form_id ) ) {
523
+		if (wp_is_post_revision($form_id)) {
524 524
 			return;
525 525
 		}
526 526
 
527 527
 		$donation_query = new Give_Payments_Query(
528 528
 			array(
529
-				'number'     => - 1,
529
+				'number'     => -1,
530 530
 				'give_forms' => $form_id,
531 531
 			)
532 532
 		);
533 533
 
534 534
 		$donations = $donation_query->get_payments();
535 535
 
536
-		if ( ! empty( $donations ) ) {
536
+		if ( ! empty($donations)) {
537 537
 			/* @var Give_Payment $donation */
538
-			foreach ( $donations as $donation ) {
539
-				wp_cache_delete( $donation->ID, 'give-donations' );
540
-				wp_cache_delete( $donation->donor_id, 'give-donors' );
538
+			foreach ($donations as $donation) {
539
+				wp_cache_delete($donation->ID, 'give-donations');
540
+				wp_cache_delete($donation->donor_id, 'give-donors');
541 541
 			}
542 542
 		}
543 543
 
544
-		self::$instance->get_incrementer( true );
544
+		self::$instance->get_incrementer(true);
545 545
 	}
546 546
 
547 547
 	/**
@@ -553,22 +553,22 @@  discard block
 block discarded – undo
553 553
 	 *
554 554
 	 * @param int $donation_id
555 555
 	 */
556
-	public function delete_payment_related_cache( $donation_id ) {
556
+	public function delete_payment_related_cache($donation_id) {
557 557
 		// If this is just a revision, don't send the email.
558
-		if ( wp_is_post_revision( $donation_id ) ) {
558
+		if (wp_is_post_revision($donation_id)) {
559 559
 			return;
560 560
 		}
561 561
 
562 562
 		/* @var Give_Payment $donation */
563
-		$donation = new Give_Payment( $donation_id );
563
+		$donation = new Give_Payment($donation_id);
564 564
 
565
-		if ( $donation && $donation->donor_id ) {
566
-			wp_cache_delete( $donation->donor_id, 'give-donors' );
565
+		if ($donation && $donation->donor_id) {
566
+			wp_cache_delete($donation->donor_id, 'give-donors');
567 567
 		}
568 568
 
569
-		wp_cache_delete( $donation->ID, 'give-donations' );
569
+		wp_cache_delete($donation->ID, 'give-donations');
570 570
 
571
-		self::$instance->get_incrementer( true );
571
+		self::$instance->get_incrementer(true);
572 572
 	}
573 573
 
574 574
 	/**
@@ -582,17 +582,17 @@  discard block
 block discarded – undo
582 582
 	 * @param string $group
583 583
 	 * @param int    $expire
584 584
 	 */
585
-	public function delete_donor_related_cache( $id, $group, $expire ) {
586
-		$donor        = new Give_Donor( $id );
587
-		$donation_ids = array_map( 'trim', (array) explode( ',', trim( $donor->payment_ids ) ) );
585
+	public function delete_donor_related_cache($id, $group, $expire) {
586
+		$donor        = new Give_Donor($id);
587
+		$donation_ids = array_map('trim', (array) explode(',', trim($donor->payment_ids)));
588 588
 
589
-		if ( ! empty( $donation_ids ) ) {
590
-			foreach ( $donation_ids as $donation ) {
591
-				wp_cache_delete( $donation, 'give-donations' );
589
+		if ( ! empty($donation_ids)) {
590
+			foreach ($donation_ids as $donation) {
591
+				wp_cache_delete($donation, 'give-donations');
592 592
 			}
593 593
 		}
594 594
 
595
-		self::$instance->get_incrementer( true );
595
+		self::$instance->get_incrementer(true);
596 596
 	}
597 597
 
598 598
 	/**
@@ -606,15 +606,15 @@  discard block
 block discarded – undo
606 606
 	 * @param string $group
607 607
 	 * @param int    $expire
608 608
 	 */
609
-	public function delete_donations_related_cache( $id, $group, $expire ) {
609
+	public function delete_donations_related_cache($id, $group, $expire) {
610 610
 		/* @var Give_Payment $donation */
611
-		$donation = new Give_Payment( $id );
611
+		$donation = new Give_Payment($id);
612 612
 
613
-		if ( $donation && $donation->donor_id ) {
614
-			wp_cache_delete( $donation->donor_id, 'give-donors' );
613
+		if ($donation && $donation->donor_id) {
614
+			wp_cache_delete($donation->donor_id, 'give-donors');
615 615
 		}
616 616
 
617
-		self::$instance->get_incrementer( true );
617
+		self::$instance->get_incrementer(true);
618 618
 	}
619 619
 
620 620
 
@@ -632,12 +632,12 @@  discard block
 block discarded – undo
632 632
 	 *
633 633
 	 * @return string
634 634
 	 */
635
-	private function get_incrementer( $refresh = false, $incrementer_key = 'give-cahce-incrementer-db-queries' ) {
636
-		$incrementer_value = wp_cache_get( $incrementer_key );
635
+	private function get_incrementer($refresh = false, $incrementer_key = 'give-cahce-incrementer-db-queries') {
636
+		$incrementer_value = wp_cache_get($incrementer_key);
637 637
 
638
-		if ( false === $incrementer_value || true === $refresh ) {
639
-			$incrementer_value = microtime( true );
640
-			wp_cache_set( $incrementer_key, $incrementer_value );
638
+		if (false === $incrementer_value || true === $refresh) {
639
+			$incrementer_value = microtime(true);
640
+			wp_cache_set($incrementer_key, $incrementer_value);
641 641
 		}
642 642
 
643 643
 		return $incrementer_value;
@@ -654,11 +654,11 @@  discard block
 block discarded – undo
654 654
 	public function flush_cache() {
655 655
 		if (
656 656
 			Give_Admin_Settings::is_saving_settings() &&
657
-			isset( $_POST['cache'] ) &&
658
-			give_is_setting_enabled( give_clean( $_POST['cache'] ) )
657
+			isset($_POST['cache']) &&
658
+			give_is_setting_enabled(give_clean($_POST['cache']))
659 659
 		) {
660
-			$this->get_incrementer( true );
661
-			$this->get_incrementer( true, 'give-cahce-incrementer' );
660
+			$this->get_incrementer(true);
661
+			$this->get_incrementer(true, 'give-cahce-incrementer');
662 662
 		}
663 663
 	}
664 664
 
@@ -673,11 +673,11 @@  discard block
 block discarded – undo
673 673
 	 *
674 674
 	 * @return mixed
675 675
 	 */
676
-	private function filter_group_name( $group ) {
677
-		if ( ! empty( $group ) ) {
678
-			$incrementer = self::$instance->get_incrementer( false, 'give-cahce-incrementer' );
676
+	private function filter_group_name($group) {
677
+		if ( ! empty($group)) {
678
+			$incrementer = self::$instance->get_incrementer(false, 'give-cahce-incrementer');
679 679
 
680
-			if ( 'give-db-queries' === $group ) {
680
+			if ('give-db-queries' === $group) {
681 681
 				$incrementer = self::$instance->get_incrementer();
682 682
 			}
683 683
 
Please login to merge, or discard this patch.
includes/class-give-db-donors.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 * NOTE: This should not be called directly as it does not make necessary changes to
208 208
 	 * the payment meta and logs. Use give_donor_delete() instead.
209 209
 	 *
210
-	 * @param  bool|string|int $_id_or_email ID or Email of Donor.
210
+	 * @param  integer $_id_or_email ID or Email of Donor.
211 211
 	 *
212 212
 	 * @since  1.0
213 213
 	 * @access public
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	 * @access public
408 408
 	 *
409 409
 	 * @param  string $field ID or email. Default is 'id'.
410
-	 * @param  mixed  $value The Customer ID or email to search. Default is 0.
410
+	 * @param  integer  $value The Customer ID or email to search. Default is 0.
411 411
 	 *
412 412
 	 * @return mixed         Upon success, an object of the donor. Upon failure, NULL
413 413
 	 */
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 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
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		$this->bc_200_params();
43 43
 
44 44
 		// Set hooks and register table only if instance loading first time.
45
-		if ( ! ( Give()->donors instanceof Give_DB_Donors ) ) {
45
+		if ( ! (Give()->donors instanceof Give_DB_Donors)) {
46 46
 			// Install table.
47 47
 			$this->register_table();
48 48
 		}
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			'purchase_value'  => 0.00,
92 92
 			'purchase_count'  => 0,
93 93
 			'notes'           => '',
94
-			'date_created'    => date( 'Y-m-d H:i:s' ),
94
+			'date_created'    => date('Y-m-d H:i:s'),
95 95
 			'token'           => '',
96 96
 			'verify_key'      => '',
97 97
 			'verify_throttle' => '',
@@ -108,40 +108,40 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return int|bool
110 110
 	 */
111
-	public function add( $data = array() ) {
111
+	public function add($data = array()) {
112 112
 
113 113
 		$defaults = array(
114 114
 			'payment_ids' => '',
115 115
 		);
116 116
 
117
-		$args = wp_parse_args( $data, $defaults );
117
+		$args = wp_parse_args($data, $defaults);
118 118
 
119
-		if ( empty( $args['email'] ) ) {
119
+		if (empty($args['email'])) {
120 120
 			return false;
121 121
 		}
122 122
 
123
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
124
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
123
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
124
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
125 125
 		}
126 126
 
127
-		$donor = $this->get_donor_by( 'email', $args['email'] );
127
+		$donor = $this->get_donor_by('email', $args['email']);
128 128
 
129 129
 		// update an existing donor.
130
-		if ( $donor ) {
130
+		if ($donor) {
131 131
 
132 132
 			// Update the payment IDs attached to the donor
133
-			if ( ! empty( $args['payment_ids'] ) ) {
133
+			if ( ! empty($args['payment_ids'])) {
134 134
 
135
-				if ( empty( $donor->payment_ids ) ) {
135
+				if (empty($donor->payment_ids)) {
136 136
 
137 137
 					$donor->payment_ids = $args['payment_ids'];
138 138
 
139 139
 				} else {
140 140
 
141
-					$existing_ids       = array_map( 'absint', explode( ',', $donor->payment_ids ) );
142
-					$payment_ids        = array_map( 'absint', explode( ',', $args['payment_ids'] ) );
143
-					$payment_ids        = array_merge( $payment_ids, $existing_ids );
144
-					$donor->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
141
+					$existing_ids       = array_map('absint', explode(',', $donor->payment_ids));
142
+					$payment_ids        = array_map('absint', explode(',', $args['payment_ids']));
143
+					$payment_ids        = array_merge($payment_ids, $existing_ids);
144
+					$donor->payment_ids = implode(',', array_unique(array_values($payment_ids)));
145 145
 
146 146
 				}
147 147
 
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 
150 150
 			}
151 151
 
152
-			$this->update( $donor->id, $args );
152
+			$this->update($donor->id, $args);
153 153
 
154 154
 			return $donor->id;
155 155
 
156 156
 		} else {
157 157
 
158
-			return $this->insert( $args, 'donor' );
158
+			return $this->insert($args, 'donor');
159 159
 
160 160
 		}
161 161
 
@@ -172,12 +172,12 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return bool
174 174
 	 */
175
-	public function update( $row_id, $data = array(), $where = '' ) {
175
+	public function update($row_id, $data = array(), $where = '') {
176 176
 
177
-		$status = parent::update( $row_id, $data, $where );
177
+		$status = parent::update($row_id, $data, $where);
178 178
 
179
-		if ( $status ) {
180
-			Give_Cache::delete_group( $row_id, 'give-donors' );
179
+		if ($status) {
180
+			Give_Cache::delete_group($row_id, 'give-donors');
181 181
 		}
182 182
 
183 183
 		return $status;
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
 	 *
192 192
 	 * @return int
193 193
 	 */
194
-	public function insert( $data, $type = '' ) {
195
-		$donor_id = parent::insert( $data, $type );
194
+	public function insert($data, $type = '') {
195
+		$donor_id = parent::insert($data, $type);
196 196
 
197
-		if ( $donor_id ) {
198
-			Give_Cache::delete_group( $donor_id, 'give-donors' );
197
+		if ($donor_id) {
198
+			Give_Cache::delete_group($donor_id, 'give-donors');
199 199
 		}
200 200
 
201 201
 		return $donor_id;
@@ -214,16 +214,16 @@  discard block
 block discarded – undo
214 214
 	 *
215 215
 	 * @return bool|int
216 216
 	 */
217
-	public function delete( $_id_or_email = false ) {
217
+	public function delete($_id_or_email = false) {
218 218
 
219
-		if ( empty( $_id_or_email ) ) {
219
+		if (empty($_id_or_email)) {
220 220
 			return false;
221 221
 		}
222 222
 
223
-		$column = is_email( $_id_or_email ) ? 'email' : 'id';
224
-		$donor  = $this->get_donor_by( $column, $_id_or_email );
223
+		$column = is_email($_id_or_email) ? 'email' : 'id';
224
+		$donor  = $this->get_donor_by($column, $_id_or_email);
225 225
 
226
-		if ( $donor->id > 0 ) {
226
+		if ($donor->id > 0) {
227 227
 
228 228
 			global $wpdb;
229 229
 
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
 			 *
233 233
 			 * @since 1.8.14
234 234
 			 */
235
-			Give()->donor_meta->delete_all_meta( $donor->id );
235
+			Give()->donor_meta->delete_all_meta($donor->id);
236 236
 
237 237
 			// Cache already deleted in delete_all_meta fn.
238 238
 
239
-			return $wpdb->delete( $this->table_name, array( 'id' => $donor->id ), array( '%d' ) );
239
+			return $wpdb->delete($this->table_name, array('id' => $donor->id), array('%d'));
240 240
 
241 241
 		} else {
242 242
 			return false;
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 	 *
258 258
 	 * @return bool|int
259 259
 	 */
260
-	public function delete_by_user_id( $user_id = false ) {
260
+	public function delete_by_user_id($user_id = false) {
261 261
 		global $wpdb;
262 262
 
263
-		if ( empty( $user_id ) ) {
263
+		if (empty($user_id)) {
264 264
 			return false;
265 265
 		}
266 266
 
@@ -269,14 +269,14 @@  discard block
 block discarded – undo
269 269
 		 *
270 270
 		 * @since 1.8.14
271 271
 		 */
272
-		$donor = new Give_Donor( $user_id, true );
273
-		if ( ! empty( $donor->id ) ) {
274
-			Give()->donor_meta->delete_all_meta( $donor->id );
272
+		$donor = new Give_Donor($user_id, true);
273
+		if ( ! empty($donor->id)) {
274
+			Give()->donor_meta->delete_all_meta($donor->id);
275 275
 		}
276 276
 
277 277
 		// Cache is already deleted in delete_all_meta fn.
278 278
 
279
-		return $wpdb->delete( $this->table_name, array( 'user_id' => $user_id ), array( '%d' ) );
279
+		return $wpdb->delete($this->table_name, array('user_id' => $user_id), array('%d'));
280 280
 	}
281 281
 
282 282
 	/**
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
 	 *
291 291
 	 * @return bool          True is exists, false otherwise.
292 292
 	 */
293
-	public function exists( $value = '', $field = 'email' ) {
293
+	public function exists($value = '', $field = 'email') {
294 294
 
295 295
 		$columns = $this->get_columns();
296
-		if ( ! array_key_exists( $field, $columns ) ) {
296
+		if ( ! array_key_exists($field, $columns)) {
297 297
 			return false;
298 298
 		}
299 299
 
300
-		return (bool) $this->get_column_by( 'id', $field, $value );
300
+		return (bool) $this->get_column_by('id', $field, $value);
301 301
 
302 302
 	}
303 303
 
@@ -312,16 +312,16 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @return bool
314 314
 	 */
315
-	public function attach_payment( $donor_id = 0, $payment_id = 0 ) {
315
+	public function attach_payment($donor_id = 0, $payment_id = 0) {
316 316
 
317
-		$donor = new Give_Donor( $donor_id );
317
+		$donor = new Give_Donor($donor_id);
318 318
 
319
-		if ( empty( $donor->id ) ) {
319
+		if (empty($donor->id)) {
320 320
 			return false;
321 321
 		}
322 322
 
323 323
 		// Attach the payment, but don't increment stats, as this function previously did not
324
-		return $donor->attach_payment( $payment_id, false );
324
+		return $donor->attach_payment($payment_id, false);
325 325
 
326 326
 	}
327 327
 
@@ -336,16 +336,16 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * @return bool
338 338
 	 */
339
-	public function remove_payment( $donor_id = 0, $payment_id = 0 ) {
339
+	public function remove_payment($donor_id = 0, $payment_id = 0) {
340 340
 
341
-		$donor = new Give_Donor( $donor_id );
341
+		$donor = new Give_Donor($donor_id);
342 342
 
343
-		if ( ! $donor ) {
343
+		if ( ! $donor) {
344 344
 			return false;
345 345
 		}
346 346
 
347 347
 		// Remove the payment, but don't decrease stats, as this function previously did not
348
-		return $donor->remove_payment( $payment_id, false );
348
+		return $donor->remove_payment($payment_id, false);
349 349
 
350 350
 	}
351 351
 
@@ -359,18 +359,18 @@  discard block
 block discarded – undo
359 359
 	 *
360 360
 	 * @return bool
361 361
 	 */
362
-	public function increment_stats( $donor_id = 0, $amount = 0.00 ) {
362
+	public function increment_stats($donor_id = 0, $amount = 0.00) {
363 363
 
364
-		$donor = new Give_Donor( $donor_id );
364
+		$donor = new Give_Donor($donor_id);
365 365
 
366
-		if ( empty( $donor->id ) ) {
366
+		if (empty($donor->id)) {
367 367
 			return false;
368 368
 		}
369 369
 
370 370
 		$increased_count = $donor->increase_purchase_count();
371
-		$increased_value = $donor->increase_value( $amount );
371
+		$increased_value = $donor->increase_value($amount);
372 372
 
373
-		return ( $increased_count && $increased_value ) ? true : false;
373
+		return ($increased_count && $increased_value) ? true : false;
374 374
 
375 375
 	}
376 376
 
@@ -385,18 +385,18 @@  discard block
 block discarded – undo
385 385
 	 *
386 386
 	 * @return bool
387 387
 	 */
388
-	public function decrement_stats( $donor_id = 0, $amount = 0.00 ) {
388
+	public function decrement_stats($donor_id = 0, $amount = 0.00) {
389 389
 
390
-		$donor = new Give_Donor( $donor_id );
390
+		$donor = new Give_Donor($donor_id);
391 391
 
392
-		if ( ! $donor ) {
392
+		if ( ! $donor) {
393 393
 			return false;
394 394
 		}
395 395
 
396 396
 		$decreased_count = $donor->decrease_donation_count();
397
-		$decreased_value = $donor->decrease_value( $amount );
397
+		$decreased_value = $donor->decrease_value($amount);
398 398
 
399
-		return ( $decreased_count && $decreased_value ) ? true : false;
399
+		return ($decreased_count && $decreased_value) ? true : false;
400 400
 
401 401
 	}
402 402
 
@@ -411,44 +411,44 @@  discard block
 block discarded – undo
411 411
 	 *
412 412
 	 * @return mixed         Upon success, an object of the donor. Upon failure, NULL
413 413
 	 */
414
-	public function get_donor_by( $field = 'id', $value = 0 ) {
415
-		$value = sanitize_text_field( $value );
414
+	public function get_donor_by($field = 'id', $value = 0) {
415
+		$value = sanitize_text_field($value);
416 416
 
417 417
 		// Bailout.
418
-		if ( empty( $field ) || empty( $value ) ) {
418
+		if (empty($field) || empty($value)) {
419 419
 			return null;
420 420
 		}
421 421
 
422 422
 		// Verify values.
423
-		if ( 'id' === $field || 'user_id' === $field ) {
423
+		if ('id' === $field || 'user_id' === $field) {
424 424
 			// Make sure the value is numeric to avoid casting objects, for example,
425 425
 			// to int 1.
426
-			if ( ! is_numeric( $value ) ) {
426
+			if ( ! is_numeric($value)) {
427 427
 				return false;
428 428
 			}
429 429
 
430
-			$value = absint( $value );
430
+			$value = absint($value);
431 431
 
432
-			if ( $value < 1 ) {
432
+			if ($value < 1) {
433 433
 				return false;
434 434
 			}
435 435
 
436
-		} elseif ( 'email' === $field ) {
436
+		} elseif ('email' === $field) {
437 437
 
438
-			if ( ! is_email( $value ) ) {
438
+			if ( ! is_email($value)) {
439 439
 				return false;
440 440
 			}
441 441
 
442
-			$value = trim( $value );
442
+			$value = trim($value);
443 443
 		}
444 444
 
445 445
 		// Bailout
446
-		if ( ! $value ) {
446
+		if ( ! $value) {
447 447
 			return false;
448 448
 		}
449 449
 
450 450
 		// Set query params.
451
-		switch ( $field ) {
451
+		switch ($field) {
452 452
 			case 'id':
453 453
 				$args['donor'] = $value;
454 454
 				break;
@@ -463,9 +463,9 @@  discard block
 block discarded – undo
463 463
 		}
464 464
 
465 465
 		// Get donors.
466
-		$donor = new Give_Donors_Query( $args );
466
+		$donor = new Give_Donors_Query($args);
467 467
 
468
-		if ( ! $donor = $donor->get_donors() ) {
468
+		if ( ! $donor = $donor->get_donors()) {
469 469
 			// Look for donor from an additional email.
470 470
 			$args = array(
471 471
 				'meta_query' => array(
@@ -476,15 +476,15 @@  discard block
 block discarded – undo
476 476
 				),
477 477
 			);
478 478
 
479
-			$donor = new Give_Donors_Query( $args );
479
+			$donor = new Give_Donors_Query($args);
480 480
 			$donor = $donor->get_donors();
481 481
 
482
-			if ( empty( $donor ) ) {
482
+			if (empty($donor)) {
483 483
 				return false;
484 484
 			}
485 485
 		}
486 486
 
487
-		return current( $donor );
487
+		return current($donor);
488 488
 	}
489 489
 
490 490
 	/**
@@ -497,10 +497,10 @@  discard block
 block discarded – undo
497 497
 	 *
498 498
 	 * @return array|object|null Donors array or object. Null if not found.
499 499
 	 */
500
-	public function get_donors( $args = array() ) {
501
-		$this->bc_1814_params( $args );
500
+	public function get_donors($args = array()) {
501
+		$this->bc_1814_params($args);
502 502
 
503
-		$donors = new Give_Donors_Query( $args );
503
+		$donors = new Give_Donors_Query($args);
504 504
 
505 505
 		return $donors->get_donors();
506 506
 
@@ -517,21 +517,21 @@  discard block
 block discarded – undo
517 517
 	 *
518 518
 	 * @return int         Total number of donors.
519 519
 	 */
520
-	public function count( $args = array() ) {
521
-		$this->bc_1814_params( $args );
520
+	public function count($args = array()) {
521
+		$this->bc_1814_params($args);
522 522
 		$args['count'] = true;
523 523
 
524
-		$cache_key = md5( 'give_donors_count' . serialize( $args ) );
525
-		$count     = Give_Cache::get_group( $cache_key, 'donors' );
524
+		$cache_key = md5('give_donors_count'.serialize($args));
525
+		$count     = Give_Cache::get_group($cache_key, 'donors');
526 526
 
527
-		if ( is_null( $count ) ) {
528
-			$donors = new Give_Donors_Query( $args );
527
+		if (is_null($count)) {
528
+			$donors = new Give_Donors_Query($args);
529 529
 			$count  = $donors->get_donors();
530 530
 
531
-			Give_Cache::set_group( $cache_key, $count, 'donors', 3600 );
531
+			Give_Cache::set_group($cache_key, $count, 'donors', 3600);
532 532
 		}
533 533
 
534
-		return absint( $count );
534
+		return absint($count);
535 535
 
536 536
 	}
537 537
 
@@ -545,9 +545,9 @@  discard block
 block discarded – undo
545 545
 	 */
546 546
 	public function create_table() {
547 547
 
548
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
548
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
549 549
 
550
-		$sql = "CREATE TABLE " . $this->table_name . " (
550
+		$sql = "CREATE TABLE ".$this->table_name." (
551 551
 		id bigint(20) NOT NULL AUTO_INCREMENT,
552 552
 		user_id bigint(20) NOT NULL,
553 553
 		email varchar(50) NOT NULL,
@@ -565,9 +565,9 @@  discard block
 block discarded – undo
565 565
 		KEY user (user_id)
566 566
 		) CHARACTER SET utf8 COLLATE utf8_general_ci;";
567 567
 
568
-		dbDelta( $sql );
568
+		dbDelta($sql);
569 569
 
570
-		update_option( $this->table_name . '_db_version', $this->version );
570
+		update_option($this->table_name.'_db_version', $this->version);
571 571
 	}
572 572
 
573 573
 	/**
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 		global $wpdb;
583 583
 
584 584
 		if (
585
-			! give_has_upgrade_completed( 'v20_rename_donor_tables' ) &&
586
-			$wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers" ) )
585
+			! give_has_upgrade_completed('v20_rename_donor_tables') &&
586
+			$wpdb->query($wpdb->prepare("SHOW TABLES LIKE %s", "{$wpdb->prefix}give_customers"))
587 587
 		) {
588 588
 			$wpdb->donors = $this->table_name = "{$wpdb->prefix}give_customers";
589 589
 		}
@@ -597,41 +597,41 @@  discard block
 block discarded – undo
597 597
 	 *
598 598
 	 * @param $args
599 599
 	 */
600
-	private function bc_1814_params( &$args ) {
600
+	private function bc_1814_params(&$args) {
601 601
 		// Backward compatibility: user_id
602
-		if ( ! empty( $args['user_id'] ) ) {
602
+		if ( ! empty($args['user_id'])) {
603 603
 			$args['user'] = $args['user_id'];
604 604
 		}
605 605
 
606 606
 		// Backward compatibility: id
607
-		if ( ! empty( $args['id'] ) ) {
607
+		if ( ! empty($args['id'])) {
608 608
 			$args['donor'] = $args['id'];
609 609
 		}
610 610
 
611 611
 		// Backward compatibility: name
612
-		if ( ! empty( $args['name'] ) ) {
612
+		if ( ! empty($args['name'])) {
613 613
 			$args['s'] = "name:{$args['name']}";
614 614
 		}
615 615
 
616 616
 		// Backward compatibility: date
617 617
 		// Donors created for a specific date or in a date range.
618
-		if ( ! empty( $args['date'] ) ) {
618
+		if ( ! empty($args['date'])) {
619 619
 
620
-			if ( is_array( $args['date'] ) ) {
620
+			if (is_array($args['date'])) {
621 621
 
622
-				if ( ! empty( $args['date']['start'] ) ) {
623
-					$args['date_query']['after'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
622
+				if ( ! empty($args['date']['start'])) {
623
+					$args['date_query']['after'] = date('Y-m-d H:i:s', strtotime($args['date']['start']));
624 624
 				}
625 625
 
626
-				if ( ! empty( $args['date']['end'] ) ) {
627
-					$args['date_query']['before'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
626
+				if ( ! empty($args['date']['end'])) {
627
+					$args['date_query']['before'] = date('Y-m-d H:i:s', strtotime($args['date']['end']));
628 628
 				}
629 629
 
630 630
 			} else {
631 631
 
632
-				$args['date_query']['year']  = date( 'Y', strtotime( $args['date'] ) );
633
-				$args['date_query']['month'] = date( 'm', strtotime( $args['date'] ) );
634
-				$args['date_query']['day']   = date( 'd', strtotime( $args['date'] ) );
632
+				$args['date_query']['year']  = date('Y', strtotime($args['date']));
633
+				$args['date_query']['month'] = date('m', strtotime($args['date']));
634
+				$args['date_query']['day']   = date('d', strtotime($args['date']));
635 635
 			}
636 636
 		}
637 637
 	}
Please login to merge, or discard this patch.
includes/class-give-logging.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -512,7 +512,7 @@
 block discarded – undo
512 512
 	 * @since  1.7
513 513
 	 * @access public
514 514
 	 *
515
-	 * @return bool
515
+	 * @return false|null
516 516
 	 */
517 517
 	public function delete_cache() {
518 518
 		// Add log related keys to delete.
Please login to merge, or discard this patch.
Spacing   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 		 * Setup properties
54 54
 		 */
55 55
 
56
-		require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-logs.php';
57
-		require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-logs-meta.php';
56
+		require_once GIVE_PLUGIN_DIR.'includes/class-give-db-logs.php';
57
+		require_once GIVE_PLUGIN_DIR.'includes/class-give-db-logs-meta.php';
58 58
 		$this->log_db     = new Give_DB_Logs();
59 59
 		$this->logmeta_db = new Give_DB_Log_Meta();
60 60
 
@@ -62,22 +62,22 @@  discard block
 block discarded – undo
62 62
 		 * Setup hooks.
63 63
 		 */
64 64
 
65
-		add_action( 'save_post_give_payment', array( $this, 'background_process_delete_cache' ) );
66
-		add_action( 'save_post_give_forms', array( $this, 'background_process_delete_cache' ) );
67
-		add_action( 'save_post_give_log', array( $this, 'background_process_delete_cache' ) );
68
-		add_action( 'give_delete_log_cache', array( $this, 'delete_cache' ) );
69
-		add_action( 'update_log_metadata', array( $this, 'bc_200_set_payment_as_log_parent' ), 10, 4 );
65
+		add_action('save_post_give_payment', array($this, 'background_process_delete_cache'));
66
+		add_action('save_post_give_forms', array($this, 'background_process_delete_cache'));
67
+		add_action('save_post_give_log', array($this, 'background_process_delete_cache'));
68
+		add_action('give_delete_log_cache', array($this, 'delete_cache'));
69
+		add_action('update_log_metadata', array($this, 'bc_200_set_payment_as_log_parent'), 10, 4);
70 70
 
71 71
 		// Backward compatibility.
72
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
72
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
73 73
 			// Create the log post type
74
-			add_action( 'init', array( $this, 'register_post_type' ), -2 );
74
+			add_action('init', array($this, 'register_post_type'), -2);
75 75
 		}
76 76
 
77 77
 		// Create types taxonomy and default types
78 78
 		// @todo: remove this taxonomy, some addon use this taxonomy with there custom log post type for example: recurring
79 79
 		// Do not use this taxonomy with your log type because we will remove it in future releases.
80
-		add_action( 'init', array( $this, 'register_taxonomy' ), -2 );
80
+		add_action('init', array($this, 'register_taxonomy'), -2);
81 81
 	}
82 82
 
83 83
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		/* Logs post type */
96 96
 		$log_args = array(
97 97
 			'labels'              => array(
98
-				'name' => esc_html__( 'Logs', 'give' ),
98
+				'name' => esc_html__('Logs', 'give'),
99 99
 			),
100 100
 			'public'              => false,
101 101
 			'exclude_from_search' => true,
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 			'query_var'           => false,
105 105
 			'rewrite'             => false,
106 106
 			'capability_type'     => 'post',
107
-			'supports'            => array( 'title', 'editor' ),
107
+			'supports'            => array('title', 'editor'),
108 108
 			'can_export'          => true,
109 109
 		);
110 110
 
111
-		register_post_type( 'give_log', $log_args );
111
+		register_post_type('give_log', $log_args);
112 112
 	}
113 113
 
114 114
 	/**
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 	 * @return void
123 123
 	 */
124 124
 	public function register_taxonomy() {
125
-		register_taxonomy( 'give_log_type', 'give_log', array(
125
+		register_taxonomy('give_log_type', 'give_log', array(
126 126
 			'public' => false,
127
-		) );
127
+		));
128 128
 	}
129 129
 
130 130
 	/**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 			'api_request',
145 145
 		);
146 146
 
147
-		return apply_filters( 'give_log_types', $terms );
147
+		return apply_filters('give_log_types', $terms);
148 148
 	}
149 149
 
150 150
 	/**
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	 *
160 160
 	 * @return bool         Whether log type is valid.
161 161
 	 */
162
-	public function valid_type( $type ) {
163
-		return in_array( $type, $this->log_types() );
162
+	public function valid_type($type) {
163
+		return in_array($type, $this->log_types());
164 164
 	}
165 165
 
166 166
 	/**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 * @return int             Log ID.
181 181
 	 */
182
-	public function add( $title = '', $message = '', $parent = 0, $type = '' ) {
182
+	public function add($title = '', $message = '', $parent = 0, $type = '') {
183 183
 		$log_data = array(
184 184
 			'post_title'   => $title,
185 185
 			'post_content' => $message,
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 			'log_type'     => $type,
188 188
 		);
189 189
 
190
-		return $this->insert_log( $log_data );
190
+		return $this->insert_log($log_data);
191 191
 	}
192 192
 
193 193
 	/**
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @return array             An array of the connected logs.
206 206
 	 */
207
-	public function get_logs( $object_id = 0, $type = '', $paged = null ) {
208
-		return $this->get_connected_logs( array(
207
+	public function get_logs($object_id = 0, $type = '', $paged = null) {
208
+		return $this->get_connected_logs(array(
209 209
 			'log_parent' => $object_id,
210 210
 			'paged'      => $paged,
211 211
 			'log_type'   => $type,
212
-		) );
212
+		));
213 213
 	}
214 214
 
215 215
 	/**
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 *
224 224
 	 * @return int             The ID of the newly created log item.
225 225
 	 */
226
-	public function insert_log( $log_data = array(), $log_meta = array() ) {
226
+	public function insert_log($log_data = array(), $log_meta = array()) {
227 227
 		$log_id = 0;
228 228
 
229 229
 		$defaults = array(
@@ -236,28 +236,28 @@  discard block
 block discarded – undo
236 236
 			'post_status' => 'publish',
237 237
 		);
238 238
 
239
-		$args = wp_parse_args( $log_data, $defaults );
240
-		$this->bc_200_validate_params( $args, $log_meta );
239
+		$args = wp_parse_args($log_data, $defaults);
240
+		$this->bc_200_validate_params($args, $log_meta);
241 241
 
242
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
242
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
243 243
 			global $wpdb;
244 244
 
245 245
 			// Backward Compatibility.
246
-			if ( ! $wpdb->get_var( "SELECT ID from {$this->log_db->table_name} ORDER BY id DESC LIMIT 1" ) ) {
247
-				$latest_log_id = $wpdb->get_var( "SELECT ID from $wpdb->posts ORDER BY id DESC LIMIT 1" );
248
-				$latest_log_id = empty( $latest_log_id ) ? 1 : ++ $latest_log_id;
246
+			if ( ! $wpdb->get_var("SELECT ID from {$this->log_db->table_name} ORDER BY id DESC LIMIT 1")) {
247
+				$latest_log_id = $wpdb->get_var("SELECT ID from $wpdb->posts ORDER BY id DESC LIMIT 1");
248
+				$latest_log_id = empty($latest_log_id) ? 1 : ++ $latest_log_id;
249 249
 
250 250
 				$args['ID'] = $latest_log_id;
251
-				$this->log_db->insert( $args );
251
+				$this->log_db->insert($args);
252 252
 			}
253 253
 		}
254 254
 
255
-		$log_id = $this->log_db->add( $args );
255
+		$log_id = $this->log_db->add($args);
256 256
 
257 257
 		// Set log meta, if any
258
-		if ( $log_id && ! empty( $log_meta ) ) {
259
-			foreach ( (array) $log_meta as $key => $meta ) {
260
-				$this->logmeta_db->update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
258
+		if ($log_id && ! empty($log_meta)) {
259
+			foreach ((array) $log_meta as $key => $meta) {
260
+				$this->logmeta_db->update_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
261 261
 			}
262 262
 		}
263 263
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @return bool|null       True if successful, false otherwise.
281 281
 	 */
282
-	public function update_log( $log_data = array(), $log_meta = array() ) {
282
+	public function update_log($log_data = array(), $log_meta = array()) {
283 283
 		$log_id = 0;
284 284
 
285 285
 		/**
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 		 * @param array $log_data Log entry data.
291 291
 		 * @param array $log_meta Log entry meta.
292 292
 		 */
293
-		do_action( 'give_pre_update_log', $log_data, $log_meta );
293
+		do_action('give_pre_update_log', $log_data, $log_meta);
294 294
 
295 295
 		$defaults = array(
296 296
 			'log_parent'  => 0,
@@ -300,28 +300,28 @@  discard block
 block discarded – undo
300 300
 			'post_status' => 'publish',
301 301
 		);
302 302
 
303
-		$args = wp_parse_args( $log_data, $defaults );
304
-		$this->bc_200_validate_params( $args, $log_meta );
303
+		$args = wp_parse_args($log_data, $defaults);
304
+		$this->bc_200_validate_params($args, $log_meta);
305 305
 
306 306
 		// Store the log entry
307
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
307
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
308 308
 			// Backward compatibility.
309
-			$log_id = wp_update_post( $args );
309
+			$log_id = wp_update_post($args);
310 310
 
311
-			if ( $log_id && ! empty( $log_meta ) ) {
312
-				foreach ( (array) $log_meta as $key => $meta ) {
313
-					if ( ! empty( $meta ) ) {
314
-						give_update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
311
+			if ($log_id && ! empty($log_meta)) {
312
+				foreach ((array) $log_meta as $key => $meta) {
313
+					if ( ! empty($meta)) {
314
+						give_update_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
315 315
 					}
316 316
 				}
317 317
 			}
318 318
 		} else {
319
-			$log_id = $this->log_db->add( $args );
319
+			$log_id = $this->log_db->add($args);
320 320
 
321
-			if ( $log_id && ! empty( $log_meta ) ) {
322
-				foreach ( (array) $log_meta as $key => $meta ) {
323
-					if ( ! empty( $meta ) ) {
324
-						$this->logmeta_db->update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
321
+			if ($log_id && ! empty($log_meta)) {
322
+				foreach ((array) $log_meta as $key => $meta) {
323
+					if ( ! empty($meta)) {
324
+						$this->logmeta_db->update_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
325 325
 					}
326 326
 				}
327 327
 			}
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 		 * @param array $log_data Log entry data.
337 337
 		 * @param array $log_meta Log entry meta.
338 338
 		 */
339
-		do_action( 'give_post_update_log', $log_id, $log_data, $log_meta );
339
+		do_action('give_post_update_log', $log_id, $log_data, $log_meta);
340 340
 	}
341 341
 
342 342
 	/**
@@ -353,30 +353,30 @@  discard block
 block discarded – undo
353 353
 	 *
354 354
 	 * @return array|false Array if logs were found, false otherwise.
355 355
 	 */
356
-	public function get_connected_logs( $args = array() ) {
356
+	public function get_connected_logs($args = array()) {
357 357
 		$logs = array();
358 358
 
359
-		$defaults   = array(
359
+		$defaults = array(
360 360
 			'number'      => 20,
361
-			'paged'       => get_query_var( 'paged' ),
361
+			'paged'       => get_query_var('paged'),
362 362
 			'log_type'    => false,
363 363
 
364 364
 			// Backward compatibility.
365 365
 			'post_type'   => 'give_log',
366 366
 			'post_status' => 'publish',
367 367
 		);
368
-		$query_args = wp_parse_args( $args, $defaults );
369
-		$this->bc_200_validate_params( $query_args );
368
+		$query_args = wp_parse_args($args, $defaults);
369
+		$this->bc_200_validate_params($query_args);
370 370
 
371
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
371
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
372 372
 			// Backward compatibility.
373
-			$logs = get_posts( $query_args );
374
-			$this->bc_200_add_new_properties( $logs );
373
+			$logs = get_posts($query_args);
374
+			$this->bc_200_add_new_properties($logs);
375 375
 		} else {
376
-			$logs = $this->log_db->get_logs( $query_args );
376
+			$logs = $this->log_db->get_logs($query_args);
377 377
 		}
378 378
 
379
-		return ( ! empty( $logs ) ? $logs : false );
379
+		return ( ! empty($logs) ? $logs : false);
380 380
 	}
381 381
 
382 382
 	/**
@@ -394,41 +394,41 @@  discard block
 block discarded – undo
394 394
 	 *
395 395
 	 * @return int                Log count.
396 396
 	 */
397
-	public function get_log_count( $object_id = 0, $type = '', $meta_query = null, $date_query = null ) {
397
+	public function get_log_count($object_id = 0, $type = '', $meta_query = null, $date_query = null) {
398 398
 		$logs_count = 0;
399 399
 
400 400
 		$query_args = array(
401
-			'number'      => - 1,
401
+			'number'      => -1,
402 402
 
403 403
 			// Backward comatibility.
404 404
 			'post_type'   => 'give_log',
405 405
 			'post_status' => 'publish',
406 406
 		);
407 407
 
408
-		if ( $object_id ) {
408
+		if ($object_id) {
409 409
 			$query_args['log_parent'] = $object_id;
410 410
 		}
411 411
 
412
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
412
+		if ( ! empty($type) && $this->valid_type($type)) {
413 413
 			$query_args['log_type'] = $type;
414 414
 		}
415 415
 
416
-		if ( ! empty( $meta_query ) ) {
416
+		if ( ! empty($meta_query)) {
417 417
 			$query_args['meta_query'] = $meta_query;
418 418
 		}
419 419
 
420
-		if ( ! empty( $date_query ) ) {
420
+		if ( ! empty($date_query)) {
421 421
 			$query_args['date_query'] = $date_query;
422 422
 		}
423 423
 
424
-		$this->bc_200_validate_params( $query_args );
424
+		$this->bc_200_validate_params($query_args);
425 425
 
426
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
426
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
427 427
 			// Backward compatibility.
428
-			$logs       = new WP_Query( $query_args );
428
+			$logs       = new WP_Query($query_args);
429 429
 			$logs_count = (int) $logs->post_count;
430 430
 		} else {
431
-			$logs_count = $this->log_db->count( $query_args );
431
+			$logs_count = $this->log_db->count($query_args);
432 432
 		}
433 433
 
434 434
 		return $logs_count;
@@ -448,10 +448,10 @@  discard block
 block discarded – undo
448 448
 	 *
449 449
 	 * @return void
450 450
 	 */
451
-	public function delete_logs( $object_id = 0, $type = '', $meta_query = null ) {
451
+	public function delete_logs($object_id = 0, $type = '', $meta_query = null) {
452 452
 		$query_args = array(
453 453
 			'log_parent'  => $object_id,
454
-			'number'      => - 1,
454
+			'number'      => -1,
455 455
 			'fields'      => 'ID',
456 456
 
457 457
 			// Backward compatibility.
@@ -459,32 +459,32 @@  discard block
 block discarded – undo
459 459
 			'post_status' => 'publish',
460 460
 		);
461 461
 
462
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
462
+		if ( ! empty($type) && $this->valid_type($type)) {
463 463
 			$query_args['log_type'] = $type;
464 464
 		}
465 465
 
466
-		if ( ! empty( $meta_query ) ) {
466
+		if ( ! empty($meta_query)) {
467 467
 			$query_args['meta_query'] = $meta_query;
468 468
 		}
469 469
 
470
-		$this->bc_200_validate_params( $query_args );
470
+		$this->bc_200_validate_params($query_args);
471 471
 
472
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
472
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
473 473
 			// Backward compatibility.
474
-			$logs = get_posts( $query_args );
474
+			$logs = get_posts($query_args);
475 475
 
476
-			if ( $logs ) {
477
-				foreach ( $logs as $log ) {
478
-					wp_delete_post( $log, true );
476
+			if ($logs) {
477
+				foreach ($logs as $log) {
478
+					wp_delete_post($log, true);
479 479
 				}
480 480
 			}
481 481
 		} else {
482
-			$logs = $this->log_db->get_logs( $query_args );
482
+			$logs = $this->log_db->get_logs($query_args);
483 483
 
484
-			if ( $logs ) {
485
-				foreach ( $logs as $log ) {
486
-					if ( $this->log_db->delete( $log->ID ) ) {
487
-						$this->logmeta_db->delete_row( $log->ID );
484
+			if ($logs) {
485
+				foreach ($logs as $log) {
486
+					if ($this->log_db->delete($log->ID)) {
487
+						$this->logmeta_db->delete_row($log->ID);
488 488
 					}
489 489
 				}
490 490
 			}
@@ -501,9 +501,9 @@  discard block
 block discarded – undo
501 501
 	 *
502 502
 	 * @param int $post_id
503 503
 	 */
504
-	public function background_process_delete_cache( $post_id ) {
504
+	public function background_process_delete_cache($post_id) {
505 505
 		// Delete log cache immediately
506
-		wp_schedule_single_event( time() - 5, 'give_delete_log_cache' );
506
+		wp_schedule_single_event(time() - 5, 'give_delete_log_cache');
507 507
 	}
508 508
 
509 509
 	/**
@@ -516,17 +516,17 @@  discard block
 block discarded – undo
516 516
 	 */
517 517
 	public function delete_cache() {
518 518
 		// Add log related keys to delete.
519
-		$cache_give_logs      = Give_Cache::get_options_like( 'give_logs' );
520
-		$cache_give_log_count = Give_Cache::get_options_like( 'log_count' );
519
+		$cache_give_logs      = Give_Cache::get_options_like('give_logs');
520
+		$cache_give_log_count = Give_Cache::get_options_like('log_count');
521 521
 
522
-		$cache_option_names = array_merge( $cache_give_logs, $cache_give_log_count );
522
+		$cache_option_names = array_merge($cache_give_logs, $cache_give_log_count);
523 523
 
524 524
 		// Bailout.
525
-		if ( empty( $cache_option_names ) ) {
525
+		if (empty($cache_option_names)) {
526 526
 			return false;
527 527
 		}
528 528
 
529
-		Give_Cache::delete( $cache_option_names );
529
+		Give_Cache::delete($cache_option_names);
530 530
 	}
531 531
 
532 532
 	/**
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 	 * @param array $log_query
539 539
 	 * @param array $log_meta
540 540
 	 */
541
-	private function bc_200_validate_params( &$log_query, &$log_meta = array() ) {
541
+	private function bc_200_validate_params(&$log_query, &$log_meta = array()) {
542 542
 		$query_params = array(
543 543
 			'log_title'    => 'post_title',
544 544
 			'log_parent'   => 'post_parent',
@@ -550,41 +550,41 @@  discard block
 block discarded – undo
550 550
 			'meta_query'   => 'meta_query',
551 551
 		);
552 552
 
553
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
553
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
554 554
 			// Set old params.
555
-			foreach ( $query_params as $new_query_param => $old_query_param ) {
555
+			foreach ($query_params as $new_query_param => $old_query_param) {
556 556
 
557
-				if ( isset( $log_query[ $old_query_param ] ) && empty( $log_query[ $new_query_param ] ) ) {
558
-					$log_query[ $new_query_param ] = $log_query[ $old_query_param ];
557
+				if (isset($log_query[$old_query_param]) && empty($log_query[$new_query_param])) {
558
+					$log_query[$new_query_param] = $log_query[$old_query_param];
559 559
 					continue;
560
-				} elseif ( ! isset( $log_query[ $new_query_param ] ) ) {
560
+				} elseif ( ! isset($log_query[$new_query_param])) {
561 561
 					continue;
562
-				} elseif( empty( $log_query[ $new_query_param ] ) ) {
562
+				} elseif (empty($log_query[$new_query_param])) {
563 563
 					continue;
564 564
 				}
565 565
 
566
-				switch ( $new_query_param ) {
566
+				switch ($new_query_param) {
567 567
 					case 'log_type':
568 568
 						$log_query['tax_query'] = array(
569 569
 							array(
570 570
 								'taxonomy' => 'give_log_type',
571 571
 								'field'    => 'slug',
572
-								'terms'    => $log_query[ $new_query_param ],
572
+								'terms'    => $log_query[$new_query_param],
573 573
 							),
574 574
 						);
575 575
 						break;
576 576
 
577 577
 					case 'meta_query':
578
-						if( ! empty( $log_query['meta_query'] ) && empty( $log_query['post_parent'] ) ) {
579
-							foreach ( $log_query['meta_query'] as $index => $meta_query ){
580
-								if( ! is_array( $meta_query ) || empty( $meta_query['key'] ) ) {
578
+						if ( ! empty($log_query['meta_query']) && empty($log_query['post_parent'])) {
579
+							foreach ($log_query['meta_query'] as $index => $meta_query) {
580
+								if ( ! is_array($meta_query) || empty($meta_query['key'])) {
581 581
 									continue;
582 582
 								}
583 583
 
584
-								switch ( $meta_query['key'] ) {
584
+								switch ($meta_query['key']) {
585 585
 									case '_give_log_form_id':
586 586
 										$log_query['post_parent'] = $meta_query['value'];
587
-										unset( $log_query['meta_query'][$index] );
587
+										unset($log_query['meta_query'][$index]);
588 588
 										break;
589 589
 								}
590 590
 							}
@@ -592,40 +592,40 @@  discard block
 block discarded – undo
592 592
 						break;
593 593
 
594 594
 					default:
595
-						switch( $new_query_param ){
595
+						switch ($new_query_param) {
596 596
 							case 'log_parent':
597 597
 								$log_query['meta_query'][] = array(
598 598
 									'key' => '_give_log_payment_id',
599
-									'value' => $log_query[ $new_query_param ]
599
+									'value' => $log_query[$new_query_param]
600 600
 								);
601 601
 
602 602
 								break;
603 603
 
604 604
 							default:
605
-								$log_query[ $old_query_param ] = $log_query[ $new_query_param ];
605
+								$log_query[$old_query_param] = $log_query[$new_query_param];
606 606
 						}
607 607
 				}
608 608
 			}
609 609
 		} else {
610 610
 			// Set only old params.
611
-			$query_params = array_flip( $query_params );
612
-			foreach ( $query_params as $old_query_param => $new_query_param ) {
613
-				if ( isset( $log_query[ $new_query_param ] ) && empty( $log_query[ $old_query_param ] ) ) {
614
-					$log_query[ $old_query_param ] = $log_query[ $new_query_param ];
611
+			$query_params = array_flip($query_params);
612
+			foreach ($query_params as $old_query_param => $new_query_param) {
613
+				if (isset($log_query[$new_query_param]) && empty($log_query[$old_query_param])) {
614
+					$log_query[$old_query_param] = $log_query[$new_query_param];
615 615
 					continue;
616
-				} elseif ( ! isset( $log_query[ $old_query_param ] ) ) {
616
+				} elseif ( ! isset($log_query[$old_query_param])) {
617 617
 					continue;
618 618
 				}
619 619
 
620
-				switch ( $old_query_param ) {
620
+				switch ($old_query_param) {
621 621
 					case 'tax_query':
622
-						if ( isset( $log_query[ $old_query_param ][0]['terms'] ) ) {
623
-							$log_query[ $new_query_param ] = $log_query[ $old_query_param ][0]['terms'];
622
+						if (isset($log_query[$old_query_param][0]['terms'])) {
623
+							$log_query[$new_query_param] = $log_query[$old_query_param][0]['terms'];
624 624
 						}
625 625
 						break;
626 626
 
627 627
 					default:
628
-						$log_query[ $new_query_param ] = $log_query[ $old_query_param ];
628
+						$log_query[$new_query_param] = $log_query[$old_query_param];
629 629
 				}
630 630
 			}
631 631
 		}
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
 	 *
640 640
 	 * @param  array $logs
641 641
 	 */
642
-	private function bc_200_add_new_properties( &$logs ) {
643
-		if ( empty( $logs ) ) {
642
+	private function bc_200_add_new_properties(&$logs) {
643
+		if (empty($logs)) {
644 644
 			return;
645 645
 		}
646 646
 
@@ -653,30 +653,30 @@  discard block
 block discarded – undo
653 653
 			'log_type'     => 'give_log_type',
654 654
 		);
655 655
 
656
-		if ( ! give_has_upgrade_completed( 'v20_logs_upgrades' ) ) {
657
-			foreach ( $logs as $index => $log ) {
658
-				foreach ( $query_params as $new_query_param => $old_query_param ) {
659
-					if ( ! property_exists( $log, $old_query_param ) ) {
656
+		if ( ! give_has_upgrade_completed('v20_logs_upgrades')) {
657
+			foreach ($logs as $index => $log) {
658
+				foreach ($query_params as $new_query_param => $old_query_param) {
659
+					if ( ! property_exists($log, $old_query_param)) {
660 660
 						/**
661 661
 						 *  Set unmatched properties.
662 662
 						 */
663 663
 
664 664
 						// 1. log_type
665
-						$term = get_the_terms( $log->ID, 'give_log_type' );
666
-						$term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array();
665
+						$term = get_the_terms($log->ID, 'give_log_type');
666
+						$term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array();
667 667
 
668
-						$logs[ $index ]->{$new_query_param} = ! empty( $term ) ? $term->slug : '';
668
+						$logs[$index]->{$new_query_param} = ! empty($term) ? $term->slug : '';
669 669
 
670 670
 						continue;
671 671
 					}
672 672
 
673
-					switch ( $old_query_param ) {
673
+					switch ($old_query_param) {
674 674
 						case 'post_parent':
675
-							$logs[ $index ]->{$new_query_param} = give_get_meta( $log->ID, '_give_log_payment_id', true );
675
+							$logs[$index]->{$new_query_param} = give_get_meta($log->ID, '_give_log_payment_id', true);
676 676
 							break;
677 677
 
678 678
 						default:
679
-							$logs[ $index ]->{$new_query_param} = $log->{$old_query_param};
679
+							$logs[$index]->{$new_query_param} = $log->{$old_query_param};
680 680
 					}
681 681
 				}
682 682
 			}
@@ -696,10 +696,10 @@  discard block
 block discarded – undo
696 696
 	 *
697 697
 	 * @return mixed
698 698
 	 */
699
-	public function bc_200_set_payment_as_log_parent( $check, $log_id, $meta_key, $meta_value ) {
699
+	public function bc_200_set_payment_as_log_parent($check, $log_id, $meta_key, $meta_value) {
700 700
 		global $wpdb;
701 701
 		$update_status = false;
702
-		$post_type     = get_post_type( $log_id );
702
+		$post_type     = get_post_type($log_id);
703 703
 
704 704
 		// Bailout.
705 705
 		if (
@@ -719,9 +719,9 @@  discard block
 block discarded – undo
719 719
 			)
720 720
 		);
721 721
 
722
-		if ( $form_id ) {
723
-			$this->logmeta_db->delete_meta( $log_id, '_give_log_payment_id' );
724
-			$this->logmeta_db->update_meta( $log_id, '_give_log_form_id', $form_id );
722
+		if ($form_id) {
723
+			$this->logmeta_db->delete_meta($log_id, '_give_log_payment_id');
724
+			$this->logmeta_db->update_meta($log_id, '_give_log_form_id', $form_id);
725 725
 
726 726
 			$update_status = $wpdb->update(
727 727
 				$this->log_db->table_name,
Please login to merge, or discard this patch.