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

Kimmo Suominen kimmo at global-wire.fi
Tue Jan 29 13:21:52 GMT 2008


On Tue, Jan 29, 2008 at 07:12:59AM -0600, Jacob Santos wrote:
> require_once( realpath( dirname(__FILE__) .'/../../wp_config.php');

Why not just

    require_once( '../../wp-config.php');

The dirname() and realpath() calls are not needed, as far as I can
tell.

Using require_once inside a strictly proceted with relative paths is
ok, as long as you don't mix something like this:

    require_once( '../../wp-config.php');
    require_once( './../../wp-config.php');
    require_once( '././../../wp-config.php');

In other words, leading "./" is going to be problematic and isn't
needed with WordPress.  WordPress already uses include statements
without a leading dot directory, and in my humble opinion should
get rid of the few include statements with leading single dot
directories.  This would make it work within a directory tree
where the whole path to the root directory (on a UNIX system) is
not readable (only executable, i.e. searchable).

Calling realpath() is another problem for strict permissions and
in every case I've seen in WordPress, completely unnecessary.

Best regards,
+ Kimmo
-- 
<A HREF="http://kimmo.suominen.com/">Kimmo Suominen</A>



More information about the wp-hackers mailing list