Update theme logic to work automatically in the background

Themes are now set depending on the prefix 'admin' in the URI and also checks the default templates for the theme according to the scope (frontend or backend)