removed $GLOBALS and used wp-api