PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.5.1
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.5.1
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 / class-wpsc-rest-api.php

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

73 lines 1.4 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_REST_API' ) ) :
7
8 final class WPSC_REST_API {
9
10 /**
11 * REST API Settings
12 *
13 * @var array
14 */
15 private static $settings = array();
16
17 /**
18 * Initialize this class
19 *
20 * @return void
21 */
22 public static function init() {
23
24 // initialize rest api.
25 add_filter( 'rest_authentication_errors', array( __CLASS__, 'load_current_user' ), 100 );
26 add_action( 'rest_api_init', array( __CLASS__, 'register_routes' ) );
27 }
28
29 /**
30 * Load current user for supportcandy after user authentication
31 *
32 * @param mixed $response - response object.
33 * @return mixed
34 */
35 public static function load_current_user( $response ) {
36
37 WPSC_Current_User::load_current_user();
38 return $response;
39 }
40
41 /**
42 * Register REST API routes
43 *
44 * @return void
45 */
46 public static function register_routes() {
47
48 $advanced = get_option( 'wpsc-ms-advanced-settings' );
49 if ( ! $advanced['rest-api'] ) {
50 return;
51 }
52
53 do_action( 'wpsc_rest_register_routes' );
54 }
55
56 /**
57 * Validate integer value
58 *
59 * @param string $param - parameter value.
60 * @param WP_REST_Request $request - request object.
61 * @param string $key - filter key.
62 * @return boolean
63 */
64 public static function validate_integer_value( $param, $request, $key ) {
65
66 return is_numeric( $param );
67 }
68 }
69
70 endif;
71
72 WPSC_REST_API::init();
73