/** * Set up globals necessary to avoid errors when using wp_mail() */ public static function setUp_wp_mail($args) { if (isset($_SERVER['SERVER_NAME'])) { self::$cached_SERVER_NAME = $_SERVER['SERVER_NAME']; } $_SERVER['SERVER_NAME'] = 'example.com'; // passthrough return $args; }
/** * Tear down globals set up in setUp_wp_mail() */ public static function tearDown_wp_mail($args) { if (!empty(self::$cached_SERVER_NAME)) { $_SERVER['SERVER_NAME'] = self::$cached_SERVER_NAME; self::$cached_SERVER_NAME = ''; } else { unset($_SERVER['SERVER_NAME']); } // passthrough return $args; }