Remove 5.0 compatibility layer plugin, this is 5.2 now
Move away from directly checking globals, instead use the WP API