Skip to content

Commit

Permalink
Fix undefined access error
Browse files Browse the repository at this point in the history
  • Loading branch information
ravichdev committed Mar 18, 2021
1 parent 54e873a commit c406092
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions plugin/php/class-block-types.php
Expand Up @@ -336,21 +336,17 @@ public function get_rest_controller( $post_type ) {
$class = $post_type->rest_controller_class ? $post_type->rest_controller_class : \WP_REST_Posts_Controller::class;

if ( ! class_exists( $class ) ) {
return null;
return null;
}

if ( ! is_subclass_of( $class, \WP_REST_Controller::class ) ) {
return null;
}

if ( ! $post_type->rest_controller ) {
$post_type->rest_controller = new $class( $post_type->name );
return null;
}

if ( ! ( $post_type->rest_controller instanceof $class ) ) {
return null;
if ( ! empty( $post_type->rest_controller ) ) {
return $post_type->rest_controller;
}

return $post_type->rest_controller;
return new $class( $post_type->name );
}
}

0 comments on commit c406092

Please sign in to comment.