-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.php
41 lines (36 loc) · 1022 Bytes
/
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
<?php
/**
* Widget endpoints for the WP REST API.
*
* Plugin Name: WordPress REST API Widgets Endpoints
* Description: Widget endpoints for the WP REST API
* Author: WP REST API Team
* Author URI: http://wp-api.org
* Version: 0.1.0
* Plugin URI: https://github.com/WP-API/widgets-endpoints
* License: GPL2+
*
* @package REST_API
* @author WP REST API Team
* @license GPL-2.0+
*/
add_action( 'rest_api_init', 'wp_api_widgets_init_controllers', 0 );
/**
* Bootstrap endpoints.
*/
function wp_api_widgets_init_controllers() {
if ( ! class_exists( 'WP_REST_Controller' ) ) {
return;
}
if ( ! class_exists( 'WP_REST_Widgets_Controller' ) ) {
require_once dirname( __FILE__ ) . '/lib/class-wp-rest-widgets-controller.php';
}
/**
* Get global widget factory.
*
* @type WP_Widget_Factory $wp_widget_factory
*/
global $wp_widget_factory;
$widgets_controller = new WP_REST_Widgets_Controller( $wp_widget_factory->widgets );
$widgets_controller->register_routes();
}