The action buttons should be part of a macro in the widget html file. The anonymous check can happen in that macro as well. Once that's done this block and similar blocks in other widgets can be removed.