PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.3.9
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.3.9
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.3.9, at includes/frontend/class-wpsc-frontend.php

624 lines 21.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_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
396 <?php
397 if ( $tc['allow-term-and-conditions-reg-user'] ) {
398 ?>
399 var tandcCheckbox = dataform.get('wpsc-tandc-reg-user');
400 if ( ! tandcCheckbox ){
401 alert(supportcandy.translations.req_term_cond);
402 return;
403 }
404 <?php
405 }
406 if ( $gdpr['allow-gdpr-reg-user'] ) {
407 ?>
408 var gdprCheckbox = dataform.get('wpsc-gdpr-reg-user');
409 if ( gdprCheckbox != 1 ){
410 alert(supportcandy.translations.req_gdpr);
411 return;
412 }
413 <?php
414 }
415 ?>
416
417 if (!firstname || !lastname || !username || !email_address || !password || !confirm_password) {
418 alert(supportcandy.translations.req_fields_missing);
419 return;
420 }
421
422 if (!validateEmail(email_address)) {
423 alert(supportcandy.translations.incorrect_email);
424 return;
425 }
426
427 if (isUsername != 1) {
428 alert(supportcandy.translations.unsername_unavailable);
429 return;
430 }
431
432 if (password !== confirm_password) {
433 alert(supportcandy.translations.incorrect_password);
434 return;
435 }
436
437 <?php
438 if ( $recaptcha['allow-recaptcha'] === 1 && $recaptcha['recaptcha-version'] == 3 && $recaptcha['recaptcha-site-key'] && $recaptcha['recaptcha-secret-key'] ) {
439 ?>
440 grecaptcha.ready(function() {
441 grecaptcha.execute('<?php echo esc_attr( $recaptcha['recaptcha-site-key'] ); ?>', {action: 'submit_registration'}).then(function(token) {
442 dataform.append('g-recaptcha-response', token);
443 wpsc_authenticate_registration(el, dataform);
444 });
445 });
446 <?php
447 } elseif ( $recaptcha['allow-recaptcha'] === 1 && $recaptcha['recaptcha-version'] == 2 && $recaptcha['recaptcha-site-key'] && $recaptcha['recaptcha-secret-key'] ) {
448 ?>
449 var token = dataform.get('g-recaptcha-response');
450 if (!token) {
451 alert("<?php esc_attr_e( 'Captcha not set!', 'supportcandy' ); ?>");
452 return;
453 }
454 wpsc_authenticate_registration(el, dataform);
455 <?php
456 } else {
457 ?>
458
459 wpsc_authenticate_registration(el, dataform);
460 <?php
461 }
462 ?>
463 }
464
465 /**
466 * Post registration form
467 */
468 function wpsc_authenticate_registration(el, dataform) {
469
470 jQuery('.auth-inner-container').html(supportcandy.loader_html);
471 jQuery.ajax({
472 url: supportcandy.ajax_url,
473 type: 'POST',
474 data: dataform,
475 processData: false,
476 contentType: false
477 }).done(function (res) {
478 if (typeof(res) == "object") {
479 alert(supportcandy.translations.something_wrong);
480 wpsc_get_default_registration();
481 } else {
482 jQuery('.auth-inner-container').html(res);
483 }
484 }).fail(function (res) {
485 alert(supportcandy.translations.something_wrong);
486 window.location.reload();
487 });
488 }
489
490 /**
491 * Register user
492 */
493 function wpsc_confirm_registration(el) {
494
495 jQuery('.auth-inner-container').html(supportcandy.loader_html);
496 var dataform = new FormData(jQuery(el).closest('form')[0]);
497 jQuery.ajax({
498 url: supportcandy.ajax_url,
499 type: 'POST',
500 data: dataform,
501 processData: false,
502 contentType: false
503 }).done(function (res) {
504 if (res.isSuccess == 1) {
505 window.location.reload();
506 } else {
507 alert(supportcandy.translations.something_wrong);
508 wpsc_get_default_registration();
509 }
510 });
511 }
512
513 /**
514 * Get guest otp login screen
515 *
516 * @return void
517 */
518 function wpsc_get_guest_sign_in() {
519
520 jQuery('.auth-inner-container').html(supportcandy.loader_html);
521 var data = { action: 'wpsc_get_guest_sign_in' };
522 jQuery.post(supportcandy.ajax_url, data, function (res) {
523 if (typeof(res) == "object") {
524 alert(supportcandy.translations.something_wrong);
525 window.location.reload();
526 } else {
527 jQuery('.auth-inner-container').html(res);
528 }
529 });
530 }
531
532 /**
533 * Send login OTP
534 *
535 * @return void
536 */
537 function wpsc_authenticate_guest_login(el) {
538
539 var dataform = new FormData(jQuery(el).closest('form')[0]);
540
541 var email_address = dataform.get('email_address').trim();
542 if ( ! email_address ) {
543 alert(supportcandy.translations.req_fields_missing);
544 return;
545 }
546
547 if (!validateEmail(email_address)) {
548 alert(supportcandy.translations.incorrect_email);
549 return;
550 }
551
552 jQuery(el).text(supportcandy.translations.please_wait);
553 jQuery.ajax({
554 url: supportcandy.ajax_url,
555 type: 'POST',
556 data: dataform,
557 processData: false,
558 contentType: false
559 }).done(function (res) {
560 if (typeof(res) == "object") {
561 alert(supportcandy.translations.something_wrong);
562 wpsc_get_guest_sign_in();
563 } else {
564 jQuery('.auth-inner-container').html(res);
565 }
566 }).fail(function (res) {
567 alert(supportcandy.translations.something_wrong);
568 window.location.reload();
569 });
570 }
571
572 /**
573 * Confirm guest login auth
574 *
575 * @return void
576 */
577 function wpsc_confirm_guest_login(el) {
578
579 jQuery('.auth-inner-container').html(supportcandy.loader_html);
580 var dataform = new FormData(jQuery(el).closest('form')[0]);
581 jQuery.ajax({
582 url: supportcandy.ajax_url,
583 type: 'POST',
584 data: dataform,
585 processData: false,
586 contentType: false
587 }).done(function (res) {
588 if (res.isSuccess == 1) {
589 window.location.reload();
590 } else {
591 alert(supportcandy.translations.something_wrong);
592 wpsc_get_guest_sign_in();
593 }
594 });
595 }
596 </script>
597 </div>
598 <?php
599 }
600
601 /**
602 * Load HTML snippets that can be used by js to load dynamically
603 *
604 * @return void
605 */
606 public static function load_html_snippets() {
607 ?>
608
609 <div class="wpsc-page-snippets" style="display: none;">
610 <div class="wpsc-editor-attachment upload-waiting">
611 <div class="attachment-label"></div>
612 <div class="attachment-remove" onclick="wpsc_remove_attachment(this)">
613 <?php WPSC_Icons::get( 'times' ); ?>
614 </div>
615 <div class="attachment-waiting"></div>
616 </div>
617 </div>
618 <?php
619 }
620 }
621 endif;
622
623 WPSC_Frontend::init();
624