we've been developing wordpress theme , stumbled on weird problem. popup displayed bootstrap.js appears fraction of second , disappears. after thorough research have figured out problem caused plugin uses bootstrap.js. 2 bootstrap.js loaded, 1 our theme , plugin. how avoid conflict?
the solution check if bootstrap.js enqueued. i've added following functions.php of theme:
function enqueue_scripts() { // check if bootstrap there $bootstrap_enqueued = false; foreach( $wp_scripts->registered $script ) { if ((stristr($script->src, 'bootstrap.min.js') !== false or stristr($script->src, 'bootstrap.js') != false) , wp_script_is($script->handle, $list = 'enqueued')) { $bootstrap_enqueued = true; break; } } if (!$bootstrap_enqueued) { wp_enqueue_script( 'theme-bootstrap-js', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '2015', true ); } // note last parameter. it's important last in list of hooks add_action( 'wp_enqueue_scripts', 'enqueue_scripts', php_int_max );`
Comments
Post a Comment