Are inline javascript in function.php for themeforest themes allowed?



I am new in themeforest. i have a code in function.php

function test_function(){

 // do something


Can i do this ?? If not how to do it without being soft reject.
Thanks in advance


use wp_add_inline_script

BTW, you probably know this, but just to be clear: you should use inline JS only if it is really necessary, like some variables generated via PHP and stuff like that. All static code should be in .js file.


Thanks for the answer. I tried that and wp_add_inline_script() doesn’t wok for me. So from your answer it is possible to use inline js. thanks for that.


Yes it is possible, via wp_add_inline_script. If it doesn’t work for you, then you are very likely doing something wrong.