[wp-hackers] "deprecating" direct calls to wp-config.php
otto at ottodestruct.com
Tue Nov 3 17:05:04 UTC 2009
On Tue, Nov 3, 2009 at 9:43 AM, Claudio Simeone <mrbrog at gmail.com> wrote:
> what's the reason, in details, of discouraging direct calls of
> wp-config.php (or similar of wp-load.php)?
> Sometimes I include wp-load.php in scripts external to WP, so I can
> use e.g., database functions etc in those scripts.
> Is that correct, or is to be discouraged, and if so, what is the
> correct way to use WP environment in external scripts?
The correct way depends on what exactly you're doing. However, there's
never any real reason to include wp-config or wp-load directly. Doing
so is.. not wrong, exactly... just a bit sloppy. It's error-prone,
more likely to break things.
If you're doing AJAX like requests and need access to WordPress
functions, then you could use techniques similar to these:
For most anything else, hooking into the template_redirect function to
produce your custom output is the better way to go.
More information about the wp-hackers