PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.5.4
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.5.4
3.5.4 3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
supportcandy / includes / admin / email-notifications / class-wpsc-en-change-agentonly-fields.php

class-wpsc-en-change-agentonly-fields.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 3.5.4, at includes/admin/email-notifications/class-wpsc-en-change-agentonly-fields.php

118 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly!
4 }
5
6 if ( ! class_exists( 'WPSC_EN_Change_Agentonly_Fields' ) ) :
7
8 final class WPSC_EN_Change_Agentonly_Fields extends WPSC_Email_Notifications {
9
10 /**
11 * Slug for this event (must be unique)
12 *
13 * @var string
14 */
15 private static $slug = 'change-agentonly-fields';
16
17 /**
18 * Ticket object
19 *
20 * @var WPSC_Ticket
21 */
22 public $ticket;
23
24 /**
25 * Ticket object
26 *
27 * @var WPSC_Ticket
28 */
29 public $prev;
30
31 /**
32 * Ticket object
33 *
34 * @var WPSC_Ticket
35 */
36 public $new;
37
38 /**
39 * Initialize this class
40 */
41 public static function init() {
42
43 // process event.
44 add_action( 'wpsc_change_agentonly_fields', array( __CLASS__, 'process_event' ), 200, 2 );
45 }
46
47 /**
48 * Process emails for this event
49 *
50 * @param WPSC_Ticket $prev - ticket object before changes.
51 * @param WPSC_Ticket $new - ticket object after changes.
52 * @return void
53 */
54 public static function process_event( $prev, $new ) {
55
56 if ( $prev == $new ) {
57 return;
58 }
59
60 $gs = get_option( 'wpsc-en-general' );
61 $email_templates = get_option( 'wpsc-email-templates', array() );
62
63 foreach ( $email_templates as $key => $et ) {
64
65 if ( $et['event'] != self::$slug ) {
66 continue;
67 }
68
69 // email notification object.
70 $en = new self();
71
72 // set properties.
73 $en->ticket = $new;
74 $en->prev = $prev;
75 $en->new = $new;
76
77 // set template.
78 $en->template = $et;
79 $en->template_key = $key;
80
81 // check whether conditions matches (if any).
82 if ( ! $en->is_valid() ) {
83 continue;
84 }
85
86 // macro attachments.
87 $en->attachments = array_merge( $en->attachments, WPSC_Macros::$attachments );
88 WPSC_Macros::$attachments = array();
89
90 $en = apply_filters( 'wpsc_en_before_sending', $en );
91
92 // send an email.
93 $attachment_ids = array();
94 foreach ( $en->attachments as $attachment ) {
95 $attachment_ids[] = $attachment->id;
96 }
97
98 WPSC_Background_Email::insert(
99 array(
100 'from_name' => $en->from_name,
101 'from_email' => $en->from_email,
102 'reply_to' => $gs['reply-to'],
103 'subject' => $en->subject,
104 'body' => $en->body,
105 'to_email' => implode( '|', $en->to ),
106 'cc_email' => implode( '|', $en->cc ),
107 'bcc_email' => implode( '|', $en->bcc ),
108 'attachments' => implode( '|', $attachment_ids ),
109 'priority' => 2,
110 )
111 );
112 }
113 }
114 }
115 endif;
116
117 WPSC_EN_Change_Agentonly_Fields::init();
118