WordPress HTTP User-Agent impacting the WolfNet WordPress Plugin Search Manager

Recently we had to debug an issue we encountered with a particular instance of our WordPress plugin on a client website.  The symptom of this issue was that their “Search Manager” was not being displayed.  If you have looked at the source code for our plugin you may know that the HTML and JavaScript for the search manager actually comes from our MLSFinder application via an HTTP request from WordPress (PHP) to our servers.  This technique has worked very well in providing an interface within the WordPress admin which is uniquely tailored to the needs of the specific clients search solution.  The client in question however was encountering an obvious issue requiring quick resolution.

Through some debugging and testing we were able to eliminate the client’s site as the source of the problem… or so we thought.

To make a long story short, the client’s WordPress site was making HTTP requests to our servers with a User-Agent header that was being identified by our site as a mobile browser.  Our first thought was that they must be using some sort of plugin/theme that was changing the default User-Agent for some reason.  As it turn out this was not the case.

WordPress uses its own dynamically generated User-Agent when making HTTP requests.  The pattern they use is as follows “WordPress/version#SiteAddress“; where version# is the version of WordPress being used and SiteAddress is the base URL for the WordPress site (ex. WordPress/3.5.1; http://www.example.com).  This is actually pretty neat as it would allow you to tailor a RESTful API to respond in a specific way based on the version of a WordPess a client site is runningfor example.

How this affected us was that our mobile detection identified the string “psp” in the URL present in the User-Agent string and made the poor decision that this meant the User-Agent was the Play Station Portable Web Browser.

In conclusion, should you ever find yourself running into an issue with HTTP requests from WordPress or want a way of determining the version of WordPress without passing additional parameters with your request keep the WordPress User-Agent in mind.

The following two tabs change content below.
I am a web developer living and working in the greater Twin Cities area. I have experience with PHP, ColdFusion, HTML, CSS, JavaScript, SQL, and a lot of other languages.

Comments are closed.