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.

What's the proper way for loading a script via WordPress that isn't in a .js file?
I'm generating some javascript on the fly based on some field options in a plugin. I want to load it into the page, but I want to do it the right way.

How should I proceed?

share|improve this question
1  
This will help you wordpress.stackexchange.com/questions/24851/… –  Vinod Dalvi Sep 9 '13 at 16:45
    
That great, wp_localize_script worked perfect. Nice and clean, thanks! –  paper_robots Sep 9 '13 at 17:04
    
Add it as an answer ans accept it. –  Vinod Dalvi Sep 9 '13 at 17:38

1 Answer 1

I ended up using wp_localize_script(). This allowed me just to send the PHP variables as parameters directly to a javascript file. Also useful for doing translations in javascript files. And then I didn't have to do messy inline javascript.

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.