admin管理员组文章数量:1291616
I work on a plugin and want to add an inline JS script once the place order button is hit on the checkout page (Woocommerce extension). In other words is there a way to add inline JS once wp_enqueue_scripts has already been fired?
I work on a plugin and want to add an inline JS script once the place order button is hit on the checkout page (Woocommerce extension). In other words is there a way to add inline JS once wp_enqueue_scripts has already been fired?
Share Improve this question asked Jun 11, 2021 at 8:26 81avas81avas 1 6 | Show 1 more comment1 Answer
Reset to default 1i don't know with version you use, but if you wan't load stuff on the initialisation of js you can have it on file using js :
( function( wp ) { your stuff } )( window.wp );
if you really want inline use in php ; https://developer.wordpress/reference/functions/wp_add_inline_script/
wp_add_inline_script( 'name_of_the_script_Woocommerce', <script> your thing</script>, 'after_or_before' );
本文标签: Adding inline JavaScript after wpenqueuescripts
版权声明:本文标题:Adding inline JavaScript after wp_enqueue_scripts 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741510578a2382584.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
wp_enqueue_scripts
has already been fired? Not sure. I think if you're looking to add inline JS after the enqueuing has already been done, and your theme supports it, you could stick some JS in using thewp_footer
hook. Not ideal, but will get the job done. – Paul G. Commented Jun 11, 2021 at 10:36