Replaces deprecated PHP function preg_replace with preg_replace_callback

preg_replace function is now deprecated, this has been replaced with preg_replace_callback function.