Completed
Push — backup/611 ( 661115 )
by Ravinder
1411:51 queued 1394:16
created

Give_Email_Notification   C

Complexity

Total Complexity 55

Size/Duplication

Total Lines 712
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 712
rs 5.888
c 0
b 0
f 0
wmc 55
lcom 2
cbo 4

34 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 3 1
A get_instance() 0 8 3
A load() 0 7 3
A __set() 0 3 1
A setup_filters() 0 23 3
A add_setting_fields() 0 7 2
A get_setting_fields() 0 3 1
A add_metabox_setting_field() 0 10 1
A get_extra_setting_fields() 0 3 1
A get_id() 0 3 1
A get_label() 0 3 1
A get_description() 0 3 1
A get_recipient() 0 14 3
A get_recipient_group_name() 0 3 1
A get_notification_status() 0 9 1
A get_email_subject() 0 10 1
A get_email_message() 0 10 1
A get_email_message_field_description() 0 13 2
A get_emails_tags_list_html() 0 19 3
B get_allowed_email_tags() 0 28 8
A get_default_email_subject() 0 3 1
A get_default_email_message() 0 3 1
A get_preview_email_recipient() 0 15 1
A get_email_attachments() 0 8 1
A get_email_type() 0 3 1
A is_email_notification_active() 0 3 1
A is_email_preview() 0 3 1
A is_email_preview_has_header() 0 3 1
A has_recipient_field() 0 3 1
A has_preview() 0 3 1
A send_preview_email() 0 10 1
A send_email_notification() 0 30 2
B preview_email_template_tags() 0 57 2
A setup_email_data() 0 2 1

How to fix   Complexity   

Complex Class

Complex classes like Give_Email_Notification often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Give_Email_Notification, and based on these observations, apply Extract Interface, too.

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