Skip to content

Commit

Permalink
Don't use version_compare()
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks committed May 25, 2021
1 parent 724ab4c commit 9b6dd58
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
die( 'Silence is golden.' );
}

global $wp_version;

require_once __DIR__ . '/init.php';
require_once __DIR__ . '/upgrade.php';

Expand Down Expand Up @@ -75,7 +73,10 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/rest-api.php';
}

if ( version_compare( $wp_version, '5.8-alpha', '<' ) ) {
// We can't use class_exists( 'WP_Widget_Block' ) because core loads widgets
// *after* plugins, so test for wp_use_widgets_block_editor() which we know
// implies the existence of WP_Widget_Block.
if ( ! function_exists( 'wp_use_widgets_block_editor' ) ) {
require_once __DIR__ . '/class-wp-widget-block.php';
}

Expand Down
6 changes: 3 additions & 3 deletions lib/widgets-customize.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* @package gutenberg
*/

global $wp_version;

/**
* Gutenberg's Customize Register.
*
Expand Down Expand Up @@ -169,7 +167,9 @@ function gutenberg_widgets_customize_load_block_editor_scripts_and_styles( $is_b
return $is_block_editor_screen;
}

if ( version_compare( $wp_version, '5.8-alpha', '<' ) ) {
// Test for wp_use_widgets_block_editor(), as the existence of this in core
// implies that the Customizer already supports the widgets block editor.
if ( ! function_exists( 'wp_use_widgets_block_editor' ) ) {
add_action( 'customize_register', 'gutenberg_widgets_customize_register' );
add_filter( 'widget_customizer_setting_args', 'gutenberg_widgets_customize_add_unstable_instance', 10, 2 );
add_action( 'customize_controls_enqueue_scripts', 'gutenberg_customize_widgets_init' );
Expand Down

0 comments on commit 9b6dd58

Please sign in to comment.