Checking if WordPress.com or self hosted
-
As a plugin author, what is the simplest way to check if the current site is a WordPress.com site or a self hosted site using the open source package?
I’ve not been able to find anything close to an answer on this topic when searching the web. I was thinking that perhaps a built in function that may return false on one versus the other or even a global variable with a specific value.
-
Hi there,
If you’d like to check whether the site is hosted on WordPress.com, try a whois search using your favorite tool, such as https://whois.net/, to check whether the site’s name servers are set to ns1.wordpress.com, ns2.wordpress.com, ns3.wordpress.com.
If they are, the site is most likely hosted on WordPress.com, even if you don’t see the WordPress.com admin bar or our branding in the footer.Hope this helps! Let me know if you have any questions.
Thanks! -
I know how to tell if a site is hosted by one or the other when I check it myself.
What I’m looking for is how to tell within plugin code. Some things are handled differently between the two and I’m looking for a reliable variable to base my conditional code on.
So if the plugin is installed on wordpress.com do A else do B.
-
I have added “modlook” tag for the staff assistance. You will get a reply soon from the staff.
-
Hi there,
There’s no way to tell from within the code that I know of – you could query for a WordPress.com site ID using our API, but that would return a result for self-hosted sites connected by Jetpack as well, so is not really reliable.
Please open a ticket via our developers contact form at https://developer.wordpress.com/contact/ to ask this directly from our developers. If you can give them more details on what you want to do, and why exactly it’s important that your plugin make this distinction, they might also be able to suggest other options to you.
This forum is for end-users of free WordPress.com sites, and neither our volunteers nor us on the support staff really have the expertise to advise you on this, as none of us are developers :)
- The topic ‘Checking if WordPress.com or self hosted’ is closed to new replies.