Skip to content

Commit

Permalink
Update WP compatibility check in gutenberg_pre_init() (#29938)
Browse files Browse the repository at this point in the history
* Update `gutenberg_pre_init()` compat check to WP 5.6

The plugin relies on `WP_Block_Supports`, which was added in 5.6
and `register_block_format()`, which was added in 5.5.

* Do not bail early after adding WP version notice

When `return` is used here, Gutenberg is not loaded and the other
hooks added in this file use functions that are only loaded with
Gutenberg.

* Update gutenberg.php

* Update gutenberg.php

Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
  • Loading branch information
jeremyfelt and gziolo authored Apr 14, 2021
1 parent c78128f commit 2864336
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
function gutenberg_wordpress_version_notice() {
echo '<div class="error"><p>';
/* translators: %s: Minimum required version */
printf( __( 'Gutenberg requires WordPress %s or later to function properly. Please upgrade WordPress before activating Gutenberg.', 'gutenberg' ), '5.3.0' );
printf( __( 'Gutenberg requires WordPress %s or later to function properly. Please upgrade WordPress before activating Gutenberg.', 'gutenberg' ), '5.6' );
echo '</p></div>';

deactivate_plugins( array( 'gutenberg/gutenberg.php' ) );
Expand Down Expand Up @@ -61,7 +61,10 @@ function gutenberg_pre_init() {
// Strip '-src' from the version string. Messes up version_compare().
$version = str_replace( '-src', '', $wp_version );

if ( version_compare( $version, '5.3.0', '<' ) ) {
// Compare against major release versions (X.Y) rather than minor (X.Y.Z)
// unless a minor release is the actual minimum requirement. WordPress reports
// X.Y for its major releases.
if ( version_compare( $version, '5.6', '<' ) ) {
add_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
return;
}
Expand Down

0 comments on commit 2864336

Please sign in to comment.