[wp-hackers] "deprecating" direct calls to wp-config.php

Otto otto at ottodestruct.com
Tue Nov 17 14:41:20 UTC 2009


Sounds like you're doing it wrong.

Where you load your javascript code is irrelevant. Load it on any page
you like, however you like.

The place where you load wp-config.php can be replaced by putting your
code in an action triggered by wp_ajax_whatever. That's the
difference.

And no, there is no reliable way to find and/or load wp-config. That's
simply the wrong way to do things, every single time. It's always been
the wrong way. And there's absolutely no guarantee that the method
will continue to work in the future.

-Otto



On Tue, Nov 17, 2009 at 8:33 AM, Olivier <autremonde75 at gmail.com> wrote:
> Hello,
>
> I saw this subject so I tried to adapt my plugins but no luck so far :
> (
> I have used the example provided on the CoDex.
>
> So I have removed the require_once wp-config.php
> Then I have encapsulated all my js/jQuery ajax code into a php
> function. Then I have hooked my function on admin_header and added a
> require_once for the file including my ajax function into my main
> plugin file but no luck, it doesn't work, the code is apparently not
> hit :(
>
> One issue I see about this change is that my ajax code will be loaded
> on every admin page while right now it was loaded only for the
> specific page it was intended to (thanks to the admin_print_scripts
> hook) so it will be a performance degradation.
>
> Isn't there any way to make everybody happy (ie finding a way to
> properly locate the wp-config.php whatever the installation path is?).
>
> Thanks!
>
> Olivier
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list