When using on a multisite the domain code doesn't work

Note only second commit has any functional change