Get current screen what?

Hey there guys, Jimbo1337 here.

So today I wanted to talk about an interesting problem that I encountered on one of the many many WordPress-sites that I manage. The site in question is a WordPress multisite installation with a main theme and a bunch of child themes that override some different stuff. For derp reasons I had to add an extra global config-variable to know exactly where in the development cycle the site existed. Ergo, I had to know if the site was on the development or production server and do some stuff based on this.

How this is handled is of course top top secret but what I tried in this case was to add a php-file in the main theme root folder simply called settings.php where I declared my variable. I then included this at the top of my theme functions file and did my stuff and it seemingly worked just fine. Though problems arised some few months later when someone tried to access the multisite network admin page. WordPress threw an error message for reasons we could not understand.

Fatal error: Call to undefined function get_current_screen() in /network/settings.php on line 27

So what the f does this mean? I have no idea but apparently you cannot include a file named settings.php from your theme root if you want your network admin to be functional. But take notice, the error is thrown in a completly different file that we have no control over. When i renamed my file to config.php the problem disappeared so my best guess is that some weird global wordpress stuff is happening here. It is somewhat questionable if you want to put a config file like this in your theme root but it was a quick fix on my part. If you put it in a folder I think it’s completely fine.