PluginProbe ʕ •ᴥ•ʔ
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More / 3.6.1
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More v3.6.1
4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 trunk 1.0.0 2.0.0 2.0.1 2.0.2 2.0.3 3.0 3.0.1 3.0.2 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.4 3.2.5 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.4.5 3.4.6 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1
superb-blocks / src / data / controllers / class-rest-controller.php
superb-blocks / src / data / controllers Last commit date
class-cache-controller.php 10 months ago class-css-controller.php 10 months ago class-domainshift-controller.php 10 months ago class-key-controller.php 10 months ago class-log-controller.php 10 months ago class-option-controller.php 10 months ago class-rest-controller.php 10 months ago
class-rest-controller.php
59 lines
1 <?php
2
3 namespace SuperbAddons\Data\Controllers;
4
5 defined('ABSPATH') || exit();
6
7 class RestController
8 {
9 const NAMESPACE = 'superbaddons';
10 const TOKEN = 'SPBAV1iZV7b674&p7%8#v#Z';
11
12 private static $Routes = array();
13
14 public static function AddRoute($route, $args)
15 {
16 self::$Routes[] = array(
17 "route" => $route,
18 "args" => $args
19 );
20 }
21
22 public static function RegisterRoutes()
23 {
24 add_action('rest_api_init', function () {
25 foreach (self::$Routes as $Route) {
26 register_rest_route(self::NAMESPACE, $Route['route'], $Route['args']);
27 }
28 });
29 }
30
31 public static function GetArgsHeadersArray($args = array())
32 {
33 $headers = array(
34 'X-Superb-Auth' => 'Token ' . self::TOKEN
35 );
36 if (isset($args['headers']) && is_array($args['headers'])) {
37 foreach ($args['headers'] as $key => $value) {
38 $headers[$key] = $value;
39 }
40 }
41 return array_merge($args, array(
42 'timeout' => 60,
43 'headers' => $headers
44 ));
45 }
46
47 public static function IsAcceptableConnection($response)
48 {
49 if (!is_wp_error($response) && wp_remote_retrieve_response_code($response) === 200) {
50 if (!isset($response['headers']) || (isset($response['headers']['server']) && strpos($response['headers']['server'], 'imunify360') !== false)) {
51 return false;
52 }
53 return true;
54 }
55
56 return false;
57 }
58 }
59