PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / trunk
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent vtrunk
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 trunk, at framework/class-wpsc-framework.php

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