I am working on a site now where I need to use the current page URL as a condition to determine where the main menu links will lead. This function has made an easy task of it: