I use to retrieve block fields with get_field, both on the front-end and the back-end. If you experience this problem only on the back-end, try changing all instances of $block[‘data’] into $data and adding this at the beginning of the function:
<?php
$data = is_admin() ? get_field( 'data' ) : $block['data'] ;