If a court orders a party to pay attorney's fees or costs under this code, the court shall first determine that the party has or is reasonably likely to have the ability to pay.