Completed
Push — issues/611 ( 5f4e1c...15a365 )
by Ravinder
19:47
created

Give_Email_Notification::get_recipient()   B

Complexity

Conditions 3
Paths 2

Size

Total Lines 30
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 12
nc 2
nop 1
dl 0
loc 30
rs 8.8571
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 27 and the first side effect is on line 16.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Email Notification
4
 *
5
 * This class handles all email notification settings.
6
 *
7
 * @package     Give
8
 * @subpackage  Classes/Emails
9
 * @copyright   Copyright (c) 2016, WordImpress
10
 * @license     https://opensource.org/licenses/gpl-license GNU Public License
11
 * @since       2.0
12
 */
13
14
// Exit if access directly.
15
if ( ! defined( 'ABSPATH' ) ) {
16
	exit;
17
}
18
19
if ( ! class_exists( 'Give_Email_Notification' ) ) :
20
21
	/**
22
	 * Give_Email_Notification
23
	 *
24
	 * @abstract
25
	 * @since       2.0
26
	 */
27
	abstract class Give_Email_Notification {
28
		/**
29
		 * Array of instances
30
		 *
31
		 * @since  2.0
32
		 * @access private
33
		 * @var array
34
		 */
35
		private static $singleton = array();
36
37
38
		/**
39
		 * Array of notification settings.
40
		 *
41
		 * @since  2.0
42
		 * @access public
43
		 * @var array
44
		 */
45
		public $config = array(
46
			'id'                           => '',
47
			'label'                        => '',
48
			'description'                  => '',
49
			'has_recipient_field'          => false,
50
			'recipient_group_name'         => '',
51
			'notification_status'          => 'disabled',
52
			'notification_status_editable' => true,
53
			'notices'                      => array(),
54
			'content_type_editable'        => true,
55
			'has_preview'                  => true,
56
			'has_preview_header'           => true,
57
			'preview_email_tags_values'    => array(),
58
			'email_tag_context'            => 'all',
59
			'form_metabox_setting'         => true,
60
			'content_type'                 => '',
61
			'email_template'               => '',
62
			'default_email_subject'        => '',
63
			'default_email_message'        => '',
64
		);
65
66
		/**
67
		 * @var     string $recipient_email Donor email.
68
		 * @access  protected
69
		 * @since   2.0
70
		 */
71
		protected $recipient_email = '';
72
73
74
		/**
75
		 * Setup email notification.
76
		 *
77
		 * @since 2.0
78
		 */
79
		public function init() {
80
81
		}
82
83
84
		/**
85
		 * Get instance.
86
		 *
87
		 * @since  2.0
88
		 * @access public
89
		 *
90
		 * @param string $email_notification_id
91
		 *
92
		 * @return Give_Email_Notification
93
		 */
94
		public static function get_instance( $email_notification_id = '' ) {
95
			$class = '';
96
97
			if ( ! empty( $email_notification_id ) ) {
98
				/* @var Give_Email_Notification $class */
99
				foreach ( self::$singleton as $class ) {
100
					if ( $email_notification_id === $class->config['id'] ) {
101
						$class = get_class( $class );
102
						break;
103
					}
104
				}
105
			} else {
106
				$class = get_called_class();
107
			}
108
109
			if ( ! empty( $class ) && ( ! array_key_exists( $class, self::$singleton ) || is_null( self::$singleton[ $class ] ) ) ) {
110
				self::$singleton[ $class ] = new $class();
111
			}
112
113
			return ( isset( self::$singleton[ $class ] ) ? self::$singleton[ $class ] : null );
114
		}
115
116
		/**
117
		 * Setup action and filters.
118
		 *
119
		 * @access  public
120
		 * @since   2.0
121
		 *
122
		 * @param array $config
123
		 */
124
		public function load( $config ) {
125
			// Set notification configuration.
126
			$this->config = wp_parse_args( $config, $this->config );
127
128
			// Set email preview header status.
129
			$this->config['has_preview_header'] = $this->config['has_preview'] && $this->config['has_preview_header'] ? true : false;
130
131
			// Set email content type
132
			$this->config['content_type'] = empty( $this->config['content_type'] ) || ! in_array( $this->config['content_type'], array(
133
				'text/html',
134
				'text/plain',
135
			) )
136
				? Give()->emails->get_content_type()
137
				: $this->config['content_type'];
138
			$this->config['content_type'] = give_get_option( "{$this->config['id']}_email_content_type", $this->config['content_type'] );
139
140
			// Set email template type.
141
			$this->config['email_template'] = empty( $this->config['email_template'] )
142
				? give_get_option( 'email_template' )
143
				: $this->config['email_template'];
144
145
			// Set recipient group name.
146
			$this->config['recipient_group_name'] = empty( $this->config['recipient_group_name'] )
147
				? ( ! Give_Email_Notification_Util::has_recipient_field( $this ) ? __( 'Donor', 'give' ) : '' )
148
				: $this->config['recipient_group_name'];
149
150
			// Non notification status editable notice.
151
			$this->config['notices']['non-notification-status-editable'] = empty( $this->config['notices']['non-notification-status-editable'] )
152
				? __( 'You can not edit this notification directly. This will be enable or disable automatically on basis of plugin settings.', 'give' )
153
				: $this->config['notices']['non-notification-status-editable'];
154
155
			/**
156
			 *  Filter the notification config.
157
			 *
158
			 * @since 2.0
159
			 *
160
			 * @param                         array                   Give_Email_Notification::config
161
			 * @param Give_Email_Notification $this
162
			 */
163
			$this->config = apply_filters( 'give_email_api_notification_config', $this->config, $this );
164
165
			// Setup filters.
166
			$this->setup_filters();
167
		}
168
169
170
		/**
171
		 * Setup filters.
172
		 *
173
		 * @since  2.0
174
		 * @access public
175
		 */
176
		private function setup_filters() {
177
			// Apply filter only for current email notification section.
178
			if ( give_get_current_setting_section() === $this->config['id'] ) {
179
				// Initialize email context for email notification.
180
				$this->config['email_tag_context'] = apply_filters(
181
					"give_{$this->config['id']}_email_tag_context",
182
					$this->config['email_tag_context'],
183
					$this
184
				);
185
			}
186
187
			// Setup setting fields.
188
			add_filter( 'give_get_settings_emails', array( $this, 'add_setting_fields' ), 10, 2 );
189
190
			if ( $this->config['form_metabox_setting'] ) {
191
				add_filter(
192
					'give_email_notification_options_metabox_fields',
193
					array( $this, 'add_metabox_setting_field' ),
194
					10,
195
					2
196
				);
197
			}
198
199
			/**
200
			 * Filter the default email subject.
201
			 *
202
			 * @since 2.0
203
			 */
204
			$this->config['default_email_subject'] = apply_filters(
205
				"give_{$this->config['id']}_get_default_email_subject",
206
				$this->config['default_email_subject'],
207
				$this
208
			);
209
210
			/**
211
			 * Filter the default email message.
212
			 *
213
			 * @since 2.0
214
			 */
215
			$this->config['default_email_message'] = apply_filters(
216
				"give_{$this->config['id']}_get_default_email_message",
217
				$this->config['default_email_message'],
218
				$this
219
			);
220
		}
221
222
		/**
223
		 * Add sections.
224
		 *
225
		 * @since 2.0
226
		 *
227
		 * @param array $sections
228
		 *
229
		 * @return array
230
		 */
231
		public function add_section( $sections ) {
232
			$sections[ $this->config['id'] ] = $this->config['label'];
233
234
			return $sections;
235
		}
236
237
		/**
238
		 * Add sections.
239
		 *
240
		 * @since 2.0
241
		 *
242
		 * @param bool $hide_section
243
		 *
244
		 * @return bool
245
		 */
246
		public function hide_section( $hide_section ) {
0 ignored issues
show
Unused Code introduced by
The parameter $hide_section is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
247
			$hide_section = true;
248
249
			return $hide_section;
250
		}
251
252
		/**
253
		 * Register email settings.
254
		 *
255
		 * @since  2.0
256
		 * @access public
257
		 *
258
		 * @param   array $settings
259
		 *
260
		 * @return  array
261
		 */
262
		public function add_setting_fields( $settings ) {
263
			if ( $this->config['id'] === give_get_current_setting_section() ) {
264
				$settings = $this->get_setting_fields();
265
			}
266
267
			return $settings;
268
		}
269
270
271
		/**
272
		 * Get setting fields
273
		 *
274
		 * @since  2.0
275
		 * @access public
276
		 *
277
		 * @param int $form_id
278
		 *
279
		 * @return array
280
		 */
281
		public function get_setting_fields( $form_id = null ) {
282
			return Give_Email_Setting_Field::get_setting_fields( $this, $form_id );
283
		}
284
285
286
		/**
287
		 * Register email settings to form metabox.
288
		 *
289
		 * @since  2.0
290
		 * @access public
291
		 *
292
		 * @param array $settings
293
		 * @param int   $form_id
294
		 *
295
		 * @return array
296
		 */
297
		public function add_metabox_setting_field( $settings, $form_id ) {
298
299
			$settings[] = array(
300
				'id'     => $this->config['id'],
301
				'title'  => $this->config['label'],
302
				'fields' => $this->get_setting_fields( $form_id ),
303
			);
304
305
			return $settings;
306
		}
307
308
309
		/**
310
		 * Get extra setting field.
311
		 *
312
		 * @since  2.0
313
		 * @access public
314
		 *
315
		 * @param int $form_id
316
		 *
317
		 * @return array
318
		 */
319
		public function get_extra_setting_fields( $form_id = null ) {
0 ignored issues
show
Unused Code introduced by
The parameter $form_id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
320
			return array();
321
		}
322
323
324
		/**
325
		 * Get recipient(s).
326
		 *
327
		 * Note: in case of admin notification this fx will return array of emails otherwise empty string or email of donor.
328
		 *
329
		 * @since  2.0
330
		 * @access public
331
		 *
332
		 * @param int $form_id
333
		 *
334
		 * @return string|array
335
		 */
336
		public function get_recipient( $form_id = null ) {
337
			if ( empty( $this->recipient_email ) && $this->config['has_recipient_field'] ) {
338
				$this->recipient_email = Give_Email_Notification_Util::get_value( $this, "{$this->config['id']}_recipient", $form_id );
339
340
341
				/**
342
				 * Filter the admin notice emails.
343
				 *
344
				 * @since 1.0
345
				 * @deprecated 2.0
346
				 */
347
				$this->recipient_email = apply_filters( 'give_admin_notice_emails', $this->recipient_email, $this, $form_id );
348
			}
349
350
			/**
351
			 * Filter the recipients
352
			 *
353
			 * @since 2.0
354
			 */
355
			return apply_filters(
356
				"give_{$this->config['id']}_get_recipients",
357
				give_check_variable(
358
					$this->recipient_email,
359
					'empty',
360
					Give()->emails->get_from_address()
361
				),
362
				$this,
363
				$form_id
364
			);
365
		}
366
367
		/**
368
		 * Get notification status.
369
		 *
370
		 * @since  2.0
371
		 * @access public
372
		 *
373
		 * @param int $form_id
374
		 *
375
		 * @return bool
376
		 */
377
		public function get_notification_status( $form_id = null ) {
378
			$notification_status = empty( $form_id )
379
				? give_get_option( "{$this->config['id']}_notification", $this->config['notification_status'] )
380
				: get_post_meta( $form_id, "{$this->config['id']}_notification", true );
381
382
			/**
383
			 * Filter the notification status.
384
			 *
385
			 * @since 1.8
386
			 */
387
			return apply_filters(
388
				"give_{$this->config['id']}_get_notification_status",
389
				$notification_status,
390
				$this,
391
				$form_id
392
			);
393
		}
394
395
		/**
396
		 * Get email subject.
397
		 *
398
		 * @since  2.0
399
		 * @access public
400
		 *
401
		 * @param int $form_id
402
		 *
403
		 * @return string
404
		 */
405
		function get_email_subject( $form_id = null ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
406
			$subject = wp_strip_all_tags(
407
				Give_Email_Notification_Util::get_value(
408
					$this,
409
					"{$this->config['id']}_email_subject",
410
					$form_id,
411
					$this->config['default_email_subject']
412
				)
413
			);
414
415
			/**
416
			 * Filter the subject.
417
			 *
418
			 * @since 2.0
419
			 */
420
			return apply_filters(
421
				"give_{$this->config['id']}_get_email_subject",
422
				$subject,
423
				$this,
424
				$form_id
425
			);
426
		}
427
428
		/**
429
		 * Get email message.
430
		 *
431
		 * @since  2.0
432
		 * @access public
433
		 *
434
		 * @param int $form_id
435
		 *
436
		 * @return string
437
		 */
438
		public function get_email_message( $form_id = null ) {
439
			$message = Give_Email_Notification_Util::get_value(
440
				$this,
441
				"{$this->config['id']}_email_message",
442
				$form_id,
443
				$this->config['default_email_message']
444
			);
445
446
			/**
447
			 * Filter the message.
448
			 *
449
			 * @since 2.0
450
			 */
451
			return apply_filters(
452
				"give_{$this->config['id']}_get_email_message",
453
				$message,
454
				$this,
455
				$form_id
456
			);
457
		}
458
459
460
		/**
461
		 * Get email content type.
462
		 *
463
		 * @since  2.0
464
		 * @access public
465
		 *
466
		 * @param $form_id
467
		 *
468
		 * @return string
469
		 */
470
		public function get_email_content_type( $form_id ) {
471
			$content_type = Give_Email_Notification_Util::get_value(
472
				$this,
473
				"{$this->config['id']}_email_content_type",
474
				$form_id,
475
				$this->config['content_type']
476
			);
477
478
			/**
479
			 * Filter the email content type.
480
			 *
481
			 * @since 2.0
482
			 */
483
			return apply_filters(
484
				"give_{$this->config['id']}_get_email_content_type",
485
				$content_type,
486
				$this,
487
				$form_id
488
			);
489
		}
490
491
		/**
492
		 * Get email template.
493
		 *
494
		 * @since  2.0
495
		 * @access public
496
		 *
497
		 * @param $form_id
498
		 *
499
		 * @return string
500
		 */
501
		public function get_email_template( $form_id ) {
502
			$content_type = Give_Email_Notification_Util::get_value(
503
				$this,
504
				"{$this->config['id']}_email_template",
505
				$form_id,
506
				$this->config['email_template']
507
			);
508
509
			/**
510
			 * Filter the email template.
511
			 *
512
			 * @since 2.0
513
			 */
514
			return apply_filters(
515
				"give_{$this->config['id']}_get_email_template",
516
				$content_type,
517
				$this,
518
				$form_id
519
			);
520
		}
521
522
523
		/**
524
		 * Get allowed email tags for current email notification.
525
		 *
526
		 * @since  2.0
527
		 * @access private
528
		 *
529
		 * @param bool $formatted
530
		 *
531
		 * @return array
0 ignored issues
show
Documentation introduced by
Should the return type not be string|array?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
532
		 */
533
		public function get_allowed_email_tags( $formatted = false ) {
534
			// Get all email tags.
535
			$email_tags = Give()->email_tags->get_tags();
536
537
			// Skip if all email template tags context setup exit.
538
			if ( $this->config['email_tag_context'] && 'all' !== $this->config['email_tag_context'] ) {
539
				if ( is_array( $this->config['email_tag_context'] ) ) {
540
					foreach ( $email_tags as $index => $email_tag ) {
541
						if ( in_array( $email_tag['context'], $this->config['email_tag_context'] ) ) {
542
							continue;
543
						}
544
545
						unset( $email_tags[ $index ] );
546
					}
547
				} else {
548
					foreach ( $email_tags as $index => $email_tag ) {
549
						if ( $this->config['email_tag_context'] === $email_tag['context'] ) {
550
							continue;
551
						}
552
553
						unset( $email_tags[ $index ] );
554
					}
555
				}
556
			}
557
558
			if ( count( $email_tags ) && $formatted ) : ob_start() ?>
559
				<div class="give-email-tags-wrap">
560
					<?php foreach ( $email_tags as $email_tag ) : ?>
561
						<span class="give_<?php echo $email_tag['tag']; ?>_tag">
562
							<code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?>
563
						</span>
564
					<?php endforeach; ?>
565
				</div>
566
				<?php
567
				$email_tags = ob_get_clean();
568
			endif;
569
570
			return $email_tags;
571
		}
572
573
		/**
574
		 * Get preview email recipients.
575
		 *
576
		 * @since  2.0
577
		 * @access public
578
		 *
579
		 * @param int $form_id
580
		 *
581
		 * @return array|string
582
		 */
583
		public function get_preview_email_recipient( $form_id = null ) {
584
			$recipients = $this->get_recipient( $form_id );
585
586
			/**
587
			 * Filter the preview email recipients.
588
			 *
589
			 * @since 2.0
590
			 *
591
			 * @param string|array            $recipients List of recipients.
592
			 * @param Give_Email_Notification $this
593
			 */
594
			$recipients = apply_filters( 'give_get_preview_email_recipient', $recipients, $this, $form_id );
595
596
			return $recipients;
597
		}
598
599
		/**
600
		 * Get the recipient attachments.
601
		 *
602
		 * @since  2.0
603
		 * @access public
604
		 *
605
		 * @param int $form_id
606
		 *
607
		 * @return array
608
		 */
609
		public function get_email_attachments( $form_id = null ) {
610
			/**
611
			 * Filter the attachment.
612
			 *
613
			 * @since 2.0
614
			 */
615
			return apply_filters( "give_{$this->config['id']}_get_email_attachments", array(), $this, $form_id );
616
		}
617
618
619
		/**
620
		 * Send preview email.
621
		 *
622
		 * @since  2.0
623
		 * @access public
624
		 */
625
		public function send_preview_email() {
626
			// Get form id
627
			$form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null;
628
629
			// setup email data.
630
			$this->setup_email_data();
631
632
			$attachments  = $this->get_email_attachments();
633
			$message      = $this->preview_email_template_tags( $this->get_email_message( $form_id ) );
634
			$subject      = $this->preview_email_template_tags( $this->get_email_subject( $form_id ) );
635
			$content_type = $this->get_email_content_type( $form_id );
636
637
			// Setup email content type.
638
			Give()->emails->__set( 'content_type', $content_type );
639
			Give()->emails->__set( 'html', true );
640
641
			// Setup email template
642
			Give()->emails->__set( 'template', $this->get_email_template( $form_id ) );
643
644
			// Format plain content type email.
645
			if ( 'text/plain' === $content_type ) {
646
				Give()->emails->__set( 'html', false );
647
				Give()->emails->__set( 'template', 'none' );
648
				$message = strip_tags( $message );
649
			}
650
651
			return Give()->emails->send( $this->get_preview_email_recipient( $form_id ), $subject, $message, $attachments );
652
		}
653
654
655
		/**
656
		 * Send email notification.
657
		 *
658
		 * Note: To render email tags in all context certain parameters are necessary for core (includes/emails/class-give-emails):
659
		 *    1. payment_id
660
		 *    2. user_id
661
		 *    3. form_id
662
		 *    4. donor_id
663
		 *    5. for third party email tags you can pass necessary param along above parameters other value replace by empty string.
664
		 *
665
		 * @since  2.0
666
		 * @access public
667
		 *
668
		 * @param array $email_tag_args Arguments which helps to decode email template tags.
669
		 *
670
		 * @return bool
671
		 */
672
		public function send_email_notification( $email_tag_args = array() ) {
673
			// Add email content type email tags.
674
			$email_tag_args['email_content_type'] = $this->config['content_type'];
675
676
			/**
677
			 * Filter the email tag args
678
			 *
679
			 * @since 2.0
680
			 */
681
			$email_tag_args = apply_filters( "give_{$this->config['id']}_email_tag_args", $email_tag_args, $this );
682
683
			// Get form id.
684
			$form_id = ! empty( $email_tag_args['form_id'] )
685
				? absint( $email_tag_args['form_id'] )
686
				: ( ! empty( $email_tag_args['payment_id'] ) ? give_get_payment_form_id( $email_tag_args['payment_id'] ) : null );
687
688
689
			// Do not send email if notification is disable.
690
			if ( ! Give_Email_Notification_Util::is_email_notification_active( $this, $form_id ) ) {
691
				return false;
692
			}
693
694
			/**
695
			 * Fire action after before email send.
696
			 *
697
			 * @since 2.0
698
			 */
699
			do_action( "give_{$this->config['id']}_email_send_before", $this, $form_id );
700
701
			$attachments  = $this->get_email_attachments();
702
			$message      = give_do_email_tags( $this->get_email_message( $form_id ), $email_tag_args );
703
			$subject      = give_do_email_tags( $this->get_email_subject( $form_id ), $email_tag_args );
704
			$content_type = $this->get_email_content_type( $form_id );
705
706
			// Setup email content type.
707
			Give()->emails->__set( 'content_type', $content_type );
708
			Give()->emails->__set( 'html', true );
709
710
			// Set email template.
711
			Give()->emails->__set( 'template', $this->get_email_template( $form_id ) );
712
713
			if ( 'text/plain' === $content_type ) {
714
				Give()->emails->__set( 'html', false );
715
				Give()->emails->__set( 'template', 'none' );
716
				$message = strip_tags( $message );
717
			}
718
719
			// Send email.
720
			$email_status = Give()->emails->send( $this->get_recipient( $form_id ), $subject, $message, $attachments );
721
722
			/**
723
			 * Fire action after after email send.
724
			 *
725
			 * @since 2.0
726
			 */
727
			do_action( "give_{$this->config['id']}_email_send_after", $email_status, $this, $form_id );
728
729
			return $email_status;
730
		}
731
732
733
		/**
734
		 * Decode preview email template tags.
735
		 *
736
		 * @since 2.0
737
		 *
738
		 * @param string $message
739
		 *
740
		 * @return string
741
		 */
742
		public function preview_email_template_tags( $message ) {
743
			// Set Payment.
744
			$payment_id = give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'preview_id' );
745
			$payment    = $payment_id ? new Give_Payment( $payment_id ) : new stdClass();
746
747
			// Set donor.
748
			$user_id = $payment_id
749
				? $payment->user_id
750
				: give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'user_id' );
751
			$user_id = $user_id ? $user_id : wp_get_current_user()->ID;
752
753
			// Set receipt.
754
			$receipt_id = strtolower( md5( uniqid() ) );
755
756
			$receipt_link_url = esc_url( add_query_arg( array(
757
				'payment_key' => $receipt_id,
758
				'give_action' => 'view_receipt',
759
			), home_url() ) );
760
761
			$receipt_link = sprintf(
762
				'<a href="%1$s">%2$s</a>',
763
				$receipt_link_url,
764
				esc_html__( 'View the receipt in your browser &raquo;', 'give' )
765
			);
766
767
			// Set default values for tags.
768
			$this->config['preview_email_tags_values'] = wp_parse_args(
769
				$this->config['preview_email_tags_values'],
770
				array(
771
					'name'              => give_email_tag_first_name( array(
772
						'payment_id' => $payment_id,
773
						'user_id'    => $user_id,
774
					) ),
775
					'fullname'          => give_email_tag_fullname( array(
776
						'payment_id' => $payment_id,
777
						'user_id'    => $user_id,
778
					) ),
779
					'username'          => give_email_tag_username( array(
780
						'payment_id' => $payment_id,
781
						'user_id'    => $user_id,
782
					) ),
783
					'user_email'        => give_email_tag_user_email( array(
784
						'payment_id' => $payment_id,
785
						'user_id'    => $user_id,
786
					) ),
787
					'payment_total'     => $payment_id ? give_email_tag_payment_total( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ),
788
					'amount'            => $payment_id ? give_email_tag_amount( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ),
789
					'price'             => $payment_id ? give_email_tag_price( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ),
790
					'payment_method'    => $payment_id ? give_email_tag_payment_method( array( 'payment_id' => $payment_id ) ) : __( 'PayPal', 'give' ),
791
					'receipt_id'        => $receipt_id,
792
					'payment_id'        => $payment_id ? $payment_id : rand( 2000, 2050 ),
793
					'receipt_link_url'  => $receipt_link_url,
794
					'receipt_link'      => $receipt_link,
795
					'date'              => $payment_id ? date( give_date_format(), strtotime( $payment->date ) ) : date( give_date_format(), current_time( 'timestamp' ) ),
796
					'donation'          => $payment_id ? give_email_tag_donation( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title', 'give' ),
797
					'form_title'        => $payment_id ? give_email_tag_form_title( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ),
798
					'sitename'          => $payment_id ? give_email_tag_sitename( array( 'payment_id' => $payment_id ) ) : get_bloginfo( 'name' ),
799
					'pdf_receipt'       => '<a href="#">Download Receipt</a>',
800
					'billing_address'   => $payment_id ? give_email_tag_billing_address( array( 'payment_id' => $payment_id ) ) : '',
801
					'email_access_link' => sprintf(
802
						'<a href="%1$s">%2$s</a>',
803
						add_query_arg(
804
							array(
805
								'give_nl' => uniqid(),
806
							),
807
							get_permalink( give_get_option( 'history_page' ) )
808
						),
809
						__( 'Access Donation Details &raquo;', 'give' )
810
					),
811
				)
812
			);
813
814
			// Decode tags.
815
			foreach ( $this->config['preview_email_tags_values'] as $preview_tag => $value ) {
816
				if ( isset( $this->config['preview_email_tags_values'][ $preview_tag ] ) ) {
817
					$message = str_replace( "{{$preview_tag}}", $this->config['preview_email_tags_values'][ $preview_tag ], $message );
818
				}
819
			}
820
821
			return apply_filters( 'give_email_preview_template_tags', $message );
822
		}
823
824
		/**
825
		 * Setup email data
826
		 *
827
		 * @since 2.0
828
		 */
829
		public function setup_email_data() {
830
		}
831
	}
832
833
endif; // End class_exists check
834