A unified approach for variationally consistent finite elements in elastoplasticity