Fixes #1109 Themes with same name

Tried a fix for this:
https://github.com/mybb/mybb/issues/1109
This is an existing code chunk. I have just relocated it.