PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.5.2
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.5.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 / working-hrs / class-wpsc-working-hrs.php

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

126 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_Working_Hrs' ) ) :
7
8 final class WPSC_Working_Hrs {
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_working_hrs_settings', array( __CLASS__, 'get_working_hrs_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_wh_tabs',
48 array(
49 'working-hrs' => array(
50 'slug' => 'working_hrs',
51 'label' => esc_attr__( 'Working Hours', 'supportcandy' ),
52 'callback' => 'wpsc_get_working_hrs',
53 ),
54 'holidays' => array(
55 'slug' => 'holidays',
56 'label' => esc_attr__( 'Holidays', 'supportcandy' ),
57 'callback' => 'wpsc_get_holidays',
58 ),
59 'exceptions' => array(
60 'slug' => 'exceptions',
61 'label' => esc_attr__( 'Exceptions', 'supportcandy' ),
62 'callback' => 'wpsc_get_wh_exceptions',
63 ),
64 'settings' => array(
65 'slug' => 'settings',
66 'label' => esc_attr__( 'Settings', 'supportcandy' ),
67 'callback' => 'wpsc_get_wh_settings',
68 ),
69 )
70 );
71 self::$current_tab = isset( $_REQUEST['tab'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['tab'] ) ) : 'working-hrs'; // phpcs:ignore
72 }
73
74
75 /**
76 * Add localizations to local JS
77 *
78 * @param array $localizations - localization list.
79 * @return array
80 */
81 public static function localizations( $localizations ) {
82
83 if ( ! ( WPSC_Settings::$is_current_page && WPSC_Settings::$current_section === 'working-hrs' ) ) {
84 return $localizations;
85 }
86
87 // Current section.
88 $localizations['current_tab'] = self::$current_tab;
89
90 return $localizations;
91 }
92
93 /**
94 * General setion body layout
95 *
96 * @return void
97 */
98 public static function get_working_hrs_settings() {
99
100 if ( ! WPSC_Functions::is_site_admin() ) {
101 wp_send_json_error( __( 'Unauthorized access!', 'supportcandy' ), 401 );
102 }?>
103
104 <div class="wpsc-setting-tab-container">
105 <?php
106 foreach ( self::$tabs as $key => $tab ) {
107 $active = self::$current_tab === $key ? 'active' : ''
108 ?>
109 <button
110 class="<?php echo esc_attr( $key ) . ' ' . esc_attr( $active ); ?>"
111 onclick="<?php echo esc_attr( $tab['callback'] ) . '();'; ?>">
112 <?php echo esc_attr( $tab['label'] ); ?>
113 </button>
114 <?php
115 }
116 ?>
117 </div>
118 <div class="wpsc-setting-section-body"></div>
119 <?php
120 wp_die();
121 }
122 }
123 endif;
124
125 WPSC_Working_Hrs::init();
126