[wp-hackers] find wp-config from a plugin file

wordpress at santosj.name wordpress at santosj.name
Tue Jan 29 17:23:40 GMT 2008

> On Jan 29, 2008 7:46 AM, Jacob Santos <wordpress at santosj.name> wrote:
>> I think all of these are reasons why 'ABSPATH' exists.
> ABSPATH doesn't exist until you include wp-config.php.  In the plugins
> I've
> recently developed with ajax calls, I used the '../../../wp-config.php'
> method and I haven't had any complaints with it.
> --
> Dan Coulter
> http://www.dancoulter.com/
> http://www.phpflickr.com/
> It is time - http://e-hobo.com/
> Hey, I got nothing to do today but smile
> -Simon and Garfunkel

I don't like making assumptions when I write code. You assume that the
include path has '.' in it, which would make your relative link work. By
using ABSPATH when it is defined (if you are going to insinuate further),
you bypass those assumptions.

The only time I use relative paths like that is when my code defines the
include path and I always define both ABSPATH and set the include path to
that. It is all in the boot strap file.

Which going off what another said, your path would evaluate to
'./../../../wp-config.php', so I mean the entire argument is pointless,
which is what I was stating. You have so many ways, that universally,
using ABSPATH is by far the best one to achieve uniform results of "Where
is the top application folder?"

I could go on, but I think we are just talking in cycles. You obviously
know what you are talking about, so I'm not telling you anything that you
didn't know and you are basically doing the same. This is probably useful
for others who don't know, but there are many (better) resources for
finding out this information.

Jacob Santos

More information about the wp-hackers mailing list