Test Failed
Push — master ( f5d3bd...a6c3df )
by Ravinder
06:01
created
includes/admin/emails/abstract-email-notification.php 1 patch
Spacing   +163 added lines, -164 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
@@ -94,14 +94,14 @@  discard block
 block discarded – undo
94 94
 		 *
95 95
 		 * @return Give_Email_Notification
96 96
 		 */
97
-		public static function get_instance( $email_notification_id = '' ) {
97
+		public static function get_instance($email_notification_id = '') {
98 98
 			$class = '';
99 99
 
100
-			if ( ! empty( $email_notification_id ) ) {
100
+			if ( ! empty($email_notification_id)) {
101 101
 				/* @var Give_Email_Notification $class */
102
-				foreach ( self::$singleton as $class ) {
103
-					if ( $email_notification_id === $class->config['id'] ) {
104
-						$class = get_class( $class );
102
+				foreach (self::$singleton as $class) {
103
+					if ($email_notification_id === $class->config['id']) {
104
+						$class = get_class($class);
105 105
 						break;
106 106
 					}
107 107
 				}
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 				$class = get_called_class();
110 110
 			}
111 111
 
112
-			if ( ! empty( $class ) && ( ! array_key_exists( $class, self::$singleton ) || is_null( self::$singleton[ $class ] ) ) ) {
113
-				self::$singleton[ $class ] = new $class();
112
+			if ( ! empty($class) && ( ! array_key_exists($class, self::$singleton) || is_null(self::$singleton[$class]))) {
113
+				self::$singleton[$class] = new $class();
114 114
 			}
115 115
 
116
-			return ( isset( self::$singleton[ $class ] ) ? self::$singleton[ $class ] : null );
116
+			return (isset(self::$singleton[$class]) ? self::$singleton[$class] : null);
117 117
 		}
118 118
 
119 119
 		/**
@@ -124,35 +124,35 @@  discard block
 block discarded – undo
124 124
 		 *
125 125
 		 * @param array $config
126 126
 		 */
127
-		public function load( $config ) {
127
+		public function load($config) {
128 128
 			// Set notification configuration.
129
-			$this->config = wp_parse_args( $config, $this->config );
129
+			$this->config = wp_parse_args($config, $this->config);
130 130
 
131 131
 			// Set email preview header status.
132 132
 			$this->config['has_preview_header'] = $this->config['has_preview'] && $this->config['has_preview_header'] ? true : false;
133 133
 
134 134
 			// Set email content type
135
-			$this->config['content_type'] = empty( $this->config['content_type'] ) || ! in_array( $this->config['content_type'], array(
135
+			$this->config['content_type'] = empty($this->config['content_type']) || ! in_array($this->config['content_type'], array(
136 136
 				'text/html',
137 137
 				'text/plain',
138
-			) )
138
+			))
139 139
 				? Give()->emails->get_content_type()
140 140
 				: $this->config['content_type'];
141
-			$this->config['content_type'] = give_get_option( Give_Email_Setting_Field::get_prefix( $this ) . 'email_content_type', $this->config['content_type'] );
141
+			$this->config['content_type'] = give_get_option(Give_Email_Setting_Field::get_prefix($this).'email_content_type', $this->config['content_type']);
142 142
 
143 143
 			// Set email template type.
144
-			$this->config['email_template'] = empty( $this->config['email_template'] )
145
-				? give_get_option( 'email_template' )
144
+			$this->config['email_template'] = empty($this->config['email_template'])
145
+				? give_get_option('email_template')
146 146
 				: $this->config['email_template'];
147 147
 
148 148
 			// Set recipient group name.
149
-			$this->config['recipient_group_name'] = empty( $this->config['recipient_group_name'] )
150
-				? ( ! Give_Email_Notification_Util::has_recipient_field( $this ) ? __( 'Donor', 'give' ) : '' )
149
+			$this->config['recipient_group_name'] = empty($this->config['recipient_group_name'])
150
+				? ( ! Give_Email_Notification_Util::has_recipient_field($this) ? __('Donor', 'give') : '')
151 151
 				: $this->config['recipient_group_name'];
152 152
 
153 153
 			// Non notification status editable notice.
154
-			$this->config['notices']['non-notification-status-editable'] = empty( $this->config['notices']['non-notification-status-editable'] )
155
-				? __( 'You can not edit notification status from here.', 'give' )
154
+			$this->config['notices']['non-notification-status-editable'] = empty($this->config['notices']['non-notification-status-editable'])
155
+				? __('You can not edit notification status from here.', 'give')
156 156
 				: $this->config['notices']['non-notification-status-editable'];
157 157
 
158 158
 			/**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 			 * @param                         array                   Give_Email_Notification::config
164 164
 			 * @param Give_Email_Notification $this
165 165
 			 */
166
-			$this->config = apply_filters( 'give_email_api_notification_config', $this->config, $this );
166
+			$this->config = apply_filters('give_email_api_notification_config', $this->config, $this);
167 167
 
168 168
 			// Setup filters.
169 169
 			$this->setup_filters();
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		 */
179 179
 		private function setup_filters() {
180 180
 			// Apply filter only for current email notification section.
181
-			if ( give_get_current_setting_section() === $this->config['id'] ) {
181
+			if (give_get_current_setting_section() === $this->config['id']) {
182 182
 				// Initialize email context for email notification.
183 183
 				$this->config['email_tag_context'] = apply_filters(
184 184
 					"give_{$this->config['id']}_email_tag_context",
@@ -188,23 +188,23 @@  discard block
 block discarded – undo
188 188
 			}
189 189
 
190 190
 			// Setup setting fields.
191
-			if( $this->config['show_on_emails_setting_page'] ) {
192
-				add_filter( 'give_get_settings_emails', array( $this, 'add_setting_fields' ), 10, 2 );
191
+			if ($this->config['show_on_emails_setting_page']) {
192
+				add_filter('give_get_settings_emails', array($this, 'add_setting_fields'), 10, 2);
193 193
 			}
194 194
 
195
-			if ( $this->config['form_metabox_setting'] && ! empty( $this->config['form_metabox_id'] ) ) {
195
+			if ($this->config['form_metabox_setting'] && ! empty($this->config['form_metabox_id'])) {
196 196
 				add_filter(
197 197
 					$this->config['form_metabox_id'],
198
-					array( $this, 'add_metabox_setting_field' ),
198
+					array($this, 'add_metabox_setting_field'),
199 199
 					10,
200 200
 					2
201 201
 				);
202 202
 			}
203 203
 
204
-			if( $this->config['has_recipient_field'] ) {
204
+			if ($this->config['has_recipient_field']) {
205 205
 				add_action(
206 206
 						"give_save__give_{$this->config['id']}_recipient",
207
-						array( $this, 'validate_form_recipient_field_value' ),
207
+						array($this, 'validate_form_recipient_field_value'),
208 208
 						10,
209 209
 						3
210 210
 				);
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 		 *
254 254
 		 * @return array
255 255
 		 */
256
-		public function add_section( $sections ) {
257
-			$sections[ $this->config['id'] ] = $this->config['label'];
256
+		public function add_section($sections) {
257
+			$sections[$this->config['id']] = $this->config['label'];
258 258
 
259 259
 			return $sections;
260 260
 		}
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		 *
269 269
 		 * @return bool
270 270
 		 */
271
-		public function hide_section( $hide_section ) {
271
+		public function hide_section($hide_section) {
272 272
 			$hide_section = true;
273 273
 
274 274
 			return $hide_section;
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 		 *
285 285
 		 * @return  array
286 286
 		 */
287
-		public function add_setting_fields( $settings ) {
288
-			if ( $this->config['id'] === give_get_current_setting_section() ) {
287
+		public function add_setting_fields($settings) {
288
+			if ($this->config['id'] === give_get_current_setting_section()) {
289 289
 				$settings = $this->get_setting_fields();
290 290
 			}
291 291
 
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 		 *
304 304
 		 * @return array
305 305
 		 */
306
-		public function get_setting_fields( $form_id = null ) {
307
-			return Give_Email_Setting_Field::get_setting_fields( $this, $form_id );
306
+		public function get_setting_fields($form_id = null) {
307
+			return Give_Email_Setting_Field::get_setting_fields($this, $form_id);
308 308
 		}
309 309
 
310 310
 
@@ -319,13 +319,13 @@  discard block
 block discarded – undo
319 319
 		 *
320 320
 		 * @return array
321 321
 		 */
322
-		public function add_metabox_setting_field( $settings, $form_id ) {
322
+		public function add_metabox_setting_field($settings, $form_id) {
323 323
 
324
-			if( Give_Email_Notification_Util::is_email_notification_active( $this ) ) {
324
+			if (Give_Email_Notification_Util::is_email_notification_active($this)) {
325 325
 				$settings[] = array(
326 326
 					'id'     => $this->config['id'],
327 327
 					'title'  => $this->config['label'],
328
-					'fields' => $this->get_setting_fields( $form_id ),
328
+					'fields' => $this->get_setting_fields($form_id),
329 329
 				);
330 330
 			}
331 331
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 		 *
344 344
 		 * @return array
345 345
 		 */
346
-		public function get_extra_setting_fields( $form_id = null ) {
346
+		public function get_extra_setting_fields($form_id = null) {
347 347
 			return array();
348 348
 		}
349 349
 
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
 		 *
361 361
 		 * @return string|array
362 362
 		 */
363
-		public function get_recipient( $form_id = null ) {
364
-			if ( empty( $this->recipient_email ) && $this->config['has_recipient_field'] ) {
363
+		public function get_recipient($form_id = null) {
364
+			if (empty($this->recipient_email) && $this->config['has_recipient_field']) {
365 365
 				$this->recipient_email = Give_Email_Notification_Util::get_value(
366 366
 						$this,
367
-						Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'recipient',
367
+						Give_Email_Setting_Field::get_prefix($this, $form_id).'recipient',
368 368
 						$form_id
369 369
 				);
370 370
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 				 * @since 1.0
376 376
 				 * @deprecated 2.0
377 377
 				 */
378
-				$this->recipient_email = apply_filters( 'give_admin_notice_emails', $this->recipient_email, $this, $form_id );
378
+				$this->recipient_email = apply_filters('give_admin_notice_emails', $this->recipient_email, $this, $form_id);
379 379
 			}
380 380
 
381 381
 			/**
@@ -405,10 +405,10 @@  discard block
 block discarded – undo
405 405
 		 *
406 406
 		 * @return bool
407 407
 		 */
408
-		public function get_notification_status( $form_id = null ) {
409
-			$notification_status = empty( $form_id )
410
-				? give_get_option( "{$this->config['id']}_notification", $this->config['notification_status'] )
411
-				: give_get_meta( $form_id, Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'notification', true, 'global' );
408
+		public function get_notification_status($form_id = null) {
409
+			$notification_status = empty($form_id)
410
+				? give_get_option("{$this->config['id']}_notification", $this->config['notification_status'])
411
+				: give_get_meta($form_id, Give_Email_Setting_Field::get_prefix($this, $form_id).'notification', true, 'global');
412 412
 
413 413
 			/**
414 414
 			 * Filter the notification status.
@@ -433,11 +433,11 @@  discard block
 block discarded – undo
433 433
 		 *
434 434
 		 * @return string
435 435
 		 */
436
-		function get_email_subject( $form_id = null ) {
436
+		function get_email_subject($form_id = null) {
437 437
 			$subject = wp_strip_all_tags(
438 438
 				Give_Email_Notification_Util::get_value(
439 439
 					$this,
440
-					Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_subject',
440
+					Give_Email_Setting_Field::get_prefix($this, $form_id).'email_subject',
441 441
 					$form_id,
442 442
 					$this->config['default_email_subject']
443 443
 				)
@@ -466,10 +466,10 @@  discard block
 block discarded – undo
466 466
 		 *
467 467
 		 * @return string
468 468
 		 */
469
-		public function get_email_message( $form_id = null ) {
469
+		public function get_email_message($form_id = null) {
470 470
 			$message = Give_Email_Notification_Util::get_value(
471 471
 				$this,
472
-				Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message',
472
+				Give_Email_Setting_Field::get_prefix($this, $form_id).'email_message',
473 473
 				$form_id,
474 474
 				$this->config['default_email_message']
475 475
 			);
@@ -496,10 +496,10 @@  discard block
 block discarded – undo
496 496
 		 *
497 497
 		 * @return string
498 498
 		 */
499
-		public function get_email_header( $form_id = null ) {
499
+		public function get_email_header($form_id = null) {
500 500
 			$header = Give_Email_Notification_Util::get_value(
501 501
 				$this,
502
-				Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_header',
502
+				Give_Email_Setting_Field::get_prefix($this, $form_id).'email_header',
503 503
 				$form_id,
504 504
 				$this->config['default_email_header']
505 505
 			);
@@ -527,10 +527,10 @@  discard block
 block discarded – undo
527 527
 		 *
528 528
 		 * @return string
529 529
 		 */
530
-		public function get_email_content_type( $form_id ) {
530
+		public function get_email_content_type($form_id) {
531 531
 			$content_type = Give_Email_Notification_Util::get_value(
532 532
 				$this,
533
-				Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_content_type',
533
+				Give_Email_Setting_Field::get_prefix($this, $form_id).'email_content_type',
534 534
 				$form_id,
535 535
 				$this->config['content_type']
536 536
 			);
@@ -558,15 +558,14 @@  discard block
 block discarded – undo
558 558
 		 *
559 559
 		 * @return string
560 560
 		 */
561
-		public function get_email_template( $form_id ) {
562
-			$email_template = give_get_meta( $form_id, '_give_email_template', true );
561
+		public function get_email_template($form_id) {
562
+			$email_template = give_get_meta($form_id, '_give_email_template', true);
563 563
 			$email_template = Give_Email_Notification_Util::get_value(
564 564
 				$this,
565
-				Give_Email_Setting_Field::get_prefix( $this, $form_id ) .'email_template',
565
+				Give_Email_Setting_Field::get_prefix($this, $form_id).'email_template',
566 566
 				$form_id,
567
-				! empty( $email_template ) && Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ?
568
-					$email_template :
569
-					$this->config['email_template']
567
+				! empty($email_template) && Give_Email_Notification_Util::can_use_form_email_options($this, $form_id) ?
568
+					$email_template : $this->config['email_template']
570 569
 			);
571 570
 
572 571
 			/**
@@ -593,20 +592,20 @@  discard block
 block discarded – undo
593 592
 		 *
594 593
 		 * @return array
595 594
 		 */
596
-		public function get_allowed_email_tags( $formatted = false ) {
595
+		public function get_allowed_email_tags($formatted = false) {
597 596
 			// Get all email tags.
598 597
 			$email_tags = Give()->email_tags->get_tags();
599 598
 
600 599
 			// Skip if all email template tags context setup exit.
601
-			if ( $this->config['email_tag_context'] && 'all' !== $this->config['email_tag_context'] ) {
600
+			if ($this->config['email_tag_context'] && 'all' !== $this->config['email_tag_context']) {
602 601
 				$email_context = (array) $this->config['email_tag_context'];
603 602
 
604
-				foreach ( $email_tags as $index => $email_tag ) {
605
-					if ( in_array( $email_tag['context'], $email_context ) ) {
603
+				foreach ($email_tags as $index => $email_tag) {
604
+					if (in_array($email_tag['context'], $email_context)) {
606 605
 						continue;
607 606
 					}
608 607
 
609
-					unset( $email_tags[ $index ] );
608
+					unset($email_tags[$index]);
610 609
 				}
611 610
 			}
612 611
 
@@ -614,17 +613,17 @@  discard block
 block discarded – undo
614 613
 			 * Disallow tags on Email Notifications which don't have a
615 614
 			 * recipient and if the tag's is_admin property is set to true.
616 615
 			 */
617
-			if ( false === $this->config['has_recipient_field'] ) {
618
-				foreach ( $email_tags as $index => $email_tag ) {
619
-					if ( true === $email_tag['is_admin'] ) {
620
-						unset( $email_tags[ $index ] );
616
+			if (false === $this->config['has_recipient_field']) {
617
+				foreach ($email_tags as $index => $email_tag) {
618
+					if (true === $email_tag['is_admin']) {
619
+						unset($email_tags[$index]);
621 620
 					}
622 621
 				}
623 622
 			}
624 623
 
625
-			if ( count( $email_tags ) && $formatted ) : ob_start() ?>
624
+			if (count($email_tags) && $formatted) : ob_start() ?>
626 625
 				<ul class="give-email-tags-wrap">
627
-					<?php foreach ( $email_tags as $email_tag ) : ?>
626
+					<?php foreach ($email_tags as $email_tag) : ?>
628 627
 						<li class="give_<?php echo $email_tag['tag']; ?>_tag">
629 628
 							<code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['desc']; ?>
630 629
 						</li>
@@ -647,8 +646,8 @@  discard block
 block discarded – undo
647 646
 		 *
648 647
 		 * @return array|string
649 648
 		 */
650
-		public function get_preview_email_recipient( $form_id = null ) {
651
-			$recipients = $this->get_recipient( $form_id );
649
+		public function get_preview_email_recipient($form_id = null) {
650
+			$recipients = $this->get_recipient($form_id);
652 651
 
653 652
 			/**
654 653
 			 * Filter the preview email recipients.
@@ -658,7 +657,7 @@  discard block
 block discarded – undo
658 657
 			 * @param string|array            $recipients List of recipients.
659 658
 			 * @param Give_Email_Notification $this
660 659
 			 */
661
-			$recipients = apply_filters( 'give_get_preview_email_recipient', $recipients, $this, $form_id );
660
+			$recipients = apply_filters('give_get_preview_email_recipient', $recipients, $this, $form_id);
662 661
 
663 662
 			return $recipients;
664 663
 		}
@@ -673,13 +672,13 @@  discard block
 block discarded – undo
673 672
 		 *
674 673
 		 * @return array
675 674
 		 */
676
-		public function get_email_attachments( $form_id = null ) {
675
+		public function get_email_attachments($form_id = null) {
677 676
 			/**
678 677
 			 * Filter the attachment.
679 678
 			 *
680 679
 			 * @since 2.0
681 680
 			 */
682
-			return apply_filters( "give_{$this->config['id']}_get_email_attachments", array(), $this, $form_id );
681
+			return apply_filters("give_{$this->config['id']}_get_email_attachments", array(), $this, $form_id);
683 682
 		}
684 683
 
685 684
 
@@ -693,43 +692,43 @@  discard block
 block discarded – undo
693 692
 		 *
694 693
 		 * @return bool
695 694
 		 */
696
-		public function send_preview_email( $send = true ) {
695
+		public function send_preview_email($send = true) {
697 696
 			// Get form id
698
-			$form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null;
697
+			$form_id = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null;
699 698
 
700 699
 			// setup email data.
701 700
 			$this->setup_email_data();
702 701
 
703 702
 			$attachments  = $this->get_email_attachments();
704
-			$message      = $this->preview_email_template_tags( $this->get_email_message( $form_id ) );
705
-			$subject      = $this->preview_email_template_tags( $this->get_email_subject( $form_id ) );
706
-			$content_type = $this->get_email_content_type( $form_id );
703
+			$message      = $this->preview_email_template_tags($this->get_email_message($form_id));
704
+			$subject      = $this->preview_email_template_tags($this->get_email_subject($form_id));
705
+			$content_type = $this->get_email_content_type($form_id);
707 706
 
708 707
 			// Setup email content type.
709
-			Give()->emails->__set( 'content_type', $content_type );
710
-			Give()->emails->__set( 'html', true );
708
+			Give()->emails->__set('content_type', $content_type);
709
+			Give()->emails->__set('html', true);
711 710
 
712 711
 			// Setup email template
713
-			Give()->emails->__set( 'template', $this->get_email_template( $form_id ) );
712
+			Give()->emails->__set('template', $this->get_email_template($form_id));
714 713
 
715 714
 			// Set email header.
716
-			Give()->emails->__set( 'heading', $this->preview_email_template_tags( $this->get_email_header( $form_id ) ) );
715
+			Give()->emails->__set('heading', $this->preview_email_template_tags($this->get_email_header($form_id)));
717 716
 
718 717
 			// Format plain content type email.
719
-			if ( 'text/plain' === $content_type ) {
720
-				Give()->emails->__set( 'html', false );
721
-				Give()->emails->__set( 'template', 'none' );
722
-				$message = strip_tags( $message );
718
+			if ('text/plain' === $content_type) {
719
+				Give()->emails->__set('html', false);
720
+				Give()->emails->__set('template', 'none');
721
+				$message = strip_tags($message);
723 722
 			}
724 723
 
725
-			if ( Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ) {
724
+			if (Give_Email_Notification_Util::can_use_form_email_options($this, $form_id)) {
726 725
 				Give()->emails->form_id      = $form_id;
727
-				Give()->emails->from_name    = give_get_meta( $form_id, '_give_from_name', true );
728
-				Give()->emails->from_address = give_get_meta( $form_id, '_give_from_email', true );
726
+				Give()->emails->from_name    = give_get_meta($form_id, '_give_from_name', true);
727
+				Give()->emails->from_address = give_get_meta($form_id, '_give_from_email', true);
729 728
 			}
730 729
 
731 730
 			return $send
732
-				? Give()->emails->send( $this->get_preview_email_recipient( $form_id ), $subject, $message, $attachments )
731
+				? Give()->emails->send($this->get_preview_email_recipient($form_id), $subject, $message, $attachments)
733 732
 				: false;
734 733
 		}
735 734
 
@@ -751,7 +750,7 @@  discard block
 block discarded – undo
751 750
 		 *
752 751
 		 * @return bool
753 752
 		 */
754
-		public function send_email_notification( $email_tag_args = array() ) {
753
+		public function send_email_notification($email_tag_args = array()) {
755 754
 			// Add email content type email tags.
756 755
 			$email_tag_args['email_content_type'] = $this->config['content_type'];
757 756
 
@@ -760,16 +759,16 @@  discard block
 block discarded – undo
760 759
 			 *
761 760
 			 * @since 2.0
762 761
 			 */
763
-			$email_tag_args = apply_filters( "give_{$this->config['id']}_email_tag_args", $email_tag_args, $this );
762
+			$email_tag_args = apply_filters("give_{$this->config['id']}_email_tag_args", $email_tag_args, $this);
764 763
 
765 764
 			// Get form id.
766
-			$form_id = ! empty( $email_tag_args['form_id'] )
767
-				? absint( $email_tag_args['form_id'] )
768
-				: ( ! empty( $email_tag_args['payment_id'] ) ? give_get_payment_form_id( $email_tag_args['payment_id'] ) : null );
765
+			$form_id = ! empty($email_tag_args['form_id'])
766
+				? absint($email_tag_args['form_id'])
767
+				: ( ! empty($email_tag_args['payment_id']) ? give_get_payment_form_id($email_tag_args['payment_id']) : null);
769 768
 
770 769
 
771 770
 			// Do not send email if notification is disable.
772
-			if ( ! Give_Email_Notification_Util::is_email_notification_active( $this, $form_id ) ) {
771
+			if ( ! Give_Email_Notification_Util::is_email_notification_active($this, $form_id)) {
773 772
 				return false;
774 773
 			}
775 774
 
@@ -778,33 +777,33 @@  discard block
 block discarded – undo
778 777
 			 *
779 778
 			 * @since 2.0
780 779
 			 */
781
-			do_action( "give_{$this->config['id']}_email_send_before", $this, $form_id );
780
+			do_action("give_{$this->config['id']}_email_send_before", $this, $form_id);
782 781
 
783 782
 			$attachments  = $this->get_email_attachments();
784
-			$message      = give_do_email_tags( $this->get_email_message( $form_id ), $email_tag_args );
785
-			$subject      = give_do_email_tags( $this->get_email_subject( $form_id ), $email_tag_args );
786
-			$content_type = $this->get_email_content_type( $form_id );
783
+			$message      = give_do_email_tags($this->get_email_message($form_id), $email_tag_args);
784
+			$subject      = give_do_email_tags($this->get_email_subject($form_id), $email_tag_args);
785
+			$content_type = $this->get_email_content_type($form_id);
787 786
 
788 787
 			// Setup email content type.
789
-			Give()->emails->__set( 'content_type', $content_type );
790
-			Give()->emails->__set( 'html', true );
788
+			Give()->emails->__set('content_type', $content_type);
789
+			Give()->emails->__set('html', true);
791 790
 
792 791
 			// Set email template.
793
-			Give()->emails->__set( 'template', $this->get_email_template( $form_id ) );
792
+			Give()->emails->__set('template', $this->get_email_template($form_id));
794 793
 
795 794
 			// Set email header.
796
-			Give()->emails->__set( 'heading', give_do_email_tags( $this->get_email_header( $form_id ), $email_tag_args ) );
795
+			Give()->emails->__set('heading', give_do_email_tags($this->get_email_header($form_id), $email_tag_args));
797 796
 
798
-			if ( 'text/plain' === $content_type ) {
799
-				Give()->emails->__set( 'html', false );
800
-				Give()->emails->__set( 'template', 'none' );
801
-				$message = strip_tags( $message );
797
+			if ('text/plain' === $content_type) {
798
+				Give()->emails->__set('html', false);
799
+				Give()->emails->__set('template', 'none');
800
+				$message = strip_tags($message);
802 801
 			}
803 802
 
804
-			if ( Give_Email_Notification_Util::can_use_form_email_options( $this, $form_id ) ) {
803
+			if (Give_Email_Notification_Util::can_use_form_email_options($this, $form_id)) {
805 804
 				Give()->emails->form_id      = $form_id;
806
-				Give()->emails->from_name    = give_get_meta( $form_id, '_give_from_name', true );
807
-				Give()->emails->from_address = give_get_meta( $form_id, '_give_from_email', true );
805
+				Give()->emails->from_name    = give_get_meta($form_id, '_give_from_name', true);
806
+				Give()->emails->from_address = give_get_meta($form_id, '_give_from_email', true);
808 807
 			}
809 808
 
810 809
 			// Send email.
@@ -815,8 +814,8 @@  discard block
 block discarded – undo
815 814
 			 *
816 815
 			 * @since 2.2.3
817 816
 			 */
818
-			if ( apply_filters( 'give_is_send_email_notification', true, $this ) ) {
819
-				$email_status = Give()->emails->send( $this->get_recipient( $form_id ), $subject, $message, $attachments );
817
+			if (apply_filters('give_is_send_email_notification', true, $this)) {
818
+				$email_status = Give()->emails->send($this->get_recipient($form_id), $subject, $message, $attachments);
820 819
 			}
821 820
 
822 821
 			/**
@@ -824,7 +823,7 @@  discard block
 block discarded – undo
824 823
 			 *
825 824
 			 * @since 2.0
826 825
 			 */
827
-			do_action( "give_{$this->config['id']}_email_send_after", $email_status, $this, $form_id );
826
+			do_action("give_{$this->config['id']}_email_send_after", $email_status, $this, $form_id);
828 827
 
829 828
 			return $email_status;
830 829
 		}
@@ -839,63 +838,63 @@  discard block
 block discarded – undo
839 838
 		 *
840 839
 		 * @return string
841 840
 		 */
842
-		public function preview_email_template_tags( $message ) {
841
+		public function preview_email_template_tags($message) {
843 842
 			// Set Payment.
844
-			$payment_id = give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'preview_id' );
845
-			$payment    = $payment_id ? new Give_Payment( $payment_id ) : new stdClass();
843
+			$payment_id = give_check_variable(give_clean($_GET), 'isset_empty', 0, 'preview_id');
844
+			$payment    = $payment_id ? new Give_Payment($payment_id) : new stdClass();
846 845
 
847 846
 			// Set donor.
848 847
 			$user_id = $payment_id
849 848
 				? $payment->user_id
850
-				: give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'user_id' );
849
+				: give_check_variable(give_clean($_GET), 'isset_empty', 0, 'user_id');
851 850
 			$user_id = $user_id ? $user_id : wp_get_current_user()->ID;
852 851
 
853 852
 			// Set receipt.
854
-			$receipt_id = strtolower( md5( uniqid() ) );
853
+			$receipt_id = strtolower(md5(uniqid()));
855 854
 
856
-			$receipt_link_url = esc_url( add_query_arg( array(
855
+			$receipt_link_url = esc_url(add_query_arg(array(
857 856
 				'payment_key' => $receipt_id,
858
-			), give_get_history_page_uri() ) );
857
+			), give_get_history_page_uri()));
859 858
 
860 859
 			$receipt_link = sprintf(
861 860
 				'<a href="%1$s">%2$s</a>',
862 861
 				$receipt_link_url,
863
-				esc_html__( 'View the receipt in your browser &raquo;', 'give' )
862
+				esc_html__('View the receipt in your browser &raquo;', 'give')
864 863
 			);
865 864
 
866 865
 			// Set default values for tags.
867 866
 			$this->config['preview_email_tags_values'] = wp_parse_args(
868 867
 				$this->config['preview_email_tags_values'],
869 868
 				array(
870
-					'name'                     => give_email_tag_first_name( array(
869
+					'name'                     => give_email_tag_first_name(array(
871 870
 						'payment_id' => $payment_id,
872 871
 						'user_id'    => $user_id,
873
-					) ),
874
-					'fullname'                 => give_email_tag_fullname( array(
872
+					)),
873
+					'fullname'                 => give_email_tag_fullname(array(
875 874
 						'payment_id' => $payment_id,
876 875
 						'user_id'    => $user_id,
877
-					) ),
878
-					'username'                 => give_email_tag_username( array(
876
+					)),
877
+					'username'                 => give_email_tag_username(array(
879 878
 						'payment_id' => $payment_id,
880 879
 						'user_id'    => $user_id,
881
-					) ),
882
-					'user_email'               => give_email_tag_user_email( array(
880
+					)),
881
+					'user_email'               => give_email_tag_user_email(array(
883 882
 						'payment_id' => $payment_id,
884 883
 						'user_id'    => $user_id,
885
-					) ),
886
-					'payment_total'            => $payment_id ? give_email_tag_payment_total( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ),
887
-					'amount'                   => $payment_id ? give_email_tag_amount( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ),
888
-					'price'                    => $payment_id ? give_email_tag_price( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ),
889
-					'payment_method'           => $payment_id ? give_email_tag_payment_method( array( 'payment_id' => $payment_id ) ) : __( 'PayPal', 'give' ),
884
+					)),
885
+					'payment_total'            => $payment_id ? give_email_tag_payment_total(array('payment_id' => $payment_id)) : give_currency_filter('10.50'),
886
+					'amount'                   => $payment_id ? give_email_tag_amount(array('payment_id' => $payment_id)) : give_currency_filter('10.50'),
887
+					'price'                    => $payment_id ? give_email_tag_price(array('payment_id' => $payment_id)) : give_currency_filter('10.50'),
888
+					'payment_method'           => $payment_id ? give_email_tag_payment_method(array('payment_id' => $payment_id)) : __('PayPal', 'give'),
890 889
 					'receipt_id'               => $receipt_id,
891
-					'payment_id'               => $payment_id ? $payment_id : rand( 2000, 2050 ),
890
+					'payment_id'               => $payment_id ? $payment_id : rand(2000, 2050),
892 891
 					'receipt_link_url'         => $receipt_link_url,
893 892
 					'receipt_link'             => $receipt_link,
894
-					'date'                     => $payment_id ? date( give_date_format(), strtotime( $payment->date ) ) : date( give_date_format(), current_time( 'timestamp' ) ),
895
-					'donation'                 => $payment_id ? give_email_tag_donation( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title', 'give' ),
896
-					'form_title'               => $payment_id ? give_email_tag_form_title( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ),
897
-					'sitename'                 => $payment_id ? give_email_tag_sitename( array( 'payment_id' => $payment_id ) ) : get_bloginfo( 'name' ),
898
-					'billing_address'         => $payment_id ? give_email_tag_billing_address( array( 'payment_id' => $payment_id ) ) : '',
893
+					'date'                     => $payment_id ? date(give_date_format(), strtotime($payment->date)) : date(give_date_format(), current_time('timestamp')),
894
+					'donation'                 => $payment_id ? give_email_tag_donation(array('payment_id' => $payment_id)) : esc_html__('Sample Donation Form Title', 'give'),
895
+					'form_title'               => $payment_id ? give_email_tag_form_title(array('payment_id' => $payment_id)) : esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'),
896
+					'sitename'                 => $payment_id ? give_email_tag_sitename(array('payment_id' => $payment_id)) : get_bloginfo('name'),
897
+					'billing_address'         => $payment_id ? give_email_tag_billing_address(array('payment_id' => $payment_id)) : '',
899 898
 					'email_access_link'       => sprintf(
900 899
 						'<a href="%1$s">%2$s</a>',
901 900
 						add_query_arg(
@@ -904,13 +903,13 @@  discard block
 block discarded – undo
904 903
 							),
905 904
 							give_get_history_page_uri()
906 905
 						),
907
-						__( 'View your donation history &raquo;', 'give' )
906
+						__('View your donation history &raquo;', 'give')
908 907
 					),
909
-					'reset_password_link'     => $user_id ? give_email_tag_reset_password_link( array( 'user_id' => $user_id ), $payment_id ) : '',
908
+					'reset_password_link'     => $user_id ? give_email_tag_reset_password_link(array('user_id' => $user_id), $payment_id) : '',
910 909
 					'site_url'                => sprintf(
911 910
 						'<a href="%1$s">%2$s</a>',
912
-						get_bloginfo( 'url' ),
913
-						get_bloginfo( 'url' )
911
+						get_bloginfo('url'),
912
+						get_bloginfo('url')
914 913
 					),
915 914
 					'admin_email'             => give_email_admin_email(),
916 915
 					'offline_mailing_address' => give_email_offline_mailing_address(),
@@ -918,13 +917,13 @@  discard block
 block discarded – undo
918 917
 			);
919 918
 
920 919
 			// Decode tags.
921
-			foreach ( $this->config['preview_email_tags_values'] as $preview_tag => $value ) {
922
-				if ( isset( $this->config['preview_email_tags_values'][ $preview_tag ] ) ) {
923
-					$message = str_replace( "{{$preview_tag}}", $this->config['preview_email_tags_values'][ $preview_tag ], $message );
920
+			foreach ($this->config['preview_email_tags_values'] as $preview_tag => $value) {
921
+				if (isset($this->config['preview_email_tags_values'][$preview_tag])) {
922
+					$message = str_replace("{{$preview_tag}}", $this->config['preview_email_tags_values'][$preview_tag], $message);
924 923
 				}
925 924
 			}
926 925
 
927
-			return apply_filters( 'give_email_preview_template_tags', $message );
926
+			return apply_filters('give_email_preview_template_tags', $message);
928 927
 		}
929 928
 
930 929
 		/**
@@ -949,17 +948,17 @@  discard block
 block discarded – undo
949 948
 		 * @param $post_id
950 949
 		 *
951 950
 		 */
952
-		public function validate_form_recipient_field_value( $form_meta_key, $form_meta_value, $post_id ) {
951
+		public function validate_form_recipient_field_value($form_meta_key, $form_meta_value, $post_id) {
953 952
 			// Get valid emails.
954
-			$new_form_meta_value = array_filter( $form_meta_value, function ( $value ) {
955
-				return ! empty( $value['email'] ) && is_email( $value['email'] );
953
+			$new_form_meta_value = array_filter($form_meta_value, function($value) {
954
+				return ! empty($value['email']) && is_email($value['email']);
956 955
 			} );
957 956
 
958 957
 			// Remove duplicate emails from array.
959 958
 			$email_arr = array();
960
-			foreach ( $new_form_meta_value as $index => $email ) {
961
-				if( in_array( $email['email'], $email_arr  ) ) {
962
-					unset( $new_form_meta_value[$index] );
959
+			foreach ($new_form_meta_value as $index => $email) {
960
+				if (in_array($email['email'], $email_arr)) {
961
+					unset($new_form_meta_value[$index]);
963 962
 					continue;
964 963
 				}
965 964
 
@@ -968,25 +967,25 @@  discard block
 block discarded – undo
968 967
 
969 968
 			$update = false;
970 969
 
971
-			if ( empty( $new_form_meta_value ) ) {
970
+			if (empty($new_form_meta_value)) {
972 971
 				// Set default recipient.
973 972
 				$form_meta_value = array(
974 973
 					array(
975
-						'email' => get_bloginfo( 'admin_email' )
974
+						'email' => get_bloginfo('admin_email')
976 975
 					),
977 976
 				);
978 977
 
979 978
 				$update = true;
980 979
 
981
-			} elseif ( count( $new_form_meta_value ) !== count( $form_meta_value ) ) {
980
+			} elseif (count($new_form_meta_value) !== count($form_meta_value)) {
982 981
 				// Filter recipient emails.
983 982
 				$form_meta_value = $new_form_meta_value;
984 983
 
985 984
 				$update = true;
986 985
 			}
987 986
 
988
-			if( $update ) {
989
-				give_update_meta( $post_id, $form_meta_key, $form_meta_value );
987
+			if ($update) {
988
+				give_update_meta($post_id, $form_meta_key, $form_meta_value);
990 989
 			}
991 990
 		}
992 991
 	}
Please login to merge, or discard this patch.