Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST API: Check for WP5.5 and skip registering routes #23880

Merged
merged 2 commits into from
Jul 14, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 -beta and -src from the version string. Messes up version_compare().
$version = explode( '-', $wp_version, 2 )[0];

// Only register routes for versions older than WP 5.5.
if ( version_compare( $version, '5.5', '<' ) ) {
$image_editor = new WP_REST_Image_Editor_Controller();
$image_editor->register_routes();
}
mkaz marked this conversation as resolved.
Show resolved Hide resolved
}
add_filter( 'rest_api_init', 'gutenberg_register_image_editor' );