A suggestion to simply extract/merge this functionality from/with another plugin.