Skip to content

Commit

Permalink
REST API: Check for WP5.5 and skip registering routes (#23880)
Browse files Browse the repository at this point in the history
* Check for WP5.5 and skip registering routes

* Simplify version compare
  • Loading branch information
mkaz authored Jul 14, 2020
1 parent 90920ac commit 9bcd83d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,15 @@ function gutenberg_auto_draft_get_sample_permalink( $permalink, $id, $title, $na
* @since 7.x.0
*/
function gutenberg_register_image_editor() {
$image_editor = new WP_REST_Image_Editor_Controller();
$image_editor->register_routes();
global $wp_version;

// Strip '-src' from the version string. Messes up version_compare().
$version = str_replace( '-src', '', $wp_version );

// Only register routes for versions older than WP 5.5.
if ( version_compare( $version, '5.5-beta', '<' ) ) {
$image_editor = new WP_REST_Image_Editor_Controller();
$image_editor->register_routes();
}
}
add_filter( 'rest_api_init', 'gutenberg_register_image_editor' );

0 comments on commit 9bcd83d

Please sign in to comment.