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 / includes / frontend / class-wpsc-shortcode-five.php

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

112 lines 2.6 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_Shortcode_Five' ) ) :
7
8 final class WPSC_Shortcode_Five {
9
10 /**
11 * Initialize this class
12 */
13 public static function init() {
14
15 // register shortcode.
16 add_shortcode( 'wpsc_my_profile', array( __CLASS__, 'layout' ) );
17 }
18
19 /**
20 * Layout for this shortcode
21 *
22 * @param array $attrs - Shortcode attributes.
23 * @return string
24 */
25 public static function layout( $attrs ) {
26
27 $current_user = WPSC_Current_User::$current_user;
28
29 // logout if guest login is open-ticket.
30 if ( WPSC_Current_User::$login_type == 'guest' && WPSC_Current_User::$guest_login_type == 'open-ticket' ) {
31 $current_user->logout();
32 }
33
34 ob_start();?>
35 <div id="wpsc-container" style="display:none;">
36 <div class="wpsc-shortcode-container" style="border: none !important;">
37 <?php
38
39 // logged in.
40 if ( $current_user->is_customer ) {
41 // js events.
42 add_action( 'wpsc_js_ready', array( __CLASS__, 'register_js_ready_function' ) );
43 ?>
44 <div class="wpsc-body"></div>
45 <?php
46 } else {
47 // Not logged in.
48 WPSC_Frontend::load_authentication_screen( true, false );
49 }
50 ?>
51
52 </div>
53 </div>
54 <?php
55 WPSC_Frontend::load_html_snippets();
56 self::load_js_functions();
57 return ob_get_clean();
58 }
59
60 /**
61 * Load js functions for this shortcode
62 *
63 * @return void
64 */
65 public static function load_js_functions() {
66 ?>
67
68 <script type="text/javascript">
69
70 /**
71 * Get create ticket form
72 */
73 function wpsc_get_user_profile(is_humbargar = false) {
74
75 jQuery('.wpsc-body').html(supportcandy.loader_html);
76
77 if (supportcandy.is_reload != 1) {
78 wpsc_scroll_top();
79 } else { supportcandy.is_reload = 0 }
80
81 var url = new URL(window.location.href);
82 var search_params = url.searchParams;
83
84 var data = { action: 'wpsc_get_user_profile'};
85 search_params.forEach(function(value, key) {
86 data[key] = value;
87 });
88 jQuery.post(supportcandy.ajax_url, data).done(function (response) {
89 jQuery('.wpsc-body').html(response);
90 wpsc_reset_responsive_style();
91 }).fail(function(response){
92 jQuery('.wpsc-body').html('<div style="display:flex; justify-content:center; margin:0 15px 15px; width:100%;"><?php esc_attr_e( 'Unauthorized access!', 'supportcandy' ); ?></div>');
93 });
94 }
95 </script>
96 <?php
97 }
98
99 /**
100 * JS ready function
101 *
102 * @return void
103 */
104 public static function register_js_ready_function() {
105
106 echo 'wpsc_get_user_profile();' . PHP_EOL;
107 }
108 }
109 endif;
110
111 WPSC_Shortcode_Five::init();
112