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 / settings / general-settings / class-wpsc-gs.php

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

125 lines 3.0 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_GS' ) ) :
7
8 final class WPSC_GS {
9
10 /**
11 * Tabs for this section
12 *
13 * @var array
14 */
15 private static $tabs;
16
17 /**
18 * Current tab
19 *
20 * @var string
21 */
22 public static $current_tab;
23
24 /**
25 * Initialize this class
26 *
27 * @return void
28 */
29 public static function init() {
30
31 // Load tabs for this section.
32 add_action( 'admin_init', array( __CLASS__, 'load_tabs' ) );
33
34 // Add current tab to admin localization data.
35 add_filter( 'wpsc_admin_localizations', array( __CLASS__, 'localizations' ) );
36
37 // Load section tab layout.
38 add_action( 'wp_ajax_wpsc_get_general_settings', array( __CLASS__, 'get_general_settings' ) );
39 }
40
41 /**
42 * Load tabs for this section
43 */
44 public static function load_tabs() {
45
46 self::$tabs = apply_filters(
47 'wpsc_gs_tabs',
48 array(
49 'general' => array(
50 'slug' => 'general',
51 'label' => esc_attr__( 'General', 'supportcandy' ),
52 'callback' => 'wpsc_get_gs_general',
53 ),
54 'page-settings' => array(
55 'slug' => 'page_settings',
56 'label' => esc_attr__( 'Page Settings', 'supportcandy' ),
57 'callback' => 'wpsc_get_gs_page_settings',
58 ),
59 'file-attachments' => array(
60 'slug' => 'file_attachments',
61 'label' => esc_attr__( 'File Attachments', 'supportcandy' ),
62 'callback' => 'wpsc_get_gs_file_attachments',
63 ),
64 'thank-you-page' => array(
65 'slug' => 'thank_you_page',
66 'label' => esc_attr__( 'Thank you page', 'supportcandy' ),
67 'callback' => 'wpsc_get_gs_thankyou',
68 ),
69 )
70 );
71 self::$current_tab = isset( $_REQUEST['tab'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['tab'] ) ) : 'general'; // phpcs:ignore
72 }
73
74 /**
75 * Add localizations to local JS
76 *
77 * @param array $localizations - localizations.
78 * @return array
79 */
80 public static function localizations( $localizations ) {
81
82 if ( ! ( WPSC_Settings::$is_current_page && WPSC_Settings::$current_section === 'general-settings' ) ) {
83 return $localizations;
84 }
85
86 // Current section.
87 $localizations['current_tab'] = self::$current_tab;
88
89 return $localizations;
90 }
91
92 /**
93 * General setion body layout
94 *
95 * @return void
96 */
97 public static function get_general_settings() {
98
99 if ( ! WPSC_Functions::is_site_admin() ) {
100 wp_send_json_error( __( 'Unauthorized access!', 'supportcandy' ), 401 );
101 }?>
102
103 <div class="wpsc-setting-tab-container">
104 <?php
105 foreach ( self::$tabs as $key => $tab ) :
106 $active = self::$current_tab === $key ? 'active' : ''
107 ?>
108 <button
109 class="<?php echo esc_attr( $key ) . ' ' . esc_attr( $active ); ?>"
110 onclick="<?php echo esc_attr( $tab['callback'] ) . '();'; ?>">
111 <?php echo esc_attr( $tab['label'] ); ?>
112 </button>
113 <?php
114 endforeach;
115 ?>
116 </div>
117 <div class="wpsc-setting-section-body"></div>
118 <?php
119 wp_die();
120 }
121 }
122 endif;
123
124 WPSC_GS::init();
125