better logic needed to build a wordpress plugin