Bug in WordPress 5.5 – Solution provided
-
Hey,
First of all, this is a great project.
However with the new version of WordPress I have figured out an issue. The lightbox is not displayed in the new version.The error is caused by this code snipped in wp-lightbox-2.js of your plugin root folder:
if(parseFloat($().jquery) >= 1.7){ return $(this).on("click", onClick); } else { return $(this).live("click", onClick); //deprecated since 1.7 }
The thing is WordPress 5.5 is using jQuery 1.12
Due1.12
is lower than1.7
the script tries to use thelive
function, which is deprecated since1.7
, obviously.I would suggest to compare the jQuery version with the major and minor version.
Here is my solution:
var currentJqueryVersion = $().jquery; var splittedJqueryVersion = currentJqueryVersion.split("."); if(splittedJqueryVersion.length >= 2) { var majorVersion = parseInt(splittedJqueryVersion[0]); var minorVersion = parseInt(splittedJqueryVersion[1]); if(majorVersion >= 1 && minorVersion >= 7) { return $(this).on("click", onClick); } else { return $(this).live("click", onClick); //deprecated since 1.7 } } else { throw new Error("jQuery version could not be determined. jQuery version: " + currentJqueryVersion); }
Feel free to use this snippet.
Kind regards,
csskevin
- The topic ‘Bug in WordPress 5.5 – Solution provided’ is closed to new replies.