Every attorney is guilty of a misdemeanor and, in addition to the punishment prescribed therefor, shall be disbarred:
(a)
Who directly or indirectly advises in relation to, or aids, or promotes the defense of any action or proceeding in any court the prosecution of which is carried on, aided or promoted by any person as district attorney or other public prosecutor with whom such person is directly or indirectly connected as a partner.
(b)
Who, having himself prosecuted or in any manner aided or promoted any action or proceeding in any court as district attorney or other public prosecutor, afterwards, directly or indirectly, advises in relation to or takes any part in the defense thereof, as attorney or otherwise, or who takes or receives any valuable consideration from or on behalf of any defendant in any such action upon any understanding or agreement whatever having relation to the defense thereof.
This section does not prohibit an attorney from defending himself in person, as attorney or counsel, when prosecuted, either civilly or criminally.