Replace methodology for removing double whitespace

Fixes issue #1480

I've added this as a function to the functions file as the same whitespace regex was being used in metabox.