「wp_enqueue_script() が誤って呼び出されました」エラーの対処法

WordPressアップグレードでウィジェットが崩れるエラー発生

WordPressのアップグレードでウィジェットのページが崩れて正常に表示されなくなりました。WordPressのデバッグを有効にすると以下のメッセージが表示されました。

wp_enqueue_script() が誤って呼び出されました。”wp-editor” script should not be enqueued together with the new widgets editor (wp-edit-widgets or wp-customize-widgets).

このエラーの場合、テーマのfunctions.phpに以下のコードを追加すると解消します。

function phi_theme_support() {
    remove_theme_support( 'widgets-block-editor' );
}
add_action( 'after_setup_theme', 'phi_theme_support' );