How to change domain used when pinging sites

Here’s what I came up with to accomplish this. I’m not naive enough to think this is the best way, but it works. Again, still interested to know if others have any better ideas. Ultimately, the reason why I needed to do this was because I use the domain mapping plugin, and I have it set to redirect admin requests to the original domain (the multisite subdomain). Now WordPress pings with the mapped domain and not e.g. child.parent.com

function ping_domain_map($home_url) {
    if (strpos($_SERVER['REQUEST_URI'], 'wp-cron.php') && strpos(print_r(debug_backtrace(),1), 'weblog_ping') ) {
        if ( !function_exists( 'domain_mapping_siteurl' ) )
            return $home_url;

        $mapped_url = domain_mapping_siteurl( false );
        if ( !$mapped_url )
            return $home_url;
        else
            return preg_replace('#^.*?//[^/]+#', $mapped_url, $home_url);
    }
    return $home_url;
}
add_filter( 'home_url', 'ping_domain_map');