In widget-data.php, I did this:
Replace
add_action( 'admin_enqueue_scripts', function($hook) use ($export_page, $import_page){
if( !in_array( $hook, array( $export_page, $import_page ) ) )
return;
wp_enqueue_style( 'widget_data', plugins_url( '/widget-data.css', __FILE__ ) );
wp_enqueue_script( 'widget_data', plugins_url( '/widget-data.js', __FILE__ ), array( 'jquery', 'wp-ajax-response' ) );
wp_localize_script( 'widget_data', 'widgets_url', get_admin_url( false, 'widgets.php' ) );
} );
with this
if(is_admin())
{
wp_enqueue_style( 'widget_data', plugins_url( '/widget-data.css', __FILE__ ) );
wp_enqueue_script( 'widget_data', plugins_url( '/widget-data.js', __FILE__ ), array( 'jquery', 'wp-ajax-response' ) );
wp_localize_script( 'widget_data', 'widgets_url', get_admin_url( false, 'widgets.php' ) );
}
It worked for me. Not the best solution, I’m sure, but it worked.