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

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

630 lines 21.9 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_Frontend' ) ) :
7
8 final class WPSC_Frontend {
9
10 /**
11 * Initialize this class
12 */
13 public static function init() {
14
15 // Load scripts.
16 add_action( 'wp_enqueue_scripts', array( __CLASS__, 'load_scripts' ) );
17
18 // ticket url redirect.
19 add_action( 'init', array( __CLASS__, 'ticket_url_redirect' ) );
20 }
21
22 /**
23 * Ticket url support for old versions
24 *
25 * @return void
26 */
27 public static function ticket_url_redirect() {
28
29 if ( isset( $_REQUEST['ticket_id'] ) && isset( $_REQUEST['auth_code'] ) ) { // phpcs:ignore
30
31 $id = isset( $_REQUEST['ticket_id'] ) ? intval( $_REQUEST['ticket_id'] ) : 0; // phpcs:ignore
32 if ( ! $id ) {
33 return;
34 }
35
36 $ticket = new WPSC_Ticket( $id );
37 if ( ! $ticket->id ) {
38 return;
39 }
40
41 wp_safe_redirect( $ticket->get_url() );
42 exit;
43 }
44 }
45
46 /**
47 * Load JS and CSS scripts
48 *
49 * @return void
50 */
51 public static function load_scripts() {
52
53 // Check load scripts setting to load script on perticular page.
54 $page_settings = get_option( 'wpsc-gs-page-settings' );
55 if ( $page_settings['load-scripts'] == 'custom' && ! in_array( get_the_id(), $page_settings['load-script-pages'] ) ) {
56 return;
57 }
58
59 // jquery.
60 wp_enqueue_script( 'jquery' );
61 wp_enqueue_script( 'jquery-ui-core' );
62
63 // TinyMCE.
64 wp_enqueue_editor();
65
66 // jQuery UI Effects.
67 wp_enqueue_script( 'jquery-effects-core' );
68 wp_enqueue_script( 'jquery-effects-slide' );
69
70 // Sortable.
71 wp_enqueue_script( 'jquery-ui-sortable' );
72
73 // WPSC Framework.
74 wp_enqueue_script( 'wpsc-framework', WPSC_PLUGIN_URL . 'framework/scripts.js', array( 'jquery' ), WPSC_VERSION, true );
75
76 if ( is_rtl() ) {
77 wp_enqueue_style( 'wpsc-framework', WPSC_PLUGIN_URL . 'framework/style-rtl.css', array(), WPSC_VERSION );
78 } else {
79 wp_enqueue_style( 'wpsc-framework', WPSC_PLUGIN_URL . 'framework/style.css', array(), WPSC_VERSION );
80 }
81
82 wp_localize_script( 'wpsc-framework', 'supportcandy', self::get_localization_data() );
83
84 // selectWoo.
85 wp_enqueue_script( 'wpsc-selectWoo', WPSC_PLUGIN_URL . 'asset/js/selectWoo/selectWoo.full.min.js', array( 'jquery' ), WPSC_VERSION, true );
86 if ( file_exists( WPSC_ABSPATH . 'asset/js/selectWoo/i18n/' . get_locale() . '.js' ) ) {
87 wp_enqueue_script( 'selectWoo-lang', WPSC_PLUGIN_URL . 'asset/js/selectWoo/i18n/' . get_locale() . '.js', array( 'jquery' ), WPSC_VERSION, true );
88 }
89 wp_enqueue_style( 'wpsc-select2', WPSC_PLUGIN_URL . 'asset/css/select2.css', array(), WPSC_VERSION );
90
91 // gpopover.
92 wp_enqueue_script( 'gpopover', WPSC_PLUGIN_URL . 'asset/libs/gpopover/jquery.gpopover.js', array( 'jquery' ), WPSC_VERSION, true );
93 wp_enqueue_style( 'gpopover', WPSC_PLUGIN_URL . 'asset/libs/gpopover/jquery.gpopover.css', array(), WPSC_VERSION );
94
95 // jquery circle progress.
96 wp_enqueue_script( 'jquery-circle-progress', WPSC_PLUGIN_URL . 'asset/libs/jquery-circle-progress/circle-progress.min.js', array( 'jquery' ), WPSC_VERSION, true );
97
98 // flatpickr.
99 wp_enqueue_script( 'flatpickr-js', WPSC_PLUGIN_URL . 'asset/libs/flatpickr/flatpickr.js', array( 'jquery' ), WPSC_VERSION, true );
100 wp_enqueue_style( 'flatpickr-css', WPSC_PLUGIN_URL . 'asset/libs/flatpickr/flatpickr.min.css', array(), WPSC_VERSION );
101
102 if ( file_exists( WPSC_ABSPATH . 'asset/libs/flatpickr/l10n/' . WPSC_Functions::get_locale_iso() . '.js' ) ) {
103 wp_enqueue_script( 'flatpickr-lang', WPSC_PLUGIN_URL . 'asset/libs/flatpickr/l10n/' . WPSC_Functions::get_locale_iso() . '.js', array( 'jquery' ), WPSC_VERSION, true );
104 }
105
106 // fullcalendar.
107 wp_enqueue_script( 'fullcalendar', WPSC_PLUGIN_URL . 'asset/libs/fullcalendar/lib/main.min.js', array( 'jquery' ), WPSC_VERSION, true );
108 wp_enqueue_script( 'fullcalendar-locales', WPSC_PLUGIN_URL . 'asset/libs/fullcalendar/lib/locales-all.min.js', array( 'jquery' ), WPSC_VERSION, true );
109 wp_enqueue_style( 'fullcalendar', WPSC_PLUGIN_URL . 'asset/libs/fullcalendar/lib/main.min.css', array(), WPSC_VERSION );
110
111 // DataTables.
112 wp_enqueue_script( 'datatables', WPSC_PLUGIN_URL . 'asset/libs/DataTables/datatables.min.js', array( 'jquery' ), WPSC_VERSION, true );
113 wp_enqueue_style( 'datatables', WPSC_PLUGIN_URL . 'asset/libs/DataTables/datatables.min.css', array(), WPSC_VERSION );
114
115 // ChartJs.
116 wp_enqueue_script( 'chartjs', WPSC_PLUGIN_URL . 'asset/libs/chartjs/dist/chart.min.js', array( 'jquery' ), WPSC_VERSION, true );
117 }
118
119 /**
120 * Get localization data for the admin scripts
121 *
122 * @return array
123 */
124 private static function get_localization_data() {
125
126 $gs = get_option( 'wpsc-gs-general' );
127 $page_settings = get_option( 'wpsc-gs-page-settings' );
128 $file_settings = get_option( 'wpsc-gs-file-attachments' );
129
130 $localizations = array(
131 'ajax_url' => admin_url( 'admin-ajax.php' ),
132 'urls' => array(
133 'support' => $page_settings['support-page'] ? get_permalink( $page_settings['support-page'] ) : '',
134 'open_ticket' => $page_settings['open-ticket-page'] ? get_permalink( $page_settings['open-ticket-page'] ) : '',
135 ),
136 'plugin_url' => WPSC_PLUGIN_URL,
137 'version' => WPSC_VERSION,
138 'loader_html' => WPSC_Framework::loader_html(),
139 'inline_loader' => WPSC_Framework::inline_loader(),
140 'is_frontend' => 1,
141 'is_reload' => 1,
142 'reply_form_position' => $gs['reply-form-position'],
143 'allowed_file_extensions' => array_map( 'trim', array_map( 'strtolower', explode( ',', $file_settings['allowed-file-extensions'] ) ) ),
144 'nonce' => wp_create_nonce( 'general' ),
145 'translations' => array(
146 'req_fields_error' => esc_attr__( 'Required fields can not be empty!', 'supportcandy' ),
147 'datatables' => array(
148 'emptyTable' => esc_attr__( 'No Records', 'supportcandy' ),
149 'zeroRecords' => esc_attr__( 'No Records', 'supportcandy' ),
150 'info' => sprintf(
151 /* translators: e.g. Showing 1 to 20 of 300 records */
152 esc_attr__( 'Showing %1$s to %2$s of %3$s records', 'supportcandy' ),
153 '_START_',
154 '_END_',
155 '_TOTAL_'
156 ),
157 'infoEmpty' => '',
158 'loadingRecords' => '',
159 'processing' => '',
160 'infoFiltered' => '',
161 'search' => esc_attr__( 'Search:', 'supportcandy' ),
162 'paginate' => array(
163 'first' => esc_attr__( 'First', 'supportcandy' ),
164 'previous' => esc_attr__( 'Previous', 'supportcandy' ),
165 'next' => esc_attr__( 'Next', 'supportcandy' ),
166 'last' => esc_attr__( 'Last', 'supportcandy' ),
167 ),
168 ),
169 ),
170 'temp' => array(),
171 'home_url' => home_url(),
172 );
173
174 return apply_filters( 'wpsc_frontend_localizations', $localizations );
175 }
176
177 /**
178 * Authentication screen
179 *
180 * @param boolean $otp_login - otp login option.
181 * @param boolean $additional_links - additional links.
182 * @return void
183 */
184 public static function load_authentication_screen( $otp_login = true, $additional_links = true ) {
185
186 $gs = get_option( 'wpsc-gs-general' );
187 $page_settings = get_option( 'wpsc-gs-page-settings' );
188 $recaptcha = get_option( 'wpsc-recaptcha-settings' );
189 $tc = get_option( 'wpsc-term-and-conditions' );
190 $gdpr = get_option( 'wpsc-gdpr-settings' );
191 ?>
192 <div class="wpsc-auth-container">
193 <div class="auth-inner-container">
194 <h2><?php esc_attr_e( 'Please sign in', 'supportcandy' ); ?></h2>
195 <form onsubmit="return false;" class="wpsc-login wpsc-default-login">
196 <?php
197 if ( $page_settings['user-login'] === 'default' ) {
198 ?>
199
200 <input type="text" name="username" placeholder="<?php esc_attr_e( 'Username / Email address', 'supportcandy' ); ?>" autocomplete="off"/>
201 <input type="password" name="password" placeholder="<?php esc_attr_e( 'Password', 'supportcandy' ); ?>"/>
202 <div class="checkbox-container remember-me">
203 <input id="wpsc-remember-me" type="checkbox" name="remember_me" value="1"/>
204 <label for="wpsc-remember-me"><?php esc_attr_e( 'Remember me', 'supportcandy' ); ?></label>
205 </div>
206 <?php
207
208 // recaptcha.
209 if ( $recaptcha['allow-recaptcha'] === 1 && $recaptcha['recaptcha-version'] == 2 && $recaptcha['recaptcha-site-key'] && $recaptcha['recaptcha-secret-key'] ) :
210 $unique_id = uniqid( 'wpsc_' )
211 ?>
212 <script src="https://www.google.com/recaptcha/api.js?onload=recaptchaCallback&render=explicit" async defer></script> <?php // phpcs:ignore ?>
213 <div id="<?php echo esc_attr( $unique_id ); ?>" style="margin-bottom: 5px;"></div>
214 <script>
215 var recaptchaCallback = function() {
216 var obj = jQuery('#<?php echo esc_attr( $unique_id ); ?>');
217 grecaptcha.render(obj.attr("id"), {
218 "sitekey" : "<?php echo esc_attr( $recaptcha['recaptcha-site-key'] ); ?>",
219 "callback" : function(token) {
220 obj.closest('form').find(".g-recaptcha-response").val(token);
221 }
222 });
223 }
224 </script>
225 <?php
226 endif;
227 if ( $recaptcha['allow-recaptcha'] === 1 && $recaptcha['recaptcha-version'] == 3 && $recaptcha['recaptcha-site-key'] && $recaptcha['recaptcha-secret-key'] ) :
228 ?>
229 <script src="https://www.google.com/recaptcha/api.js?render=<?php echo esc_attr( $recaptcha['recaptcha-site-key'] ); ?>"></script> <?php // phpcs:ignore ?>
230 <?php
231 endif;
232 ?>
233
234 <button class="wpsc-button normal primary" onclick="wpsc_submit_login_form(this)"><?php esc_attr_e( 'Sign In', 'supportcandy' ); ?></button>
235 <input type="hidden" name="action" value="wpsc_default_login"/>
236 <input type="hidden" name="_ajax_nonce" value="<?php echo esc_attr( wp_create_nonce( 'wpsc_default_login' ) ); ?>"/>
237 <?php
238
239 } else {
240 $host = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '';
241 $uri = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
242
243 $redirect_url = ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http' ) . '://' . $host . $uri;
244 $login_url = $page_settings['user-login'] == 'custom' ? $page_settings['custom-login-url'] : wp_login_url( $redirect_url );
245 ?>
246 <button class="wpsc-button normal primary" onclick="wpsc_custom_login( this, '<?php echo esc_url( $login_url ); ?>' )"><?php esc_attr_e( 'Sign In', 'supportcandy' ); ?></button>
247 <?php
248
249 }
250 ?>
251 </form>
252
253 <div class="auth-links">
254 <?php
255
256 if ( $page_settings['user-login'] === 'default' ) :
257 ?>
258 <a class="wpsc-link wpsc-forgot-password" href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php esc_attr_e( 'Forgot your password?', 'supportcandy' ); ?></a>
259 <?php
260 endif;
261
262 if ( $page_settings['user-registration'] == 'default' ) {
263
264 $registration_url = 'javascript:wpsc_get_default_registration();';
265
266 } elseif ( $page_settings['user-registration'] == 'wp-default' ) {
267
268 $registration_url = wp_registration_url();
269
270 } elseif ( $page_settings['user-registration'] == 'custom' ) {
271
272 $registration_url = $page_settings['custom-registration-url'];
273 }
274 if ( $page_settings['user-registration'] !== 'disable' ) {
275 ?>
276 <a class="wpsc-link wpsc-register" href="<?php echo esc_attr( $registration_url ); ?>"><?php esc_attr_e( 'Register now', 'supportcandy' ); ?></a>
277 <?php
278 }
279 if ( $otp_login && $page_settings['otp-login'] && in_array( 'guest', $gs['allow-create-ticket'] ) ) :
280 ?>
281 <a class="wpsc-link wpsc-otp-signin" href="javascript:wpsc_get_guest_sign_in();"><?php esc_attr_e( 'Sign-in using one time password', 'supportcandy' ); ?></a>
282 <?php
283 endif;
284
285 if ( $additional_links && in_array( 'guest', $gs['allow-create-ticket'] ) ) :
286 ?>
287 <a class="wpsc-link wpsc-guest-create-ticket" href="javascript:wpsc_get_guest_ticket_form();"><?php esc_attr_e( 'Create new ticket as guest', 'supportcandy' ); ?></a>
288 <?php
289 endif;
290
291 if ( $additional_links && $page_settings['open-ticket-page'] ) :
292 ?>
293 <a class="wpsc-link wpsc-otp-open-ticket" href="<?php echo esc_url( get_permalink( $page_settings['open-ticket-page'] ) ); ?>"><?php esc_attr_e( 'Open existing ticket using one time password', 'supportcandy' ); ?></a>
294 <?php
295 endif;
296 ?>
297 </div>
298 </div>
299 <script>
300 /**
301 * Submit default login form
302 */
303 function wpsc_submit_login_form(el) {
304
305 var dataform = new FormData(jQuery(el).closest('form')[0]);
306 var username = dataform.get('username').trim();
307 var password = dataform.get('password').trim();
308 if (!username || !password) {
309 alert(supportcandy.translations.req_fields_missing);
310 return;
311 }
312 <?php
313 if ( $recaptcha['allow-recaptcha'] === 1 && $recaptcha['recaptcha-version'] == 3 && $recaptcha['recaptcha-site-key'] && $recaptcha['recaptcha-secret-key'] ) {
314 ?>
315 grecaptcha.ready(function() {
316 grecaptcha.execute('<?php echo esc_attr( $recaptcha['recaptcha-site-key'] ); ?>', {action: 'submit_login'}).then(function(token) {
317 dataform.append('g-recaptcha-response', token);
318 wpsc_post_login_form(el, dataform);
319 });
320 });
321 <?php
322 } elseif ( $recaptcha['allow-recaptcha'] === 1 && $recaptcha['recaptcha-version'] == 2 && $recaptcha['recaptcha-site-key'] && $recaptcha['recaptcha-secret-key'] ) {
323 ?>
324 var token = dataform.get('g-recaptcha-response');
325 if (!token) {
326 alert("<?php esc_attr_e( 'Captcha not set!', 'supportcandy' ); ?>");
327 return;
328 }
329 wpsc_post_login_form(el, dataform);
330 <?php
331 } else {
332 ?>
333
334 wpsc_post_login_form(el, dataform);
335 <?php
336 }
337 ?>
338 }
339
340 /**
341 * Submit login form
342 */
343 function wpsc_post_login_form(el, dataform) {
344
345 jQuery(el).text(supportcandy.translations.please_wait);
346 jQuery.ajax({
347 url: supportcandy.ajax_url,
348 type: 'POST',
349 data: dataform,
350 processData: false,
351 contentType: false
352 }).done(function (response) {
353 if (response.success != 1) alert(supportcandy.translations.incorrect_login);
354 }).fail(function (res) {
355 alert(supportcandy.translations.something_wrong);
356 }).always(function () {
357 window.location.reload();
358 });
359 }
360
361 /**
362 * Custom login
363 */
364 function wpsc_custom_login(el, url) {
365
366 jQuery(el).text(supportcandy.translations.please_wait);
367 window.location.href = url;
368 }
369
370 /**
371 * Get default registration page
372 */
373 function wpsc_get_default_registration() {
374
375 jQuery('.auth-inner-container').html(supportcandy.loader_html);
376 var data = { action: 'wpsc_get_default_registration' };
377 jQuery.post(supportcandy.ajax_url, data, function (response) {
378 jQuery('.auth-inner-container').html(response);
379 });
380 }
381
382 /**
383 * Set default registration form
384 */
385 function wpsc_set_default_registration(el) {
386
387 var dataform = new FormData(jQuery(el).closest('form')[0]);
388 var firstname = dataform.get('firstname').trim();
389 var lastname = dataform.get('lastname').trim();
390 var username = dataform.get('username').trim();
391 var email_address = dataform.get('email_address').trim();
392 var password = dataform.get('password').trim();
393 var confirm_password = dataform.get('confirm_password').trim();
394 var isUsername = dataform.get('is_username').trim();
395 var isEmail = dataform.get('is_email').trim();
396
397 <?php
398 if ( $tc['allow-term-and-conditions-reg-user'] ) {
399 ?>
400 var tandcCheckbox = dataform.get('wpsc-tandc-reg-user');
401 if ( ! tandcCheckbox ){
402 alert(supportcandy.translations.req_term_cond);
403 return;
404 }
405 <?php
406 }
407 if ( $gdpr['allow-gdpr-reg-user'] ) {
408 ?>
409 var gdprCheckbox = dataform.get('wpsc-gdpr-reg-user');
410 if ( gdprCheckbox != 1 ){
411 alert(supportcandy.translations.req_gdpr);
412 return;
413 }
414 <?php
415 }
416 ?>
417
418 if (!firstname || !lastname || !username || !email_address || !password || !confirm_password) {
419 alert(supportcandy.translations.req_fields_missing);
420 return;
421 }
422
423 if (!validateEmail(email_address)) {
424 alert(supportcandy.translations.incorrect_email);
425 return;
426 }
427
428 if (isUsername != 1) {
429 alert(supportcandy.translations.unsername_unavailable);
430 return;
431 }
432
433 if (isEmail != 1) {
434 alert(supportcandy.translations.email_unavailable);
435 return;
436 }
437
438 if (password !== confirm_password) {
439 alert(supportcandy.translations.incorrect_password);
440 return;
441 }
442
443 <?php
444 if ( $recaptcha['allow-recaptcha'] === 1 && $recaptcha['recaptcha-version'] == 3 && $recaptcha['recaptcha-site-key'] && $recaptcha['recaptcha-secret-key'] ) {
445 ?>
446 grecaptcha.ready(function() {
447 grecaptcha.execute('<?php echo esc_attr( $recaptcha['recaptcha-site-key'] ); ?>', {action: 'submit_registration'}).then(function(token) {
448 dataform.append('g-recaptcha-response', token);
449 wpsc_authenticate_registration(el, dataform);
450 });
451 });
452 <?php
453 } elseif ( $recaptcha['allow-recaptcha'] === 1 && $recaptcha['recaptcha-version'] == 2 && $recaptcha['recaptcha-site-key'] && $recaptcha['recaptcha-secret-key'] ) {
454 ?>
455 var token = dataform.get('g-recaptcha-response');
456 if (!token) {
457 alert("<?php esc_attr_e( 'Captcha not set!', 'supportcandy' ); ?>");
458 return;
459 }
460 wpsc_authenticate_registration(el, dataform);
461 <?php
462 } else {
463 ?>
464
465 wpsc_authenticate_registration(el, dataform);
466 <?php
467 }
468 ?>
469 }
470
471 /**
472 * Post registration form
473 */
474 function wpsc_authenticate_registration(el, dataform) {
475
476 jQuery('.auth-inner-container').html(supportcandy.loader_html);
477 jQuery.ajax({
478 url: supportcandy.ajax_url,
479 type: 'POST',
480 data: dataform,
481 processData: false,
482 contentType: false
483 }).done(function (res) {
484 if (typeof(res) == "object") {
485 alert(supportcandy.translations.something_wrong);
486 wpsc_get_default_registration();
487 } else {
488 jQuery('.auth-inner-container').html(res);
489 }
490 }).fail(function (res) {
491 alert(supportcandy.translations.something_wrong);
492 window.location.reload();
493 });
494 }
495
496 /**
497 * Register user
498 */
499 function wpsc_confirm_registration(el) {
500
501 jQuery('.auth-inner-container').html(supportcandy.loader_html);
502 var dataform = new FormData(jQuery(el).closest('form')[0]);
503 jQuery.ajax({
504 url: supportcandy.ajax_url,
505 type: 'POST',
506 data: dataform,
507 processData: false,
508 contentType: false
509 }).done(function (res) {
510 if (res.isSuccess == 1) {
511 window.location.reload();
512 } else {
513 alert(supportcandy.translations.something_wrong);
514 wpsc_get_default_registration();
515 }
516 });
517 }
518
519 /**
520 * Get guest otp login screen
521 *
522 * @return void
523 */
524 function wpsc_get_guest_sign_in() {
525
526 jQuery('.auth-inner-container').html(supportcandy.loader_html);
527 var data = { action: 'wpsc_get_guest_sign_in' };
528 jQuery.post(supportcandy.ajax_url, data, function (res) {
529 if (typeof(res) == "object") {
530 alert(supportcandy.translations.something_wrong);
531 window.location.reload();
532 } else {
533 jQuery('.auth-inner-container').html(res);
534 }
535 });
536 }
537
538 /**
539 * Send login OTP
540 *
541 * @return void
542 */
543 function wpsc_authenticate_guest_login(el) {
544
545 var dataform = new FormData(jQuery(el).closest('form')[0]);
546
547 var email_address = dataform.get('email_address').trim();
548 if ( ! email_address ) {
549 alert(supportcandy.translations.req_fields_missing);
550 return;
551 }
552
553 if (!validateEmail(email_address)) {
554 alert(supportcandy.translations.incorrect_email);
555 return;
556 }
557
558 jQuery(el).text(supportcandy.translations.please_wait);
559 jQuery.ajax({
560 url: supportcandy.ajax_url,
561 type: 'POST',
562 data: dataform,
563 processData: false,
564 contentType: false
565 }).done(function (res) {
566 if (typeof(res) == "object") {
567 alert(supportcandy.translations.something_wrong);
568 wpsc_get_guest_sign_in();
569 } else {
570 jQuery('.auth-inner-container').html(res);
571 }
572 }).fail(function (res) {
573 alert(supportcandy.translations.something_wrong);
574 window.location.reload();
575 });
576 }
577
578 /**
579 * Confirm guest login auth
580 *
581 * @return void
582 */
583 function wpsc_confirm_guest_login(el) {
584
585 jQuery('.auth-inner-container').html(supportcandy.loader_html);
586 var dataform = new FormData(jQuery(el).closest('form')[0]);
587 jQuery.ajax({
588 url: supportcandy.ajax_url,
589 type: 'POST',
590 data: dataform,
591 processData: false,
592 contentType: false
593 }).done(function (res) {
594 if (res.isSuccess == 1) {
595 window.location.reload();
596 } else {
597 alert(supportcandy.translations.something_wrong);
598 wpsc_get_guest_sign_in();
599 }
600 });
601 }
602 </script>
603 </div>
604 <?php
605 }
606
607 /**
608 * Load HTML snippets that can be used by js to load dynamically
609 *
610 * @return void
611 */
612 public static function load_html_snippets() {
613 ?>
614
615 <div class="wpsc-page-snippets" style="display: none;">
616 <div class="wpsc-editor-attachment upload-waiting">
617 <div class="attachment-label"></div>
618 <div class="attachment-remove" onclick="wpsc_remove_attachment(this)">
619 <?php WPSC_Icons::get( 'times' ); ?>
620 </div>
621 <div class="attachment-waiting"></div>
622 </div>
623 </div>
624 <?php
625 }
626 }
627 endif;
628
629 WPSC_Frontend::init();
630