• ResolvedPlugin Author csskevin

    (@csskevin)


    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
    Due 1.12 is lower than 1.7 the script tries to use the live function, which is deprecated since 1.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

    • This topic was modified 4 years, 3 months ago by csskevin.
    • This topic was modified 4 years, 3 months ago by csskevin.
Viewing 8 replies - 16 through 23 (of 23 total)
  • rcain

    (@rcain)

    Just to let people know, as of the current date and version (3.0.6.3) that in order to patch this bug, you will need to apply BOTH:

    – the first solution provided by @csskevin above

    AND

    – the two changes further from github also provided by @csskevin (further down)

    – and ALSO remember to rebuild all associated .min versions of the modified js files!

    Big thanks for your work @csskevin ! ??

    Developers: a fix for this bug has been outstanding for quite a while now – please can we know when a properly fixed version will be available? Many thanks.

    Plugin Author csskevin

    (@csskevin)

    Hey,

    To apply the latest bug (version 3.0.6.3) the easiest way is to replace the js/dist/wp-lightbox-2.min.js with the latest commit on the github repo: Here is the raw file: https://raw.githubusercontent.com/awesomemotive/wp-lightbox-2/master/js/dist/wp-lightbox-2.min.js
    Just replace the file content with it from github

    To apply the bug of version 3.0.6.2 and below all you need to do is, replace the snippet code

    
    if(parseFloat($().jquery) >= 1.7){
      return $(this).on("click", onClick);
    } else {
      return $(this).live("click", onClick); //deprecated since 1.7
    }		
    

    in wp-lightbox-2.js as well in wp-lightbox-2.min.js with

    
    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);
    }
    

    Just an update for the next release: @rcain
    The latest commit already contains everything for the release 3.0.6.4. As the review is done, the new version will be pushed to production.
    It shouldn’t take too long anymore and the version will be released in the next few days.

    rcain

    (@rcain)

    Thanks for the update ??

    Moderator Yui

    (@fierevere)

    永子

    It seems that option to reduce large images to fit the screen is not working in 3.0.6.4

    Plugin Author csskevin

    (@csskevin)

    @fierevere Sorry, for the late response: Which WordPress version do you use? I’ll keep looking to fix this bug with the next release.

    Moderator Yui

    (@fierevere)

    永子

    5.4 at that site.
    There are 2 “obstacles” to update to 5.5 or 5.6
    older wp-lightbox-2 is one of them.

    Plugin Author csskevin

    (@csskevin)

    The bug fix is included in the latest pull request.
    https://github.com/awesomemotive/wp-lightbox-2/pull/3

    After review the new version will be released.

    Plugin Author csskevin

    (@csskevin)

    There is now a new version of Wp-Lightbox 2 available, which fixes this bug.

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘Bug in WordPress 5.5 – Solution provided’ is closed to new replies.