admin管理员组文章数量:1279055
I am trying to manually use the accordion tool from wpbakery. Now before my question gets closed, my question is not about wpbakery.
My question is how to load the correct scripts so that the accordion will work without actually using an accordion function in the page edit screen.
If editing a page and I add my short code (which adds HTML similar to the output that would be made if I added an accordion option from the wp-bakery edit screen), then on the front end that page doesn't present the accordion function correctly. however if i add an accordion from my edit screen, then both the accordion and my shortcode output accordions on the front and both work perfectly.
I think it is because wp-bakery has a function that says "if you are using our accordion option, enqueue our js".
I had verified this by checking that this script is loaded when I add an accordion properly:
<script type='text/javascript' src='.min.js?ver=6.7.0' id='vc_accordion_script-js'></script>
is loaded, but otherwise it's not.
So I tried adding this code to functions.php:
function enqueue_scripts_style_page_content_using_shortcode(){
wp_enqueue_script('vc_accordion_script-js');
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts_only_if_page_using_shortcode' );
as well as
function enqueue_scripts_style_page_content_using_shortcode(){
wp_enqueue_script('vc_accordion_script-js', '.min.js');
}
add_action( 'wp_enqueue_scripts', 'enqueue_scripts_only_if_page_using_shortcode' );
However, neither load the script.
So my question is how to make sure this script is loaded even if I don't actually use the accordion widget from the plugin?
本文标签: How can I manually enqueue plugin scripts
版权声明:本文标题:How can I manually enqueue plugin scripts 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741213242a2359543.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论