Metacore plugin integration

Adds metacore plugin integration functionality
How is it WAY too nested? It's just two subsequent AJAX calls. Looks ugly, yes, but that's downside of the "functional" style programming for you. Of course, it could be rewritten so the handlers are implemented as separate functions outside of this block, but frankly I don't see any reason to do it, this is a small enough block to sit in a single function, fairly easy to read.