Multiple versions of the same jquery plugin being loaded by wordpress plugins
I am using two wordpress plugins WP-Cycle and NextGen-Gallery. Both these plugins use jquery cycle plugin. Is there any 开发者_如何学运维way to avoid this in the theme?
I see the following error in firebug:
[cycle] terminating; zero elements found by selector
I think this is causing one of my other jquery script to function incorrectly.
The page with the issue is: http://www.rakshakfoundation.org/temp-2/
The script that is not functioning correctly: http://www.rakshakfoundation.org/wp-content/plugins/gravityforms/js/conditional_logic.js?ver=1.5.2
Thanks
What is the plugin supposed to do? It seems that this is not an error, rather, it's debugging output. My guess is that the dev wisely is checking for some kind of element before the routine is run. Since no elements were found, the routine isn't run and a debugging message is printed out. There are no JS errors occurring. My guess is that the plugin attempts to do whatever it is supposed to do (perhaps an operation on some images), but since no matching elements are found, the sequence is terminated. As far as I can tell, the plugin seems to be doing it's job.
The Cycle plugin is indeed being loaded twice because each plugin loads a different version under a different handle. WP-Cycle enqueues the plugin as 'cycle' whereas nextegen enqueues it as 'jquery-cycle'.
What you want to do is manually override the loading of one of these (assuming both will work with the latest version of the jQuery plugin) by editing the functions.php file in your theme's directory and adding the line.
<?php wp_deregister_script( 'jquery-cycle' ); ?>
That should work, but if not you can edit nggallery.php and comment out the line
wp_register_script('jquery-cycle', NGGALLERY_URLPATH .'js/jquery.cycle.all.min.js', array('jquery'), '2.88');
精彩评论