The issue raised in the OP is whether the husband's lawyer should have been permitted to introduce evidence about the abortion. There's no suggestion that the prostitution evidence was excluded. I omitted the prostitution stuff because it didn't relate to the issue I was addressing.
Of course, admitting either piece of evidence depends on invoking a particular view of morality -- sex is permissible only with one's opposite-gender spouse -- as being relevant to custody. I have my doubts about that whole assumption. If the husband sometimes visits prostitutes, or if the wife sometimes has nonmarital sex in her house behind closed doors while the children are elsewhere in the house, are the children actually harmed? In today's courts, though, I would guess that either of these points would be deemed to be a factor weighing against that parent in the custody fight. (The inquiry is supposed to be about the best interests of the children. Therefore, such a character attack should be considered only to the extent that it reflects on the person's fitness as a parent. You would have to argue that the husband has a view of women as sex objects and will impart that view if he has any role in raising the kids, or that the wife engages in casual sex and will set an example of promiscuity if she has such a role. Whatever validity there may be to either argument, I suspect that this type of evidence is more powerful for its prejudicial effect, i.e., painting that spouse as a bad person.)