Remove those checks from three different places and put them into a reusable component, which can be used for different plugins. REVIEW: 127583