In this article, we will take an in-depth look at the conflicts between certain themes and plugins from a WordPress website and how these issues can be addressed.
Quick Fix of Themes/Plugins Conflicts
Note: This solution involves editing some PHP code in your theme or plugin files. If you are not familiar with the WordPress code editor or you’re unsure of what you’re doing it’s safer to ask for assistance, by opening a support conversation.
The most common cause of conflicts is different versions of jQuery loaded directly by one of your plugins or your theme.
WordPress comes with jQuery included in /wp-includes/js/jquery/ and every theme and plugin should load it from there. However, some developers choose to include a different version of jQuery in their products and this might cause issues with TCB.
If you read this entry and you identified the plugin/theme causing this, there’s a chance that you can easily fix the issue with minimum code editing.
How jQuery is Supposed to be Loaded
This single line does the trick. jQuery is already included in WordPress, so this one call is enough to load it in the theme/plugin.
Where is jQuery Loaded
Themes usually load it in their functions.php or header.php files. Some frameworks have different structures so you might be looking for some sort of theme-scripts.php file. Plugins can load it in their main php file, but this also varies.
What am I Looking For and How to Fix it
To check out your theme’s files, go to Appearance >> Editor and select one of the files I mentioned.
If you are investigating one of your plugins, go to Plugins >> Editor and select the plugin. Search (CTRL+F) for “jquery”. If you find the wp_enqueue_script(‘jquery’); line chances are (it’s a conflicting plugin after all) that it’s preceded by something like this:
wp_deregister_script('jquery');wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js", false, null);
These two lines of code basically remove a registered script and register a new one from Google CDN.
The solution is to simply comment out these two lines, thus leaving the default jquery script registered:
//wp_deregister_script('jquery');//wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js", false, null);
This is just an example of how this code can look in your files. There are other ways too, generally, if you see jQuery loaded from an external source, that’s the line that’s probably breaking TCB.