[wp-hackers] WPMU VHOST constant
Will Anderson
wp-hackers at itsananderson.com
Tue Aug 4 19:50:39 UTC 2009
On Tue, Aug 4, 2009 at 3:31 PM, Brent <thenbrent at gmail.com> wrote:
> Hello all,
>
> For those familiar with WPMU, is using the VHOST constant the best way to
> determine if a WPMU installation is using sub-domains for blog addresses?
>
> For example:
> if(constant("VHOST") == 'yes')
> //do something for when blog addresses use sub-domains
> else
> //do something for when blog addresses use
> sub-directories<http://codex.wordpress.org/WPMU%27s_VHOST_Constant>
>
> I'm writing a plugin that needs to know if the installation is using
> sub-domains or sub-folders. I couldn't find a function or database entry to
> get this setting. Eventually, I copied the method used within core WPMU
> files, which is to use VHOST.
>
> Thanks in advance for any advice. :)
>
> Brent
>
Unfortunately I'm not terribly familiar with WPMU, but I can tell you from a
PHP perspective that the code you posted won't work. The constant should
already be defined in wp-config.php (from what I understand) so you
shouldn't try defining it again (which is what the "constant" function
does). Instead, do something like this...
if(defined('VHOST') && 'yes' == VHOST)
// do something for when blog addresses use sub-domains
else
//do something for when blog addresses use sub-directories
As with many of my code snippets that I post on here, this is untested, and
YMMV, but if I understand how the VHOST constant works in WordPress MU (my
knowledge is admittedly limited to 20 minutes of Google searching), this
should be what you need.
--
Will Anderson
http://www.itsananderson.com/
More information about the wp-hackers
mailing list