Twig url() function returns CP path when called from plugin
Right, url() (and UrlHelper::getUrl(), which url() maps to) will create a URL to either a front-end page or a CP page, depending on where it is being called from.

If you want to get a front-end URL from a CP request, you can use siteUrl() instead. (You can also get a CP URL from a front-end request via cpUrl().)