Update NavMenuHacks.php

applying a few of the changes from the wordpress discussion threads to avoid php notices in logs. checking if two variables are actually arrays before trying to iterate on them.