PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.4.7
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.4.7
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 / framework / class-wpsc-framework.php

class-wpsc-framework.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 3.4.7, at framework/class-wpsc-framework.php

479 lines 16.7 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_Framework' ) ) :
7
8 final class WPSC_Framework {
9
10 /**
11 * Initialize the class
12 *
13 * @return void
14 */
15 public static function init() {
16
17 // Add framework snippets to footer for wpsc pages.
18 add_action( 'wp_footer', array( __CLASS__, 'print_snippets' ) );
19 add_action( 'admin_footer', array( __CLASS__, 'print_snippets' ) );
20
21 // JS events for framework.
22 add_action( 'wp_footer', array( __CLASS__, 'js_events' ) );
23 add_action( 'admin_footer', array( __CLASS__, 'js_events' ) );
24
25 // Framework dynamic css used in appearance setting.
26 add_action( 'wp_footer', array( __CLASS__, 'dynamic_css' ) );
27 add_action( 'admin_footer', array( __CLASS__, 'dynamic_css' ) );
28
29 // Localization.
30 add_filter( 'wpsc_admin_localizations', array( __CLASS__, 'localizations' ) );
31 add_filter( 'wpsc_frontend_localizations', array( __CLASS__, 'localizations' ) );
32
33 // Dynamic scripts.
34 add_action( 'wp_footer', array( __CLASS__, 'js_frontend' ) );
35 add_action( 'admin_footer', array( __CLASS__, 'js_frontend' ) );
36 add_action( 'admin_footer', array( __CLASS__, 'js_backend' ) );
37 }
38
39 /**
40 * Print framework snippets to footer
41 *
42 * @return void
43 */
44 public static function print_snippets() {
45
46 // Check load scripts setting to load script on perticular page.
47 $page_settings = get_option( 'wpsc-gs-page-settings' );
48 if ( ! is_admin() && $page_settings['load-scripts'] == 'custom' && ! in_array( get_the_id(), $page_settings['load-script-pages'] ) ) {
49 return;
50 }
51 ?>
52 <!-- Modal Pop-up -->
53 <div class="wpsc-modal" style="display:none">
54 <div class="overlay"></div>
55 <div class="loader">
56 <img
57 src="<?php echo esc_url( WPSC_PLUGIN_URL . 'asset/images/loader-white.gif' ); ?>"
58 alt="Loading...">
59 </div>
60 <div class="inner-container">
61 <div class="modal">
62 <div class="wpsc-modal-header"></div>
63 <div class="wpsc-modal-body"></div>
64 <div class="wpsc-modal-footer"></div>
65 </div>
66 </div>
67 </div>
68 <?php
69 }
70
71 /**
72 * Print JS events functionality for frameworks
73 *
74 * @return void
75 */
76 public static function js_events() {
77
78 // Check load scripts setting to load script on perticular page.
79 $page_settings = get_option( 'wpsc-gs-page-settings' );
80 if ( ! is_admin() && $page_settings['load-scripts'] == 'custom' && ! in_array( get_the_id(), $page_settings['load-script-pages'] ) ) {
81 return;
82 }
83 ?>
84 <script type="text/javascript">
85
86 // Register functions to call for responsive behaviour changes
87 function wpsc_apply_responsive_styles(){
88
89 wpsc_close_humbargar();
90 wpsc_el_reset_visible();
91 wpsc_el_reset_hidden();
92 <?php do_action( 'wpsc_js_apply_responsive_styles' ); ?>
93 }
94
95 // Register functions to call on document ready
96 function wpsc_document_ready() {
97 <?php do_action( 'wpsc_js_ready' ); ?>
98 }
99
100 // after ticket reply
101 function wpsc_after_ticket_reply(ticket_id) {
102 <?php do_action( 'wpsc_js_after_ticket_reply' ); ?>
103 }
104
105 // after close ticket
106 function wpsc_after_close_ticket(ticket_id) {
107 <?php do_action( 'wpsc_js_after_close_ticket' ); ?>
108 }
109
110 // after change create as
111 function wpsc_after_change_create_as() {
112 wpsc_get_create_as_customer_fields('<?php echo esc_attr( wp_create_nonce( 'wpsc_get_create_as_customer_fields' ) ); ?>');
113 <?php do_action( 'wpsc_js_after_change_create_as' ); ?>
114 }
115 </script>
116 <?php
117 }
118
119 /**
120 * Loader HTML
121 *
122 * @return string - Prints HTML.
123 */
124 public static function loader_html() {
125
126 ob_start();
127 ?>
128 <div class="wpsc-loader">
129 <img src="<?php echo esc_url( WPSC_PLUGIN_URL . 'asset/images/loader.gif' ); ?>" alt="Loading..." />
130 </div>
131 <?php
132 return ob_get_clean();
133 }
134
135 /**
136 * Inline loader
137 *
138 * @return string - Prints HTML.
139 */
140 public static function inline_loader() {
141
142 ob_start();
143 ?>
144 <img class="wpsc-inline-loader" src="<?php echo esc_url( WPSC_PLUGIN_URL . 'asset/images/loader.gif' ); ?>" alt="Loading..." />
145 <?php
146 return ob_get_clean();
147 }
148
149 /**
150 * Load settings based dynamic css
151 *
152 * @return void
153 */
154 public static function dynamic_css() {
155
156 // Check load scripts setting to load script on perticular page.
157 $page_settings = get_option( 'wpsc-gs-page-settings' );
158 if ( ! is_admin() && $page_settings['load-scripts'] == 'custom' && ! in_array( get_the_id(), $page_settings['load-script-pages'] ) ) {
159 return;
160 }
161
162 $general = get_option( 'wpsc-ap-general' );
163 $ticket_list = get_option( 'wpsc-ap-ticket-list' );
164 $individual_ticket = get_option( 'wpsc-ap-individual-ticket' );
165 $modal = get_option( 'wpsc-ap-modal' );
166 $agent_collision = get_option( 'wpsc-ap-agent-collision' );
167
168 ?>
169 <style type="text/css">
170 .wpsc-modal .overlay,
171 .wpsc-humbargar-overlay {
172 z-index: <?php echo esc_attr( $modal['z-index'] ); ?>;
173 }
174 .wpsc-modal .loader,
175 .wpsc-modal .inner-container,
176 .wpsc-humbargar-menu {
177 z-index: <?php echo esc_attr( intval( $modal['z-index'] + 1 ) ); ?>;
178 }
179 .select2-container--open {
180 z-index: <?php echo esc_attr( intval( $modal['z-index'] + 2 ) ); ?>;
181 }
182 .wpsc-header {
183 background-color: <?php echo esc_attr( $general['primary-color'] ); ?> !important;
184 }
185 .wpsc-menu-list {
186 color: <?php echo esc_attr( $general['menu-link-color'] ); ?>;
187 }
188 .wpsc-shortcode-container {
189 background-color: <?php echo esc_attr( $general['main-background-color'] ); ?> !important;
190 border: 1px solid <?php echo esc_attr( $general['primary-color'] ); ?> !important;
191 color: <?php echo esc_attr( $general['main-text-color'] ); ?>;
192 }
193 .wpsc-humbargar,
194 .wpsc-humbargar-title {
195 color: #fff !important;
196 }
197 .wpsc-humbargar-overlay {
198 z-index: <?php echo esc_attr( intval( $modal['z-index'] ) ); ?>;
199 }
200 .wpsc-humbargar-menu {
201 z-index: <?php echo esc_attr( intval( $modal['z-index'] + 1 ) ); ?>;
202 background-color: #fff !important;
203 }
204 .wpsc-humbargar-menu-item:hover,
205 .wpsc-humbargar-menu-item.active,
206 .wpsc-setting-nav:hover,
207 .wpsc-setting-nav.active {
208 background-color: <?php echo esc_attr( $general['primary-color'] ); ?> !important;
209 }
210
211 /* Ticket list */
212 .wpsc-search input {
213 color: #8a8a8a !important;
214 }
215 .wpsc-ticket-list-tbl th {
216 background-color: <?php echo esc_attr( $ticket_list['list-header-background-color'] ); ?>;
217 color: <?php echo esc_attr( $ticket_list['list-header-text-color'] ); ?>;
218 }
219 .wpsc-ticket-list-tbl tr:nth-child(even){
220 background-color: <?php echo esc_attr( $ticket_list['list-item-even-background-color'] ); ?>;
221 color: <?php echo esc_attr( $ticket_list['list-item-even-text-color'] ); ?>;
222 }
223 .wpsc-ticket-list-tbl tr:nth-child(odd){
224 background-color: <?php echo esc_attr( $ticket_list['list-item-odd-background-color'] ); ?>;
225 color: <?php echo esc_attr( $ticket_list['list-item-odd-text-color'] ); ?>;
226 }
227 .wpsc-ticket-list-tbl tbody tr:hover {
228 background-color: <?php echo esc_attr( $ticket_list['list-item-hover-background-color'] ); ?>;
229 color: <?php echo esc_attr( $ticket_list['list-item-hover-text-color'] ); ?>;
230 }
231
232 /* Individual Ticket */
233 .wpsc-thread.reply,
234 .wpsc-thread.reply h2 {
235 color: <?php echo esc_attr( $individual_ticket['reply-primary-color'] ); ?>;
236 }
237 .wpsc-thread.reply .thread-time,
238 .wpsc-thread.reply .wpsc-thread-logs {
239 color: <?php echo esc_attr( $individual_ticket['reply-secondary-color'] ); ?>;
240 }
241 .wpsc-thread.reply .actions {
242 color: <?php echo esc_attr( $individual_ticket['reply-icon-color'] ); ?>;
243 }
244 .wpsc-thread.note,
245 .wpsc-thread.note h2 {
246 color: <?php echo esc_attr( $individual_ticket['note-primary-color'] ); ?>;
247 }
248 .wpsc-thread.note .email-address,
249 .wpsc-thread.note .thread-time,
250 .wpsc-thread.note .wpsc-thread-logs {
251 color: <?php echo esc_attr( $individual_ticket['note-secondary-color'] ); ?>;
252 }
253 .wpsc-thread.note .actions {
254 color: <?php echo esc_attr( $individual_ticket['note-icon-color'] ); ?>;
255 }
256 .wpsc-thread.log .thread-body {
257 color: <?php echo esc_attr( $individual_ticket['log-text'] ); ?>;
258 }
259 .wpsc-widget-header {
260 background-color: <?php echo esc_attr( $individual_ticket['widget-header-bg-color'] ); ?>;
261 color: <?php echo esc_attr( $individual_ticket['widget-header-text-color'] ); ?>;
262 }
263 .wpsc-widget-header h2 {
264 color: <?php echo esc_attr( $individual_ticket['widget-header-text-color'] ); ?>;
265 }
266 .wpsc-widget-body {
267 background-color: <?php echo esc_attr( $individual_ticket['widget-body-bg-color'] ); ?>;
268 color: <?php echo esc_attr( $individual_ticket['widget-body-text-color'] ); ?>;
269 }
270 .wpsc-widget-body .info-list-item .info-label, .wpsc-lg-label {
271 color: <?php echo esc_attr( $individual_ticket['widget-body-label-color'] ); ?>;
272 }
273 .wpsc-popover-menu > .wpsc-reply-close {
274 background-color: <?php echo esc_attr( $individual_ticket['reply-close-bg-color'] ); ?>;
275 color: <?php echo esc_attr( $individual_ticket['reply-close-text-color'] ); ?>;
276 }
277
278 /* Input fields */
279 #wpsc-container input[type=text]:focus,
280 #wpsc-container input[type=text],
281 #wpsc-container input[type=password]:focus,
282 #wpsc-container input[type=password],
283 .wpsc-modal input[type=text]:focus,
284 .wpsc-modal input[type=text],
285 .wpsc-modal input[type=password]:focus,
286 .wpsc-modal input[type=password],
287 #wpsc-container select,
288 #wpsc-container select:focus,
289 .wpsc-modal select,
290 .wpsc-modal select:focus,
291 #wpsc-container textarea,
292 #wpsc-container textarea:focus,
293 .wpsc-modal textarea,
294 .wpsc-modal textarea:focus,
295 #wpsc-container .checkbox-container label:before,
296 .wpsc-modal .checkbox-container label:before,
297 #wpsc-container .radio-container label:before,
298 .wpsc-modal .radio-container label:before {
299 border: 1px solid #8a8a8a !important;
300 color: #000 !important;
301 }
302
303 /* Buttons */
304 .wpsc-button.primary {
305 border: 1px solid <?php echo esc_attr( $general['primary-color'] ); ?> !important;
306 background-color: <?php echo esc_attr( $general['primary-color'] ); ?> !important;
307 color: #fff !important;
308 }
309
310 .wpsc-button.secondary {
311 border: 1px solid <?php echo esc_attr( $general['primary-color'] ); ?> !important;
312 background-color: #fff !important;
313 color: <?php echo esc_attr( $general['primary-color'] ); ?> !important;
314 }
315
316 /* Links */
317 .wpsc-link {
318 color: <?php echo esc_attr( $general['link-color'] ); ?>;
319 }
320
321 /* Modal popup */
322 .wpsc-modal-header {
323 background-color: <?php echo esc_attr( $modal['header-bg-color'] ); ?>;
324 color: <?php echo esc_attr( $modal['header-text-color'] ); ?>;
325 }
326 .wpsc-modal-body {
327 background-color: <?php echo esc_attr( $modal['body-bg-color'] ); ?>;
328 color: <?php echo esc_attr( $modal['body-text-color'] ); ?>;
329 }
330 .wpsc-modal-footer {
331 background-color: <?php echo esc_attr( $modal['footer-bg-color'] ); ?>;
332 }
333 .wpsc-modal-body .info-label {
334 color: <?php echo esc_attr( $modal['body-label-color'] ); ?>;
335 }
336
337 /* Misc */
338 .wpsc-section-header,
339 .wpsc-it-subject-container h2 {
340 color: <?php echo esc_attr( $general['main-text-color'] ); ?>;
341 }
342 .wpsc-popover-menu-item:hover,
343 .wpsc-ap-nav.active,
344 .wpsc-ap-nav:hover,
345 .wpsc-popover-menu > .wpsc-reply-close:hover {
346 background-color: <?php echo esc_attr( $general['primary-color'] ); ?>;
347 }
348
349 /* Agent Collision */
350 .wpsc-ac-agent {
351 color: <?php echo esc_attr( $agent_collision['header-text-color'] ); ?>;
352 background-color: <?php echo esc_attr( $agent_collision['header-bg-color'] ); ?>;
353 }
354
355 /* Ticket tags */
356 .wpsc-add-ticket-tag {
357 position: relative;
358 display: flex;
359 align-items: center;
360 justify-content: center;
361 width: 25px;
362 height: 25px;
363 color: #fff !important;
364 background-color: <?php echo esc_attr( $general['primary-color'] ); ?> !important;
365 border: 1px solid <?php echo esc_attr( $general['primary-color'] ); ?> !important;
366 outline: none;
367 border-radius: 5px;
368 cursor: pointer;
369 margin: 0px 0px 0px 3px;
370 padding: 5px;
371 box-sizing: border-box;
372 }
373
374 .wpsc-close-ticket-tag {
375 position: relative;
376 display: flex;
377 align-items: center;
378 justify-content: center;
379 width: 25px;
380 height: 25px;
381 color: <?php echo esc_attr( $general['primary-color'] ); ?> !important;
382 background-color: #fff !important;
383 border: 1px solid <?php echo esc_attr( $general['primary-color'] ); ?> !important;
384 outline: none;
385 border-radius: 5px;
386 cursor: pointer;
387 margin: 0px 0px 0px 3px;
388 padding: 5px;
389 box-sizing: border-box;
390 }
391
392 .wpsc-ticket-tags-action {
393 display: flex;
394 margin: 5px 0px 10px 0px;
395 flex-direction: row-reverse;
396 }
397
398 /* User profile starts */
399 .wpsc-up-tab > .active {
400 border-top: 3px solid <?php echo esc_attr( $general['primary-color'] ); ?> !important;
401 }
402 /* User profile ends */
403 </style>
404 <?php
405 }
406
407 /**
408 * Localizations for framework
409 *
410 * @param array $localizations - localization list.
411 * @return array
412 */
413 public static function localizations( $localizations ) {
414
415 $localizations['translations']['please_wait'] = esc_attr__( 'Please wait...', 'supportcandy' );
416 $localizations['translations']['req_fields_missing'] = esc_attr__( 'Required fields missing!', 'supportcandy' );
417 $localizations['translations']['confirm'] = esc_attr__( 'Are you sure?', 'supportcandy' );
418 $localizations['translations']['something_wrong'] = esc_attr__( 'Something went wrong!', 'supportcandy' );
419 $localizations['translations']['view_more'] = esc_attr__( 'View more!', 'supportcandy' );
420 $localizations['translations']['view_less'] = esc_attr__( 'View less!', 'supportcandy' );
421 $localizations['translations']['warning_message'] = html_entity_decode( esc_attr__( 'There is unposted text in the reply area. Are you sure you want to discard and proceed?', 'supportcandy' ), ENT_QUOTES );
422 $localizations['translations']['incorrect_login'] = esc_attr__( 'Incorrect username or password!', 'supportcandy' );
423 $localizations['translations']['incorrect_password'] = esc_attr__( 'Incorrect password!', 'supportcandy' );
424 $localizations['translations']['unsername_unavailable'] = esc_attr__( 'Username is already taken!', 'supportcandy' );
425 $localizations['translations']['email_unavailable'] = esc_attr__( 'Email is already taken or not allowed!', 'supportcandy' );
426 $localizations['translations']['incorrect_email'] = esc_attr__( 'Incorrect email address!', 'supportcandy' );
427 $localizations['translations']['copy_url'] = esc_attr__( 'Ticket URL copied!', 'supportcandy' );
428 $localizations['translations']['invalidEmail'] = esc_attr__( 'Invalid email address!', 'supportcandy' );
429 $localizations['translations']['customer_delete_warn'] = esc_attr__( 'Deleting a customer will permanently remove all associated customer information and tickets!', 'supportcandy' );
430 $localizations['translations']['req_term_cond'] = esc_attr__( 'Please accept terms and conditions!', 'supportcandy' );
431 $localizations['translations']['req_gdpr'] = esc_attr__( 'Please accept GDPR policy!', 'supportcandy' );
432 $localizations['translations']['delete_permanently'] = esc_attr__( 'Deleting a ticket will permanently remove all associated information and cannot be undone!', 'supportcandy' );
433 $localizations['translations']['block_notifications'] = esc_attr__( 'Blocking notifications will stop all email alerts for this ticket.', 'supportcandy' );
434 $localizations['translations']['unblock_notifications'] = esc_attr__( 'Unblocking notifications will resume email alerts for this ticket.', 'supportcandy' );
435 return $localizations;
436 }
437
438 /**
439 * JS functions to print for frontend only
440 *
441 * @return void
442 */
443 public static function js_frontend() {
444
445 // Check load scripts setting to load script on perticular page.
446 $page_settings = get_option( 'wpsc-gs-page-settings' );
447 if ( ! is_admin() && $page_settings['load-scripts'] == 'custom' && ! in_array( get_the_id(), $page_settings['load-script-pages'] ) ) {
448 return;
449 }
450 ?>
451 <script>
452 <?php do_action( 'wpsc_js_frontend' ); ?>
453 </script>
454 <style>
455 <?php do_action( 'wpsc_css_frontend' ); ?>
456 </style>
457 <?php
458 }
459
460 /**
461 * JS functions to print for backend only
462 *
463 * @return void
464 */
465 public static function js_backend() {
466 ?>
467 <script>
468 <?php do_action( 'wpsc_js_backend' ); ?>
469 </script>
470 <style>
471 <?php do_action( 'wpsc_css_backend' ); ?>
472 </style>
473 <?php
474 }
475 }
476 endif;
477
478 WPSC_Framework::init();
479