Add fallbacks for wp_get_referer()

Closes #6609