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 / includes / admin / ai-assistant / class-wpsc-ai-admin.php

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

86 lines 2.5 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_Ai_Admin' ) ) :
7
8 final class WPSC_Ai_Admin {
9
10 /**
11 * Initialize this class
12 *
13 * @return void
14 */
15 public static function init() {
16
17 // load scripts & styles.
18 add_action( 'wpsc_js_backend', array( __CLASS__, 'backend_scripts' ) );
19 add_action( 'wpsc_css_backend', array( __CLASS__, 'backend_styles' ) );
20
21 // Add localizations for AI assistant.
22 add_filter( 'wpsc_admin_localizations', array( __CLASS__, 'localizations' ) );
23 add_filter( 'wpsc_frontend_localizations', array( __CLASS__, 'localizations' ) );
24 }
25
26 /**
27 * Backend scripts
28 *
29 * @return void
30 */
31 public static function backend_scripts() {
32
33 echo file_get_contents( WPSC_ABSPATH . 'asset/js/ai-assistant/admin.js' ) . PHP_EOL . PHP_EOL; // phpcs:ignore
34 echo file_get_contents( WPSC_ABSPATH . 'asset/js/ai-assistant/ai-training.js' ) . PHP_EOL . PHP_EOL; // phpcs:ignore
35 echo file_get_contents( WPSC_ABSPATH . 'asset/js/ai-assistant/script.js' ) . PHP_EOL . PHP_EOL; // phpcs:ignore
36 }
37
38 /**
39 * Backend styles
40 *
41 * @return void
42 */
43 public static function backend_styles() {
44
45 if ( is_rtl() ) {
46 echo file_get_contents( WPSC_ABSPATH . 'asset/css/ai-assistant/admin-rtl.css' ) . PHP_EOL . PHP_EOL; // phpcs:ignore
47 } else {
48 echo file_get_contents( WPSC_ABSPATH . 'asset/css/ai-assistant/admin.css' ) . PHP_EOL . PHP_EOL; // phpcs:ignore
49 }
50 }
51
52 /**
53 * Add localizations for AI assistant
54 *
55 * @param array $localizations - existing localizations.
56 * @return array
57 */
58 public static function localizations( $localizations ) {
59
60 $localizations['ai_loader_html'] = self::ai_loader_html();
61 $localizations['translations']['empty_desc_warning'] = esc_attr__( 'Write something to get AI assistance.', 'supportcandy' );
62 $localizations['translations']['valid_url'] = esc_attr__( 'Please enter valid URL(s)', 'supportcandy' );
63 $localizations['translations']['delete_all_posts'] = esc_attr__( 'Deleting all posts will permanently remove any existing training data. Do you want to proceed?', 'supportcandy' );
64 return $localizations;
65 }
66
67 /**
68 * Loader HTML
69 *
70 * @return string - Returns HTML.
71 */
72 public static function ai_loader_html() {
73
74 ob_start();
75 ?>
76 <div class="wpsc-ai-loader">
77 <img src="<?php echo esc_url( WPSC_PLUGIN_URL . 'asset/images/loader.gif' ); ?>" alt="Loading..." />
78 </div>
79 <?php
80 return ob_get_clean();
81 }
82 }
83 endif;
84
85 WPSC_Ai_Admin::init();
86