From 5f6182ea011162dfffdebce708634bee51443f01 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Wed, 7 Sep 2016 20:51:35 +1000 Subject: [PATCH] Check if REST API class and function exists. --- includes/api/class-sp-rest-api.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/api/class-sp-rest-api.php b/includes/api/class-sp-rest-api.php index 1b5951c4..b7327fc4 100644 --- a/includes/api/class-sp-rest-api.php +++ b/includes/api/class-sp-rest-api.php @@ -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(