Avoid Fatal Errors when Core REST API classes don't exist.

This commit is contained in:
Jeremy Herve
2017-02-16 19:19:18 +01:00
parent 8612ea908b
commit 4b42e124de
2 changed files with 12 additions and 8 deletions

View File

@@ -1,8 +1,10 @@
<?php
class SP_REST_Posts_Controller extends WP_REST_Posts_Controller {
public function __construct( $post_type ) {
parent::__construct( $post_type );
$this->namespace = 'sportspress/v2';
if ( class_exists( 'WP_REST_Posts_Controller' ) ) {
class SP_REST_Posts_Controller extends WP_REST_Posts_Controller {
public function __construct( $post_type ) {
parent::__construct( $post_type );
$this->namespace = 'sportspress/v2';
}
}
}

View File

@@ -1,8 +1,10 @@
<?php
class SP_REST_Terms_Controller extends WP_REST_Terms_Controller {
public function __construct( $taxonomy ) {
parent::__construct( $taxonomy );
$this->namespace = 'sportspress/v2';
if ( class_exists( 'WP_REST_Terms_Controller' ) ) {
class SP_REST_Terms_Controller extends WP_REST_Terms_Controller {
public function __construct( $taxonomy ) {
parent::__construct( $taxonomy );
$this->namespace = 'sportspress/v2';
}
}
}