Skip to content

Commit

Permalink
Only silence REST errors if the REST server is added (#10903)
Browse files Browse the repository at this point in the history
* Only silence REST errors if the REST server is added

If the REST server is not available in a code run, Gutenberg will fatal with `Fatal error: Uncaught Error: Call to undefined function gutenberg_silence_rest_errors()`

`gutenberg_silence_rest_errors` is defined in `lib/rest-api.php`, which is only loaded if `class_exists( 'WP_REST_Controller' )` in `load.php`.

This PR adds the same `class_exists()` test to the call to `gutenberg_silence_rest_errors()` in `gutenberg.php`.
  • Loading branch information
georgeh authored Oct 23, 2018
1 parent f0831a1 commit 1232f8f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ function gutenberg_pre_init() {

require_once dirname( __FILE__ ) . '/lib/load.php';

gutenberg_silence_rest_errors();
if ( function_exists( 'gutenberg_silence_rest_errors' ) ) {
gutenberg_silence_rest_errors();
}

add_filter( 'replace_editor', 'gutenberg_init', 10, 2 );
}
Expand Down

0 comments on commit 1232f8f

Please sign in to comment.