• So I have a plugin that gets a bunch of values that I want to pass to my javascript.

    I know localize_script will output data but I also want a to write out a function call in it.

    For example my plugin gets a value of “apple”. Once it does I want to place this in the footer

    <script>
    var myVar = ‘apples’;
    my_function_call(myVar);
    </script>

    Well not exactly but you get the idea. I just want to print it out, and not enqueue a script file.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter lerizzle

    (@lerizzle)

    oh and I need to make sure this gets outputted after my other footer scripts which are called enqueue.

    Thread Starter lerizzle

    (@lerizzle)

    So I was able to do this

    add_action(‘wp_print_footer_scripts’, ‘add_footer_js’, 10, 1);

    But now my question is, how do I pass parameters to this function. The only was I can see is make them globals so they are available to my function?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘adding inline script’ is closed to new replies.