-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
38 lines (34 loc) · 986 Bytes
/
index.php
File metadata and controls
38 lines (34 loc) · 986 Bytes
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
<?php
/*
Plugin Name: CODESIGN2 WordPress REST API Example Plugin
Plugin URI: https://www.codesign2.co.uk
Description: Really basic WordPress REST API Example Plugin
Version: 1.0.0
Author: CD2Team
Author URI: https://www.codesign2.co.uk
*/
namespace lewiscowles;
\add_action('rest_api_init', function() {
error_reporting(E_ALL);
ini_set('display_errors', true);
foreach([
'Test'
] as $endpoint) {
require_once( __DIR__."/controllers/{$endpoint}Controller.php");
$controller_class = __NAMESPACE__."\\{$endpoint}Controller";
$controller = new $controller_class();
$controller->register_routes();
}
});
\add_action('wp_ajax_apinonce', function() {
die(\wp_create_nonce( 'wp_rest' ));
});
\spl_autoload_register( function($classname) {
$file = sprintf(
'%s/vendor/%s.php',
__DIR__, str_replace('\\', DIRECTORY_SEPARATOR, $classname)
);
if(file_exists($file)) {
require $file;
}
});