Your filter generally seems fine.
I’d probably filter option_home
instead of home_url
, but it results in the same thing for most use cases (bloginfo("home")
will work and so will get_home_url()
, but get_option("home")
will only work correctly with option_home
).