Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I just learned about wp_localize_script() and it's very cool. I read Otto's post and Gary Cao's post, but I'm learning Ajax so I'm trying to wrap my head around getting the path to wp-load.php this way.

I have array like this in my test env:

$data = array(
'test' => 'test2',
'wp_get_site_url' => get_site_url(),
'wp_abspath' => ABSPATH,
'wp_load' => get_site_url() . '/wp-load.php',  
'foo' => 'bar',
'setting' => 123 );

Inside my plugin, how to declare data.wp_load (dynamic) path?

<script>How_Do_I_Declare data.wpload; alert('thanks'); </script>

If I'm doing things wrong, I'd love your help. I'm currently reading Ajax_In_Plugins as I type this. Thanks.

share|improve this question
    
When you're viewing your site, its already loaded, otherwise nothing will work. What exactly are you trying to do? –  passatgt Apr 7 at 14:01
    
Sorry I wasn't clear. I updated my subject. I'm trying to dynamically get path to wp-load.php within my plugin and avoid using /../../../wp-load.php thanks. –  Tai Sem Apr 7 at 14:05
    
You should not have to bother to include wp-load.php yourself. Post your Ajax requests to admin-ajax.php and you're done. What are you trying to do ? –  Fabien Quatravaux Apr 7 at 14:08
    
Nevermind. After reading AJAX_in_Plugins I'm doing this all wrong, haha. We can close this topic. Thanks –  Tai Sem Apr 7 at 14:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.