You can also try:
/*
* Add filter attribute
*/
add_filter( \'walker_nav_menu_start_el\', \'modify_walker_data_attr\', 10, 4);
function modify_walker_data_attr( $item_output, $item, $depth, $args )
{
// I use ACF for adding field to a menu item
// https://www.advancedcustomfields.com/resources/adding-fields-menu-items/
$data_hover = get_field(\'data-hover\', $item);
$old = \'<a\';
$new = \'<a data-hover="\'.$data_hover.\'" \';
$item_output = str_replace($old, $new, $item_output);
return $item_output;
}