• Resolved KZeni

    (@kzeni)


    I tried clicking the “X” to dismiss the quota exceeded notice on a site’s Dashboard (running 5.0.2 of the plugin), and it appears nothing happens.

    Checking the JS console shows an error of Uncaught TypeError: $ is not a function. I’m guessing this might be a simple matter of swapping $ out for jQuery for the script being used to hide the notice.

    Meanwhile, it does hide the notice on refresh… it just doesn’t go away or otherwise appear to do anything when the “X” is clicked. Hopefully swapping $ out for jQuery in the various spot(s) is all that’s needed here.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Pedro

    (@petredobrescu)

    Dear @kzeni,

    Can you please check this with version 5.0.3 (just released) and let me know if it’s resolved?

    Thank you!
    Pedro/ShortPixel dev team

    Thread Starter KZeni

    (@kzeni)

    It seems it still is problematic in 5.0.3.

    There’s still

    jQuery(document).ready(function(){ 
    function shortpixel_notice_dismiss(event) {
                        event.preventDefault();
                        var ev = event.detail;
                        var target = event.target;
                        var parent = target.parentElement;
                        console.log(ev);
                        var data = {
                          'plugin_action': 'dismiss',
                          'action' : 'ShortPixel-notices',
                          'nonce' : '9728a764b6',
                        }
                        data.time = target.getAttribute('data-dismiss');
                        data.id = parent.getAttribute('id');
                        jQuery.post("https:\/\/www.amperagemarketing.com\/wp-admin\/admin-ajax.php",data);
    
                        $(parent).fadeTo(100,0,function() {
                            $(parent).slideUp(100, 0, function () {
                                $(parent).remove();
                            })
                        });
              } jQuery("#Error100").find(".notice-dismiss").on("click", shortpixel_notice_dismiss); 
    });

    being loaded onto the page where it has $ used in various spots that should be switched to jQuery as JS debug still shows the Uncaught TypeError: $ is not a function error when trying to dismiss a ShortPixel notice in the site admin (it then pointing specifically to the shortpixel_notice_dismiss() function containing the problematic code.)

    There’s also:

    var el = document.getElementById('$id');
                                      var el = document.getElementById('$id');
                               				$(el).fadeTo(100,0,function() {
                               				jQuery(el).fadeTo(100,0,function() {
                                   		$(el).slideUp(100, 0, function () {
                                   		jQuery(el).slideUp(100, 0, function () {
                                      $(el).remove();
                                      jQuery(el).remove();
                                   })

    which may cause a similar $ issue due to jQuery noconflict or some other $ conflict.

    My guess is that switching out that code for:

    jQuery(document).ready(function(){ 
    function shortpixel_notice_dismiss(event) {
                        event.preventDefault();
                        var ev = event.detail;
                        var target = event.target;
                        var parent = target.parentElement;
                        console.log(ev);
                        var data = {
                          'plugin_action': 'dismiss',
                          'action' : 'ShortPixel-notices',
                          'nonce' : '9728a764b6',
                        }
                        data.time = target.getAttribute('data-dismiss');
                        data.id = parent.getAttribute('id');
                        jQuery.post("https:\/\/www.amperagemarketing.com\/wp-admin\/admin-ajax.php",data);
    
                        jQuery(parent).fadeTo(100,0,function() {
                            jQuery(parent).slideUp(100, 0, function () {
                                jQuery(parent).remove();
                            })
                        });
              } jQuery("#Error100").find(".notice-dismiss").on("click", shortpixel_notice_dismiss); 
    });

    as well as:

    var el = document.getElementById('$id');
                               				jQuery(el).fadeTo(100,0,function() {
                                   		jQuery(el).slideUp(100, 0, function () {
                                      jQuery(el).remove();
                                   })

    respectively will address the issue (again just swap out the few remaining instances of $ in the script for jQuery with the .fadeTo, .slideUp, and .remove functions that are called after the .post AJAX call completes.)

    Thread Starter KZeni

    (@kzeni)

    I’ve gone ahead and created a PR on GitHub at: https://github.com/short-pixel-optimizer/shortpixel-image-optimiser/pull/99

    It seems this similar bit of code is also present in one other spot in that file so I’ve updated both to avoid this issue.

    Plugin Support Gerard Blanco

    (@sixaxis)

    Thanks for the PR, KZeni!

    Thread Starter KZeni

    (@kzeni)

    I appreciate the quick updates on this stuff!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Quota Exceeded Notice Doesn’t Appear to be Dismissed on Dashboard’ is closed to new replies.