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 <?php
class SP_REST_Posts_Controller extends WP_REST_Posts_Controller { if ( class_exists( 'WP_REST_Posts_Controller' ) ) {
public function __construct( $post_type ) { class SP_REST_Posts_Controller extends WP_REST_Posts_Controller {
parent::__construct( $post_type ); public function __construct( $post_type ) {
$this->namespace = 'sportspress/v2'; parent::__construct( $post_type );
$this->namespace = 'sportspress/v2';
}
} }
} }

View File

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