PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.4.2
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.4.2
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 / appearence / class-wpsc-appearence-general.php

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

193 lines 5.9 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_Appearence_General' ) ) :
7
8 final class WPSC_Appearence_General {
9
10 /**
11 * Initialize this class
12 *
13 * @return void
14 */
15 public static function init() {
16
17 // user interface.
18 add_action( 'wp_ajax_wpsc_get_ap_general', array( __CLASS__, 'load_settings_ui' ) );
19 add_action( 'wp_ajax_wpsc_set_ap_general', array( __CLASS__, 'save_settings' ) );
20 add_action( 'wp_ajax_wpsc_reset_ap_general', array( __CLASS__, 'reset_settings' ) );
21 }
22
23 /**
24 * Reset default settings
25 *
26 * @return void
27 */
28 public static function reset() {
29
30 update_option(
31 'wpsc-ap-general',
32 array(
33 'primary-color' => '#313042',
34 'menu-link-color' => '#fff',
35 'main-background-color' => '#fff',
36 'main-text-color' => '#2c3e50',
37 'link-color' => '#2271b1',
38 )
39 );
40 }
41
42 /**
43 * Get general settings
44 *
45 * @return void
46 */
47 public static function load_settings_ui() {
48
49 if ( ! WPSC_Functions::is_site_admin() ) {
50 wp_send_json_error( __( 'Unauthorized access!', 'supportcandy' ), 401 );
51 }
52
53 $settings = get_option( 'wpsc-ap-general' );?>
54
55 <form action="#" onsubmit="return false;" class="wpsc-frm-ap-general">
56
57 <div class="wpsc-input-group">
58 <div class="label-container">
59 <label for=""><?php esc_attr_e( 'Primary color', 'supportcandy' ); ?></label>
60 </div>
61 <input class="wpsc-color-picker" type="text" name="primary-color" value="<?php echo esc_attr( $settings['primary-color'] ); ?>">
62 </div>
63
64 <div class="wpsc-input-group">
65 <div class="label-container">
66 <label for=""><?php esc_attr_e( 'Menu color', 'supportcandy' ); ?></label>
67 </div>
68 <input class="wpsc-color-picker" type="text" name="menu-link-color" value="<?php echo esc_attr( $settings['menu-link-color'] ); ?>">
69 </div>
70
71 <div class="wpsc-input-group">
72 <div class="label-container">
73 <label for=""><?php esc_attr_e( 'Main container', 'supportcandy' ); ?></label>
74 </div>
75 <table class="wpsc-ap-table">
76 <tr>
77 <td><?php esc_attr_e( 'Background color', 'supportcandy' ); ?></td>
78 <td><?php esc_attr_e( 'Text color', 'supportcandy' ); ?></td>
79 </tr>
80 <tr>
81 <td><input class="wpsc-color-picker" type="text" name="main-background-color" value="<?php echo esc_attr( $settings['main-background-color'] ); ?>"></td>
82 <td><input class="wpsc-color-picker" type="text" name="main-text-color" value="<?php echo esc_attr( $settings['main-text-color'] ); ?>"></td>
83 </tr>
84 </table>
85 </div>
86
87 <div class="wpsc-input-group">
88 <div class="label-container">
89 <label for=""><?php esc_attr_e( 'Link color', 'supportcandy' ); ?></label>
90 </div>
91 <input class="wpsc-color-picker" type="text" name="link-color" value="<?php echo esc_attr( $settings['link-color'] ); ?>">
92 </div>
93
94 <input type="hidden" name="action" value="wpsc_set_ap_general">
95 <input type="hidden" name="_ajax_nonce" value="<?php echo esc_attr( wp_create_nonce( 'wpsc_set_ap_general' ) ); ?>">
96
97 <script>jQuery('.wpsc-color-picker').wpColorPicker();</script>
98 <style>
99 .wpsc-ap-table td {padding: 5px;}
100 .wpsc-ap-table table, .wpsc-ap-table td {border: 1px solid #c3c3c3;}
101 </style>
102
103 </form>
104 <div class="setting-footer-actions">
105 <button
106 class="wpsc-button normal primary margin-right"
107 onclick="wpsc_set_ap_general(this);">
108 <?php esc_attr_e( 'Submit', 'supportcandy' ); ?></button>
109 <button
110 class="wpsc-button normal secondary"
111 onclick="wpsc_reset_ap_general(this, '<?php echo esc_attr( wp_create_nonce( 'wpsc_reset_ap_general' ) ); ?>');">
112 <?php esc_attr_e( 'Reset default', 'supportcandy' ); ?></button>
113 </div>
114 <?php
115 wp_die();
116 }
117
118 /**
119 * Save settings
120 *
121 * @return void
122 */
123 public static function save_settings() {
124
125 if ( check_ajax_referer( 'wpsc_set_ap_general', '_ajax_nonce', false ) != 1 ) {
126 wp_send_json_error( 'Unauthorised request!', 401 );
127 }
128
129 if ( ! WPSC_Functions::is_site_admin() ) {
130 wp_send_json_error( __( 'Unauthorized access!', 'supportcandy' ), 401 );
131 }
132
133 $primary_color = isset( $_POST['primary-color'] ) ? sanitize_text_field( wp_unslash( $_POST['primary-color'] ) ) : '';
134 if ( ! $primary_color ) {
135 wp_send_json_error( 'Bad request', 400 );
136 }
137
138 $menu_link_color = isset( $_POST['menu-link-color'] ) ? sanitize_text_field( wp_unslash( $_POST['menu-link-color'] ) ) : '';
139 if ( ! $primary_color ) {
140 wp_send_json_error( 'Bad request', 400 );
141 }
142
143 $main_background_color = isset( $_POST['main-background-color'] ) ? sanitize_text_field( wp_unslash( $_POST['main-background-color'] ) ) : '';
144 if ( ! $main_background_color ) {
145 wp_send_json_error( 'Bad request', 400 );
146 }
147
148 $main_text_color = isset( $_POST['main-text-color'] ) ? sanitize_text_field( wp_unslash( $_POST['main-text-color'] ) ) : '';
149 if ( ! $main_text_color ) {
150 wp_send_json_error( 'Bad request', 400 );
151 }
152
153 $link_color = isset( $_POST['link-color'] ) ? sanitize_text_field( wp_unslash( $_POST['link-color'] ) ) : '';
154 if ( ! $link_color ) {
155 wp_send_json_error( 'Bad request', 400 );
156 }
157
158 update_option(
159 'wpsc-ap-general',
160 array(
161 'primary-color' => $primary_color,
162 'menu-link-color' => $menu_link_color,
163 'main-background-color' => $main_background_color,
164 'main-text-color' => $main_text_color,
165 'link-color' => $link_color,
166 )
167 );
168
169 wp_die();
170 }
171
172 /**
173 * Reset settings to default
174 *
175 * @return void
176 */
177 public static function reset_settings() {
178
179 if ( check_ajax_referer( 'wpsc_reset_ap_general', '_ajax_nonce', false ) != 1 ) {
180 wp_send_json_error( 'Unauthorised request!', 401 );
181 }
182
183 if ( ! WPSC_Functions::is_site_admin() ) {
184 wp_send_json_error( __( 'Unauthorized access!', 'supportcandy' ), 401 );
185 }
186 self::reset();
187 wp_die();
188 }
189 }
190 endif;
191
192 WPSC_Appearence_General::init();
193