Completed
Push — issues/611 ( 9fa10b...0a38a6 )
by Ravinder
41:20 queued 21:12
created

Give_Email_Notification::get_email_template()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 1
dl 0
loc 20
rs 9.4285
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
			'has_preview'                  => true,
54
			'has_preview_header'           => true,
55
			'preview_email_tags_values'    => array(),
56
			'email_tag_context'            => 'all',
57
			'form_metabox_setting'         => true,
58
			'content_type'                 => '',
59
			'email_template'               => '',
60
			'default_email_subject'        => '',
61
			'default_email_message'        => '',
62
		);
63
64
		/**
65
		 * @var     string $recipient_email Donor email.
66
		 * @access  protected
67
		 * @since   2.0
68
		 */
69
		protected $recipient_email = '';
70
71
72
		/**
73
		 * Setup email notification.
74
		 *
75
		 * @since 2.0
76
		 */
77
		public function init() {
78
79
		}
80
81
82
		/**
83
		 * Get instance.
84
		 *
85
		 * @since  2.0
86
		 * @access public
87
		 * @return Give_Email_Notification
88
		 */
89
		public static function get_instance() {
90
			$class = get_called_class();
91
			if ( ! array_key_exists( $class, self::$singleton ) || is_null( self::$singleton[ $class ] ) ) {
92
				self::$singleton[ $class ] = new $class();
93
			}
94
95
			return self::$singleton[ $class ];
96
		}
97
98
		/**
99
		 * Setup action and filters.
100
		 *
101
		 * @access  public
102
		 * @since   2.0
103
		 *
104
		 * @param array $config
105
		 */
106
		public function load( $config ) {
107
			// Set notification configuration.
108
			$this->config = wp_parse_args( $config, $this->config );
109
110
			// Set email preview header status.
111
			$this->config['has_preview_header'] = $this->config['has_preview'] && $this->config['has_preview_header'] ? true : false;
112
113
			// Set email content type
114
			$this->config['content_type'] = empty( $this->config['content_type'] ) || ! in_array( $this->config['content_type'], array( 'text/html', 'text/plain', ) )
115
				? Give()->emails->get_content_type()
116
				: $this->config['content_type'];
117
			$this->config['content_type'] = give_get_option( "{$this->config['id']}_email_content_type", $this->config['content_type'] );
118
119
			$this->config['email_template'] = empty( $this->config['email_template'] )
120
				? give_get_option( 'email_template' )
121
				: $this->config['email_template'];
122
123
			/**
124
			 *  Filter the notification config.
125
			 *
126
			 * @since 2.0
127
			 *
128
			 * @param                         array                   Give_Email_Notification::config
129
			 * @param Give_Email_Notification $this
130
			 */
131
			$this->config = apply_filters( 'give_email_api_notification_config', $this->config, $this );
132
133
			// Setup filters.
134
			$this->setup_filters();
135
		}
136
137
138
		/**
139
		 * Setup filters.
140
		 *
141
		 * @since  2.0
142
		 * @access public
143
		 */
144
		private function setup_filters() {
145
			// Apply filter only for current email notification section.
146
			if ( give_get_current_setting_section() === $this->config['id'] ) {
147
				// Initialize email context for email notification.
148
				$this->config['email_tag_context'] = apply_filters(
149
					"give_{$this->config['id']}_email_tag_context",
150
					$this->config['email_tag_context'],
151
					$this
152
				);
153
			}
154
155
			// Setup setting fields.
156
			add_filter( 'give_get_settings_emails', array( $this, 'add_setting_fields' ), 10, 2 );
157
158
			if ( $this->config['form_metabox_setting'] ) {
159
				add_filter(
160
					'give_email_notification_options_metabox_fields',
161
					array( $this, 'add_metabox_setting_field' ),
162
					10,
163
					2
164
				);
165
			}
166
167
			/**
168
			 * Filter the default email subject.
169
			 *
170
			 * @since 2.0
171
			 */
172
			$this->config['default_email_subject'] = apply_filters(
173
				"give_{$this->config['id']}_get_default_email_subject",
174
				$this->config['default_email_subject'],
175
				$this
176
			);
177
178
			/**
179
			 * Filter the default email message.
180
			 *
181
			 * @since 2.0
182
			 */
183
			$this->config['default_email_message'] = apply_filters(
184
				"give_{$this->config['id']}_get_default_email_message",
185
				$this->config['default_email_message'],
186
				$this
187
			);
188
		}
189
190
		/**
191
		 * Add sections.
192
		 *
193
		 * @since 2.0
194
		 *
195
		 * @param array $sections
196
		 *
197
		 * @return array
198
		 */
199
		public function add_section( $sections ) {
200
			$sections[ $this->config['id'] ] = $this->config['label'];
201
202
			return $sections;
203
		}
204
205
		/**
206
		 * Add sections.
207
		 *
208
		 * @since 2.0
209
		 *
210
		 * @param bool $hide_section
211
		 *
212
		 * @return bool
213
		 */
214
		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...
215
			$hide_section = true;
216
217
			return $hide_section;
218
		}
219
220
		/**
221
		 * Register email settings.
222
		 *
223
		 * @since  2.0
224
		 * @access public
225
		 *
226
		 * @param   array $settings
227
		 *
228
		 * @return  array
229
		 */
230
		public function add_setting_fields( $settings ) {
231
			if ( $this->config['id'] === give_get_current_setting_section() ) {
232
				$settings = $this->get_setting_fields();
233
			}
234
235
			return $settings;
236
		}
237
238
239
		/**
240
		 * Get setting fields
241
		 *
242
		 * @since  2.0
243
		 * @access public
244
		 *
245
		 * @param int $form_id
246
		 *
247
		 * @return array
248
		 */
249
		public function get_setting_fields( $form_id = null ) {
250
			return Give_Email_Setting_Field::get_setting_fields( $this, $form_id );
251
		}
252
253
254
		/**
255
		 * Register email settings to form metabox.
256
		 *
257
		 * @since  2.0
258
		 * @access public
259
		 *
260
		 * @param array $settings
261
		 * @param int   $form_id
262
		 *
263
		 * @return array
264
		 */
265
		public function add_metabox_setting_field( $settings, $form_id ) {
266
267
			$settings[] = array(
268
				'id'     => $this->config['id'],
269
				'title'  => $this->config['label'],
270
				'fields' => $this->get_setting_fields( $form_id ),
271
			);
272
273
			return $settings;
274
		}
275
276
277
		/**
278
		 * Get extra setting field.
279
		 *
280
		 * @since  2.0
281
		 * @access public
282
		 *
283
		 * @param int $form_id
284
		 *
285
		 * @return array
286
		 */
287
		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...
288
			return array();
289
		}
290
291
292
		/**
293
		 * Get recipient(s).
294
		 *
295
		 * Note: in case of admin notification this fx will return array of emails otherwise empty string or email of donor.
296
		 *
297
		 * @since  2.0
298
		 * @access public
299
		 *
300
		 * @param int $form_id
301
		 *
302
		 * @return string|array
303
		 */
304
		public function get_recipient( $form_id = null ) {
305
			if ( empty( $this->recipient_email ) && $this->config['has_recipient_field'] ) {
306
				$this->recipient_email = Give_Email_Notification_Util::get_value( $this, "{$this->config['id']}_recipient", $form_id );
307
			}
308
309
			/**
310
			 * Filter the recipients
311
			 *
312
			 * @since 2.0
313
			 */
314
			return apply_filters(
315
				"give_{$this->config['id']}_get_recipients",
316
				give_check_variable(
317
					$this->recipient_email,
318
					'empty',
319
					Give()->emails->get_from_address()
320
				),
321
				$this,
322
				$form_id
323
			);
324
		}
325
326
		/**
327
		 * Get notification status.
328
		 *
329
		 * @since  2.0
330
		 * @access public
331
		 *
332
		 * @param int $form_id
333
		 *
334
		 * @return bool
335
		 */
336
		public function get_notification_status( $form_id = null ) {
337
			$notification_status = empty( $form_id )
338
				? give_get_option( "{$this->config['id']}_notification", $this->config['notification_status'] )
339
				: get_post_meta( $form_id,"{$this->config['id']}_notification", true  );
340
341
			/**
342
			 * Filter the notification status.
343
			 *
344
			 * @since 1.8
345
			 */
346
			return apply_filters(
347
				"give_{$this->config['id']}_get_notification_status",
348
				$notification_status,
349
				$this,
350
				$form_id
351
			);
352
		}
353
354
		/**
355
		 * Get email subject.
356
		 *
357
		 * @since  2.0
358
		 * @access public
359
		 *
360
		 * @param int $form_id
361
		 *
362
		 * @return string
363
		 */
364
		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...
365
			$subject = wp_strip_all_tags(
366
				Give_Email_Notification_Util::get_value(
367
					$this,
368
					"{$this->config['id']}_email_subject",
369
					$form_id,
370
					$this->config['default_email_subject']
371
				)
372
			);
373
374
			/**
375
			 * Filter the subject.
376
			 *
377
			 * @since 2.0
378
			 */
379
			return apply_filters(
380
				"give_{$this->config['id']}_get_email_subject",
381
				$subject,
382
				$this,
383
				$form_id
384
			);
385
		}
386
387
		/**
388
		 * Get email message.
389
		 *
390
		 * @since  2.0
391
		 * @access public
392
		 *
393
		 * @param int $form_id
394
		 *
395
		 * @return string
396
		 */
397
		public function get_email_message( $form_id = null ) {
398
			$message = Give_Email_Notification_Util::get_value(
399
				$this,
400
				"{$this->config['id']}_email_message",
401
				$form_id,
402
				$this->config['default_email_message']
403
			);
404
405
			/**
406
			 * Filter the message.
407
			 *
408
			 * @since 2.0
409
			 */
410
			return apply_filters(
411
				"give_{$this->config['id']}_get_email_message",
412
				$message,
413
				$this,
414
				$form_id
415
			);
416
		}
417
418
419
		/**
420
		 * Get email content type.
421
		 *
422
		 * @since 2.0
423
		 * @access public
424
		 *
425
		 * @param $form_id
426
		 *
427
		 * @return string
428
		 */
429
		public function get_email_content_type( $form_id ) {
430
			$content_type = Give_Email_Notification_Util::get_value(
431
				$this,
432
				"{$this->config['id']}_email_content_type",
433
				$form_id,
434
				$this->config['content_type']
435
			);
436
437
			/**
438
			 * Filter the email content type.
439
			 *
440
			 * @since 2.0
441
			 */
442
			return apply_filters(
443
				"give_{$this->config['id']}_get_email_content_type",
444
				$content_type,
445
				$this,
446
				$form_id
447
			);
448
		}
449
450
		/**
451
		 * Get email template.
452
		 *
453
		 * @since 2.0
454
		 * @access public
455
		 *
456
		 * @param $form_id
457
		 *
458
		 * @return string
459
		 */
460
		public function get_email_template( $form_id ) {
461
			$content_type = Give_Email_Notification_Util::get_value(
462
				$this,
463
				"{$this->config['id']}_email_template",
464
				$form_id,
465
				$this->config['email_template']
466
			);
467
468
			/**
469
			 * Filter the email template.
470
			 *
471
			 * @since 2.0
472
			 */
473
			return apply_filters(
474
				"give_{$this->config['id']}_get_email_template",
475
				$content_type,
476
				$this,
477
				$form_id
478
			);
479
		}
480
481
482
		/**
483
		 * Get allowed email tags for current email notification.
484
		 *
485
		 * @since  2.0
486
		 * @access private
487
		 *
488
		 * @param bool $formatted
489
		 *
490
		 * @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...
491
		 */
492
		public function get_allowed_email_tags( $formatted = false ) {
493
			// Get all email tags.
494
			$email_tags = Give()->email_tags->get_tags();
495
496
			// Skip if all email template tags context setup exit.
497
			if ( $this->config['email_tag_context'] && 'all' !== $this->config['email_tag_context'] ) {
498
				if ( is_array( $this->config['email_tag_context'] ) ) {
499
					foreach ( $email_tags as $index => $email_tag ) {
500
						if ( in_array( $email_tag['context'], $this->config['email_tag_context'] ) ) {
501
							continue;
502
						}
503
504
						unset( $email_tags[ $index ] );
505
					}
506
				} else {
507
					foreach ( $email_tags as $index => $email_tag ) {
508
						if ( $this->config['email_tag_context'] === $email_tag['context'] ) {
509
							continue;
510
						}
511
512
						unset( $email_tags[ $index ] );
513
					}
514
				}
515
			}
516
517
			if ( count( $email_tags ) && $formatted ) : ob_start() ?>
518
				<div class="give-email-tags-wrap">
519
					<?php foreach ( $email_tags as $email_tag ) : ?>
520
						<span class="give_<?php echo $email_tag['tag']; ?>_tag">
521
							<code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?>
522
						</span>
523
					<?php endforeach; ?>
524
				</div>
525
				<?php
526
				$email_tags = ob_get_clean();
527
			endif;
528
529
			return $email_tags;
530
		}
531
532
		/**
533
		 * Get preview email recipients.
534
		 *
535
		 * @since  2.0
536
		 * @access public
537
		 *
538
		 * @param int $form_id
539
		 * @return array|string
540
		 */
541
		public function get_preview_email_recipient( $form_id = null ) {
542
			$recipients = $this->get_recipient( $form_id );
543
544
			/**
545
			 * Filter the preview email recipients.
546
			 *
547
			 * @since 2.0
548
			 *
549
			 * @param string|array            $recipients List of recipients.
550
			 * @param Give_Email_Notification $this
551
			 */
552
			$recipients = apply_filters( 'give_get_preview_email_recipient', $recipients, $this, $form_id );
553
554
			return $recipients;
555
		}
556
557
		/**
558
		 * Get the recipient attachments.
559
		 *
560
		 * @since  2.0
561
		 * @access public
562
		 *
563
		 * @param int $form_id
564
		 * @return array
565
		 */
566
		public function get_email_attachments( $form_id = null ) {
567
			/**
568
			 * Filter the attachment.
569
			 *
570
			 * @since 2.0
571
			 */
572
			return apply_filters( "give_{$this->config['id']}_get_email_attachments", array(), $this, $form_id );
573
		}
574
575
576
		/**
577
		 * Send preview email.
578
		 *
579
		 * @since  2.0
580
		 * @access public
581
		 */
582
		public function send_preview_email() {
583
			// Get form id
584
			$form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null;
585
586
			// setup email data.
587
			$this->setup_email_data();
588
589
			$attachments  = $this->get_email_attachments();
590
			$message      = $this->preview_email_template_tags( $this->get_email_message( $form_id ) );
591
			$subject      = $this->preview_email_template_tags( $this->get_email_subject( $form_id ) );
592
			$content_type = $this->get_email_content_type( $form_id );
593
594
			// Setup email content type.
595
			Give()->emails->__set( 'content_type', $content_type );
596
			Give()->emails->__set( 'html', true );
597
598
			// Setup email template
599
			Give()->emails->__set( 'template', $this->get_email_template( $form_id ) );
600
601
			// Format plain content type email.
602
			if ( 'text/plain' === $content_type ) {
603
				Give()->emails->__set( 'html', false );
604
				Give()->emails->__set( 'template', 'none' );
605
				$message = strip_tags( $message );
606
			}
607
608
			return Give()->emails->send( $this->get_preview_email_recipient( $form_id ), $subject, $message, $attachments );
609
		}
610
611
612
		/**
613
		 * Send email notification.
614
		 *
615
		 * Note: To render email tags in all context certain parameters are necessary for core (includes/emails/class-give-emails):
616
		 * 	1. payment_id
617
		 * 	2. user_id
618
		 * 	3. form_id
619
		 * 	4. donor_id
620
		 * 	5. for third party email tags you can pass necessary param along above parameters other value replace by empty string.
621
		 *
622
		 * @since  2.0
623
		 * @access public
624
		 *
625
		 * @param array $email_tag_args Arguments which helps to decode email template tags.
626
		 *
627
		 * @return bool
628
		 */
629
		public function send_email_notification( $email_tag_args = array() ) {
630
			// Add email content type email tags.
631
			$email_tag_args['email_content_type'] = $this->config['content_type'];
632
633
			/**
634
			 * Filter the email tag args
635
			 *
636
			 * @since 2.0
637
			 */
638
			$email_tag_args = apply_filters( "give_{$this->config['id']}_email_tag_args", $email_tag_args, $this );
639
640
			// Get form id.
641
			$form_id = ! empty( $email_tag_args['form_id'] )
642
				? absint( $email_tag_args['form_id'] )
643
				: ( ! empty( $email_tag_args['payment_id'] ) ? give_get_payment_form_id( $email_tag_args['payment_id'] ) : null );
644
645
646
			// Do not send email if notification is disable.
647
			if ( ! Give_Email_Notification_Util::is_email_notification_active( $this, $form_id ) ) {
648
				return false;
649
			}
650
651
			/**
652
			 * Fire action after before email send.
653
			 *
654
			 * @since 2.0
655
			 */
656
			do_action( "give_{$this->config['id']}_email_send_before", $this, $form_id );
657
658
			$attachments  = $this->get_email_attachments();
659
			$message      = give_do_email_tags( $this->get_email_message( $form_id ), $email_tag_args );
660
			$subject      = give_do_email_tags( $this->get_email_subject( $form_id ), $email_tag_args );
661
			$content_type = $this->get_email_content_type( $form_id );
662
663
			// Setup email content type.
664
			Give()->emails->__set( 'content_type', $content_type );
665
			Give()->emails->__set( 'html', true );
666
667
			// Set email template.
668
			Give()->emails->__set( 'template', $this->get_email_template( $form_id ) );
669
670
			if ( 'text/plain' === $content_type ) {
671
				Give()->emails->__set( 'html', false );
672
				Give()->emails->__set( 'template', 'none' );
673
				$message = strip_tags( $message );
674
			}
675
676
			// Send email.
677
			$email_status = Give()->emails->send( $this->get_recipient( $form_id ), $subject, $message, $attachments );
678
679
			/**
680
			 * Fire action after after email send.
681
			 *
682
			 * @since 2.0
683
			 */
684
			do_action( "give_{$this->config['id']}_email_send_after", $email_status, $this, $form_id );
685
686
			return $email_status;
687
		}
688
689
690
		/**
691
		 * Decode preview email template tags.
692
		 *
693
		 * @since 2.0
694
		 *
695
		 * @param string $message
696
		 *
697
		 * @return string
698
		 */
699
		public function preview_email_template_tags( $message ) {
700
			// Set Payment.
701
			$payment_id = give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'preview_id' );
702
			$payment    = $payment_id ? new Give_Payment( $payment_id ) : new stdClass();
703
704
			// Set donor.
705
			$user_id = $payment_id
706
				? $payment->user_id
707
				: give_check_variable( give_clean( $_GET ), 'isset_empty', 0, 'user_id' );
708
			$user_id = $user_id ? $user_id : wp_get_current_user()->ID;
709
710
			// Set receipt.
711
			$receipt_id = strtolower( md5( uniqid() ) );
712
713
			$receipt_link_url = esc_url( add_query_arg( array(
714
				'payment_key' => $receipt_id,
715
				'give_action' => 'view_receipt',
716
			), home_url() ) );
717
718
			$receipt_link = sprintf(
719
				'<a href="%1$s">%2$s</a>',
720
				$receipt_link_url,
721
				esc_html__( 'View the receipt in your browser &raquo;', 'give' )
722
			);
723
724
			// Set default values for tags.
725
			$this->config['preview_email_tags_values'] = wp_parse_args(
726
				$this->config['preview_email_tags_values'],
727
				array(
728
					'name'              => give_email_tag_first_name( array(
729
						'payment_id' => $payment_id,
730
						'user_id'    => $user_id,
731
					) ),
732
					'fullname'          => give_email_tag_fullname( array(
733
						'payment_id' => $payment_id,
734
						'user_id'    => $user_id,
735
					) ),
736
					'username'          => give_email_tag_username( array(
737
						'payment_id' => $payment_id,
738
						'user_id'    => $user_id,
739
					) ),
740
					'user_email'        => give_email_tag_user_email( array(
741
						'payment_id' => $payment_id,
742
						'user_id'    => $user_id,
743
					) ),
744
					'payment_total'     => $payment_id ? give_email_tag_payment_total( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ),
745
					'amount'            => $payment_id ? give_email_tag_amount( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ),
746
					'price'             => $payment_id ? give_email_tag_price( array( 'payment_id' => $payment_id ) ) : give_currency_filter( '10.50' ),
747
					'payment_method'    => $payment_id ? give_email_tag_payment_method( array( 'payment_id' => $payment_id ) ) : __( 'PayPal', 'give' ),
748
					'receipt_id'        => $receipt_id,
749
					'payment_id'        => $payment_id ? $payment_id : rand( 2000, 2050 ),
750
					'receipt_link_url'  => $receipt_link_url,
751
					'receipt_link'      => $receipt_link,
752
					'date'              => $payment_id ? date( give_date_format(), strtotime( $payment->date ) ) : date( give_date_format(), current_time( 'timestamp' ) ),
753
					'donation'          => $payment_id ? give_email_tag_donation( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title', 'give' ),
754
					'form_title'        => $payment_id ? give_email_tag_form_title( array( 'payment_id' => $payment_id ) ) : esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ),
755
					'sitename'          => $payment_id ? give_email_tag_sitename( array( 'payment_id' => $payment_id ) ) : get_bloginfo( 'name' ),
756
					'pdf_receipt'       => '<a href="#">Download Receipt</a>',
757
					'billing_address'   => $payment_id ? give_email_tag_billing_address( array( 'payment_id' => $payment_id ) ) : '',
758
					'email_access_link' => sprintf(
759
						'<a href="%1$s">%2$s</a>',
760
						add_query_arg(
761
							array(
762
								'give_nl' => uniqid(),
763
							),
764
							get_permalink( give_get_option( 'history_page' ) )
765
						),
766
						__( 'Access Donation Details &raquo;', 'give' )
767
					),
768
				)
769
			);
770
771
			// Decode tags.
772
			foreach ( $this->config['preview_email_tags_values'] as $preview_tag => $value ) {
773
				if ( isset( $this->config['preview_email_tags_values'][ $preview_tag ] ) ) {
774
					$message = str_replace( "{{$preview_tag}}", $this->config['preview_email_tags_values'][ $preview_tag ], $message );
775
				}
776
			}
777
778
			return apply_filters( 'give_email_preview_template_tags', $message );
779
		}
780
781
		/**
782
		 * Setup email data
783
		 *
784
		 * @since 2.0
785
		 */
786
		public function setup_email_data() {
787
		}
788
	}
789
790
endif; // End class_exists check
791