-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlugin.php
64 lines (60 loc) · 1.22 KB
/
Plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* @package Nabo
* @version 4.1
*/
/*
Plugin Name: 南博插件
Plugin URI: https://github.com/krait-team/Nabo-wordpress
Description: 南博KAT-RPC
Author: 南博工作室
Version: 4.1
Author URI: https://github.com/krait-team
*/
add_action('query_vars', 'nabo_add_query_vars');
/**
* @param $public_query_vars
* @return mixed
*/
function nabo_add_query_vars($public_query_vars)
{
$public_query_vars[] = 'nabo';
return $public_query_vars;
}
add_action('template_redirect', 'nabo_template_redirect');
/**
* @throws Exception
*/
function nabo_template_redirect()
{
global $wp_query;
switch ($wp_query->query_vars['nabo']) {
case 'service':
{
include_once 'Service.php';
$service = new Nabo_Service();
$service->launch();
break;
}
case 'upload':
{
include_once 'Upload.php';
$upload = new Nabo_Upload();
$upload->launch();
}
}
}
/**
* @param $data
* @return string[]
*/
function nabo_test($data)
{
return ['test'];
}
add_action('rest_api_init', function () {
register_rest_route('nabo', '/test', [
'methods' => 'GET',
'callback' => 'nabo_test',
]);
});