Add some additional checking before trying to load wordpress so that it is only loaded when needed.