Then see at the source code of that plugin if you want to know how it works, it's the magic of open source.