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

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

299 lines 10.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_Admin' ) ) :
7
8 final class WPSC_Admin {
9
10 /**
11 * Initialize the class
12 *
13 * @return void
14 */
15 public static function init() {
16
17 add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_scripts' ) );
18 add_action( 'admin_menu', array( __CLASS__, 'load_admin_menus' ), 10 );
19 }
20
21 /**
22 * Load JS and CSS scripts
23 *
24 * @return void
25 */
26 public static function load_scripts() {
27
28 if ( ! WPSC_Functions::is_wpsc_page() ) {
29 return;
30 }
31
32 // jquery.
33 wp_enqueue_script( 'jquery' );
34 wp_enqueue_script( 'jquery-ui-core' );
35 wp_enqueue_style( 'wpsc-jquery-ui', WPSC_PLUGIN_URL . 'asset/css/jquery-ui.css', array(), WPSC_VERSION );
36
37 // TinyMCE.
38 wp_enqueue_editor();
39
40 // jQuery UI Effects.
41 wp_enqueue_script( 'jquery-effects-core' );
42 wp_enqueue_script( 'jquery-effects-slide' );
43
44 // color picker.
45 wp_enqueue_script( 'wp-color-picker' );
46 wp_enqueue_style( 'wp-color-picker' );
47
48 // Sortable.
49 wp_enqueue_script( 'jquery-ui-sortable' );
50
51 // Accordion.
52 wp_enqueue_script( 'jquery-ui-accordion' );
53
54 // Progrss bar.
55 wp_enqueue_script( 'jquery-ui-progressbar' );
56
57 // WPSC Scripts.
58 wp_enqueue_script( 'wpsc-admin', WPSC_PLUGIN_URL . 'asset/js/admin.js', array( 'jquery' ), WPSC_VERSION, true );
59 wp_localize_script( 'wpsc-admin', 'supportcandy', self::get_localization_data() );
60
61 // WPSC Framework.
62 wp_enqueue_script( 'wpsc-framework', WPSC_PLUGIN_URL . 'framework/scripts.js', array( 'jquery' ), WPSC_VERSION, true );
63
64 if ( is_rtl() ) {
65 wp_enqueue_style( 'wpsc-admin', WPSC_PLUGIN_URL . 'asset/css/admin-rtl.css', array(), WPSC_VERSION );
66 wp_enqueue_style( 'wpsc-framework', WPSC_PLUGIN_URL . 'framework/style-rtl.css', array(), WPSC_VERSION );
67 } else {
68 wp_enqueue_style( 'wpsc-admin', WPSC_PLUGIN_URL . 'asset/css/admin.css', array(), WPSC_VERSION );
69 wp_enqueue_style( 'wpsc-framework', WPSC_PLUGIN_URL . 'framework/style.css', array(), WPSC_VERSION );
70 }
71
72 // selectWoo.
73 wp_enqueue_script( 'selectWoo', WPSC_PLUGIN_URL . 'asset/js/selectWoo/selectWoo.full.min.js', array( 'jquery' ), WPSC_VERSION, true );
74 if ( file_exists( WPSC_ABSPATH . 'asset/js/selectWoo/i18n/' . get_locale() . '.js' ) ) {
75 wp_enqueue_script( 'selectWoo-lang', WPSC_PLUGIN_URL . 'asset/js/selectWoo/i18n/' . get_locale() . '.js', array( 'jquery' ), WPSC_VERSION, true );
76 }
77 wp_enqueue_style( 'select2', WPSC_PLUGIN_URL . 'asset/css/select2.css', array(), WPSC_VERSION );
78
79 // gpopover.
80 wp_enqueue_script( 'gpopover', WPSC_PLUGIN_URL . 'asset/libs/gpopover/jquery.gpopover.js', array( 'jquery' ), WPSC_VERSION, true );
81 wp_enqueue_style( 'gpopover', WPSC_PLUGIN_URL . 'asset/libs/gpopover/jquery.gpopover.css', array(), WPSC_VERSION );
82
83 // jquery circle progress.
84 wp_enqueue_script( 'jquery-circle-progress', WPSC_PLUGIN_URL . 'asset/libs/jquery-circle-progress/circle-progress.min.js', array( 'jquery' ), WPSC_VERSION, true );
85
86 // flatpickr.
87 wp_enqueue_script( 'flatpickr', WPSC_PLUGIN_URL . 'asset/libs/flatpickr/flatpickr.js', array( 'jquery' ), WPSC_VERSION, true );
88 wp_enqueue_style( 'flatpickr', WPSC_PLUGIN_URL . 'asset/libs/flatpickr/flatpickr.min.css', array(), WPSC_VERSION );
89
90 if ( file_exists( WPSC_ABSPATH . 'asset/libs/flatpickr/l10n/' . WPSC_Functions::get_locale_iso() . '.js' ) ) {
91 wp_enqueue_script( 'flatpickr-lang', WPSC_PLUGIN_URL . 'asset/libs/flatpickr/l10n/' . WPSC_Functions::get_locale_iso() . '.js', array( 'jquery' ), WPSC_VERSION, true );
92 }
93
94 // fullcalendar.
95 wp_enqueue_script( 'fullcalendar', WPSC_PLUGIN_URL . 'asset/libs/fullcalendar/lib/main.min.js', array( 'jquery' ), WPSC_VERSION, true );
96 wp_enqueue_script( 'fullcalendar-locales', WPSC_PLUGIN_URL . 'asset/libs/fullcalendar/lib/locales-all.min.js', array( 'jquery' ), WPSC_VERSION, true );
97 wp_enqueue_style( 'fullcalendar', WPSC_PLUGIN_URL . 'asset/libs/fullcalendar/lib/main.min.css', array(), WPSC_VERSION );
98
99 // DataTables.
100 wp_enqueue_script( 'wpsc-datatables', WPSC_PLUGIN_URL . 'asset/libs/DataTables/datatables.min.js', array( 'jquery' ), WPSC_VERSION, true );
101 wp_enqueue_style( 'wpsc-datatables', WPSC_PLUGIN_URL . 'asset/libs/DataTables/datatables.min.css', array(), WPSC_VERSION );
102
103 // ChartJs.
104 wp_enqueue_script( 'chartjs', WPSC_PLUGIN_URL . 'asset/libs/chartjs/dist/chart.min.js', array( 'jquery' ), WPSC_VERSION, true );
105 }
106
107 /**
108 * Load admin/dashboard menus
109 *
110 * @return void
111 */
112 public static function load_admin_menus() {
113
114 $current_user = WPSC_Current_User::$current_user;
115 $count_str = '';
116 if ( $current_user->is_agent && $current_user->agent->unresolved_count > 0 ) {
117 $count_str = ' <span class="update-plugins wpsc-uc"><span class="plugin-count">' . $current_user->agent->unresolved_count . '</span></span>';
118 }
119
120 add_menu_page(
121 esc_attr__( 'Support', 'supportcandy' ),
122 esc_attr__( 'Support', 'supportcandy' ) . $count_str,
123 'wpsc_agent',
124 'wpsc-tickets',
125 array( 'WPSC_Tickets', 'layout' ),
126 'dashicons-sos',
127 25
128 );
129
130 add_submenu_page(
131 'wpsc-tickets',
132 esc_attr__( 'Ticket List', 'supportcandy' ),
133 esc_attr__( 'Tickets', 'supportcandy' ),
134 'wpsc_agent',
135 'wpsc-tickets',
136 array( 'WPSC_Tickets', 'layout' )
137 );
138
139 add_submenu_page(
140 'wpsc-tickets',
141 esc_attr__( 'Customers', 'supportcandy' ),
142 esc_attr__( 'Customers', 'supportcandy' ),
143 'manage_options',
144 'wpsc-customers',
145 array( 'WPSC_Customers', 'layout' )
146 );
147
148 add_submenu_page(
149 'wpsc-tickets',
150 esc_attr__( 'Support Agents', 'supportcandy' ),
151 esc_attr__( 'Support Agents', 'supportcandy' ),
152 'manage_options',
153 'wpsc-support-agents',
154 array( 'WPSC_Support_Agents', 'layout' )
155 );
156
157 add_submenu_page(
158 'wpsc-tickets',
159 esc_attr__( 'Custom Fields', 'supportcandy' ),
160 esc_attr__( 'Custom Fields', 'supportcandy' ),
161 'manage_options',
162 'wpsc-ticket-form',
163 array( 'WPSC_CF_Settings', 'layout' )
164 );
165
166 add_submenu_page(
167 'wpsc-tickets',
168 esc_attr__( 'Ticket List', 'supportcandy' ),
169 esc_attr__( 'Ticket List', 'supportcandy' ),
170 'manage_options',
171 'wpsc-ticket-list',
172 array( 'WPSC_Ticket_List_Settings', 'layout' )
173 );
174
175 add_submenu_page(
176 'wpsc-tickets',
177 esc_attr__( 'Email Notifications', 'supportcandy' ),
178 esc_attr__( 'Email Notifications', 'supportcandy' ),
179 'manage_options',
180 'wpsc-email-notifications',
181 array( 'WPSC_EN_Settings', 'layout' )
182 );
183
184 do_action( 'wpsc_before_setting_admin_menu' );
185
186 add_submenu_page(
187 'wpsc-tickets',
188 esc_attr__( 'Settings', 'supportcandy' ),
189 esc_attr__( 'Settings', 'supportcandy' ),
190 'manage_options',
191 'wpsc-settings',
192 array( 'WPSC_Settings', 'layout' )
193 );
194
195 add_submenu_page(
196 'wpsc-tickets',
197 esc_attr__( 'Licenses', 'supportcandy' ),
198 esc_attr__( 'Licenses', 'supportcandy' ),
199 'manage_options',
200 'wpsc-license',
201 array( 'WPSC_License', 'layout' )
202 );
203
204 add_submenu_page(
205 'wpsc-tickets',
206 esc_attr__( 'Pro Features', 'supportcandy' ),
207 '<strong style="color: #F1C40F;">' . esc_attr__( 'Pro Features', 'supportcandy' ) . '</strong>',
208 'manage_options',
209 'wpsc-add-ons',
210 array( 'WPSC_Addons', 'layout' )
211 );
212
213 add_submenu_page(
214 'wpsc-tickets',
215 esc_attr__( 'Other Plugins', 'supportcandy' ),
216 '<strong style="color: #F1C40F;">' . esc_attr__( 'Other Plugins', 'supportcandy' ) . '</strong>',
217 'manage_options',
218 'wpsc-other-plugins',
219 array( 'WPSC_Other_Plugins', 'layout' )
220 );
221
222 // hidden submenu page for manual scheduled tasks.
223 add_submenu_page(
224 ' ',
225 esc_attr__( 'Task Manager', 'supportcandy' ),
226 '',
227 'manage_options',
228 'wpsc-task-manager',
229 array( 'WPSC_Task_Scheduler', 'perform_manual_scheduler' )
230 );
231
232 // hidden submenu page for recent activity.
233 add_submenu_page(
234 ' ',
235 esc_attr__( 'Recent Activites', 'supportcandy' ),
236 '',
237 'manage_options',
238 'wpsc-recent-activities',
239 array( 'WPSC_RA_Logs', 'layout' )
240 );
241 }
242
243 /**
244 * Get localization data for the admin scripts
245 *
246 * @return string
247 */
248 private static function get_localization_data() {
249
250 $gs = get_option( 'wpsc-gs-general' );
251 $file_settings = get_option( 'wpsc-gs-file-attachments' );
252 $localizations = array(
253 'ajax_url' => admin_url( 'admin-ajax.php' ),
254 'plugin_url' => WPSC_PLUGIN_URL,
255 'version' => WPSC_VERSION,
256 'loader_html' => WPSC_Framework::loader_html(),
257 'inline_loader' => WPSC_Framework::inline_loader(),
258 'is_frontend' => 0,
259 'reply_form_position' => $gs['reply-form-position'],
260 'allowed_file_extensions' => array_map( 'trim', array_map( 'strtolower', explode( ',', $file_settings['allowed-file-extensions'] ) ) ),
261 'nonce' => wp_create_nonce( 'general' ),
262 'translations' => array(
263 'req_fields_error' => esc_attr__( 'Required fields can not be empty!', 'supportcandy' ),
264 'submit_option_error' => esc_attr__( 'Please submit the option!', 'supportcandy' ),
265 'datatables' => array(
266 'emptyTable' => esc_attr__( 'No Records', 'supportcandy' ),
267 'zeroRecords' => esc_attr__( 'No Records', 'supportcandy' ),
268 'info' => sprintf(
269 /* translators: e.g. Showing 1 to 20 of 300 records */
270 esc_attr__( 'Showing %1$s to %2$s of %3$s records', 'supportcandy' ),
271 '_START_',
272 '_END_',
273 '_TOTAL_'
274 ),
275 'infoEmpty' => '',
276 'loadingRecords' => '',
277 'processing' => '',
278 'infoFiltered' => '',
279 'search' => esc_attr__( 'Search:', 'supportcandy' ),
280 'paginate' => array(
281 'first' => esc_attr__( 'First', 'supportcandy' ),
282 'previous' => esc_attr__( 'Previous', 'supportcandy' ),
283 'next' => esc_attr__( 'Next', 'supportcandy' ),
284 'last' => esc_attr__( 'Last', 'supportcandy' ),
285 ),
286 ),
287 ),
288 'temp' => array(),
289 'home_url' => home_url(),
290 );
291
292 return apply_filters( 'wpsc_admin_localizations', $localizations );
293 }
294 }
295
296 endif;
297
298 WPSC_Admin::init();
299