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 / framework / class-wpsc-framework.php

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

469 lines 16.1 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
164 ?>
165 <style type="text/css">
166 .wpsc-modal .overlay,
167 .wpsc-humbargar-overlay {
168 z-index: <?php echo esc_attr( $modal['z-index'] ); ?>;
169 }
170 .wpsc-modal .loader,
171 .wpsc-modal .inner-container,
172 .wpsc-humbargar-menu {
173 z-index: <?php echo esc_attr( intval( $modal['z-index'] + 1 ) ); ?>;
174 }
175 .select2-container--open {
176 z-index: <?php echo esc_attr( intval( $modal['z-index'] + 2 ) ); ?>;
177 }
178 .wpsc-header {
179 background-color: <?php echo esc_attr( $general['primary-color'] ); ?> !important;
180 }
181 .wpsc-menu-list {
182 color: <?php echo esc_attr( $general['menu-link-color'] ); ?>;
183 }
184 .wpsc-shortcode-container {
185 background-color: <?php echo esc_attr( $general['main-background-color'] ); ?> !important;
186 border: 1px solid <?php echo esc_attr( $general['primary-color'] ); ?> !important;
187 color: <?php echo esc_attr( $general['main-text-color'] ); ?>;
188 }
189 .wpsc-humbargar,
190 .wpsc-humbargar-title {
191 color: #fff !important;
192 }
193 .wpsc-humbargar-overlay {
194 z-index: <?php echo esc_attr( intval( $modal['z-index'] ) ); ?>;
195 }
196 .wpsc-humbargar-menu {
197 z-index: <?php echo esc_attr( intval( $modal['z-index'] + 1 ) ); ?>;
198 background-color: #fff !important;
199 }
200 .wpsc-humbargar-menu-item:hover,
201 .wpsc-humbargar-menu-item.active,
202 .wpsc-setting-nav:hover,
203 .wpsc-setting-nav.active {
204 background-color: <?php echo esc_attr( $general['primary-color'] ); ?> !important;
205 }
206
207 /* Ticket list */
208 .wpsc-search input {
209 color: #8a8a8a !important;
210 }
211 .wpsc-ticket-list-tbl th {
212 background-color: <?php echo esc_attr( $ticket_list['list-header-background-color'] ); ?>;
213 color: <?php echo esc_attr( $ticket_list['list-header-text-color'] ); ?>;
214 }
215 .wpsc-ticket-list-tbl tr:nth-child(even){
216 background-color: <?php echo esc_attr( $ticket_list['list-item-even-background-color'] ); ?>;
217 color: <?php echo esc_attr( $ticket_list['list-item-even-text-color'] ); ?>;
218 }
219 .wpsc-ticket-list-tbl tr:nth-child(odd){
220 background-color: <?php echo esc_attr( $ticket_list['list-item-odd-background-color'] ); ?>;
221 color: <?php echo esc_attr( $ticket_list['list-item-odd-text-color'] ); ?>;
222 }
223 .wpsc-ticket-list-tbl tbody tr:hover {
224 background-color: <?php echo esc_attr( $ticket_list['list-item-hover-background-color'] ); ?>;
225 color: <?php echo esc_attr( $ticket_list['list-item-hover-text-color'] ); ?>;
226 }
227
228 /* Individual Ticket */
229 .wpsc-thread.reply,
230 .wpsc-thread.reply h2 {
231 color: <?php echo esc_attr( $individual_ticket['reply-primary-color'] ); ?>;
232 }
233 .wpsc-thread.reply .thread-time,
234 .wpsc-thread.reply .wpsc-thread-logs {
235 color: <?php echo esc_attr( $individual_ticket['reply-secondary-color'] ); ?>;
236 }
237 .wpsc-thread.reply .actions {
238 color: <?php echo esc_attr( $individual_ticket['reply-icon-color'] ); ?>;
239 }
240 .wpsc-thread.note,
241 .wpsc-thread.note h2 {
242 color: <?php echo esc_attr( $individual_ticket['note-primary-color'] ); ?>;
243 }
244 .wpsc-thread.note .email-address,
245 .wpsc-thread.note .thread-time,
246 .wpsc-thread.note .wpsc-thread-logs {
247 color: <?php echo esc_attr( $individual_ticket['note-secondary-color'] ); ?>;
248 }
249 .wpsc-thread.note .actions {
250 color: <?php echo esc_attr( $individual_ticket['note-icon-color'] ); ?>;
251 }
252 .wpsc-thread.log .thread-body {
253 color: <?php echo esc_attr( $individual_ticket['log-text'] ); ?>;
254 }
255 .wpsc-widget-header {
256 background-color: <?php echo esc_attr( $individual_ticket['widget-header-bg-color'] ); ?>;
257 color: <?php echo esc_attr( $individual_ticket['widget-header-text-color'] ); ?>;
258 }
259 .wpsc-widget-header h2 {
260 color: <?php echo esc_attr( $individual_ticket['widget-header-text-color'] ); ?>;
261 }
262 .wpsc-widget-body {
263 background-color: <?php echo esc_attr( $individual_ticket['widget-body-bg-color'] ); ?>;
264 color: <?php echo esc_attr( $individual_ticket['widget-body-text-color'] ); ?>;
265 }
266 .wpsc-widget-body .info-list-item .info-label, .wpsc-lg-label {
267 color: <?php echo esc_attr( $individual_ticket['widget-body-label-color'] ); ?>;
268 }
269 .wpsc-popover-menu > .wpsc-reply-close {
270 background-color: <?php echo esc_attr( $individual_ticket['reply-close-bg-color'] ); ?>;
271 color: <?php echo esc_attr( $individual_ticket['reply-close-text-color'] ); ?>;
272 }
273
274 /* Input fields */
275 #wpsc-container input[type=text]:focus,
276 #wpsc-container input[type=text],
277 #wpsc-container input[type=password]:focus,
278 #wpsc-container input[type=password],
279 .wpsc-modal input[type=text]:focus,
280 .wpsc-modal input[type=text],
281 .wpsc-modal input[type=password]:focus,
282 .wpsc-modal input[type=password],
283 #wpsc-container select,
284 #wpsc-container select:focus,
285 .wpsc-modal select,
286 .wpsc-modal select:focus,
287 #wpsc-container textarea,
288 #wpsc-container textarea:focus,
289 .wpsc-modal textarea,
290 .wpsc-modal textarea:focus,
291 #wpsc-container .checkbox-container label:before,
292 .wpsc-modal .checkbox-container label:before,
293 #wpsc-container .radio-container label:before,
294 .wpsc-modal .radio-container label:before {
295 border: 1px solid #8a8a8a !important;
296 color: #000 !important;
297 }
298
299 /* Buttons */
300 .wpsc-button.primary {
301 border: 1px solid <?php echo esc_attr( $general['primary-color'] ); ?> !important;
302 background-color: <?php echo esc_attr( $general['primary-color'] ); ?> !important;
303 color: #fff !important;
304 }
305
306 .wpsc-button.secondary {
307 border: 1px solid <?php echo esc_attr( $general['primary-color'] ); ?> !important;
308 background-color: #fff !important;
309 color: <?php echo esc_attr( $general['primary-color'] ); ?> !important;
310 }
311
312 /* Links */
313 .wpsc-link {
314 color: <?php echo esc_attr( $general['link-color'] ); ?>;
315 }
316
317 /* Modal popup */
318 .wpsc-modal-header {
319 background-color: <?php echo esc_attr( $modal['header-bg-color'] ); ?>;
320 color: <?php echo esc_attr( $modal['header-text-color'] ); ?>;
321 }
322 .wpsc-modal-body {
323 background-color: <?php echo esc_attr( $modal['body-bg-color'] ); ?>;
324 color: <?php echo esc_attr( $modal['body-text-color'] ); ?>;
325 }
326 .wpsc-modal-footer {
327 background-color: <?php echo esc_attr( $modal['footer-bg-color'] ); ?>;
328 }
329 .wpsc-modal-body .info-label {
330 color: <?php echo esc_attr( $modal['body-label-color'] ); ?>;
331 }
332
333 /* Misc */
334 .wpsc-section-header,
335 .wpsc-it-subject-container h2 {
336 color: <?php echo esc_attr( $general['main-text-color'] ); ?>;
337 }
338 .wpsc-popover-menu-item:hover,
339 .wpsc-ap-nav.active,
340 .wpsc-ap-nav:hover,
341 .wpsc-popover-menu > .wpsc-reply-close:hover {
342 background-color: <?php echo esc_attr( $general['primary-color'] ); ?>;
343 }
344
345 /* Ticket tags */
346 .wpsc-add-ticket-tag {
347 position: relative;
348 display: flex;
349 align-items: center;
350 justify-content: center;
351 width: 25px;
352 height: 25px;
353 color: #fff !important;
354 background-color: <?php echo esc_attr( $general['primary-color'] ); ?> !important;
355 border: 1px solid <?php echo esc_attr( $general['primary-color'] ); ?> !important;
356 outline: none;
357 border-radius: 5px;
358 cursor: pointer;
359 margin: 0px 0px 0px 3px;
360 padding: 5px;
361 box-sizing: border-box;
362 }
363
364 .wpsc-close-ticket-tag {
365 position: relative;
366 display: flex;
367 align-items: center;
368 justify-content: center;
369 width: 25px;
370 height: 25px;
371 color: <?php echo esc_attr( $general['primary-color'] ); ?> !important;
372 background-color: #fff !important;
373 border: 1px solid <?php echo esc_attr( $general['primary-color'] ); ?> !important;
374 outline: none;
375 border-radius: 5px;
376 cursor: pointer;
377 margin: 0px 0px 0px 3px;
378 padding: 5px;
379 box-sizing: border-box;
380 }
381
382 .wpsc-ticket-tags-action {
383 display: flex;
384 margin: 5px 0px 10px 0px;
385 flex-direction: row-reverse;
386 }
387
388 /* User profile starts */
389 .wpsc-up-tab > .active {
390 border-top: 3px solid <?php echo esc_attr( $general['primary-color'] ); ?> !important;
391 }
392 /* User profile ends */
393 </style>
394 <?php
395 }
396
397 /**
398 * Localizations for framework
399 *
400 * @param array $localizations - localization list.
401 * @return array
402 */
403 public static function localizations( $localizations ) {
404
405 $localizations['translations']['please_wait'] = esc_attr__( 'Please wait...', 'supportcandy' );
406 $localizations['translations']['req_fields_missing'] = esc_attr__( 'Required fields missing!', 'supportcandy' );
407 $localizations['translations']['confirm'] = esc_attr__( 'Are you sure?', 'supportcandy' );
408 $localizations['translations']['something_wrong'] = esc_attr__( 'Something went wrong!', 'supportcandy' );
409 $localizations['translations']['view_more'] = esc_attr__( 'View more!', 'supportcandy' );
410 $localizations['translations']['view_less'] = esc_attr__( 'View less!', 'supportcandy' );
411 $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 );
412 $localizations['translations']['incorrect_login'] = esc_attr__( 'Incorrect username or password!', 'supportcandy' );
413 $localizations['translations']['incorrect_password'] = esc_attr__( 'Incorrect password!', 'supportcandy' );
414 $localizations['translations']['unsername_unavailable'] = esc_attr__( 'Username is already taken!', 'supportcandy' );
415 $localizations['translations']['email_unavailable'] = esc_attr__( 'Email is already taken or not allowed!', 'supportcandy' );
416 $localizations['translations']['incorrect_email'] = esc_attr__( 'Incorrect email address!', 'supportcandy' );
417 $localizations['translations']['copy_url'] = esc_attr__( 'Ticket URL copied!', 'supportcandy' );
418 $localizations['translations']['invalidEmail'] = esc_attr__( 'Invalid email address!', 'supportcandy' );
419 $localizations['translations']['customer_delete_warn'] = esc_attr__( 'Deleting a customer will permanently remove all associated customer information and tickets!', 'supportcandy' );
420 $localizations['translations']['req_term_cond'] = esc_attr__( 'Please accept terms and conditions!', 'supportcandy' );
421 $localizations['translations']['req_gdpr'] = esc_attr__( 'Please accept GDPR policy!', 'supportcandy' );
422 $localizations['translations']['delete_permanently'] = esc_attr__( 'Deleting a ticket will permanently remove all associated information and cannot be undone!', 'supportcandy' );
423 $localizations['translations']['block_notifications'] = esc_attr__( 'Blocking notifications will stop all email alerts for this ticket.', 'supportcandy' );
424 $localizations['translations']['unblock_notifications'] = esc_attr__( 'Unblocking notifications will resume email alerts for this ticket.', 'supportcandy' );
425 $localizations['translations']['unauthorized_value'] = esc_attr__( 'Unauthorized value!', 'supportcandy' );
426 return $localizations;
427 }
428
429 /**
430 * JS functions to print for frontend only
431 *
432 * @return void
433 */
434 public static function js_frontend() {
435
436 // Check load scripts setting to load script on perticular page.
437 if ( ! is_admin() && ! WPSC_Functions::is_load_scripts_page() ) {
438 return;
439 }
440 ?>
441 <script>
442 <?php do_action( 'wpsc_js_frontend' ); ?>
443 </script>
444 <style>
445 <?php do_action( 'wpsc_css_frontend' ); ?>
446 </style>
447 <?php
448 }
449
450 /**
451 * JS functions to print for backend only
452 *
453 * @return void
454 */
455 public static function js_backend() {
456 ?>
457 <script>
458 <?php do_action( 'wpsc_js_backend' ); ?>
459 </script>
460 <style>
461 <?php do_action( 'wpsc_css_backend' ); ?>
462 </style>
463 <?php
464 }
465 }
466 endif;
467
468 WPSC_Framework::init();
469