not sure why you'd want to change the php code (it's not very reader friendly
).
the vmk0 is connected to a portgroup and usually that portgroup gets the vlan tags. that command is in the script builder: esxcfg-vswitch -p "<portgroup name>" -v <VLAN_ID> <virtual switch name>
is your setup different? that usually works fine.