Check if REST API class and function exists.

This commit is contained in:
Brian Miyaji
2016-09-07 20:51:35 +10:00
parent 3c59c937b8
commit 5f6182ea01

View File

@@ -37,6 +37,8 @@ class SP_REST_API {
* Create REST routes.
*/
public static function create_routes() {
if ( ! class_exists( 'WP_REST_Posts_Controller' ) ) return;
if ( ! class_exists( 'SP_REST_Posts_Controller' ) ) {
require_once dirname( __FILE__ ) . '/class-sp-rest-posts-controller.php';
}
@@ -60,6 +62,8 @@ class SP_REST_API {
* Register REST fields.
*/
public static function register_fields() {
if ( ! function_exists( 'register_rest_field' ) ) return;
register_rest_field( 'sp_event',
'teams',
array(